Revision: 201003 default PDK_3.0.g
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 02 Feb 2010 00:17:27 +0200
changeset 0 d6fe6244b863
child 3 2703485a934c
Revision: 201003 Kit: 201005
creator/data/creator.rss
creator/data/creator_reg.rss
creator/files/3GPP-70kB.dat
creator/files/AAC-100kB.dat
creator/files/AMR-20kB.dat
creator/files/BMP-25kB.dat
creator/files/DOC-20kB.dat
creator/files/Deck-1kB.dat
creator/files/GIF-2kB.dat
creator/files/HTML-20kB.dat
creator/files/JAD-1kB.dat
creator/files/JAR-10kB.dat
creator/files/JP2-65kB.dat
creator/files/JPEG-200kB.dat
creator/files/JPEG-25kB.dat
creator/files/JPEG-500kB.dat
creator/files/MIDI-10kB.dat
creator/files/MP3-250kB.dat
creator/files/MP4-200kB.dat
creator/files/MXMF-40kB.dat
creator/files/PNG-15kB.dat
creator/files/PPT-40kB.dat
creator/files/RAM-1kB.dat
creator/files/RM-95kB.dat
creator/files/RNG-1kB.dat
creator/files/SISX-10kB.dat
creator/files/SVG-15kB.dat
creator/files/SWF-15kB.dat
creator/files/TIF-25kB.dat
creator/files/TXT-10kB.dat
creator/files/TXT-70kB.dat
creator/files/VCF-1kB.dat
creator/files/VCS-1kB.dat
creator/files/WAV-20kB.dat
creator/files/WMA-50kB.dat
creator/files/WMV-200kB.dat
creator/files/XLS-15kB.dat
creator/group/ReleaseNotes_Creator.txt
creator/group/backup_registration.xml
creator/group/bld.inf
creator/group/creator.mmp
creator/group/creator_icons_aif.mk
creator/group/creator_stub_sis.mk
creator/icons/qgn_menu_creator.svg
creator/inc/creator.hrh
creator/inc/creator.pan
creator/inc/creator_accesspoint.h
creator/inc/creator_app.h
creator/inc/creator_appui.h
creator/inc/creator_browser.h
creator/inc/creator_browserelement.h
creator/inc/creator_calendar.h
creator/inc/creator_calendarbase.h
creator/inc/creator_calendarelement.h
creator/inc/creator_connectionmethod.h
creator/inc/creator_connectionmethodbase.h
creator/inc/creator_connectionmethodelement.h
creator/inc/creator_contactelement.h
creator/inc/creator_contactsetcache.h
creator/inc/creator_container.h
creator/inc/creator_document.h
creator/inc/creator_factory.h
creator/inc/creator_file.h
creator/inc/creator_fileelement.h
creator/inc/creator_imps.h
creator/inc/creator_impselement.h
creator/inc/creator_landmark.h
creator/inc/creator_landmarkelement.h
creator/inc/creator_log.h
creator/inc/creator_logelement.h
creator/inc/creator_mailbox.h
creator/inc/creator_mailboxelement.h
creator/inc/creator_message.h
creator/inc/creator_messageelement.h
creator/inc/creator_model.h
creator/inc/creator_modulebase.h
creator/inc/creator_note.h
creator/inc/creator_noteelement.h
creator/inc/creator_phonebook.h
creator/inc/creator_phonebookbase.h
creator/inc/creator_randomdatafield.h
creator/inc/creator_randomdataparser.h
creator/inc/creator_scriptelement.h
creator/inc/creator_scriptelementfactory.h
creator/inc/creator_scriptentry.h
creator/inc/creator_scriptparser.h
creator/inc/creator_std.h
creator/inc/creator_traces.h
creator/inc/creator_virtualphonebook.h
creator/inc/creator_wepsecuritysettings.h
creator/rom/creator.iby
creator/scripts/browserEx.creatorxml
creator/scripts/calendarEx.creatorxml
creator/scripts/connectionmethodEx.creatorxml
creator/scripts/contactEx.creatorxml
creator/scripts/creator.xsd
creator/scripts/filesEx.creatorxml
creator/scripts/impsEx.creatorxml
creator/scripts/landmarkEx.creatorxml
creator/scripts/logEx.creatorxml
creator/scripts/mailboxEx.creatorxml
creator/scripts/messagesEx.creatorxml
creator/scripts/notepadEx.creatorxml
creator/sis/Creator_S60-30.pkg
creator/sis/Creator_S60-30.sis
creator/sis/Creator_S60-32.pkg
creator/sis/Creator_S60-32.sis
creator/sis/Creator_stub.pkg
creator/src/creator.cpp
creator/src/creator_accesspoint.cpp
creator/src/creator_app.cpp
creator/src/creator_appui.cpp
creator/src/creator_browser.cpp
creator/src/creator_browserelement.cpp
creator/src/creator_calendar.cpp
creator/src/creator_calendarelement.cpp
creator/src/creator_connectionmethod.cpp
creator/src/creator_connectionmethodelement.cpp
creator/src/creator_contactelement.cpp
creator/src/creator_contactsetcache.cpp
creator/src/creator_container.cpp
creator/src/creator_document.cpp
creator/src/creator_factory.cpp
creator/src/creator_file.cpp
creator/src/creator_fileelement.cpp
creator/src/creator_imps.cpp
creator/src/creator_impselement.cpp
creator/src/creator_landmark.cpp
creator/src/creator_landmarkelement.cpp
creator/src/creator_log.cpp
creator/src/creator_logelement.cpp
creator/src/creator_mailbox.cpp
creator/src/creator_mailboxelement.cpp
creator/src/creator_message.cpp
creator/src/creator_messageelement.cpp
creator/src/creator_model.cpp
creator/src/creator_note.cpp
creator/src/creator_noteelement.cpp
creator/src/creator_phonebook.cpp
creator/src/creator_phonebookbase.cpp
creator/src/creator_randomdataparser.cpp
creator/src/creator_scriptelement.cpp
creator/src/creator_scriptelementfactory.cpp
creator/src/creator_scriptentry.cpp
creator/src/creator_scriptparser.cpp
creator/src/creator_virtualphonebook.cpp
creator/src/creator_wepsecuritysettings.cpp
filebrowser/data/filebrowser.rss
filebrowser/data/filebrowser_reg.rss
filebrowser/envpatcher/EnvPatcher.pl
filebrowser/envpatcher/ReadMe.txt
filebrowser/fileopclient/BWINS/FileBrowserFileOpClientU.DEF
filebrowser/fileopclient/eabi/FileBrowserFileOpClientu.def
filebrowser/fileopclient/group/FBFileOpClient.mmp
filebrowser/fileopclient/group/bld.inf
filebrowser/fileopclient/inc/FBFileOpClient.h
filebrowser/fileopclient/inc/FBFileOpClientServer.h
filebrowser/fileopclient/src/FBFileOpClient.cpp
filebrowser/fileopserver/group/FBFileOpServer.mmp
filebrowser/fileopserver/group/bld.inf
filebrowser/fileopserver/inc/FBDrivePartitioner.h
filebrowser/fileopserver/inc/FBFileOpServer.h
filebrowser/fileopserver/src/FBDrivePartitioner.cpp
filebrowser/fileopserver/src/FBFileOpServer.cpp
filebrowser/group/ReleaseNotes_FileBrowser.txt
filebrowser/group/backup_registration.xml
filebrowser/group/bld.inf
filebrowser/group/filebrowser.mmp
filebrowser/group/filebrowser_extraicons.mk
filebrowser/group/filebrowser_icons_aif.mk
filebrowser/group/filebrowser_stub_sis.mk
filebrowser/helpertools/snapshot_compare_dirs.pl
filebrowser/icons/qgn_indi_tb_filebrowser_find.svg
filebrowser/icons/qgn_indi_tb_filebrowser_folder_parent.svg
filebrowser/icons/qgn_indi_tb_filebrowser_selection.svg
filebrowser/icons/qgn_indi_tb_filebrowser_selection_active.svg
filebrowser/icons/qgn_menu_filebrowser.svg
filebrowser/inc/FB.hrh
filebrowser/inc/FBApp.h
filebrowser/inc/FBAppUi.h
filebrowser/inc/FBDocument.h
filebrowser/inc/FBFileDlgs.h
filebrowser/inc/FBFileEditor.h
filebrowser/inc/FBFileListContainer.h
filebrowser/inc/FBFileListView.h
filebrowser/inc/FBFileOps.h
filebrowser/inc/FBFileUtils.h
filebrowser/inc/FBModel.h
filebrowser/inc/FBSettingViewDlg.h
filebrowser/inc/FBStd.h
filebrowser/inc/FBToolbar.h
filebrowser/inc/FBTraces.h
filebrowser/rom/filebrowser.iby
filebrowser/sis/FileBrowser_S60-30.pkg
filebrowser/sis/FileBrowser_S60-30.sis
filebrowser/sis/FileBrowser_S60-50.pkg
filebrowser/sis/FileBrowser_S60-50.sis
filebrowser/sis/FileBrowser_stub.pkg
filebrowser/src/FBApp.cpp
filebrowser/src/FBAppUi.cpp
filebrowser/src/FBDocument.cpp
filebrowser/src/FBFileDlgs.cpp
filebrowser/src/FBFileEditor.cpp
filebrowser/src/FBFileListContainer.cpp
filebrowser/src/FBFileListView.cpp
filebrowser/src/FBFileOps.cpp
filebrowser/src/FBFileUtils.cpp
filebrowser/src/FBModel.cpp
filebrowser/src/FBSettingViewDlg.cpp
filebrowser/src/FBToolbar.cpp
group/bld.inf
htiui/HtiAdmin/data/1020DEB6.rss
htiui/HtiAdmin/data/HtiAdmin.rss
htiui/HtiAdmin/data/HtiAdmin_reg.rss
htiui/HtiAdmin/group/HtiAdmin.mmp
htiui/HtiAdmin/group/bld.inf
htiui/HtiAdmin/inc/HtiAdmin.hrh
htiui/HtiAdmin/inc/HtiAdmin.pan
htiui/HtiAdmin/inc/HtiAdminAppUi.h
htiui/HtiAdmin/inc/HtiAdminAppView.h
htiui/HtiAdmin/inc/HtiAdminApplication.h
htiui/HtiAdmin/inc/HtiAdminDocument.h
htiui/HtiAdmin/src/HtiAdmin.cpp
htiui/HtiAdmin/src/HtiAdminAppUi.cpp
htiui/HtiAdmin/src/HtiAdminAppView.cpp
htiui/HtiAdmin/src/HtiAdminApplication.cpp
htiui/HtiAdmin/src/HtiAdminDocument.cpp
htiui/HtiCommPlugins/HtiBtCommPlugin/BWINS/HtiBtCommInterfaceu.def
htiui/HtiCommPlugins/HtiBtCommPlugin/BWINS/HtiBtCommServeru.def
htiui/HtiCommPlugins/HtiBtCommPlugin/BWINS/HtiBtSerialComHelperu.def
htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/BtSerialClient.h
htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/BtSerialEngine.pan
htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/HtiBtEngineLogging.h
htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/SocketObserver.h
htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/btservicesearcher.h
htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/btservicesearcher.pan
htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/messageprotocolconstants.h
htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/messageservicesearcher.h
htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/sdpattributenotifier.h
htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/sdpattributeparser.h
htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/sdpattributeparser.pan
htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/socketsreader.h
htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/socketswriter.h
htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/staticarrayc.h
htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/staticarrayc.inl
htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/timeoutnotifier.h
htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/timeouttimer.h
htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/src/BtSerialClient.cpp
htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/src/btservicesearcher.cpp
htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/src/messageservicesearcher.cpp
htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/src/sdpattributeparser.cpp
htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/src/socketsreader.cpp
htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/src/socketswriter.cpp
htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/src/timeouttimer.cpp
htiui/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommEcomPlugin/data/200212CB.rss
htiui/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommEcomPlugin/inc/HtiBtCommEcomPlugin.h
htiui/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommEcomPlugin/src/HtiBtCommEcomPlugin.cpp
htiui/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommEcomPlugin/src/proxy.cpp
htiui/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommServer/inc/HtiBtClientServerCommon.h
htiui/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommServer/inc/HtiBtCommInterface.h
htiui/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommServer/inc/HtiBtCommServer.h
htiui/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommServer/inc/HtiBtCommServerSession.h
htiui/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommServer/inc/Logger.h
htiui/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommServer/src/HtiBtCommInterface.cpp
htiui/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommServer/src/HtiBtCommServer.cpp
htiui/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommServer/src/HtiBtCommServerSession.cpp
htiui/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommServer/src/Logger.cpp
htiui/HtiCommPlugins/HtiBtCommPlugin/eabi/HtiBtCommInterfaceu.def
htiui/HtiCommPlugins/HtiBtCommPlugin/eabi/HtiBtCommServeru.def
htiui/HtiCommPlugins/HtiBtCommPlugin/eabi/HtiBtSerialComHelperu.def
htiui/HtiCommPlugins/HtiBtCommPlugin/group/HtiBtComm.cfg
htiui/HtiCommPlugins/HtiBtCommPlugin/group/HtiBtCommEcomPlugin.mmp
htiui/HtiCommPlugins/HtiBtCommPlugin/group/HtiBtCommInterface.mmp
htiui/HtiCommPlugins/HtiBtCommPlugin/group/HtiBtCommServer.mmp
htiui/HtiCommPlugins/HtiBtCommPlugin/group/HtiBtSerialComHelper.mmp
htiui/HtiCommPlugins/HtiBtCommPlugin/group/bld.inf
htiui/HtiDeviceReboot/group/HtiDeviceReboot.mmp
htiui/HtiDeviceReboot/group/bld.inf
htiui/HtiDeviceReboot/src/HtiDeviceReboot.cpp
htiui/HtiServicePlugins/HtiAppServicePlugin/bwins/HtiAppControlu.def
htiui/HtiServicePlugins/HtiAppServicePlugin/eabi/HtiAppControlu.def
htiui/HtiServicePlugins/HtiAppServicePlugin/group/HtiAppControl.mmp
htiui/HtiServicePlugins/HtiAppServicePlugin/group/bld.inf
htiui/HtiServicePlugins/HtiAppServicePlugin/inc/HtiAppControl.h
htiui/HtiServicePlugins/HtiAppServicePlugin/src/HtiAppControl.cpp
htiui/HtiServicePlugins/HtiAudioServicePlugin/data/1020DEC8.rss
htiui/HtiServicePlugins/HtiAudioServicePlugin/group/HtiAudioServicePlugin.mmp
htiui/HtiServicePlugins/HtiAudioServicePlugin/group/bld.inf
htiui/HtiServicePlugins/HtiAudioServicePlugin/inc/HtiAudioServicePlugin.h
htiui/HtiServicePlugins/HtiAudioServicePlugin/src/HtiAudioServicePlugin.cpp
htiui/HtiServicePlugins/HtiAudioServicePlugin/src/proxy.cpp
htiui/HtiServicePlugins/HtiFtpBackupFake/bwins/HtiFtpBackupFakeu.def
htiui/HtiServicePlugins/HtiFtpBackupFake/eabi/HtiFtpBackupFakeu.def
htiui/HtiServicePlugins/HtiFtpBackupFake/group/HtiFtpBackupFake.mmp
htiui/HtiServicePlugins/HtiFtpBackupFake/group/bld.inf
htiui/HtiServicePlugins/HtiFtpBackupFake/inc/HtiFtpBackupFake.h
htiui/HtiServicePlugins/HtiFtpBackupFake/src/HtiFtpBackupFake.cpp
htiui/HtiServicePlugins/HtiKeyEventServicePlugin/data/1020DEC0.rss
htiui/HtiServicePlugins/HtiKeyEventServicePlugin/group/HtiKeyEventServicePlugin.mmp
htiui/HtiServicePlugins/HtiKeyEventServicePlugin/group/bld.inf
htiui/HtiServicePlugins/HtiKeyEventServicePlugin/inc/HtiKeyEventServicePlugin.h
htiui/HtiServicePlugins/HtiKeyEventServicePlugin/inc/KeyEventHandler.h
htiui/HtiServicePlugins/HtiKeyEventServicePlugin/inc/PointerEventHandler.h
htiui/HtiServicePlugins/HtiKeyEventServicePlugin/src/HtiKeyEventServicePlugin.cpp
htiui/HtiServicePlugins/HtiKeyEventServicePlugin/src/KeyEventHandler.cpp
htiui/HtiServicePlugins/HtiKeyEventServicePlugin/src/PointerEventHandler.cpp
htiui/HtiServicePlugins/HtiKeyEventServicePlugin/src/proxy.cpp
htiui/HtiServicePlugins/HtiMessagesServicePlugin/data/200212C5.rss
htiui/HtiServicePlugins/HtiMessagesServicePlugin/group/HtiMessagesServicePlugin.mmp
htiui/HtiServicePlugins/HtiMessagesServicePlugin/group/bld.inf
htiui/HtiServicePlugins/HtiMessagesServicePlugin/inc/HtiIAPHandler.h
htiui/HtiServicePlugins/HtiMessagesServicePlugin/inc/HtiMailboxHandler.h
htiui/HtiServicePlugins/HtiMessagesServicePlugin/inc/HtiMessagesServicePlugin.h
htiui/HtiServicePlugins/HtiMessagesServicePlugin/inc/HtiMsgSettingsHandler.h
htiui/HtiServicePlugins/HtiMessagesServicePlugin/inc/MessageMgmntHandler.h
htiui/HtiServicePlugins/HtiMessagesServicePlugin/src/HtiIAPHandler.cpp
htiui/HtiServicePlugins/HtiMessagesServicePlugin/src/HtiMailboxHandler.cpp
htiui/HtiServicePlugins/HtiMessagesServicePlugin/src/HtiMessagesServicePlugin.cpp
htiui/HtiServicePlugins/HtiMessagesServicePlugin/src/HtiMsgSettingsHandler.cpp
htiui/HtiServicePlugins/HtiMessagesServicePlugin/src/MessageMgmntHandler.cpp
htiui/HtiServicePlugins/HtiMessagesServicePlugin/src/proxy.cpp
htiui/HtiServicePlugins/HtiPIMServicePlugin/data/200212C3.rss
htiui/HtiServicePlugins/HtiPIMServicePlugin/group/HtiNpdHlp.mmp
htiui/HtiServicePlugins/HtiPIMServicePlugin/group/HtiPIMServicePlugin.mmp
htiui/HtiServicePlugins/HtiPIMServicePlugin/group/bld.inf
htiui/HtiServicePlugins/HtiPIMServicePlugin/inc/HtiBookmarkHandler.h
htiui/HtiServicePlugins/HtiPIMServicePlugin/inc/HtiPIMServicePlugin.h
htiui/HtiServicePlugins/HtiPIMServicePlugin/inc/HtiSimDirHandlerVPbk.h
htiui/HtiServicePlugins/HtiPIMServicePlugin/inc/PIMHandler.h
htiui/HtiServicePlugins/HtiPIMServicePlugin/src/HtiBookmarkHandler.cpp
htiui/HtiServicePlugins/HtiPIMServicePlugin/src/HtiNpdHlp.cpp
htiui/HtiServicePlugins/HtiPIMServicePlugin/src/HtiPIMServicePlugin.cpp
htiui/HtiServicePlugins/HtiPIMServicePlugin/src/HtiSimDirHandlerVPbk.cpp
htiui/HtiServicePlugins/HtiPIMServicePlugin/src/PIMHandler.cpp
htiui/HtiServicePlugins/HtiPIMServicePlugin/src/proxy.cpp
htiui/HtiServicePlugins/HtiScreenshotServicePlugin/data/1020DEC2.rss
htiui/HtiServicePlugins/HtiScreenshotServicePlugin/group/HtiScreenshotServicePlugin.mmp
htiui/HtiServicePlugins/HtiScreenshotServicePlugin/group/bld.inf
htiui/HtiServicePlugins/HtiScreenshotServicePlugin/inc/HtiScreenshotServicePlugin.h
htiui/HtiServicePlugins/HtiScreenshotServicePlugin/inc/HtiTextRcg.h
htiui/HtiServicePlugins/HtiScreenshotServicePlugin/src/HtiScreenshotServicePlugin.cpp
htiui/HtiServicePlugins/HtiScreenshotServicePlugin/src/HtiTextRcg.cpp
htiui/HtiServicePlugins/HtiScreenshotServicePlugin/src/proxy.cpp
htiui/HtiServicePlugins/HtiSysInfoServicePlugin/data/10210CC6.rss
htiui/HtiServicePlugins/HtiSysInfoServicePlugin/group/HtiSysInfoServicePlugin.mmp
htiui/HtiServicePlugins/HtiSysInfoServicePlugin/group/bld.inf
htiui/HtiServicePlugins/HtiSysInfoServicePlugin/inc/HtiLightsController.h
htiui/HtiServicePlugins/HtiSysInfoServicePlugin/inc/HtiPropertySubscriber.h
htiui/HtiServicePlugins/HtiSysInfoServicePlugin/inc/HtiSysInfoServicePlugin.h
htiui/HtiServicePlugins/HtiSysInfoServicePlugin/src/HtiLightsController.cpp
htiui/HtiServicePlugins/HtiSysInfoServicePlugin/src/HtiPropertySubscriber.cpp
htiui/HtiServicePlugins/HtiSysInfoServicePlugin/src/HtiSysInfoServicePlugin.cpp
htiui/HtiServicePlugins/HtiSysInfoServicePlugin/src/proxy.cpp
htiui/HtiStartupWait/bwins/HtiStartupWaitu.def
htiui/HtiStartupWait/eabi/HtiStartupWaitu.def
htiui/HtiStartupWait/group/HtiStartupWait.mmp
htiui/HtiStartupWait/group/bld.inf
htiui/HtiStartupWait/inc/HtiStartupWait.h
htiui/HtiStartupWait/src/HtiStartupWait.cpp
htiui/group/bld.inf
htiui/group/hti_stub_sis.mk
htiui/rom/htiui.iby
htiui/sis/HTI_S60-51.pkg
htiui/sis/HTI_S60-52.pkg
htiui/sis/HTI_stub.pkg
htiui/symbian_version.hrh
launcher/data/launcher.rss
launcher/data/launcher_reg.rss
launcher/envpatcher/EnvPatcher.pl
launcher/envpatcher/ReadMe.txt
launcher/group/ReleaseNotes_Launcher.txt
launcher/group/backup_registration.xml
launcher/group/bld.inf
launcher/group/launcher.mmp
launcher/group/launcher_icons_aif.mk
launcher/group/launcher_stub_sis.mk
launcher/icons/qgn_menu_launcher.svg
launcher/inc/e32image.h
launcher/inc/e32imageheaders.h
launcher/inc/launcher.hrh
launcher/inc/launcher.pan
launcher/inc/launcherapplication.h
launcher/inc/launcherappui.h
launcher/inc/launchercontainerapps.h
launcher/inc/launchercontaineroutput.h
launcher/inc/launcherdllelement.h
launcher/inc/launcherdllparser.h
launcher/inc/launcherdocument.h
launcher/inc/launcherengine.h
launcher/inc/launcherparserobserver.h
launcher/inc/launchertraces.h
launcher/inc/launcherviewapps.h
launcher/inc/launcherviewoutput.h
launcher/inc/launcherxmlparser.h
launcher/rom/Launcher.iby
launcher/sis/Launcher_S60-30.pkg
launcher/sis/Launcher_S60-30.sis
launcher/sis/Launcher_stub.pkg
launcher/src/e32image.cpp
launcher/src/launcher.cpp
launcher/src/launcherapplication.cpp
launcher/src/launcherappui.cpp
launcher/src/launchercontainerapps.cpp
launcher/src/launchercontaineroutput.cpp
launcher/src/launcherdllelement.cpp
launcher/src/launcherdllparser.cpp
launcher/src/launcherdocument.cpp
launcher/src/launcherengine.cpp
launcher/src/launcherviewapps.cpp
launcher/src/launcherviewoutput.cpp
launcher/src/launcherxmlparser.cpp
layers.sysdef.xml
loadgen/data/loadgen.rss
loadgen/data/loadgen_reg.rss
loadgen/envpatcher/EnvPatcher.pl
loadgen/envpatcher/ReadMe.txt
loadgen/group/ReleaseNotes_LoadGen.txt
loadgen/group/backup_registration.xml
loadgen/group/bld.inf
loadgen/group/loadgen.mmp
loadgen/group/loadgen_extraicons.mk
loadgen/group/loadgen_icons_aif.mk
loadgen/group/loadgen_stub_sis.mk
loadgen/icons/qgn_menu_loadgen.svg
loadgen/icons/qgn_prob_status_green.svg
loadgen/icons/qgn_prob_status_red.svg
loadgen/inc/loadgen.hrh
loadgen/inc/loadgen_app.h
loadgen/inc/loadgen_applications.h
loadgen/inc/loadgen_appui.h
loadgen/inc/loadgen_bluetooth.h
loadgen/inc/loadgen_cpuload.h
loadgen/inc/loadgen_document.h
loadgen/inc/loadgen_editors.h
loadgen/inc/loadgen_keypress.h
loadgen/inc/loadgen_loadattributes.h
loadgen/inc/loadgen_loadbase.h
loadgen/inc/loadgen_maincontainer.h
loadgen/inc/loadgen_mainview.h
loadgen/inc/loadgen_memoryeat.h
loadgen/inc/loadgen_messages.h
loadgen/inc/loadgen_model.h
loadgen/inc/loadgen_netconn.h
loadgen/inc/loadgen_phonecall.h
loadgen/inc/loadgen_photocapture.h
loadgen/inc/loadgen_pointerevent.h
loadgen/inc/loadgen_settingsviewdlg.h
loadgen/inc/loadgen_std.h
loadgen/inc/loadgen_traces.h
loadgen/rom/loadgen.iby
loadgen/sis/LoadGen_S60-30.pkg
loadgen/sis/LoadGen_S60-30.sis
loadgen/sis/LoadGen_stub.pkg
loadgen/src/loadgen_app.cpp
loadgen/src/loadgen_applications.cpp
loadgen/src/loadgen_appui.cpp
loadgen/src/loadgen_bluetooth.cpp
loadgen/src/loadgen_cpuload.cpp
loadgen/src/loadgen_document.cpp
loadgen/src/loadgen_editors.cpp
loadgen/src/loadgen_keypress.cpp
loadgen/src/loadgen_loadbase.cpp
loadgen/src/loadgen_maincontainer.cpp
loadgen/src/loadgen_mainview.cpp
loadgen/src/loadgen_memoryeat.cpp
loadgen/src/loadgen_messages.cpp
loadgen/src/loadgen_model.cpp
loadgen/src/loadgen_netconn.cpp
loadgen/src/loadgen_phonecall.cpp
loadgen/src/loadgen_photocapture.cpp
loadgen/src/loadgen_pointerevent.cpp
loadgen/src/loadgen_settingsviewdlg.cpp
memspyui/data/Example_MemSpyProcessMemoryTrackingAutoStartConfig.xml
memspyui/data/MemSpyEComInterfaceIds.xml
memspyui/data/MemSpyProcessMemoryTrackingAutoStartConfig.xml
memspyui/data/backup_registration.xml
memspyui/data/memspyui.rss
memspyui/data/memspyui_reg.rss
memspyui/group/MemSpyCapabilities.mmh
memspyui/group/bld.inf
memspyui/group/memspyui.mmp
memspyui/group/memspyui_icons_aif.mk
memspyui/group/memspyui_stub_sis.mk
memspyui/icons/qgn_menu_memspyui.svg
memspyui/include/MemSpy.hrh
memspyui/include/MemSpyApp.h
memspyui/include/MemSpyAppUi.h
memspyui/include/MemSpyContainer.h
memspyui/include/MemSpyContainerObserver.h
memspyui/include/MemSpyDeviceWideOperationDialog.h
memspyui/include/MemSpyDocument.h
memspyui/include/MemSpyExportBitmapsToMemoryCardDialog.h
memspyui/include/MemSpySettings.h
memspyui/include/MemSpyUiUtils.h
memspyui/include/MemSpyViewBase.h
memspyui/include/MemSpyViewChunkList.h
memspyui/include/MemSpyViewCodeSegList.h
memspyui/include/MemSpyViewDriveInfo.h
memspyui/include/MemSpyViewECom.h
memspyui/include/MemSpyViewFBServBitmaps.h
memspyui/include/MemSpyViewHeapTracking.h
memspyui/include/MemSpyViewHeapTrackingResults.h
memspyui/include/MemSpyViewHeapTrackingSettings.h
memspyui/include/MemSpyViewKernel.h
memspyui/include/MemSpyViewKernelContainers.h
memspyui/include/MemSpyViewKernelHeap.h
memspyui/include/MemSpyViewKernelObjects.h
memspyui/include/MemSpyViewMainMenu.h
memspyui/include/MemSpyViewMemoryTrackingAutoStartConfig.h
memspyui/include/MemSpyViewObserver.h
memspyui/include/MemSpyViewOpenFiles.h
memspyui/include/MemSpyViewProcesses.h
memspyui/include/MemSpyViewRAMInfo.h
memspyui/include/MemSpyViewROMInfo.h
memspyui/include/MemSpyViewServerList.h
memspyui/include/MemSpyViewSystemConfig.h
memspyui/include/MemSpyViewThreadInfoItemActiveObject.h
memspyui/include/MemSpyViewThreadInfoItemChunk.h
memspyui/include/MemSpyViewThreadInfoItemCodeSeg.h
memspyui/include/MemSpyViewThreadInfoItemGeneralInfo.h
memspyui/include/MemSpyViewThreadInfoItemGeneric.h
memspyui/include/MemSpyViewThreadInfoItemHeap.h
memspyui/include/MemSpyViewThreadInfoItemList.h
memspyui/include/MemSpyViewThreadInfoItemMemoryTracking.h
memspyui/include/MemSpyViewThreadInfoItemServer.h
memspyui/include/MemSpyViewThreadInfoItemStack.h
memspyui/include/MemSpyViewThreads.h
memspyui/include/MemSpyViewType.h
memspyui/include/MemSpyViewWindowGroups.h
memspyui/include/viewcli.h
memspyui/memspywindowserverhelper/bwins/memspywindowserverhelperu.def
memspyui/memspywindowserverhelper/eabi/memspywindowserverhelperu.def
memspyui/memspywindowserverhelper/group/bld.inf
memspyui/memspywindowserverhelper/group/memspywindowserverhelper.mmp
memspyui/memspywindowserverhelper/inc/MemSpyEngineHelperWindowServerImpl.h
memspyui/memspywindowserverhelper/src/MemSpyEngineHelperWindowServerImpl.cpp
memspyui/rom/memspyui.iby
memspyui/sis/MemSpy_S60-50.pkg
memspyui/sis/MemSpy_S60-50.sis
memspyui/sis/MemSpy_S60-52.pkg
memspyui/sis/MemSpy_S60-52.sis
memspyui/sis/MemSpy_stub.pkg
memspyui/source/MemSpyApp.cpp
memspyui/source/MemSpyAppUi.cpp
memspyui/source/MemSpyContainer.cpp
memspyui/source/MemSpyDeviceWideOperationDialog.cpp
memspyui/source/MemSpyDocument.cpp
memspyui/source/MemSpyExportBitmapsToMemoryCardDialog.cpp
memspyui/source/MemSpySettings.cpp
memspyui/source/MemSpyUiUtils.cpp
memspyui/source/MemSpyViewBase.cpp
memspyui/source/MemSpyViewChunkList.cpp
memspyui/source/MemSpyViewCodeSegList.cpp
memspyui/source/MemSpyViewDriveInfo.cpp
memspyui/source/MemSpyViewECom.cpp
memspyui/source/MemSpyViewFBServBitmaps.cpp
memspyui/source/MemSpyViewHeapTracking.cpp
memspyui/source/MemSpyViewHeapTrackingResults.cpp
memspyui/source/MemSpyViewHeapTrackingSettings.cpp
memspyui/source/MemSpyViewKernel.cpp
memspyui/source/MemSpyViewKernelContainers.cpp
memspyui/source/MemSpyViewKernelHeap.cpp
memspyui/source/MemSpyViewKernelObjects.cpp
memspyui/source/MemSpyViewMainMenu.cpp
memspyui/source/MemSpyViewMemoryTrackingAutoStartConfig.cpp
memspyui/source/MemSpyViewOpenFiles.cpp
memspyui/source/MemSpyViewProcesses.cpp
memspyui/source/MemSpyViewRAMInfo.cpp
memspyui/source/MemSpyViewROMInfo.cpp
memspyui/source/MemSpyViewServerList.cpp
memspyui/source/MemSpyViewSystemConfig.cpp
memspyui/source/MemSpyViewThreadInfoItemActiveObject.cpp
memspyui/source/MemSpyViewThreadInfoItemChunk.cpp
memspyui/source/MemSpyViewThreadInfoItemCodeSeg.cpp
memspyui/source/MemSpyViewThreadInfoItemGeneralInfo.cpp
memspyui/source/MemSpyViewThreadInfoItemGeneric.cpp
memspyui/source/MemSpyViewThreadInfoItemHeap.cpp
memspyui/source/MemSpyViewThreadInfoItemList.cpp
memspyui/source/MemSpyViewThreadInfoItemMemoryTracking.cpp
memspyui/source/MemSpyViewThreadInfoItemServer.cpp
memspyui/source/MemSpyViewThreadInfoItemStack.cpp
memspyui/source/MemSpyViewThreads.cpp
memspyui/source/MemSpyViewType.cpp
memspyui/source/MemSpyViewWindowGroups.cpp
package_definition.xml
perfmon/data/perfmon.rss
perfmon/data/perfmon_reg.rss
perfmon/envpatcher/EnvPatcher.pl
perfmon/envpatcher/ReadMe.txt
perfmon/group/ReleaseNotes_PerfMon.txt
perfmon/group/backup_registration.xml
perfmon/group/bld.inf
perfmon/group/perfmon.mmp
perfmon/group/perfmon_icons_aif.mk
perfmon/group/perfmon_stub_sis.mk
perfmon/icons/qgn_menu_perfmon.svg
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/rom/perfmon.iby
perfmon/sis/PerfMon_S60-30.pkg
perfmon/sis/PerfMon_S60-30.sis
perfmon/sis/PerfMon_stub.pkg
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
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/icons/qgn_menu_screengrabber.svg
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/rom/screengrabber.iby
screengrabber/sis/ScreenGrabber_S60-30.pkg
screengrabber/sis/ScreenGrabber_S60-30.sis
screengrabber/sis/ScreenGrabber_S60-32.pkg
screengrabber/sis/ScreenGrabber_S60-32.sis
screengrabber/sis/ScreenGrabber_stub.pkg
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
stifui/group/ReleaseNote.txt
stifui/group/bld.inf
stifui/rom/Stifui.iby
stifui/sis/Stifui.pkg
stifui/sis/Stifui_31.sis
stifui/sis/Stifui_31_Stub.SIS
stifui/stifui/data/Stifui.rss
stifui/stifui/data/Stifui_reg.rss
stifui/stifui/group/Stifui.mmp
stifui/stifui/group/bld.inf
stifui/stifui/inc/AppUIApp.h
stifui/stifui/inc/AppUIAppUi.h
stifui/stifui/inc/AppUIDocument.h
stifui/stifui/inc/Container.h
stifui/stifui/inc/CreatedTestSetMenuContainer.h
stifui/stifui/inc/CreatedTestSetMenuView.h
stifui/stifui/inc/MainMenuContainer.h
stifui/stifui/inc/MainMenuView.h
stifui/stifui/inc/MenuListBox.h
stifui/stifui/inc/ShowStartedCasesContainer.h
stifui/stifui/inc/ShowStartedCasesView.h
stifui/stifui/inc/StartCasesContainer.h
stifui/stifui/inc/StartCasesView.h
stifui/stifui/inc/StartedCasesMenuContainer.h
stifui/stifui/inc/StartedCasesMenuView.h
stifui/stifui/inc/StatisticsContainer.h
stifui/stifui/inc/StatisticsView.h
stifui/stifui/inc/Stifui.hrh
stifui/stifui/inc/Stifui_loc.hrh
stifui/stifui/inc/TestCaseMenuContainer.h
stifui/stifui/inc/TestCaseMenuView.h
stifui/stifui/inc/TestCaseOutputContainer.h
stifui/stifui/inc/TestCaseOutputView.h
stifui/stifui/inc/TestModulesMenuContainer.h
stifui/stifui/inc/TestModulesMenuView.h
stifui/stifui/inc/TestSetBaseMenuContainer.h
stifui/stifui/inc/TestSetBaseMenuView.h
stifui/stifui/inc/TestSetInsertMenuContainer.h
stifui/stifui/inc/TestSetInsertMenuView.h
stifui/stifui/inc/TestSetMenuContainer.h
stifui/stifui/inc/TestSetMenuView.h
stifui/stifui/inc/TestSetStartedCasesContainer.h
stifui/stifui/inc/TestSetStartedCasesView.h
stifui/stifui/inc/UIStoreHandler.h
stifui/stifui/inc/View.h
stifui/stifui/inc/version.h
stifui/stifui/src/AppUIApp.cpp
stifui/stifui/src/AppUIAppUi.cpp
stifui/stifui/src/AppUIDocument.cpp
stifui/stifui/src/Container.cpp
stifui/stifui/src/CreatedTestSetMenuContainer.cpp
stifui/stifui/src/CreatedTestSetMenuView.cpp
stifui/stifui/src/MainMenuContainer.cpp
stifui/stifui/src/MainMenuView.cpp
stifui/stifui/src/MenuListBox.cpp
stifui/stifui/src/ShowStartedCasesContainer.cpp
stifui/stifui/src/ShowStartedCasesView.cpp
stifui/stifui/src/StartCasesContainer.cpp
stifui/stifui/src/StartCasesView.cpp
stifui/stifui/src/StartedCasesMenuContainer.cpp
stifui/stifui/src/StartedCasesMenuView.cpp
stifui/stifui/src/StatisticsContainer.cpp
stifui/stifui/src/StatisticsView.cpp
stifui/stifui/src/TestCaseMenuContainer.cpp
stifui/stifui/src/TestCaseMenuView.cpp
stifui/stifui/src/TestCaseOutputContainer.cpp
stifui/stifui/src/TestCaseOutputView.cpp
stifui/stifui/src/TestModulesMenuContainer.cpp
stifui/stifui/src/TestSetBaseMenuContainer.cpp
stifui/stifui/src/TestSetBaseMenuView.cpp
stifui/stifui/src/TestSetInsertMenuContainer.cpp
stifui/stifui/src/TestSetInsertMenuView.cpp
stifui/stifui/src/TestSetMenuContainer.cpp
stifui/stifui/src/TestSetMenuView.cpp
stifui/stifui/src/TestSetStartedCasesContainer.cpp
stifui/stifui/src/TestSetStartedCasesView.cpp
stifui/stifui/src/Testmodulesmenuview.cpp
stifui/stifui/src/UIStoreHandler.cpp
stifui/stifui/src/View.cpp
stifui/uitestserverstarter/data/UITestServerStarter.rls
stifui/uitestserverstarter/data/UITestServerStarter.rss
stifui/uitestserverstarter/data/UITestServerStarter_reg.rss
stifui/uitestserverstarter/group/UITestServerStarter.mmp
stifui/uitestserverstarter/group/bld.inf
stifui/uitestserverstarter/inc/AknUiEnvProxy.h
stifui/uitestserverstarter/inc/EventUtil.h
stifui/uitestserverstarter/inc/TestServerThreadStarter.h
stifui/uitestserverstarter/inc/UITestServerStarter.hrh
stifui/uitestserverstarter/inc/UITestServerStarterAppContainer.h
stifui/uitestserverstarter/inc/UITestServerStarterAppUi.h
stifui/uitestserverstarter/inc/UITestServerStarterAppView.h
stifui/uitestserverstarter/inc/UITestServerStarterApplication.h
stifui/uitestserverstarter/inc/UITestServerStarterDocument.h
stifui/uitestserverstarter/src/AknUiEnvProxy.cpp
stifui/uitestserverstarter/src/EventUtil.cpp
stifui/uitestserverstarter/src/TestServerThreadStarter.cpp
stifui/uitestserverstarter/src/UITestServerStarter.cpp
stifui/uitestserverstarter/src/UITestServerStarterAppContainer.cpp
stifui/uitestserverstarter/src/UITestServerStarterAppUi.cpp
stifui/uitestserverstarter/src/UITestServerStarterAppView.cpp
stifui/uitestserverstarter/src/UITestServerStarterApplication.cpp
stifui/uitestserverstarter/src/UITestServerStarterDocument.cpp
sysdef_1_4_0.dtd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/data/creator.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,2324 @@
+/*
+* 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:  
+*
+*/
+
+
+
+
+NAME MATT
+
+#include <eikon.rh>
+#include <eikon.rsg>
+#include <avkon.rh>
+#include <avkon.rsg>
+#include <avkon.mbg>
+#include <AvkonIcons.hrh>
+
+
+
+#include "creator.hrh"
+#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
+    {
+    menubar = r_creator_menubar;
+    cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
+    }
+
+
+// ---------------------------------------------------------
+//   
+//   r_creator_menubar
+//   Menubar for Creator
+//
+// ---------------------------------------------------------
+//
+RESOURCE MENU_BAR r_creator_menubar
+    {
+    titles =
+        {
+        MENU_TITLE {menu_pane = r_creator_menu;}
+        };
+    }
+
+
+// ---------------------------------------------------------
+//   
+//   r_creator_menu
+//   Menu for "Options"
+//
+// ---------------------------------------------------------
+//
+RESOURCE MENU_PANE r_creator_menu
+    {
+    items = 
+        {
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+        MENU_ITEM 
+            {
+            command = ECmdCreateFromFile;
+             txt = "Run script";
+            },
+#endif
+
+        MENU_ITEM 
+            {
+            command = ECmdCreateCalendarEntries;
+            cascade = r_creator_agendaentries_submenu;
+             txt = "Calendar";
+            },
+
+        MENU_ITEM 
+            {
+            command = ECmdCreateBrowserEntries;
+            cascade = r_creator_browserentries_submenu;
+             txt = "Browser";
+            },
+
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntries;
+            cascade = r_creator_fileentries_submenu;
+             txt = "Files";
+            },
+
+        MENU_ITEM 
+            {
+            command = ECmdCreateLogEntries;
+            cascade = r_creator_logentries_submenu;
+             txt = "Logs";
+            },
+
+        MENU_ITEM 
+            {
+            command = ECmdCreateMessagingEntries;
+            cascade = r_creator_messagingentries_submenu;
+             txt = "Messaging";
+            },
+
+        MENU_ITEM 
+            {
+            command = ECmdCreateMiscEntries;
+            cascade = r_creator_miscentries_submenu;
+             txt = "Misc";
+            },
+
+        MENU_ITEM 
+            {
+            command = ECmdCreatePhoneBookEntries;
+            cascade = r_creator_phonebookentries_submenu;
+             txt = "Phonebook";
+            },
+
+        MENU_ITEM 
+            {
+            command = ECmdDeleteEntries;
+            cascade = r_creator_deleteentries_submenu;
+            txt = "Delete";
+            },
+
+        MENU_ITEM 
+            {
+            command = ECmdSelectRandomDataFile;
+            txt = "Select random data file";
+            },
+
+        MENU_ITEM 
+            {
+            command = ECmdAboutCreator;
+            txt = "About Creator";
+            },
+
+        MENU_ITEM 
+            {
+            command = EAknSoftkeyExit;   
+            txt = "Exit";
+            }
+        };
+    }
+
+
+// ---------------------------------------------------------
+
+RESOURCE MENU_PANE r_creator_agendaentries_submenu
+    {
+    items = 
+        {
+        MENU_ITEM 
+            {
+            command = ECmdCreateCalendarEntryAppointments;
+            txt = "Appointments";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateCalendarEntryEvents;
+            txt = "Events";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateCalendarEntryAnniversaries;
+            txt = "Anniversaries";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateCalendarEntryToDos;
+            txt = "Todos";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateCalendarEntryReminders;
+            txt = "Reminders";
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+
+RESOURCE MENU_PANE r_creator_browserentries_submenu
+    {
+    items = 
+        {
+        MENU_ITEM 
+            {
+            command = ECmdCreateBrowserBookmarkEntries;
+            txt = "Bookmarks";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateBrowserBookmarkFolderEntries;
+            txt = "Bookmark folders";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateBrowserSavedPageEntries;
+            txt = "Saved pages";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateBrowserSavedPageFolderEntries;
+            txt = "Saved page folders";
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+
+RESOURCE MENU_PANE r_creator_fileentries_submenu
+    {
+    items = 
+        {
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryEmptyFolder;
+            txt = "Empty folder";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryJPEG_25kB;
+            txt = "JPEG 25kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryJPEG_200kB;
+            txt = "JPEG 200kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryJPEG_500kB;
+            txt = "JPEG 500kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryPNG_15kB;
+            txt = "PNG 15kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryGIF_2kB;
+            txt = "GIF 2kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryBMP_25kB;
+            txt = "BMP 25kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryJP2_65kB;
+            txt = "JP2 65kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntrySVG_15kB;
+            txt = "SVG 15kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryTIF_25kB;
+            txt = "TIF 25kB";
+            },                                                
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryRNG_1kB;
+            txt = "RNG 1kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryMIDI_10kB;
+            txt = "MIDI 10kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryWAV_20kB;
+            txt = "WAVE 20kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryAMR_20kB;
+            txt = "AMR 20kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryXLS_15kB;
+            txt = "Excel 15kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryDOC_20kB;
+            txt = "Word 20kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryPPT_40kB;
+            txt = "PowerPoint 40kB";
+            },
+        MENU_ITEM 
+            {            
+            command = ECmdCreateFileEntryTXT_10kB;
+            txt = "Text 10kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryTXT_70kB;
+            txt = "Text 70kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryHTML_20kB;
+            txt = "HTML 20kB";
+            },
+        /*MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryDeck_1kB;
+            txt = "Savedeck 1kB";
+            },*/
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryMXMF_40kB;
+            txt = "MXMF 40kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryRAM_1kB;
+            txt = "RAM 1kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryJAD_1kB;
+            txt = "JAD 1kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryJAR_10kB;
+            txt = "JAR 10kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryVCF_1kB;
+            txt = "VCF 1kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryVCS_1kB;
+            txt = "VCS 1kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntrySISX_10kB;
+            txt = "SISX 10kB";
+            },               
+        MENU_ITEM 
+            {                     
+            command = ECmdCreateFileEntry3GPP_70kB;
+            txt = "3GPP 70kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryMP3_250kB;
+            txt = "MP3 250kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryAAC_100kB;
+            txt = "AAC 100kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntrySWF_15kB;
+            txt = "SWF 15kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryMP4_200kB;
+            txt = "MP4 200kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryRM_95kB;
+            txt = "RM 95kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryWMA_50kB;
+            txt = "WMA 50kB";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateFileEntryWMV_200kB;
+            txt = "WMV 200kB";
+            }
+        };
+    }
+
+
+// ---------------------------------------------------------
+
+RESOURCE MENU_PANE r_creator_logentries_submenu
+    {
+    items = 
+        {
+        MENU_ITEM 
+            {
+            command = ECmdCreateLogEntryMissedCalls;
+            txt = "Missed calls";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateLogEntryReceivedCalls;
+            txt = "Received calls";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateLogEntryDialledNumbers;
+            txt = "Dialled numbers";
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+
+RESOURCE MENU_PANE r_creator_messagingentries_submenu
+    {
+    items = 
+        {
+/*        
+        MENU_ITEM 
+            {
+            command = ECmdCreateMessagingEntryCBSTopics;
+            txt = "CBS topics";
+            },
+        MENU_ITEM
+            {
+            command = ECmdCreateMessagingEntryDocumentsFolders;
+            txt = "Documents folders";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateMessagingEntrySMSMessageCenters;
+            txt = "SMS Message Centers";
+            },
+*/
+        MENU_ITEM 
+            {
+            command = ECmdCreateMessagingEntryMailboxes;
+            txt = "Mailboxes";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreateMessagingEntryMessages;
+            txt = "Messages";
+            }
+/*            
+            ,
+        MENU_ITEM 
+            {
+            command = ECmdCreateMessagingEntryTemplates;
+            txt = "Templates";
+            }
+*/
+        };
+    }
+
+// ---------------------------------------------------------
+
+RESOURCE MENU_PANE r_creator_miscentries_submenu
+    {
+    items = 
+        {
+      #if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+        MENU_ITEM 
+            {
+            command = ECmdCreateMiscEntryAccessPoints;
+             txt = "Access Points";
+            },
+                
+      #else
+        MENU_ITEM 
+            {
+            command = ECmdCreateMiscEntryAccessPoints;
+            txt = "Connection Methods";
+            },
+            
+      #endif                 
+            
+/*
+        MENU_ITEM 
+            {
+            command = ECmdCreateMiscEntryAppMenuFolders;
+             txt = "App menu folders";
+            },
+*/
+    #ifdef __PRESENCE
+        MENU_ITEM 
+            {
+            command = ECmdCreateMiscEntryIMPSServers;
+             txt = "IMPS servers";
+            },
+    #endif
+    
+        MENU_ITEM 
+            {
+            command = ECmdCreateMiscEntryNotes;
+             txt = "Notes";
+            }
+ 
+
+/*            
+            ,
+        MENU_ITEM 
+            {
+            command = ECmdCreateMiscEntrySyncSettings;
+             txt = "Sync settings";
+            }
+*/
+            ,
+        MENU_ITEM 
+            {
+            command = ECmdCreateMiscEntryLandmarks;
+            txt = "Landmarks";
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+
+RESOURCE MENU_PANE r_creator_phonebookentries_submenu
+    {
+    items = 
+        {
+        MENU_ITEM 
+            {
+            command = ECmdCreatePhoneBookEntryContacts;
+             txt = "Contacts";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdCreatePhoneBookEntryGroups;
+             txt = "Groups";
+            }
+/*            
+            ,
+        MENU_ITEM 
+            {
+            command = ECmdCreatePhoneBookEntrySubscribedContacts;
+             txt = "Subscribed contacts";
+            }
+*/
+        };
+    }
+
+// ---------------------------------------------------------
+
+RESOURCE MENU_PANE r_creator_deleteentries_submenu
+    {
+    items = 
+        {
+        MENU_ITEM 
+            {
+            command = ECmdDeleteAllEntries;
+            cascade = r_creator_deleteall_submenu;
+            txt = "All items";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdDeleteCalendarEntries;
+            cascade = r_creator_deletecalendar_submenu;
+            txt = "Calendar entries";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdDeleteBrowserBookmarks;
+            cascade = r_creator_deletebookmarks_submenu;
+            txt = "Br bookmarks";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdDeleteCreatorBrowserBookmarkFolders;
+            cascade = r_creator_deletebookmarkfolders_submenu;
+            txt = "Br bookmark folders";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdDeleteBrowserSavedPages;
+            cascade = r_creator_deletesavedpages_submenu;
+            txt = "Br saved pages";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdDeleteBrowserSavedPageFolders;
+            cascade = r_creator_deletesavedpagefolders_submenu;
+            txt = "Br saved page folders";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdDeleteCreatorFiles;
+            cascade = r_creator_deletefiles_submenu;
+            txt = "Files";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdDeleteLogs;
+            cascade = r_creator_deletelogs_submenu;
+            txt = "Logs";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdDeleteMessages;
+            cascade = r_creator_deletemessages_submenu;
+            txt = "Messages";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdDeleteIAPs; // ECmdDeleteMiscEntryAccessPoints
+            cascade = r_creator_deleteiaps_submenu;
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+            txt = "Access Points";
+#else
+            txt = "Connection methods";
+#endif
+            },
+        MENU_ITEM 
+            {
+            command = ECmdDeleteIMPSs;
+            cascade = r_creator_deleteimps_submenu;
+            txt = "IMPS servers";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdDeleteNotes;
+            cascade = r_creator_deletenotes_submenu;
+            txt = "Notes";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdDeleteLandmarks;
+            cascade = r_creator_deletelandmarks_submenu;
+            txt = "Landmarks";
+            },            
+        MENU_ITEM 
+            {
+            command = ECmdDeleteContacts;
+            cascade = r_creator_deletecontacts_submenu;
+            txt = "Contacts";
+            },
+        MENU_ITEM 
+            {
+            command = ECmdDeleteContactGroups;
+            cascade = r_creator_deletecontactgroups_submenu;
+            txt = "Contact groups";
+            }
+            
+        /*
+        MENU_ITEM 
+            {
+            command = ECmdDeleteMiscEntryAccessPoints;
+            txt = "All Connection Methods";
+            }
+        */
+        };
+    }
+
+#define string_creator_deletemenu_all "All"
+#define string_creator_deletemenu_by_creator "By Creator"
+
+// ---------------------------------------------------------
+RESOURCE MENU_PANE r_creator_deleteall_submenu
+    {
+    items =
+        {
+        MENU_ITEM
+            {
+            command = ECmdDeleteAllEntries;
+            txt = string_creator_deletemenu_all;
+            },
+        MENU_ITEM
+            {
+            command = ECmdDeleteAllCreatorEntries;
+            txt = string_creator_deletemenu_by_creator;
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+RESOURCE MENU_PANE r_creator_deletecalendar_submenu
+    {
+    items =
+        {
+        MENU_ITEM
+            {
+            command = ECmdDeleteCalendarEntries;
+            txt = string_creator_deletemenu_all;
+            },
+        MENU_ITEM
+            {
+            command = ECmdDeleteCreatorCalendarEntries;
+            txt = string_creator_deletemenu_by_creator;
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+RESOURCE MENU_PANE r_creator_deletebookmarks_submenu
+    {
+    items =
+        {
+        MENU_ITEM
+            {
+            command = ECmdDeleteBrowserBookmarks;
+            txt = string_creator_deletemenu_all;
+            },
+        MENU_ITEM
+            {
+            command = ECmdDeleteCreatorBrowserBookmarks;
+            txt = string_creator_deletemenu_by_creator;
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+RESOURCE MENU_PANE r_creator_deletebookmarkfolders_submenu
+    {
+    items =
+        {
+        MENU_ITEM
+            {
+            command = ECmdDeleteBrowserBookmarkFolders;
+            txt = string_creator_deletemenu_all;
+            },
+        MENU_ITEM
+            {
+            command = ECmdDeleteCreatorBrowserBookmarkFolders;
+            txt = string_creator_deletemenu_by_creator;
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+RESOURCE MENU_PANE r_creator_deletesavedpages_submenu
+    {
+    items =
+        {
+        MENU_ITEM
+            {
+            command = ECmdDeleteBrowserSavedPages;
+            txt = string_creator_deletemenu_all;
+            },
+        MENU_ITEM
+            {
+            command = ECmdDeleteCreatorBrowserSavedPages;
+            txt = string_creator_deletemenu_by_creator;
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+RESOURCE MENU_PANE r_creator_deletesavedpagefolders_submenu
+    {
+    items =
+        {
+        MENU_ITEM
+            {
+            command = ECmdDeleteBrowserSavedPageFolders;
+            txt = string_creator_deletemenu_all;
+            },
+        MENU_ITEM
+            {
+            command = ECmdDeleteCreatorBrowserSavedPageFolders;
+            txt = string_creator_deletemenu_by_creator;
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+RESOURCE MENU_PANE r_creator_deletefiles_submenu
+    {
+    items =
+        {
+        MENU_ITEM
+            {
+            command = ECmdDeleteCreatorFiles;
+            txt = string_creator_deletemenu_by_creator;
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+RESOURCE MENU_PANE r_creator_deletelogs_submenu
+    {
+    items =
+        {
+        MENU_ITEM
+            {
+            command = ECmdDeleteLogs;
+            txt = string_creator_deletemenu_all;
+            },
+        MENU_ITEM
+            {
+            command = ECmdDeleteCreatorLogs;
+            txt = string_creator_deletemenu_by_creator;
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+RESOURCE MENU_PANE r_creator_deletemailboxes_submenu
+    {
+    items =
+        {
+        MENU_ITEM
+            {
+            command = ECmdDeleteMailboxes;
+            txt = string_creator_deletemenu_all;
+            },
+        MENU_ITEM
+            {
+            command = ECmdDeleteCreatorMailboxes;
+            txt = string_creator_deletemenu_by_creator;
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+RESOURCE MENU_PANE r_creator_deletemessages_submenu
+    {
+    items =
+        {
+        MENU_ITEM
+            {
+            command = ECmdDeleteMessages;
+            txt = string_creator_deletemenu_all;
+            },
+        MENU_ITEM
+            {
+            command = ECmdDeleteCreatorMessages;
+            txt = string_creator_deletemenu_by_creator;
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+RESOURCE MENU_PANE r_creator_deleteiaps_submenu
+    {
+    items =
+        {
+        MENU_ITEM
+            {
+            command = ECmdDeleteIAPs;
+            txt = string_creator_deletemenu_all;
+            },
+        MENU_ITEM
+            {
+            command = ECmdDeleteCreatorIAPs;
+            txt = string_creator_deletemenu_by_creator;
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+RESOURCE MENU_PANE r_creator_deleteimps_submenu
+    {
+    items =
+        {
+        MENU_ITEM
+            {
+            command = ECmdDeleteIMPSs;
+            txt = string_creator_deletemenu_all;
+            },
+        MENU_ITEM
+            {
+            command = ECmdDeleteCreatorIMPSs;
+            txt = string_creator_deletemenu_by_creator;
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+RESOURCE MENU_PANE r_creator_deletenotes_submenu
+    {
+    items =
+        {
+        MENU_ITEM
+            {
+            command = ECmdDeleteNotes;
+            txt = string_creator_deletemenu_all;
+            }
+        // By Creator not supported because 
+        // note id is not available via Notepad API
+        };
+    }
+
+// ---------------------------------------------------------
+RESOURCE MENU_PANE r_creator_deletelandmarks_submenu
+    {
+    items =
+        {
+        MENU_ITEM
+            {
+            command = ECmdDeleteLandmarks;
+            txt = string_creator_deletemenu_all;
+            },
+        MENU_ITEM
+            {
+            command = ECmdDeleteCreatorLandmarks;
+            txt = string_creator_deletemenu_by_creator;
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+RESOURCE MENU_PANE r_creator_deletecontacts_submenu
+    {
+    items =
+        {
+        MENU_ITEM
+            {
+            command = ECmdDeleteContacts;
+            txt = string_creator_deletemenu_all;
+            },
+        MENU_ITEM
+            {
+            command = ECmdDeleteCreatorContacts;
+            txt = string_creator_deletemenu_by_creator;
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+RESOURCE MENU_PANE r_creator_deletecontactgroups_submenu
+    {
+    items =
+        {
+        MENU_ITEM
+            {
+            command = ECmdDeleteContactGroups;
+            txt = string_creator_deletemenu_all;
+            },
+        MENU_ITEM
+            {
+            command = ECmdDeleteCreatorContactGroups;
+            txt = string_creator_deletemenu_by_creator;
+            }
+        };
+    }
+
+
+// ---------------------------------------------------------
+//   
+//   r_creator_about_dialog
+//   About dialog - show version and copyright info etc.
+//
+// ---------------------------------------------------------
+//
+
+RESOURCE DIALOG r_creator_about_dialog
+{
+    flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow;
+    buttons = R_AVKON_SOFTKEYS_OK_EMPTY;
+    items=
+    {
+        DLG_LINE
+        {
+            type = EAknCtPopupHeadingPane;
+            id = EAknMessageQueryHeaderId;
+            control = AVKON_HEADING
+            {
+                label = "About Creator";
+                headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE;
+            };
+        },
+        DLG_LINE
+        {
+            type = EAknCtMessageQuery;
+            id = EAknMessageQueryContentId;
+            control = AVKON_MESSAGE_QUERY
+            {
+                message = "Version 5.3.5 - 30th October 2009. Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0.";
+            };
+        }
+    };
+}
+
+
+// ---------------------------------------------------------
+//   
+//   r_entry_query
+//   Dialog to query the amount of entries to create
+//
+// ---------------------------------------------------------
+//
+
+
+RESOURCE DIALOG r_entry_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtQuery;
+            id = EGeneralQuery;
+            control= AVKON_DATA_QUERY
+                {
+                layout = ENumberLayout;
+                label = "Insert label to ExecuteLD";
+                control = AVKON_INTEGER_EDWIN
+                    {
+                    min = 0;
+                    max = 9999;
+                    };
+                };
+            }
+        };
+    }
+
+
+// ---------------------------------------------------------
+//   
+//   r_start_date_query
+//   Dialog to query a start date
+//
+// ---------------------------------------------------------
+//
+
+RESOURCE DIALOG r_start_date_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtQuery;
+            id = EGeneralQuery;
+            control= AVKON_DATA_QUERY
+                {
+                layout = EDateLayout;
+                label = "Start date of creation period";
+                control = DATE_EDITOR
+                    {
+                    minDate = DATE
+                        {
+                        year = 1900;
+                        };
+                    maxDate = DATE
+                        {
+                        year = 3000;
+                        };
+                    flags = 0;
+                    };
+                };
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+//   
+//   r_end_date_query
+//   Dialog to query a start date
+//
+// ---------------------------------------------------------
+//
+
+RESOURCE DIALOG r_end_date_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtQuery;
+            id = EGeneralQuery;
+            control= AVKON_DATA_QUERY
+                {
+                layout = EDateLayout;
+                label = "End date of creation period";
+                control = DATE_EDITOR
+                    {
+                    minDate = DATE
+                        {
+                        year = 1900;
+                        };
+                    maxDate = DATE
+                        {
+                        year = 3000;
+                        };
+                    flags = 0;
+                    };
+                };
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+//   
+//   r_contact_creation_type_query
+//   Dialog to query a contact creation type
+//
+// ---------------------------------------------------------
+//
+
+RESOURCE DIALOG r_contact_creation_type_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            control= AVKON_LIST_QUERY_CONTROL
+                {
+                listtype = EAknCtSinglePopupMenuListBox;
+                listbox = AVKON_LIST_QUERY_LIST
+                    {
+                    array_id = r_contact_creation_type_query_array;
+                    };
+                heading = "Fields in contact";                
+                };
+            }
+        };
+    }
+
+RESOURCE ARRAY r_contact_creation_type_query_array
+    {
+    items =
+        {
+        LBUF {txt = "Default fields"; },
+        LBUF {txt = "Define..."; }
+        };
+    }
+
+
+// ---------------------------------------------------------
+//   
+//   r_message_type_query
+//   Dialog to query a message type
+//
+// ---------------------------------------------------------
+//
+
+RESOURCE DIALOG r_message_type_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            control= AVKON_LIST_QUERY_CONTROL
+                {
+                listtype = EAknCtSinglePopupMenuListBox;
+                listbox = AVKON_LIST_QUERY_LIST
+                    {
+                    array_id = r_message_type_query_array;
+                    };
+                heading = "Message type";                
+                };
+            }
+        };
+    }
+
+RESOURCE ARRAY r_message_type_query_array
+    {
+    items =
+        {
+        LBUF {txt = "SMS"; },
+        LBUF {txt = "MMS"; },
+        LBUF {txt = "AMS"; },
+        LBUF {txt = "Email"; },
+        LBUF {txt = "Smart Message"; },
+        LBUF {txt = "IR Message"; },
+        LBUF {txt = "BT Message"; }
+        };
+    }
+
+// ---------------------------------------------------------
+//   
+//   r_folder_type_query
+//   Dialog to query a message type
+//
+// ---------------------------------------------------------
+//
+
+RESOURCE DIALOG r_folder_type_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            control= AVKON_LIST_QUERY_CONTROL
+                {
+                listtype = EAknCtSinglePopupMenuListBox;
+                listbox = AVKON_LIST_QUERY_LIST
+                    {
+                    array_id = r_folder_type_query_array;
+                    };
+                heading = "Folder type";                
+                };
+            }
+        };
+    }
+    
+RESOURCE ARRAY r_folder_type_query_array
+    {
+    items =
+        {
+        LBUF {txt = "Inbox"; },
+        LBUF {txt = "Drafts"; },
+        LBUF {txt = "Outbox"; },
+        LBUF {txt = "Sent"; }
+        };
+    }
+
+// ---------------------------------------------------------
+//   
+//   r_folder_type_with_mailbox_query
+//   Dialog to query a message type
+//
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_folder_type_with_mailbox_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            control= AVKON_LIST_QUERY_CONTROL
+                {
+                listtype = EAknCtSinglePopupMenuListBox;
+                listbox = AVKON_LIST_QUERY_LIST
+                    {
+                    array_id = r_folder_type_with_mailbox_query_array;
+                    };
+                heading = "Folder type";                
+                };
+            }
+        };
+    }
+RESOURCE ARRAY r_folder_type_with_mailbox_query_array
+    {
+    items =
+        {
+        LBUF {txt = "Inbox"; },
+        LBUF {txt = "Drafts"; },
+        LBUF {txt = "Outbox"; },
+        LBUF {txt = "Sent"; },
+        LBUF {txt = "Mailbox..."; }
+        };
+    }
+
+// ---------------------------------------------------------
+//   
+//   r_app_selection_query
+//   
+//
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_mailbox_selection_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            control= AVKON_LIST_QUERY_CONTROL
+                {
+                listtype = EAknCtSinglePopupMenuListBox;
+                listbox = AVKON_LIST_QUERY_LIST
+                    {
+                    };
+                heading = "Choose mailbox:";                
+                };
+            }
+        };
+    } 
+        
+// ---------------------------------------------------------
+//   
+//   r_unread_type_query
+//   Dialog to query whether to create the message unread or not
+//
+// ---------------------------------------------------------
+//
+
+RESOURCE DIALOG r_unread_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            control= AVKON_LIST_QUERY_CONTROL
+                {
+                listtype = EAknCtSinglePopupMenuListBox;
+                listbox = AVKON_LIST_QUERY_LIST
+                    {
+                    array_id = r_unread_query_array;
+                    };
+                heading = "Message status";                
+                };
+            }
+        };
+    }
+
+RESOURCE ARRAY r_unread_query_array
+    {
+    items =
+        {
+        LBUF {txt = "Read"; },
+        LBUF {txt = "New"; }
+        };
+    }
+
+// ---------------------------------------------------------
+//   
+//   r_attachment_single_selection_query
+//   r_attachment_multi_selection_query
+//   Dialogs to query attachments
+//
+// ---------------------------------------------------------
+//
+
+RESOURCE DIALOG r_attachment_single_selection_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            control= AVKON_LIST_QUERY_CONTROL
+                {
+                listtype = EAknCtSinglePopupMenuListBox;
+                listbox = AVKON_LIST_QUERY_LIST
+                    {
+                    array_id = r_attachment_query_array;
+                    };
+                heading = "Choose attachment:";                
+                };
+            }
+        };
+    }
+
+RESOURCE DIALOG r_ams_attachment_single_selection_query
+{
+flags = EGeneralQueryFlags;
+buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+items =
+    {
+    AVKON_LIST_QUERY_DLG_LINE
+        {
+        control= AVKON_LIST_QUERY_CONTROL
+            {
+            listtype = EAknCtSinglePopupMenuListBox;
+            listbox = AVKON_LIST_QUERY_LIST
+                {
+                array_id = r_ams_attachment_query_array;
+                };
+            heading = "Choose attachment:";                
+            };
+        }
+    };
+}
+
+
+RESOURCE DIALOG r_attachment_multi_selection_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        AVKON_MULTISELECTION_LIST_QUERY_DLG_LINE
+            {
+            control= AVKON_LIST_QUERY_CONTROL
+                {
+                listtype = EAknCtSingleGraphicPopupMenuListBox;
+                listbox = AVKON_MULTISELECTION_LIST_QUERY_LIST
+                    {
+                    array_id = r_attachment_multiselection_query_array;
+                    };
+                heading = "Choose attachments:";                
+                };
+            }
+        };
+    }
+
+
+RESOURCE ARRAY r_attachment_query_array
+    {
+    items =
+        {
+        LBUF {txt = "JPEG 25kB"; },
+        LBUF {txt = "JPEG 300kB"; },
+        LBUF {txt = "JPEG 500kB"; },
+        LBUF {txt = "PNG 15kB"; },
+        LBUF {txt = "GIF 2kB"; },
+        LBUF {txt = "RNG 1kB"; },
+        LBUF {txt = "MIDI 10kB"; },
+        LBUF {txt = "WAVE 20kB"; },
+        LBUF {txt = "AMR 20kB"; },
+        LBUF {txt = "Excel 15kB"; },
+        LBUF {txt = "Word 20kB"; },
+        LBUF {txt = "PowerPoint 40kB"; },
+        LBUF {txt = "Text 10kB"; },
+        LBUF {txt = "Text 70kB"; },
+        LBUF {txt = "3GPP 70kB"; },
+        LBUF {txt = "MP3 250kB"; },
+        LBUF {txt = "AAC 100kB"; },
+        LBUF {txt = "RM 95kB"; }
+        };
+    }
+
+RESOURCE ARRAY r_ams_attachment_query_array
+    {
+    items =
+        {
+        LBUF {txt = "AMR 20kB"; }
+        };
+    }
+
+RESOURCE ARRAY r_attachment_multiselection_query_array
+    {
+    items =
+        {
+        LBUF {txt = "1\tNone"; },
+        LBUF {txt = "1\tJPEG 25kB"; },
+        LBUF {txt = "1\tJPEG 200kB"; },
+        LBUF {txt = "1\tJPEG 500kB"; },
+        LBUF {txt = "1\tPNG 15kB"; },
+        LBUF {txt = "1\tGIF 2kB"; },
+        LBUF {txt = "1\tRNG 1kB"; },
+        LBUF {txt = "1\tMIDI 10kB"; },
+        LBUF {txt = "1\tWAVE 20kB"; },
+        LBUF {txt = "1\tAMR 20kB"; },
+        LBUF {txt = "1\tExcel 15kB"; },
+        LBUF {txt = "1\tWord 20kB"; },
+        LBUF {txt = "1\tPowerPoint 40kB"; },
+        LBUF {txt = "1\tText 10kB"; },
+        LBUF {txt = "1\tText 70kB"; },
+        LBUF {txt = "1\t3GPP 70kB"; },
+        LBUF {txt = "1\tMP3 250kB"; },
+        LBUF {txt = "1\tAAC 100kB"; },
+        LBUF {txt = "1\tRM 95kB"; },        
+        LBUF {txt = "1\tBMP 25kB"; },
+        LBUF {txt = "1\tHTML 20kB"; },
+        LBUF {txt = "1\tJAD 1kB"; },
+        LBUF {txt = "1\tJAR 10kB"; },
+        LBUF {txt = "1\tJP2 65kB"; },
+        LBUF {txt = "1\tMP4 200kB"; },
+        LBUF {txt = "1\tMXMF 40kB"; },
+        LBUF {txt = "1\tRAM 1kB"; },
+        LBUF {txt = "1\tSVG 15kB"; },
+        LBUF {txt = "1\tSWF 15kB"; },
+        LBUF {txt = "1\tTIF 25kB"; },
+        LBUF {txt = "1\tVCF 1kB"; },
+        LBUF {txt = "1\tVCS 1kB"; },
+        LBUF {txt = "1\tSISX 10kB"; }
+        };
+    }
+
+// ---------------------------------------------------------
+//   
+//   r_group_creation_type_query
+//   Dialog to query a group creation type
+//
+// ---------------------------------------------------------
+//
+
+RESOURCE DIALOG r_group_creation_type_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            control= AVKON_LIST_QUERY_CONTROL
+                {
+                listtype = EAknCtSinglePopupMenuListBox;
+                listbox = AVKON_LIST_QUERY_LIST
+                    {
+                    array_id = r_group_creation_type_query_array;
+                    };
+                heading = "Fields in contact";                
+                };
+            }
+        };
+    }
+
+RESOURCE ARRAY r_group_creation_type_query_array
+    {
+    items =
+        {
+        LBUF {txt = "Random"; },
+        LBUF {txt = "Define..."; }
+        };
+    }
+
+// ---------------------------------------------------------
+//   
+//   r_directory_query
+//   Dialog to query the directory from the user
+//
+// ---------------------------------------------------------
+//
+
+
+RESOURCE DIALOG r_directory_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtQuery;
+            id = EGeneralQuery;
+            control= AVKON_DATA_QUERY
+                {
+                layout = EDataLayout;
+                label = "Specify the directory";
+                control = EDWIN
+                    {
+                    };
+                };
+            }
+        };
+    }
+
+
+//
+// ---------------------------------------------------------
+//
+
+RESOURCE DIALOG r_progress_note
+    {
+    flags = EAknProgressNoteFlags;
+    buttons = R_AVKON_SOFTKEYS_CANCEL;
+    items=
+        {
+        DLG_LINE
+            {
+            type = EAknCtNote;
+            id = EProgressNote;
+            control= AVKON_NOTE 
+                { 
+                layout = EProgressLayout;
+                imagefile = AVKON_ICON_FILE;
+                imageid = EMbmAvkonQgn_note_progress;
+                imagemask = EMbmAvkonQgn_note_progress_mask;
+                };
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+
+RESOURCE ARRAY r_data_firstnames
+    {
+    items=
+        {
+        LBUF { txt="John"; },
+        LBUF { txt="Francis"; },
+        LBUF { txt="Andrew"; },
+        LBUF { txt="Lawrence"; },
+        LBUF { txt="Gregory"; },
+        LBUF { txt="Fulke"; },
+        LBUF { txt="Thomas"; },
+        LBUF { txt="Nicholas"; },
+        LBUF { txt="Hakle"; },
+        LBUF { txt="Roger"; },
+        LBUF { txt="Nathaniel"; },
+        LBUF { txt="Luke"; },
+        LBUF { txt="William"; },
+        LBUF { txt="Ralph"; },
+        LBUF { txt="Leonar"; },
+        LBUF { txt="Daniel"; },
+        LBUF { txt="Aban"; },
+        LBUF { txt="Mathias"; },
+        LBUF { txt="Robert"; },
+        LBUF { txt="Christopher"; },
+        LBUF { txt="Martin"; },
+        LBUF { txt="Michael"; },
+        LBUF { txt="Barnaby"; },
+        LBUF { txt="Tobias"; },
+        LBUF { txt="Richard"; },
+        LBUF { txt="Anthony"; },
+        LBUF { txt="Simon"; },
+        LBUF { txt="Samuel"; },
+        LBUF { txt="Geoffrey"; },
+        LBUF { txt="Isaac"; },
+        LBUF { txt="Henry"; },
+        LBUF { txt="Matthew"; },
+        LBUF { txt="Peter"; },
+        LBUF { txt="Allen"; },
+        LBUF { txt="Reynold"; },
+        LBUF { txt="Jerome"; },
+        LBUF { txt="Elizabeth"; },
+        LBUF { txt="Catherine"; },
+        LBUF { txt="Frances"; },
+        LBUF { txt="Cecily"; },
+        LBUF { txt="Millicent"; },
+        LBUF { txt="Audrey"; },
+        LBUF { txt="Joan"; },
+        LBUF { txt="Elinor"; },
+        LBUF { txt="Joyce"; },
+        LBUF { txt="Frideswide"; },
+        LBUF { txt="Rose"; },
+        LBUF { txt="Helen"; },
+        LBUF { txt="Margaret"; },
+        LBUF { txt="Isabel"; },
+        LBUF { txt="Bridget"; },
+        LBUF { txt="Grace"; },
+        LBUF { txt="Thomasin"; },
+        LBUF { txt="Janet"; },
+        LBUF { txt="Agnes"; },
+        LBUF { txt="Dorothy"; },
+        LBUF { txt="Christian"; },
+        LBUF { txt="Amy"; },
+        LBUF { txt="Fortune"; },
+        LBUF { txt="Sybil"; },
+        LBUF { txt="Alice"; },
+        LBUF { txt="Margery"; },
+        LBUF { txt="Edith"; },
+        LBUF { txt="Barbara"; },
+        LBUF { txt="Gillian"; },
+        LBUF { txt="Ursula"; }
+        };
+    }
+
+RESOURCE ARRAY r_data_surnames
+    {
+    items=
+        {
+        LBUF { txt="Lux"; },
+        LBUF { txt="Mandot"; },
+        LBUF { txt="Mansfield"; },
+        LBUF { txt="Mayberry"; },
+        LBUF { txt="McCarrel"; },
+        LBUF { txt="McDaniel"; },
+        LBUF { txt="Mefford"; },
+        LBUF { txt="Metcalf"; },
+        LBUF { txt="Metchell"; },
+        LBUF { txt="Moller"; },
+        LBUF { txt="Margan"; },
+        LBUF { txt="Keaney"; },
+        LBUF { txt="Kenyon"; },
+        LBUF { txt="Kesler"; },
+        LBUF { txt="Kinman"; },
+        LBUF { txt="Kreinert"; },
+        LBUF { txt="Kummerlin"; },
+        LBUF { txt="Lamgley"; },
+        LBUF { txt="Leas"; },
+        LBUF { txt="Leighton"; },
+        LBUF { txt="Lillie"; },
+        LBUF { txt="Hilms"; },
+        LBUF { txt="Holt"; },
+        LBUF { txt="Hosier"; },
+        LBUF { txt="Howard"; },
+        LBUF { txt="Hypes"; },
+        LBUF { txt="Jacmor"; },
+        LBUF { txt="Behnson"; },
+        LBUF { txt="Kammer"; },
+        LBUF { txt="Patts"; },
+        LBUF { txt="West"; },
+        LBUF { txt="Wilbar"; },
+        LBUF { txt="Witsan"; },
+        LBUF { txt="Gillams"; },
+        LBUF { txt="Good"; },
+        LBUF { txt="Wreght"; },
+        LBUF { txt="Worthley"; },
+        LBUF { txt="Adams"; },
+        LBUF { txt="Allen"; },
+        LBUF { txt="Ansley"; },
+        LBUF { txt="Ayries"; },
+        LBUF { txt="Bartlett"; },
+        LBUF { txt="Barton"; },
+        LBUF { txt="Payne"; },
+        LBUF { txt="Pintard"; },
+        LBUF { txt="Prence"; },
+        LBUF { txt="Richards"; },
+        LBUF { txt="Dillman"; },
+        LBUF { txt="Dory"; },
+        LBUF { txt="Edgards"; },
+        LBUF { txt="Engell"; },
+        LBUF { txt="Farprington"; },
+        LBUF { txt="Fisher"; },
+        LBUF { txt="Foed"; },
+        LBUF { txt="Burges"; },
+        LBUF { txt="Childwall"; },
+        LBUF { txt="Smith"; },
+        LBUF { txt="Sipon"; },
+        LBUF { txt="Simmons"; },
+        LBUF { txt="Stewert"; },
+        LBUF { txt="Stiles"; },
+        LBUF { txt="Stratton"; },
+        LBUF { txt="Dennis"; },
+        LBUF { txt="Talmot"; }
+        };
+    }
+
+RESOURCE ARRAY r_data_companies
+    {
+    items=
+        {
+        LBUF { txt="CDP"; },
+        LBUF { txt="Exbox"; },
+        LBUF { txt="Munro"; },
+        LBUF { txt="Majaka"; },
+        LBUF { txt="Bitzumi"; },
+        LBUF { txt="Melroy"; },
+        LBUF { txt="Matal"; },
+        LBUF { txt="Japponi"; },
+        LBUF { txt="Siwaka"; },
+        LBUF { txt="Keiku"; },
+        LBUF { txt="Naamate"; },
+        LBUF { txt="Remonti"; },
+        LBUF { txt="Melleva"; },
+        LBUF { txt="WEX"; },
+        LBUF { txt="Chataz"; },
+        LBUF { txt="Ponly"; },
+        LBUF { txt="Alriva"; },
+        LBUF { txt="Giate"; },
+        LBUF { txt="Kesso"; },
+        LBUF { txt="Nyssa"; },
+        LBUF { txt="Peger"; },
+        LBUF { txt="Metrio"; },
+        LBUF { txt="Mitchitatchi"; },
+        LBUF { txt="Neppari"; },
+        LBUF { txt="Amcuila"; },
+        LBUF { txt="Muipitsu"; },
+        LBUF { txt="Redex"; },
+        LBUF { txt="Maariz"; },
+        LBUF { txt="Swerck"; },
+        LBUF { txt="Makiac"; },
+        LBUF { txt="Dumpia"; },
+        LBUF { txt="Worldmom"; },
+        LBUF { txt="Renfaul"; },
+        LBUF { txt="Kmartissori"; },
+        LBUF { txt="Findo"; },
+        LBUF { txt="Samsanc"; },
+        LBUF { txt="Dellervo"; },
+        LBUF { txt="Manrel"; },
+        LBUF { txt="WSMRL"; },
+        LBUF { txt="Eripox"; },
+        LBUF { txt="Abiturien"; },
+        LBUF { txt="Vesus"; },
+        LBUF { txt="MI4"; },
+        LBUF { txt="Overhiba"; },
+        LBUF { txt="Tridune"; },
+        LBUF { txt="Kyomcera"; },
+        LBUF { txt="Praston"; },
+        LBUF { txt="Gapmis"; },
+        LBUF { txt="WPPDCD"; }
+        };
+    }
+
+RESOURCE ARRAY r_data_addresses
+    {
+    items=
+        {
+        LBUF { txt="Barnes Street"; },
+        LBUF { txt="Barnes Place"; },
+        LBUF { txt="Eastman Street"; },
+        LBUF { txt="West Park"; },
+        LBUF { txt="South Park"; },
+        LBUF { txt="Park Avenue"; },
+        LBUF { txt="Richards Court"; },
+        LBUF { txt="Pukershire Avenue"; },
+        LBUF { txt="Ellis Avenue"; },
+        LBUF { txt="East Mountain"; },
+        LBUF { txt="Chestnut Hill"; },
+        LBUF { txt="Plains Road"; },
+        LBUF { txt="Fremont Street"; },
+        LBUF { txt="Heritage Court"; },
+        LBUF { txt="Highland Avenue Extension"; },
+        LBUF { txt="Maple Heights"; },
+        LBUF { txt="McKenzie Avenue"; },
+        LBUF { txt="McKenzie Lane"; },
+        LBUF { txt="West Terrace Street"; },
+        LBUF { txt="Windsor Avenue"; },
+        LBUF { txt="Windsor Road"; },
+        LBUF { txt="Mechanic Street Extension"; },
+        LBUF { txt="Granite Place"; },
+        LBUF { txt="Meadow Street"; },
+        LBUF { txt="Sugar River"; }
+        };
+    }
+
+RESOURCE ARRAY r_data_cities
+    {
+    items=
+        {
+        LBUF { txt="Kuopio"; },       
+        LBUF { txt="Los Angeles"; },        
+        LBUF { txt="Lappeenranta"; },
+        LBUF { txt="London"; },        
+        LBUF { txt="Bangkok"; },
+        LBUF { txt="St. Michel"; },                
+        LBUF { txt="St. Petersburg"; },        
+        LBUF { txt="Tokyo"; },
+        LBUF { txt="Helsinki"; },
+        LBUF { txt="Trondheim"; },        
+        LBUF { txt="Nairobi"; },
+        LBUF { txt="Havana"; }        
+        };
+    }
+
+RESOURCE ARRAY r_data_countries
+    {
+    items=
+        {
+        LBUF { txt="Finland"; },
+        LBUF { txt="Cuba"; },
+        LBUF { txt="United States of America"; },
+        LBUF { txt="Thailand"; },
+        LBUF { txt="Sweden"; },
+        LBUF { txt="Russia"; },
+        LBUF { txt="Japan"; },
+        LBUF { txt="Norway"; },
+        LBUF { txt="Kenya"; }                
+        };
+    }
+
+RESOURCE ARRAY r_data_postcodes
+    {
+    items=
+        {
+        LBUF { txt="00310"; },
+        LBUF { txt="FI-70100"; },
+        LBUF { txt="99002"; },
+        LBUF { txt="11233"; }            
+        };
+    }
+
+RESOURCE ARRAY r_data_states
+    {
+    items=
+        {
+        LBUF { txt="California state"; }, 
+        LBUF { txt="Alaska state"; },
+        LBUF { txt="Florida state"; }
+        };
+    }
+
+RESOURCE ARRAY r_data_poboxes
+    {
+    items=
+        {
+        LBUF { txt="P.O BOX 5532"; },
+        LBUF { txt="P.O BOX 701"; },
+        LBUF { txt="99"; },
+        LBUF { txt="1133"; },
+        LBUF { txt="P.O. BOX 113322"; },
+        LBUF { txt="112"; }
+        };
+    }
+
+RESOURCE ARRAY r_data_prefixes
+    {
+    items=
+        {
+        LBUF { txt="Ms."; },
+        LBUF { txt="Mrs."; }, 
+        LBUF { txt="Mr."; },
+        LBUF { txt="Dr."; }
+        
+        };
+    }
+
+RESOURCE ARRAY r_data_suffixes
+    {
+    items=
+        {
+        LBUF { txt="Jr."; },
+        LBUF { txt="Sr."; }        
+        };
+    }
+
+RESOURCE ARRAY r_data_jobtitles
+    {
+    items=
+        {
+        LBUF { txt="Doctor"; },
+        LBUF { txt="SW Engineer"; },
+        LBUF { txt="Administrative Assistant"; },
+        LBUF { txt="Bookkeeper"; },
+        LBUF { txt="Credit Controller"; },
+        LBUF { txt="Data Entry Operator"; },
+        LBUF { txt="Payroll Officer"; },
+        LBUF { txt="Receptionist"; },
+        LBUF { txt="Trainee"; },
+        LBUF { txt="Accounts Clerk"; },
+        LBUF { txt="Administrator"; },
+        LBUF { txt="Taxation Assistant"; },
+        LBUF { txt="Financial Director"; },
+        LBUF { txt="Bank Manager"; },
+        LBUF { txt="Mobile Lending"; },
+        LBUF { txt="Overseas Transactions"; },
+        LBUF { txt="Restructuring"; },
+        LBUF { txt="Business Analyst"; },
+        LBUF { txt="Call Centre Manager"; },
+        LBUF { txt="Administration"; },
+        LBUF { txt="Manager"; },
+        LBUF { txt="Student"; },
+        LBUF { txt="Mail Sorter"; },
+        LBUF { txt="Mayor"; },
+        LBUF { txt="Account Servicing"; },
+        LBUF { txt="Management"; },
+        LBUF { txt="Media Consultant"; },
+        LBUF { txt="Newsagent"; },
+        LBUF { txt="Librarian"; },
+        LBUF { txt="Creative Director"; },
+        LBUF { txt="Announcer"; },
+        LBUF { txt="Copywriter"; },
+        LBUF { txt="Presenter"; },
+        LBUF { txt="Promotions Manager"; },
+        LBUF { txt="Advertising Sales Representative"; },
+        LBUF { txt="Editor"; },
+        LBUF { txt="Marketing, Sales & Publicity"; },
+        LBUF { txt="Publisher"; },
+        LBUF { txt="Gallery Assistant"; },
+        LBUF { txt="Photographer"; },
+        LBUF { txt="Storyboard Artist"; },
+        LBUF { txt="Events Manager"; },
+        LBUF { txt="Cameraman"; },
+        LBUF { txt="Technician"; },
+        LBUF { txt="Producer"; }
+        };
+    }
+
+RESOURCE ARRAY r_data_phonenumbers
+    {
+    items=
+        {
+        LBUF { txt="0307834387"; },
+        LBUF { txt="0230328732"; },
+        LBUF { txt="0430365562"; },
+        LBUF { txt="0530328732"; },
+        LBUF { txt="0433032865"; },
+        LBUF { txt="0542306532"; },
+        LBUF { txt="0342303777"; },
+        LBUF { txt="0250235603"; },
+        LBUF { txt="0492303652"; },
+        LBUF { txt="0542303286"; },
+        LBUF { txt="0543656546"; },
+        LBUF { txt="0545545454"; },
+        LBUF { txt="0543444454"; },
+        LBUF { txt="0776463255"; },
+        LBUF { txt="0432443343"; },
+        LBUF { txt="0243334344"; },
+        LBUF { txt="0544543443"; },
+        LBUF { txt="0231343243"; },
+        LBUF { txt="0213443434"; },
+        LBUF { txt="0143234476"; },
+        LBUF { txt="0785434444"; },
+        LBUF { txt="0454445345"; },
+        LBUF { txt="0342443433"; },
+        LBUF { txt="0432434454"; },
+        LBUF { txt="0455454454"; },
+        LBUF { txt="0656565655"; },
+        LBUF { txt="0343434443"; },
+        LBUF { txt="0565645455"; },
+        LBUF { txt="0343243243"; },
+        LBUF { txt="0565466565"; },
+        LBUF { txt="0465565655"; },
+        LBUF { txt="0435445454"; },
+        LBUF { txt="+35854553456"; },
+        LBUF { txt="+35878453486"; },
+        LBUF { txt="+35876653456"; },
+        LBUF { txt="+35834435486"; },
+        LBUF { txt="+35876766466"; },
+        LBUF { txt="+4465665456"; },
+        LBUF { txt="+4432434334"; },
+        LBUF { txt="+4488776776"; },
+        LBUF { txt="+4465655656"; },
+        LBUF { txt="+4443433434"; },
+        LBUF { txt="+4465656565"; },
+        LBUF { txt="+4454454354"; }
+        };
+    }
+
+RESOURCE ARRAY r_data_groupnames
+    {
+    items=
+        {
+        LBUF { txt="Nice guys"; },
+        LBUF { txt="Repairs"; },
+        LBUF { txt="Office works"; },
+        LBUF { txt="The buddies"; },
+        LBUF { txt="Football team"; },
+        LBUF { txt="Gold club"; },
+        LBUF { txt="Silver club"; },
+        LBUF { txt="Bronze club"; },
+        LBUF { txt="Best buddies"; },
+        LBUF { txt="Rockers"; },
+        LBUF { txt="Science group"; }
+        };
+    }
+
+RESOURCE ARRAY r_data_meetingreasons
+    {
+    items=
+        {
+        LBUF { txt="Security issues"; },
+        LBUF { txt="Team meeting"; },
+        LBUF { txt="Discussion about"; },
+        LBUF { txt="Work plans"; },
+        LBUF { txt="Meeting with the professor"; },
+        LBUF { txt="Meeting with the boss"; },
+        LBUF { txt="Work issues"; },
+        LBUF { txt="New workers"; }
+        };
+    }
+
+RESOURCE ARRAY r_data_meetingplaces
+    {
+    items=
+        {
+        LBUF { txt="Room"; },
+        LBUF { txt="Home"; },
+        LBUF { txt="Auditorium"; },
+        LBUF { txt="Company"; }
+        };
+    }
+
+RESOURCE ARRAY r_data_landmark_names
+    {
+    items=
+        {
+        LBUF { txt="Good place to fish";},
+        LBUF { txt="Uncle over board";},
+        LBUF { txt="Best food ever!";},
+        LBUF { txt="Nice beach";},
+        LBUF { txt="Good hamburgers";},
+        LBUF { txt="Nice view";},
+        LBUF { txt="John's home";},
+        LBUF { txt="Carage";},
+        LBUF { txt="Gas station";},
+        LBUF { txt="Food store";},
+        LBUF { txt="Car wash";},
+        LBUF { txt="Summer cottage";},
+        LBUF { txt="My home";},
+        LBUF { txt="Bank";},
+        LBUF { txt="Hospital";},
+        LBUF { txt="Ice hall";},
+        LBUF { txt="Work place";}
+        };
+    }
+
+RESOURCE ARRAY r_data_landmark_descriptions
+    {
+    items=
+        {
+        LBUF { txt="The salmons were really big here!";},        
+        LBUF { txt="Delicious strawberries sold here. Must visit again sometime!";},
+        LBUF { txt="Place looks really nice.";},
+        LBUF { txt="This is my favorite place";},
+        LBUF { txt="Words are not enough to describe this landmark";},        
+        LBUF { txt="What a shocking place to visit! Remember to bring camera next time :-)";}
+        };
+    }
+
+RESOURCE ARRAY r_data_memos
+    {
+    items=
+        {
+        LBUF { txt="No work today!"; },
+        LBUF { txt="Movies tonight"; },
+        LBUF { txt="Ship new binaries"; },
+        LBUF { txt="New works"; },
+        LBUF { txt="Exam"; },
+        LBUF { txt="Community service"; },
+        LBUF { txt="Volunteer work"; },
+        LBUF { txt="Don't forget the dinner at the restaurant"; },
+        LBUF { txt="Go the bank"; },
+        LBUF { txt="Go to the store"; },
+        LBUF { txt="Buy goods"; },
+        LBUF { txt="Buy food"; },
+        LBUF { txt="Buy new pair of socks"; },
+        LBUF { txt="Buy vegetables"; },
+        LBUF { txt="Buy fruits"; },
+        LBUF { txt="Umbrella"; },
+        LBUF { txt="New shoes"; },
+        LBUF { txt="New suit"; },
+        LBUF { txt="Buy flowers"; },
+        LBUF { txt="School day"; }
+        };
+    }
+RESOURCE ARRAY r_data_anniversaries
+    {
+    items=
+        {
+        LBUF { txt="birthday"; },
+        LBUF { txt="anniversary"; }
+        };
+    }
+
+RESOURCE ARRAY r_data_todos
+    {
+    items=
+        {
+        LBUF { txt="Watch for gum on my shoe"; },
+        LBUF { txt="Watch my step in the hall"; },
+        LBUF { txt="Always think big"; },
+        LBUF { txt="Don't ever think small"; },
+        LBUF { txt="Keep pedaling my bike"; },
+        LBUF { txt="Watch for bees in my pop"; },
+        LBUF { txt="Keep moving forward"; },
+        LBUF { txt="Don't ever stop"; },
+        LBUF { txt="Keep my sled underneath me"; },
+        LBUF { txt="Keep my stick on the ice"; },
+        LBUF { txt="Don't swim in a whirlpool"; },
+        LBUF { txt="Don't look for a fight"; },
+        LBUF { txt="Don't spit in the wind"; },
+        LBUF { txt="Just do what is right"; },
+        LBUF { txt="Go out in the world"; },
+        LBUF { txt="Enjoy a warm rain"; },
+        LBUF { txt="Don't worship TV"; },
+        LBUF { txt="Keep my oars in the water"; },
+        LBUF { txt="Point my boat right downstream"; },
+        LBUF { txt="Face head on my problems"; },
+        LBUF { txt="Change underwear daily"; },
+        LBUF { txt="Believe myself first"; },
+        LBUF { txt="Go out and have fun"; },
+        LBUF { txt="Turn the cards one by one"; },
+        LBUF { txt="Get out and do something"; }
+        };
+    }
+
+RESOURCE ARRAY r_data_reminders
+    {
+    items=
+        {
+        LBUF { txt="Remeber to fix car"; },
+        LBUF { txt="Remeber to eat vegetables"; },
+        LBUF { txt="Remeber to go shopping"; },
+        LBUF { txt="Remeber to buy boxes for moving"; },
+        LBUF { txt="Remeber to fix bike"; },
+        LBUF { txt="Remeber to buy christmast presents"; },
+        LBUF { txt="Remeber to send flowers to grandmother"; },
+        LBUF { txt="Remeber to talk with son"; },
+        LBUF { txt="Remeber to cut hedge"; },
+        LBUF { txt="Remeber to bumper potatoes"; },
+        LBUF { txt="Remeber to harvest corn field"; },
+        LBUF { txt="Remeber to sleep enaugh"; },
+        LBUF { txt="Remeber to wash teeths ewery morning"; },
+        LBUF { txt="Remeber to get sleep early"; },
+        LBUF { txt="Remeber to give some wather to flowers"; },
+        LBUF { txt="Remeber to wax snowboard"; },
+        LBUF { txt="Remeber to wax skiis"; },
+        LBUF { txt="Remeber to wax cross country skiis"; },
+        LBUF { txt="Remeber to call mother"; },
+        LBUF { txt="Remeber to call father"; },
+        LBUF { txt="Remeber to call brother"; },
+        LBUF { txt="Remeber to call sister"; },
+        LBUF { txt="Remeber to call daughter"; },
+        LBUF { txt="Remeber to call son"; },
+        LBUF { txt="Remeber to rent villa"; }
+        };
+    }
+
+RESOURCE ARRAY r_data_messagesubjects
+    {
+    items=
+        {
+        LBUF { txt="Whaaasssaaap!!??"; },
+        LBUF { txt="Hello"; },
+        LBUF { txt="How are you doing?"; },
+        LBUF { txt="You will win the battle, GUARANTEED!"; },
+        LBUF { txt="Why pay more for something if you don't have to?"; },
+        LBUF { txt="You can afford health care now"; },
+        LBUF { txt="Re: *Buddy* *Lists*!!~ (it's soooo cool)!!~"; },
+        LBUF { txt="Weedmon say: call, we be open 7 days, mon"; },
+        LBUF { txt="Want her to look better?"; },
+        LBUF { txt="Good Morning andyw, how are you?"; },
+        LBUF { txt="Happy Assumption"; },
+        LBUF { txt="There is NO Risk involved"; },
+        LBUF { txt="Free Bottle Offer!"; },
+        LBUF { txt="Introduction on MDSL"; },
+        LBUF { txt="Theres Help out there for you"; },
+        LBUF { txt="hello there - check this out"; },
+        LBUF { txt="Darling"; },
+        LBUF { txt="It doesn't have to be that way"; },
+        LBUF { txt="Webmaster, Free health insurance quotes!"; },
+        LBUF { txt="Join us at the OSGi 2003 World Congress"; },
+        LBUF { txt="Put your subject line here"; },
+        LBUF { txt="You are not protected"; },
+        LBUF { txt="Please try again"; },
+        LBUF { txt="you didn't reply my email ? why ? ???"; },
+        LBUF { txt="A very funny game"; },
+        LBUF { txt="Meeting notice"; },
+        LBUF { txt="Opportunities"; }
+        };
+    }
+
+RESOURCE ARRAY r_data_messagetexts
+    {
+    items=
+        {
+        LBUF { txt="The contents of these pages are copyrighted. Any rights not expressly granted herein are reserved. The use of this site is permitted to private use."; },
+        LBUF { txt="Reproduction, transfer, distribution or storage of part or all of the contents in any form without the prior written permission is prohibited."; },
+        LBUF { txt="We consents to you browsing the pages on your computer or printing copies of extracts from these pages for your personal use only."; },
+        LBUF { txt="If you place an order for a product, request a service or submit content to this site, we may need to contact you for additional information."; },
+        LBUF { txt="The use of press releases and other documents classified as public is permitted in public communications if the source for the information has been stated."; },
+        LBUF { txt="For your easy accessibility we may include links to sites on the Internet that are owned or operated by third parties."; },
+        LBUF { txt="You also agree that we have no control over the content of that site and cannot assume any responsibility for material by such third-party sites."; },
+        LBUF { txt="In addition, a link to a such site does not imply that we endorses the site or the products or services referenced in such third party site."; },
+        LBUF { txt="In order to respond to your questions or manage interactive customer programs, it may be necessary to ask for personal information."; },
+        LBUF { txt="We may use this information to respond to your requests, or to contact you via mail, e-mail or phone to inform you of new products."; },
+        LBUF { txt="If you place an order for a product, request a service or submit content to this site, we may need to contact you for additional information."; }
+        };
+    }
+
+
+// ---------------------------------------------------------
+//   
+//    New framework:
+//    Secure platform and scalable UI changes 
+//
+// ---------------------------------------------------------
+//
+RESOURCE LOCALISABLE_APP_INFO r_creator_localisable_app_info
+    {
+    short_caption = "Creator";
+    caption_and_icon = 
+    CAPTION_AND_ICON_INFO
+        {
+        caption = "Creator";
+
+        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"\\creator_aif.mif";
+        };
+    }
+
+RESOURCE DIALOG r_yes_no_dialog
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_YES_NO;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtQuery;
+            id = EGeneralQuery;
+            control = AVKON_CONFIRMATION_QUERY
+                {
+                layout = EConfirmationQueryLayout;
+                animation = R_QGN_NOTE_QUERY_ANIM;
+                };
+            }
+        };
+    }
+    
+RESOURCE DIALOG r_encryption_dialog
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtListQueryControl;
+            id = EListQueryControl;
+            control = AVKON_LIST_QUERY_CONTROL
+                {
+                listtype = EAknCtSinglePopupMenuListBox;
+                listbox = LISTBOX
+                    {
+                    flags = EAknListBoxSelectionList;
+                    height = 3;
+                    width = 3;
+                    };
+                heading = "Encryption";
+                };
+            }
+        };
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/data/creator_reg.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,35 @@
+/*
+* 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:  
+*
+*/
+
+
+#include <creator.rsg>
+#include <appinfo.rh>
+#include <data_caging_paths_strings.hrh>
+
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0x20011383
+
+
+
+RESOURCE APP_REGISTRATION_INFO
+    {
+    app_file = "Creator";
+    localisable_resource_file = APP_RESOURCE_DIR"\\Creator";
+    localisable_resource_id = R_CREATOR_LOCALISABLE_APP_INFO;
+    group_name = "RnD Tools";
+    }
Binary file creator/files/3GPP-70kB.dat has changed
Binary file creator/files/AAC-100kB.dat has changed
Binary file creator/files/AMR-20kB.dat has changed
Binary file creator/files/BMP-25kB.dat has changed
Binary file creator/files/DOC-20kB.dat has changed
Binary file creator/files/Deck-1kB.dat has changed
Binary file creator/files/GIF-2kB.dat has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/files/HTML-20kB.dat	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,378 @@
+<html>
+<header>
+<title>My HTML page</title>
+<header>
+<body>
+<H1>My HTML page</H1>
+
+<li>item 1</li>
+<li>item 2</li>
+<li>item 3</li>
+<li>item 4</li>
+
+<p>
+                      COPYRIGHT LICENSE
+</p><p>
+
+      NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR
+      CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS
+
+</p><p>
+
+This Software Agreement ("Agreement") is between You (either an
+individual or an entity), the End User, and Nokia Corporation
+("Nokia"). The Agreement authorizes You to use the Software specified
+in Clause 1 below, which may be stored on a CD-ROM, sent to You by
+electronic mail, or downloaded from Nokia's Web pages or Servers or
+from other sources under the terms and conditions set forth below.
+This is an agreement on end-user rights and not an agreement for sale.
+Nokia continues to own the copy of the Software and the physical media
+contained in the sales package and any other copy that You are
+authorized to make pursuant to this Agreement.
+
+Read this Agreement carefully before installing, downloading, or using
+the Software. By clicking on the "I Accept" button while installing,
+downloading, and/or using the Software, You agree to the terms and
+conditions of this Agreement. If You do not agree to all of the terms
+and conditions of this Agreement, promptly click the "Decline" or
+"I Do Not Accept" button, cancel the installation or downloading, or
+destroy or return the Software and accompanying documentation to
+Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU
+HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS
+TERMS AND CONDITIONS.
+
+</p>
+
+<p>
+                      COPYRIGHT LICENSE
+</p><p>
+      NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR
+      CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS
+</p><p>
+This Software Agreement ("Agreement") is between You (either an
+individual or an entity), the End User, and Nokia Corporation
+("Nokia"). The Agreement authorizes You to use the Software specified
+in Clause 1 below, which may be stored on a CD-ROM, sent to You by
+electronic mail, or downloaded from Nokia's Web pages or Servers or
+from other sources under the terms and conditions set forth below.
+This is an agreement on end-user rights and not an agreement for sale.
+Nokia continues to own the copy of the Software and the physical media
+contained in the sales package and any other copy that You are
+authorized to make pursuant to this Agreement.
+
+Read this Agreement carefully before installing, downloading, or using
+the Software. By clicking on the "I Accept" button while installing,
+downloading, and/or using the Software, You agree to the terms and
+conditions of this Agreement. If You do not agree to all of the terms
+and conditions of this Agreement, promptly click the "Decline" or
+"I Do Not Accept" button, cancel the installation or downloading, or
+destroy or return the Software and accompanying documentation to
+Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU
+HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS
+TERMS AND CONDITIONS.
+
+</p>
+
+<p>
+                      COPYRIGHT LICENSE
+</p><p>
+      NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR
+      CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS
+</p><p>
+This Software Agreement ("Agreement") is between You (either an
+individual or an entity), the End User, and Nokia Corporation
+("Nokia"). The Agreement authorizes You to use the Software specified
+in Clause 1 below, which may be stored on a CD-ROM, sent to You by
+electronic mail, or downloaded from Nokia's Web pages or Servers or
+from other sources under the terms and conditions set forth below.
+This is an agreement on end-user rights and not an agreement for sale.
+Nokia continues to own the copy of the Software and the physical media
+contained in the sales package and any other copy that You are
+authorized to make pursuant to this Agreement.
+
+Read this Agreement carefully before installing, downloading, or using
+the Software. By clicking on the "I Accept" button while installing,
+downloading, and/or using the Software, You agree to the terms and
+conditions of this Agreement. If You do not agree to all of the terms
+and conditions of this Agreement, promptly click the "Decline" or
+"I Do Not Accept" button, cancel the installation or downloading, or
+destroy or return the Software and accompanying documentation to
+Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU
+HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS
+TERMS AND CONDITIONS.
+
+</p>
+
+<p>
+                      COPYRIGHT LICENSE
+</p><p>
+      NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR
+      CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS
+</p><p>
+This Software Agreement ("Agreement") is between You (either an
+individual or an entity), the End User, and Nokia Corporation
+("Nokia"). The Agreement authorizes You to use the Software specified
+in Clause 1 below, which may be stored on a CD-ROM, sent to You by
+electronic mail, or downloaded from Nokia's Web pages or Servers or
+from other sources under the terms and conditions set forth below.
+This is an agreement on end-user rights and not an agreement for sale.
+Nokia continues to own the copy of the Software and the physical media
+contained in the sales package and any other copy that You are
+authorized to make pursuant to this Agreement.
+
+Read this Agreement carefully before installing, downloading, or using
+the Software. By clicking on the "I Accept" button while installing,
+downloading, and/or using the Software, You agree to the terms and
+conditions of this Agreement. If You do not agree to all of the terms
+and conditions of this Agreement, promptly click the "Decline" or
+"I Do Not Accept" button, cancel the installation or downloading, or
+destroy or return the Software and accompanying documentation to
+Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU
+HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS
+TERMS AND CONDITIONS.
+
+</p>
+
+<p>
+                      COPYRIGHT LICENSE
+</p><p>
+      NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR
+      CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS
+</p><p>
+This Software Agreement ("Agreement") is between You (either an
+individual or an entity), the End User, and Nokia Corporation
+("Nokia"). The Agreement authorizes You to use the Software specified
+in Clause 1 below, which may be stored on a CD-ROM, sent to You by
+electronic mail, or downloaded from Nokia's Web pages or Servers or
+from other sources under the terms and conditions set forth below.
+This is an agreement on end-user rights and not an agreement for sale.
+Nokia continues to own the copy of the Software and the physical media
+contained in the sales package and any other copy that You are
+authorized to make pursuant to this Agreement.
+
+Read this Agreement carefully before installing, downloading, or using
+the Software. By clicking on the "I Accept" button while installing,
+downloading, and/or using the Software, You agree to the terms and
+conditions of this Agreement. If You do not agree to all of the terms
+and conditions of this Agreement, promptly click the "Decline" or
+"I Do Not Accept" button, cancel the installation or downloading, or
+destroy or return the Software and accompanying documentation to
+Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU
+HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS
+TERMS AND CONDITIONS.
+
+</p>
+
+<p>
+                      COPYRIGHT LICENSE
+</p><p>
+      NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR
+      CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS
+</p><p>
+This Software Agreement ("Agreement") is between You (either an
+individual or an entity), the End User, and Nokia Corporation
+("Nokia"). The Agreement authorizes You to use the Software specified
+in Clause 1 below, which may be stored on a CD-ROM, sent to You by
+electronic mail, or downloaded from Nokia's Web pages or Servers or
+from other sources under the terms and conditions set forth below.
+This is an agreement on end-user rights and not an agreement for sale.
+Nokia continues to own the copy of the Software and the physical media
+contained in the sales package and any other copy that You are
+authorized to make pursuant to this Agreement.
+
+Read this Agreement carefully before installing, downloading, or using
+the Software. By clicking on the "I Accept" button while installing,
+downloading, and/or using the Software, You agree to the terms and
+conditions of this Agreement. If You do not agree to all of the terms
+and conditions of this Agreement, promptly click the "Decline" or
+"I Do Not Accept" button, cancel the installation or downloading, or
+destroy or return the Software and accompanying documentation to
+Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU
+HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS
+TERMS AND CONDITIONS.
+
+</p>
+
+<p>
+                      COPYRIGHT LICENSE
+</p><p>
+      NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR
+      CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS
+</p><p>
+This Software Agreement ("Agreement") is between You (either an
+individual or an entity), the End User, and Nokia Corporation
+("Nokia"). The Agreement authorizes You to use the Software specified
+in Clause 1 below, which may be stored on a CD-ROM, sent to You by
+electronic mail, or downloaded from Nokia's Web pages or Servers or
+from other sources under the terms and conditions set forth below.
+This is an agreement on end-user rights and not an agreement for sale.
+Nokia continues to own the copy of the Software and the physical media
+contained in the sales package and any other copy that You are
+authorized to make pursuant to this Agreement.
+
+Read this Agreement carefully before installing, downloading, or using
+the Software. By clicking on the "I Accept" button while installing,
+downloading, and/or using the Software, You agree to the terms and
+conditions of this Agreement. If You do not agree to all of the terms
+and conditions of this Agreement, promptly click the "Decline" or
+"I Do Not Accept" button, cancel the installation or downloading, or
+destroy or return the Software and accompanying documentation to
+Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU
+HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS
+TERMS AND CONDITIONS.
+
+</p>
+
+<p>
+                      COPYRIGHT LICENSE
+</p><p>
+      NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR
+      CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS
+</p><p>
+This Software Agreement ("Agreement") is between You (either an
+individual or an entity), the End User, and Nokia Corporation
+("Nokia"). The Agreement authorizes You to use the Software specified
+in Clause 1 below, which may be stored on a CD-ROM, sent to You by
+electronic mail, or downloaded from Nokia's Web pages or Servers or
+from other sources under the terms and conditions set forth below.
+This is an agreement on end-user rights and not an agreement for sale.
+Nokia continues to own the copy of the Software and the physical media
+contained in the sales package and any other copy that You are
+authorized to make pursuant to this Agreement.
+
+Read this Agreement carefully before installing, downloading, or using
+the Software. By clicking on the "I Accept" button while installing,
+downloading, and/or using the Software, You agree to the terms and
+conditions of this Agreement. If You do not agree to all of the terms
+and conditions of this Agreement, promptly click the "Decline" or
+"I Do Not Accept" button, cancel the installation or downloading, or
+destroy or return the Software and accompanying documentation to
+Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU
+HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS
+TERMS AND CONDITIONS.
+
+</p>
+
+<p>
+                      COPYRIGHT LICENSE
+</p><p>
+      NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR
+      CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS
+</p><p>
+This Software Agreement ("Agreement") is between You (either an
+individual or an entity), the End User, and Nokia Corporation
+("Nokia"). The Agreement authorizes You to use the Software specified
+in Clause 1 below, which may be stored on a CD-ROM, sent to You by
+electronic mail, or downloaded from Nokia's Web pages or Servers or
+from other sources under the terms and conditions set forth below.
+This is an agreement on end-user rights and not an agreement for sale.
+Nokia continues to own the copy of the Software and the physical media
+contained in the sales package and any other copy that You are
+authorized to make pursuant to this Agreement.
+
+Read this Agreement carefully before installing, downloading, or using
+the Software. By clicking on the "I Accept" button while installing,
+downloading, and/or using the Software, You agree to the terms and
+conditions of this Agreement. If You do not agree to all of the terms
+and conditions of this Agreement, promptly click the "Decline" or
+"I Do Not Accept" button, cancel the installation or downloading, or
+destroy or return the Software and accompanying documentation to
+Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU
+HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS
+TERMS AND CONDITIONS.
+
+</p>
+
+<p>
+                      COPYRIGHT LICENSE
+</p><p>
+      NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR
+      CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS
+</p><p>
+This Software Agreement ("Agreement") is between You (either an
+individual or an entity), the End User, and Nokia Corporation
+("Nokia"). The Agreement authorizes You to use the Software specified
+in Clause 1 below, which may be stored on a CD-ROM, sent to You by
+electronic mail, or downloaded from Nokia's Web pages or Servers or
+from other sources under the terms and conditions set forth below.
+This is an agreement on end-user rights and not an agreement for sale.
+Nokia continues to own the copy of the Software and the physical media
+contained in the sales package and any other copy that You are
+authorized to make pursuant to this Agreement.
+
+Read this Agreement carefully before installing, downloading, or using
+the Software. By clicking on the "I Accept" button while installing,
+downloading, and/or using the Software, You agree to the terms and
+conditions of this Agreement. If You do not agree to all of the terms
+and conditions of this Agreement, promptly click the "Decline" or
+"I Do Not Accept" button, cancel the installation or downloading, or
+destroy or return the Software and accompanying documentation to
+Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU
+HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS
+TERMS AND CONDITIONS.
+
+</p>
+
+<p>
+                      COPYRIGHT LICENSE
+</p><p>
+      NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR
+      CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS
+</p><p>
+This Software Agreement ("Agreement") is between You (either an
+individual or an entity), the End User, and Nokia Corporation
+("Nokia"). The Agreement authorizes You to use the Software specified
+in Clause 1 below, which may be stored on a CD-ROM, sent to You by
+electronic mail, or downloaded from Nokia's Web pages or Servers or
+from other sources under the terms and conditions set forth below.
+This is an agreement on end-user rights and not an agreement for sale.
+Nokia continues to own the copy of the Software and the physical media
+contained in the sales package and any other copy that You are
+authorized to make pursuant to this Agreement.
+
+Read this Agreement carefully before installing, downloading, or using
+the Software. By clicking on the "I Accept" button while installing,
+downloading, and/or using the Software, You agree to the terms and
+conditions of this Agreement. If You do not agree to all of the terms
+and conditions of this Agreement, promptly click the "Decline" or
+"I Do Not Accept" button, cancel the installation or downloading, or
+destroy or return the Software and accompanying documentation to
+Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU
+HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS
+TERMS AND CONDITIONS.
+
+</p>
+
+<p>
+                      COPYRIGHT LICENSE
+</p><p>
+      NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR
+      CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS
+</p><p>
+This Software Agreement ("Agreement") is between You (either an
+individual or an entity), the End User, and Nokia Corporation
+("Nokia"). The Agreement authorizes You to use the Software specified
+in Clause 1 below, which may be stored on a CD-ROM, sent to You by
+electronic mail, or downloaded from Nokia's Web pages or Servers or
+from other sources under the terms and conditions set forth below.
+This is an agreement on end-user rights and not an agreement for sale.
+Nokia continues to own the copy of the Software and the physical media
+contained in the sales package and any other copy that You are
+authorized to make pursuant to this Agreement.
+
+Read this Agreement carefully before installing, downloading, or using
+the Software. By clicking on the "I Accept" button while installing,
+downloading, and/or using the Software, You agree to the terms and
+conditions of this Agreement. If You do not agree to all of the terms
+and conditions of this Agreement, promptly click the "Decline" or
+"I Do Not Accept" button, cancel the installation or downloading, or
+destroy or return the Software and accompanying documentation to
+Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU
+HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS
+TERMS AND CONDITIONS.
+
+</p>
+
+
+</body>
+</html>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/files/JAD-1kB.dat	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,7 @@
+MIDlet-1: HelloWorld, , helloworld.HelloWorld
+MIDlet-Icon: \HelloWorld.png
+MIDlet-Jar-Size: 6817
+MIDlet-Jar-URL: HelloWorld.jar
+MIDlet-Name: HelloWorld
+MIDlet-Vendor: My Vendor
+MIDlet-Version: 1.0
Binary file creator/files/JAR-10kB.dat has changed
Binary file creator/files/JP2-65kB.dat has changed
Binary file creator/files/JPEG-200kB.dat has changed
Binary file creator/files/JPEG-25kB.dat has changed
Binary file creator/files/JPEG-500kB.dat has changed
Binary file creator/files/MIDI-10kB.dat has changed
Binary file creator/files/MP3-250kB.dat has changed
Binary file creator/files/MP4-200kB.dat has changed
Binary file creator/files/MXMF-40kB.dat has changed
Binary file creator/files/PNG-15kB.dat has changed
Binary file creator/files/PPT-40kB.dat has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/files/RAM-1kB.dat	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,1 @@
+rtsp://nokia.com
\ No newline at end of file
Binary file creator/files/RM-95kB.dat has changed
Binary file creator/files/RNG-1kB.dat has changed
Binary file creator/files/SISX-10kB.dat has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/files/SVG-15kB.dat	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg baseProfile="tiny" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%" viewBox="0 0 88 88">
+  <defs
+     id="defs6909" />
+  <rect
+     id="rect7683"
+     style="fill:#ffd800;fill-opacity:1.0000000;fill-rule:evenodd;stroke:#000000;stroke-width:0.12500001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000;stroke-dasharray:none"
+     transform="matrix(0.707097,0.707117,-0.707116,0.707097,0.000000,0.000000)"
+     y="-27.734158"
+     x="34.175232"
+     height="55.153564"
+     width="55.155079" />
+  <rect
+     id="rect10008"
+     style="fill:#ffd800;fill-opacity:0.00000000;stroke:#000000;stroke-width:1.4641515;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"
+     transform="matrix(0.707807,0.706406,-0.707368,0.706845,0.000000,0.000000)"
+     y="-24.579279"
+     x="37.081882"
+     height="49.570164"
+     width="49.602535" />
+  <path
+     id="path13048"
+     style="fill:none;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#000000;stroke-width:1.6682692;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"
+     d="M 27.031591,57.263037 L 60.609963,57.263037" />
+  <path
+     style="stroke-opacity:1.0000000;stroke-miterlimit:4.0000000;stroke-linejoin:miter;stroke-linecap:butt;stroke-width:0.12965260;stroke:#000000;fill-rule:evenodd;fill-opacity:1.0000000;fill:#000000"
+     d="M 53.055235,56.214138 C 52.624696,55.783599 53.895322,55.268316 54.042996,54.677621 C 54.177132,54.141074 54.531315,54.216369 54.372250,53.580108 C 54.255651,53.113713 53.875841,52.644696 53.603991,52.372845 C 53.309600,52.078454 53.118192,51.620750 52.945484,51.275333 C 52.703517,50.791400 52.280433,50.498349 51.957723,50.068070 C 51.603941,49.596361 51.413359,49.198844 51.189464,48.751055 C 50.899300,48.170724 50.368976,47.381811 49.982201,46.995036 C 49.704954,46.717789 49.601842,45.905065 49.433445,45.568270 C 49.184790,45.070960 49.138813,44.724882 48.774938,44.361006 C 48.320481,43.906550 47.740713,44.517222 47.567675,44.690260 C 47.298191,44.959743 46.811103,45.340001 46.360411,45.678021 C 45.855798,46.056480 45.501514,46.517804 45.262898,46.995036 C 45.012812,47.495209 44.962345,48.087501 44.823894,48.641303 C 44.672748,49.245890 44.626653,49.759521 44.494640,50.287572 C 44.374994,50.766160 44.494640,51.437604 44.494640,51.933840 C 44.494640,52.473242 44.479725,53.091014 44.384889,53.470358 C 44.236156,54.065293 43.580797,53.654026 44.165387,54.238616 C 44.585434,54.658664 44.644693,54.758223 44.933645,55.336128 C 45.224512,55.917862 44.973069,56.284464 44.714142,56.543391 C 44.460419,56.797114 43.654774,56.762894 43.177626,56.762894 C 42.469818,56.762894 41.865291,56.872645 41.202104,56.872645 C 40.653348,56.872645 40.104592,56.872645 39.555835,56.872645 C 39.007079,56.872645 38.458323,56.872645 37.909567,56.872645 C 37.360811,56.872645 36.812055,56.872645 36.263299,56.872645 C 35.361025,56.872645 34.513340,56.762894 33.629270,56.762894 C 33.007346,56.762894 32.385423,56.762894 31.763499,56.762894 C 31.141575,56.762894 30.519651,56.762894 29.897729,56.762894 C 29.316629,56.762894 28.811179,56.765634 28.361211,56.653142 C 28.294677,56.636509 28.361211,54.800636 28.361211,54.677621 C 28.361211,54.122622 28.373835,53.419862 28.470963,53.031353 C 28.595884,52.531668 28.801084,52.149872 28.909968,51.714338 C 29.009519,51.316133 29.389366,50.975043 29.568474,50.616825 C 29.828283,50.097211 29.986001,49.824729 30.117231,49.299811 C 30.235460,48.826894 30.775433,48.531857 30.995240,48.312050 C 31.322699,47.984592 31.766969,47.981929 32.202504,47.873045 C 32.844620,47.712517 33.143720,48.218959 33.300016,48.531553 C 33.507317,48.946154 33.940327,49.281615 34.178026,49.519314 C 34.504402,49.845689 34.655723,50.255205 34.836533,50.616825 C 35.036987,51.017734 35.283331,51.306507 35.385290,51.714338 C 35.510174,52.213877 35.484864,52.661395 35.604792,53.141103 C 35.720800,53.605133 36.020969,53.996287 36.263299,54.238616 C 36.590757,54.566074 37.035027,54.568737 37.470562,54.677621 C 37.877196,54.779280 38.450774,54.787372 39.007079,54.787372 C 39.499561,54.787372 39.726237,54.336816 39.885089,54.019113 C 40.048252,53.692788 39.994840,52.735696 39.994840,52.372845 C 39.994840,51.764083 39.885089,51.340231 39.885089,50.836328 C 39.885089,50.227207 39.994840,49.666649 39.994840,49.080309 C 39.994840,48.594446 40.231693,47.913395 40.324094,47.543792 C 40.463214,46.987311 40.640950,46.471075 40.872850,46.007275 C 41.112138,45.528699 41.332188,45.417852 41.531357,45.019514 C 41.798584,44.485060 41.919124,44.478034 41.641109,43.922001 C 41.427678,43.495140 41.418998,43.033558 41.311854,42.604987 C 41.183697,42.092355 41.189896,41.666058 41.311854,41.178221 C 41.441133,40.661112 41.531357,40.378202 41.531357,39.751456 C 41.531357,39.357313 41.147280,38.983300 40.982601,38.653943 C 40.761616,38.211972 40.577118,38.019774 40.433845,37.446679 C 40.293896,36.886882 40.102128,36.558816 39.994840,36.129665 C 39.884579,35.688622 39.615766,35.371517 39.446084,35.032153 C 39.247021,34.634025 39.226582,34.204135 39.226582,33.605387 C 39.226582,32.945903 39.466503,32.796291 39.665587,32.398124 C 39.865488,31.998320 40.030648,31.703808 40.324094,31.410363 C 40.648346,31.086110 40.792597,30.722357 41.092353,30.422602 C 41.497139,30.017815 40.746419,29.764094 40.324094,29.764094 C 39.766471,29.764094 39.381552,29.512327 39.007079,29.325090 C 38.644368,29.143734 38.429384,28.550821 38.348572,28.227577 C 38.239216,27.790154 37.911825,27.569635 37.470562,27.459319 C 36.870536,27.309312 36.716357,27.816679 36.373050,27.130065 C 36.166333,26.716631 36.263299,26.084628 36.263299,25.593549 C 36.263299,25.032763 36.269922,24.469546 36.373050,24.057031 C 36.480019,23.629153 36.767491,23.268149 36.921806,22.959519 C 37.118553,22.566025 37.706265,22.347787 38.019318,22.191261 C 38.389122,22.006359 39.035295,22.081510 39.555835,22.081510 C 40.104592,22.081510 40.653348,22.081510 41.202104,22.081510 C 41.550777,22.081510 42.048741,22.504828 42.299615,22.630266 C 42.779900,22.870407 43.095825,22.877718 43.397128,23.179022 C 43.856580,23.638474 43.334114,23.790792 43.067875,24.057031 C 42.608660,24.516246 42.293774,24.264849 42.628870,24.935041 C 42.796868,25.271038 43.241637,25.657560 43.506879,25.922802 C 43.829866,26.245788 44.071833,26.471558 44.604392,26.471558 C 45.231133,26.471558 45.468527,26.258992 45.921406,26.032553 C 46.380507,25.803003 46.621967,25.682272 47.018918,25.483797 C 47.432354,25.277079 48.064355,25.374046 48.555436,25.374046 C 48.881562,25.374046 49.547228,25.870950 49.762698,26.032553 C 50.233060,26.385325 50.346134,26.562541 50.860211,26.691060 C 51.323258,26.806822 51.603308,27.096337 52.177225,27.239816 C 52.669260,27.362825 53.085679,27.686432 53.494239,27.788572 C 54.085273,27.936331 54.424563,27.883965 54.921006,28.008075 C 55.515417,28.156678 55.672225,28.522753 55.908767,28.995836 C 56.129829,29.437960 56.491410,29.722118 56.677025,30.093348 C 56.910943,30.561183 56.502923,30.880558 56.238021,31.410363 C 56.056374,31.773656 55.750791,32.117094 55.469761,32.398124 C 55.126451,32.741435 54.982268,33.373113 54.811255,33.715138 C 54.580847,34.175955 54.213651,34.581092 53.933245,35.141904 C 53.665425,35.677541 53.569455,36.088987 53.384489,36.458918 C 53.193251,36.841393 53.274738,37.478767 53.274738,37.995435 C 53.274738,38.355483 53.637246,38.896713 53.713742,39.202699 C 53.826257,39.652756 54.049119,39.995451 54.152747,40.409962 C 54.261646,40.845559 54.246127,41.441991 54.372250,41.946479 C 54.491897,42.425068 54.372250,43.096512 54.372250,43.592748 C 54.372250,44.221105 54.406333,44.648676 54.591752,45.019514 C 54.805887,45.447783 54.950405,45.736818 55.140508,46.117026 C 55.318283,46.472575 55.666926,46.862946 56.018518,47.214537 C 56.421894,47.617914 56.456093,48.089688 56.677025,48.531553 C 56.956851,49.091204 57.024443,49.445891 57.225781,49.848567 C 57.525499,50.448001 57.843039,50.781081 57.994040,51.385084 C 58.121209,51.893759 58.424571,52.009700 58.542796,52.482597 C 58.645326,52.892716 58.958398,53.157244 59.091552,53.689860 C 59.206608,54.150081 59.311055,54.491721 59.311055,55.116625 C 59.311055,55.745296 59.151256,56.154433 58.872050,56.433641 C 58.548620,56.757070 57.979019,56.653142 57.445283,56.653142 C 57.019297,56.653142 56.409259,56.762894 55.908767,56.762894 C 55.327666,56.762894 54.822217,56.760154 54.372250,56.872645 C 53.888809,56.993505 53.322734,56.966958 52.945484,56.872645 C 52.548865,56.773490 53.055235,56.085649 53.055235,55.665381"
+     id="path2140" />
+  <path
+     style="fill:#000000;fill-opacity:1.0000000;fill-rule:evenodd;stroke:#000000;stroke-width:0.15643996;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"
+     d="M 38.428125,47.795987 C 38.311148,47.854477 36.965297,46.068306 36.706578,45.809587 C 36.275090,45.378099 35.986619,44.957203 35.647163,44.617746 C 35.160123,44.130704 34.556573,44.434693 34.190469,44.617746 C 33.723208,44.851375 33.274878,45.075540 32.866201,45.279879 C 32.358140,45.533910 32.262581,46.015925 31.939214,46.339294 C 31.632132,46.646376 31.393272,47.331218 31.277080,47.795987 C 31.083157,48.571681 31.468244,48.972877 31.674360,49.385108 C 31.912314,49.861016 32.778380,50.223928 33.131055,50.312097 C 33.776711,50.473511 34.431575,50.444524 35.117456,50.444524 C 35.382879,50.444524 36.028034,49.885811 36.441723,49.782389 C 36.905836,49.666361 37.228511,49.190356 37.633565,48.987829 C 37.959970,48.824626 38.265273,48.203119 38.428125,47.795987 z "
+     id="path2902" />
+  <path
+     style="fill:none;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#000000;stroke-width:1.0000000px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000"
+     d="M 36.399595,46.098141 C 41.690234,42.288881 41.690234,42.288881 41.690234,42.288881"
+     id="path3662" />
+  <path
+     style="fill:#ffd800;fill-opacity:1.0000000;fill-rule:evenodd;stroke:#000000;stroke-width:0.00000000;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"
+     d="M 51.177526,33.514353 C 51.643815,33.290634 52.117036,32.810504 52.277706,32.050272 C 52.490950,31.041286 52.186388,30.532180 51.727616,30.260839 C 51.228746,29.965782 50.690078,29.935489 49.939823,29.935489 C 48.958188,29.935489 48.839642,29.898727 48.839642,31.074218 C 48.839642,31.604089 49.483749,32.272697 49.664777,32.700974 C 49.972897,33.429925 50.486789,33.514353 51.177526,33.514353 z "
+     id="path3666" />
+  <path
+     style="fill:#ffd800;fill-opacity:1.0000000;fill-rule:evenodd;stroke:none;stroke-width:0.00000000;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"
+     d="M 43.339938,38.616989 C 43.358543,38.676580 44.048989,37.735278 44.132320,37.601827 C 44.413539,37.151472 44.464358,36.937090 44.370034,36.332872 C 44.312608,35.965007 43.825038,35.713886 43.656891,35.444606 C 43.366077,34.978882 43.133760,34.623676 42.864509,34.048757 C 42.530139,33.334791 42.389080,34.076845 42.389080,34.683233 C 42.389080,35.330477 42.556959,35.728514 42.706032,36.205977 C 42.849733,36.666232 42.864509,37.134957 42.864509,37.855617 C 42.864509,38.303047 43.016630,38.409884 43.339938,38.616989 z "
+     id="path4426" />
+  <path
+     style="fill:#000000;fill-opacity:1.0000000;fill-rule:evenodd;stroke:#000000;stroke-width:0.00000000;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"
+     d="M 43.635359,9.6022099 C 40.526110,12.711459 40.475138,12.762431 40.475138,12.762431 L 46.795580,12.762431 L 43.635359,9.6022099 z "
+     id="path8982" />
+  <path
+     style="fill:#000000;fill-opacity:1.0000000;fill-rule:evenodd;stroke:#000000;stroke-width:0.00000000;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"
+     d="M 43.878453,78.154696 C 40.769204,75.045447 40.718232,74.994475 40.718232,74.994475 L 47.038674,74.994475 L 43.878453,78.154696 z "
+     id="path9742" />
+  <path
+     style="fill:#000000;fill-opacity:1.0000000;fill-rule:evenodd;stroke:#000000;stroke-width:0.00000000;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"
+     d="M 9.4806628,43.878454 C 12.589911,46.987703 12.640883,47.038675 12.640883,47.038675 L 12.640883,40.718232 L 9.4806628,43.878454 z "
+     id="path9744" />
+  <path
+     style="fill:#000000;fill-opacity:1.0000000;fill-rule:evenodd;stroke:#000000;stroke-width:0.00000000;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"
+     d="M 78.033148,43.756906 C 74.923900,46.866155 74.872928,46.917127 74.872928,46.917127 L 74.872928,40.596684 L 78.033148,43.756906 z "
+     id="path9746" />
+</svg>
Binary file creator/files/SWF-15kB.dat has changed
Binary file creator/files/TIF-25kB.dat has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/files/TXT-10kB.dat	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,19 @@
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/files/TXT-70kB.dat	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,147 @@
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing.Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... TestiTesting... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing..ing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Te. Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... 
+
+
+Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... ng... .. 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/files/VCF-1kB.dat	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,17 @@
+BEGIN:VCARD
+VERSION:2.1
+N:Smith;John
+FN:John Smith
+ORG:Firm
+TITLE:Boss
+NOTE;ENCODING=QUOTED-PRINTABLE:Liirum larum.=0D=0A
+TEL;WORK;VOICE:132456798
+TEL;HOME;VOICE:654654987
+TEL;CELL;VOICE:0400654987654
+TEL;WORK;FAX:2321654987987
+ADR;WORK:;;Firmstreet 1;New City;Sawo;00000;Finland
+LABEL;WORK;ENCODING=QUOTED-PRINTABLE:Firmstreet 1=0D=0ANew City, Sawo 00000=0D=0AFinland
+URL;WORK:http://www.nokia.com
+EMAIL;PREF;INTERNET:John.Smith@firm.com
+REV:20080306T115812Z
+END:VCARD
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/files/VCS-1kB.dat	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,15 @@
+BEGIN:VCALENDAR
+PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN
+VERSION:1.0
+BEGIN:VEVENT
+DTSTART:20080306T060000Z
+DTEND:20080306T070000Z
+LOCATION;ENCODING=QUOTED-PRINTABLE:Meeting room
+UID:040000008200E00074C5B7101A82E00800000000000CEF7E917FC8010000000000000000100
+ 000008AA6A7A7250C0A4E97153769E69DD064
+DESCRIPTION;ENCODING=QUOTED-PRINTABLE:Remember to bring laptop and document=
+ation=0D=0A
+SUMMARY;ENCODING=QUOTED-PRINTABLE:Meeting with BOSS
+PRIORITY:3
+END:VEVENT
+END:VCALENDAR
Binary file creator/files/WAV-20kB.dat has changed
Binary file creator/files/WMA-50kB.dat has changed
Binary file creator/files/WMV-200kB.dat has changed
Binary file creator/files/XLS-15kB.dat has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/group/ReleaseNotes_Creator.txt	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,206 @@
+===============================================================================
+
+RELEASE NOTES - CREATOR v5.3.5
+RELEASED 30th October 2009 
+
+SUPPORTS S60 3.0+
+
+===============================================================================
+
+Product Description:
+====================
+The Creator tool can be used to create different kinds of data into a device.
+It's useful for testing that the device works correctly when there are
+large amounts of data saved.
+
+Main Features:
+==============
+- Creating appointment, event, anniversary, todo, and reminder entries
+- Creating bookmark, bookmark folder, saved page, and saved page folder
+  entries
+- Creating different kinds of predefined file formats with or without DRM
+- Creating missed call, received call, and dialed number entries
+- Creating SMS, MMS, AMS, Email, Smart, Infrared and Bluetooth messages
+- Creating mailbox entries
+- Creating connection method, IMPS server, landmark and note entries
+- Creating contact and contact group entries
+- Entries can be created on the UI or by using scripts
+- Entries can be deleted with the UI
+
+===============================================================================
+
+What's New in v5.3.5
+====================
+- Fix: Creator crashes when creating 2000 contact entries.
+- Fix: Creator cannot create 1000 SMS messages
+
+===============================================================================
+
+Installation Notes:
+===================
+Creator is typically preinstalled on ROM. If not, it can be added to the
+ROM with the .iby file. Alternatively, a .sis file can be found under the sis-
+directory, but the user needs 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:
+  ReadDeviceData
+  WriteDeviceData
+  AllFiles
+  SwEvent
+  NetworkServices
+  LocalServices
+  ReadUserData
+  WriteUserData
+  Location
+  UserEnvironment
+
+===============================================================================
+
+System Requirements:
+====================
+Basic Requirements:
+- Any S60 3.x device, 5.x device or emulator environment
+
+===============================================================================
+
+Compatibility Issues:
+=====================
+Since version 5.0.0, the old .creator script files are no longer supported, 
+therefore you should use the new .creatorxml format instead. However, the script
+support is not available for S60 3.0 and 3.1 releases.
+
+When Creator has been compiled against 3.0 or 3.1, it will use the old
+phonebook and accesspoint APIs. With 3.2 and newer, new virtual phonebook and
+connection method APIs are used.
+
+===============================================================================
+
+Known Issues:
+=============
+- Generated browser saved pages cannot be opened in the browser. Currently no
+  workaround available.
+- Logs: <datetime> element is not saved into database. Event time is always
+  creation time of the event. S60 feature.
+- Deleting Notes created only with Creator is not supported
+- Deleting mailboxes is not supported
+- Deleting entries without using Creator may cause Creator to delete incorrect
+  entries when using Delete -> ... -> By Creator -command
+  
+===============================================================================
+
+Version History:
+================
+
+Version 5.3.4 - 12th October 2009
+---------------------------------
+- Fix: Cannot create SMS messages in inbox with Creator
+- Fix: Softkeys are not visible immediately when progress bar is shown
+
+Version 5.3.3 - 26th August 2009
+-------------------------------- 
+- Fix: Creator crashes when using scripts to create calendar appointments, 
+  which have existing contacts as attendees.
+- Fix: Destinations cannot be opened after deleting connection methods with
+  Creator.
+  
+Version 5.3.2 - 17th April 2009
+------------------------------- 
+- Fix: Creator crashes after phonebook operation
+
+Version 5.3.1 - 20th February 2009
+----------------------------------
+- Fix: Unable to create a phonebook group with more than 15 members
+
+Version 5.3.0 - 13th February 2009
+----------------------------------
+- Change: XML Schema is now available for validating Creator scripts
+- Change: Creator now deletes files created by Creator when selecting
+  Options -> Delete -> All
+- Fix: Creator crashes when creating RNG file
+- Fix: Creator crashes when creating large amount of files
+- Fix: Actual MIDI and 3GPP filenames are different from names described in
+  Creator UI
+- Fix: Text type attachment are not displayed correctly with generated messages
+ 
+Version 5.2.2 - 12th December 2008
+----------------------------------
+- Change: Generated file data changed 
+
+Version 5.2.1 - 14th November 2008
+----------------------------------
+- Fix: VCS and VCF type attachments does not work with MMS in Creator scripts
+- Fix: DRM accumulated element in Creator script mixes up starttime and
+  endtime values
+- Fix: Deleting Browser Bookmark folders -> By Creator deletes all bookmark
+  folders when it should delete only those created with Creator
+
+Version 5.2.0 - 31st October 2008
+---------------------------------
+- Feature: Deleting entries
+- Feature: Support for creating WMA and WMV files 
+
+Version 5.1.1 - 3rd October 2008
+--------------------------------
+- Fix: Creator creates messages with invalid recepients which causes Messages
+  application to crash
+- Fix: Creator crashes when pressing cancel while creating phonebook entries
+- Feature: Script support for DRM protected files
+- Feature: "incvalueforeachcopy" attribute introduced for increasing phone
+  numbers in scripts
+  
+Version 5.1.0 - 19th September 2008
+-----------------------------------
+- Feature: DRM protected files can be now generated
+- Fix: Message read status does not get generated correctly from script
+- Change: Legacy version removed
+
+Version 5.0.4 - 8th August 2008
+-------------------------------
+- Feature: Random string can be now specified via an external XML file if not
+  wanting to use the defaults provided by the tool
+- Fix: Crash when creating new landmark entries
+
+Version 5.0.3 - 2nd June 2008
+-----------------------------
+- Feature: Scripts can be now executed directly via commandline
+- Fix: With some combinations of parameters, connection method generation could
+  fail
+  
+Version 5.0.2 - 14th May 2008
+-----------------------------
+- Fix: Error handling in calendar entry recurrency rule improved
+- Fix: Context check for script's fields could fail
+
+Version 5.0.1 - 5th May 2008
+----------------------------
+- Fix: Calendar entry creation may crash due to incorrect status field
+- Fix: Saved deck entry creation may crash due to invalid path
+
+Version 5.0.0 - 21st April 2008
+-------------------------------
+- Feature: Uses Virtual Phonebook API for S60 3.2 or newer 
+- Feature: Uses Connection Method API for S60 3.2 or newer 
+- Feature: Creation of Landmarks 
+- Feature: Completely new XML based script-format supporting all features
+- Change: Agenda API replaced with Calendar Interim API
+
+Version 4.9.0 - 1st April 2008
+------------------------------
+- Change: Modified to support coexisting with Creator 5.0.0   
+
+Version 4.8.1 - 19th March 2008
+---------------------------------
+- Fix: Contact groups were created incorrectly
+
+===============================================================================
+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".
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/group/backup_registration.xml	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,8 @@
+<?xml version="1.0" standalone="yes"?>
+<backup_registration>
+  <passive_backup>
+    <include_directory name="\"/>
+  </passive_backup>
+  <system_backup/>
+  <restore requires_reboot = "no"/>
+</backup_registration>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,102 @@
+/*
+* 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:  
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_EXPORTS
+../group/backup_registration.xml    Z:/private/20011383/backup_registration.xml
+../files/3GPP-70kB.dat              Z:/private/20011383/3GPP-70kB.3gpp
+../files/AAC-100kB.dat              Z:/private/20011383/AAC-100kB.aac
+../files/AMR-20kB.dat               Z:/private/20011383/AMR-20kB.amr
+../files/BMP-25kB.dat               Z:/private/20011383/BMP-25kB.bmp
+../files/Deck-1kB.dat               Z:/private/20011383/Deck-1kB.saveddeck
+../files/DOC-20kB.dat               Z:/private/20011383/DOC-20kB.doc
+../files/GIF-2kB.dat                Z:/private/20011383/GIF-2kB.gif
+../files/HTML-20kB.dat              Z:/private/20011383/HTML-20kB.html
+../files/JAD-1kB.dat                Z:/private/20011383/JAD-1kB.jad
+../files/JAR-10kB.dat               Z:/private/20011383/JAR-10kB.jar
+../files/JP2-65kB.dat               Z:/private/20011383/JP2-65kB.jp2
+../files/JPEG-200kB.dat             Z:/private/20011383/JPEG-200kB.jpg
+../files/JPEG-25kB.dat              Z:/private/20011383/JPEG-25kB.jpg
+../files/JPEG-500kB.dat             Z:/private/20011383/JPEG-500kB.jpg
+../files/MIDI-10kB.dat              Z:/private/20011383/MIDI-10kB.mid
+../files/MP3-250kB.dat              Z:/private/20011383/MP3-250kB.mp3
+../files/MP4-200kB.dat              Z:/private/20011383/MP4-200kB.mp4
+../files/MXMF-40kB.dat              Z:/private/20011383/MXMF-40kB.mxmf
+../files/PNG-15kB.dat               Z:/private/20011383/PNG-15kB.png
+../files/PPT-40kB.dat               Z:/private/20011383/PPT-40kB.ppt
+../files/RAM-1kB.dat                Z:/private/20011383/RAM-1kB.ram
+../files/RM-95kB.dat                Z:/private/20011383/RM-95kB.rm
+../files/RNG-1kB.dat                Z:/private/20011383/RNG-1kB.rng
+../files/SVG-15kB.dat               Z:/private/20011383/SVG-15kB.svg
+../files/SWF-15kB.dat               Z:/private/20011383/SWF-15kB.swf
+../files/TIF-25kB.dat               Z:/private/20011383/TIF-25kB.tif
+../files/TXT-10kB.dat               Z:/private/20011383/TXT-10kB.txt
+../files/TXT-70kB.dat               Z:/private/20011383/TXT-70kB.txt
+../files/VCF-1kB.dat                Z:/private/20011383/VCF-1kB.vcf
+../files/VCS-1kB.dat                Z:/private/20011383/VCS-1kB.vcs
+../files/WAV-20kB.dat               Z:/private/20011383/WAV-20kB.wav
+../files/XLS-15kB.dat               Z:/private/20011383/XLS-15kB.xls
+../files/SISX-10kB.dat              Z:/private/20011383/SISX-10kB.sisx
+../files/WMA-50kB.dat               Z:/private/20011383/WMA-50kB.wma
+../files/WMV-200kB.dat              Z:/private/20011383/WMV-200kB.wmv
+
+../scripts/creator.xsd                   +/tools/s60rndtools/creator/creator.xsd
+../scripts/browserEx.creatorxml          +/tools/s60rndtools/creator/browserEx.creatorxml
+../scripts/calendarEx.creatorxml         +/tools/s60rndtools/creator/calendarEx.creatorxml
+../scripts/connectionmethodEx.creatorxml +/tools/s60rndtools/creator/connectionmethodEx.creatorxml
+../scripts/contactEx.creatorxml          +/tools/s60rndtools/creator/contactEx.creatorxml
+../scripts/filesEx.creatorxml            +/tools/s60rndtools/creator/filesEx.creatorxml
+../scripts/impsEx.creatorxml             +/tools/s60rndtools/creator/impsEx.creatorxml
+../scripts/landmarkEx.creatorxml         +/tools/s60rndtools/creator/landmarkEx.creatorxml
+../scripts/logEx.creatorxml              +/tools/s60rndtools/creator/logEx.creatorxml
+../scripts/mailboxEx.creatorxml          +/tools/s60rndtools/creator/mailboxEx.creatorxml
+../scripts/messagesEx.creatorxml         +/tools/s60rndtools/creator/messagesEx.creatorxml
+../scripts/notepadEx.creatorxml          +/tools/s60rndtools/creator/notepadEx.creatorxml
+
+#ifdef CORE_IBY_EXPORT_PATH
+  ../rom/creator.iby CORE_IBY_EXPORT_PATH(tools,creator.iby)
+#endif
+
+
+PRJ_MMPFILES
+#if defined(__SERIES60_30__) || defined(__SERIES60_31__) || defined(__S60_32__)
+  gnumakefile creator_icons_aif.mk
+
+  #ifdef MARM
+  gnumakefile creator_stub_sis.mk
+  #endif
+#endif
+
+creator.mmp
+
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)
+  PRJ_EXTENSIONS
+  START EXTENSION s60/mifconv
+  OPTION TARGETFILE creator_aif.mif
+  OPTION SOURCEDIR ../icons
+  OPTION SOURCES -c8,8 qgn_menu_creator
+  END
+
+  #ifdef MARM
+  START EXTENSION app-services/buildstubsis
+  OPTION SRCDIR ../sis
+  OPTION SISNAME Creator_stub
+  END
+  #endif  
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/group/creator.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,158 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+
+TARGET            creator.exe
+TARGETTYPE        exe
+EPOCSTACKSIZE     0x5000
+EPOCHEAPSIZE      0x10000 0x2000000  // Min 64Kb, Max 32Mb
+
+UID 0x100039CE    0x20011383
+
+VENDORID          VID_DEFAULT
+CAPABILITY        CAP_APPLICATION AllFiles
+
+SMPSAFE
+
+LANG              SC
+
+
+START RESOURCE    ../data/creator.rss
+HEADER
+TARGETPATH        APP_RESOURCE_DIR
+END
+
+START RESOURCE    ../data/creator_reg.rss
+DEPENDS           creator.rsg
+TARGETPATH        /private/10003a3f/apps
+END
+
+APP_LAYER_SYSTEMINCLUDE
+USERINCLUDE       ../inc
+SOURCEPATH        ../src
+
+
+SOURCE            creator.cpp
+SOURCE            creator_app.cpp 
+SOURCE            creator_document.cpp
+SOURCE            creator_appui.cpp
+SOURCE            creator_container.cpp
+SOURCE            creator_model.cpp
+SOURCE            creator_factory.cpp 
+SOURCE            creator_scriptentry.cpp
+SOURCE            creator_scriptparser.cpp 
+SOURCE            creator_scriptelementfactory.cpp 
+SOURCE 		      creator_scriptelement.cpp
+SOURCE            creator_calendar.cpp  
+SOURCE            creator_calendarelement.cpp 
+SOURCE            creator_message.cpp 
+SOURCE            creator_messageelement.cpp 
+SOURCE            creator_note.cpp
+SOURCE            creator_noteelement.cpp 
+SOURCE            creator_log.cpp
+SOURCE 			  creator_logelement.cpp 
+SOURCE            creator_file.cpp
+SOURCE 			  creator_fileelement.cpp 
+SOURCE            creator_browser.cpp 
+SOURCE 			  creator_browserelement.cpp 
+SOURCE            creator_imps.cpp
+SOURCE		      creator_impselement.cpp 
+SOURCE            creator_mailbox.cpp
+SOURCE 			  creator_mailboxelement.cpp 
+SOURCE			  creator_landmark.cpp 
+SOURCE 			  creator_landmarkelement.cpp 
+SOURCE 			  creator_phonebookbase.cpp 
+SOURCE 			  creator_contactelement.cpp 
+SOURCE            creator_contactsetcache.cpp 
+SOURCE			  creator_connectionmethodelement.cpp
+SOURCE			  creator_randomdataparser.cpp
+
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+  SOURCE			  creator_phonebook.cpp
+  SOURCE			  creator_accesspoint.cpp 
+#else
+  SOURCE			  creator_virtualphonebook.cpp
+  SOURCE			  creator_connectionmethod.cpp
+#endif  
+
+
+LIBRARY euser.lib
+LIBRARY apparc.lib
+LIBRARY cone.lib 
+LIBRARY eikcore.lib  
+LIBRARY avkon.lib 
+LIBRARY aknnotify.lib
+LIBRARY estor.lib
+LIBRARY cntmodel.lib	
+LIBRARY favouritesengine.lib
+LIBRARY msgs.lib
+LIBRARY logwrap.lib
+LIBRARY logcli.lib
+LIBRARY efsrv.lib
+LIBRARY gsmu.lib
+LIBRARY imcm.lib
+LIBRARY npdlib.lib
+LIBRARY bafl.lib 
+LIBRARY eikcoctl.lib 
+LIBRARY eikctl.lib
+LIBRARY commdb.lib
+LIBRARY muiu.lib
+LIBRARY etext.lib 
+LIBRARY commonengine.lib 
+LIBRARY commonui.lib 
+LIBRARY platformenv.lib 
+LIBRARY apgrfx.lib
+LIBRARY apmime.lib
+LIBRARY obexmtmutil.lib
+LIBRARY smcm.lib
+LIBRARY aknskins.lib
+LIBRARY aknskinsrv.lib 
+LIBRARY flogger.lib
+LIBRARY etel.lib
+LIBRARY etelmm.lib
+LIBRARY xmlframework.lib
+LIBRARY charconv.lib 
+LIBRARY senutils.lib
+LIBRARY calinterimapi.lib
+LIBRARY eposlandmarks.lib
+LIBRARY lbs.lib
+LIBRARY ecom.lib
+LIBRARY caf.lib
+LIBRARY cafutils.lib 
+LIBRARY drmrights.lib
+LIBRARY edbms.lib
+LIBRARY imageconversion.lib
+LIBRARY fbscli.lib
+LIBRARY bitmaptransforms.lib
+
+#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
+  LIBRARY apengine.lib
+  LIBRARY pbkeng.lib
+#else
+  LIBRARY cmmanager.lib
+  LIBRARY cmmanagerdatabase.lib
+  LIBRARY vpbkeng.lib
+  LIBRARY pbk2presentation.lib		
+#endif
+
+#ifdef __PRESENCE
+  LIBRARY wvsapsettingsstore.lib
+#endif  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/group/creator_icons_aif.mk	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,54 @@
+#
+# Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:  
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z
+else
+ZDIR=\epoc32\data\z
+endif
+
+TARGETDIR=$(ZDIR)\resource\apps
+ICONTARGETFILENAME=$(TARGETDIR)\creator_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_creator.svg
+	mifconv $(ICONTARGETFILENAME) \
+		/c8,8 ..\icons\qgn_menu_creator.svg
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/group/creator_stub_sis.mk	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,56 @@
+#
+# Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:  
+#
+
+
+TARGETDIR=$(EPOCROOT)EPOC32\Data\Z\System\Install
+
+SISNAME=Creator_stub
+PKGNAME=Creator_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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/icons/qgn_menu_creator.svg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg baseProfile="tiny" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%" viewBox="0 0 88 88">
+  <defs
+     id="defs6909" />
+  <rect
+     id="rect7683"
+     style="fill:#ffd800;fill-opacity:1.0000000;fill-rule:evenodd;stroke:#000000;stroke-width:0.12500001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000;stroke-dasharray:none"
+     transform="matrix(0.707097,0.707117,-0.707116,0.707097,0.000000,0.000000)"
+     y="-27.734158"
+     x="34.175232"
+     height="55.153564"
+     width="55.155079" />
+  <rect
+     id="rect10008"
+     style="fill:#ffd800;fill-opacity:0.00000000;stroke:#000000;stroke-width:1.4641515;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"
+     transform="matrix(0.707807,0.706406,-0.707368,0.706845,0.000000,0.000000)"
+     y="-24.579279"
+     x="37.081882"
+     height="49.570164"
+     width="49.602535" />
+  <path
+     id="path13048"
+     style="fill:none;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#000000;stroke-width:1.6682692;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"
+     d="M 27.031591,57.263037 L 60.609963,57.263037" />
+  <path
+     style="stroke-opacity:1.0000000;stroke-miterlimit:4.0000000;stroke-linejoin:miter;stroke-linecap:butt;stroke-width:0.12965260;stroke:#000000;fill-rule:evenodd;fill-opacity:1.0000000;fill:#000000"
+     d="M 53.055235,56.214138 C 52.624696,55.783599 53.895322,55.268316 54.042996,54.677621 C 54.177132,54.141074 54.531315,54.216369 54.372250,53.580108 C 54.255651,53.113713 53.875841,52.644696 53.603991,52.372845 C 53.309600,52.078454 53.118192,51.620750 52.945484,51.275333 C 52.703517,50.791400 52.280433,50.498349 51.957723,50.068070 C 51.603941,49.596361 51.413359,49.198844 51.189464,48.751055 C 50.899300,48.170724 50.368976,47.381811 49.982201,46.995036 C 49.704954,46.717789 49.601842,45.905065 49.433445,45.568270 C 49.184790,45.070960 49.138813,44.724882 48.774938,44.361006 C 48.320481,43.906550 47.740713,44.517222 47.567675,44.690260 C 47.298191,44.959743 46.811103,45.340001 46.360411,45.678021 C 45.855798,46.056480 45.501514,46.517804 45.262898,46.995036 C 45.012812,47.495209 44.962345,48.087501 44.823894,48.641303 C 44.672748,49.245890 44.626653,49.759521 44.494640,50.287572 C 44.374994,50.766160 44.494640,51.437604 44.494640,51.933840 C 44.494640,52.473242 44.479725,53.091014 44.384889,53.470358 C 44.236156,54.065293 43.580797,53.654026 44.165387,54.238616 C 44.585434,54.658664 44.644693,54.758223 44.933645,55.336128 C 45.224512,55.917862 44.973069,56.284464 44.714142,56.543391 C 44.460419,56.797114 43.654774,56.762894 43.177626,56.762894 C 42.469818,56.762894 41.865291,56.872645 41.202104,56.872645 C 40.653348,56.872645 40.104592,56.872645 39.555835,56.872645 C 39.007079,56.872645 38.458323,56.872645 37.909567,56.872645 C 37.360811,56.872645 36.812055,56.872645 36.263299,56.872645 C 35.361025,56.872645 34.513340,56.762894 33.629270,56.762894 C 33.007346,56.762894 32.385423,56.762894 31.763499,56.762894 C 31.141575,56.762894 30.519651,56.762894 29.897729,56.762894 C 29.316629,56.762894 28.811179,56.765634 28.361211,56.653142 C 28.294677,56.636509 28.361211,54.800636 28.361211,54.677621 C 28.361211,54.122622 28.373835,53.419862 28.470963,53.031353 C 28.595884,52.531668 28.801084,52.149872 28.909968,51.714338 C 29.009519,51.316133 29.389366,50.975043 29.568474,50.616825 C 29.828283,50.097211 29.986001,49.824729 30.117231,49.299811 C 30.235460,48.826894 30.775433,48.531857 30.995240,48.312050 C 31.322699,47.984592 31.766969,47.981929 32.202504,47.873045 C 32.844620,47.712517 33.143720,48.218959 33.300016,48.531553 C 33.507317,48.946154 33.940327,49.281615 34.178026,49.519314 C 34.504402,49.845689 34.655723,50.255205 34.836533,50.616825 C 35.036987,51.017734 35.283331,51.306507 35.385290,51.714338 C 35.510174,52.213877 35.484864,52.661395 35.604792,53.141103 C 35.720800,53.605133 36.020969,53.996287 36.263299,54.238616 C 36.590757,54.566074 37.035027,54.568737 37.470562,54.677621 C 37.877196,54.779280 38.450774,54.787372 39.007079,54.787372 C 39.499561,54.787372 39.726237,54.336816 39.885089,54.019113 C 40.048252,53.692788 39.994840,52.735696 39.994840,52.372845 C 39.994840,51.764083 39.885089,51.340231 39.885089,50.836328 C 39.885089,50.227207 39.994840,49.666649 39.994840,49.080309 C 39.994840,48.594446 40.231693,47.913395 40.324094,47.543792 C 40.463214,46.987311 40.640950,46.471075 40.872850,46.007275 C 41.112138,45.528699 41.332188,45.417852 41.531357,45.019514 C 41.798584,44.485060 41.919124,44.478034 41.641109,43.922001 C 41.427678,43.495140 41.418998,43.033558 41.311854,42.604987 C 41.183697,42.092355 41.189896,41.666058 41.311854,41.178221 C 41.441133,40.661112 41.531357,40.378202 41.531357,39.751456 C 41.531357,39.357313 41.147280,38.983300 40.982601,38.653943 C 40.761616,38.211972 40.577118,38.019774 40.433845,37.446679 C 40.293896,36.886882 40.102128,36.558816 39.994840,36.129665 C 39.884579,35.688622 39.615766,35.371517 39.446084,35.032153 C 39.247021,34.634025 39.226582,34.204135 39.226582,33.605387 C 39.226582,32.945903 39.466503,32.796291 39.665587,32.398124 C 39.865488,31.998320 40.030648,31.703808 40.324094,31.410363 C 40.648346,31.086110 40.792597,30.722357 41.092353,30.422602 C 41.497139,30.017815 40.746419,29.764094 40.324094,29.764094 C 39.766471,29.764094 39.381552,29.512327 39.007079,29.325090 C 38.644368,29.143734 38.429384,28.550821 38.348572,28.227577 C 38.239216,27.790154 37.911825,27.569635 37.470562,27.459319 C 36.870536,27.309312 36.716357,27.816679 36.373050,27.130065 C 36.166333,26.716631 36.263299,26.084628 36.263299,25.593549 C 36.263299,25.032763 36.269922,24.469546 36.373050,24.057031 C 36.480019,23.629153 36.767491,23.268149 36.921806,22.959519 C 37.118553,22.566025 37.706265,22.347787 38.019318,22.191261 C 38.389122,22.006359 39.035295,22.081510 39.555835,22.081510 C 40.104592,22.081510 40.653348,22.081510 41.202104,22.081510 C 41.550777,22.081510 42.048741,22.504828 42.299615,22.630266 C 42.779900,22.870407 43.095825,22.877718 43.397128,23.179022 C 43.856580,23.638474 43.334114,23.790792 43.067875,24.057031 C 42.608660,24.516246 42.293774,24.264849 42.628870,24.935041 C 42.796868,25.271038 43.241637,25.657560 43.506879,25.922802 C 43.829866,26.245788 44.071833,26.471558 44.604392,26.471558 C 45.231133,26.471558 45.468527,26.258992 45.921406,26.032553 C 46.380507,25.803003 46.621967,25.682272 47.018918,25.483797 C 47.432354,25.277079 48.064355,25.374046 48.555436,25.374046 C 48.881562,25.374046 49.547228,25.870950 49.762698,26.032553 C 50.233060,26.385325 50.346134,26.562541 50.860211,26.691060 C 51.323258,26.806822 51.603308,27.096337 52.177225,27.239816 C 52.669260,27.362825 53.085679,27.686432 53.494239,27.788572 C 54.085273,27.936331 54.424563,27.883965 54.921006,28.008075 C 55.515417,28.156678 55.672225,28.522753 55.908767,28.995836 C 56.129829,29.437960 56.491410,29.722118 56.677025,30.093348 C 56.910943,30.561183 56.502923,30.880558 56.238021,31.410363 C 56.056374,31.773656 55.750791,32.117094 55.469761,32.398124 C 55.126451,32.741435 54.982268,33.373113 54.811255,33.715138 C 54.580847,34.175955 54.213651,34.581092 53.933245,35.141904 C 53.665425,35.677541 53.569455,36.088987 53.384489,36.458918 C 53.193251,36.841393 53.274738,37.478767 53.274738,37.995435 C 53.274738,38.355483 53.637246,38.896713 53.713742,39.202699 C 53.826257,39.652756 54.049119,39.995451 54.152747,40.409962 C 54.261646,40.845559 54.246127,41.441991 54.372250,41.946479 C 54.491897,42.425068 54.372250,43.096512 54.372250,43.592748 C 54.372250,44.221105 54.406333,44.648676 54.591752,45.019514 C 54.805887,45.447783 54.950405,45.736818 55.140508,46.117026 C 55.318283,46.472575 55.666926,46.862946 56.018518,47.214537 C 56.421894,47.617914 56.456093,48.089688 56.677025,48.531553 C 56.956851,49.091204 57.024443,49.445891 57.225781,49.848567 C 57.525499,50.448001 57.843039,50.781081 57.994040,51.385084 C 58.121209,51.893759 58.424571,52.009700 58.542796,52.482597 C 58.645326,52.892716 58.958398,53.157244 59.091552,53.689860 C 59.206608,54.150081 59.311055,54.491721 59.311055,55.116625 C 59.311055,55.745296 59.151256,56.154433 58.872050,56.433641 C 58.548620,56.757070 57.979019,56.653142 57.445283,56.653142 C 57.019297,56.653142 56.409259,56.762894 55.908767,56.762894 C 55.327666,56.762894 54.822217,56.760154 54.372250,56.872645 C 53.888809,56.993505 53.322734,56.966958 52.945484,56.872645 C 52.548865,56.773490 53.055235,56.085649 53.055235,55.665381"
+     id="path2140" />
+  <path
+     style="fill:#000000;fill-opacity:1.0000000;fill-rule:evenodd;stroke:#000000;stroke-width:0.15643996;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"
+     d="M 38.428125,47.795987 C 38.311148,47.854477 36.965297,46.068306 36.706578,45.809587 C 36.275090,45.378099 35.986619,44.957203 35.647163,44.617746 C 35.160123,44.130704 34.556573,44.434693 34.190469,44.617746 C 33.723208,44.851375 33.274878,45.075540 32.866201,45.279879 C 32.358140,45.533910 32.262581,46.015925 31.939214,46.339294 C 31.632132,46.646376 31.393272,47.331218 31.277080,47.795987 C 31.083157,48.571681 31.468244,48.972877 31.674360,49.385108 C 31.912314,49.861016 32.778380,50.223928 33.131055,50.312097 C 33.776711,50.473511 34.431575,50.444524 35.117456,50.444524 C 35.382879,50.444524 36.028034,49.885811 36.441723,49.782389 C 36.905836,49.666361 37.228511,49.190356 37.633565,48.987829 C 37.959970,48.824626 38.265273,48.203119 38.428125,47.795987 z "
+     id="path2902" />
+  <path
+     style="fill:none;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#000000;stroke-width:1.0000000px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000"
+     d="M 36.399595,46.098141 C 41.690234,42.288881 41.690234,42.288881 41.690234,42.288881"
+     id="path3662" />
+  <path
+     style="fill:#ffd800;fill-opacity:1.0000000;fill-rule:evenodd;stroke:#000000;stroke-width:0.00000000;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"
+     d="M 51.177526,33.514353 C 51.643815,33.290634 52.117036,32.810504 52.277706,32.050272 C 52.490950,31.041286 52.186388,30.532180 51.727616,30.260839 C 51.228746,29.965782 50.690078,29.935489 49.939823,29.935489 C 48.958188,29.935489 48.839642,29.898727 48.839642,31.074218 C 48.839642,31.604089 49.483749,32.272697 49.664777,32.700974 C 49.972897,33.429925 50.486789,33.514353 51.177526,33.514353 z "
+     id="path3666" />
+  <path
+     style="fill:#ffd800;fill-opacity:1.0000000;fill-rule:evenodd;stroke:none;stroke-width:0.00000000;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"
+     d="M 43.339938,38.616989 C 43.358543,38.676580 44.048989,37.735278 44.132320,37.601827 C 44.413539,37.151472 44.464358,36.937090 44.370034,36.332872 C 44.312608,35.965007 43.825038,35.713886 43.656891,35.444606 C 43.366077,34.978882 43.133760,34.623676 42.864509,34.048757 C 42.530139,33.334791 42.389080,34.076845 42.389080,34.683233 C 42.389080,35.330477 42.556959,35.728514 42.706032,36.205977 C 42.849733,36.666232 42.864509,37.134957 42.864509,37.855617 C 42.864509,38.303047 43.016630,38.409884 43.339938,38.616989 z "
+     id="path4426" />
+  <path
+     style="fill:#000000;fill-opacity:1.0000000;fill-rule:evenodd;stroke:#000000;stroke-width:0.00000000;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"
+     d="M 43.635359,9.6022099 C 40.526110,12.711459 40.475138,12.762431 40.475138,12.762431 L 46.795580,12.762431 L 43.635359,9.6022099 z "
+     id="path8982" />
+  <path
+     style="fill:#000000;fill-opacity:1.0000000;fill-rule:evenodd;stroke:#000000;stroke-width:0.00000000;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"
+     d="M 43.878453,78.154696 C 40.769204,75.045447 40.718232,74.994475 40.718232,74.994475 L 47.038674,74.994475 L 43.878453,78.154696 z "
+     id="path9742" />
+  <path
+     style="fill:#000000;fill-opacity:1.0000000;fill-rule:evenodd;stroke:#000000;stroke-width:0.00000000;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"
+     d="M 9.4806628,43.878454 C 12.589911,46.987703 12.640883,47.038675 12.640883,47.038675 L 12.640883,40.718232 L 9.4806628,43.878454 z "
+     id="path9744" />
+  <path
+     style="fill:#000000;fill-opacity:1.0000000;fill-rule:evenodd;stroke:#000000;stroke-width:0.00000000;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"
+     d="M 78.033148,43.756906 C 74.923900,46.866155 74.872928,46.917127 74.872928,46.917127 L 74.872928,40.596684 L 78.033148,43.756906 z "
+     id="path9746" />
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator.hrh	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,177 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef __CREATOR_HRH__
+#define __CREATOR_HRH__
+
+
+enum TCreatorIds
+    {
+    ECmdCreateFromFile=1,
+
+    ECmdCreateCalendarEntries,
+    ECmdCreateCalendarEntryAppointments,
+    ECmdCreateCalendarEntryEvents,
+    ECmdCreateCalendarEntryAnniversaries,
+    ECmdCreateCalendarEntryToDos,
+    ECmdCreateCalendarEntryReminders,
+
+    ECmdCreateBrowserEntries,
+    ECmdCreateBrowserBookmarkEntries,
+    ECmdCreateBrowserBookmarkFolderEntries,
+    ECmdCreateBrowserSavedPageEntries,
+    ECmdCreateBrowserSavedPageFolderEntries,
+
+    ECmdCreateFileEntries,
+    ECmdCreateFileEntryEmptyFolder,
+
+    ECmdCreateFileEntry3GPP_70kB,
+    ECmdCreateFileEntryAAC_100kB,
+    ECmdCreateFileEntryAMR_20kB,
+    ECmdCreateFileEntryBMP_25kB,
+    ECmdCreateFileEntryDeck_1kB,
+    ECmdCreateFileEntryDOC_20kB,
+    ECmdCreateFileEntryGIF_2kB,
+    ECmdCreateFileEntryHTML_20kB,
+    ECmdCreateFileEntryJAD_1kB,
+    ECmdCreateFileEntryJAR_10kB,
+    ECmdCreateFileEntryJP2_65kB,
+    ECmdCreateFileEntryJPEG_200kB,
+    ECmdCreateFileEntryJPEG_25kB,
+    ECmdCreateFileEntryJPEG_500kB,
+    ECmdCreateFileEntryMIDI_10kB,
+    ECmdCreateFileEntryMP3_250kB,
+    ECmdCreateFileEntryMP4_200kB,
+    ECmdCreateFileEntryMXMF_40kB,
+    ECmdCreateFileEntryPNG_15kB,
+    ECmdCreateFileEntryPPT_40kB,
+    ECmdCreateFileEntryRAM_1kB,
+    ECmdCreateFileEntryRM_95kB,
+    ECmdCreateFileEntryRNG_1kB,
+    ECmdCreateFileEntrySVG_15kB,
+    ECmdCreateFileEntrySWF_15kB,
+    ECmdCreateFileEntryTIF_25kB,
+    ECmdCreateFileEntryTXT_10kB,
+    ECmdCreateFileEntryTXT_70kB,
+    ECmdCreateFileEntryVCF_1kB,
+    ECmdCreateFileEntryVCS_1kB,
+    ECmdCreateFileEntryWAV_20kB,
+    ECmdCreateFileEntryXLS_15kB,
+    ECmdCreateFileEntrySISX_10kB,
+    ECmdCreateFileEntryWMA_50kB,
+    ECmdCreateFileEntryWMV_200kB,
+
+    ECmdCreateLogEntries,
+    ECmdCreateLogEntryMissedCalls,
+    ECmdCreateLogEntryReceivedCalls,
+    ECmdCreateLogEntryDialledNumbers,
+
+    ECmdCreateMessagingEntries,
+    ECmdCreateMessagingEntryCBSTopics,
+    ECmdCreateMessagingEntryDocumentsFolders,
+    ECmdCreateMessagingEntrySMSMessageCenters,
+    ECmdCreateMessagingEntryMailboxes,
+    ECmdCreateMessagingEntryMessages,
+    ECmdCreateMessagingEntryMessagesViaScript,
+    ECmdCreateMessagingEntryTemplates,
+
+    ECmdCreateRandomEntrySMSInbox,
+    ECmdCreateRandomEntrySMSDrafts,
+    ECmdCreateRandomEntrySMSOutbox,
+    ECmdCreateRandomEntrySMSSent,
+    ECmdCreateRandomEntryMMSInbox,
+    ECmdCreateRandomEntryMMSDrafts,
+    ECmdCreateRandomEntryMMSOutbox,
+    ECmdCreateRandomEntryMMSSent,
+    ECmdCreateRandomEntryAMSInbox,
+    ECmdCreateRandomEntryAMSDrafts,
+    ECmdCreateRandomEntryAMSOutbox,
+    ECmdCreateRandomEntryAMSSent,
+    ECmdCreateRandomEntryEmailInbox,
+    ECmdCreateRandomEntryEmailDrafts,
+    ECmdCreateRandomEntryEmailOutbox,
+    ECmdCreateRandomEntryEmailSent,
+    ECmdCreateRandomEntryBIOInbox,
+    ECmdCreateRandomEntryBIODrafts,
+    ECmdCreateRandomEntryBIOOutbox,
+    ECmdCreateRandomEntryBIOSent,
+    ECmdCreateRandomEntryIRInbox,
+    ECmdCreateRandomEntryIRDrafts,
+    ECmdCreateRandomEntryIROutbox,
+    ECmdCreateRandomEntryIRSent,
+    ECmdCreateRandomEntryBTInbox,
+    ECmdCreateRandomEntryBTDrafts,
+    ECmdCreateRandomEntryBTOutbox,
+    ECmdCreateRandomEntryBTSent,
+
+    ECmdCreateMiscEntries,
+    ECmdCreateMiscEntryAccessPoints,
+    ECmdCreateMiscEntryAppMenuFolders,
+    ECmdCreateMiscEntryIMPSServers,
+    ECmdCreateMiscEntryNotes,
+    ECmdCreateMiscEntrySyncSettings,
+    ECmdCreateMiscEntryLandmarks,
+
+    ECmdCreatePhoneBookEntries,
+    ECmdCreatePhoneBookEntryContacts,
+    ECmdCreatePhoneBookEntryGroups,
+    ECmdCreatePhoneBookEntrySubscribedContacts,
+
+    ECmdDeleteEntries,
+    ECmdDeleteAllEntries,
+    ECmdDeleteAllCreatorEntries,
+    ECmdDeleteContacts,
+    ECmdDeleteCreatorContacts,
+    ECmdDeleteContactGroups,
+    ECmdDeleteCreatorContactGroups,
+    ECmdDeleteCalendarEntries,
+    ECmdDeleteCreatorCalendarEntries,
+    ECmdDeleteBrowserBookmarks,
+    ECmdDeleteCreatorBrowserBookmarks,
+    ECmdDeleteBrowserBookmarkFolders,
+    ECmdDeleteCreatorBrowserBookmarkFolders,
+    ECmdDeleteBrowserSavedPages,
+    ECmdDeleteCreatorBrowserSavedPages,
+    ECmdDeleteBrowserSavedPageFolders,
+    ECmdDeleteCreatorBrowserSavedPageFolders,
+    ECmdDeleteCreatorFiles,
+    ECmdDeleteLogs,
+    ECmdDeleteCreatorLogs,
+    ECmdDeleteMessages,
+    ECmdDeleteCreatorMessages,
+    ECmdDeleteMailboxes,
+    ECmdDeleteCreatorMailboxes,
+    ECmdDeleteIAPs,
+    ECmdDeleteCreatorIAPs,
+    ECmdDeleteIMPSs,
+    ECmdDeleteCreatorIMPSs,
+    ECmdDeleteNotes,
+    // ECmdDeleteCreatorNotes, not supported
+    ECmdDeleteLandmarks,
+    ECmdDeleteCreatorLandmarks,
+
+    ECmdAboutCreator,
+
+    ECmdSelectRandomDataFile,
+
+    EProgressNote
+
+    };
+
+#endif // __CREATOR_HRH__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator.pan	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef __CREATOR_PAN__
+#define __CREATOR_PAN__
+
+
+/** Creator application panic codes */
+enum TCreatorPanics 
+    {
+    ECreatorBasicUi = 1
+    // add further panics here
+    };
+
+#endif // __CREATOR_PAN__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_accesspoint.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,125 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef __CREATORACCESSPOINTS_H__
+#define __CREATORACCESSPOINTS_H__
+
+#include "creator_model.h"
+#include "creator_modulebase.h"
+#include "creator_connectionmethodbase.h"
+
+#include <e32base.h>
+#include <commdb.h>
+#include <apselect.h>
+#include <apdatahandler.h>
+#include <apaccesspointitem.h>
+#include <aputils.h>
+#include <apengineconsts.h>
+#include <msvapi.h>
+#include <mtclreg.h>
+#include <mmsclient.h>
+
+
+class CCreatorEngine;
+class CAccessPointsParameters;
+
+
+
+class CCreatorAccessPoints : public CCreatorConnectionSettingsBase, public MMsvSessionObserver
+    {
+public: 
+    static CCreatorAccessPoints* NewL(CCreatorEngine* aEngine);
+    static CCreatorAccessPoints* NewLC(CCreatorEngine* aEngine);
+    ~CCreatorAccessPoints();
+
+private:
+    CCreatorAccessPoints();
+    void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase
+
+    void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); // from MMsvSessionObserver
+
+public:
+    TBool AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries); // from MCreatorModuleBase
+
+    TInt CreateConnectionSettingsEntryL(CCreatorModuleBaseParameters *aParameters);    
+    TUint32 AccessPointNameToIdL(const TDesC& aAPName, TBool aAnyIfNotFound = EFalse );
+    
+    void DeleteAllL();
+    void DeleteAllCreatedByCreatorL();
+
+private:
+    CCommsDatabase* iCommsDb;
+    CApDataHandler* iApDataHandler;
+    CApUtils* iApUtils;
+    CAccessPointsParameters* iParameters;
+    RArray<TUint32> iEntryIds; // TUint32 CApDataHandler::CreateFromDataL
+
+public:
+    };
+
+
+class CAccessPointsParameters : public CCreatorModuleBaseParameters
+    {
+public: 
+    HBufC*          iConnectionName; // connection name
+    TApBearerType   iBearerType; // bearer type
+    HBufC*          iWapStartPage; // WAP start page
+    TUint32         iWapWspOption; // connection type
+    HBufC*          iGprsAcessPointName; // access point name
+    HBufC*          iIspLoginName; // username
+    TBool           iSecureAuthentication; // password authentication
+    HBufC*          iIspLoginPass; // password
+    TBool           iPromptPassword; // prompt password
+    HBufC*          iWapGatewayAddress; // WAP gateway address
+    HBufC*          iIspIPAddr; // phone IP
+    HBufC*          iIspIPNameServer1;  // primary name server
+    HBufC*          iIspIPNameServer2;  // secondary name server
+    HBufC*          iIspDefaultTelNumber; // datacall number
+    TUint32         iIspBearerCallTypeIsdn; // datacall type
+    TUint32         iIspBearerSpeed;  // max connection speed
+    HBufC*          iProxyServerAddress;  // proxy address
+    TUint32         iProxyPortNumber; // proxy number
+    
+    void SetRandomCMNameL(CCreatorEngine& aEngine);
+    void SetRandomLoginNameL(CCreatorEngine& aEngine);
+    void SetRandomLoginPassL(CCreatorEngine& aEngine);
+    void SetRandomSecureAuthenticationL(CCreatorEngine& aEngine);
+    void SetRandomPromptPasswordL(CCreatorEngine& aEngine);
+    void SetRandomProxyAddressL(CCreatorEngine& aEngine);
+    void SetRandomProxyPortL(CCreatorEngine& aEngine);
+    void SetRandomStartPageL(CCreatorEngine& aEngine);
+    void SetRandomIPAddressL(CCreatorEngine& aEngine);
+    void SetRandomIP4NameServer1L(CCreatorEngine& aEngine);
+    void SetRandomIP4NameServer2L(CCreatorEngine& aEngine);
+    void SetRandomTelephoneNumberL(CCreatorEngine& aEngine);
+    void SetRandomBearerTypeIsdnL(CCreatorEngine& aEngine);
+    void SetRandomBearerSpeedL(CCreatorEngine& aEngine);
+    void SetRandomWapWspOptionL(CCreatorEngine& aEngine);
+    void SetRandomGatewayAddressL(CCreatorEngine& aEngine);
+    
+
+public:
+    CAccessPointsParameters();
+    ~CAccessPointsParameters();
+    };
+
+
+
+#endif // __CREATORACCESSPOINTS_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_app.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef __CREATOR_APPLICATION_H__
+#define __CREATOR_APPLICATION_H__
+
+#include <aknapp.h>
+
+static const TUid KUidCreatorApp = {0x20011383}; 
+
+/*! 
+  @class CCreatorApplication
+  
+  @discussion An instance of CCreatorApplication is the application part of the AVKON
+  application framework for the Creator example application
+  */
+class CCreatorApplication : public CAknApplication
+    {
+public:  // from CApaApplication
+
+/*! 
+  @function AppDllUid
+  
+  @discussion Returns the application DLL UID value
+  @result the UID of this Application/Dll
+  */
+    TUid AppDllUid() const;
+
+protected: // from CEikApplication
+/*! 
+  @function CreateDocumentL
+  
+  @discussion Create a CApaDocument object and return a pointer to it
+  @result a pointer to the created document
+  */
+    CApaDocument* CreateDocumentL();
+    };
+
+#endif // __CREATOR_APPLICATION_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_appui.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,134 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef __CREATOR_APPUI_H__
+#define __CREATOR_APPUI_H__
+
+#include "creator_model.h"
+#include <creator.rsg>
+#include <aknappui.h>
+#include <aknnotewrappers.h> 
+
+
+class CCoeEnv;
+class CCreatorEngine;
+
+class CCreatorAppView;
+
+
+
+/*! 
+  @class CCreatorAppUi
+  
+  @discussion An instance of class CCreatorAppUi is the UserInterface part of the AVKON
+  application framework for the Creator example application
+  */
+class CCreatorAppUi : public CAknAppUi, public MBeating
+    {
+public:
+/*!
+  @function ConstructL
+  
+  @discussion Perform the second phase construction of a CCreatorAppUi object
+  this needs to be public due to the way the framework constructs the AppUi 
+  */
+    void ConstructL();
+
+/*!
+  @function CCreatorAppUi
+  
+  @discussion Perform the first phase of two phase construction.
+  This needs to be public due to the way the framework constructs the AppUi 
+  */
+    CCreatorAppUi();
+
+
+/*!
+  @function ~CCreatorAppUi
+  
+  @discussion Destroy the object and release all memory objects
+  */
+    ~CCreatorAppUi();
+
+
+public: // from CEikAppUi
+/*!
+  @function HandleCommandL
+  
+  @discussion Handle user menu selections
+  @param aCommand the enumerated code for the option selected
+  */
+    void HandleCommandL(TInt aCommand);
+
+
+
+public: // from MEikMenuPaneObserver
+    
+    /*!
+     @function DynInitMenuPaneL
+
+     @discussion Initialise a menu pane before it is displayed
+     @param aMenuId id of menu
+     @param aMenuPane handle for menu pane
+     */
+    void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
+
+    // callback from engine when the commands from the script file have been executed
+    void RunScriptDone();
+
+    // from MBeating
+    void Beat();
+    void Synchronize();
+
+private:
+	void Tick();
+	
+protected:
+    CEikonEnv* iEnv;
+
+
+//private:
+public:
+    CCreatorAppView* iAppView;
+    CCreatorEngine* iEngine;
+
+
+
+public:
+
+private:
+	HBufC* iCommandLineScriptName;
+	HBufC* iCommandLineRandomDataFileName;
+	CHeartbeat* iTimer;
+	enum TTimerMode
+		{
+		ETimerModeNone,
+		ETimerModeStartScript,
+		ETimerModeExitAppUi
+		};
+	TTimerMode iMode;
+	TInt iTickCount;
+    };
+
+
+
+
+
+#endif // __CREATOR_APPUI_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_browser.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,106 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef __CREATORBROWSER_H__
+#define __CREATORBROWSER_H__
+
+#include "creator_model.h"
+#include "creator_modulebase.h"
+
+#include <e32base.h>
+#include <FavouritesItem.h>
+#include <FavouritesDb.h>
+#include <FavouritesFile.h>
+
+
+
+class CCreatorEngine;
+class CBrowserParameters;
+
+
+class CCreatorBrowser : public CBase, public MCreatorModuleBase
+    {
+public: 
+    static CCreatorBrowser* NewL(CCreatorEngine* aEngine);
+    static CCreatorBrowser* NewLC(CCreatorEngine* aEngine);
+    ~CCreatorBrowser();
+
+private:
+    CCreatorBrowser();
+    void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase
+
+public:
+    TBool AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries); // from MCreatorModuleBase
+    TInt CreateBookmarkEntryL(CBrowserParameters *aParameters);    
+    TInt CreateBookmarkFolderEntryL(CBrowserParameters *aParameters);
+    TInt CreateSavedDeckEntryL(CBrowserParameters *aParameters); 
+    TInt CreateSavedDeckFolderEntryL(CBrowserParameters *aParameters);
+    
+    void DeleteAllL();
+    void DeleteAllCreatedByCreatorL();
+    
+    void DeleteAllBookmarksL();
+    void DeleteAllBookmarksCreatedByCreatorL();
+    void DeleteAllBookmarkFoldersL();
+    void DeleteAllBookmarkFoldersCreatedByCreatorL();
+    void DeleteAllSavedPagesL();
+    void DeleteAllSavedPagesCreatedByCreatorL();
+    void DeleteAllSavedPageFoldersL();
+    void DeleteAllSavedPageFoldersCreatedByCreatorL();
+
+private:
+    void DeleteAllItemsL( const TDesC& aDbName, CFavouritesItem::TType aTypeFilter, TBool aOnlyCreatedWithCreator, RArray<TInt>& aEntryIds, const TUid aDictUid );
+    
+
+
+private:
+    CBrowserParameters* iParameters;
+    RArray<TInt> iBmEntryIds;
+    RArray<TInt> iBmFEntryIds;
+    RArray<TInt> iSpEntryIds;
+    RArray<TInt> iSpFEntryIds;
+public:
+    };
+
+
+class CBrowserParameters : public CCreatorModuleBaseParameters
+    {
+public: 
+    HBufC*              iBookmarkName;
+    HBufC*              iBookmarkAddress;
+    TFavouritesWapAp    iBookmarkAccessPoint;
+    HBufC*              iBookmarkUsername;
+    HBufC*              iBookmarkPassword;    
+
+    HBufC*              iBookmarkFolderName;
+    
+    HBufC*              iSavedDeckLinkName;
+    HBufC*              iSavedDeckLocalAddress;
+            
+    HBufC*              iSavedDeckFolderName;
+
+public:
+    CBrowserParameters();
+    ~CBrowserParameters();
+    };
+
+
+
+#endif // __CREATORBROWSER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_browserelement.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef CREATORBROWSERELEMENT_H_
+#define CREATORBROWSERELEMENT_H_
+
+#include "creator_scriptelement.h"
+
+namespace creatorbrowser
+{
+_LIT(KBookmark, "bookmark");
+_LIT(KBookmarkFolder, "bookmarkfolder");
+_LIT(KSavedPage, "savedpage");
+_LIT(KSavedPageFolder, "savedpagefolder");
+
+_LIT(KName, "name");
+_LIT(KPath, "path");
+_LIT(KUsername, "username");
+_LIT(KPassword, "password");
+_LIT(KUrl, "url");
+}
+
+class CCreatorBrowserElement : public CCreatorScriptElement
+{
+public:
+    static CCreatorBrowserElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC);
+    void ExecuteCommandL();
+    
+protected:
+    CCreatorBrowserElement(CCreatorEngine* aEngine);    
+    TInt GetBrowserCommandL() const;
+};
+#endif /*CREATORBROWSERELEMENT_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_calendar.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,235 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef __CREATORCALENDARINTERIM_H__
+#define __CREATORCALENDARINTERIM_H__
+
+#include "creator_model.h"
+#include "creator_modulebase.h"
+#include "creator_calendarbase.h"
+
+#include <e32base.h>
+#include <e32std.h>
+
+//#include <calenlauncher.h> 
+#include <calentry.h>
+#include <calentryview.h>
+#include <caltime.h>
+#include <calsession.h>
+#include <calprogresscallback.h>
+#include <calcategory.h>
+#include <caluser.h>
+#include <calrrule.h>
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+#include <MVPbkSingleContactOperationObserver.h>
+#include <MVPbkContactStoreListObserver.h>
+#include <MVPbkContactFindObserver.h>
+class CVPbkContactManager;
+#endif
+
+class CCreatorEngine;
+class CCalenderInterimParameters;
+class CAsyncWaiter;
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+class CCreatorInterimCalendar : public CCreatorCalendarBase, public MCalProgressCallBack, 
+public MVPbkSingleContactOperationObserver, public MVPbkContactStoreListObserver, public MVPbkContactFindObserver
+#else
+class CCreatorInterimCalendar : public CCreatorCalendarBase, public MCalProgressCallBack
+#endif
+    {
+public: 
+    static CCreatorInterimCalendar* NewL(CCreatorEngine* aEngine);
+    static CCreatorInterimCalendar* NewLC(CCreatorEngine* aEngine);
+    ~CCreatorInterimCalendar();
+
+private:
+    CCreatorInterimCalendar();
+    void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase
+    void AddRepeatingRuleL(const TCalTime& aStartTime, CCalEntry& aCalEntry, CCalenderInterimParameters* parameters=0);
+    void SetRandomAlarmL(CCalEntry& aCalEntry);
+    void SetAlarmL(CCalEntry& aCalEntry, CCalenderInterimParameters* params);
+    void AddAttendeesL(CCalEntry& aCalEntry, CCalenderInterimParameters* parameters=0);
+    void SetPhoneOwnerL(CCalEntry& aCalEntry, const TDesC& aCN, const TDesC& aEmail, const TDesC& aSentBy );
+    void SetOrganizerL(CCalEntry& aCalEntry, const TDesC& aCN, const TDesC& aEmail, const TDesC& aSentBy);
+    void SetOrganizerL(CCalEntry& aCalEntry, CCalenderInterimParameters* parameters );
+    
+public:
+    TBool AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries); // from MCreatorModuleBase
+
+    TInt CreateAppointmentEntryL(CCreatorModuleBaseParameters *aParameters);    
+    TInt CreateEventEntryL(CCreatorModuleBaseParameters *aParameters);
+    TInt CreateAnniversaryEntryL(CCreatorModuleBaseParameters *aParameters); 
+    TInt CreateTodoEntryL(CCreatorModuleBaseParameters *aParameters);
+    TInt CreateReminderEntryL(CCreatorModuleBaseParameters *aParameters);
+    
+    void GenerateRandomId(TDes8& aText);
+    void DeleteAllL();
+    void DeleteAllCreatedByCreatorL();
+    
+public:
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+    // From MVPbkSingleContactOperationObserver:
+    virtual void VPbkSingleContactOperationComplete(
+            MVPbkContactOperationBase& aOperation,
+            MVPbkStoreContact* aContact );
+    
+    virtual void VPbkSingleContactOperationFailed(
+            MVPbkContactOperationBase& aOperation, 
+            TInt aError );
+    
+    // From MVPbkContactStoreListObserver
+    virtual void OpenComplete();
+    virtual void StoreReady(MVPbkContactStore&);
+    virtual void StoreUnavailable(MVPbkContactStore&, TInt);
+    virtual void HandleStoreEventL(MVPbkContactStore&, TVPbkContactStoreEvent);
+    
+    // From MVPbkContactFindObserver
+    virtual void FindCompleteL( MVPbkContactLinkArray* aResults );
+    virtual void FindFailed( TInt aError );
+    void HandleSingleContactResultL();
+#endif
+
+private:
+
+    CCalenderInterimParameters* iParameters;
+    TTime   iRandomModeStartTime;
+    TTime   iRandomModeEndTime;
+    TInt    iNumberRepeatingEntries;
+    TInt    iNumberOfAttendees;
+    CCalEntryView* 		iCalEntryView;
+    CCalSession* 		iCalSession;
+    TBool iSetAlarm;
+    CDesCArrayFlat* iSoundFileArray;
+    CAsyncWaiter* iWaiter;
+    HBufC* iTmpCN;
+    HBufC* iTmpEmail;
+    RArray<TUint32> iEntryIds; // TCalLocalUid ( == TUint32 ) CCalEntry::LocalUidL
+    
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+    CVPbkContactManager* iContactManager;
+    MVPbkContactLinkArray* iExistingContacts;
+    MVPbkStoreContact* iTempContact;
+#endif
+public:
+
+    //Observer implementation for MCalProgressCallBack
+	void Progress(TInt aPercentageCompleted);
+	
+	void Completed(TInt aError);
+	
+	TBool NotifyProgress();
+
+    };
+
+class CCreatorCalenderAttendee : public CBase
+{
+public:
+    virtual ~CCreatorCalenderAttendee();
+    static CCreatorCalenderAttendee* NewL();
+    void SetCommonNameL(const TDesC& aName);
+    void SetEmailAddressL(const TDesC& aEmail);
+    void SetRole(CCalAttendee::TCalRole aRole);
+    void SetStatus(CCalAttendee::TCalStatus);
+    
+    const TDesC& CommonName() const;
+    const TDesC& EmailAddress() const;
+    CCalAttendee::TCalRole Role() const;
+    CCalAttendee::TCalStatus Status() const;
+    
+private:
+    CCreatorCalenderAttendee();
+    TPtrC  iDummy;
+    HBufC* iCommonName;
+    HBufC* iEmailAddress;
+    CCalAttendee::TCalRole iRole;
+    CCalAttendee::TCalStatus iStatus;
+};
+
+class CCalenderInterimParameters : public CCreatorModuleBaseParameters
+    {
+public:
+
+	void ParseL(CCommandParser* parser, TParseParams aCase);
+	TBool IsAllowedEntryStatus(CCalEntry::TType aType, CCalEntry::TStatus aStatus);
+
+	TCalRRule::TType iRecurrentFrequency;
+	TInt iRecurrentInterval;
+	TTime iRecurrentStartTime;
+	TTime iRecurrentEndTime;
+	TInt iRepeatingCount; // This is used when running a script...
+	TTime iAlarmTime; // NullTTime means no alarm
+	TBool iUseRandomAlarmTime; // ETrue if random alarm should be set. Overwrites the iAlarmTime.
+	
+	RPointerArray<CCreatorCalenderAttendee> iAttendees;
+	RArray<TLinkIdParam> iAttendeeLinkIds; // For attendees. Stores the linked contact ids.
+	HBufC* iOrganizerName;
+	HBufC* iOrganizerEmail;
+		 
+	HBufC*  iDescription;
+	HBufC*  iSummary;
+	HBufC*  iLocation;
+	TTime   iStartTime;
+	TTime   iEndTime;
+	TInt    iNumberRepeatingEntries; // This is used when user input is used...
+	TInt    iNumberOfAttendees; // Number of randomly generated attendees
+	TInt    iNumberOfExistingAttendees; // Number of attendees selected from existing contacts.
+	
+	//An appointment, which has a start time and end time.
+    TTime   iAppointmentStartTime;
+    TTime   iAppointmentEndTime;
+    HBufC*  iAppointmentLocation;
+    HBufC*  iAppointmentReason;
+
+    //An event, which has a start time and end time.
+    
+    TTime   iEventStartTime;
+    TTime   iEventEndTime;
+    HBufC*  iEventReason;
+
+    //A reminder, which has a start time only.
+    TTime   iReminderStartTime;
+    HBufC*  iReminderReason;
+    
+    //An anniversary, which has a start time and end time.
+    TTime   iAnniversaryStartTime;
+    TTime   iAnniversaryEndTime;
+    HBufC*  iAnniversaryReason;
+
+    //A to-do, which can have a start time and end time (the end time is the due date), or can be undated.
+    TTime   iTodoStartTime;//optional
+    TTime   iTodoDueTime;//also end time (optional)
+    HBufC*  iTodoTask;
+    TInt    iTodoPriority;
+
+    TTime   iRandomModeStartTime;
+    TTime   iRandomModeEndTime;
+    
+    CCalEntry::TStatus iStatus;
+    
+public:
+	CCalenderInterimParameters();
+    ~CCalenderInterimParameters();   
+    
+    };
+
+
+
+#endif // __CREATORCALENDARINTERIM_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_calendarbase.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef CCREATORCALENDARBASE_
+#define CCREATORCALENDARBASE_
+
+#include "creator_modulebase.h"
+
+class CCreatorModuleBaseParameters;
+
+class CCreatorCalendarBase : public CBase, public MCreatorModuleBase{
+public:
+
+
+    //An appointment, which has a start time and end time. EAppt.
+    virtual TInt CreateAppointmentEntryL(CCreatorModuleBaseParameters *aParameters) = 0;
+    //An event, which has a start time and end time. EEvent.
+    virtual TInt CreateEventEntryL(CCreatorModuleBaseParameters *aParameters) = 0;
+    //An anniversary, which has a start time and end time. EAnniv.
+    virtual TInt CreateAnniversaryEntryL(CCreatorModuleBaseParameters *aParameters) = 0;
+    //A to-do, which can have a start time and end time (the end time is the due date), or can be undated. ETodo.
+    virtual TInt CreateTodoEntryL(CCreatorModuleBaseParameters *aParameters) = 0;     
+    //A reminder, which has a start time only. EReminder.
+    virtual TInt CreateReminderEntryL(CCreatorModuleBaseParameters *aParameters) = 0;
+
+};
+
+#endif /*CCREATORCALENDARBASE_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_calendarelement.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,119 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef CREATORCALENDARELEMENT_H_
+#define CREATORCALENDARELEMENT_H_
+
+#include "creator_scriptelement.h"
+
+class CCalenderInterimParameters;
+
+// Calendar elements:
+namespace creatorcalendar
+{
+    _LIT(KCalendar, "calendar");
+
+    // Calendar entry types:
+    _LIT(KType, "type");
+    _LIT(KCalTypeAppointment, "appointment");
+    _LIT(KCalTypeEvent, "event");
+    _LIT(KCalTypeReminder, "reminder");
+    _LIT(KCalTypeAnniversary, "anniversary");
+    _LIT(KCalTypeTodo, "todo");
+
+    // Calendar entry field elements:
+    _LIT(KSummary, "summary");
+    _LIT(KDescription, "description");
+    _LIT(KLocation, "location");
+    _LIT(KStarttime, "starttime");
+    _LIT(KEndtime, "endtime");
+    _LIT(KRecurrentFreq, "recurrentfrequency");
+    _LIT(KRecurrentInterval, "recurrentinterval");
+    _LIT(KRecurrentFrom, "recurrentfrom");
+    _LIT(KRecurrentTo, "recurrentto");
+    _LIT(KRepeatingCount, "repeatingcount");
+    _LIT(KAlarmtime, "alarmtime");
+    _LIT(KSynchronization, "synchronization");
+    _LIT(KOrganizername, "organizername");
+    _LIT(KOrganizeremail, "organizeremail");
+    _LIT(KAttendees, "attendees");
+    _LIT(KAttendee, "attendee");
+    _LIT(KCommonname, "commonname");
+    _LIT(KEmail, "email");
+    _LIT(KRole, "role");
+    _LIT(KStatus, "status");
+    _LIT(KPriority, "priority");
+
+    // Recurrency frequency values:
+    _LIT(KNotRepeated, "not-repeated");
+    _LIT(KWeekly, "weekly");
+    _LIT(KDaily, "daily");
+    _LIT(KMonthly, "monthly");
+    _LIT(KYearly, "yearly");
+
+    // Attendee role values:
+    _LIT(KRoleRequired, "required");
+    _LIT(KRoleOptional, "optional");
+    _LIT(KRoleNonPart, "non-participant");
+    _LIT(KRoleChair, "chair");
+    
+    // Calendar entry status values:
+    _LIT(KCalStatusTentative, "tentative");
+    _LIT(KCalStatusConfirmed, "confirmed");
+    _LIT(KCalStatusCancelled, "cancelled");
+    _LIT(KCalStatusNeedsAction, "todoneedsaction");
+    _LIT(KCalStatusCompleted, "todocompleted");
+    _LIT(KCalStatusInProcess, "todoinprocess");
+
+    // Attendee status values:
+    _LIT(KStatusNeedsAction, "needsaction");
+    _LIT(KStatusAccepted, "accepted");
+    _LIT(KStatusTentative, "tentative");
+    _LIT(KStatusConfirmed, "confirmed");
+    _LIT(KStatusDeclined, "declined");
+    _LIT(KStatusCompleted, "completed");
+    _LIT(KStatusDelegated, "delegated");
+    _LIT(KStatusInProcess, "inprocess");
+    
+    // Priority values:
+    _LIT(KPriorityHigh, "high");
+    _LIT(KPriorityMedium, "medium");
+    _LIT(KPriorityLow, "low");
+}
+
+class CCreatorCalendarElement : public CCreatorScriptElement
+{
+public:
+    static CCreatorCalendarElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC);
+    void ExecuteCommandL();
+protected:
+    CCreatorCalendarElement(CCreatorEngine* aEngine);
+    
+    enum TEntryType {
+        EAppointment,
+        EEvent,
+        EReminder,
+        EAnniversary,
+        ETodo
+    };
+    
+    void FillEntryParamsL(TEntryType aType, const RPointerArray<CCreatorScriptElement>& fields, CCalenderInterimParameters* parameters); 
+};
+
+#endif /*CREATORCALENDARELEMENT_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_connectionmethod.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,154 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef __CREATORCONNECTIONSETTINGS_H__
+#define __CREATORCONNECTIONSETTINGS_H__
+
+#include "creator_model.h"
+#include "creator_modulebase.h"
+#include "creator_connectionmethodbase.h"
+
+#include <e32base.h>
+#include <commdb.h>
+#include <msvapi.h>
+#include <mtclreg.h>
+#include <mmsclient.h>
+
+#include <cmconnectionmethoddef.h>
+#include <cmmanagerext.h>
+#include <cmpluginwlandef.h>
+using namespace CMManager;
+
+#include <etelpckt.h>//ETel Packet API needed for enums
+
+class CCreatorEngine;
+class CConnectionSettingsParameters;
+
+class CCreatorConnectionSettings : public CCreatorConnectionSettingsBase, public MMsvSessionObserver
+    {
+public: 
+    static CCreatorConnectionSettings* NewL(CCreatorEngine* aEngine);
+    static CCreatorConnectionSettings* NewLC(CCreatorEngine* aEngine);
+    ~CCreatorConnectionSettings();
+
+private:
+    CCreatorConnectionSettings();
+    void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase
+
+    void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); // from MMsvSessionObserver
+        
+public:
+    TBool AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries); // from MCreatorModuleBase
+    
+    TInt CreateConnectionSettingsEntryL(CCreatorModuleBaseParameters *aParameters);    
+    TUint32 AccessPointNameToIdL(const TDesC& aAPName, TBool aAnyIfNotFound = EFalse );
+    
+    //Setting default connection method, if not set
+    void SetDefaultCML(RCmConnectionMethodExt conMethod);
+    //Set random parameters
+    void SetRandomParametersL(CConnectionSettingsParameters& parameters);
+    void SetRandomBearerTypeL(CConnectionSettingsParameters& parameters);
+    void DeleteAllL();
+    void DeleteAllCreatedByCreatorL();
+private:
+    void DeleteAllDestinationsL( TBool aOnlyCreatedWithCreator );
+private:
+    CCommsDatabase* iCommsDb;
+    
+    RCmManagerExt iCmManagerExt;
+
+    CConnectionSettingsParameters* iParameters;
+    
+    RArray<TUint32> iEntryIds; // TUint32 RCmDestinationExt::Id()
+
+public:
+    };
+
+   
+class CConnectionSettingsParameters : public CCreatorModuleBaseParameters
+    {
+public: 
+    HBufC*          iConnectionName; // connection name
+    TUint           iBearerType; // bearer type
+    HBufC*          iStartPage; // start page
+    TWapWSPOption   iWapWspOption; // Indicating whether connection-oriented  or connectionless API should be used.
+    
+    RPacketContext::TProtocolType iProtocolType; //Type of protocol EPdpTypeIPv4 or EPdpTypeIPv4
+    
+    HBufC*          iLoginName; // username
+    TBool           iSecureAuthentication; // password authentication
+    HBufC*          iLoginPass; // password
+    TBool           iPromptPassword; // prompt password
+    HBufC*          iGatewayAddress; // gateway address
+    HBufC*          iSubnetMask;  // subnet mask
+    HBufC*          iIPAddr; // phone IP
+    HBufC*          iIP4NameServer1;  // primary name server
+    HBufC*          iIP4NameServer2;  // secondary name server
+    HBufC*          iDefaultTelNumber; // datacall number
+    TUint32         iBearerCallTypeIsdn; // datacall type
+    TUint32         iBearerSpeed;  // max connection speed
+    TBool           iUseProxy; //Use proxy or not
+    HBufC*          iProxyServerAddress;  // proxy address
+    TUint32         iProxyPortNumber; // proxy number
+    HBufC*          iWLANName;//WLAN network name
+    HBufC*          iWlanIpAddr;//IP address of EPOC.
+    TWlanSecMode    iWLanSecMode;//WLAN security modes
+    TWlanNetMode    iWlanNetMode;//WLAN connection mode. Ad-hoc or infrastructure.
+
+    HBufC*          iIP6NameServer1;  // primary name server for IP v6
+    HBufC*          iIP6NameServer2;  // secondary name server for IP v6
+    TBool           iDisableTextAuth; // Disable plaintext authentication 
+    
+    CCreatorEngine* iEngine;
+    
+public:
+    CConnectionSettingsParameters();
+    ~CConnectionSettingsParameters();   
+    
+    void SetRandomCMNameL(CCreatorEngine& aEngine);
+    void SetRandomWLANNameL(CCreatorEngine& aEngine);
+    void SetRandomWLANNetModeL(CCreatorEngine& aEngine);
+    void SetRandomWLANSecurityModeL(CCreatorEngine& aEngine);
+    void SetRandomLoginNameL(CCreatorEngine& aEngine);
+    void SetRandomLoginPassL(CCreatorEngine& aEngine);
+    void SetRandomSecureAuthenticationL(CCreatorEngine& aEngine);
+    void SetRandomPromptPasswordL(CCreatorEngine& aEngine);
+    void SetRandomUseProxyL(CCreatorEngine& aEngine);
+    void SetRandomProxyAddressL(CCreatorEngine& aEngine);
+    void SetRandomProxyPortL(CCreatorEngine& aEngine);
+    void SetRandomStartPageL(CCreatorEngine& aEngine);
+    void SetRandomIPAddressL(CCreatorEngine& aEngine);
+    void SetRandomIP4NameServer1L(CCreatorEngine& aEngine);
+    void SetRandomIP4NameServer2L(CCreatorEngine& aEngine);
+    void SetRandomProtocolTypeL(CCreatorEngine& aEngine);
+    void SetRandomTelephoneNumberL(CCreatorEngine& aEngine);
+    void SetRandomBearerTypeIsdnL(CCreatorEngine& aEngine);
+    void SetRandomBearerSpeedL(CCreatorEngine& aEngine);
+    void SetRandomWapWspOptionL(CCreatorEngine& aEngine);
+    void SetRandomSubnetMaskL(CCreatorEngine& aEngine);
+    void SetRandomGatewayAddressL(CCreatorEngine& aEngine);
+    void SetRandomWlanIpAddrL(CCreatorEngine& aEngine);
+    void SetRandomIPv6NameServer1L(CCreatorEngine& aEngine);
+    void SetRandomIPv6NameServer2L(CCreatorEngine& aEngine);
+    void SetRandomDisableTextAuthL(CCreatorEngine& aEngine);
+    };
+
+
+
+#endif // __CREATORCONNECTIONSETTINGS_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_connectionmethodbase.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef __CCREATORCONNECTIONSETTINGSBASE_H_
+#define __CCREATORCONNECTIONSETTINGSBASE_H_
+
+#include "creator_modulebase.h"
+
+class CCreatorModuleBaseParameters;
+
+const TUint KRandomBearerType = 0xEEEEEEEE;
+
+class CCreatorConnectionSettingsBase : public CBase, public MCreatorModuleBase
+    {
+public:
+    
+    virtual ~CCreatorConnectionSettingsBase(){};
+
+    virtual TInt CreateConnectionSettingsEntryL(CCreatorModuleBaseParameters *aParameters) = 0;    
+    virtual TUint32 AccessPointNameToIdL(const TDesC& aAPName, TBool aAnyIfNotFound = EFalse ) = 0;
+    virtual void DeleteAllConnectionMethodsL(){};
+    };
+
+#endif /*__CCREATORCONNECTIONSETTINGSBASE_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_connectionmethodelement.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,98 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef CREATORCONNECTIONMETHODELEMENT_H_
+#define CREATORCONNECTIONMETHODELEMENT_H_
+
+#include "creator_scriptelement.h"
+
+namespace creatorconnectionmethod
+{
+    _LIT(KCm, "connectionmethod");
+    _LIT(Kconnectionname, "connectionname");
+    _LIT(Kbearertype, "bearertype");
+    _LIT(Kstartpage, "startpage");
+    _LIT(Kwapwspoption, "wapwspoption");
+    _LIT(Kprotocoltype, "protocoltype");
+    _LIT(Kloginname, "loginname");
+    _LIT(Ksecureauthentication, "secureauthentication");
+    _LIT(Kloginpass, "loginpass");
+    _LIT(Kpromptpassword, "promptpassword");
+    _LIT(Kgatewayaddress, "gatewayaddress");
+    _LIT(Ksubnetmask, "subnetmask");
+    _LIT(Kdeviceipaddr, "deviceipaddr");
+    _LIT(Kip4nameserver1, "ip4nameserver1");
+    _LIT(Kip4nameserver2, "ip4nameserver2");
+    _LIT(Kdatacalltelnumber, "datacalltelnumber");
+    _LIT(Kdatacalltypeisdn, "datacalltypeisdn");
+    _LIT(Kdatacalllinespeed, "datacalllinespeed");
+    _LIT(Kuseproxy, "useproxy");
+    _LIT(Kproxyserveraddress, "proxyserveraddress");
+    _LIT(Kproxyportnumber, "proxyportnumber");
+    _LIT(Kip6nameserver1, "ip6nameserver1");
+    _LIT(Kip6nameserver2, "ip6nameserver2");
+    _LIT(Kdisabletextauth, "disabletextauth");
+    _LIT(Kwlanname, "wlanname");
+    _LIT(Kwlanipaddr, "wlanipaddr");
+    _LIT(Kwlansecmode, "wlansecmode");
+    _LIT(Kwlannetmode, "wlannetmode");
+    
+    // Bearer type:
+    _LIT(Kwlan, "wlan");
+    _LIT(Kgprs, "gprs");
+    _LIT(Kdatacall, "datacall");
+    _LIT(Khsgsm, "hsgsm");
+    _LIT(Kembedded, "embedded");
+    _LIT(Kvpn, "vpn");
+    _LIT(Klan, "lan");
+    
+    // Data call type isdn:
+    _LIT(Kanalogue, "analogue");
+    _LIT(Kisdnv110, "isdnv110");
+    _LIT(Kisdnv120, "isdnv120");
+    
+    // Line speed:
+    _LIT(Kautomatic, "automatic");
+    // WAP wps options:
+    _LIT(Kconnectionless, "connectionless"); // ECmWapWspOptionConnectionless
+    _LIT(Kconnectionoriented, "connectionoriented"); // ECmWapWspOptionConnectionOriented
+    
+    // Protocol
+    _LIT(Kipv4, "ipv4");
+    _LIT(Kipv6, "ipv6");
+
+    // WLAN security mode:
+    _LIT(Kopen, "open");
+    _LIT(Kwep, "wep");
+    _LIT(Ke802_1x, "e802_1x");
+    _LIT(Kwpa, "wpa");
+    _LIT(Kwpa2, "wpa2");
+}
+
+class CCreatorConnectionMethodElement : public CCreatorScriptElement
+{
+public:
+    static CCreatorConnectionMethodElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC);
+    void ExecuteCommandL();
+    
+protected:
+    CCreatorConnectionMethodElement(CCreatorEngine* aEngine);
+};
+
+#endif /*CREATORCONNECTIONMETHODELEMENT_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_contactelement.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,186 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef CREATORCONTACTELEMENT_H_
+#define CREATORCONTACTELEMENT_H_
+
+#include "creator_scriptelement.h"
+
+namespace creatorcontact
+{ 
+    _LIT(KContact, "contact");
+    _LIT(KContactSet, "contact-set");
+    _LIT(KContactGroup, "contactgroup");
+    _LIT(KMembers, "members");
+    _LIT(KName, "name");
+    
+    // Contact field elements:
+    _LIT(KFirstname, "firstname");
+    _LIT(KLastname, "lastname");
+    _LIT(KFirstnameReading, "firstnamereading");
+    _LIT(KLastnameReading, "lastnamereading");
+    _LIT(KPrefix, "prefix");
+    _LIT(KSuffix, "suffix");
+    _LIT(KSecondname, "secondname");
+    _LIT(KLandphoneHome, "landphonehome");
+    
+    _LIT(KMobilephoneHome, "mobilephonehome");
+    _LIT(KVideonumberHome, "videonumberhome");
+    _LIT(KFaxnumberHome, "faxnumberhome");
+    _LIT(KVoipHome, "voiphome");
+    _LIT(KEmailHome, "emailhome");
+    _LIT(KUrlHome, "urlhome");
+    _LIT(KAddrlabelHome, "addrlabelhome");
+    _LIT(KAddrpoHome, "addrpohome");
+    
+    _LIT(KAddrextHome, "addrexthome");
+    _LIT(KAddrstreetHome, "addrstreethome");
+    _LIT(KAddrlocalHome, "addrlocalhome");
+    _LIT(KAddrregionHome, "addrregionhome");
+    _LIT(KAddrpostcodeHome, "addrpostcodehome");
+    _LIT(KAddrcountryHome, "addrcountryhome");
+    _LIT(KJobtitle, "jobtitle");
+    _LIT(KCompanyname, "company");
+    
+    _LIT(KLandphoneWork, "landphonework");
+    _LIT(KMobilephoneWork, "mobilephonework");
+    _LIT(KVideonumberWork, "videonumberwork");
+    _LIT(KFaxnumberWork, "faxnumberwork");
+    _LIT(KVoipWork, "voipwork");
+    _LIT(KEmailWork, "emailwork");
+    _LIT(KUrlWork, "urlwork");
+    _LIT(KAddrlabelWork, "addrlabelwork");
+    
+    _LIT(KAddrpoWork, "addrpowork");
+    _LIT(KAddrextWork, "addrextwork");
+    _LIT(KAddrstreetWork, "addrstreetwork");
+    _LIT(KAddrlocalWork, "addrlocalwork");
+    _LIT(KAddrregionWork, "addrregionwork");
+    _LIT(KAddrpostcodeWork, "addrpostcodework");
+    _LIT(KAddrcountryWork, "addrcountrywork");
+    _LIT(KLandphoneGen, "landphonegen");
+    
+    _LIT(KMobilephoneGen, "mobilephonegen");
+    _LIT(KVideonumberGen, "videonumbergen");
+    _LIT(KFaxnumberGen, "faxnumbergen");
+    _LIT(KVoipGen, "voipgen");
+    _LIT(KPoc, "poc");
+    _LIT(KSwis, "swis");
+    _LIT(KSip, "sip");
+    _LIT(KEmailGen, "emailgen");
+    
+    _LIT(KUrlGen, "urlgen");
+    _LIT(KAddrlabelGen, "addrlabelgen");
+    _LIT(KAddrpoGen, "addrpogen");
+    _LIT(KAddrextGen, "addrextgen");
+    _LIT(KAddrstreetGen, "addrstreetgen");
+    _LIT(KAddrlocalGen, "addrlocalgen");
+    _LIT(KAddrregionGen, "addrregiongen");
+    _LIT(KAddrpostcodeGen, "addrpostcodegen");
+    
+    _LIT(KAddrcountryGen, "addrcountrygen");
+    _LIT(KPagerNumber, "pagernumber");
+    _LIT(KDtmfString, "dtmfstring");
+    _LIT(KWvAddress, "wvaddress");
+    _LIT(KDate, "date");
+    _LIT(KNote, "note");
+    _LIT(KThumbnailPath, "thumbnailpath");
+    _LIT(KThumbnailId, "thumbnailid");
+    _LIT(KRingTone, "ringtonepath");
+    _LIT(KRingToneId, "ringtoneid");
+    
+    _LIT(KCallerobjImg, "callerobjimg");
+    _LIT(KCallerobjText, "callerobjtext");
+    _LIT(KMiddlename, "middlename");
+    _LIT(KDepartment, "department");
+    _LIT(KAsstname, "asstname");
+    _LIT(KSpouse, "spouse");
+    _LIT(KChildren, "children");
+    _LIT(KAsstphone, "asstphone");
+    
+    _LIT(KCarphone, "caphone");
+    _LIT(KAnniversary, "anniversary");
+    _LIT(KSyncclass, "synchronization");
+    _LIT(KLocPrivacy, "locprivacy");
+    _LIT(KGenlabel, "genlabel");
+}
+/**
+ * Contact elements
+ */
+
+/**
+ * Base class for contact elements
+ */
+class CCreatorContactElementBase : public CCreatorScriptElement
+{
+public:
+    static CCreatorContactElementBase* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC);
+protected:
+    CCreatorContactElementBase(CCreatorEngine* aEngine);
+};
+
+/**
+ * Contact element
+ */
+class CCreatorContactElement : public CCreatorContactElementBase
+{
+public:
+    static CCreatorContactElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC);
+    void ExecuteCommandL();
+protected:
+    CCreatorContactElement(CCreatorEngine* aEngine);
+};
+
+/**
+ * Contact-set element
+ */
+class CCreatorContactSetElement : public CCreatorContactElementBase
+{
+public:
+    static CCreatorContactSetElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC);
+    void ExecuteCommandL();
+    virtual void AddToCacheL();
+protected:
+    CCreatorContactSetElement(CCreatorEngine* aEngine);
+};
+
+/**
+ * Contact group element
+ */
+class CCreatorContactGroupElement : public CCreatorContactElementBase
+{
+public:
+    static CCreatorContactGroupElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC);
+    void ExecuteCommandL();
+protected:
+    CCreatorContactGroupElement(CCreatorEngine* aEngine);
+};
+
+/**
+ * Contact field element
+ */
+class CCreatorContactFieldElement : public CCreatorScriptElement
+{
+public:
+    static CCreatorContactFieldElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC);
+protected:
+    CCreatorContactFieldElement(CCreatorEngine* aEngine);
+};
+
+#endif /*CREATORCONTACTELEMENT_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_contactsetcache.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef CREATORCONTACTSETCACHE_H_
+#define CREATORCONTACTSETCACHE_H_
+
+#include <e32base.h>
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+#include <MVPbkContactLink.h>
+#endif
+
+// Forward declarations
+class CContactLinkCacheImp;
+
+class CCreatorContactSet : public CBase
+{
+public:
+    static CCreatorContactSet* NewL(TInt aLinkId, TInt aNumOfExistingContacts);
+    virtual ~CCreatorContactSet();
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)    
+    void AppendL(MVPbkContactLink*);
+    TInt NumberOfExistingContacts() const;
+    RPointerArray<MVPbkContactLink>& ContactLinks();
+    const RPointerArray<MVPbkContactLink>& ContactLinks() const;
+#endif
+    TInt LinkId() const;
+
+private:
+    CCreatorContactSet(TInt aLinkId, TInt aNumOfExistingContacts);    
+    //void ConstructL();
+    TInt iLinkId;
+    TInt iNumOfExistingContacts;
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)    
+    RPointerArray<MVPbkContactLink> iContactLinks;
+#endif
+};
+
+class MContactLinkCache
+{
+public:
+    virtual void AppendL(CCreatorContactSet* aContactSet) = 0;
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)    
+    virtual RPointerArray<MVPbkContactLink>& ContactLinks(TInt aLinkId) = 0;
+    virtual const RPointerArray<MVPbkContactLink>& ContactLinks(TInt aLinkId) const = 0;    
+#endif    
+    virtual RPointerArray<CCreatorContactSet>& ContactSets() = 0;
+    virtual const RPointerArray<CCreatorContactSet>& ContactSets() const = 0;
+    virtual const CCreatorContactSet& ContactSet(TInt aLinkId) const = 0;
+    virtual CCreatorContactSet& ContactSet(TInt aLinkId) = 0;
+};
+
+class ContactLinkCache
+{
+public:
+    static void InitializeL();
+    static void DestroyL();
+    
+    static MContactLinkCache* Instance();
+    
+private:
+    ContactLinkCache(){};
+    static CContactLinkCacheImp* iImp;
+};
+
+#endif /*CREATORCONTACTSETCACHE_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_container.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,130 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef __CREATORAPPVIEW_H__
+#define __CREATORAPPVIEW_H__
+
+#include <coecntrl.h>
+
+/*! 
+  @class CCreatorAppView
+  
+  @discussion An instance of the Application View object for the Creator 
+  example application
+  */
+class CCreatorAppView : public CCoeControl
+    {
+public:
+
+
+
+/*!
+  @function NewL
+   
+  @discussion Create a CCreatorAppView object, which will draw itself to aRect
+  @param aRect the rectangle this view will be drawn to
+  @result a pointer to the created instance of CCreatorAppView
+  */
+    static CCreatorAppView* NewL(const TRect& aRect);
+
+/*!
+  @function NewLC
+   
+  @discussion Create a CCreatorAppView object, which will draw itself to aRect
+  @param aRect the rectangle this view will be drawn to
+  @result a pointer to the created instance of CCreatorAppView
+  */
+    static CCreatorAppView* NewLC(const TRect& aRect);
+
+
+/*!
+  @function ~CCreatorAppView
+  
+  @discussion Destroy the object and release all memory
+  */
+     ~CCreatorAppView();
+
+/*!
+  @function UserDraw
+  
+  @discussion Draw this CHelloWorldAppView to the screen
+  @param aRect the rectangle of this view that needs updating
+  */
+    void UserDraw() const;
+
+
+public:  // from CCoeControl
+/*!
+  @function Draw
+  
+  @discussion Draw this CCreatorAppView to the screen
+  @param aRect the rectangle of this view that needs updating
+  */
+    void Draw(const TRect& aRect) const;
+  
+
+/*!
+  @function OfferKeyEventL
+  
+  @discussion Handle any user keypresses
+  @param aKeyEvent holds the data for the event that occurred
+  @param aType holds the type of key event that occured
+  @result a TKeyResponse indicating if the key was consumed or not
+  */
+    TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
+
+/*!
+  @function InputCapabilities
+  
+  @discussion Return the capabilities of the OfferKeyEventL 
+              method for this class
+  @result a TCoeInputCapabilities indicating the capabilities 
+          for this class
+  */
+	TCoeInputCapabilities InputCapabilities() const;
+
+
+
+private:
+
+/*!
+  @function ConstructL
+  
+  @discussion  Perform the second phase construction of a CCreatorAppView object
+  @param aRect the rectangle this view will be drawn to
+  */
+    void ConstructL(const TRect& aRect);
+
+/*!
+  @function CCreatorAppView
+  
+  @discussion Perform the first phase of two phase construction 
+  */
+    CCreatorAppView();
+
+
+    TBool MMC_OK() const;
+
+public:
+    void HandleResourceChange(TInt aType);
+    };
+
+
+#endif // __CREATORAPPVIEW_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_document.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,96 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef __CREATOR_DOCUMENT_H__
+#define __CREATOR_DOCUMENT_H__
+
+
+#include <AknDoc.h>
+
+// Forward references
+class CCreatorAppUi;
+class CEikApplication;
+
+
+/*! 
+  @class CCreatorDocument
+  
+  @discussion An instance of class CCreatorDocument is the Document part of the AVKON
+  application framework for the Creator example application
+  */
+class CCreatorDocument : public CAknDocument
+    {
+public:
+
+/*!
+  @function NewL
+  
+  @discussion Construct a CCreatorDocument for the AVKON application aApp 
+  using two phase construction, and return a pointer to the created object
+  @param aApp application creating this document
+  @result a pointer to the created instance of CCreatorDocument
+  */
+    static CCreatorDocument* NewL(CEikApplication& aApp);
+
+/*!
+  @function NewLC
+  
+  @discussion Construct a CCreatorDocument for the AVKON application aApp 
+  using two phase construction, and return a pointer to the created object
+  @param aApp application creating this document
+  @result a pointer to the created instance of CCreatorDocument
+  */
+    static CCreatorDocument* NewLC(CEikApplication& aApp);
+
+/*!
+  @function ~CCreatorDocument
+  
+  @discussion Destroy the object and release all memory objects
+  */
+    ~CCreatorDocument();
+
+/*!
+  @function CreateAppUiL 
+  
+  @discussion Create a CCreatorAppUi object and return a pointer to it
+  @result a pointer to the created instance of the AppUi created
+  */
+    CEikAppUi* CreateAppUiL();
+private:
+
+/*!
+  @function ConstructL
+  
+  @discussion Perform the second phase construction of a CCreatorDocument object
+  */
+    void ConstructL();
+
+/*!
+  @function CCreatorDocument
+  
+  @discussion Perform the first phase of two phase construction 
+  @param aApp application creating this document
+  */
+    CCreatorDocument(CEikApplication& aApp);
+
+    };
+
+
+#endif // __CREATOR_DOCUMENT_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_factory.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef TCREATORFACTORY_H_
+#define TCREATORFACTORY_H_
+
+#include "creator_modulebase.h"
+
+class CCreatorEngine;
+class CCreatorPhonebookBase;
+class CCreatorConnectionSettingsBase;
+
+
+class TCreatorFactory{
+
+public: 
+	static CCreatorPhonebookBase* CreatePhoneBookL(CCreatorEngine* aEngine);
+	static CCreatorModuleBaseParameters* CreatePhoneBookParametersL();
+
+    static CCreatorConnectionSettingsBase* CreateConnectionSettingsL(CCreatorEngine* aEngine);
+    static CCreatorModuleBaseParameters* CreateConnectionSettingsParametersL();
+	
+
+};
+
+#endif /*TCREATORFACTORY_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_file.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,96 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef __CREATORFiles_H__
+#define __CREATORFiles_H__
+
+#include "creator_model.h"
+#include "creator_modulebase.h"
+
+#include <caf/caf.h>
+using namespace ContentAccess;
+
+#include <e32base.h>
+#include <bautils.h>
+#include <pathinfo.h>
+#include <apgcli.h> // RApaLsSession
+
+class CCreatorEngine;
+class CFilesParameters;
+class CDRMPermission;
+class CDRMConstraint;
+
+class CCreatorFiles : public CBase, public MCreatorModuleBase
+    {
+public: 
+    static CCreatorFiles* NewL(CCreatorEngine* aEngine);
+    static CCreatorFiles* NewLC(CCreatorEngine* aEngine);
+    ~CCreatorFiles();
+
+private:
+    CCreatorFiles();
+    void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase
+
+public:
+    TBool AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries); // from MCreatorModuleBase
+    TInt CreateFileEntryL(CFilesParameters *aParameters, TInt aCommand);    
+    void DeleteAllL();
+    void DeleteAllCreatedByCreatorL();
+
+private:
+    
+    void EncryptFileL( const TDesC& aFileName, const TDesC& aOutFileName, CFilesParameters *aParameters );
+    void SetPermissionsL( CMetaDataArray* aMetaData, const TDesC& aOutFileName, CFilesParameters *aParameters );
+    void SetMimeTypeL( const TDesC& aFileName, TDes8& aMime, CFilesParameters *aParameters );
+    TBool AskDRMDataFromUserL();
+    TBool AskDRMCDDataFromUserL();
+    void StorePathsForDeleteL( CDesCArray& aPaths );
+    void GenerateFileNameL( TFileName& aRootName );
+    
+private:
+    CFilesParameters* iParameters;
+    CFilesParameters* iUserParameters;
+    HBufC* iDirectoryQueriedFromUser;
+    RFs& iFs;
+    RApaLsSession iApaLs;
+    CDesCArray* iFilePaths;
+    TInt iFileId;
+
+public:
+    };
+
+
+class CFilesParameters : public CCreatorModuleBaseParameters
+    {
+public: 
+    HBufC*          iFullFilePath;
+    TInt            iFileCommand;
+    CDRMPermission* iPermission;
+    TBool           iEncrypt;
+    
+public:
+    CFilesParameters();
+    CFilesParameters( CFilesParameters& aCopy );
+    ~CFilesParameters();
+    };
+
+
+
+#endif // __CREATORFiles_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_fileelement.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef CREATORFILEELEMENT_H_
+#define CREATORFILEELEMENT_H_
+
+#include "creator_scriptelement.h"
+
+namespace creatorfile
+{
+    _LIT(KFile, "file");
+    _LIT(KType, "type");
+    _LIT(KDirectory, "directory");
+    _LIT(KDefaultDir, "c:\\data");
+    _LIT(KEncryption, "encryption");
+    _LIT(KDRMRight, "right");
+    _LIT(KDRMFL, "DRM-FL");
+    _LIT(KDRMCD, "DRM-CD");
+    _LIT(KDRMPlayRight, "play");
+    _LIT(KDRMDisplayRight, "display");
+    _LIT(KDRMPrintRight, "print");
+    _LIT(KDRMExecuteRight, "execute");
+    _LIT(KDRMCount, "count");
+    _LIT(KDRMInterval, "interval");
+    _LIT(KDRMStartTime, "starttime");
+    _LIT(KDRMEndTime, "endtime");
+    _LIT(KDRMAccumulated, "accumulated");
+}
+
+class CDRMConstraint;
+class CFilesParameters;
+
+class CCreatorFileElement : public CCreatorScriptElement
+{
+public:
+    static CCreatorFileElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC);
+    void ExecuteCommandL();
+    
+protected:
+    CCreatorFileElement(CCreatorEngine* aEngine);
+    TInt GetFileCommandL( const TDesC& aFileIdStr, TBool aRandom ) const;
+private:
+    void ParseDRMElementsL( CCreatorScriptElement* aField, CFilesParameters* aParam );
+    void ParseDRMConstraintsL( CCreatorScriptElement* aRight, CDRMConstraint* aConstraint );
+    TTimeIntervalSeconds ParseTimeInterval( TDesC& aTimeString );
+private: // Data
+    TInt64 iTimeZone;
+};
+
+#endif // CREATORFILEELEMENT_H_
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_imps.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,88 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef __CREATORIMPS_H__
+#define __CREATORIMPS_H__
+
+#ifdef __PRESENCE
+
+#include "creator_model.h"
+#include "creator_modulebase.h"
+
+#include <e32base.h>
+
+#include <cimpssapsettings.h>
+#include <cimpssapsettingsstore.h>
+
+
+class CCreatorEngine;
+class CIMPSParameters;
+
+
+class CCreatorIMPS : public CBase, public MCreatorModuleBase
+    {
+public: 
+    static CCreatorIMPS* NewL(CCreatorEngine* aEngine);
+    static CCreatorIMPS* NewLC(CCreatorEngine* aEngine);
+    ~CCreatorIMPS();
+
+private:
+    CCreatorIMPS();
+    void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase
+
+public:
+    TBool AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries); // from MCreatorModuleBase
+    TInt CreateIMPSServerEntryL(CIMPSParameters *aParameters);
+    void DeleteAllL();
+    void DeleteAllCreatedByCreatorL();
+
+private:
+    CIMPSSAPSettingsStore* iIMPSSAPSettingsStore;
+
+    CIMPSParameters* iParameters;
+    RArray<TUint32> iEntryIds; // TUint32 CIMPSSAPSettings::Uid()
+
+public:
+    };
+
+
+class CIMPSParameters : public CCreatorModuleBaseParameters
+    {
+public: 
+    HBufC*              iServerName;
+    HBufC*              iServerURL;
+    HBufC*              iServerUsername;
+    HBufC*              iServerPassword;    
+    HBufC*              iServerAccessPointName;
+    
+    void SetRandomNameL(CCreatorEngine& aEngine);
+    void SetRandomUrlL(CCreatorEngine& aEngine);
+    void SetRandomUsernameL(CCreatorEngine& aEngine);
+    void SetRandomPasswordL(CCreatorEngine& aEngine);
+    void SetDefaultAccessPointL();
+
+public:
+    CIMPSParameters();
+    ~CIMPSParameters();
+    };
+
+#endif //__PRESENCE
+
+#endif // __CREATORIMPS_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_impselement.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef CREATORIMPSSERVERELEMENT_H_
+#define CREATORIMPSSERVERELEMENT_H_
+
+#ifdef __PRESENCE
+
+#include "creator_scriptelement.h"
+
+namespace creatorimps
+{
+    _LIT(KImpsServer, "impsserver");
+    _LIT(KName, "name");
+    _LIT(KUrl, "url");
+    _LIT(KUsername, "username");
+    _LIT(KPassword, "password");
+    _LIT(KConnectionMethodName, "connectionmethodname");
+    _LIT(KDefault, "default");
+}
+
+class CCreatorImpsServerElement : public CCreatorScriptElement
+{
+public:
+    static CCreatorImpsServerElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC);
+    void ExecuteCommandL();
+    
+protected:
+    CCreatorImpsServerElement(CCreatorEngine* aEngine);
+};
+
+#endif // __PRESENCE
+
+#endif /*CREATORIMPSSERVERELEMENT_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_landmark.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,104 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef LANDMARKS_H_
+#define LANDMARKS_H_
+
+#include "creator_model.h"
+#include "creator_modulebase.h"
+
+#include <e32base.h>
+#include <EPos_Landmarks.h>
+
+class CLandmarkParameters;
+class CPosLandmarkDatabase;
+class CPosLmOperation;
+
+static const TInt KLandmarkFieldLength = 256;
+
+class CCreatorLandmarks : public CBase, public MCreatorModuleBase
+    {
+public: 
+    static CCreatorLandmarks* NewL(CCreatorEngine* aEngine);
+    static CCreatorLandmarks* NewLC(CCreatorEngine* aEngine);
+    ~CCreatorLandmarks();
+
+private:
+    CCreatorLandmarks();
+    void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase    
+    TPosLmItemId GetCategoryIdL( TPosLmGlobalCategory aGlobalCategoryID );
+
+public:
+    TBool AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries); // from MCreatorModuleBase
+    TInt CreateLandmarkEntryL(CLandmarkParameters *aParameters);
+    static TPosLmGlobalCategory GetCategoryIdL(const TDesC& aCategoryStr);
+    void DeleteAllL();
+    void DeleteAllCreatedByCreatorL();
+
+private:
+    CPosLandmarkDatabase* iLandmarkDb;    
+    CLandmarkParameters* iParameters;
+    CPosLmOperation* iLmOperation;
+    RArray<TPosLmItemId> iEntryIds; // TPosLmItemId (==TUint32) CPosLandmark::LandmarkId()
+public:
+    };
+
+
+class CLandmarkParameters : public CCreatorModuleBaseParameters
+    {
+public: 
+    HBufC*              iName;
+    RArray<TUint>       iCategories;
+    HBufC*              iStreet;
+    HBufC*              iCity;    
+    HBufC*              iState;
+    HBufC*              iCountry;
+    HBufC*              iPostCode;    
+    HBufC*              iDescription;
+    HBufC*              iPhonenumber;
+    HBufC*              iUrl;
+    TReal64             iLatitude;
+    TReal64             iLongitude;
+    TReal32             iPositionAccuracy;
+    TReal32             iAltitude;
+    TReal32             iAltitudeAccuracy;
+    
+    void SetRandomNameL(CCreatorEngine& aEngine);
+    void SetRandomUrlL(CCreatorEngine& aEngine);
+    void AddRandomCategoryL(CCreatorEngine& aEngine);
+    void SetRandomStreetL(CCreatorEngine& aEngine);
+    void SetRandomCityL(CCreatorEngine& aEngine);
+    void SetRandomStateL(CCreatorEngine& aEngine);
+    void SetRandomCountryL(CCreatorEngine& aEngine);
+    void SetRandomPostCodeL(CCreatorEngine& aEngine);
+    void SetRandomLatitudeL(CCreatorEngine& aEngine);
+    void SetRandomLongitudeL(CCreatorEngine& aEngine);
+    void SetRandomPositionAccuracyL(CCreatorEngine& aEngine);
+    void SetRandomAltitudeL(CCreatorEngine& aEngine);
+    void SetRandomAltitudeAccuracyL(CCreatorEngine& aEngine);
+    void SetRandomDescriptionL(CCreatorEngine& aEngine);
+    void SetRandomPhoneNumberL(CCreatorEngine& aEngine);
+    
+private:
+    
+public:
+    CLandmarkParameters();
+    ~CLandmarkParameters();
+    };
+#endif /*LANDMARKS_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_landmarkelement.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef CREATORLANDMARKELEMENT_H_
+#define CREATORLANDMARKELEMENT_H_
+
+#include "creator_scriptelement.h"
+
+namespace creatorlandmark
+{
+    _LIT(KLandmark, "landmark");
+    _LIT(KName, "name");
+    _LIT(KCategory, "category");
+    _LIT(KDescription, "description");
+    _LIT(KStreet, "street");
+    _LIT(KPostalcode, "postalcode");
+    _LIT(KCity, "city");
+    _LIT(KState, "state");
+    _LIT(KCountry, "country");
+    _LIT(KPhonenumber, "phonenbr");
+    _LIT(KUrl, "url");
+    _LIT(KLatitude, "latitude");
+    _LIT(KLongitude, "longitude");
+    _LIT(KPositionaccuracy, "positionaccuracy");
+    _LIT(KAltitude, "altitude");
+    _LIT(KAltitudeaccuracy, "altitudeaccuracy");
+}
+
+class CCreatorLandmarkElement : public CCreatorScriptElement
+{
+public:
+    static CCreatorLandmarkElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC);
+    void ExecuteCommandL();
+    
+protected:
+    CCreatorLandmarkElement(CCreatorEngine* aEngine);
+};
+
+#endif /*CREATORLANDMARKELEMENT_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_log.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,114 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef __CREATORLOGS_H__
+#define __CREATORLOGS_H__
+
+#include "creator_model.h"
+#include "creator_modulebase.h"
+
+
+#include <e32base.h>
+#include <logwrap.h>
+#include <logcli.h>
+#include <logeng.h>
+
+
+
+class CCreatorEngine;
+class CLogsParameters;
+
+// Creator log ids:
+typedef TInt32  TLogIdCreator;
+typedef TInt8   TLogDurationTypeCreator;
+typedef TUint32 TLogDurationCreator;
+typedef TUint32 TLogLinkCreator;
+
+const TLogIdCreator KLogNullIdCreator = -1;
+const TLogLinkCreator KLogNullLinkCreator = 0;
+const TLogDurationTypeCreator KLogNullDurationTypeCreator = -1;
+const TLogDurationCreator KLogNullDurationCreator = 0;
+const TLogDurationTypeCreator KLogDurationNoneCreator = 0;
+const TLogDurationTypeCreator KLogDurationValidCreator = 1;
+const TLogDurationTypeCreator KLogDurationDataCreator = 2;
+
+
+
+
+class CCreatorLogs : public CActive, public MCreatorModuleBase
+    {
+public: 
+    static CCreatorLogs* NewL(CCreatorEngine* aEngine);
+    static CCreatorLogs* NewLC(CCreatorEngine* aEngine);
+    ~CCreatorLogs();
+
+private:
+    CCreatorLogs();
+    void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase
+
+    void RunL();  // from CActive
+	void DoCancel();  // from CActive
+
+public:
+    TBool AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries); // from MCreatorModuleBase
+
+    TInt CreateMissedCallEntryL(CLogsParameters *aParameters);    
+    TInt CreateReceivedCallEntryL(CLogsParameters *aParameters);
+    TInt CreateDialledNumberEntryL(CLogsParameters *aParameters);
+    void DeleteAllL();
+    void DeleteAllCreatedByCreatorL();
+
+private:
+    CLogClient* iLogClient;
+    CLogEvent* iLogEvent;
+    CActiveSchedulerWait iLogWriteWait;
+
+    CLogsParameters* iParameters;
+    RArray<TInt> iEntryIds; // TLogId ( == TInt32) CLogEvent::Id()
+
+public:
+    };
+
+
+class CLogsParameters : public CCreatorModuleBaseParameters
+    {
+public: 
+    /*HBufC*              iMissedCallPhoneNumber;
+    TTime               iMissedCallEventTime;
+	
+    HBufC*              iReceivedCallPhoneNumber;
+    TTime               iReceivedCallEventTime;
+    TLogDuration        iReceivedCallDuration;
+
+    HBufC*              iDialledNumberPhoneNumber;
+    TTime               iDialledNumberEventTime;
+    TLogDuration        iDialledNumberDuration;*/
+    HBufC*              iPhoneNumber;
+    TTime               iEventTime;
+    TLogDuration        iDuration;
+
+public:
+    CLogsParameters();
+    ~CLogsParameters();
+    };
+
+
+
+#endif // __CREATORLOGS_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_logelement.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef CREATORLOGELEMENT_H_
+#define CREATORLOGELEMENT_H_
+
+#include "creator_scriptelement.h"
+
+namespace creatorlog
+{
+    _LIT(KLog, "log");
+    _LIT(KDirection, "direction");
+    _LIT(KDuration, "duration");
+    _LIT(KPhonenumber, "phonenumber");
+    _LIT(KDatetime, "datetime");
+    _LIT(KMissed, "missed");
+    _LIT(KIn, "in");
+    _LIT(KOut, "out");
+}
+
+class CCreatorLogElement : public CCreatorScriptElement
+{
+public:
+    static CCreatorLogElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC);
+    void ExecuteCommandL();
+    
+protected:
+    CCreatorLogElement(CCreatorEngine* aEngine);
+    TInt GetLogCommandL( const TDesC& aFileIdStr, TBool aRandom ) const;
+};
+
+#endif /*CREATORLOGELEMENT_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_mailbox.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,188 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef __CREATORMAILBOXES_H__
+#define __CREATORMAILBOXES_H__
+
+#include "creator_model.h"
+#include "creator_modulebase.h"
+
+
+#include <e32base.h>
+#include <SenduiMtmUids.h>
+#include <smtpset.h>
+#include <imapset.h>
+#include <pop3set.h>
+#include <mtmuibas.h>
+#include <iapprefs.h>
+#include <cemailaccounts.h>
+
+class CCreatorEngine;
+class CMailboxesParameters;
+
+const TInt KDefaultSmtpPort = 25;
+
+enum TMailboxType
+    {
+    EMailboxPOP3,
+    EMailboxIMAP4
+    };
+
+class CCreatorMailboxes : public CBase, public MCreatorModuleBase, public MMsvSessionObserver
+    {
+public: 
+    static CCreatorMailboxes* NewL(CCreatorEngine* aEngine);
+    static CCreatorMailboxes* NewLC(CCreatorEngine* aEngine);
+    ~CCreatorMailboxes();
+
+private:
+    CCreatorMailboxes();
+    void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase
+
+    void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); // from MMsvSessionObserver
+    void StoreIMEIToEntryL(const TMsvId aMailboxId);
+    void GetIMEIFromThePhoneL();
+    
+    void PopulateSmtpSettingsL( 
+            CEmailAccounts& aEmailAccount, 
+            CImSmtpSettings& aSmtpSettings, 
+            CImIAPPreferences& aIApSettings, 
+            const CMailboxesParameters& aParameters );
+    
+    void PopulateImapSettingsL( 
+            CEmailAccounts& aEmailAccount, 
+            CImImap4Settings& aImapSettings, 
+            CImIAPPreferences& aIApSettings, 
+            const CMailboxesParameters& aParameters );
+    
+    void PopulatePopSettingsL( 
+            CEmailAccounts& aEmailAccount, 
+            CImPop3Settings& aPopSettings, 
+            CImIAPPreferences& aIApSettings, 
+            const CMailboxesParameters& aParameters );
+
+
+public:
+    TBool AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries); // from MCreatorModuleBase
+    TInt CreateMailboxEntryL(CMailboxesParameters *aParameters);
+    void DeleteAllL();
+    void DeleteAllCreatedByCreatorL();
+
+
+private:
+    CMailboxesParameters* iParameters;
+    TBuf<50> iIMEI;
+    RArray<TInt> iEntryIds;
+
+public:
+    };
+
+
+class CMailboxesParameters : public CCreatorModuleBaseParameters
+    {
+public: 
+//    HBufC*          iMailboxName;
+//    HBufC*          iAccessPoint;
+//    HBufC*          iMyMailAddress;
+//    HBufC*          iOutgoingMailServer;
+//    TBool           iSendMessageImmediately;
+//    TBool           iSendCopyToSelf;
+//    TBool           iIncludeSignature;
+//    HBufC*          iUserName;
+//    HBufC*          iPassword;
+//    HBufC*          iIncomingMailServer;
+//    TMailboxType    iMailboxType;  // IMAP4 or POP3
+//    TBool           iSecurityOn; // SecureSockets
+//    TBool           iSSLWrapper; // SSL Wrapper
+//    TBool           iAPOPSecureLogin; // POP3 only
+//    TBool           iRetrieveAttachment; // IMAP4 only
+//    TInt32          iRetrieveHeaders;  // IMAP4 only
+
+    enum TGetEmailOption
+    {
+    EUndef = 0,
+    EGetHeaders,
+    EGetBodyText,
+    EGetBodyTextAndAttachments,
+    EGetAttachments,
+    EGetBodyAlternativeText,
+    EGetEmailOptionLast
+    };
+
+    HBufC*  iMailboxName;    
+    HBufC*  iIncomingLoginName;
+    HBufC*  iIncomingPassword;
+    HBufC*  iIncomingServerName;
+    HBufC*  iIncomingConnectionMethod;
+    HBufC*  iIncomingFolderPath;
+    HBufC*  iPathSeparator;
+    HBufC*  iOutgoingLoginName;
+    HBufC*  iOutgoingPassword;
+    HBufC*  iOutgoingServerName;
+    HBufC*  iOutgoingConnectionMethod;
+    HBufC*  iOwnEmailAddress;
+    HBufC*  iOwnEmailAlias;
+    HBufC*  iReceiptAddress;
+    HBufC*  iReplyToAddress;
+    
+    TInt    iIncomingPort;
+    TInt    iAttachmentSizeLimit;
+    TInt    iBodyTextSizeLimit;
+    TInt    iAttachmentFetchSize;
+    TInt    iImapIdleTimeout;
+    TInt    iMaxEmailSize;
+    TInt    iSyncRate;
+    TInt    iInboxSyncLimit; // -1 = All
+    TInt    iMailboxSyncLimit; // -1 = All
+    TInt    iOutgoingPort;
+    TInt    iToCCIncludeLimit;
+    
+    TBool   iIncomingSSLWrapper;
+    TBool   iIncomingSecureSockets;
+    TBool   iAcknowledgeReceipts;
+    TBool   iAutoSendOnConnect;
+    TBool   iDeleteEmailsAtDisconnect;
+    TBool   iImapIdleCommand;
+    TBool   iMarkSeenInSync;
+    TBool   iEnableExpungeMode;
+    TBool   iUseApop;
+    TBool   iDisconnectedUserMode;
+    TBool   iOutgoingSSLWrapper;
+    TBool   iOutgoingSecureSockets;
+    TBool   iIncludeSignature;
+    TBool   iAddVCard;
+    TBool   iRequestReceipts;
+    TBool   iSmtpAuth;
+    
+    TGetEmailOption iGetEmailOptions;   
+    TFolderSubscribeType iSubscribeType;    
+    TFolderSyncType iSyncType;  
+    TImSMTPSendCopyToSelf iSendCopyToSelf;
+    TImSMTPSendMessageOption iSendOption;    
+    TMailboxType iMailboxType;  // IMAP4 or POP3
+    
+public:
+    CMailboxesParameters();
+    ~CMailboxesParameters();
+    };
+
+
+
+#endif // __CREATORMAILBOXES_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_mailboxelement.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,129 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef CREATORMAILBOXELEMENT_H_
+#define CREATORMAILBOXELEMENT_H_
+
+#include "creator_scriptelement.h"
+
+namespace creatormailbox
+{
+    _LIT(Kmailbox, "mailbox");
+    _LIT(Kname, "name");
+    _LIT(Kincomingport, "incomingport");
+    _LIT(Kincomingsslwrapper, "incomingsslwrapper");
+    _LIT(Kincomingsecuresockets, "incomingsecuresockets");
+    _LIT(Kincomingloginname, "incomingloginname");
+    _LIT(Kincomingpassword, "incomingpassword");
+    _LIT(Kincomingservername, "incomingservername");
+    _LIT(Kincomingconnectionmethod, "incomingconnectionmethod");
+    _LIT(Kacknowledgereceipts, "acknowledgereceipts");
+    _LIT(Kattachmentsizelimit, "attachmentsizelimit");
+    _LIT(Kautosendonconnect, "autosendonconnect");
+    _LIT(Kbodytextsizelimit, "bodytextsizelimit");
+    _LIT(Kdeletemailsatdisconnect, "deletemailsatdisconnect");
+    _LIT(Kattachmentfetchsize, "attachmentfetchsize");
+    _LIT(Kincomingfolderpath, "incomingfolderpath");
+    _LIT(Kpathseparator, "pathseparator");
+    _LIT(Kgetemailoptions, "getemailoptions");
+    _LIT(Kimapidlecommand, "imapidlecommand");
+    _LIT(Kimapidletimeout, "imapidletimeout");
+    _LIT(Kmaxemailsize, "maxemailsize");
+    _LIT(Ksubscribetype, "subscribetype");
+    _LIT(Ksyncrate, "syncrate");
+    _LIT(Kfoldersynctype, "foldersynctype");
+    _LIT(Kmarkseeninsync, "markseeninsync");
+    _LIT(Kenableexpungemode, "enableexpungemode");
+    _LIT(Kuseapopsecurelogin, "useapopsecurelogin");
+    _LIT(Kinboxsynclimit, "inboxsynclimit");
+    _LIT(Kmailboxsynclimit, "mailboxsynclimit");
+    _LIT(Kdisconnectedusermode, "disconnectedusermode");
+    _LIT(Koutgoingport, "outgoingport");
+    _LIT(Koutgoingsslwrapper, "outgoingsslwrapper");
+    _LIT(Koutgoingsecuresockets, "outgoingsecuresockets");
+    _LIT(Koutgoingloginname, "outgoingloginname");
+    _LIT(Koutgoingpassword, "outgoingpassword");
+    _LIT(Koutgoingservername, "outgoingservername");
+    _LIT(Koutgoingconnectionmethod, "outgoingconnectionmethod");
+    _LIT(Kincludesignature, "includesignature");
+    _LIT(Kaddvcard, "addvcard");
+    _LIT(Kownemail, "ownemail");
+    _LIT(Kemailalias, "emailalias");
+    _LIT(Kreceiptaddress, "receiptaddress");
+    _LIT(Kreplytoaddress, "replytoaddress");
+    _LIT(Krequestreceipts, "requestreceipts");
+    _LIT(Ksmtpauth, "smtpauth");
+    _LIT(Kcopytoself, "copytoself");
+    _LIT(Ksendoption, "sendoption");
+    _LIT(Ktoccincludelimit, "toccincludelimit");
+    
+    
+    // Get email options:
+    _LIT(Kgetheaders, "getheaders");
+    _LIT(Kgetbodytext, "getbodytext");
+    _LIT(Kgetbodytextandattachments, "getbodytextandattachments");
+    _LIT(Kgetattachments, "getattachments");
+    _LIT(Kgetbodyalternativetext, "getbodyalternativetext");
+    
+    // Subscribe types:
+    _LIT(Kupdateneither, "updateneither");
+    _LIT(Kupdatelocal, "updatelocal");
+    _LIT(Kupdateremote, "updateremote");
+    _LIT(Kupdateboth, "updateboth");
+    
+    // Folder sync. types:
+    _LIT(Kusecombination, "usecombination");
+    _LIT(Kuselocal, "uselocal");
+    _LIT(Kuseremote, "useremote");
+    
+    // Send copy to self option:
+    _LIT(Kno, "no");
+    _LIT(Kto, "to");
+    _LIT(Kcc, "cc");
+    _LIT(Kbcc, "bcc");
+    
+    // Send option:
+    _LIT(Kimmediately, "immediately");
+    _LIT(Konnextconnection, "onnextconnection");
+    _LIT(Konrequest, "onrequest");
+    
+    // Mailbox types:
+    _LIT(KMailboxType, "type");
+    _LIT(Kpop3, "pop3");
+    _LIT(Kimap4, "imap4");
+    _LIT(Ksyncml, "syncml");
+}
+
+class CCreatorMailboxElement : public CCreatorScriptElement
+{
+public:
+    static CCreatorMailboxElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC);
+    void ExecuteCommandL();
+    
+protected:
+    CCreatorMailboxElement(CCreatorEngine* aEngine);
+    TBool SetTextParamL(const TDesC& aElemName, const TDesC& aElemContent, CMailboxesParameters* aParams, TBool aSetRandom );
+    TBool SetBooleanParamL(const TDesC& aElemName, const TDesC& aElemContent, CMailboxesParameters* aParams, TBool aSetRandom );
+    TBool SetIntegerParamL(const TDesC& aElemName, const TDesC& aElemContent, CMailboxesParameters* aParams, TBool aSetRandom );
+    TBool SetEnumParamL(const TDesC& aElemName, const TDesC& aElemContent, CMailboxesParameters* aParams, TBool aSetRandom );
+    
+    TBool GetBooleanValueL(const TDesC& aElemContent, TBool aSetRandom);
+};
+
+#endif /*CREATORMAILBOXELEMENT_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_message.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,226 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef __CREATORMESSAGES_H__
+#define __CREATORMESSAGES_H__
+
+#include "creator_model.h"
+#include "creator_modulebase.h"
+
+#include <e32base.h>
+#include <e32std.h>
+#include <msvapi.h>
+#include <mtclbase.h>
+#include <mtclreg.h>
+#include <smut.h>
+#include <smuthdr.h>
+#include <smsclnt.h>
+#include <miutset.h>
+#include <mmsclient.h>
+#include <ircmtm.h>
+#include <irmsgtypeuid.h>
+#include <btmsgtypeuid.h>
+#include <bif.h>
+#include <biouids.h>
+#include <miuthdr.h>
+
+#include <cmsvmimeheaders.h>
+#include <smtcmtm.h>
+#include <ircmtm.h>
+#include <btcmtm.h>
+#include <mmsvattachmentmanager.h>
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+#include <MVPbkSingleContactOperationObserver.h>
+#include <MVPbkContactStoreListObserver.h>
+#include <MVPbkContactFindObserver.h>
+class CVPbkContactManager;
+#endif
+
+class CCreatorEngine;
+class CMessagesParameters;
+class CAsyncWaiter; 
+
+enum TMessageType
+    {
+    ESMS = 0,
+    EMMS,
+    EAMS,
+    EEmail,
+    ESmartMessage,
+    EIrMessage,
+    EBTMessage
+    };
+
+enum TFolderType
+    {
+    EInbox = 0,
+    EDrafts,
+    EOutbox,
+    ESent,
+    EMailbox
+    };
+    
+class CRecipientInfo : public CBase
+{
+public:
+    CRecipientInfo();
+    virtual ~CRecipientInfo();
+    
+    void SetPhoneNumber(HBufC* aPhone);
+    void SetEmailAddress(HBufC* aEmail);
+    const HBufC* PhoneNumber() const;
+    const HBufC* EmailAddress() const;
+    
+private:
+    HBufC* iPhoneNumber;
+    HBufC* iEmailAddress;
+};
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+class CCreatorMessages : public CBase, public MCreatorModuleBase, public MMsvSessionObserver, 
+    public MVPbkSingleContactOperationObserver, public MVPbkContactStoreListObserver, public MVPbkContactFindObserver
+#else
+class CCreatorMessages : public CBase, public MCreatorModuleBase, public MMsvSessionObserver
+#endif
+    {
+public: 
+    static CCreatorMessages* NewL(CCreatorEngine* aEngine);
+    static CCreatorMessages* NewLC(CCreatorEngine* aEngine);
+    ~CCreatorMessages();
+
+private:
+    CCreatorMessages();
+    void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase
+
+    TInt CreateSMSEntryL(const CMessagesParameters& parameters);
+    TInt CreateMMSEntryL(const CMessagesParameters& parameters);
+    TInt CreateAMSEntryL(const CMessagesParameters& parameters);
+    TInt CreateEmailEntryL(const CMessagesParameters& parameters);
+    TInt CreateSmartMessageEntryL(const CMessagesParameters& parameters);
+    TInt CreateObexEntryL(TUid aMtm, const CMessagesParameters& parameters);
+    void HandleAttachementsL(const CMessagesParameters& parameters, CMsvStore* store, TInt err );
+    void HandleAttachementL(CMsvStore* store, TInt err, TFileName& sourceFileName );
+
+    CMsvEntrySelection* DoGetListOfAccountsL(CMsvSession& aSession, TUid aMtm, TBool aAlwaysListHidden);
+    TMsvId DefaultServiceForMTML(CMsvSession& aSession, TUid aMtm, TBool aFindFirstServiceIfNoDefault);
+
+    void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); // from MMsvSessionObserver
+    
+    void AddRecipientsL(CBaseMtm& aMtm, const CMessagesParameters& aParameters, TBool aUseEmailAddress );
+    void GetLinkedAddressesL(   RPointerArray<HBufC>& aAddressArray, 
+                                const RArray<TLinkIdParam>& aLinkIds, 
+                                TBool aUseEmailAddress,
+                                TInt aNumOfExistingAddresses );
+    
+    void GetAllRecipientsL(RPointerArray<HBufC>& aRecipientArray, const CMessagesParameters& aParameters, TBool aUseEmailAddress );
+    void SetSenderToEntryDetails(TMsvEntry& aMsgEntry, const CMessagesParameters& aParameters, TBool aUseEmailAddress);
+    void SetRecipientToEntryDetails(TMsvEntry& aMsgEntry, const CMessagesParameters& aParameters, TBool aUseEmailAddress);
+    void AddSenderToMtmAddresseeL(CBaseMtm& aMtm, const CMessagesParameters& aParameters, TBool aUseEmailAddress );
+    void AddMtmSenderL(CMmsClientMtm& aMtm, const CMessagesParameters& aParameters, TBool aUseEmailAddress );
+    void GetSendersL(RPointerArray<HBufC>& aSenderArray, const CMessagesParameters& aParameters, TBool aUseEmailAddress, TInt aMaxNum );
+    void DeleteAllMessagesL( TBool aOnlyCreatedWithCreator );
+    void DeleteAllFromFolderL( const TMsvId aContext, CMsvSession* aSession, CSmsClientMtm* aClientMtm, TBool aOnlyCreatedWithCreator = EFalse );
+    
+public:
+    TBool AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries); // from MCreatorModuleBase
+
+    TInt CreateMessageEntryL(CMessagesParameters *aParameters, TBool aTakeUserGivenParameters=EFalse);    
+    TInt CreateRandomMessageEntryL(TInt aCommand);
+    void DeleteAllL();
+    void DeleteAllCreatedByCreatorL();
+    
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+    // From MVPbkSingleContactOperationObserver:
+    virtual void VPbkSingleContactOperationComplete(
+            MVPbkContactOperationBase& aOperation,
+            MVPbkStoreContact* aContact );
+            
+    virtual void VPbkSingleContactOperationFailed(
+            MVPbkContactOperationBase& aOperation, 
+            TInt aError );
+    
+    void HandleSingleContactResultL();
+            
+    // From MVPbkContactStoreListObserver
+    virtual void OpenComplete();
+    virtual void StoreReady(MVPbkContactStore&);
+    virtual void StoreUnavailable(MVPbkContactStore&, TInt);
+    virtual void HandleStoreEventL(MVPbkContactStore&, TVPbkContactStoreEvent);
+    
+    // From MVPbkContactFindObserver
+    virtual void FindCompleteL( MVPbkContactLinkArray* aResults );
+    virtual void FindFailed( TInt aError );
+#endif
+
+private:
+    CMessagesParameters*    iParameters;
+    TMessageType            iMessageType;
+    TFolderType             iFolderType;
+    TInt                    iDefinedMessageLength;
+    CArrayFixFlat<TInt>*    iAttachments; 
+    //RPointerArray<HBufC>    iAttachmentPaths;
+    TBool                   iCreateAsUnread;
+    TMsvId                  iUserSelectedMailbox;
+    HBufC*                  iTmpPhoneNumber;
+    HBufC*                  iTmpEmail;
+    RArray<TInt>            iEntryIds; // TMsvId ( == TInt32 ) TMsvEntry::Id()
+    CMsvSession*            iSession;
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+    MVPbkContactLinkArray*  iExistingContacts;
+    CVPbkContactManager* iContactManager;
+    MVPbkContactStore* iStore;
+    MVPbkStoreContact* iTempContact;
+#endif
+    CAsyncWaiter* iWaiter;
+    RPointerArray<HBufC>    iSenderArray;
+    RPointerArray<HBufC>    iRecipientArray;
+public:
+    };
+
+
+class CMessagesParameters : public CCreatorModuleBaseParameters
+    {
+public: 
+    TMessageType            iMessageType;
+    TFolderType             iFolderType;
+    HBufC*                  iSenderAddress;    
+    HBufC*                  iRecipientAddress;
+    RPointerArray<HBufC>    iRecipientAddressArray;
+    HBufC*                  iMessageSubject;
+    HBufC*                  iMessageBodyText;
+    CArrayFixFlat<TInt>*    iAttachments; 
+    RPointerArray<HBufC>    iAttachmentPaths;
+    TInt                    iDefinedMessageLength;
+    TUid                    iBIOMessageType;
+    TBool                   iCreateAsUnread;
+    RArray<TLinkIdParam>    iRecipientLinkIds;
+    RArray<TLinkIdParam>    iSenderLinkIds;
+    TInt                    iNumberOfExistingRecipients;
+    TInt                    iNumberOfExistingSenders;
+
+public:
+    CMessagesParameters();
+    ~CMessagesParameters();
+    };
+
+
+
+#endif // __CREATORMESSAGES_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_messageelement.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef CREATORMESSAGEELEMENT_H_
+#define CREATORMESSAGEELEMENT_H_
+
+#include "creator_scriptelement.h"
+#include "creator_message.h"
+
+namespace creatormsg
+{
+    _LIT(KMessage, "message");
+    _LIT(KType, "type");
+    _LIT(KTo, "to");
+    _LIT(KFrom, "from");
+    _LIT(KFolder, "folder");
+    _LIT(KSubject, "subject");
+    _LIT(KText, "text");
+    _LIT(KAttachmentPath, "attachmentpath");
+    _LIT(KAttachmentId, "attachmentid");
+    _LIT(KStatus, "status");
+    _LIT(KSms, "sms");
+    _LIT(KMms, "mms");
+    _LIT(KAms, "ams");
+    _LIT(KEmail, "email");
+    _LIT(KSmart, "smart");
+    _LIT(KBt, "bt");
+    _LIT(KIr, "ir");
+    _LIT(KSent, "sent");
+    _LIT(KInbox, "inbox");
+    _LIT(KDraft, "draft");
+    _LIT(KOutbox, "outbox");
+    _LIT(KMailbox, "mailbox");
+    _LIT(KRead, "read");
+    _LIT(KNew, "new");
+}
+
+/*
+ * Builds message parameters from the parsed script and adds a command to the engine 
+ */
+class CCreatorMessageElement : public CCreatorScriptElement
+{
+public:
+    static CCreatorMessageElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC);
+    void ExecuteCommandL();
+protected:    
+    CCreatorMessageElement(CCreatorEngine* aEngine);
+    /*
+     * Creates message address. The address type is based on the message type.
+     * @return Phone number string for SMS, MMS, AMS and Smart messages. Email address for other types.
+     * @param msgType Message type.
+     */
+    HBufC* CreateMessageAddressLC(const TDesC& msgType);
+    /*
+     * Sets message type to parameters
+     * @param aParameters Message parameters
+     * @param aMsgTypeStr Message type string
+     */
+    void SetMessageTypeL(CMessagesParameters& aParameters, const TDesC& aMsgTypeStr ) const;
+    /*
+     * Gets length of the random data
+     * @return Length of the random data
+     * @param aRandomLenStr String defining the random length (from the script)
+     * @param aMsgType Message type string
+     */
+    TInt GetRandomBodyLengthL(const TDesC& aRandomLenStr, const TDesC& aMsgType ) const;
+    /*
+     * Gets maximum length of the body text
+     * @return Maximum length of the body text
+     * @param aMsgType Message type string
+     */
+    TInt GetMaxBodyLength( const TDesC& aMsgType ) const;
+
+};
+    
+
+#endif /*CREATORMESSAGEELEMENT_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_model.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,455 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#ifndef __CREATORENGINE_H__
+#define __CREATORENGINE_H__
+
+
+#include "creator_appui.h"
+#include "creator.hrh"
+
+#include "creator_std.h"
+#include "creator_scriptentry.h"
+#include "creator_modulebase.h"
+#include "creator_browser.h"
+#include "creator_calendar.h"
+#include "creator_phonebookbase.h"
+#include "creator_note.h"
+#include "creator_log.h"
+#include "creator_connectionmethodbase.h"
+#include "creator_mailbox.h"
+#include "creator_imps.h"
+#include "creator_message.h"
+#include "creator_landmark.h"
+#include "creator_randomdataparser.h"
+
+#include <e32base.h>
+#include <aknenv.h>
+#include <coeutils.h>
+#include <apparc.h>
+#include <eikenv.h>
+#include <AknProgressDialog.h>
+#include <eikprogi.h>
+#include <bautils.h>
+#include <commdb.h>
+#include <imageconversion.h> //TFrameInfo
+
+class CCreatorAppUi;
+class TCommand;
+class CCreatorBrowser;
+class CCreatorCalendarBase;
+class CCreatorNotepad;
+class CCreatorLogs;
+class CCreatorAccessPoints;
+class CCreatorMailboxes;
+class CCreatorIMPS;
+class CCreatorFiles;
+class CCreatorMessages;
+class CCreatorLandmarks;
+class CDictionaryFileStore;
+class CImageDecoder;
+class CFbsBitmap;
+class CBitmapScaler;
+
+// Common constant for undefined integer value:
+const TInt KUndef = KErrNotFound;
+
+class CCreatorEngine : public CActive, public MProgressDialogCallback 
+	{
+public:
+    
+    enum TRandomStringType
+        {
+        EFirstName = 0,
+        ESurname,
+        ECompany,
+        EAddress,
+        EJobTitle,
+        EPhoneNumber,
+        EGroupName,
+        EMeetingReason,
+        EMeetingPlace,
+        EMemoText,
+        EAnniversaryReason,
+        EToDoText,
+        EReminderText,
+        EMessageSubject,
+        EMessageText,
+        ECity,
+        ECountry,
+        EPostcode,        
+        EState,
+        EPobox,
+        EPrefix,
+        ESuffix,
+        ELandmarkName,
+        ELandmarkDescription
+        };
+
+
+// note! changing order will cause regression in other modules
+
+    enum TTestDataPath
+        {
+        EJPEG_25kB = 0,
+        EJPEG_200kB,
+        EJPEG_500kB,
+        EPNG_15kB,
+        EGIF_2kB,
+        ERNG_1kB,
+        EMIDI_10kB,
+        EWAVE_20kB,
+        EAMR_20kB,
+        EExcel_15kB,
+        EWord_20kB,
+        EPowerPoint_40kB,
+        EText_10kB,
+        EText_70kB,
+        E3GPP_70kB,
+        EMP3_250kB,
+        EAAC_100kB,
+        ERM_95kB,
+        EBMP_25kB,
+        EHTML_20kB,
+        EJAD_1kB,
+        EJAR_10kB,
+        EJP2_65kB,
+        EMP4_200kB,
+        EMXMF_40kB,
+        ERAM_1kB,
+        ESVG_15kB,
+        ESWF_15kB,
+        ETIF_25kB,
+        EVCF_1kB,
+        EVCS_1kB,
+        ESISX_10kB,
+        EWMA_50kB,
+        EWMV_200kB,
+        ESavedDeck_1kB,
+        LAST_FILE_ID//When you add new items to enum, add them before last item, so random number generations does not need to be updated also         
+        };
+        
+    enum TRandomDateType
+        {
+        EDatePast,
+        EDateFuture    
+        };
+
+public:
+    static CCreatorEngine* NewL(CCreatorAppUi* aAppUi);
+    ~CCreatorEngine();
+
+private:
+    CCreatorEngine();
+    void ConstructL(CCreatorAppUi* aAppUi);
+    void Init();
+    void RunL();
+    TInt RunError(TInt aError);
+    void DoCancel();
+
+    void ExecuteFirstCommandL(const TDesC& aText);
+    void ExecuteCommand();
+    void StartEnginesL();
+    void ShutDownEnginesL();
+    void CheckForMoreCommandsL();
+    void DialogDismissedL(TInt aButtonId);  //from MProgressDialogCallback 
+    
+    TBool IsDeleteCommand( TInt aCommand );
+    
+    TInt ReadRandomDataL(const TRandomStringType aRandomStringType,
+    		             const TInt aResourceId,
+    		             const TDesC& aFilename,
+    		             const CCreatorRandomDataParser::TRandomDataType aRandomDataType);
+    void GenerateSourceImageFileL( const TTestDataPath aFileType, const TDesC& aFileName );
+    void GenereteSourceTextFileL( const TDesC& aFileName, TInt aSize );
+
+public:
+    void ExecuteOptionsMenuCommandL(TInt aCommand);
+    void RunScriptL();
+    TInt RunScriptL(const TDesC& aScriptFile);
+
+    void AppendToCommandArrayL(TInt aCommand, CCreatorModuleBaseParameters* aParameters, TInt aNumberOfEntries = 1);
+    TInt CommandArrayCount();
+
+    TBool EntriesQueryDialogL(TInt& aNumberOfEntries, const TDesC& aPrompt, TBool aAcceptsZero=EFalse);
+    TBool TimeQueryDialogL(TTime& aTime, TInt aResourceId);
+    TBool YesNoQueryDialogL(const TDesC& aPrompt);
+    
+    TPtrC TestDataPathL(enum TTestDataPath aTestDataPath);
+    TPtrC RandomSoundFileL(); // Returns temporary path, which will be removed on shutdown 
+    TPtrC RandomPictureFileL();  // Returns temporary path, which will be removed on shutdown
+    TPtrC CreateRandomSoundFileL(); // Copies file to new location and returns the new path
+    TPtrC CreateSoundFileL(TTestDataPath aId); // Copies file to new location and returns the new path
+    
+    void CopyFileL(const TFileName& aSourceFile, const TFileName& aTargetFile, TBool aOverwrite = EFalse );
+    /*
+     * Gets attacment file id based on the file id string
+     * @return Attachment file id
+     * @param aAttachmentIdStr Attachment file id string
+     */
+    TInt GetAttachmentIdL( const TDesC& aAttachmentIdStr ) const;    
+
+    TUint32 GetDefaultIAPL();
+    TUint32 AccessPointNameToIdL(const TDesC& aAPName, TBool aAnyIfNotFound = EFalse );
+
+    TPtrC RandomString(enum TRandomStringType aRandomStringType);    
+    TInt RandomNumber(TInt aRange);
+    TInt RandomNumber(TInt aMin, TInt aMax);
+    TTime RandomDate(TRandomDateType type, TInt aMinDays = 0, TInt aMaxDays = 360 );
+    TTime RandomDate(TTime baseTime, TRandomDateType type, TInt aMinDays = 0, TInt aMaxDays = 360);  
+    TTime RandomTime(TTime baseTime, TRandomDateType type, TInt aMinHours=0, TInt aMaxHours=24, TInt aMinMinutes=0, TInt aMaxMinutes=60 );
+    CDesCArrayFlat* SoundFilesL();
+    CDesCArrayFlat* PictureFilesL();
+    
+    HBufC* CreateEmailAddressLC();
+    HBufC* CreateHTTPUrlLC();
+    HBufC* CreateRandomStringLC(TInt aStrLen);
+    
+    HBufC* CreateEmailAddressLC(
+            const TDesC& firstname,
+            const TDesC& lastname,
+            const TDesC& domain,
+            const TDesC& country ) const;
+    
+    HBufC* CreateUrlLC(
+            const TDesC& protocol,
+            const TDesC& prefix,
+            const TDesC& domain,
+            const TDesC& country) const;
+    
+    void SetDefaultPathForFileCommandL(TInt aCommand, TFileName& aPath);
+
+    TBool GetRandomDataFilenameL(TDes& aFilename);
+    TBool GetRandomDataFromFileL(const TDesC& aFilename);
+    void CancelComplete();
+    CDictionaryFileStore* FileStoreLC();
+    void ReadEntryIdsFromStoreL( RArray<TInt>& aEntryIds, const TUid aModuleUid );
+    void WriteEntryIdsToStoreL( RArray<TInt>& aEntryIds, const TUid aModuleUid );
+    void ReadEntryIdsFromStoreL( RArray<TUint32>& aEntryIds, const TUid aModuleUid );
+    void WriteEntryIdsToStoreL( RArray<TUint32>& aEntryIds, const TUid aModuleUid );
+    void RemoveStoreL( const TUid aModuleUid );
+    
+private:
+    // needed by the engine itself
+    RTimer iTimer;
+    CEikonEnv* iEnv;
+    CCreatorAppUi* iAppUi;
+    TInt iCurrentEntry;
+    TInt iEntriesToBeCreated;
+    TInt iFailedCommands;
+
+    CDesCArrayFlat* iSoundFileArray;
+    CDesCArrayFlat* iPictureFileArray;
+    CCommandArray* iCommandArray;
+    RPointerArray<CCreatorModuleBaseParameters> iParameterArray;
+    // progress bar
+    CAknProgressDialog* iProgressDialog;
+    CEikProgressInfo* iProgressInfo;
+        
+    // for the random data generator
+    TInt64 iSeed;
+    
+    class TStringArrayPtr
+        {
+        public:
+        TStringArrayPtr(TRandomStringType aType, CDesCArray* aPtr)
+            {
+            iStringType = aType;
+            iArrayPtr = aPtr;
+            };
+        TRandomStringType iStringType;
+        CDesCArray* iArrayPtr;
+        }; 
+    
+    RArray<TStringArrayPtr> iStringArrays;
+    
+    // modules
+    CCreatorBrowser* iBrowser;
+    CCreatorCalendarBase* iCalendar;
+    CCreatorPhonebookBase* iPhonebook;
+    CCreatorNotepad* iNotepad;
+    CCreatorLogs* iLogs;
+    CCreatorConnectionSettingsBase* iAccessPoints;
+    CCreatorMailboxes* iMailboxes;
+    CCreatorIMPS* iIMPS;
+    CCreatorFiles* iFiles;
+    CCreatorMessages* iMessages;
+    CCreatorLandmarks* iLandmarks;
+
+    // options menu command home module
+    MCreatorModuleBase* iUsedOptionsMenuModule;
+    
+    HBufC* iTempPath;
+    
+    RPointerArray<HBufC> iAllocatedFilePaths;
+    TBool iUserCancelled;
+    
+    // For generating missing bitmaps
+    HBufC8* iBitmapData;
+    CFbsBitmap* iBitmap;
+    CFbsBitmap* iScaledBitmap;
+    CImageDecoder* iDecoder;
+    TFrameInfo iFrameinfo;
+    CImageEncoder* iEncoder;
+    CFrameImageData* iFrameImageData;
+    CBitmapScaler* iScaler;
+
+public:
+
+	};
+
+// this class contains a command which will be executed
+class TCommand
+    {
+public:
+    TInt iCommandId;
+    CCreatorModuleBaseParameters* iParameters;
+public:
+    TCommand(TInt aCommandId, CCreatorModuleBaseParameters* aParameters);
+    ~TCommand();
+
+    };
+
+
+// utility class for waiting for asychronous requests
+class CAsyncWaiter : public CActive
+	{
+public:
+	static CAsyncWaiter* NewL( TInt aPriority = EPriorityStandard );
+	static CAsyncWaiter* NewLC( TInt aPriority = EPriorityStandard );
+	~CAsyncWaiter();
+	
+	void StartAndWait();
+	TInt Result() const;
+	
+private:
+	CAsyncWaiter( TInt aPriority );
+	
+	// from CActive
+	void RunL();
+	void DoCancel();
+	
+private:
+    CActiveSchedulerWait iWait;
+	TInt iError;
+	};
+	
+	
+/*
+ * Maps file id string (file name) to TTestDataPath (file id) and TCreatorIds (command id)
+ */
+// File ids:
+	
+	_LIT(K3GPP_70KB, "3GPP-70kB");
+	_LIT(KAAC_100KB, "AAC-100kB");
+	_LIT(KAMR_20KB, "AMR-20kB");
+	_LIT(KXLS_15KB, "XLS-15kB");
+	_LIT(KGIF_2KB, "GIF-2kB");
+	_LIT(KJPEG_200KB, "JPEG-200kB");
+	_LIT(KJPEG_25KB, "JPEG-25kB");
+	_LIT(KJPEG_500KB, "JPEG-500kB");
+	_LIT(KMIDI_10KB, "MIDI-10kB");
+	_LIT(KMP3_250KB, "MP3-250kB");
+	_LIT(KPNG_15KB, "PNG-15kB");
+	_LIT(KPPT_40KB, "PPT-40kB");
+	_LIT(KRM_95KB, "RM-95kB");
+	_LIT(KRNG_1KB, "RNG-1kB");
+	_LIT(KTXT_10KB, "TXT-10kB");
+	_LIT(KTXT_70KB, "TXT-70kB");
+	_LIT(KWAV_20KB, "WAV-20kB");
+	_LIT(KDOC_20KB, "DOC-20kB");
+	_LIT(KSWF_15KB, "SWF-15kB");
+	_LIT(KJAD_1KB, "JAD-1kB");
+	_LIT(KJAR_10KB, "JAR-10kB");
+	_LIT(KTIF_25KB, "TIF-25kB");
+	_LIT(KMXMF_40KB, "MXMF-40kB");
+	_LIT(KBMP_25KB, "BMP-25kB");
+	_LIT(KJP2_25KB, "JP2-25kB");
+	_LIT(KSVG_15KB, "SVG-15kB");
+	_LIT(KHTML_20KB, "HTML-20kB");
+	_LIT(KVCF_1KB, "VCF-1kB");
+	_LIT(KVCS_1KB, "VCS-1kB");
+	_LIT(KMP4_200KB, "MP4-200kB");
+	_LIT(KSISX_10KB, "SISX-10kB");
+	_LIT(KRAM_1KB, "RAM-1kB");
+    _LIT(KDECK_1KB, "DECK-1kB");
+    _LIT(KWMA_50KB, "WMA-50kB");
+    _LIT(KWMV_200KB, "WMV-200kB");
+	
+class FileMapping
+    {
+	public:
+	FileMapping(const TDesC& aFileName, TInt aFileId, TInt aCommandId );
+	const TDesC& FileName() const;
+	TInt FileId() const;
+	TInt CommandId() const;
+
+	private:
+	const TDesC& iFileName;
+	TInt  iFileId;
+	TInt  iCommandId;
+	};
+	
+	/*
+	 * This table contains the string <-> TTestDataPath mappings for the file types
+	 */
+	static FileMapping FileMap[] = 
+	    {
+      
+	    FileMapping(K3GPP_70KB, CCreatorEngine::E3GPP_70kB, ECmdCreateFileEntry3GPP_70kB),
+	    FileMapping(KAAC_100KB, CCreatorEngine::EAAC_100kB, ECmdCreateFileEntryAAC_100kB),
+	    FileMapping(KAMR_20KB, CCreatorEngine::EAMR_20kB, ECmdCreateFileEntryAMR_20kB),
+	    FileMapping(KXLS_15KB, CCreatorEngine::EExcel_15kB, ECmdCreateFileEntryXLS_15kB),
+	    FileMapping(KGIF_2KB, CCreatorEngine::EGIF_2kB, ECmdCreateFileEntryGIF_2kB),
+	    FileMapping(KJPEG_200KB, CCreatorEngine::EJPEG_200kB, ECmdCreateFileEntryJPEG_200kB),
+	    FileMapping(KJPEG_25KB, CCreatorEngine::EJPEG_25kB, ECmdCreateFileEntryJPEG_25kB),
+	    FileMapping(KJPEG_500KB, CCreatorEngine::EJPEG_500kB, ECmdCreateFileEntryJPEG_500kB),
+	    FileMapping(KMIDI_10KB, CCreatorEngine::EMIDI_10kB, ECmdCreateFileEntryMIDI_10kB),
+	    FileMapping(KMP3_250KB, CCreatorEngine::EMP3_250kB, ECmdCreateFileEntryMP3_250kB),
+	    FileMapping(KPNG_15KB, CCreatorEngine::EPNG_15kB, ECmdCreateFileEntryPNG_15kB),
+	    FileMapping(KPPT_40KB, CCreatorEngine::EPowerPoint_40kB, ECmdCreateFileEntryPPT_40kB),
+	    FileMapping(KRM_95KB, CCreatorEngine::ERM_95kB, ECmdCreateFileEntryRM_95kB),
+	    FileMapping(KRNG_1KB, CCreatorEngine::ERNG_1kB, ECmdCreateFileEntryRNG_1kB),
+	    FileMapping(KTXT_10KB, CCreatorEngine::EText_10kB, ECmdCreateFileEntryTXT_10kB),
+	    FileMapping(KTXT_70KB, CCreatorEngine::EText_70kB, ECmdCreateFileEntryTXT_70kB),
+	    FileMapping(KWAV_20KB, CCreatorEngine::EWAVE_20kB, ECmdCreateFileEntryWAV_20kB),
+	    FileMapping(KDOC_20KB, CCreatorEngine::EWord_20kB, ECmdCreateFileEntryDOC_20kB),
+	    FileMapping(KBMP_25KB, CCreatorEngine::EBMP_25kB, ECmdCreateFileEntryBMP_25kB),
+	    FileMapping(KDECK_1KB, CCreatorEngine::ESavedDeck_1kB, ECmdCreateFileEntryDeck_1kB),
+	    FileMapping(KHTML_20KB, CCreatorEngine::EHTML_20kB, ECmdCreateFileEntryHTML_20kB),
+	    FileMapping(KJAD_1KB, CCreatorEngine::EJAD_1kB, ECmdCreateFileEntryJAD_1kB),
+	    FileMapping(KJAR_10KB, CCreatorEngine::EJAR_10kB, ECmdCreateFileEntryJAR_10kB),
+	    FileMapping(KJP2_25KB, CCreatorEngine::EJP2_65kB, ECmdCreateFileEntryJP2_65kB),
+	    FileMapping(KMP4_200KB, CCreatorEngine::EMP4_200kB, ECmdCreateFileEntryMP4_200kB),
+	    FileMapping(KMXMF_40KB, CCreatorEngine::EMXMF_40kB, ECmdCreateFileEntryMXMF_40kB),
+	    FileMapping(KRAM_1KB, CCreatorEngine::ERAM_1kB, ECmdCreateFileEntryRAM_1kB),
+	    FileMapping(KSVG_15KB, CCreatorEngine::ESVG_15kB, ECmdCreateFileEntrySVG_15kB),
+	    FileMapping(KSWF_15KB, CCreatorEngine::ESWF_15kB, ECmdCreateFileEntrySWF_15kB),
+	    FileMapping(KTIF_25KB, CCreatorEngine::ETIF_25kB, ECmdCreateFileEntryTIF_25kB),
+	    FileMapping(KVCF_1KB, CCreatorEngine::EVCF_1kB, ECmdCreateFileEntryVCF_1kB),
+	    FileMapping(KVCS_1KB, CCreatorEngine::EVCS_1kB, ECmdCreateFileEntryVCS_1kB),
+	    FileMapping(KSISX_10KB, CCreatorEngine::ESISX_10kB, ECmdCreateFileEntrySISX_10kB),
+	    FileMapping(KWMA_50KB, CCreatorEngine::EWMA_50kB, ECmdCreateFileEntryWMA_50kB),
+	    FileMapping(KWMV_200KB, CCreatorEngine::EWMV_200kB, ECmdCreateFileEntryWMV_200kB)
+	    };
+
+#endif // __CREATORENGINE_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_modulebase.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,114 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef __CREATOR_MODULEBASE_H__
+#define __CREATOR_MODULEBASE_H__
+
+#include <e32base.h>
+
+// Dictionary uids for each Creator module.
+// Dictionaries are for storing item identifiers created by Creator.
+// Item identifiers are for enabling deletion of only items created by Creator. 
+const TUid KUidDictionaryUidContacts         = { 0x00 };
+const TUid KUidDictionaryUidContactGroups    = { 0x01 };
+const TUid KUidDictionaryUidCalendar         = { 0x02 };
+const TUid KUidDictionaryUidBrowserBookmarks = { 0x03 };
+const TUid KUidDictionaryUidFiles            = { 0x04 };
+const TUid KUidDictionaryUidLogs             = { 0x05 };
+const TUid KUidDictionaryUidMessages         = { 0x06 };
+const TUid KUidDictionaryUidMailbox          = { 0x07 };
+const TUid KUidDictionaryUidIAP              = { 0x08 };
+const TUid KUidDictionaryUidIMPS             = { 0x09 };
+const TUid KUidDictionaryUidNotes            = { 0x0A };
+const TUid KUidDictionaryUidLandmarks        = { 0x0B };
+const TUid KUidDictionaryUidBrowserSavedPg   = { 0x0C };
+const TUid KUidDictionaryUidBrowserBookmarkF = { 0x0D };
+const TUid KUidDictionaryUidBrowserSavedPgF  = { 0x0E };
+
+class CCreatorEngine;
+class MCreatorModuleBaseParameters;
+class CCommandParser;
+
+class MCreatorModuleBase
+    {
+public:
+
+private:
+    // constructs the module, add "iEngine = aEngine" and other construction stuff to the body
+    virtual void ConstructL(CCreatorEngine* aEngine) = 0;
+
+public:
+    // this one is called when user select some features directly from menu, not running a script
+    // should call CreateRandomData() function
+    // returns ETrue when success, EFalse when user has cancelled
+    virtual TBool AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries) = 0;
+    virtual void DeleteAllL() = 0;
+    virtual void DeleteAllCreatedByCreatorL() = 0;
+
+public:
+    CCreatorEngine* iEngine;
+
+private:
+
+    };
+
+
+class MCreatorModuleBaseParameters
+    {
+    // a base class for the parameters, no default implementation
+    
+    public:
+    	enum TParseParams
+    	{
+    	EParamNone = 0,
+    	ECalendarMeeting,
+    	ECalendarMemo,
+    	ECalendarAnniv,
+    	ECalendarTodo
+    	};
+    
+public:
+	virtual void ParseL(CCommandParser* /*aParser*/, TParseParams /*aCase = 0*/) = 0;
+
+	
+    };
+    
+// Following struct represents the parameters that links for example contact groups
+// to contac-sets.
+typedef struct 
+    {
+    TInt iLinkId; // ID
+    TInt iLinkAmount; // Amount of elements in linked set 
+    } TLinkIdParam;
+
+        
+class CCreatorModuleBaseParameters : public CBase, public MCreatorModuleBaseParameters
+        {
+        public:
+        virtual void ParseL(CCommandParser* /*aParser*/, TParseParams /*aCase = 0*/){};
+        virtual TInt ScriptLinkId() const {return -1;};
+        virtual void SetScriptLinkId(TInt) {};
+        // a base class for the parameters, no default implementation
+        };
+        
+
+
+
+#endif  // __CREATOR_MODULEBASE_H__
+ 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_note.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef __CREATORNOTEPAD_H__
+#define __CREATORNOTEPAD_H__
+
+#include "creator_model.h"
+#include "creator_modulebase.h"
+
+
+#include <e32base.h>
+#include <NpdApi.h>
+
+
+static const TInt KNotepadFieldLength = 1024;
+
+class CCreatorEngine;
+class CNotepadParameters;
+
+
+class CCreatorNotepad : public CBase, public MCreatorModuleBase
+    {
+public: 
+    static CCreatorNotepad* NewL(CCreatorEngine* aEngine);
+    static CCreatorNotepad* NewLC(CCreatorEngine* aEngine);
+    ~CCreatorNotepad();
+
+private:
+    CCreatorNotepad();
+    void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase
+
+public:
+    TBool AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries); // from MCreatorModuleBase
+    TInt CreateNoteEntryL(CNotepadParameters *aParameters);
+    void DeleteAllL();
+    void DeleteAllCreatedByCreatorL();
+
+private:
+    CNotepadApi *iNotepadApi;
+
+    CNotepadParameters* iParameters;
+    RFs& iFs;
+
+public:
+    };
+
+
+class CNotepadParameters : public CCreatorModuleBaseParameters
+    {
+public: 
+    HBufC*              iNoteText;
+
+public:
+    CNotepadParameters();
+    ~CNotepadParameters();
+    };
+
+
+
+#endif // __CREATORNOTEPAD_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_noteelement.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef CREATORNOTEELEMENT_H_
+#define CREATORNOTEELEMENT_H_
+
+#include "creator_scriptelement.h"
+
+namespace creatornote
+{
+    _LIT(KNote, "note");
+    _LIT(KText, "text");
+}
+
+class CCreatorNoteElement : public CCreatorScriptElement
+{
+public:
+    static CCreatorNoteElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC);
+    void ExecuteCommandL();
+    
+protected:
+    CCreatorNoteElement(CCreatorEngine* aEngine);
+};
+
+#endif /*CREATORNOTEELEMENT_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_phonebook.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,117 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef __CREATORPHONEBOOK_H__
+#define __CREATORPHONEBOOK_H__
+
+#include "creator_model.h"
+#include "creator_phonebookbase.h"
+
+
+#include <e32base.h>
+#include <cntdef.h>
+#include <cntdb.h>
+#include <cntitem.h>
+#include <cntfldst.h>
+#include <cntview.h>
+#include <cpbkcontactengine.h>
+#include <cpbkcontactitem.h> 
+#include <cpbkfieldinfo.h> 
+#include <cpbkfieldsinfo.h> 
+#include <pbkfields.hrh>
+
+
+
+class CCreatorEngine;
+class CCreatorModuleBaseParameters;
+class CPhonebookParameters;
+
+
+class CCreatorPhonebook : public CCreatorPhonebookBase 
+    {
+public: 
+    static CCreatorPhonebook* NewL(CCreatorEngine* aEngine);
+    static CCreatorPhonebook* NewLC(CCreatorEngine* aEngine);
+    ~CCreatorPhonebook();
+
+private:
+    CCreatorPhonebook();
+    void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase
+
+public:
+
+    TInt CreateContactEntryL(CCreatorModuleBaseParameters *aParameters);    
+    TInt CreateGroupEntryL(CCreatorModuleBaseParameters *aParameters);
+    TInt CreateSubscribedContactEntryL(CCreatorModuleBaseParameters *aParameters);
+    TBool IsActive(){ return EFalse; };
+    void CancelOperation() {};
+    void DeleteAllL();
+    void DeleteAllCreatedByCreatorL();
+    void DeleteAllGroupsL();
+    void DeleteAllGroupsCreatedByCreatorL();
+
+
+private:
+    void CompactPbkDatabase(TBool aCompressImmediately=EFalse);
+    void AddFieldToContactItemL(CPbkContactItem& aItem, TPbkFieldId aFieldId, const TDesC& aFieldText);
+    void DeleteAllItemsL( TUid aStoreUid );
+    void DeleteItemsCreatedWithCreatorL( TUid aStoreUid );
+
+
+private:
+    CPbkContactEngine* iContactDBEngine;
+    TInt iOpCounter;
+    CPhonebookParameters* iParameters;
+    RArray<TInt> iContactIds;
+    RArray<TInt> iGroupIds;        // TContactItemId ( = TInt32 ) CContactItem::Id()
+    RArray<TInt> iEntriesToDelete; // TContactItemId ( = TInt32 ) CContactItem::Id()
+  
+public:
+    };
+
+
+class CPhonebookParameters : public CCreatorModuleBaseParameters
+    {
+public:
+	void ParseL(CCommandParser* parser, TParseParams /*aCase = 0*/);
+    HBufC*  iContactFirstName;
+    HBufC*  iContactLastName;
+    HBufC*  iContactCompanyName;
+    HBufC*  iContactJobTitle;
+    HBufC*  iContactPostalAddress;
+    HBufC*  iWvUserId;
+    HBufC*  iRingingtone;
+    HBufC*  iThumbnailImage;
+    HBufC*  iContactPhoneNumberGeneral;     TInt iNumberOfPhoneNumberFields;
+    HBufC*  iContactURL;                    TInt iNumberOfURLFields;
+    HBufC*  iContactEmailAddress;           TInt iNumberOfEmailAddressFields;
+
+    HBufC*  iGroupName;
+    TInt    iContactsInGroup;
+
+
+public:
+    CPhonebookParameters();
+    ~CPhonebookParameters();
+    };
+
+
+
+#endif // __CREATORPHONEBOOK_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_phonebookbase.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef __CCREATORPHONEBOOKBASE_H_
+#define __CCREATORPHONEBOOKBASE_H_
+
+#include "creator_modulebase.h"
+
+static const TInt KPhonebookFieldLength = 128;
+static const TInt KCreateRandomAmountOfGroups = -9999;
+
+class CCreatorModuleBaseParameters;
+
+class CCreatorPhonebookBase : public CBase, public MCreatorModuleBase{
+public:
+
+    virtual TInt CreateContactEntryL(CCreatorModuleBaseParameters *aParameters) = 0;    
+    virtual TInt CreateGroupEntryL(CCreatorModuleBaseParameters *aParameters) = 0;
+    virtual TInt CreateSubscribedContactEntryL(CCreatorModuleBaseParameters *aParameters) = 0;
+    virtual TBool AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries); // from MCreatorModuleBase
+    virtual TBool IsActive() = 0;
+    virtual void CancelOperation() = 0;
+    virtual void DeleteAllGroupsL() = 0;
+    virtual void DeleteAllGroupsCreatedByCreatorL() = 0;
+    
+protected:
+
+    virtual void SetDefaultParameters();    
+    TInt iNumberOfPhoneNumberFields;
+    TInt iNumberOfURLFields;
+    TInt iNumberOfEmailAddressFields;
+    TInt iContactsInGroup;    
+    TBool iDefaultFieldsSelected;
+};
+
+
+#endif /*__CCREATORPHONEBOOKBASE_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_randomdatafield.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef CREATORDATAFIELD_H_
+#define CREATORDATAFIELD_H_
+
+#include <e32base.h>
+
+class MCreatorRandomDataField
+{
+public:
+    enum TRandomLengthType
+    {
+    ERandomLengthUndefined,
+    ERandomLengthDefault, // Default length (use data from engine)
+    ERandomLengthMax,     // Maximum length
+    ERandomLengthExplicit // Explicitly defined length
+    };
+    
+    /**
+     * Set field content to random.     
+     * @param aRandomLenType Random length type
+     * @param aExplicitRandomLen Random length when ERandomLengthExplicit is used. Ignored otherwise.
+     */
+    virtual void SetRandomParametersL( TRandomLengthType aRandomLenType, TInt aRandomLen ) = 0;
+};
+
+#endif /*CREATORDATAFIELD_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_randomdataparser.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,130 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef CREATORRANDOMDATAPARSER_H_
+#define CREATORRANDOMDATAPARSER_H_
+
+#include <e32base.h>
+#include <badesca.h>
+#include <xml/contenthandler.h>
+#include <xml/parser.h>
+
+//using namespace Xml;
+
+class CCreatorRandomDataParser : public CBase, public Xml::MContentHandler
+	{
+
+public:
+    enum TRandomDataType
+    	{
+    	EFirstName,
+    	ESurname,
+    	ECompany,
+    	EAddress,
+    	EJobTitle,
+    	EPhoneNumber,
+    	EGroupName,
+    	EMeetingReason,
+    	EMeetingPlace,
+    	EMemoText,
+    	EAnniversaryReason,
+    	EToDoText,
+    	EReminderText,
+    	EMessageSubject,
+    	EMessageText,
+    	ECity,
+    	ECountry,
+    	EPostcode,
+    	EState,
+    	EPobox,
+    	EPrefix,
+    	ESuffix,
+    	ELandmarkName,
+    	ELandmarkDescription
+    	};
+
+public:
+
+    virtual ~CCreatorRandomDataParser();
+    static CCreatorRandomDataParser* NewL();
+    static CCreatorRandomDataParser* NewLC();    
+    CDesCArrayFlat* ParseL(const TDesC& aFileName, const TRandomDataType aDataType);
+    
+    TInt GetError() const;
+    
+private:
+
+    CCreatorRandomDataParser();
+    void ConstructL();
+    
+    /**
+     * Converts 8 bit descriptor to 16 bit descriptor
+     * @param aDes 8 bit descriptor to be converted
+     * @return Pointer to the new 16 bit descriptor     
+     */
+    HBufC* Convert8BitTo16BitLC(const TDesC8& aInput);
+    void GetTextFileMode(RFile& aFile, TInt& aFileSize);
+
+    
+public:
+    // From MContentHandler:    
+    void OnStartDocumentL(const Xml::RDocumentParameters &aDocParam, TInt aErrorCode);
+    void OnEndDocumentL(TInt aErrorCode);
+    void OnStartElementL(const Xml::RTagInfo& aElement, 
+                         const Xml::RAttributeArray& aAttributes, 
+                         TInt aErrorCode);
+    void OnEndElementL(const Xml::RTagInfo& aElement, TInt aErrorCode);
+    void OnContentL(const TDesC8& aBytes, TInt aErrorCode);
+    void OnStartPrefixMappingL(const RString& aPrefix, 
+                               const RString& aUri, 
+                               TInt aErrorCode);
+    void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode);
+    void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode);
+    void OnSkippedEntityL(const RString& aName, TInt aErrorCode);
+    void OnProcessingInstructionL(const TDesC8& aTarget, 
+                                  const TDesC8& aData, 
+                                  TInt aErrorCode);
+    void OnError(TInt aErrorCode);
+    TAny* GetExtendedInterface(const TInt32 aUid);
+    
+private:
+	TRandomDataType iDataType;
+	CDesCArray* iElementNameArray;
+	HBufC* iContentData;
+	TBool iInsideRootElement;
+	TBool iContentParsingActive;
+
+	CDesCArrayFlat* iResultArray;
+	
+    enum TFileFormat
+        {
+        EFormatANSIASCII,
+        EFormatUTF8,
+        EFormatUTF16LE,
+        EFormatUTF16BE
+        };
+    
+    // XML parser
+    Xml::CParser* iParser;
+    
+    TFileFormat iScriptTextFormat;
+    TInt iLastError;
+};
+
+#endif /*CREATORRANDOMDATAPARSER_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_scriptelement.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,349 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef CREATORSCRIPTELEMENT_H_
+#define CREATORSCRIPTELEMENT_H_
+
+#include "creator_randomdatafield.h"
+#include "creator_modulebase.h"
+#include "creator_model.h"
+#include <e32base.h>
+
+class CCreatorScriptElement;
+class CCreatorEngine;
+
+_LIT(KEmpty, "");
+_LIT(KContextSep, "::");
+
+// Common attributes:
+_LIT(KAmount, "amount");
+_LIT(KRandomLength, "randomlength");
+_LIT(KId, "id");
+_LIT(KMaxAmount, "maxamount");
+
+// Common element names:
+_LIT(KScript, "creatorscript");
+_LIT(KFields, "fields");
+_LIT(KContactSetRef, "contact-set-reference");
+_LIT(KExistingContacts, "numberofexistingcontacts");
+
+// Common attribute values:
+_LIT(KMax, "max");
+_LIT(KDefault, "default");
+_LIT(KIncrease, "incvalueforeachcopy");
+
+class CCreatorScriptElementCache : public CBase
+{
+public:
+    static CCreatorScriptElementCache* CCreatorScriptElementCache::NewL();
+    virtual ~CCreatorScriptElementCache();    
+        
+    void RemoveElements();    
+    void AddElementL(CCreatorScriptElement* aElement);
+private:
+    CCreatorScriptElementCache();
+    void ConstructL();
+    RPointerArray<CCreatorScriptElement> iElementCache;
+
+};
+
+
+class CCreatorScriptAttribute : public CBase
+{
+public:
+    static CCreatorScriptAttribute* NewL(const TDesC& aName, const TDesC& aValue);
+    static CCreatorScriptAttribute* NewLC(const TDesC& aName, const TDesC& aValue);
+    virtual ~CCreatorScriptAttribute();    
+    
+    TPtrC Name() const;
+    void SetNameL(const TDesC& aName);      
+    TPtrC Value() const;
+    void SetValueL(const TDesC& aValue);
+    
+protected:
+
+    CCreatorScriptAttribute();
+    virtual void ConstructL(const TDesC& aName, const TDesC& aValue);
+    
+private:
+    HBufC* iName;
+    HBufC* iValue;    
+};
+
+/**
+ * Base class for all elements
+ */
+class CCreatorScriptElement : public CBase
+{
+public:
+
+    static CCreatorScriptElement* CCreatorScriptElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC);
+
+    /**
+     * Destructor
+     */
+    virtual ~CCreatorScriptElement();
+    
+    /**
+     * Returns the array of sub-elements.
+     * @return Reference to the sub-element array.
+     */
+    virtual RPointerArray<CCreatorScriptElement> const& SubElements() const;
+    virtual RPointerArray<CCreatorScriptElement>& SubElements();
+    
+    /**
+     * Returns a sub-element.
+     * @param aIndex Sub-element array index.
+     * @return Pointer to a sub-element
+     */ 
+    virtual CCreatorScriptElement* SubElement(TInt aIndex);
+    
+    /**
+     * Finds a sub-element by a name.
+     * @param aName Name of the sub-element
+     * @return Pointer to the first matching sub-element. NULL if not found.
+     */
+    virtual CCreatorScriptElement* FindSubElement(const TDesC& aName);
+    
+    /**
+     * Removes all sub-elements.
+     */
+    virtual void RemoveSubElements();
+    
+    /**
+     * Removes a sub-element
+     * @param aIndex Index of the element to be removed
+     */
+    virtual void RemoveSubElementL(TInt aIndex);
+    
+    /**
+     * Adds an element to the sub-element list. 
+     * Leaves with error KErrNotSupported, if sub-element is illegal.
+     * Leaves with error KErrArgument, if the index in out of bounds.
+     * @param aElem Pointer to the element to be added. Takes ownership of the pointer.
+     * @param aIndex Sub-element array index where to add the element. -1 means that
+     * the element is added to the end of the array.
+     */
+    virtual void AddSubElementL(CCreatorScriptElement* aElem, TInt aIndex = -1);
+  
+    /**
+     * Returns the array of attributes.
+     * @return Reference to the attribute array.
+     */
+    virtual RPointerArray<CCreatorScriptAttribute> const& Attributes() const;
+        
+    /**
+     * Returns an attribute.
+     * @param aIndex Attribute array index.
+     * @return Pointer to a attribute
+     */ 
+    virtual CCreatorScriptAttribute* Attribute(TInt aIndex);
+    
+    /**
+     * Removes all attributes.
+     */
+    virtual void RemoveAttributes();
+    
+    /**
+     * Removes an attribute
+     * @param aIndex Index of the attribute to be removed
+     */
+    virtual void RemoveAttributeL(TInt aIndex);
+    
+    /**
+     * Adds an attribute to the attribute list. 
+     * Leaves with error KErrNotSupported, if attribute is illegal.
+     * @param aAttribute Pointer to the element to be added. Takes ownership of the pointer.
+     * @param aIndex Attribute array index where to add the attribute. -1 means that
+     * the attribute is added to the end of the array.
+     */
+    virtual void AddAttributeL(CCreatorScriptAttribute* aAttribute, TInt aIndex = -1);
+    
+    /**
+     * Finds attribute with the given name. First match is returned.
+     */
+    virtual const CCreatorScriptAttribute* FindAttributeByName(const TDesC& aName) const;
+    virtual CCreatorScriptAttribute* FindAttributeByName(const TDesC& aName);
+
+    /**
+     * Returns element name
+     * @return Element name
+     */
+    virtual TPtrC Name() const;
+    
+    /**
+     * Sets the element name.
+     * @param aName Element name
+     */
+    virtual void SetNameL(const TDesC& aName);
+    
+    /**
+     * Returns element content
+     * @return Element content
+     */
+    virtual TPtrC Content() const;
+    
+    /**
+     * Set the content of the element.
+     * @param aContenct Element content
+     */
+    virtual void SetContentL(const TDesC& aContent);
+    virtual void AppendContentL(const TDesC& aContent);
+    
+    /**
+     * Returns element context
+     * @return Element context
+     */
+    virtual TPtrC Context() const;
+        
+    /**
+     * Set the context of the element.
+     * @param aContenct Element context
+     */
+    virtual void SetContextL(const TDesC& aContext);
+    
+    /**
+     * Tells whether the element should be cached for future use.
+     * @return ETrue if the element should be cached for future use, EFalse otherwise.
+     */
+    virtual TBool IsCacheNeeded();
+    virtual void AddToCacheL(CCreatorScriptElementCache& aCache);
+    virtual void AddToCacheL();
+    virtual TBool IsCommandElement() const;
+    virtual void ExecuteCommandL();
+    //virtual void SaveCommandResultsL();
+    //virtual void DiscardCommandResultsL();
+    virtual TBool IsRoot() const;
+    virtual RPointerArray<CCreatorModuleBaseParameters>& CommandParameters();
+    virtual const RPointerArray<CCreatorModuleBaseParameters>& CommandParameters() const;
+    
+protected:
+
+    /**
+     * Constructors. 
+     */    
+    CCreatorScriptElement(CCreatorEngine* aEngine = 0);
+    
+    /**
+     * @param aName Name of the element.
+     */
+    virtual void ConstructL(const TDesC& aName, const TDesC& aContext = KNullDesC);
+    
+    /**
+     * Tells whethet the sub-element is allowed or not.
+     * @param aElem Sub-element to be tested.
+     * @return Boolean value telling whether the sub-element is allowed 
+     * to be added or not.
+     */
+    virtual TBool IsSubElementSupported(const CCreatorScriptElement& aElem) const;
+    
+    virtual MCreatorRandomDataField::TRandomLengthType ResolveRandomDataTypeL(const CCreatorScriptAttribute& aAttr, TInt& aRandomLen ) const;
+    
+    virtual TBool ConvertStrToBooleanL(const TDesC& aStr) const;
+    virtual TInt ConvertStrToIntL(const TDesC& aStr) const;
+    virtual TUint ConvertStrToUintL(const TDesC& aStr) const;
+    virtual void ConvertStrToReal64L(const TDesC& aStr, TReal64& aVal) const;
+    virtual void ConvertStrToReal32L(const TDesC& aStr, TReal32& aVal) const;
+    
+    virtual void AppendContactSetReferenceL(const CCreatorScriptElement& aContactSetRefElem, RArray<TLinkIdParam>& aLinkArray ) const;    
+    
+    virtual void SetContentToTextParamL(HBufC*& aPtr, const TDesC& aContent );
+    
+    virtual TTime ConvertToDateTimeL(const TDesC& aDtStr) const;
+    
+    virtual TInt CompareIgnoreCase(const TDesC& aStr1, const TDesC& aStr2 ) const;
+    
+    /**
+     * Increases phonenumber by aDelta.
+     * 
+     * Special cases, that are handled:
+     * +9          -> +9, +10, +11...
+     * +3584098#99 -> +3584098#99, +3584098#100, +3584098#101...
+     * #           -> #0, #1, #2...
+     * 123#        -> 123#0, 123#1, 123#2...
+     * 099         -> 099, 100, 101...
+     * 
+     * @param aOriginal original phonenumber
+     * @param aDelta number to be added to original number. Must be >= 0.
+     * @param aIncreased on return contains the increased number.
+     *        The buffer must be allocated by the caller.
+     */
+    void IncreasePhoneNumL( const TDesC& aOriginal, TInt aDelta, HBufC* aIncreased ) const;
+    
+protected:
+    
+    // Sub-element array
+    RPointerArray<CCreatorScriptElement> iSubElements;
+    // Attribute array
+    RPointerArray<CCreatorScriptAttribute> iAttributes;
+    // Element name (e.g. "contact")
+    HBufC* iName;
+    // Element content
+    HBufC* iContent;
+    // Context
+    HBufC* iContext;
+    
+    TBool iIsCommandElement;
+    TBool iIsRoot;
+    CCreatorEngine* iEngine;
+    RPointerArray<CCreatorModuleBaseParameters> iParameters;
+};
+
+/**
+ * Script element
+ */
+class CCreatorScriptRoot : public CCreatorScriptElement
+{
+public:
+    static CCreatorScriptRoot* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC);
+protected:
+    CCreatorScriptRoot(CCreatorEngine* aEngine);
+};
+
+/**
+ * Calendar elements
+ */
+
+/**
+ * Base class for calendar elements
+ */
+class CCreatorCalendarElementBase : public CCreatorScriptElement
+{
+public:
+    static CCreatorCalendarElementBase* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC);
+protected:
+    CCreatorCalendarElementBase(CCreatorEngine* aEngine);
+};
+
+/**
+ * Message elements
+ */
+
+/**
+ * Base class for message elements
+ */
+class CCreatorMessageElementBase : public CCreatorScriptElement
+{
+public:
+    static CCreatorMessageElementBase* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC);
+protected:
+    CCreatorMessageElementBase(CCreatorEngine* aEngine);
+};
+
+#endif /*CREATORSCRIPTELEMENT_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_scriptelementfactory.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef CREATORSCRIPTELEMENTFACTORY_H_
+#define CREATORSCRIPTELEMENTFACTORY_H_
+
+#include "creator_scriptelement.h"
+
+/**
+ * Creates script element instance based on the element name and context.
+ */
+class TCreatorScriptElementFactory
+{
+public:
+    static CCreatorScriptElement* CreateElementL(CCreatorEngine* aEngine, const TDesC& aElementName, const TDesC& aContext = KNullDesC);
+};
+
+#endif /*CREATORSCRIPTELEMENTFACTORY_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_scriptentry.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,85 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef __FILEUTILS_H__
+#define __FILEUTILS_H__
+
+
+#include "creator_model.h"
+
+#include <e32base.h>
+#include <f32file.h>
+#include <badesca.h>
+#include <AknGlobalNote.h>
+#include <AknIconArray.h> 
+#include <aknmemorycardui.mbg>
+#include <msvapi.h>
+
+
+class CCreatorEngine;
+
+class CreatorFileUtils
+{
+public:
+    static TInt FindFiles(CDesCArrayFlat* aFileArray, const TDesC& aFileName, const TDesC& aPath);
+    static TInt FindFilesRecursiveL(CDesCArrayFlat* aFileArray, const TDesC& aFileName, const TDesC& aPath);
+};
+
+class CCommandParser : public CBase, public MMsvSessionObserver
+    {
+public:
+    static CCommandParser* NewL(CCreatorEngine* aEngine);
+    static CCommandParser* NewLC(CCreatorEngine* aEngine);
+    ~CCommandParser();
+    
+    void StrParserL(HBufC*& aDestinationBuf, TUint aToken);
+    void StrParserL(HBufC8*& aDestinationBuf, TUint aToken);
+
+private:
+    CCommandParser();
+    void ConstructL(CCreatorEngine* aEngine);
+
+    TInt FindFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath);
+    TInt FindFiles(const TDesC& aFileName, const TDesC& aPath);
+    TInt ReadLineFromFileL(RFile& aInputFile);    
+    //void ParseCommandFromDescriptorL();
+
+    void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); // from MMsvSessionObserver
+
+public:
+    void OpenScriptL();
+    TBool OpenScriptL(RFile& aScriptFile);
+    TBool GetRandomDataFilenameL(TDes& aFilename);
+
+private:
+    CCreatorEngine* iEngine;
+    CDesCArrayFlat* iSearchArray;
+
+    TInt iParserPosition;
+    TInt iParserOldPosition;
+
+    HBufC8* iReadBuf;
+
+    };
+
+
+
+#endif // __FILEUTILS_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_scriptparser.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,139 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef CREATORSCRIPTPARSER_H_
+#define CREATORSCRIPTPARSER_H_
+
+#include <e32base.h>
+#include <xml/contenthandler.h>
+#include <xml/parser.h>
+
+using namespace Xml;
+
+class CCreatorScriptElement;
+class CCreatorEngine;
+class CCreatorScriptElementCache;
+
+class TCreatorScriptElementInfo
+{
+public:
+    enum TElementStatus
+    {
+    EStatusUndefined,   // undefined
+    EStatusParsing,     // currently being parsed
+    EStatusParsed       // parsed
+    };
+    TCreatorScriptElementInfo()
+        {
+        iStatus = EStatusUndefined;
+        iElement = 0;
+        }
+    TCreatorScriptElementInfo(TElementStatus aStatus, CCreatorScriptElement* aElement)
+        {
+        iStatus = aStatus;
+        iElement = aElement;
+        };
+    
+    TElementStatus iStatus;    
+    CCreatorScriptElement* iElement;
+};
+
+class CCreatorScriptParser : public CBase, public MContentHandler
+{
+public:
+
+    virtual ~CCreatorScriptParser();
+    static CCreatorScriptParser* NewL(CCreatorEngine* aEngine);
+    static CCreatorScriptParser* NewLC(CCreatorEngine* aEngine);    
+    void ParseL(const TDesC& aFileName);
+    void ParseL(RFile& aFile);
+    
+    TInt GetError() const;
+    
+private:
+
+    CCreatorScriptParser();
+    void ConstructL(CCreatorEngine* aEngine);
+    
+    /**
+     * Converts 8 bit descriptor to 16 bit descriptor
+     * @param aDes 8 bit descriptor to be converted
+     * @return Pointer to the new 16 bit descriptor     
+     */
+    HBufC* Convert8BitTo16BitLC(const TDesC8& aInput);
+    const TCreatorScriptElementInfo& LastElementInfo() const;
+    void GetTextFileMode(RFile& aFile, TInt& aFileSize);
+
+    
+public:
+    // From MContentHandler:    
+    void OnStartDocumentL(const RDocumentParameters &aDocParam, TInt aErrorCode);
+    void OnEndDocumentL(TInt aErrorCode);
+    void OnStartElementL(   const RTagInfo& aElement, 
+                            const RAttributeArray& aAttributes, 
+                            TInt aErrorCode);
+    void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode);
+    void OnContentL(const TDesC8& aBytes, TInt aErrorCode);
+    void OnStartPrefixMappingL( const RString& aPrefix, 
+                                const RString& aUri, 
+                                TInt aErrorCode);
+    void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode);
+    void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode);
+    void OnSkippedEntityL(const RString& aName, TInt aErrorCode);
+    void OnProcessingInstructionL(  const TDesC8& aTarget, 
+                                    const TDesC8& aData, 
+                                    TInt aErrorCode);
+    void OnError(TInt aErrorCode);
+    TAny* GetExtendedInterface(const TInt32 aUid);
+    
+private:
+
+    enum TFileFormat
+        {
+        EFormatANSIASCII,
+        EFormatUTF8,
+        EFormatUTF16LE,
+        EFormatUTF16BE
+        };
+    // XML parser
+    CParser* iParser;
+    
+    /**
+     * Element stack holding the elements that are currently being parsed.
+     */
+    RArray<TCreatorScriptElementInfo> iElementStack;
+    
+    /**
+     * Cache object containig the elements that are referred in future and thus should
+     * not be deleted after parsing.
+     */
+    CCreatorScriptElementCache* iElementCache;
+    
+    /**
+     * Pointer to the engine
+     */
+    CCreatorEngine* iEngine;
+    
+    TCreatorScriptElementInfo iDefaultElement;
+    
+    TFileFormat iScriptTextFormat;
+    TInt iLastError;
+};
+
+#endif /*CREATORSCRIPTPARSER_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_std.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef __CREATOR_STD_H__
+#define __CREATOR_STD_H__
+
+#include <e32base.h>
+
+class TCommand;
+typedef CArrayFixSeg<TCommand> CCommandArray;
+
+
+#endif // __CREATOR_STD_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_traces.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,106 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef __CREATOR_TRACES_H__
+#define __CREATOR_TRACES_H__
+
+#include <e32def.h>
+
+
+// ---------------------------------------------------------------------------
+// You change these logging method values below! Recompile the application to take changes effect.
+
+    // logging methods
+    // 0 = No logging
+    // 1 = Flogger
+    // 2 = RDebug
+    // 3 = Flogger and RDebug
+    
+    #ifndef _DEBUG
+        
+        // Logging method for UREL builds:
+        #define CREATOR_LOGGING_METHOD  3
+
+    #else
+
+        // Logging method for UDEB builds:
+        #define CREATOR_LOGGING_METHOD  3
+
+    #endif    
+    
+
+
+// ---------------------------------------------------------------------------
+// Do not make any changes to lines below...
+
+    #if CREATOR_LOGGING_METHOD == 1 || CREATOR_LOGGING_METHOD == 3
+
+        #include <flogger.h>
+        _LIT(KLogFolder,"Creator");
+        _LIT(KLogFile,"Creator_Trace.txt");
+
+    #endif
+
+    #if CREATOR_LOGGING_METHOD == 2 || CREATOR_LOGGING_METHOD == 3
+
+        #include <e32debug.h>
+
+    #endif
+
+
+    #if CREATOR_LOGGING_METHOD == 0
+    
+        #define LOGTEXT(AAA)
+        #define LOGSTRING(AAA)
+        #define LOGSTRING2(AAA,BBB)
+        #define LOGSTRING3(AAA,BBB,CCC)
+        #define LOGSTRING4(AAA,BBB,CCC,DDD)
+    
+    
+    #elif CREATOR_LOGGING_METHOD == 1
+    
+        #define LOGTEXT(AAA)                RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend, AAA)
+        #define LOGSTRING(AAA)              do { _LIT(tempLogDes,AAA); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0)
+        #define LOGSTRING2(AAA,BBB)         do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB); } while (0)
+        #define LOGSTRING3(AAA,BBB,CCC)     do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB,CCC); } while (0)
+        #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB,CCC,DDD); } while (0)
+   
+    #elif CREATOR_LOGGING_METHOD == 2
+    
+        #define LOGTEXT(AAA)                RDebug::Print(AAA)
+        #define LOGSTRING(AAA)              do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); } while (0)
+        #define LOGSTRING2(AAA,BBB)         do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); } while (0)
+        #define LOGSTRING3(AAA,BBB,CCC)     do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); } while (0)
+        #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); } while (0)
+    
+    #elif CREATOR_LOGGING_METHOD == 3
+    
+        #define LOGTEXT(AAA)                RDebug::Print(AAA); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend, AAA)
+        #define LOGSTRING(AAA)              do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0)
+        #define LOGSTRING2(AAA,BBB)         do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB); } while (0)
+        #define LOGSTRING3(AAA,BBB,CCC)     do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB,CCC); } while (0)
+        #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB,CCC,DDD); } while (0)
+
+    #endif
+
+// ---------------------------------------------------------------------------
+
+#endif // __LAUNCHER_TRACES_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_virtualphonebook.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,300 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef __CREATORVIRTUALPHONEBOOK_H__
+#define __CREATORVIRTUALPHONEBOOK_H__
+
+#include "creator_model.h"
+#include "creator_phonebookbase.h"
+#include "creator_randomdatafield.h"
+
+#include <e32base.h>
+#include <cntdef.h>
+#include <cntdb.h>
+#include <cntitem.h>
+#include <cntfldst.h>
+#include <cntview.h>
+#include <CVPbkContactManager.h>
+#include <PbkFields.hrh>
+#include <CPbk2ImageManager.h>
+#include <MVPbkContactStoreListObserver.h>
+#include <MVPbkBatchOperationObserver.h>
+#include <MVPbkContactFindObserver.h>
+#include <MVPbkContactObserver.h>
+#include <MPbk2ImageOperationObservers.h>
+#include <VPbkEng.rsg>
+#include <CVPbkContactLinkArray.h>
+#include <MVPbkContactViewObserver.h>
+
+class CCreatorEngine;
+class CCreatorModuleBaseParameters;
+
+class MVPbkStoreContact;
+class MVPbkContactStore;
+class CAsyncWaiter;
+class CContactDatabase;
+class MVPbkContactLinkArray;
+class CVirtualPhonebookParameters;
+
+
+class CCreatorVirtualPhonebook : public CCreatorPhonebookBase,  
+	public MVPbkContactStoreListObserver, public MVPbkBatchOperationObserver,
+	public MVPbkContactFindObserver, public MVPbkContactObserver, public MPbk2ImageSetObserver,
+	public MVPbkSingleContactOperationObserver, public MVPbkContactViewObserver
+    {
+public: 
+    static CCreatorVirtualPhonebook* NewL(CCreatorEngine* aEngine);
+    static CCreatorVirtualPhonebook* NewLC(CCreatorEngine* aEngine);
+    ~CCreatorVirtualPhonebook();
+
+private:
+    CCreatorVirtualPhonebook();
+    void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase
+
+public:  
+    virtual TBool AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries);
+    TInt CreateContactEntryL(CCreatorModuleBaseParameters *aParameters);    
+    TInt CreateGroupEntryL(CCreatorModuleBaseParameters *aParameters);
+    TInt CreateSubscribedContactEntryL(CCreatorModuleBaseParameters *aParameters); 
+
+    void AddFieldToContactItemL(MVPbkStoreContact& aItem, TPbkFieldId aFieldId, const TDesC& aFieldText);
+    void AddFieldToContactItemL(MVPbkStoreContact& aItem, TPbkFieldId aFieldId, const TDesC8& aFieldText);
+    void AddFieldToContactItemL(MVPbkStoreContact& aItem, TPbkFieldId aFieldId, const TTime& aFieldText);
+    
+    void AddImageToContactL(MVPbkStoreContact& aContact, TInt aFieldResId, const TDesC& aFileName);
+    TBool IsActive();
+    void CancelOperation();
+    void DeleteAllL();
+    void DeleteAllCreatedByCreatorL();
+    void DeleteAllGroupsL();
+    void DeleteAllGroupsCreatedByCreatorL();
+    
+private:
+    void CompactPbkDatabaseL(TBool aCompressImmediately=EFalse);    
+    void AddFieldToParamsL(TInt aFieldType, const TDesC& aData);
+    void AddFieldToParamsL(TInt aFieldType, const TDesC8& aData);
+    void AddFieldToParamsL(TInt aFieldType, const TTime& aData);    
+    void InitializeContactParamsL(/*CCreatorModuleBaseParameters* aParameters*/);
+    TBool IsContactGroupL(const MVPbkContactLink& aLink);
+    void StoreLinksForDeleteL( MVPbkContactLinkArray& aLinks, TUid aStoreUid );
+    void DeleteContactsL( MVPbkContactLinkArray* aContacts, TBool aGroup );
+    void DeleteItemsCreatedWithCreatorL( TUid aStoreUid );
+    void DoDeleteItemsCreatedWithCreatorL( TUid aStoreUid, CDictionaryFileStore* aStore );
+    TBool HasOtherThanGroupsL( MVPbkContactLinkArray* aContacts );
+
+public: // MVPbkSingleContactOperationObserver
+    
+    void VPbkSingleContactOperationComplete(
+                    MVPbkContactOperationBase& aOperation,
+                    MVPbkStoreContact* aContact );
+    void VPbkSingleContactOperationFailed(
+                    MVPbkContactOperationBase& aOperation, 
+                    TInt aError );
+
+private: // MVPbkContactViewObserver
+    
+    void ContactViewReady( MVPbkContactViewBase& aView );
+    void ContactViewUnavailable(
+            MVPbkContactViewBase& aView );
+    void ContactAddedToView(
+            MVPbkContactViewBase& aView, 
+            TInt aIndex, 
+            const MVPbkContactLink& aContactLink );
+    void ContactRemovedFromView(
+            MVPbkContactViewBase& aView, 
+            TInt aIndex, 
+            const MVPbkContactLink& aContactLink );
+    void ContactViewError(
+            MVPbkContactViewBase& aView, 
+            TInt aError, 
+            TBool aErrorNotified );
+
+private:
+	CVPbkContactManager* iContactManager;
+    TInt iOpCounter;
+
+    CVirtualPhonebookParameters* iParameters;
+    
+    static TInt iPhoneNumberFields[];
+    static TInt iUrlFields[];
+    static TInt iEmailFields[];
+    TBool iAddAllFields;
+    CVPbkContactLinkArray* iContactLinkArray;
+    CVPbkContactLinkArray* iContactsToDelete;
+    CVPbkContactLinkArray* iContactGroupsToDelete;
+    RPointerArray<MVPbkContactLinkArray> iPreviousDeleteLinks;   
+    
+private:
+	//new variables
+	/// Ref: the target of the copy
+	MVPbkContactStore* iStore;
+    
+    CAsyncWaiter* iWaiter;	
+    
+    /// Own: Contact database for this store
+    CContactDatabase* iContactDb;    
+    
+    //Contacts found in contacts db.
+    MVPbkContactLinkArray* iContactResults;
+    // Contact groups that are found in the store. These are used in filtering
+    // the groups from the find results.
+    MVPbkContactLinkArray* iContactGroupsInStore;
+    
+    // Phonebook asynchronous operation
+    MVPbkContactOperationBase* iOperation;
+    
+    // Flag to indicate whether it is required to notify
+    // iEngine after operation is complete. This happens
+    // when user has cancelled the operation during 
+    // iOperation exists.
+    TBool iCancelCbRequested;
+    
+    TInt iLastError;
+
+public:
+	//Observer implentation from MVPbkContactStoreListObserver
+	void OpenComplete();
+
+	//observer implentation from MVPbkContactStoreObserver
+
+	void StoreReady(MVPbkContactStore& aContactStore);
+
+	void StoreUnavailable(MVPbkContactStore& aContactStore, 
+	        TInt aReason);
+
+	void HandleStoreEventL(
+	        MVPbkContactStore& aContactStore, 
+	        TVPbkContactStoreEvent aStoreEvent);
+
+	 TAny* ContactStoreObserverExtension(TUid aExtensionUid); 
+	        	
+	
+
+    
+    
+public:
+	//Observer implementation for MVPbkBatchOperationObserver
+
+	void StepComplete( 
+	        MVPbkContactOperationBase& aOperation,
+	        TInt aStepSize );
+	
+	TBool StepFailed(
+	        MVPbkContactOperationBase& aOperation,
+	        TInt aStepSize, TInt aError );
+	
+	void OperationComplete( 
+	        MVPbkContactOperationBase& aOperation );
+	
+	TAny* BatchOperationObserverExtension( 
+	        TUid aExtensionUid ) ;
+
+	
+	//--------------------------------------------
+	//Observer implementation for MVPbkContactFindObserver
+	public: // Interface
+
+	        void FindCompleteL( MVPbkContactLinkArray* aResults );
+
+	        void FindFailed( TInt aError );
+
+	        TAny* ContactFindObserverExtension( 
+	                TUid aExtensionUid );	
+	
+	
+	
+   	//--------------------------------------------
+   	//Observer implementation for MVPbkContactObserver
+
+	public:
+		void ContactOperationCompleted(TContactOpResult aResult);
+	
+		void ContactOperationFailed
+			(TContactOp aOpCode, TInt aErrorCode, TBool aErrorNotified);
+	
+	    TAny* ContactObserverExtension(TUid aExtensionUid) ;
+	     //~MVPbkContactObserver();	        
+	        
+	//--------------------------------------------
+	// Implementation of MPbk2ImageSetObserver:
+	public:
+	    void Pbk2ImageSetComplete(MPbk2ImageOperation& aOperation);
+	    void Pbk2ImageSetFailed(MPbk2ImageOperation& aOperation, TInt aError );	        
+    };
+
+class CCreatorContactFieldImpl;
+class CCreatorContactField : public CBase, public MCreatorRandomDataField
+    {
+public:    
+    static CCreatorContactField* NewL(TInt aFieldType, const TDesC& aData);
+    static CCreatorContactField* NewL(TInt aFieldType, const TDesC8& aData);
+    static CCreatorContactField* NewL(TInt aFieldType, const TTime& aData);
+    
+    static CCreatorContactField* NewL(TInt aFieldType, TRandomLengthType aRandomLenType, TInt aRandomLen);
+    
+    ~CCreatorContactField();    
+    TInt FieldType();
+    virtual void AddToContactL(CCreatorEngine* aEngine, MVPbkStoreContact& aContact, CCreatorVirtualPhonebook* aVPbk);
+    virtual void SetRandomParametersL(  MCreatorRandomDataField::TRandomLengthType aRandomLenType = MCreatorRandomDataField::ERandomLengthDefault, 
+                                TInt aRandomLen = 0 );
+    virtual void ParseL(CCommandParser* parser);
+    
+private:    
+    CCreatorContactField();
+    void ConstructL(TInt aFieldType, const TDesC& aData);
+    void ConstructL(TInt aFieldType, const TDesC8& aData);
+    void ConstructL(TInt aFieldType, const TTime& aData);
+    CCreatorContactFieldImpl* pImpl;    
+    };
+    
+    
+/**
+ * Virtual phonebook parameters
+ */
+    
+
+class CVirtualPhonebookParameters : public CCreatorModuleBaseParameters
+    {
+public:
+	void ParseL(CCommandParser* parser, TParseParams /*aCase = 0*/);
+	
+	TInt CVirtualPhonebookParameters::ScriptLinkId() const;
+	void CVirtualPhonebookParameters::SetScriptLinkId(TInt aLinkId);
+	RPointerArray<CCreatorContactField> iContactFields;
+
+    HBufC*  iGroupName;
+    TInt    iContactsInGroup;
+    TInt iNumberOfPhoneNumberFields;
+    TInt iNumberOfURLFields;
+    TInt iNumberOfEmailAddressFields;
+    TInt iContactSetPtr;
+    RArray<TLinkIdParam> iLinkIds; // For contactgroup. Stores the linked contact ids.
+    
+public:
+    CVirtualPhonebookParameters();
+    ~CVirtualPhonebookParameters();
+    
+private:
+    TInt iLinkId; // For contact. Stores the contact id
+    };
+
+
+
+#endif // __CREATORVIRTUALPHONEBOOK_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/inc/creator_wepsecuritysettings.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,142 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef CREATORWEPSECURITYSETTINGS_H_
+#define CREATORWEPSECURITYSETTINGS_H_
+
+//
+// Methods copied from WEPSecuritySettingsImpl.h 
+// (Part of  : WEP Security Settings UI)
+// @see \s60\mw\networking\networkingutilities\WEPSecuritySettingsUI\inc\WEPSecuritySettingsImpl.h
+//
+
+
+// INCLUDES
+
+//#include "creator_model.h"
+
+#include <e32base.h>
+#include <metadatabase.h>
+using namespace CommsDat;
+
+// FORWARD DECLARATIONS
+
+class CCommsDatabase;
+
+// Index of first key
+const TInt KFirstKey = 0;
+
+// Index of second key
+const TInt KSecondKey = 1;
+
+// Index of third key
+const TInt KThirdKey = 2;
+
+// Index of fourth key
+const TInt KFourthKey = 3;
+
+const TInt KMaxNumberofKeys = 4;
+
+// Number of characters for a 232 bits key
+const TUint KKeyDataLength232Bits = 58;
+
+// The maximum length of key data
+const TUint KMaxLengthOfKeyData = KKeyDataLength232Bits;
+
+
+
+
+class CCreatorWEPSecuritySettings : public CBase
+    {
+public: 
+    static CCreatorWEPSecuritySettings* NewL();
+    static CCreatorWEPSecuritySettings* NewLC();
+    ~CCreatorWEPSecuritySettings();
+
+private:
+    CCreatorWEPSecuritySettings();
+    void ConstructL(); // from MCreatorModuleBase
+
+
+public:
+/**
+* Save to database.
+* @param aIapId Wlan Service Table Id of the IAP to be saved
+* @param aCommsDb Comms database.
+*/
+void SaveL( TUint32 aIapId, CCommsDatabase& aCommsDb ) const;
+
+public:
+// Enumeration of the possible keys in use
+enum TWEPKeyInUse
+    {
+    EKeyNumber1,            // Key number 1
+    EKeyNumber2,            // Key number 2
+    EKeyNumber3,            // Key number 3
+    EKeyNumber4             // Key number 4
+    };
+
+
+// Enumeration of the possible authentication types
+enum TWEPAuthentication
+    {
+    EAuthOpen,              // Open authentication
+    EAuthShared             // Shared authentication
+    };
+
+
+// Possible lengths of the keys
+enum TWEPKeyLength
+    {
+    E40Bits,                // 40 bits
+    E104Bits,               // 104 bits
+    E232Bits                // 232 bits
+    };
+
+
+// Possible formats of the keys
+enum TWEPKeyFormat
+    {
+    EAscii,                 // Ascii format
+    EHexadecimal            // Hex format
+    };
+    
+    
+
+private:
+
+// Index of the key currently in use (EKeyNumber1, EKeyNumber2, 
+// EKeyNumber3, EKeyNumber4
+CCreatorWEPSecuritySettings::TWEPKeyInUse iKeyInUse;
+
+// Type of authentication (EAuthOpen, EAuthShared)
+CCreatorWEPSecuritySettings::TWEPAuthentication iAuthentication;
+
+// Length of the key (E40Bits, E104Bits, E232Bits)
+CCreatorWEPSecuritySettings::TWEPKeyLength iKeyLength[KMaxNumberofKeys];
+
+// Format of the key (EAscii, EHexadecimal)
+CCreatorWEPSecuritySettings::TWEPKeyFormat iKeyFormat[KMaxNumberofKeys];
+
+
+    };
+
+
+
+#endif /*CREATORWEPSECURITYSETTINGS_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/rom/creator.iby	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef __CREATOR_IBY__
+#define __CREATOR_IBY__
+
+S60_APP_EXE(Creator)
+S60_APP_AIF_ICONS(Creator)
+S60_APP_RESOURCE(Creator)
+#ifdef S60_UPGRADABLE_APP_REG_RSC
+  S60_UPGRADABLE_APP_REG_RSC(Creator)
+#else
+  S60_APP_AIF_RSC(Creator)
+#endif
+
+data=ZPRIVATE\20011383\backup_registration.xml        	private\20011383\backup_registration.xml
+data=ZSYSTEM\Install\Creator_stub.sis                   \system\install\Creator_stub.sis
+
+// test files (remove largest files if running out of ROM space):
+data=ZPRIVATE\20011383\3GPP-70kB.3gpp                   private\20011383\3GPP-70kB.3gpp
+data=ZPRIVATE\20011383\AAC-100kB.aac                    private\20011383\AAC-100kB.aac
+data=ZPRIVATE\20011383\AMR-20kB.amr                     private\20011383\AMR-20kB.amr
+data=ZPRIVATE\20011383\Deck-1kB.saveddeck               private\20011383\Deck-1kB.saveddeck
+data=ZPRIVATE\20011383\DOC-20kB.doc                     private\20011383\DOC-20kB.doc
+data=ZPRIVATE\20011383\HTML-20kB.html                   private\20011383\HTML-20kB.html
+data=ZPRIVATE\20011383\JAD-1kB.jad                      private\20011383\JAD-1kB.jad
+data=ZPRIVATE\20011383\JAR-10kB.jar                     private\20011383\JAR-10kB.jar
+data=ZPRIVATE\20011383\JP2-65kB.jp2                     private\20011383\JP2-65kB.jp2
+data=ZPRIVATE\20011383\MIDI-10kB.mid                    private\20011383\MIDI-10kB.mid
+data=ZPRIVATE\20011383\MP3-250kB.mp3                    private\20011383\MP3-250kB.mp3
+data=ZPRIVATE\20011383\MP4-200kB.mp4                    private\20011383\MP4-200kB.mp4
+data=ZPRIVATE\20011383\MXMF-40kB.mxmf                   private\20011383\MXMF-40kB.mxmf
+data=ZPRIVATE\20011383\PNG-15kB.png                     private\20011383\PNG-15kB.png
+data=ZPRIVATE\20011383\PPT-40kB.ppt                     private\20011383\PPT-40kB.ppt
+data=ZPRIVATE\20011383\RAM-1kB.ram                      private\20011383\RAM-1kB.ram
+data=ZPRIVATE\20011383\RM-95kB.rm                       private\20011383\RM-95kB.rm
+data=ZPRIVATE\20011383\RNG-1kB.rng                      private\20011383\RNG-1kB.rng
+data=ZPRIVATE\20011383\SVG-15kB.svg                     private\20011383\SVG-15kB.svg
+data=ZPRIVATE\20011383\SWF-15kB.swf                     private\20011383\SWF-15kB.swf
+data=ZPRIVATE\20011383\TIF-25kB.tif                     private\20011383\TIF-25kB.tif
+data=ZPRIVATE\20011383\VCF-1kB.vcf                      private\20011383\VCF-1kB.vcf
+data=ZPRIVATE\20011383\VCS-1kB.vcs                      private\20011383\VCS-1kB.vcs
+data=ZPRIVATE\20011383\WAV-20kB.wav                     private\20011383\WAV-20kB.wav
+data=ZPRIVATE\20011383\XLS-15kB.xls                     private\20011383\XLS-15kB.xls
+data=ZPRIVATE\20011383\SISX-10kB.sisx                   private\20011383\SISX-10kB.sisx
+data=ZPRIVATE\20011383\WMA-50kB.wma                     private\20011383\WMA-50kB.wma
+data=ZPRIVATE\20011383\WMV-200kB.wmv                    private\20011383\WMV-200kB.wmv
+
+#endif // __CREATOR_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/scripts/browserEx.creatorxml	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<creatorscript schemaVersion="1.0" scriptVersion="1.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:noNamespaceSchemaLocation="creator.xsd">
+
+<!-- Create bookmark -->
+<bookmark>
+   <fields>
+    <name>Creator bookmark</name>
+    <url>http://example.net</url>
+    <username>User</username>
+    <password>passwd</password>
+  </fields>
+</bookmark>
+
+<!-- Create 5 random bookmarks -->
+<bookmark amount="5">
+   <fields>
+        <name randomlength="default"/>
+        <url randomlength="default"/>
+        <username randomlength="default"/>
+        <password randomlength="default"/>
+   </fields>
+</bookmark>
+
+<!-- Create bookmark folder -->
+<bookmarkfolder>
+   <fields>
+       <name>Creator bookmarks</name>
+   </fields>
+</bookmarkfolder>
+
+<!-- Create saved page folder -->
+<savedpagefolder>
+    <fields>
+       <name>Creator saved pages</name>
+    </fields>
+</savedpagefolder>
+
+<!-- Create saved page -->
+<savedpage>
+    <fields>
+       <name>Creator saved page</name>
+       <path randomlength="default"/>
+    </fields>
+</savedpage>
+
+</creatorscript>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/scripts/calendarEx.creatorxml	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,103 @@
+<?xml version="1.0" standalone="yes" ?>
+<creatorscript schemaVersion="1.0" scriptVersion="1.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:noNamespaceSchemaLocation="creator.xsd">
+
+<!-- Contact set with existing contacts -->
+<contact-set id="1" numberofexistingcontacts="10">
+</contact-set>
+
+<!-- Create an appointment with 5 attendees. Two of the attendees are selected from the contacts -->
+<!-- and two of the attendees are randomly generated. One contact explicitly given. -->
+<calendar type="appointment">
+   <fields>
+   <summary>Project meeting</summary>
+   <description>Let's have a bi-weekly project meeting. Welcome everyone!</description>
+   <location>Meeting room 1</location>
+   <starttime>2008-03-27T13:02:57</starttime>
+   <endtime>2008-03-27T16:15:00</endtime>
+   <recurrentfrequency>weekly</recurrentfrequency>
+   <recurrentinterval>2</recurrentinterval>
+   <recurrentfrom>2008-03-27</recurrentfrom>   
+   <recurrentto>2009-03-27</recurrentto>
+   <attendees>
+      <!-- Two existing contacts -->
+   	  <contact-set-reference id="1" maxamount="2"/>
+      <attendee>
+         <commonname>John Doe</commonname>
+         <email>john.doe@example.net</email>
+      </attendee>
+      <attendee>
+         <commonname/>
+         <email/>
+      </attendee>
+      <attendee>
+         <commonname/>
+         <email/>
+      </attendee>
+   </attendees>
+   </fields>  
+</calendar>
+
+<!-- Contact set with 5 contacts having first name "Jane" -->
+<contact-set id="2">
+    <contact amount="5">
+        <fields>
+            <firstname>Jane</firstname>
+            <lastname/>
+            <emailwork/>
+            <mobilephonework/>
+        </fields>
+    </contact>
+</contact-set>
+
+<!-- Create an appointment having "Jane" as an attendee (random location) -->
+<calendar type="appointment">
+   <fields>
+   <summary>Appointment with Jane</summary>
+   <starttime>2008-02-29T14:00:00</starttime>
+   <endtime>2008-02-29T15:00:00</endtime>
+   <location/>
+   <attendees>      
+      <contact-set-reference id="2" maxamount="1"/>      
+   </attendees>
+   </fields>
+</calendar>
+
+<!-- Create an event -->
+<calendar type="event">
+   <fields>
+   <summary>Tech Days</summary>
+   <description>Annual tech days, let's have fun!</description>
+   <starttime>2008-05-01</starttime>
+   <endtime>2008-05-03</endtime>
+   </fields>
+</calendar>
+
+<!-- Create a reminder -->
+<calendar type="reminder">
+  <fields>
+  <summary>Remember to buy Lotto!</summary>
+  <starttime>2008-02-28T18:00:00</starttime>
+  <endtime>2008-02-28T18:00:00</endtime>
+  </fields>
+</calendar>
+
+<!-- Create 10 random anniversaries -->
+<calendar type="anniversary" amount="10">
+  <fields>
+  <summary/>
+  <starttime/>
+  </fields>
+</calendar>
+
+<!-- Create a to-do entry -->
+<calendar type="todo">
+  <fields>
+     <summary>Should do something...?</summary>
+     <starttime>2008-02-29T10:00:00</starttime>
+     <endtime>2008-02-29T12:00:00</endtime>
+  </fields>
+</calendar>
+
+</creatorscript>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/scripts/connectionmethodEx.creatorxml	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<creatorscript schemaVersion="1.0" scriptVersion="1.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:noNamespaceSchemaLocation="creator.xsd">
+
+<connectionmethod>
+  <fields>
+    <connectionname>CR_Example</connectionname>
+    <bearertype>GPRS</bearertype>
+    <startpage>http://wap.example.net</startpage>
+    <wapwspoption>connectionoriented</wapwspoption>
+    <protocoltype>ipv4</protocoltype>
+    <loginname>john</loginname>
+    <secureauthentication>no</secureauthentication>
+    <loginpass>doe</loginpass>
+    <promptpassword>no</promptpassword>
+    <gatewayaddress>10.10.10.101</gatewayaddress>
+    <subnetmask>255.255.255.0</subnetmask>
+    <deviceipaddr>10.10.10.102</deviceipaddr>
+    <useproxy>no</useproxy>
+  </fields>
+</connectionmethod>
+  <connectionmethod amount="2">
+    <fields>
+      <connectionname randomlength="max" />
+      <bearertype randomlength="max" />
+      <startpage randomlength="max" />
+      <wapwspoption randomlength="max" />
+      <protocoltype randomlength="max" />
+      <loginname randomlength="max" />
+      <secureauthentication randomlength="max" />
+      <loginpass randomlength="max" />
+      <promptpassword randomlength="max" />
+      <gatewayaddress randomlength="max" />
+      <subnetmask randomlength="max" />
+      <deviceipaddr randomlength="max" />
+      <ip4nameserver1 randomlength="max" />
+      <ip4nameserver2 randomlength="max" />
+      <datacalltelnumber randomlength="max" />
+      <datacalltypeisdn randomlength="max" />
+      <datacalllinespeed randomlength="max" />
+      <useproxy randomlength="max" />
+      <proxyserveraddress randomlength="max" />
+      <proxyportnumber randomlength="max" />
+      <ip6nameserver1 randomlength="max" />
+      <ip6nameserver2 randomlength="max" />
+      <disabletextauth randomlength="max" />
+      <wlanname randomlength="max" />
+      <wlanipaddr randomlength="max" />
+      <wlansecmode randomlength="max" />
+      <wlannetmode randomlength="max" />
+    </fields>
+  </connectionmethod>
+</creatorscript>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/scripts/contactEx.creatorxml	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<creatorscript schemaVersion="1.0" scriptVersion="1.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:noNamespaceSchemaLocation="creator.xsd">
+
+<contact-set id="1" numberofexistingcontacts="10">
+</contact-set>
+
+<contactgroup name="Group with 5 existing contacts">
+   <members>
+      <contact-set-reference maxamount="5" id="1"/>
+   </members>
+</contactgroup>
+
+<contactgroup name="ExampleCompany&apos;s Designers">
+   <members>
+      <contact-set-reference id="2"/>
+   </members>
+</contactgroup>
+
+<contact>
+   <fields>
+      <firstname>John</firstname>
+      <lastname>Smith</lastname>
+      <mobilephonework>+35800101010101</mobilephonework>
+      <mobilephonework>00101010102</mobilephonework>
+      <emailgen>john.smith@example.com</emailgen>
+      <prefix>Mr.</prefix>
+   </fields>
+</contact>
+
+<contact-set id="2">
+   <contact amount="15">
+    <fields>
+    <firstname/>
+    <lastname/>
+    <mobilephonegen/>
+    <landphonegen/>
+    <emailgen/>
+    <videonumbergen/>
+    <voipgen/>
+    <poc/>
+    <company>ExampleCompany Ltd.</company>
+    <jobtitle>Software Designer</jobtitle>
+    <note/>
+ 	<middlename/>
+    <secondname/>
+    <prefix/>
+    <suffix/>
+    <addrlabelgen/>
+    <addrpogen/>
+    <addrextgen/>
+    <addrstreetgen/>
+    <addrlocalgen/>
+    </fields>
+   </contact>
+</contact-set>
+
+</creatorscript>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/scripts/creator.xsd	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,1187 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="0.1">
+
+<!-- Version 0.1 February 13th 2009: First version of the schema-->
+
+<xs:complexType name="entityfield">
+  <xs:simpleContent>
+    <xs:extension base="xs:string">
+      <!-- If not given, amount="1" is assumed -->
+      <xs:attribute name="amount" type="xs:positiveInteger" use="optional" />
+      <!-- This can be a numeric length (in bytes) "default" or "max", valid with random data only -->
+      <xs:attribute name="randomlength" type="xs:string" use="optional" />
+    </xs:extension>
+  </xs:simpleContent>
+</xs:complexType>
+
+<xs:element name="contact-set-reference">
+  <xs:complexType>
+    <xs:attribute name="id" type="xs:integer" use="required" />
+    <xs:attribute name="maxamount" type="xs:integer" use="optional" />
+  </xs:complexType>
+</xs:element>
+                  
+<xs:complexType name="contactfield" mixed="true">
+  <xs:sequence>
+    <xs:element ref="contact-set-reference" minOccurs="0" maxOccurs="unbounded" />
+  </xs:sequence>
+  <!-- If not given, amount="1" is assumed -->
+  <xs:attribute name="amount" type="xs:positiveInteger" use="optional" />
+  <xs:attribute name="incvalueforeachcopy" type="xs:boolean" use="optional" />
+</xs:complexType>
+
+<xs:complexType name="simplefield">
+  <xs:simpleContent>
+    <xs:extension base="xs:string">
+    </xs:extension>
+  </xs:simpleContent>
+</xs:complexType>
+
+<xs:group name="randomElements">
+  <xs:sequence>
+  </xs:sequence>
+</xs:group>
+
+<xs:simpleType name="fileidfield">
+  <xs:restriction base="xs:string">
+    <xs:enumeration value="3GPP-70kB" />
+    <xs:enumeration value="AAC-100kB" />
+    <xs:enumeration value="AMR-20kB" />
+    <xs:enumeration value="XLS-15kB" />
+    <xs:enumeration value="GIF-2kB" />
+    <xs:enumeration value="JPEG-200kB" />
+    <xs:enumeration value="JPEG-25kB" />
+    <xs:enumeration value="JPEG-500kB" />
+    <xs:enumeration value="MIDI-10kB" />
+    <xs:enumeration value="MP3-250kB" />
+    <xs:enumeration value="PNG-15kB" />
+    <xs:enumeration value="PPT-40kB" />
+    <xs:enumeration value="RM-95kB" />
+    <xs:enumeration value="RNG-1kB" />
+    <xs:enumeration value="TXT-10kB" />
+    <xs:enumeration value="TXT-70kB" />
+    <xs:enumeration value="WAV-20kB" />
+    <xs:enumeration value="DOC-20kB" />
+    <xs:enumeration value="SWF-15kB" />
+    <xs:enumeration value="JAD-1kB" />
+    <xs:enumeration value="JAR-10kB" />
+    <xs:enumeration value="TIF-25kB" />
+    <xs:enumeration value="MXMF-40kB" />
+    <xs:enumeration value="BMP-25kB" />
+    <xs:enumeration value="JP2-65kB" />
+    <xs:enumeration value="SVG-15kB" />
+    <xs:enumeration value="HTML-20kB" />
+    <xs:enumeration value="VCF-1kB" />
+    <xs:enumeration value="VCS-1kB" />
+    <xs:enumeration value="MP4-200kB" />
+    <xs:enumeration value="SISX-10kB" />
+    <xs:enumeration value="RAM-1kB" />
+    <xs:enumeration value="WMV-200kB" />
+    <xs:enumeration value="WMA-50kB" />
+    <xs:enumeration value="" /> <!-- allow empty content to enable random content to be generated -->
+  </xs:restriction>
+</xs:simpleType>
+
+<xs:simpleType name="syncfield">
+  <xs:restriction base="xs:string">
+    <xs:enumeration value="public" />
+    <xs:enumeration value="private" />
+    <xs:enumeration value="none" />
+    <xs:enumeration value="" /> <!-- allow empty content to enable random content to be generated -->
+  </xs:restriction>
+</xs:simpleType>
+
+<xs:simpleType name="datetimeemptyfield">
+  <xs:union>
+    <xs:simpleType>
+      <xs:restriction base="xs:string">
+        <xs:minLength value="0" />
+        <xs:maxLength value="0" />
+      </xs:restriction>
+    </xs:simpleType>
+    <xs:simpleType>
+      <xs:restriction base="xs:dateTime" />
+    </xs:simpleType>
+    <xs:simpleType>
+      <xs:restriction base="xs:date" />
+    </xs:simpleType>
+  </xs:union>
+</xs:simpleType>
+
+<xs:simpleType name="integerEmptyType">
+  <xs:union>
+    <xs:simpleType>
+      <xs:restriction base="xs:string">
+        <xs:minLength value="0" />
+        <xs:maxLength value="0" />
+      </xs:restriction>
+    </xs:simpleType>
+    <xs:simpleType>
+      <xs:restriction base="xs:integer" />
+    </xs:simpleType>
+  </xs:union>
+</xs:simpleType>
+
+<xs:simpleType name="positiveIntegerEmptyType">
+  <xs:union>
+    <xs:simpleType>
+      <xs:restriction base="xs:string">
+        <xs:minLength value="0" />
+        <xs:maxLength value="0" />
+      </xs:restriction>
+    </xs:simpleType>
+    <xs:simpleType>
+      <xs:restriction base="xs:positiveInteger" />
+    </xs:simpleType>
+  </xs:union>
+</xs:simpleType>
+
+<xs:simpleType name="datetimefield">
+  <xs:union>
+    <xs:simpleType>
+      <xs:restriction base="xs:dateTime" />
+    </xs:simpleType>
+    <xs:simpleType>
+      <xs:restriction base="xs:date" />
+    </xs:simpleType>
+  </xs:union>
+</xs:simpleType>
+
+<xs:group name="contactElements">
+  <xs:sequence>
+    <xs:element name="firstname" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="lastname" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="company" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="jobtitle" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="prefix" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="suffix" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="secondname" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="addrlabelgen" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="addrpogen" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="addrextgen" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="addrstreetgen" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="addrlocalgen" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="addrregiongen" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="addrpostcodegen" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="addrcountrygen" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="addrlabelhome" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="addrpohome" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="addrexthome" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="addrstreethome" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="addrlocalhome" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="addrregionhome" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="addrpostcodehome" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="addrcountryhome" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="addrlabelwork" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="addrpowork" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="addrextwork" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="addrstreetwork" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="addrlocalwork" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="addrregionwork" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="addrpostcodework" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="addrcountrywork" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="poc" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="swis" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="sip" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="dtmfstring" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="note" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="middlename" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="department" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="asstname" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="spouse" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="children" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="locprivacy" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="genlabel" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="wvaddress" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="thumbnailpath" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="thumbnailid" minOccurs="0" maxOccurs="unbounded" type="fileidfield" />
+    <xs:element name="callerobjtext" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="landphonegen" minOccurs="0" maxOccurs="unbounded" type="contactfield" />
+    <xs:element name="landphonehome" minOccurs="0" maxOccurs="unbounded" type="contactfield" />
+    <xs:element name="landphonework" minOccurs="0" maxOccurs="unbounded" type="contactfield" />
+    <xs:element name="mobilephonegen" minOccurs="0" maxOccurs="unbounded" type="contactfield" />
+    <xs:element name="mobilephonehome" minOccurs="0" maxOccurs="unbounded" type="contactfield" />
+    <xs:element name="mobilephonework" minOccurs="0" maxOccurs="unbounded" type="contactfield" />
+    <xs:element name="faxnumbergen" minOccurs="0" maxOccurs="unbounded" type="contactfield" />
+    <xs:element name="faxnumberhome" minOccurs="0" maxOccurs="unbounded" type="contactfield" />
+    <xs:element name="faxnumberwork" minOccurs="0" maxOccurs="unbounded" type="contactfield" />
+    <xs:element name="pagernumber" minOccurs="0" maxOccurs="unbounded" type="contactfield" />
+    <xs:element name="videonumbergen" minOccurs="0" maxOccurs="unbounded" type="contactfield" />
+    <xs:element name="videonumberhome" minOccurs="0" maxOccurs="unbounded" type="contactfield" />
+    <xs:element name="videonumberwork" minOccurs="0" maxOccurs="unbounded" type="contactfield" />
+    <xs:element name="voipgen" minOccurs="0" maxOccurs="unbounded" type="contactfield" />
+    <xs:element name="voiphome" minOccurs="0" maxOccurs="unbounded" type="contactfield" />
+    <xs:element name="voipwork" minOccurs="0" maxOccurs="unbounded" type="contactfield" />
+    <xs:element name="asstphone" minOccurs="0" maxOccurs="unbounded" type="contactfield" />
+    <xs:element name="carphone" minOccurs="0" maxOccurs="unbounded" type="contactfield" />
+    <xs:element name="urlgen" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="urlhome" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="urlwork" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="emailgen" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="emailhome" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="emailwork" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="ringtonepath" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="ringtoneid" minOccurs="0" maxOccurs="unbounded" type="fileidfield" />
+    <xs:element name="callerobjimg" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+    <xs:element name="birthday" minOccurs="0" maxOccurs="unbounded" type="datetimeemptyfield" />
+    <xs:element name="anniversary" minOccurs="0" maxOccurs="unbounded" type="datetimeemptyfield" />
+    <xs:element name="synchronization" minOccurs="0" maxOccurs="unbounded" type="syncfield" />
+  </xs:sequence>
+</xs:group>
+  
+<xs:element name="contact">
+  <xs:annotation>
+    <xs:documentation>
+      There are three different contact related elements: contact, contact-set and contactgroup. The contact element describes one
+      contact in a database. The contact can be defined explicitly by giving the contact fields and their data, or it can just define the fields to be
+      used and let the Creator fill the fields with random data. There can also be several same type of fields, for example multiple emailwork fields.
+
+      When contact is defined without fields sub-element, a contact with all fields containing default length random data is created.
+    </xs:documentation>
+  </xs:annotation>
+  <xs:complexType>
+    <xs:sequence>
+      <xs:element name="fields" minOccurs="0" maxOccurs="1">
+        <xs:complexType>
+          <xs:choice minOccurs="0" maxOccurs="unbounded">
+            <xs:group ref="contactElements" minOccurs="0" maxOccurs="unbounded" />
+          </xs:choice>
+        </xs:complexType>
+      </xs:element>
+    </xs:sequence>
+    <!-- If not given, amount="1" is assumed -->
+    <xs:attribute name="amount" use="optional" type="xs:positiveInteger" />
+  </xs:complexType>
+</xs:element>
+
+<xs:element name="contact-set">
+  <xs:annotation>
+    <xs:documentation>
+      The contact-set element can be used to bind multiple contacts together and linking them to contactgroups, messages and
+      calendars. When contact-set is used as a link target it must have a unique id attribute. See example usage of contact-set in
+      contactEx.creatorxml.
+    </xs:documentation>
+  </xs:annotation>
+  <xs:complexType>
+    <xs:sequence>
+      <xs:element ref="contact" minOccurs="0" maxOccurs="unbounded" />
+    </xs:sequence>
+    <xs:attribute name="id" use="required" type="xs:integer" />
+    <xs:attribute name="numberofexistingcontacts" type="xs:integer" use="optional">
+      <xs:annotation>
+        <xs:documentation>
+          Amount of members in the group. Indicates how many existing contacts should be taken to the set. 
+        </xs:documentation>
+      </xs:annotation>
+    </xs:attribute>
+  </xs:complexType>
+</xs:element>
+
+<xs:element name="contactgroup">
+  <xs:annotation>
+    <xs:documentation>
+      The contactgroup element describes one contact group that should be created to the device's database. 
+    </xs:documentation>
+  </xs:annotation>
+  <xs:complexType>
+    <xs:sequence>
+      <xs:element name="members" maxOccurs="1">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element ref="contact-set-reference" maxOccurs="unbounded" />
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+    </xs:sequence>
+    <xs:attribute name="name" type="xs:string" use="optional" />
+  </xs:complexType>
+</xs:element>
+
+<xs:element name="calendar">
+  <xs:annotation>
+    <xs:documentation>
+      Note: If alarmtime element is not set, alarm is set as not active and if alarmtime is set, alarm is set to active.
+      Note: If recurrentfrequency is not set, or set to not-repeated recurrentinterval will be skipped, even if set.
+    </xs:documentation>
+  </xs:annotation>
+  <xs:complexType>
+    <xs:sequence>
+      <xs:element name="fields">
+        <xs:complexType>
+          <xs:all>
+            <xs:element name="summary" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="description" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="location" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="starttime" minOccurs="0" maxOccurs="1" type="datetimeemptyfield" />
+            <xs:element name="endtime" minOccurs="0" maxOccurs="1" type="datetimeemptyfield" />
+            <xs:element name="creationperiodstartdate" minOccurs="0" maxOccurs="1" type="datetimeemptyfield" />
+            <xs:element name="creationperiodenddate" minOccurs="0" maxOccurs="1" type="datetimeemptyfield" />
+            <xs:element name="recurrentfrequency" minOccurs="0" maxOccurs="1" type="eventRecurrentfrequencyType" />
+            <xs:element name="recurrentinterval" minOccurs="0" maxOccurs="1" type="xs:positiveInteger" />
+            <xs:element name="recurrentfrom" minOccurs="0" maxOccurs="1" type="datetimeemptyfield" />
+            <xs:element name="recurrentto" minOccurs="0" maxOccurs="1" type="datetimeemptyfield" />
+            <xs:element name="alarmtime" minOccurs="0" maxOccurs="1" type="datetimeemptyfield" />
+            <xs:element name="synchronization" minOccurs="0" maxOccurs="1" type="syncfield" />
+            <xs:element name="organizername" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="organizeremail" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="status" minOccurs="0" maxOccurs="1" type="eventStatusType" />
+            <xs:element name="priority" minOccurs="0" maxOccurs="1" type="eventPriorityType" />
+            <xs:element ref="attendees" minOccurs="0" maxOccurs="1" />
+          </xs:all>
+        </xs:complexType>
+      </xs:element>
+    </xs:sequence>
+    <!-- If not given, amount="1" is assumed -->
+    <xs:attribute name="type" use="required" type="eventType" />
+    <xs:attribute name="amount" use="optional" type="xs:positiveInteger" />
+  </xs:complexType>
+</xs:element>
+
+<xs:simpleType name="eventType">
+  <xs:restriction base="xs:string">
+    <xs:enumeration value="appointment" />
+    <xs:enumeration value="event" />
+    <xs:enumeration value="reminder" />
+    <xs:enumeration value="todo" />
+    <xs:enumeration value="anniversary" />
+  </xs:restriction>
+</xs:simpleType>
+
+<xs:simpleType name="eventRecurrentfrequencyType">
+  <xs:restriction base="xs:string">
+    <xs:enumeration value="not-repeated" />
+    <xs:enumeration value="daily" />
+    <xs:enumeration value="weekly" />
+    <xs:enumeration value="monthly" />
+    <xs:enumeration value="yearly" />
+  </xs:restriction>
+</xs:simpleType>
+
+<xs:simpleType name="eventStatusType">
+  <xs:restriction base="xs:string">
+    <xs:enumeration value="tentative" />
+    <xs:enumeration value="confirmed" />
+    <xs:enumeration value="cancelled" />
+    <xs:enumeration value="todoneedsaction" />
+    <xs:enumeration value="todocompleted" />
+    <xs:enumeration value="todoinprocess" />
+    <xs:enumeration value="" /> <!-- allow empty content to enable random content to be generated -->
+  </xs:restriction>
+</xs:simpleType>
+    
+<xs:simpleType name="eventPriorityType">
+  <xs:union>
+    <xs:simpleType>
+      <xs:restriction base="xs:integer">
+        <xs:minInclusive value="0" />
+        <xs:maxInclusive value="255" />
+      </xs:restriction>
+    </xs:simpleType>
+    <xs:simpleType>
+      <xs:restriction base="xs:string">
+        <xs:enumeration value="high" />
+        <xs:enumeration value="medium" />
+        <xs:enumeration value="low" />
+        <xs:enumeration value="" /> <!-- allow empty content to enable random content to be generated -->
+      </xs:restriction>
+    </xs:simpleType>
+  </xs:union>
+</xs:simpleType>
+
+<xs:element name="attendees">
+  <xs:complexType>
+    <xs:sequence>
+      <xs:element ref="contact-set-reference" minOccurs="0" maxOccurs="unbounded"/>
+      <xs:element name="attendee" minOccurs="0" maxOccurs="unbounded">
+        <xs:complexType>
+          <xs:all>
+            <xs:element name="commonname" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="email" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="role" minOccurs="0" maxOccurs="1" type="attendeeRoleType" />
+            <xs:element name="status" minOccurs="0" maxOccurs="1" type="attendeeStatusType" />
+          </xs:all>
+        </xs:complexType>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+</xs:element>
+
+<xs:simpleType name="attendeeRoleType">
+  <xs:restriction base="xs:string">
+    <xs:enumeration value="required" />
+    <xs:enumeration value="optional" />
+    <xs:enumeration value="non-participant" />
+    <xs:enumeration value="chair" />
+  </xs:restriction>
+</xs:simpleType>
+
+<xs:simpleType name="attendeeStatusType">
+  <xs:restriction base="xs:string">
+    <xs:enumeration value="needsaction" />
+    <xs:enumeration value="accepted" />
+    <xs:enumeration value="tentative" />
+    <xs:enumeration value="confirmed" />
+    <xs:enumeration value="declined" />
+    <xs:enumeration value="completed" />
+    <xs:enumeration value="delegated" />
+    <xs:enumeration value="inprocess" />
+  </xs:restriction>
+</xs:simpleType>
+    
+<xs:group name="bookmarkElements">
+  <xs:sequence> <!-- Element order is fixed. This enables using both minOccurs="1" and maxOccurs="1". -->
+    <xs:element name="name" minOccurs="1" maxOccurs="1" type="entityfield" />
+    <xs:element name="url" minOccurs="1" maxOccurs="1" type="entityfield" />
+    <xs:element name="username" minOccurs="1" maxOccurs="1" type="entityfield" />
+    <xs:element name="password" minOccurs="1" maxOccurs="1" type="entityfield" />
+  </xs:sequence>
+</xs:group>
+
+<xs:element name="bookmark">
+  <xs:complexType>
+    <xs:sequence>
+      <xs:element name="fields">
+        <xs:complexType>
+          <xs:choice minOccurs="0" maxOccurs="1">
+            <xs:group ref="randomElements" minOccurs="0" maxOccurs="1" />
+            <xs:group ref="bookmarkElements" minOccurs="0" maxOccurs="1" />
+          </xs:choice>
+        </xs:complexType>
+      </xs:element>
+    </xs:sequence>
+    <!-- If not given, amount="1" is assumed -->
+    <xs:attribute name="amount" use="optional" type="xs:positiveInteger" />
+  </xs:complexType>
+</xs:element>
+
+<xs:element name="bookmarkfolder">
+  <xs:complexType>
+    <xs:sequence>
+      <xs:element name="fields" maxOccurs="1">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element name="name" minOccurs="1" maxOccurs="1" type="entityfield"/>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+    </xs:sequence>
+    <xs:attribute name="amount" use="optional" type="xs:positiveInteger"/>
+  </xs:complexType>
+</xs:element>
+
+<xs:group name="savedpageElements">
+  <xs:sequence>
+    <xs:element name="name" minOccurs="1" maxOccurs="1" type="entityfield" />
+    <xs:element name="path" minOccurs="1" maxOccurs="1" type="entityfield" />
+  </xs:sequence>
+</xs:group>
+
+<xs:group name="savedpageElementsReverse">
+  <xs:sequence>
+    <xs:element name="path" minOccurs="1" maxOccurs="1" type="entityfield" />
+    <xs:element name="name" minOccurs="1" maxOccurs="1" type="entityfield" />
+  </xs:sequence>
+</xs:group>
+
+<xs:element name="savedpage">
+  <xs:complexType>
+    <xs:sequence>
+      <xs:element name="fields" maxOccurs="1">
+        <xs:complexType>
+          <xs:choice minOccurs="0" maxOccurs="1">
+            <xs:group ref="randomElements" minOccurs="0" maxOccurs="1" />
+            <xs:group ref="savedpageElements" minOccurs="0" maxOccurs="1" />
+            <xs:group ref="savedpageElementsReverse" minOccurs="0" maxOccurs="1" />
+          </xs:choice>
+          <!-- If not given, amount="1" is assumed -->
+          <xs:attribute name="amount" use="optional" type="xs:positiveInteger" />
+        </xs:complexType>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+</xs:element>
+
+<xs:element name="savedpagefolder">
+  <xs:complexType>
+    <xs:sequence>
+      <xs:element name="fields" maxOccurs="1">
+        <xs:complexType>
+          <xs:all>
+            <xs:element name="name" minOccurs="0" maxOccurs="1" type="entityfield" />
+          </xs:all>
+        </xs:complexType>
+      </xs:element>
+    </xs:sequence>
+    <!-- If not given, amount="1" is assumed -->
+    <xs:attribute name="amount" use="optional" type="xs:positiveInteger" />
+  </xs:complexType>
+</xs:element>
+
+<xs:element name="note">
+  <xs:complexType>
+    <xs:sequence>
+      <xs:element name="fields" maxOccurs="1">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element name="text" minOccurs="0" maxOccurs="1" type="entityfield" />
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+    </xs:sequence>
+    <!-- If not given, amount="1" is assumed -->
+    <xs:attribute name="amount" use="optional" type="xs:positiveInteger" />
+  </xs:complexType>
+</xs:element>
+
+<xs:element name="log">
+  <xs:complexType>
+    <xs:sequence>
+      <xs:element name="fields" maxOccurs="1">
+        <xs:complexType>
+          <xs:all>
+            <xs:element name="direction" minOccurs="1" maxOccurs="1" type="logDirectionType" />
+            <xs:element name="datetime" minOccurs="1" maxOccurs="1" type="entityfield" />
+            <xs:element name="phonenumber" minOccurs="1" maxOccurs="1" type="entityfield" />
+            <xs:element name="duration" minOccurs="0" maxOccurs="1" type="entityfield" />
+          </xs:all>
+        </xs:complexType>
+      </xs:element>
+    </xs:sequence>
+    <!-- If not given, amount="1" is assumed -->
+    <xs:attribute name="amount" use="optional" type="xs:positiveInteger" />
+  </xs:complexType>
+</xs:element>
+
+<xs:simpleType name="logDirectionType">
+  <xs:restriction base="xs:string">
+    <xs:enumeration value="missed" />
+    <xs:enumeration value="in" />
+    <xs:enumeration value="out" />
+    <xs:enumeration value="" /> <!-- allow empty content to enable random content to be generated -->
+  </xs:restriction>
+</xs:simpleType>
+
+<xs:element name="connectionmethod">
+  <xs:complexType>
+    <xs:sequence>
+      <xs:element name="fields" maxOccurs="1">
+        <xs:complexType>
+          <xs:all>
+            <xs:element name="connectionname" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="bearertype" minOccurs="0" maxOccurs="1" type="connBearerType" />
+            <xs:element name="startpage" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="wapwspoption" minOccurs="0" maxOccurs="1" type="wapwspoptionType" />
+            <xs:element name="protocoltype" minOccurs="0" maxOccurs="1" type="connProtocolType" />
+            <xs:element name="loginname" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="secureauthentication" minOccurs="0" maxOccurs="1" type="yesNoType" />
+            <xs:element name="loginpass" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="promptpassword" minOccurs="0" maxOccurs="1" type="yesNoType" />
+            <xs:element name="gatewayaddress" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="subnetmask" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="deviceipaddr" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="ip4nameserver1" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="ip4nameserver2" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="datacalltelnumber" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="datacalltypeisdn" minOccurs="0" maxOccurs="1" type="datacalltypeisdnType" />
+            <xs:element name="datacalllinespeed" minOccurs="0" maxOccurs="1" type="datacalllinespeedType" />
+            <xs:element name="useproxy" minOccurs="0" maxOccurs="1" type="yesNoType" />
+            <xs:element name="proxyserveraddress" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="proxyportnumber" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="ip6nameserver1" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="ip6nameserver2" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="disabletextauth" minOccurs="0" maxOccurs="1" type="yesNoType" />
+            <xs:element name="wlanname" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="wlanipaddr" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="wlansecmode" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="wlannetmode" minOccurs="0" maxOccurs="1" type="entityfield" />
+          </xs:all>
+        </xs:complexType>
+      </xs:element>
+    </xs:sequence>
+    <!-- If not given, amount="1" is assumed -->
+    <xs:attribute name="amount" use="optional" type="xs:positiveInteger" />
+  </xs:complexType>
+</xs:element>
+
+<xs:simpleType name="connBearerEnumType"> 
+  <xs:restriction base="xs:string">
+    <xs:enumeration value="WLAN" />
+    <xs:enumeration value="GPRS" />
+    <xs:enumeration value="datacall" />
+    <xs:enumeration value="HSGSM" />
+    <xs:enumeration value="embedded" />
+    <xs:enumeration value="VPN" />
+    <xs:enumeration value="LAN" />
+    <xs:enumeration value="" /> <!-- allow empty content to enable random content to be generated -->
+  </xs:restriction>
+</xs:simpleType>
+
+<xs:complexType name="connBearerType"> <!-- type with both enum value restriction and randomlength attribute  -->
+  <xs:simpleContent>
+    <xs:extension base="connBearerEnumType">
+      <xs:attribute name="randomlength" type="xs:string" use="optional" />
+    </xs:extension>
+  </xs:simpleContent>
+</xs:complexType>
+
+<xs:simpleType name="connProtocolEnumType"> 
+  <xs:restriction base="xs:string">
+    <xs:enumeration value="IPV4" />
+    <xs:enumeration value="ipv4" />
+    <xs:enumeration value="Ipv4" />
+    <xs:enumeration value="iPv4" />
+    <xs:enumeration value="ipV4" />
+    <xs:enumeration value="IPv4" />
+    <xs:enumeration value="IpV4" />
+    <xs:enumeration value="iPV4" />
+    <xs:enumeration value="IPV6" />
+    <xs:enumeration value="ipv6" />
+    <xs:enumeration value="Ipv6" />
+    <xs:enumeration value="iPv6" />
+    <xs:enumeration value="ipV6" />
+    <xs:enumeration value="IPv6" />
+    <xs:enumeration value="IpV6" />
+    <xs:enumeration value="iPV6" />
+    <xs:enumeration value="" /> <!-- allow empty content to enable random content to be generated -->
+  </xs:restriction>
+</xs:simpleType>
+
+<xs:complexType name="connProtocolType"> <!-- type with both enum value restriction and randomlength attribute  -->
+  <xs:simpleContent>
+    <xs:extension base="connProtocolEnumType">
+      <xs:attribute name="randomlength" type="xs:string" use="optional" />
+    </xs:extension>
+  </xs:simpleContent>
+</xs:complexType>
+
+<xs:simpleType name="datacalltypeisdnEnumType"> 
+  <xs:restriction base="xs:string">
+    <xs:enumeration value="analogue" />
+    <xs:enumeration value="isdnv110" />
+    <xs:enumeration value="isdnv120" />
+    <xs:enumeration value="" /> <!-- allow empty content to enable random content to be generated -->
+  </xs:restriction>
+</xs:simpleType>
+
+<xs:complexType name="datacalltypeisdnType"> <!-- type with both enum value restriction and randomlength attribute  -->
+  <xs:simpleContent>
+    <xs:extension base="datacalltypeisdnEnumType">
+      <xs:attribute name="randomlength" type="xs:string" use="optional" />
+    </xs:extension>
+  </xs:simpleContent>
+</xs:complexType>
+
+<xs:simpleType name="datacalllinespeedEnumType">
+  <xs:restriction base="xs:string">
+    <xs:enumeration value="automatic" />
+    <xs:enumeration value="9600" />
+    <xs:enumeration value="14400" />
+    <xs:enumeration value="19200" />
+    <xs:enumeration value="28800" />
+    <xs:enumeration value="38400" />
+    <xs:enumeration value="43200" />
+    <xs:enumeration value="56000" />
+    <xs:enumeration value="" /> <!-- allow empty content to enable random content to be generated -->
+  </xs:restriction>
+</xs:simpleType>
+
+<xs:complexType name="datacalllinespeedType"> <!-- type with both enum value restriction and randomlength attribute  -->
+  <xs:simpleContent>
+    <xs:extension base="datacalllinespeedEnumType">
+      <xs:attribute name="randomlength" type="xs:string" use="optional" />
+    </xs:extension>
+  </xs:simpleContent>
+</xs:complexType>
+
+<xs:simpleType name="wapwspoptionEnumType">
+  <xs:restriction base="xs:string">
+    <xs:enumeration value="connectionless" />
+    <xs:enumeration value="connectionoriented" />
+    <xs:enumeration value="" /> <!-- allow empty content to enable random content to be generated -->
+  </xs:restriction>
+</xs:simpleType>
+
+<xs:complexType name="wapwspoptionType"> <!-- type with both enum value restriction and randomlength attribute  -->
+  <xs:simpleContent>
+    <xs:extension base="wapwspoptionEnumType">
+      <xs:attribute name="randomlength" type="xs:string" use="optional" />
+    </xs:extension>
+  </xs:simpleContent>
+</xs:complexType>
+
+<xs:element name="mailbox">
+  <xs:complexType>
+    <xs:sequence>
+      <xs:element name="fields" maxOccurs="1">
+        <xs:complexType>
+          <xs:all>
+            <xs:element name="name" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <!-- Incoming mail (POP3/IMAP4) settings -->
+            <xs:element name="incomingport" minOccurs="0" maxOccurs="1" type="positiveIntegerEmptyType" />
+
+            <!-- Specifies whether a secure TLS connection will be established directly over a TLS socket when connecting to the email server -->
+            <xs:element name="incomingsslwrapper" minOccurs="0" maxOccurs="1" type="yesNoType" />
+            <!-- Specifies whether a secure socket session will be negotiated after establishing a non-secure TCP connection with the email server -->
+            <xs:element name="incomingsecuresockets" minOccurs="0" maxOccurs="1" type="yesNoType" />
+            <xs:element name="incomingloginname" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="incomingpassword" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="incomingservername" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="incomingconnectionmethod" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <!-- Send return receipts to senders -->
+            <xs:element name="acknowledgereceipts" minOccurs="0" maxOccurs="1" type="yesNoType" />
+            <!-- maximum attachment size limit for the partial fetch of attachments in a message -->
+            <xs:element name="attachmentsizelimit" minOccurs="0" maxOccurs="1" type="integerEmptyType" />
+            <xs:element name="autosendonconnect" minOccurs="0" maxOccurs="1" type="yesNoType" />
+            <xs:element name="bodytextsizelimit" minOccurs="0" maxOccurs="1" type="integerEmptyType" />
+            <xs:element name="deletemailsatdisconnect" minOccurs="0" maxOccurs="1" type="yesNoType" />
+            <!-- Specifies the IMAP fetch size in bytes -->
+            <xs:element name="attachmentfetchsize" minOccurs="0" maxOccurs="1" type="positiveIntegerEmptyType" />
+            <xs:element name="incomingfolderpath" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="pathseparator" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="getemailoptions" minOccurs="0" maxOccurs="1" type="getEmailOptionsType" />
+            <!-- Specifies whether the IMAP IDLE command should be used as defined in RFC2177 -->
+            <xs:element name="imapidlecommand" minOccurs="0" maxOccurs="1" type="yesNoType" />
+            <xs:element name="imapidletimeout" minOccurs="0" maxOccurs="1" type="xs:positiveInteger" />
+            <!-- Sets the maximum message size in bytes to be downloaded -->
+            <xs:element name="maxemailsize" minOccurs="0" maxOccurs="1" type="xs:positiveInteger" />
+            <!-- Sets the method for synchronising IMAP4 subscription information with a server -->
+            <xs:element name="subscribetype" minOccurs="0" maxOccurs="1" type="mailboxSubscribeType" />
+            <!-- Specifies the rate in seconds at which the Inbox will be refreshed when connected -->
+            <xs:element name="syncrate" minOccurs="0" maxOccurs="1" type="xs:positiveInteger" />
+            <!-- Sets the method for synchronising folder information with the server -->
+            <xs:element name="foldersynctype" minOccurs="0" maxOccurs="1" type="mailboxFolderSyncType" />
+            <!-- Specifies whether the seen flag is to be set on the IMAP4 server during synchronisation only when the message has been marked as read -->
+            <xs:element name="markseeninsync" minOccurs="0" maxOccurs="1" type="yesNoType" />
+            <xs:element name="enableexpungemode" minOccurs="0" maxOccurs="1" type="yesNoType" />
+            <xs:element name="useapopsecurelogin" minOccurs="0" maxOccurs="1" type="yesNoType" />
+            <xs:element name="inboxsynclimit" minOccurs="0" maxOccurs="1" type="syncLimitType" />
+            <xs:element name="mailboxsynclimit" minOccurs="0" maxOccurs="1" type="syncLimitType" />
+            <xs:element name="disconnectedusermode" minOccurs="0" maxOccurs="1" type="yesNoType" />
+
+            <!-- Outgoing mail (SMTP) settings -->
+            <xs:element name="outgoingport" minOccurs="0" maxOccurs="1" type="xs:positiveInteger" />
+            <xs:element name="outgoingsslwrapper" minOccurs="0" maxOccurs="1" type="yesNoType" />
+            <xs:element name="outgoingsecuresockets" minOccurs="0" maxOccurs="1" type="yesNoType" />
+            <xs:element name="outgoingloginname" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="outgoingpassword" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="outgoingservername" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="outgoingconnectionmethod" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="includesignature" minOccurs="0" maxOccurs="1" type="yesNoType" />
+            <xs:element name="addvcard" minOccurs="0" maxOccurs="1" type="yesNoType" />
+            <xs:element name="ownemail" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="emailalias" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="receiptaddress" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="replytoaddress" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="requestreceipts" minOccurs="0" maxOccurs="1" type="yesNoType" />
+            <xs:element name="smtpauth" minOccurs="0" maxOccurs="1" type="yesNoType" />
+            <xs:element name="copytoself" minOccurs="0" maxOccurs="1" type="copyToSelfType" />
+            <xs:element name="sendoption" minOccurs="0" maxOccurs="1" type="sendOptionType" />
+            <xs:element name="toccincludelimit" minOccurs="0" maxOccurs="1" type="integerEmptyType" />
+          </xs:all>
+        </xs:complexType>
+      </xs:element>
+    </xs:sequence>
+    <!-- If not given, amount="1" is assumed -->
+    <xs:attribute name="amount" use="optional" type="xs:positiveInteger" />
+    <xs:attribute name="type" use="required" type="mailboxType" />
+  </xs:complexType>
+</xs:element>
+
+<xs:simpleType name="mailboxType">
+  <xs:restriction base="xs:string">
+    <xs:enumeration value="POP3" />
+    <xs:enumeration value="IMAP4" />
+    <xs:enumeration value="syncml" />
+    <xs:enumeration value="" /> <!-- allow empty content to enable random content to be generated -->
+  </xs:restriction>
+</xs:simpleType>
+
+<xs:simpleType name="yesNoEnumType">
+  <xs:restriction base="xs:string">
+    <xs:enumeration value="yes" />
+    <xs:enumeration value="no" />
+    <xs:enumeration value="" /> <!-- allow empty content to enable random content to be generated -->
+  </xs:restriction>
+</xs:simpleType>
+
+<xs:complexType name="yesNoType"> <!-- type with both enum value restriction and randomlength attribute  -->
+  <xs:simpleContent>
+    <xs:extension base="yesNoEnumType">
+      <xs:attribute name="randomlength" type="xs:string" use="optional" />
+    </xs:extension>
+  </xs:simpleContent>
+</xs:complexType>
+
+<xs:simpleType name="getEmailOptionsEnumType">
+  <xs:restriction base="xs:string">
+    <xs:enumeration value="getheaders" />
+    <xs:enumeration value="getbodytext" />
+    <xs:enumeration value="getbodytextandattachments" />
+    <xs:enumeration value="getattachments" />
+    <xs:enumeration value="getbodyalternativetext" />
+    <xs:enumeration value="" /> <!-- allow empty content to enable random content to be generated -->
+  </xs:restriction>
+</xs:simpleType>
+
+<xs:complexType name="getEmailOptionsType"> <!-- type with both enum value restriction and randomlength attribute  -->
+  <xs:simpleContent>
+    <xs:extension base="getEmailOptionsEnumType">
+      <xs:attribute name="randomlength" type="xs:string" use="optional" />
+    </xs:extension>
+  </xs:simpleContent>
+</xs:complexType>
+
+<xs:simpleType name="syncLimitEnumType">
+  <xs:union>
+    <xs:simpleType>
+      <xs:restriction base="xs:integer">
+        <xs:minInclusive value="1" />
+        <xs:maxInclusive value="999" />
+      </xs:restriction>
+    </xs:simpleType>
+    <xs:simpleType>
+      <xs:restriction base="xs:string">
+        <xs:enumeration value="all" />
+        <xs:enumeration value="" /> <!-- allow empty content to enable random content to be generated -->
+      </xs:restriction>
+    </xs:simpleType>
+  </xs:union>
+</xs:simpleType>
+
+<xs:complexType name="syncLimitType"> <!-- type with both enum value restriction and randomlength attribute  -->
+  <xs:simpleContent>
+    <xs:extension base="syncLimitEnumType">
+      <xs:attribute name="randomlength" type="xs:string" use="optional" />
+    </xs:extension>
+  </xs:simpleContent>
+</xs:complexType>
+
+<xs:simpleType name="mailboxSubscribeEnumType">
+  <xs:restriction base="xs:string">
+    <xs:enumeration value="updateneither" />
+    <xs:enumeration value="updatelocal" />
+    <xs:enumeration value="updateremote" />
+    <xs:enumeration value="updateboth" />
+    <xs:enumeration value="" /> <!-- allow empty content to enable random content to be generated -->
+  </xs:restriction>
+</xs:simpleType>
+
+<xs:complexType name="mailboxSubscribeType"> <!-- type with both enum value restriction and randomlength attribute  -->
+  <xs:simpleContent>
+    <xs:extension base="mailboxSubscribeEnumType">
+      <xs:attribute name="randomlength" type="xs:string" use="optional" />
+    </xs:extension>
+  </xs:simpleContent>
+</xs:complexType>
+
+<xs:simpleType name="mailboxFolderSyncEnumType">
+  <xs:restriction base="xs:string">
+    <xs:enumeration value="usecombination" />
+    <xs:enumeration value="uselocal" />
+    <xs:enumeration value="useremote" />
+    <xs:enumeration value="" /> <!-- allow empty content to enable random content to be generated -->
+  </xs:restriction>
+</xs:simpleType>
+
+<xs:complexType name="mailboxFolderSyncType"> <!-- type with both enum value restriction and randomlength attribute  -->
+  <xs:simpleContent>
+    <xs:extension base="mailboxFolderSyncEnumType">
+      <xs:attribute name="randomlength" type="xs:string" use="optional" />
+    </xs:extension>
+  </xs:simpleContent>
+</xs:complexType>
+
+<xs:simpleType name="copyToSelfEnumType">
+  <xs:restriction base="xs:string">
+    <xs:enumeration value="no" />
+    <xs:enumeration value="to" />
+    <xs:enumeration value="cc" />
+    <xs:enumeration value="bcc" />
+    <xs:enumeration value="" /> <!-- allow empty content to enable random content to be generated -->
+  </xs:restriction>
+</xs:simpleType>
+
+<xs:complexType name="copyToSelfType"> <!-- type with both enum value restriction and randomlength attribute  -->
+  <xs:simpleContent>
+    <xs:extension base="copyToSelfEnumType">
+      <xs:attribute name="randomlength" type="xs:string" use="optional" />
+    </xs:extension>
+  </xs:simpleContent>
+</xs:complexType>
+
+<xs:simpleType name="sendOptionEnumType">
+  <xs:restriction base="xs:string">
+    <xs:enumeration value="immediately" />
+    <xs:enumeration value="onnextconnection" />
+    <xs:enumeration value="onrequest" />
+    <xs:enumeration value="" /> <!-- allow empty content to enable random content to be generated -->
+  </xs:restriction>
+</xs:simpleType>
+
+<xs:complexType name="sendOptionType"> <!-- type with both enum value restriction and randomlength attribute  -->
+  <xs:simpleContent>
+    <xs:extension base="sendOptionEnumType">
+      <xs:attribute name="randomlength" type="xs:string" use="optional" />
+    </xs:extension>
+  </xs:simpleContent>
+</xs:complexType>
+
+<xs:element name="message">
+  <xs:complexType>
+    <xs:sequence>
+      <xs:element name="fields" maxOccurs="1">
+        <xs:complexType>
+          <xs:sequence> <!-- Element order is fixed. This enables using both maxOccurs="unbounded" and maxOccurs="1". -->
+            <xs:element name="to" minOccurs="0" maxOccurs="unbounded" type="contactfield"/>
+            <xs:element name="from" minOccurs="0" maxOccurs="1" type="contactfield"/>
+            <xs:element name="folder" minOccurs="0" maxOccurs="1" type="messageFolderType" />
+            <xs:element name="subject" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="text" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="status" minOccurs="0" maxOccurs="1" type="messageStatusType" />
+            <xs:element name="smartmessagetype" minOccurs="0" maxOccurs="1" type="smartMessageType" />
+            <xs:element name="attachmentpath" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+            <xs:element name="attachmentid" minOccurs="0" maxOccurs="unbounded" type="fileidfield" />
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+    </xs:sequence>
+    <!-- If not given, amount="1" is assumed -->
+    <xs:attribute name="amount" use="optional" type="xs:positiveInteger" />
+    <xs:attribute name="type" use="required" type="messageType" />
+  </xs:complexType>
+</xs:element>
+
+<xs:simpleType name="messageType">
+  <xs:restriction base="xs:string">
+    <xs:enumeration value="sms" />
+    <xs:enumeration value="mms" />
+    <xs:enumeration value="ams" />
+    <xs:enumeration value="email" />
+    <xs:enumeration value="smart" />
+    <xs:enumeration value="ir" />
+    <xs:enumeration value="bt" />
+  </xs:restriction>
+</xs:simpleType>
+
+<xs:simpleType name="messageFolderType">
+  <xs:restriction base="xs:string">
+    <xs:enumeration value="sent" />
+    <xs:enumeration value="inbox" />
+    <xs:enumeration value="draft" />
+    <xs:enumeration value="outbox" />
+    <xs:enumeration value="" /> <!-- allow empty content to enable random content to be generated -->
+  </xs:restriction>
+</xs:simpleType>
+
+<xs:simpleType name="messageStatusType">
+  <xs:restriction base="xs:string">
+    <xs:enumeration value="read" />
+    <xs:enumeration value="new" />
+    <xs:enumeration value="" /> <!-- allow empty content to enable random content to be generated -->
+  </xs:restriction>
+</xs:simpleType>
+
+<xs:simpleType name="smartMessageType"> <!-- Currently not supported by S60 Creator -->
+  <xs:restriction base="xs:string">
+    <xs:enumeration value="internetsettings" />
+    <xs:enumeration value="emailnotification" />
+    <xs:enumeration value="businesscard" />
+    <xs:enumeration value="wapsettings" />
+    <xs:enumeration value="vcalendar" />
+    <xs:enumeration value="vcard" />
+    <xs:enumeration value="ringtone" />
+    <xs:enumeration value="operatorlogo" />
+    <xs:enumeration value="wapprovisioning" />
+    <xs:enumeration value="clilogo" />
+  </xs:restriction>
+</xs:simpleType>
+
+<xs:group name="impsserverElements">
+  <xs:sequence> <!-- Element order is fixed. This enables using both minOccurs="1" and maxOccurs="1". -->
+    <xs:element name="name" minOccurs="1" maxOccurs="1" type="entityfield" />
+    <xs:element name="url" minOccurs="1" maxOccurs="1" type="entityfield" />
+    <xs:element name="username" minOccurs="1" maxOccurs="1" type="entityfield" />
+    <xs:element name="password" minOccurs="1" maxOccurs="1" type="entityfield" />
+    <xs:element name="connectionmethodname" minOccurs="1" maxOccurs="1" type="entityfield" />
+  </xs:sequence>
+</xs:group>
+ 
+<xs:element name="impsserver">
+  <xs:complexType>
+    <xs:sequence>
+      <xs:element name="fields" maxOccurs="1">
+        <xs:complexType>
+          <xs:choice minOccurs="0" maxOccurs="1">
+            <xs:group ref="randomElements" minOccurs="0" maxOccurs="1" />
+            <xs:group ref="impsserverElements" minOccurs="0" maxOccurs="1" />
+          </xs:choice>
+        </xs:complexType>
+      </xs:element>
+    </xs:sequence>
+    <!-- If not given, amount="1" is assumed -->
+    <xs:attribute name="amount" use="optional" type="xs:positiveInteger" />
+  </xs:complexType>
+</xs:element>
+ 
+<xs:element name="file">
+  <xs:annotation>
+    <xs:documentation>
+      Note: If type is not set, a directory will be created. 
+    </xs:documentation>
+  </xs:annotation>
+  <xs:complexType>
+    <xs:sequence>
+      <xs:element name="fields" maxOccurs="1">
+        <xs:complexType>
+          <xs:all>
+            <xs:element name="type" minOccurs="1" maxOccurs="1" type="fileidfield" />
+            <xs:element name="directory" minOccurs="1" maxOccurs="1" type="entityfield" />
+            <xs:element ref="encryption" minOccurs="0" maxOccurs="1" />
+          </xs:all>
+        </xs:complexType>
+      </xs:element>
+    </xs:sequence>
+    <!-- If not given, amount="1" is assumed -->
+    <xs:attribute name="amount" use="optional" type="xs:positiveInteger" />
+  </xs:complexType>
+</xs:element>
+
+<xs:element name="encryption"> <!-- Random values not supported inside encryption element -->
+  <xs:complexType>
+    <xs:sequence>
+      <xs:element ref="right" minOccurs="0" maxOccurs="4" />
+    </xs:sequence>
+    <xs:attribute name="type" use="required">
+      <xs:simpleType>
+        <xs:restriction base="xs:string">
+          <xs:enumeration value="DRM-FL" />
+          <xs:enumeration value="DRM-CD" />
+        </xs:restriction>
+      </xs:simpleType>
+    </xs:attribute>
+  </xs:complexType>
+</xs:element>
+
+<xs:element name="right">
+  <xs:complexType>
+    <xs:all>
+      <xs:element name="count" minOccurs="0" maxOccurs="1" type="xs:nonNegativeInteger" />
+      <xs:element name="starttime" minOccurs="0" maxOccurs="1" type="datetimefield" />
+      <xs:element name="endtime" minOccurs="0" maxOccurs="1" type="datetimefield" />
+      <xs:element name="interval" minOccurs="0" maxOccurs="1" type="xs:duration" />
+      <xs:element name="accumulated" minOccurs="0" maxOccurs="1" type="xs:duration" />
+    </xs:all>
+    <xs:attribute name="type" default="display">
+      <xs:simpleType>
+        <xs:restriction base="xs:string">
+          <xs:enumeration value="play" />
+          <xs:enumeration value="display" />
+          <xs:enumeration value="execute" />
+          <xs:enumeration value="print" />
+        </xs:restriction>
+      </xs:simpleType>
+    </xs:attribute>
+  </xs:complexType>
+</xs:element>
+
+<xs:element name="landmark">
+  <xs:complexType>
+    <xs:sequence>
+      <xs:element name="fields" maxOccurs="1">
+        <xs:complexType>
+          <xs:sequence> <!-- Element order is fixed. This enables using both maxOccurs="unbounded" and maxOccurs="1". -->
+            <xs:element name="name" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="category" minOccurs="0" maxOccurs="unbounded" type="entityfield" />
+            <xs:element name="description" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="street" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="postalcode" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="city" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="state" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="country" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="phonenbr" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="url" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="latitude" minOccurs="0" maxOccurs="1" type="entityfield">
+              <xs:annotation>
+                <xs:documentation>
+                  Data can have following format: -nn.nnnn - nn.nnnn, where positive latitude means north and negative south, zero
+                  point is Equator.
+                </xs:documentation>
+              </xs:annotation>
+            </xs:element>
+            <xs:element name="longitude" minOccurs="0" maxOccurs="1" type="entityfield">
+              <xs:annotation>
+                <xs:documentation>
+                  Data can have following format: -nn.nnnn - nn.nnnn, where positive longitude means east and negative west, zero
+                  point is Prime Meridian.
+                </xs:documentation>
+              </xs:annotation>
+            </xs:element>
+            <xs:element name="positionaccuracy" minOccurs="0" maxOccurs="1" type="entityfield" />
+            <xs:element name="altitude" minOccurs="0" maxOccurs="1" type="entityfield">
+              <xs:annotation>
+                <xs:documentation>
+                  Data can have following format: -nn.nnnn - nn.nnnn, where zero point is sea level.
+                </xs:documentation>
+              </xs:annotation>
+            </xs:element>
+            <xs:element name="altitudeaccuracy" minOccurs="0" maxOccurs="1" type="entityfield" />
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+    </xs:sequence>
+    <!-- If not given, amount="1" is assumed -->
+    <xs:attribute name="amount" use="optional" type="xs:positiveInteger" />
+  </xs:complexType>
+</xs:element>
+
+<xs:group name="creatorscriptElements">
+  <xs:sequence>
+    <xs:element ref="contact" minOccurs="0" maxOccurs="unbounded" />
+    <xs:element ref="contact-set" minOccurs="0" maxOccurs="unbounded" />
+    <xs:element ref="contactgroup" minOccurs="0" maxOccurs="unbounded" />
+    <xs:element ref="calendar" minOccurs="0" maxOccurs="unbounded" />
+    <xs:element ref="bookmark" minOccurs="0" maxOccurs="unbounded" />
+    <xs:element ref="bookmarkfolder" minOccurs="0" maxOccurs="unbounded" />
+    <xs:element ref="savedpage" minOccurs="0" maxOccurs="unbounded" />
+    <xs:element ref="savedpagefolder" minOccurs="0" maxOccurs="unbounded" />
+    <xs:element ref="note" minOccurs="0" maxOccurs="unbounded" />
+    <xs:element ref="log" minOccurs="0" maxOccurs="unbounded" />
+    <xs:element ref="connectionmethod" minOccurs="0" maxOccurs="unbounded" />
+    <xs:element ref="mailbox" minOccurs="0" maxOccurs="unbounded" />
+    <xs:element ref="message" minOccurs="0" maxOccurs="unbounded" />
+    <xs:element ref="impsserver" minOccurs="0" maxOccurs="unbounded" />
+    <xs:element ref="file" minOccurs="0" maxOccurs="unbounded" />
+    <xs:element ref="landmark" minOccurs="0" maxOccurs="unbounded" />
+  </xs:sequence>
+</xs:group>
+
+<xs:element name="creatorscript">
+  <xs:annotation>
+    <xs:documentation>
+      Root element of a Creator script. The sub-elements can be thought as 'commands', e.g. one contact element with explicitly
+      defined fields create one contact to the database of the device. 
+    </xs:documentation>
+  </xs:annotation>
+  <xs:complexType>
+    <xs:choice minOccurs="0" maxOccurs="unbounded">
+      <xs:group ref="creatorscriptElements" minOccurs="0" maxOccurs="unbounded" />
+    </xs:choice>
+    <xs:attribute name="scriptVersion" use="optional" type="xs:string">
+      <xs:annotation>
+        <xs:documentation>
+          Declares the script version. Can be used to indicate the evolution of each script. 
+    </xs:documentation>
+      </xs:annotation>
+    </xs:attribute>
+    <xs:attribute name="schemaVersion" use="required" type="xs:string">
+      <xs:annotation>
+        <xs:documentation>
+          Declares the schema version used when designing a script file. This version information must be in sync with the schema used. Schema version is defined
+          at the beginning of the creator.xsd file in comment block.
+    </xs:documentation>
+      </xs:annotation>
+    </xs:attribute>
+  </xs:complexType>
+</xs:element>
+
+</xs:schema>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/scripts/filesEx.creatorxml	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<creatorscript schemaVersion="1.0" scriptVersion="1.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:noNamespaceSchemaLocation="creator.xsd">
+
+
+<!-- Create one jpg image file -->
+<file>
+    <fields>
+        <type>JPEG-25kB</type>
+        <directory>c:\data\images</directory>
+    </fields>
+</file>
+
+<!-- Create two midi files with DRM Forward Lock protection -->
+<file amount="2">
+    <fields>
+        <type>MIDI-10kB</type>
+        <directory>c:\data\Sounds</directory>
+        <encryption type="DRM-FL">
+        </encryption>
+    </fields>
+</file>
+
+<!-- Create one DRM protected 3GPP video file with specific access constraints -->
+<file>
+    <fields>
+        <type>3GPP-70kB</type>
+        <directory>c:\data\Videos</directory>
+        <!-- Define DRM Combined Delivery encryption type -->
+        <encryption type="DRM-CD">
+            <right type="play">
+                <!-- Define 21min 1s accumulated time constraint -->
+                <accumulated>P0Y0M0DT0H21M1S</accumulated>
+                <!-- Define that the content can only be played twice -->
+                <count>2</count>
+            </right>
+        </encryption>
+    </fields>
+</file>
+
+<!-- Create one DRM protected gif image file with specific access constraints -->
+<file>
+    <fields>
+        <type>GIF-2kB</type>
+        <directory>c:\data\Images</directory>
+        <!-- Define DRM Combined Delivery encryption type -->
+        <encryption type="DRM-CD">            
+            <right type="display">
+                <!-- Define that the content can be accessed 1,5h after first access -->
+                <interval>P0Y0M0DT1H30M0S</interval>
+                <!-- Define timeframe in which the content can be accessed -->
+                <starttime>2008-09-26T13:49:57</starttime>
+                <endtime>2009-03-27T16:15:00</endtime>
+            </right>
+        </encryption>
+    </fields>
+</file>
+
+</creatorscript>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/scripts/impsEx.creatorxml	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<creatorscript schemaVersion="1.0" scriptVersion="1.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:noNamespaceSchemaLocation="creator.xsd">
+
+<!-- Create an IMPS server -->
+<impsserver>
+    <fields>
+        <name>Creator_test_imps</name>
+        <url/>
+        <username/>
+        <password/>
+        <connectionmethodname/>
+    </fields>
+</impsserver>
+
+</creatorscript>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/scripts/landmarkEx.creatorxml	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<creatorscript schemaVersion="1.0" scriptVersion="1.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:noNamespaceSchemaLocation="creator.xsd">
+
+<!-- Create a landmark with all possible categories -->
+<landmark>
+  <fields>
+    <name>CreatorExample</name>
+    <category>accommodation</category>
+    <category>business</category>
+    <category>communication</category>
+    <category>educational</category>
+    <category>entertainment</category>
+    <category>food</category>
+    <category>geographical</category>
+    <category>outdoor</category>
+    <category>people</category>
+    <category>public</category>
+    <category>religious</category>
+    <category>shopping</category>
+    <category>sightseeing</category>
+    <category>sports</category>
+    <category>transport</category>
+    <description>This is an example landmark!</description>
+    <street>Landmark street 1</street>
+    <postalcode>00445</postalcode>
+    <city>Landmark City</city>
+    <state>Landmark State</state>
+    <country>Landmark Country</country>
+    <phonenbr>111222333</phonenbr>
+    <url>http://www.example.net</url>
+    <latitude>-76.0023</latitude>
+    <longitude>98.1002</longitude>
+    <positionaccuracy>2</positionaccuracy>
+    <altitude>-4.1</altitude>
+    <altitudeaccuracy>3</altitudeaccuracy>
+  </fields>
+</landmark>
+        
+<!-- Create 3 random landmarks -->
+<landmark amount="10">
+    <fields>
+        <name/>
+        <category/>
+        <description/>        
+        <latitude/>
+        <longitude/>        
+    </fields>
+</landmark>
+
+</creatorscript>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/scripts/logEx.creatorxml	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<creatorscript schemaVersion="1.0" scriptVersion="1.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:noNamespaceSchemaLocation="creator.xsd">
+
+<!-- Create one missed call -->
+<log>
+   <fields>
+	<direction>missed</direction>
+	<datetime>2008-03-25T13:11:21</datetime>
+	<phonenumber>1115555554112</phonenumber>
+   </fields>
+</log>
+
+<!-- Create one received call -->
+<log>
+   <fields>
+        <direction>in</direction>
+        <datetime>2008-03-24T10:21:56</datetime>
+        <phonenumber>11155554112</phonenumber>
+        <duration>241</duration>
+   </fields>
+</log>
+
+<!-- Create one dialled call -->
+<log>
+   <fields>
+        <direction>out</direction>
+        <datetime>2008-03-22T12:01:06</datetime>
+        <phonenumber>0555554555</phonenumber>
+        <duration>445</duration>
+   </fields>
+</log>
+
+<!-- Create 5 random entries -->
+<log amount="5">
+   <fields>
+        <direction/>
+        <datetime/>
+        <phonenumber/>
+        <duration/>
+   </fields>
+</log>
+
+</creatorscript>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/scripts/mailboxEx.creatorxml	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<creatorscript schemaVersion="1.0" scriptVersion="1.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:noNamespaceSchemaLocation="creator.xsd">
+
+<mailbox type="POP3">
+   <fields>
+      <name>cr_pop mail</name>
+      <ownemail/>
+      <copytoself/>
+      <useapopsecurelogin>yes</useapopsecurelogin>
+      <incomingsslwrapper>no</incomingsslwrapper>
+      <incomingsecuresockets>no</incomingsecuresockets>
+      <incomingloginname/>
+      <incomingpassword/>
+      <incomingservername/>
+   </fields>
+</mailbox>
+<mailbox type="IMAP4">
+   <fields>
+      <name>cr_imap4 mail</name>
+      <ownemail>creator@example.net</ownemail>
+      <copytoself>cc</copytoself>
+      <incomingsslwrapper>yes</incomingsslwrapper>
+      <incomingsecuresockets>yes</incomingsecuresockets>
+      <incomingloginname>creator</incomingloginname>
+      <incomingpassword>creator</incomingpassword>
+      <incomingservername>cr_mail.example.net</incomingservername>
+      <acknowledgereceipts>no</acknowledgereceipts>
+      <autosendonconnect>no</autosendonconnect>
+      <deletemailsatdisconnect>no</deletemailsatdisconnect>
+      <getemailoptions>getbodytextandattachments</getemailoptions>
+   </fields>
+</mailbox>
+</creatorscript>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/scripts/messagesEx.creatorxml	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<creatorscript schemaVersion="1.0" scriptVersion="1.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:noNamespaceSchemaLocation="creator.xsd">
+
+<contact-set id="1">
+   <contact amount="6">
+      <fields>
+         <firstname/>
+         <lastname/>
+         <mobilephonegen/>
+         <emailgen/>
+      </fields>
+   </contact>
+</contact-set>
+
+<message amount="5" type="sms">
+   <fields>
+      <to/>
+      <folder>inbox</folder>
+      <text>This is an example SMS created by Creator.</text>
+      <status>new</status>
+   </fields>
+</message>
+
+<message type="mms">
+   <fields>
+      <to/>
+      <folder>sent</folder>
+      <subject>Good music!</subject>
+      <status>new</status>
+      <attachmentid>MP3-250kB</attachmentid>
+   </fields>
+</message>
+
+<message type="email">
+   <fields>
+      <from>
+         <contact-set-reference id="1"/>
+      </from> 
+      <folder>inbox</folder>
+      <subject/>
+      <text randomlength="max"/>
+      <status>new</status>
+      <attachmentid>JPEG-200kB</attachmentid>
+   </fields>
+</message>
+
+<message amount="5" type="sms">
+   <fields>
+      <from incvalueforeachcopy="true">123456</from>
+      <folder>inbox</folder>
+      <text>This is an example SMS created by Creator.</text>
+      <status>new</status>
+   </fields>
+</message>
+
+</creatorscript>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/scripts/notepadEx.creatorxml	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<creatorscript schemaVersion="1.0" scriptVersion="1.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:noNamespaceSchemaLocation="creator.xsd">
+
+<!-- Create a note -->
+<note>
+    <fields>
+        <text>This is a Creator example note!</text>
+    </fields>
+</note>
+        
+<!-- Create 3 random notes with default content -->
+<note amount="3">
+    <fields>
+        <text/>
+    </fields>
+</note>
+
+<!-- Create a random note with maximum length -->
+<note>
+    <fields>
+        <text randomlength="max"/>
+    </fields>
+</note>
+
+</creatorscript>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/sis/Creator_S60-30.pkg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,75 @@
+;
+; 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:
+;
+
+
+; Language - standard language definitions
+&EN
+
+; Standard SIS file header
+#{"Creator"},(0x20011383),5,3,5,TYPE=SA
+
+; Supports S60 v 3.0
+[0x101F7961], 0, 0, 0, {"S60ProductID"}
+
+; Non-localised vendor name
+:"Nokia Corporation"
+
+; Localised vendor names
+%{"Nokia Corporation"}
+
+; normal stuff:
+"\epoc32\RELEASE\armv5\UREL\Creator.exe"-"!:\sys\bin\Creator.exe"
+"\epoc32\data\z\Resource\apps\Creator_aif.mif"-"!:\Resource\Apps\Creator_aif.mif"
+"\epoc32\data\z\Resource\apps\Creator.rsc"-"!:\Resource\Apps\Creator.rsc"
+"\epoc32\data\z\PRIVATE\10003A3F\APPS\Creator_reg.rsc"-"!:\private\10003a3f\import\apps\Creator_reg.rsc"
+"..\group\backup_registration.xml"-"!:\private\20011383\backup_registration.xml"
+
+; test data:
+"\epoc32\data\Z\private\20011383\3GPP-70kB.3gpp"-"!:\private\20011383\3GPP-70kB.3gpp"
+"\epoc32\data\Z\private\20011383\AAC-100kB.aac"-"!:\private\20011383\AAC-100kB.aac"
+"\epoc32\data\Z\private\20011383\AMR-20kB.amr"-"!:\private\20011383\AMR-20kB.amr"
+"\epoc32\data\Z\private\20011383\BMP-25kB.bmp"-"!:\private\20011383\BMP-25kB.bmp"
+"\epoc32\data\Z\private\20011383\Deck-1kB.saveddeck"-"!:\private\20011383\Deck-1kB.saveddeck"
+"\epoc32\data\Z\private\20011383\DOC-20kB.doc"-"!:\private\20011383\DOC-20kB.doc"
+"\epoc32\data\Z\private\20011383\GIF-2kB.gif"-"!:\private\20011383\GIF-2kB.gif"
+"\epoc32\data\Z\private\20011383\HTML-20kB.html"-"!:\private\20011383\HTML-20kB.html"
+"\epoc32\data\Z\private\20011383\JAD-1kB.jad"-"!:\private\20011383\JAD-1kB.jad"
+"\epoc32\data\Z\private\20011383\JAR-10kB.jar"-"!:\private\20011383\JAR-10kB.jar"
+"\epoc32\data\Z\private\20011383\JP2-65kB.jp2"-"!:\private\20011383\JP2-65kB.jp2"
+"\epoc32\data\Z\private\20011383\JPEG-200kB.jpg"-"!:\private\20011383\JPEG-200kB.jpg"
+"\epoc32\data\Z\private\20011383\JPEG-25kB.jpg"-"!:\private\20011383\JPEG-25kB.jpg"
+"\epoc32\data\Z\private\20011383\JPEG-500kB.jpg"-"!:\private\20011383\JPEG-500kB.jpg"
+"\epoc32\data\Z\private\20011383\MIDI-10kB.mid"-"!:\private\20011383\MIDI-10kB.mid"
+"\epoc32\data\Z\private\20011383\MP3-250kB.mp3"-"!:\private\20011383\MP3-250kB.mp3"
+"\epoc32\data\Z\private\20011383\MP4-200kB.mp4"-"!:\private\20011383\MP4-200kB.mp4"
+"\epoc32\data\Z\private\20011383\MXMF-40kB.mxmf"-"!:\private\20011383\MXMF-40kB.mxmf"
+"\epoc32\data\Z\private\20011383\PNG-15kB.png"-"!:\private\20011383\PNG-15kB.png"
+"\epoc32\data\Z\private\20011383\PPT-40kB.ppt"-"!:\private\20011383\PPT-40kB.ppt"
+"\epoc32\data\Z\private\20011383\RAM-1kB.ram"-"!:\private\20011383\RAM-1kB.ram"
+"\epoc32\data\Z\private\20011383\RM-95kB.rm"-"!:\private\20011383\RM-95kB.rm"
+"\epoc32\data\Z\private\20011383\RNG-1kB.rng"-"!:\private\20011383\RNG-1kB.rng"
+"\epoc32\data\Z\private\20011383\SVG-15kB.svg"-"!:\private\20011383\SVG-15kB.svg"
+"\epoc32\data\Z\private\20011383\SWF-15kB.swf"-"!:\private\20011383\SWF-15kB.swf"
+"\epoc32\data\Z\private\20011383\TIF-25kB.tif"-"!:\private\20011383\TIF-25kB.tif"
+"\epoc32\data\Z\private\20011383\TXT-10kB.txt"-"!:\private\20011383\TXT-10kB.txt"
+"\epoc32\data\Z\private\20011383\TXT-70kB.txt"-"!:\private\20011383\TXT-70kB.txt"
+"\epoc32\data\Z\private\20011383\VCF-1kB.vcf"-"!:\private\20011383\VCF-1kB.vcf"
+"\epoc32\data\Z\private\20011383\VCS-1kB.vcs"-"!:\private\20011383\VCS-1kB.vcs"
+"\epoc32\data\Z\private\20011383\WAV-20kB.wav"-"!:\private\20011383\WAV-20kB.wav"
+"\epoc32\data\Z\private\20011383\XLS-15kB.xls"-"!:\private\20011383\XLS-15kB.xls"
+"\epoc32\data\Z\private\20011383\SISX-10kB.sisx"-"!:\private\20011383\SISX-10kB.sisx"
+"\epoc32\data\Z\private\20011383\WMA-50kB.wma"-"!:\private\20011383\WMA-50kB.wma"
+"\epoc32\data\Z\private\20011383\WMV-200kB.wmv"-"!:\private\20011383\WMV-200kB.wmv"
Binary file creator/sis/Creator_S60-30.sis has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/sis/Creator_S60-32.pkg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,75 @@
+;
+; 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:
+;
+
+
+; Language - standard language definitions
+&EN
+
+; Standard SIS file header
+#{"Creator"},(0x20011383),5,3,5,TYPE=SA
+
+; Supports S60 v 3.2
+[0x102752AE], 0, 0, 0, {"S60ProductID"}
+
+; Non-localised vendor name
+:"Nokia Corporation"
+
+; Localised vendor names
+%{"Nokia Corporation"}
+
+; normal stuff:
+"\epoc32\RELEASE\armv5\UREL\Creator.exe"-"!:\sys\bin\Creator.exe"
+"\epoc32\data\z\Resource\apps\Creator_aif.mif"-"!:\Resource\Apps\Creator_aif.mif"
+"\epoc32\data\z\Resource\apps\Creator.rsc"-"!:\Resource\Apps\Creator.rsc"
+"\epoc32\data\z\PRIVATE\10003A3F\APPS\Creator_reg.rsc"-"!:\private\10003a3f\import\apps\Creator_reg.rsc"
+"..\group\backup_registration.xml"-"!:\private\20011383\backup_registration.xml"
+
+; test data:
+"\epoc32\data\Z\private\20011383\3GPP-70kB.3gpp"-"!:\private\20011383\3GPP-70kB.3gpp"
+"\epoc32\data\Z\private\20011383\AAC-100kB.aac"-"!:\private\20011383\AAC-100kB.aac"
+"\epoc32\data\Z\private\20011383\AMR-20kB.amr"-"!:\private\20011383\AMR-20kB.amr"
+"\epoc32\data\Z\private\20011383\BMP-25kB.bmp"-"!:\private\20011383\BMP-25kB.bmp"
+"\epoc32\data\Z\private\20011383\Deck-1kB.saveddeck"-"!:\private\20011383\Deck-1kB.saveddeck"
+"\epoc32\data\Z\private\20011383\DOC-20kB.doc"-"!:\private\20011383\DOC-20kB.doc"
+"\epoc32\data\Z\private\20011383\GIF-2kB.gif"-"!:\private\20011383\GIF-2kB.gif"
+"\epoc32\data\Z\private\20011383\HTML-20kB.html"-"!:\private\20011383\HTML-20kB.html"
+"\epoc32\data\Z\private\20011383\JAD-1kB.jad"-"!:\private\20011383\JAD-1kB.jad"
+"\epoc32\data\Z\private\20011383\JAR-10kB.jar"-"!:\private\20011383\JAR-10kB.jar"
+"\epoc32\data\Z\private\20011383\JP2-65kB.jp2"-"!:\private\20011383\JP2-65kB.jp2"
+"\epoc32\data\Z\private\20011383\JPEG-200kB.jpg"-"!:\private\20011383\JPEG-200kB.jpg"
+"\epoc32\data\Z\private\20011383\JPEG-25kB.jpg"-"!:\private\20011383\JPEG-25kB.jpg"
+"\epoc32\data\Z\private\20011383\JPEG-500kB.jpg"-"!:\private\20011383\JPEG-500kB.jpg"
+"\epoc32\data\Z\private\20011383\MIDI-10kB.mid"-"!:\private\20011383\MIDI-10kB.mid"
+"\epoc32\data\Z\private\20011383\MP3-250kB.mp3"-"!:\private\20011383\MP3-250kB.mp3"
+"\epoc32\data\Z\private\20011383\MP4-200kB.mp4"-"!:\private\20011383\MP4-200kB.mp4"
+"\epoc32\data\Z\private\20011383\MXMF-40kB.mxmf"-"!:\private\20011383\MXMF-40kB.mxmf"
+"\epoc32\data\Z\private\20011383\PNG-15kB.png"-"!:\private\20011383\PNG-15kB.png"
+"\epoc32\data\Z\private\20011383\PPT-40kB.ppt"-"!:\private\20011383\PPT-40kB.ppt"
+"\epoc32\data\Z\private\20011383\RAM-1kB.ram"-"!:\private\20011383\RAM-1kB.ram"
+"\epoc32\data\Z\private\20011383\RM-95kB.rm"-"!:\private\20011383\RM-95kB.rm"
+"\epoc32\data\Z\private\20011383\RNG-1kB.rng"-"!:\private\20011383\RNG-1kB.rng"
+"\epoc32\data\Z\private\20011383\SVG-15kB.svg"-"!:\private\20011383\SVG-15kB.svg"
+"\epoc32\data\Z\private\20011383\SWF-15kB.swf"-"!:\private\20011383\SWF-15kB.swf"
+"\epoc32\data\Z\private\20011383\TIF-25kB.tif"-"!:\private\20011383\TIF-25kB.tif"
+"\epoc32\data\Z\private\20011383\TXT-10kB.txt"-"!:\private\20011383\TXT-10kB.txt"
+"\epoc32\data\Z\private\20011383\TXT-70kB.txt"-"!:\private\20011383\TXT-70kB.txt"
+"\epoc32\data\Z\private\20011383\VCF-1kB.vcf"-"!:\private\20011383\VCF-1kB.vcf"
+"\epoc32\data\Z\private\20011383\VCS-1kB.vcs"-"!:\private\20011383\VCS-1kB.vcs"
+"\epoc32\data\Z\private\20011383\WAV-20kB.wav"-"!:\private\20011383\WAV-20kB.wav"
+"\epoc32\data\Z\private\20011383\XLS-15kB.xls"-"!:\private\20011383\XLS-15kB.xls"
+"\epoc32\data\Z\private\20011383\SISX-10kB.sisx"-"!:\private\20011383\SISX-10kB.sisx"
+"\epoc32\data\Z\private\20011383\WMA-50kB.wma"-"!:\private\20011383\WMA-50kB.wma"
+"\epoc32\data\Z\private\20011383\WMV-200kB.wmv"-"!:\private\20011383\WMV-200kB.wmv"
Binary file creator/sis/Creator_S60-32.sis has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/sis/Creator_stub.pkg	Tue Feb 02 00:17:27 2010 +0200
@@ -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:
+;
+
+
+; Language - standard language definitions
+&EN
+
+; Standard SIS file header
+#{"Creator"},(0x20011383),1,0,0
+
+; Non-localised vendor name
+:"Nokia Corporation"
+
+; Localised vendor names
+%{"Nokia Corporation"}
+
+; normal stuff:
+""-"z:\sys\bin\creator.exe"
+""-"z:\resource\apps\creator_aif.mif"
+""-"z:\resource\apps\creator.rsc"
+""-"z:\private\10003a3f\import\apps\creator_reg.rsc"
+""-"z:\private\20011383\backup_registration.xml"
+
+; test data:
+""-"z:\private\20011383\3GPP-70kB.3gpp"
+""-"z:\private\20011383\AAC-100kB.aac"
+""-"z:\private\20011383\AMR-20kB.amr"
+""-"z:\private\20011383\BMP-25kB.bmp"
+""-"z:\private\20011383\Deck-1kB.saveddeck"
+""-"z:\private\20011383\DOC-20kB.doc"
+""-"z:\private\20011383\GIF-2kB.gif"
+""-"z:\private\20011383\HTML-20kB.html"
+""-"z:\private\20011383\JAD-1kB.jad"
+""-"z:\private\20011383\JAR-10kB.jar"
+""-"z:\private\20011383\JP2-65kB.jp2"
+""-"z:\private\20011383\JPEG-200kB.jpg"
+""-"z:\private\20011383\JPEG-25kB.jpg"
+""-"z:\private\20011383\JPEG-500kB.jpg"
+""-"z:\private\20011383\MIDI-10kB.mid"
+""-"z:\private\20011383\MP3-250kB.mp3"
+""-"z:\private\20011383\MP4-200kB.mp4"
+""-"z:\private\20011383\MXMF-40kB.mxmf"
+""-"z:\private\20011383\PNG-15kB.png"
+""-"z:\private\20011383\PPT-40kB.ppt"
+""-"z:\private\20011383\RAM-1kB.ram"
+""-"z:\private\20011383\RM-95kB.rm"
+""-"z:\private\20011383\RNG-1kB.rng"
+""-"z:\private\20011383\SVG-15kB.svg"
+""-"z:\private\20011383\SWF-15kB.swf"
+""-"z:\private\20011383\TIF-25kB.tif"
+""-"z:\private\20011383\TXT-10kB.txt"
+""-"z:\private\20011383\TXT-70kB.txt"
+""-"z:\private\20011383\VCF-1kB.vcf"
+""-"z:\private\20011383\VCS-1kB.vcs"
+""-"z:\private\20011383\WAV-20kB.wav"
+""-"z:\private\20011383\XLS-15kB.xls"
+""-"z:\private\20011383\SISX-10kB.sisx"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#include "creator_app.h"
+
+#include <eikstart.h>
+
+
+LOCAL_C CApaApplication* NewApplication()
+    {
+    return new CCreatorApplication;
+    }
+
+
+GLDEF_C TInt E32Main()
+    {
+    return EikStart::RunApplication(NewApplication);
+    }
+    
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_accesspoint.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,469 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#include "creator_accesspoint.h" 
+#include "creator_traces.h"
+#include <aplistitemlist.h>
+#include <aplistitem.h> 
+
+static const TInt KAccessPointsFieldLength = 128;
+
+_LIT(KCreatorAccessPointsPrefixName, "CR_");
+_LIT(KZeroIP, "0.0.0.0");
+
+//----------------------------------------------------------------------------
+
+CAccessPointsParameters::CAccessPointsParameters()
+    {
+    LOGSTRING("Creator: CAccessPointsParameters::CAccessPointsParameters");
+
+    iConnectionName = HBufC::New(KAccessPointsFieldLength);
+    iWapStartPage = HBufC::New(KAccessPointsFieldLength);
+    iGprsAcessPointName = HBufC::New(KAccessPointsFieldLength);
+    iIspLoginName = HBufC::New(KAccessPointsFieldLength);
+    iIspLoginPass = HBufC::New(KAccessPointsFieldLength);
+    iWapGatewayAddress = HBufC::New(KAccessPointsFieldLength);
+    iIspIPAddr = HBufC::New(KAccessPointsFieldLength);
+    iIspIPNameServer1 = HBufC::New(KAccessPointsFieldLength);
+    iIspIPNameServer2 = HBufC::New(KAccessPointsFieldLength);
+    iIspDefaultTelNumber = HBufC::New(KAccessPointsFieldLength);
+    iProxyServerAddress = HBufC::New(KAccessPointsFieldLength);
+    }
+
+CAccessPointsParameters::~CAccessPointsParameters()
+    {
+    LOGSTRING("Creator: CAccessPointsParameters::~CAccessPointsParameters");
+
+    delete iProxyServerAddress;
+    delete iIspDefaultTelNumber;
+    delete iIspIPNameServer2;
+    delete iIspIPNameServer1;
+    delete iIspIPAddr;
+    delete iWapGatewayAddress;
+    delete iIspLoginPass;
+    delete iIspLoginName;
+    delete iGprsAcessPointName;
+    delete iWapStartPage;
+    delete iConnectionName;
+    }
+
+void CAccessPointsParameters::SetRandomCMNameL(CCreatorEngine& aEngine)
+	{
+	TInt num = aEngine.RandomNumber(1, 3);
+	TBuf<10> apType;
+
+	if (num==1)
+		apType = _L("mms");
+	else if (num==2)
+		apType = _L("wap");
+	else
+		apType = _L("internet");
+
+	TBuf<160> company = aEngine.RandomString(CCreatorEngine::ECompany);
+
+	iConnectionName->Des() = KCreatorAccessPointsPrefixName;
+	iConnectionName->Des().Append( company );
+	iConnectionName->Des().Append(_L(" "));
+	iConnectionName->Des().Append(apType);
+	}
+
+void CAccessPointsParameters::SetRandomLoginNameL(CCreatorEngine& aEngine)
+	{
+	iIspLoginName->Des() = aEngine.RandomString(CCreatorEngine::EFirstName);
+	iIspLoginName->Des().LowerCase();
+	}
+
+void CAccessPointsParameters::SetRandomLoginPassL(CCreatorEngine& /*aEngine*/)
+	{}
+
+void CAccessPointsParameters::SetRandomSecureAuthenticationL(CCreatorEngine& /*aEngine*/)
+	{}
+
+void CAccessPointsParameters::SetRandomPromptPasswordL(CCreatorEngine& /*aEngine*/)
+	{}
+
+void CAccessPointsParameters::SetRandomProxyAddressL(CCreatorEngine& /*aEngine*/)
+	{}
+
+void CAccessPointsParameters::SetRandomProxyPortL(CCreatorEngine& /*aEngine*/)
+	{}
+
+void CAccessPointsParameters::SetRandomStartPageL(CCreatorEngine& /*aEngine*/)
+	{}
+
+void CAccessPointsParameters::SetRandomIPAddressL(CCreatorEngine& /*aEngine*/)
+	{}
+
+void CAccessPointsParameters::SetRandomIP4NameServer1L(CCreatorEngine& /*aEngine*/)
+	{}
+
+void CAccessPointsParameters::SetRandomIP4NameServer2L(CCreatorEngine& /*aEngine*/)
+	{}
+
+void CAccessPointsParameters::SetRandomTelephoneNumberL(CCreatorEngine& /*aEngine*/)
+	{}
+
+void CAccessPointsParameters::SetRandomBearerTypeIsdnL(CCreatorEngine& /*aEngine*/)
+	{}
+
+void CAccessPointsParameters::SetRandomBearerSpeedL(CCreatorEngine& /*aEngine*/)
+	{}
+
+void CAccessPointsParameters::SetRandomWapWspOptionL(CCreatorEngine& /*aEngine*/)
+	{}
+
+void CAccessPointsParameters::SetRandomGatewayAddressL(CCreatorEngine& /*aEngine*/)
+	{}
+
+//----------------------------------------------------------------------------
+
+CCreatorAccessPoints* CCreatorAccessPoints::NewL(CCreatorEngine* aEngine)
+    {
+    CCreatorAccessPoints* self = CCreatorAccessPoints::NewLC(aEngine);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CCreatorAccessPoints* CCreatorAccessPoints::NewLC(CCreatorEngine* aEngine)
+    {
+    CCreatorAccessPoints* self = new (ELeave) CCreatorAccessPoints;
+    CleanupStack::PushL(self);
+    self->ConstructL(aEngine);
+    return self;
+    }
+
+CCreatorAccessPoints::CCreatorAccessPoints()
+    {
+    }
+
+void CCreatorAccessPoints::ConstructL(CCreatorEngine* aEngine)
+    {
+    LOGSTRING("Creator: CCreatorAccessPoints::ConstructL");
+
+    iEngine = aEngine;
+
+    iCommsDb = CCommsDatabase::NewL();;
+    iApDataHandler = CApDataHandler::NewLC(*iCommsDb);
+    CleanupStack::Pop();
+    iApUtils = CApUtils::NewLC(*iCommsDb);
+    CleanupStack::Pop();
+    }
+
+CCreatorAccessPoints::~CCreatorAccessPoints()
+    {
+    LOGSTRING("Creator: CCreatorAccessPoints::~CCreatorAccessPoints");
+
+    if ( iEngine && iEntryIds.Count() )
+        {
+        TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iEntryIds, KUidDictionaryUidIAP ) );
+        }
+    iEntryIds.Reset();
+    iEntryIds.Close();
+    
+    delete iApUtils;
+    delete iApDataHandler;
+    delete iCommsDb;
+
+    if (iParameters)
+        delete iParameters;
+    }
+
+//----------------------------------------------------------------------------
+
+TBool CCreatorAccessPoints::AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries)
+    {
+    LOGSTRING("Creator: CCreatorAccessPoints::AskDataFromUserL");
+
+    if( aCommand == ECmdDeleteIAPs )
+        {
+        return iEngine->YesNoQueryDialogL(_L("Delete all Access Points?") );
+        }
+    else if( aCommand == ECmdDeleteCreatorIAPs )
+        {
+        return iEngine->YesNoQueryDialogL(_L("Delete all Access Points created with Creator?") );
+        }
+
+    return iEngine->EntriesQueryDialogL(aNumberOfEntries, _L("How many entries to create?"));
+    }
+
+
+//----------------------------------------------------------------------------
+
+TInt CCreatorAccessPoints::CreateConnectionSettingsEntryL(CCreatorModuleBaseParameters *aParameters)
+    {
+    LOGSTRING("Creator: CCreatorAccessPoints::CreateAccessPointEntryL");
+
+    CAccessPointsParameters* parameters = (CAccessPointsParameters*) aParameters;
+    
+    // clear any existing parameter definations
+    delete iParameters;
+    iParameters = NULL;
+    
+    
+            
+    // random data needed if no predefined data available
+    if (!parameters)
+        {
+        TBuf<160> company = iEngine->RandomString(CCreatorEngine::ECompany);
+        TInt num = iEngine->RandomNumber(1, 3);
+        TBuf<10> apType;
+        
+        if (num==1)
+            apType = _L("mms");
+        else if (num==2)
+            apType = _L("wap");
+        else
+            apType = _L("internet");
+        
+        iParameters = new(ELeave) CAccessPointsParameters;
+        parameters = iParameters;
+
+        parameters->SetRandomCMNameL(*iEngine);
+
+        // in random mode just create GPRS access points
+        parameters->iBearerType = EApBearerTypeGPRS;
+
+        parameters->SetRandomLoginNameL(*iEngine);
+
+        iParameters->iIspLoginPass->Des() = iEngine->RandomString(CCreatorEngine::ESurname);
+        iParameters->iIspLoginPass->Des().LowerCase();
+
+        iParameters->iSecureAuthentication = EFalse;
+        iParameters->iPromptPassword = EFalse;
+
+        iParameters->iProxyServerAddress->Des() = _L("127.0.0.1");
+        iParameters->iProxyPortNumber = 80;
+
+        iParameters->iWapStartPage->Des() = _L("http://");
+        iParameters->iWapStartPage->Des().Append(apType);
+        iParameters->iWapStartPage->Des().Append(_L("."));
+        iParameters->iWapStartPage->Des().Append(company);
+        iParameters->iWapStartPage->Des().Append(_L(".com"));
+        iParameters->iWapStartPage->Des().LowerCase();
+
+        iParameters->iIspIPAddr->Des() = KZeroIP;
+        iParameters->iIspIPNameServer1->Des() = KZeroIP;
+        iParameters->iIspIPNameServer1->Des() = KZeroIP;
+        iParameters->iGprsAcessPointName->Des() = apType;
+        iParameters->iIspDefaultTelNumber->Des() = iEngine->RandomString(CCreatorEngine::EPhoneNumber);
+        iParameters->iIspBearerCallTypeIsdn = ECallTypeISDNv110;
+        iParameters->iIspBearerSpeed = KSpeed14400;
+
+        iParameters->iWapWspOption = EWapWspOptionConnectionOriented;
+        iParameters->iWapGatewayAddress->Des() = KZeroIP;
+        }
+    else
+        {
+        // otherwise replace the parameters object
+        iParameters = parameters;
+        }
+
+    TInt err = KErrNone;
+
+    // access point item
+    CApAccessPointItem* apItem = CApAccessPointItem::NewLC();
+
+    // set the bearer type, if it fails try to set a default type
+    TRAPD(bearerErr, apItem->SetBearerTypeL(iParameters->iBearerType));
+    if (bearerErr != KErrNone)
+        {
+        iParameters->iBearerType = EApBearerTypeGPRS;
+        TRAPD(bearerErr2, apItem->SetBearerTypeL(iParameters->iBearerType));
+        bearerErr2=bearerErr2;
+        }
+
+    if (iParameters->iBearerType == EApBearerTypeGPRS) // GPRS
+        {
+        err = apItem->WriteLongTextL(EApGprsAccessPointName, iParameters->iGprsAcessPointName->Des());
+        }
+    else  // CSD or HCSD
+        {
+        err = apItem->WriteTextL(EApIspDefaultTelNumber, iParameters->iIspDefaultTelNumber->Des());
+        err = apItem->WriteUint(EApIspBearerCallTypeIsdn, iParameters->iIspBearerCallTypeIsdn);
+        err = apItem->WriteUint(EApIspBearerSpeed, iParameters->iIspBearerSpeed);
+        }
+
+    err = apItem->WriteTextL(EApIspLoginName, iParameters->iIspLoginName->Des());
+    err = apItem->WriteTextL(EApIspIfAuthName, iParameters->iIspLoginName->Des());
+    err = apItem->WriteTextL(EApIspLoginPass, iParameters->iIspLoginPass->Des());
+    err = apItem->WriteTextL(EApIspIfAuthPass, iParameters->iIspLoginPass->Des());
+    err = apItem->WriteTextL(EApGprsIfAuthPassword, iParameters->iIspLoginPass->Des());
+    err = apItem->WriteBool(EApIspDisablePlainTextAuth, iParameters->iSecureAuthentication);
+    err = apItem->WriteBool(EApIspPromptForLogin, iParameters->iPromptPassword);
+    err = apItem->WriteTextL(EApWapGatewayAddress, iParameters->iWapGatewayAddress->Des());
+    err = apItem->WriteLongTextL(EApProxyServerAddress, iParameters->iProxyServerAddress->Des());
+    err = apItem->WriteUint(EApProxyPortNumber, iParameters->iProxyPortNumber);
+    err = apItem->WriteLongTextL(EApWapStartPage, iParameters->iWapStartPage->Des());
+    err = apItem->WriteUint(EApWapWspOption, iParameters->iWapWspOption);
+    err = apItem->WriteTextL(EApGprsIPNameServer1, iParameters->iIspIPNameServer1->Des());
+    err = apItem->WriteTextL(EApGprsIPNameServer2, iParameters->iIspIPNameServer2->Des());
+    err = apItem->WriteTextL(EApIspIPAddr, iParameters->iIspIPAddr->Des());
+
+
+    TUint32 uid = iApDataHandler->CreateFromDataL(*apItem);  // save the access point, returns the uid of the AP
+
+    // id has been generated, store it for being able to delete
+    // entries created only with Creator
+    iEntryIds.Append( uid );
+        
+    TBuf<256> name = iParameters->iConnectionName->Des();
+    iApUtils->SetNameL(name, uid); // sets the AP name
+
+
+    // if no defaults set, set the created AP as a default
+
+    // MMS access point
+    if (iParameters->iWapStartPage->Des().FindF(_L("mms")) >=0  ||  iParameters->iConnectionName->Des().FindF(_L("mms")) >=0 )
+        {
+        //User::Panic(_L("Not done yet..."), 123);
+        }
+
+
+    // WAP access point
+    else if (iParameters->iConnectionName->Des().FindF(_L("wap")) >=0  ||  iParameters->iGprsAcessPointName->Des().FindF(_L("wap")) >= 0)
+        {
+        TUint32 defID = 0;
+        TRAP( err, defID = iApDataHandler->DefaultL(ETrue) );  // ETrue==WAP
+
+        if (defID <= 1)
+            TRAP( err, iApDataHandler->SetAsDefaultL(uid, EIspTypeWAPOnly) );
+
+        }
+
+    // Internet access point
+    else if (iParameters->iConnectionName->Des().FindF(_L("internet")) >=0  ||  iParameters->iGprsAcessPointName->Des().FindF(_L("internet")) >= 0)
+        {
+        TUint32 defID = 0;
+        TRAP( err, defID = iApDataHandler->DefaultL(EFalse) );  // EFalse==IAP
+
+        if (defID <= 1)
+            TRAP( err, iApDataHandler->SetAsDefaultL(uid, EIspTypeInternetOnly) );  //  <--  POSSIBLY NOT CORRECT, NEEDS MORE TESTING
+        }
+
+
+
+    CleanupStack::PopAndDestroy(); //apItem
+
+    return err;
+    }
+
+//----------------------------------------------------------------------------
+
+TUint32 CCreatorAccessPoints::AccessPointNameToIdL(const TDesC& aAPName, TBool /*aAnyIfNotFound*/ )
+    {
+    LOGSTRING("Creator: CCreatorEngine::AccessPointNameToIdL");
+
+    TBuf<256> apName = aAPName.Left(256);
+    apName.Trim();
+
+    TUint32 APId = iEngine->GetDefaultIAPL();
+
+    // return default IAP if requested
+    if (apName.CompareF(_L("DEFAULT-IAP")) == 0 || apName.CompareF(_L("DEFAULT")) == 0)
+        {
+        return APId;
+        }
+
+    CCommsDatabase* db = CCommsDatabase::NewL(EDatabaseTypeIAP);
+    CleanupStack::PushL(db);
+    CApUtils* apUtils = CApUtils::NewLC(*db);
+    CApSelect* apSelect = CApSelect::NewLC(*db, KEApIspTypeAll, EApBearerTypeAll, KEApSortNameAscending);
+
+
+    // loop through all access points and try to find a matching name
+    if (apSelect->MoveToFirst())
+        {
+        do
+            {
+            TBuf<256> apName2;
+            apUtils->NameL(apSelect->Uid(), apName2);
+            apName2.Trim();
+
+            if (apName2.CompareF( apName ) == 0)
+                {
+                // match found, get uid and break the loop
+                TRAPD( err, APId = apUtils->IapIdFromWapIdL(apSelect->Uid()) );
+                err=err;
+                break;
+                }
+            }
+        while (apSelect->MoveNext());
+        }
+
+    CleanupStack::PopAndDestroy(3);  //apSelect, apUtils, db
+
+    return APId;
+    }
+
+//----------------------------------------------------------------------------
+
+void CCreatorAccessPoints::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) // from MMsvSessionObserver
+    {
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorAccessPoints::DeleteAllL()
+    {
+    LOGSTRING("Creator: CCreatorEngine::DeleteAllL");
+    
+    CApSelect* selector = CApSelect::NewLC( *iCommsDb, 
+                                            KEApIspTypeAll,
+                                            EApBearerTypeAllBearers,
+                                            KEApSortUidAscending );
+    
+    CApListItemList* list = new (ELeave) CApListItemList();
+    CleanupStack::PushL( list );
+    TInt count = selector->AllListItemDataL( *list );
+    for ( TInt i = 0; i < count; i++ )
+        {
+        TRAP_IGNORE( iApDataHandler->RemoveAPL( (*list)[i]->Uid() ) );
+        }
+
+    CleanupStack::PopAndDestroy( list );
+    CleanupStack::PopAndDestroy( selector );
+
+    // reset must be done here, because iEntryIds is stored in destructor
+    iEntryIds.Reset();
+    
+    // all entries deleted, remove the Logs related registry
+    iEngine->RemoveStoreL( KUidDictionaryUidIAP );
+    }
+
+//----------------------------------------------------------------------------
+
+void CCreatorAccessPoints::DeleteAllCreatedByCreatorL()
+    {
+    LOGSTRING("Creator: CCreatorEngine::DeleteAllCreatedByCreatorL");
+    iEntryIds.Reset();
+    
+    // fetch ids of entries created by Creator
+    iEngine->ReadEntryIdsFromStoreL( iEntryIds, KUidDictionaryUidIAP );
+    
+    // delete entries
+    for ( TInt i = 0; i < iEntryIds.Count(); i++ )
+        {
+        TRAP_IGNORE( iApDataHandler->RemoveAPL( iEntryIds[i] ) );
+        }
+    
+    // reset must be done here, because iEntryIds is stored in destructor
+    iEntryIds.Reset();
+    
+    // all entries deleted, remove the Logs related registry
+    iEngine->RemoveStoreL( KUidDictionaryUidIAP );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_app.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include "creator_document.h"
+#include "creator_app.h"
+
+CApaDocument* CCreatorApplication::CreateDocumentL()
+    {  
+    // Create an Creator document, and return a pointer to it
+    CApaDocument* document = CCreatorDocument::NewL(*this);
+    return document;
+    }
+
+TUid CCreatorApplication::AppDllUid() const
+    {
+    // Return the UID for the Creator application
+    return KUidCreatorApp;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_appui.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,360 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include <creator.rsg>
+
+#include "creator.pan"
+#include "creator_appui.h"
+#include "creator_container.h"
+#include "creator.hrh"
+
+#include <bautils.h>
+#include <pathinfo.h> 
+#include <aknmessagequerydialog.h> 
+#include <eikmenub.h>
+#include <akntitle.h>
+#include <akncontext.h>
+#include <aknnotewrappers.h>
+#include <avkon.hrh>
+
+// delay before script running and application exiting in seconds
+// when script is run from command line
+const TInt KCommandLineDelay = 3;
+
+// ConstructL is called by the application framework
+void CCreatorAppUi::ConstructL()
+    {
+    BaseConstructL(EAknEnableSkin);
+
+    iAppView = CCreatorAppView::NewL(ClientRect());    
+
+    AddToStackL(iAppView);
+
+    iEnv=CEikonEnv::Static();
+
+    iEngine = CCreatorEngine::NewL(this);
+ 
+	iMode = ETimerModeNone;
+	iTickCount = 0;
+    iTimer = CHeartbeat::NewL(0);
+    
+    // parse script name and random data file name from command line
+    iCommandLineScriptName = HBufC::NewL(User::CommandLineLength());
+    iCommandLineRandomDataFileName = HBufC::NewL(User::CommandLineLength());
+    HBufC* commandLine = HBufC::NewLC(User::CommandLineLength());
+    TPtr16 ptr = commandLine->Des();
+    User::CommandLine(ptr);
+    commandLine->Des().Trim();
+    
+    TInt pos = commandLine->Des().Find(_L(" "));
+    if (pos != KErrNotFound)
+    	{
+    	iCommandLineScriptName->Des().Copy(commandLine->Des().Left(pos));
+    	iCommandLineRandomDataFileName->Des().Copy(commandLine->Des().Mid(pos));
+    	iCommandLineRandomDataFileName->Des().Trim();
+    	}
+    else
+    	{
+    	iCommandLineScriptName->Des().Copy(commandLine->Des());
+    	iCommandLineRandomDataFileName->Des().Copy(KNullDesC);
+    	}
+
+    CleanupStack::PopAndDestroy(commandLine);
+    
+    if (iCommandLineScriptName->Des().Length() > 0)
+    	{
+    	iMode = ETimerModeStartScript;
+    	iTimer->Start(ETwelveOClock, this);
+    	}
+    }
+
+
+CCreatorAppUi::CCreatorAppUi()                              
+    {
+    // add any construction that cannot leave here
+    }
+
+
+CCreatorAppUi::~CCreatorAppUi()
+    {
+
+    delete iCommandLineRandomDataFileName;
+    delete iCommandLineScriptName;
+    
+    if (iTimer)
+    	{
+    	iTimer->Cancel();
+        delete iTimer;
+        iTimer = NULL;
+    	}
+    
+    delete iEngine;
+
+	if (iAppView)
+        {
+		RemoveFromStack(iAppView);
+        delete iAppView;
+        iAppView = NULL;
+        }
+    }
+
+
+// handle any menu commands
+void CCreatorAppUi::HandleCommandL(TInt aCommand)
+    {
+    switch(aCommand)
+        {
+        // main menus, not assigned to any commands
+	    case ECmdCreateCalendarEntries:
+	    case ECmdCreateBrowserEntries:
+	    case ECmdCreateFileEntries:
+	    case ECmdCreateLogEntries:
+	    case ECmdCreateMessagingEntries:
+	    case ECmdCreateMiscEntries:
+	    case ECmdCreatePhoneBookEntries:
+            {
+            User::Panic (_L("Unused command"), 102);
+            }
+            break;
+
+        // about
+	    case ECmdAboutCreator:
+            {
+	        CAknMessageQueryDialog* dialog = new (ELeave) CAknMessageQueryDialog;
+            dialog->ExecuteLD(R_CREATOR_ABOUT_DIALOG);
+            }
+            break;
+
+
+        // run script
+        case ECmdCreateFromFile:
+            {
+            iEngine->RunScriptL();
+			}
+			break;
+
+        // select random data file
+        case ECmdSelectRandomDataFile:
+            {
+            TFileName filename;
+            if (iEngine->GetRandomDataFilenameL(filename))
+            	{
+            	iEngine->GetRandomDataFromFileL(filename);
+            	}
+			}
+			break;
+
+
+        // commands:
+	    case ECmdCreateCalendarEntryAppointments:
+	    case ECmdCreateCalendarEntryEvents:
+	    case ECmdCreateCalendarEntryAnniversaries:
+	    case ECmdCreateCalendarEntryToDos:
+	    case ECmdCreateCalendarEntryReminders:
+        
+        case ECmdCreateBrowserBookmarkEntries:
+	    case ECmdCreateBrowserBookmarkFolderEntries:
+	    case ECmdCreateBrowserSavedPageEntries:
+	    case ECmdCreateBrowserSavedPageFolderEntries:
+
+	    case ECmdCreatePhoneBookEntryContacts:
+	    case ECmdCreatePhoneBookEntryGroups:
+
+   	    case ECmdCreateMiscEntryNotes:
+   	    case ECmdCreateMiscEntryLandmarks:
+
+	    case ECmdCreateLogEntryMissedCalls:
+	    case ECmdCreateLogEntryReceivedCalls:
+	    case ECmdCreateLogEntryDialledNumbers:
+
+	    case ECmdCreateMiscEntryAccessPoints:
+  	    case ECmdCreateMiscEntryIMPSServers:
+
+	    case ECmdCreateMessagingEntryMailboxes:
+	    case ECmdCreateMessagingEntryMessages:
+
+	    case ECmdCreateFileEntryEmptyFolder:
+	    case ECmdCreateFileEntry3GPP_70kB:
+	    case ECmdCreateFileEntryAAC_100kB:
+	    case ECmdCreateFileEntryAMR_20kB:
+	    case ECmdCreateFileEntryBMP_25kB:
+	    case ECmdCreateFileEntryDeck_1kB:
+	    case ECmdCreateFileEntryDOC_20kB:
+	    case ECmdCreateFileEntryGIF_2kB:
+	    case ECmdCreateFileEntryHTML_20kB:
+	    case ECmdCreateFileEntryJAD_1kB:
+	    case ECmdCreateFileEntryJAR_10kB:
+	    case ECmdCreateFileEntryJP2_65kB:
+	    case ECmdCreateFileEntryJPEG_200kB:
+	    case ECmdCreateFileEntryJPEG_25kB:
+	    case ECmdCreateFileEntryJPEG_500kB:
+	    case ECmdCreateFileEntryMIDI_10kB:
+	    case ECmdCreateFileEntryMP3_250kB:
+	    case ECmdCreateFileEntryMP4_200kB:
+	    case ECmdCreateFileEntryMXMF_40kB:
+	    case ECmdCreateFileEntryPNG_15kB:
+	    case ECmdCreateFileEntryPPT_40kB:
+	    case ECmdCreateFileEntryRAM_1kB:
+	    case ECmdCreateFileEntryRM_95kB:
+	    case ECmdCreateFileEntryRNG_1kB:
+	    case ECmdCreateFileEntrySVG_15kB:
+	    case ECmdCreateFileEntrySWF_15kB:
+	    case ECmdCreateFileEntryTIF_25kB:
+	    case ECmdCreateFileEntryTXT_10kB:
+	    case ECmdCreateFileEntryTXT_70kB:
+	    case ECmdCreateFileEntryVCF_1kB:
+	    case ECmdCreateFileEntryVCS_1kB:
+	    case ECmdCreateFileEntryWAV_20kB:
+	    case ECmdCreateFileEntryXLS_15kB:
+	    case ECmdCreateFileEntrySISX_10kB:
+	    case ECmdCreateFileEntryWMA_50kB:
+	    case ECmdCreateFileEntryWMV_200kB:
+	    case ECmdDeleteAllEntries:
+	    case ECmdDeleteAllCreatorEntries:
+	    case ECmdDeleteContacts:
+        case ECmdDeleteCreatorContacts:
+        case ECmdDeleteContactGroups:
+        case ECmdDeleteCreatorContactGroups:
+        case ECmdDeleteCalendarEntries:
+        case ECmdDeleteCreatorCalendarEntries:
+        case ECmdDeleteBrowserBookmarks:
+        case ECmdDeleteCreatorBrowserBookmarks:
+        case ECmdDeleteBrowserBookmarkFolders:
+        case ECmdDeleteCreatorBrowserBookmarkFolders:
+        case ECmdDeleteBrowserSavedPages:
+        case ECmdDeleteCreatorBrowserSavedPages:
+        case ECmdDeleteBrowserSavedPageFolders:
+        case ECmdDeleteCreatorBrowserSavedPageFolders:
+        case ECmdDeleteCreatorFiles:
+        case ECmdDeleteLogs:
+        case ECmdDeleteCreatorLogs:
+        case ECmdDeleteMessages:
+        case ECmdDeleteCreatorMessages:
+        case ECmdDeleteMailboxes:
+        case ECmdDeleteCreatorMailboxes:
+        case ECmdDeleteIAPs:
+        case ECmdDeleteCreatorIAPs:
+        case ECmdDeleteIMPSs:
+        case ECmdDeleteCreatorIMPSs:
+        case ECmdDeleteNotes:
+        case ECmdDeleteLandmarks:
+        case ECmdDeleteCreatorLandmarks:
+            {
+            iEngine->ExecuteOptionsMenuCommandL(aCommand);
+            }
+            break;
+
+        case ECmdDeleteEntries:
+        case ECmdCreatePhoneBookEntrySubscribedContacts:
+	    case ECmdCreateMessagingEntryCBSTopics:
+	    case ECmdCreateMessagingEntrySMSMessageCenters:
+	    case ECmdCreateMessagingEntryTemplates:
+	    case ECmdCreateMiscEntryAppMenuFolders:
+	    case ECmdCreateMiscEntrySyncSettings:
+        case ECmdCreateMessagingEntryDocumentsFolders:
+            {
+            CAknInformationNote* note = new(ELeave) CAknInformationNote;
+            note->ExecuteLD(_L("Please contact S60 CO if you need this feature..."));
+            }
+            break;
+
+		case EEikCmdExit:
+		case EAknSoftkeyExit:
+			{
+			Exit();
+			}
+            break;
+
+        default:
+            User::Panic (_L("Invalid command"), 101);
+            break;
+        }
+    }
+
+
+void CCreatorAppUi::DynInitMenuPaneL( TInt /*aResourceId*/, CEikMenuPane* /*aMenuPane*/ )
+	{
+	}
+
+void CCreatorAppUi::RunScriptDone()
+	{
+	if (iMode == ETimerModeStartScript)
+		{
+		iMode = ETimerModeExitAppUi;
+		iTimer->Start(ETwelveOClock, this);
+		}
+	}
+
+void CCreatorAppUi::Beat()
+	{
+	Tick();
+	}
+
+void CCreatorAppUi::Synchronize()
+	{
+	Tick();
+	}
+
+void CCreatorAppUi::Tick()
+	{
+	iTickCount++;
+	if (iTickCount > KCommandLineDelay)
+		{
+		iTimer->Cancel();
+		iTickCount = 0;
+		if (iMode == ETimerModeStartScript)
+			{
+        	iEngine->GetRandomDataFromFileL(*iCommandLineRandomDataFileName);
+			TInt status = iEngine->RunScriptL(*iCommandLineScriptName);
+			if (status != KErrNone)
+				{
+				TBuf<128> noteMsg;
+				if (status == KErrNotFound)
+					{
+					_LIT(KMessage1, "Error in opening script file.");
+					noteMsg.Copy(KMessage1);
+					}
+				else if (status == KErrCorrupt)
+					{
+					_LIT(KMessage2, "Error in parsing script file.");
+					noteMsg.Copy(KMessage2);
+					}
+				else if (status == KErrCompletion)
+					{
+					_LIT(KMessage3, "Script file does not contain any elements.");
+					noteMsg.Copy(KMessage3);
+					}
+				else
+					{
+					_LIT(KMessage4, "Unknown error in opening script file.");
+					noteMsg.Copy(KMessage4);
+					}
+				CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+				note->ExecuteLD(noteMsg);
+				RunScriptDone();
+				}
+			}
+		else if (iMode == ETimerModeExitAppUi)
+	    	{
+	    	iMode = ETimerModeNone;
+	    	Exit();
+	    	}
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_browser.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,592 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#include "creator_browser.h" 
+#include "creator_traces.h"
+
+#include <FavouritesWapAp.h> 
+
+
+static const TInt KBrowserFieldLength = 128;
+
+_LIT(KCreatorBrowserPrefixName, "CR_");
+_LIT(KCreatorBrowserPrefixFolderName, "CR_FLDR_");
+
+//----------------------------------------------------------------------------
+
+CBrowserParameters::CBrowserParameters()
+    {
+    LOGSTRING("Creator: CBrowserParameters::CBrowserParameters");
+
+    iBookmarkName = HBufC::New(KBrowserFieldLength);
+    iBookmarkAddress = HBufC::New(KBrowserFieldLength);
+    iBookmarkUsername = HBufC::New(KBrowserFieldLength);
+    iBookmarkPassword = HBufC::New(KBrowserFieldLength);    
+    iBookmarkFolderName = HBufC::New(KBrowserFieldLength);
+    iSavedDeckLinkName = HBufC::New(KBrowserFieldLength);
+    iSavedDeckLocalAddress = HBufC::New(KBrowserFieldLength);
+    iSavedDeckFolderName = HBufC::New(KBrowserFieldLength);
+    }
+
+CBrowserParameters::~CBrowserParameters()
+    {
+    LOGSTRING("Creator: CBrowserParameters::~CBrowserParameters");
+
+    delete iSavedDeckFolderName;
+    delete iSavedDeckLocalAddress;
+    delete iSavedDeckLinkName;
+    delete iBookmarkFolderName;
+    delete iBookmarkPassword;    
+    delete iBookmarkUsername;
+    delete iBookmarkAddress;
+    delete iBookmarkName;
+
+    }
+
+//----------------------------------------------------------------------------
+
+CCreatorBrowser* CCreatorBrowser::NewL(CCreatorEngine* aEngine)
+    {
+    CCreatorBrowser* self = CCreatorBrowser::NewLC(aEngine);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CCreatorBrowser* CCreatorBrowser::NewLC(CCreatorEngine* aEngine)
+    {
+    CCreatorBrowser* self = new (ELeave) CCreatorBrowser;
+    CleanupStack::PushL(self);
+    self->ConstructL(aEngine);
+    return self;
+    }
+
+CCreatorBrowser::CCreatorBrowser()
+    {
+    }
+
+void CCreatorBrowser::ConstructL(CCreatorEngine* aEngine)
+    {
+    LOGSTRING("Creator: CCreatorBrowser::ConstructL");
+
+    iEngine = aEngine;
+    }
+
+CCreatorBrowser::~CCreatorBrowser()
+    {
+    LOGSTRING("Creator: CCreatorBrowser::~CCreatorBrowser");
+    if ( iEngine && iBmEntryIds.Count() )
+        {
+        TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iBmEntryIds, KUidDictionaryUidBrowserBookmarks ) );
+        }
+    iBmEntryIds.Reset();
+    iBmEntryIds.Close();
+
+    if ( iEngine && iBmFEntryIds.Count() )
+        {
+        TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iBmFEntryIds, KUidDictionaryUidBrowserBookmarkF ) );
+        }
+    iBmFEntryIds.Reset();
+    iBmFEntryIds.Close();
+
+    if ( iEngine && iSpEntryIds.Count() )
+        {
+        TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iSpEntryIds, KUidDictionaryUidBrowserSavedPg ) );
+        }
+    iSpEntryIds.Reset();
+    iSpEntryIds.Close();
+
+    if ( iEngine && iSpFEntryIds.Count() )
+        {
+        TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iSpFEntryIds, KUidDictionaryUidBrowserSavedPgF ) );
+        }
+    iSpFEntryIds.Reset();
+    iSpFEntryIds.Close();
+
+    delete iParameters;
+    }
+
+//----------------------------------------------------------------------------
+
+TBool CCreatorBrowser::AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries)
+    {
+    LOGSTRING("Creator: CCreatorBrowser::AskDataFromUserL");
+
+    TBool result( EFalse );
+    switch ( aCommand )
+        {
+        case ECmdDeleteBrowserBookmarks:
+            {
+            result = iEngine->YesNoQueryDialogL( _L("Delete all Browser bookmarks?") );
+            break;
+            }
+        case ECmdDeleteCreatorBrowserBookmarks:
+            {
+            result = iEngine->YesNoQueryDialogL( _L("Delete all Browser bookmarks created with Creator?") );
+            break;
+            }
+        case ECmdDeleteBrowserBookmarkFolders:
+            {
+            result = iEngine->YesNoQueryDialogL( _L("Delete all Browser bookmark folders?") );
+            break;
+            }
+        case ECmdDeleteCreatorBrowserBookmarkFolders:
+            {
+            result = iEngine->YesNoQueryDialogL( _L("Delete all Browser bookmark folders created with Creator?") );
+            break;
+            }
+        case ECmdDeleteBrowserSavedPages:
+            {
+            result = iEngine->YesNoQueryDialogL( _L("Delete all Browser saved pages?") );
+            break;
+            }
+        case ECmdDeleteCreatorBrowserSavedPages:
+            {
+            result = iEngine->YesNoQueryDialogL( _L("Delete all Browser saved pages created with Creator?") );
+            break;
+            }
+        case ECmdDeleteBrowserSavedPageFolders:
+            {
+            result = iEngine->YesNoQueryDialogL( _L("Delete all Browser saved pages folders?") );
+            break;
+            }
+        case ECmdDeleteCreatorBrowserSavedPageFolders:
+            {
+            result = iEngine->YesNoQueryDialogL( _L("Delete all Browser saved pages folders created with Creator?") );
+            break;
+            }
+        default:
+            {
+            result = iEngine->EntriesQueryDialogL(aNumberOfEntries, _L("How many entries to create?"));
+            break;
+            }
+        }
+    return result;
+    }
+
+
+//----------------------------------------------------------------------------
+
+TInt CCreatorBrowser::CreateBookmarkEntryL(CBrowserParameters *aParameters)
+    {
+    LOGSTRING("Creator: CCreatorBrowser::CreateBookmarkEntryL");
+
+    // clear any existing parameter definations
+    delete iParameters;
+    iParameters = NULL;
+    
+    CBrowserParameters* parameters = aParameters;
+        
+    // random data needed if no predefined data available
+    if( !parameters )
+        {
+        iParameters = new(ELeave) CBrowserParameters;
+        parameters = iParameters; 
+
+        TFileName userAndPassword = iEngine->RandomString(CCreatorEngine::EFirstName);
+        TFileName name = iEngine->RandomString(CCreatorEngine::ECompany);
+        TFileName url = name;
+        url.Insert(0, _L("http://www."));
+        url.Append(_L(".com/"));
+        name.Insert(0, KCreatorBrowserPrefixName);
+
+        parameters->iBookmarkName->Des() = name;
+        parameters->iBookmarkAddress->Des() = url;
+        parameters->iBookmarkUsername->Des() = userAndPassword;
+        parameters->iBookmarkPassword->Des() = userAndPassword;
+        }
+   
+    TInt err = KErrNone;
+
+    RFavouritesSession session;
+    User::LeaveIfError( session.Connect() );
+    CleanupClosePushL<RFavouritesSession>(session);
+    RFavouritesDb db;
+    User::LeaveIfError( db.Open(session, KBrowserBookmarks) );
+    CleanupClosePushL<RFavouritesDb>(db);
+
+    CFavouritesItem* item = CFavouritesItem::NewLC();
+    item->SetType( CFavouritesItem::EItem );
+    item->SetParentFolder( KFavouritesRootUid ) ;
+    item->SetNameL( parameters->iBookmarkName->Des() );
+    item->SetUrlL( parameters->iBookmarkAddress->Des() );
+    item->SetUserNameL( parameters->iBookmarkUsername->Des() );
+    item->SetPasswordL( parameters->iBookmarkPassword->Des() );
+    err = db.Add(*item, /*aAutoRename=*/ETrue);
+    if (err)
+        db.Commit();
+    
+    // id has been generated, store it for being able to delete
+    // only entries created with Creator
+    iBmEntryIds.Append( item->Uid() );
+    
+    CleanupStack::PopAndDestroy(3); //db, session, item
+
+    return err;
+    }
+
+//----------------------------------------------------------------------------
+
+TInt CCreatorBrowser::CreateBookmarkFolderEntryL(CBrowserParameters *aParameters)
+    {
+    LOGSTRING("Creator: CCreatorBrowser::CreateBookmarkFolderEntryL");
+
+    // clear any existing parameter definations
+    delete iParameters;
+    iParameters = NULL;
+    
+    CBrowserParameters* parameters = aParameters;
+    
+    // random data needed if no predefined data available
+    if (!parameters)
+        {
+        iParameters = new(ELeave) CBrowserParameters;
+        parameters = iParameters;
+
+        TFileName name = iEngine->RandomString(CCreatorEngine::ECompany);
+        name.Insert(0, KCreatorBrowserPrefixFolderName);
+
+        parameters->iBookmarkFolderName->Des() = name;
+        }
+    
+    TInt err = KErrNone;
+
+    RFavouritesSession session;
+    User::LeaveIfError( session.Connect() );
+    CleanupClosePushL<RFavouritesSession>(session);
+    RFavouritesDb db;
+    User::LeaveIfError( db.Open(session, KBrowserBookmarks) );
+    CleanupClosePushL<RFavouritesDb>(db);
+
+    CFavouritesItem* item = CFavouritesItem::NewLC();
+    item->SetType( CFavouritesItem::EFolder );
+    item->SetParentFolder( KFavouritesRootUid ) ;
+    item->SetNameL( parameters->iBookmarkFolderName->Des() );
+    
+    err = db.Add(*item, /*aAutoRename=*/ETrue);
+    if (err)
+        db.Commit();
+    
+    // id has been generated, store it for being able to delete
+    // only entries created with Creator
+    iBmFEntryIds.Append( item->Uid() );
+    
+    CleanupStack::PopAndDestroy(3); //db, session, item
+            
+
+    return err;
+    
+    }
+
+//----------------------------------------------------------------------------
+
+TInt CCreatorBrowser::CreateSavedDeckEntryL(CBrowserParameters *aParameters)
+    {
+    LOGSTRING("Creator: CCreatorBrowser::CreateSavedDeckEntryL");
+
+    // clear any existing parameter definations
+    delete iParameters;
+    iParameters = NULL;
+    
+    CBrowserParameters* parameters = aParameters;
+    
+    // random data needed if no predefined data available
+    if (!parameters)
+        {
+        iParameters = new(ELeave) CBrowserParameters;
+        parameters = iParameters;
+
+        TFileName name = iEngine->RandomString(CCreatorEngine::ECompany);
+        name.Insert(0, KCreatorBrowserPrefixName);
+
+        parameters->iSavedDeckLinkName->Des() = name;
+        parameters->iSavedDeckLocalAddress->Des() = iEngine->TestDataPathL(CCreatorEngine::ESavedDeck_1kB);
+        }
+   
+    TInt err = KErrNone;
+
+    // check the deck address is correct
+    if ( parameters->iSavedDeckLocalAddress->Des().Length() == 0 ||
+    		!BaflUtils::FileExists( CEikonEnv::Static()->FsSession(), parameters->iSavedDeckLocalAddress->Des() ))
+        {
+        // not found, use a default deck instead
+        delete parameters->iSavedDeckLocalAddress;
+        parameters->iSavedDeckLocalAddress = 0;
+        TPtrC tmp = iEngine->TestDataPathL(CCreatorEngine::ESavedDeck_1kB);
+        parameters->iSavedDeckLocalAddress = HBufC::NewL(tmp.Length());
+        parameters->iSavedDeckLocalAddress->Des() = tmp;
+        }
+
+
+    RFavouritesSession session;
+    User::LeaveIfError( session.Connect() );
+    CleanupClosePushL<RFavouritesSession>(session);
+    RFavouritesDb db;
+    User::LeaveIfError( db.Open(session, KBrowserSavedPages) );
+    CleanupClosePushL<RFavouritesDb>(db);
+
+    CFavouritesItem* item = CFavouritesItem::NewLC();
+    item->SetType( CFavouritesItem::EItem );
+    item->SetParentFolder( KFavouritesRootUid ) ;
+    item->SetNameL( parameters->iSavedDeckLinkName->Des() );
+    item->SetUrlL( _L(" ") );
+
+    TFavouritesWapAp favouritesAp;
+    favouritesAp.SetDefault();
+    item->SetWapAp( favouritesAp );
+
+    
+    err = db.Add(*item, /*aAutoRename=*/ETrue);
+    if (err)
+        db.Commit();
+    
+    // read the source deck to buffer
+    RFile sourceFile;
+    User::LeaveIfError( sourceFile.Open(CEikonEnv::Static()->FsSession(), parameters->iSavedDeckLocalAddress->Des(), EFileRead) );
+    CleanupClosePushL<RFile>(sourceFile);
+    TInt sourceFileSize(0);
+    err = sourceFile.Size(sourceFileSize);
+    HBufC8* sourceBuf = HBufC8::NewLC(sourceFileSize);
+    TPtr8 sourcePtr = sourceBuf->Des();
+    sourceFile.Read(sourcePtr);
+    
+    // write the deck
+    RFavouritesFile destinationFile;
+    User::LeaveIfError( destinationFile.Replace(db, item->Uid() ));
+    CleanupClosePushL<RFavouritesFile>(destinationFile);
+    err = destinationFile.Write(sourceBuf->Des());
+
+    // id has been generated, store it for being able to delete
+    // only entries created with Creator
+    iSpEntryIds.Append( item->Uid() );
+
+ 
+    CleanupStack::PopAndDestroy(6); //db, session, item, sourceFile, destinationFile, sourceBuf    
+    
+    return err;
+    }
+
+//----------------------------------------------------------------------------
+
+TInt CCreatorBrowser::CreateSavedDeckFolderEntryL(CBrowserParameters *aParameters)
+    {
+    LOGSTRING("Creator: CCreatorBrowser::CreateSavedDeckFolderEntryL");
+
+    // clear any existing parameter definations
+    delete iParameters;
+    iParameters = NULL;
+            
+    CBrowserParameters* parameters = aParameters;
+    // random data needed if no predefined data available
+    if (!parameters)
+        {
+        iParameters = new(ELeave) CBrowserParameters;
+        parameters = iParameters;
+        
+        TFileName name = iEngine->RandomString(CCreatorEngine::ECompany);
+        name.Insert(0, KCreatorBrowserPrefixFolderName);
+
+        parameters->iSavedDeckFolderName->Des() = name;
+        }
+   
+    TInt err = KErrNone;
+
+    RFavouritesSession session;
+    User::LeaveIfError( session.Connect() );
+    CleanupClosePushL<RFavouritesSession>(session);
+    RFavouritesDb db;
+    User::LeaveIfError( db.Open(session, KBrowserSavedPages) );
+    CleanupClosePushL<RFavouritesDb>(db);
+
+    CFavouritesItem* item = CFavouritesItem::NewLC();
+    item->SetType( CFavouritesItem::EFolder );
+    item->SetParentFolder( KFavouritesRootUid ) ;
+    item->SetNameL( parameters->iSavedDeckFolderName->Des() );
+    
+    err = db.Add(*item, /*aAutoRename=*/ETrue);
+    if (err)
+        db.Commit();
+
+    // id has been generated, store it for being able to delete
+    // only entries created with Creator
+    iSpFEntryIds.Append( item->Uid() );
+
+    CleanupStack::PopAndDestroy(3); //db, session, item
+                
+    return err;
+    
+    }
+
+
+//----------------------------------------------------------------------------
+void CCreatorBrowser::DeleteAllL()
+    {
+    LOGSTRING("Creator: CCreatorBrowser::DeleteAllL");
+    User::Leave( KErrNotSupported );
+    // will not be supported, see separate implementations below
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorBrowser::DeleteAllCreatedByCreatorL()
+    {
+    LOGSTRING("Creator: CCreatorBrowser::DeleteAllCreatedByCreatorL");
+    User::Leave( KErrNotSupported );
+    // will not be supported, see separate implementations below
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorBrowser::DeleteAllBookmarksL()
+    {
+    LOGSTRING("Creator: CCreatorBrowser::DeleteAllBookmarksL");
+    DeleteAllItemsL( KBrowserBookmarks,
+                     CFavouritesItem::EItem,
+                     EFalse,
+                     iBmEntryIds, // ignored, because deleting all
+                     KUidDictionaryUidBrowserBookmarks );
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorBrowser::DeleteAllBookmarksCreatedByCreatorL()
+    {
+    LOGSTRING("Creator: CCreatorBrowser::DeleteAllBookmarksCreatedByCreatorL");
+    DeleteAllItemsL( KBrowserBookmarks,
+                     CFavouritesItem::EItem,
+                     ETrue,
+                     iBmEntryIds,
+                     KUidDictionaryUidBrowserBookmarks );
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorBrowser::DeleteAllBookmarkFoldersL()
+    {
+    LOGSTRING("Creator: CCreatorBrowser::DeleteAllBookmarkFoldersL");
+    DeleteAllItemsL( KBrowserBookmarks,
+                     CFavouritesItem::EFolder,
+                     EFalse,
+                     iBmFEntryIds, // ignored, because deleting all
+                     KUidDictionaryUidBrowserBookmarkF );
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorBrowser::DeleteAllBookmarkFoldersCreatedByCreatorL()
+    {
+    LOGSTRING("Creator: CCreatorBrowser::DeleteAllBookmarkFoldersCreatedByCreatorL");
+    DeleteAllItemsL( KBrowserBookmarks,
+                     CFavouritesItem::EFolder,
+                     ETrue,
+                     iBmFEntryIds,
+                     KUidDictionaryUidBrowserBookmarkF );
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorBrowser::DeleteAllSavedPagesL()
+    {
+    LOGSTRING("Creator: CCreatorBrowser::DeleteAllSavedPagesL");
+    DeleteAllItemsL( KBrowserSavedPages,
+                     CFavouritesItem::EItem,
+                     EFalse,
+                     iSpEntryIds, // ignored, because deleting all
+                     KUidDictionaryUidBrowserSavedPg );
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorBrowser::DeleteAllSavedPagesCreatedByCreatorL()
+    {
+    LOGSTRING("Creator: CCreatorBrowser::DeleteAllSavedPagesCreatedByCreatorL");
+    DeleteAllItemsL( KBrowserSavedPages,
+                     CFavouritesItem::EItem,
+                     ETrue,
+                     iSpEntryIds,
+                     KUidDictionaryUidBrowserSavedPg );
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorBrowser::DeleteAllSavedPageFoldersL()
+    {
+    LOGSTRING("Creator: CCreatorBrowser::DeleteAllSavedPageFoldersL");
+    DeleteAllItemsL( KBrowserSavedPages,
+                     CFavouritesItem::EFolder,
+                     EFalse,
+                     iSpFEntryIds, // ignored, because deleting all
+                     KUidDictionaryUidBrowserSavedPgF );
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorBrowser::DeleteAllSavedPageFoldersCreatedByCreatorL()
+    {
+    LOGSTRING("Creator: CCreatorBrowser::DeleteAllSavedPageFolderssCreatedByCreatorL");
+    DeleteAllItemsL( KBrowserSavedPages,
+                     CFavouritesItem::EFolder,
+                     ETrue,
+                     iSpFEntryIds,
+                     KUidDictionaryUidBrowserSavedPgF );
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorBrowser::DeleteAllItemsL( const TDesC& aDbName, 
+                                       CFavouritesItem::TType aTypeFilter,
+                                       TBool aOnlyCreatedWithCreator,
+                                       RArray<TInt>& aEntryIds,
+                                       const TUid aDictUid )
+    {
+    LOGSTRING("Creator: CCreatorBrowser::DeleteItemL");
+    RFavouritesSession session;
+    User::LeaveIfError( session.Connect() );
+    CleanupClosePushL( session );
+    RFavouritesDb db;
+    User::LeaveIfError( db.Open( session, aDbName ) );
+    CleanupClosePushL( db );
+       
+    if ( aOnlyCreatedWithCreator )
+        {
+        // read uids from Creator internal store
+        aEntryIds.Reset();
+        iEngine->ReadEntryIdsFromStoreL( aEntryIds, aDictUid );
+        
+        // delete entries from db
+        for ( TInt i = 0; i < aEntryIds.Count(); i++ )
+            {
+            db.Delete( aEntryIds[i] );
+            }
+        }
+    else
+        {
+        CArrayFixFlat<TInt>* uids = new (ELeave) CArrayFixFlat<TInt>(64);
+        CleanupStack::PushL( uids );
+        
+        // read uids from browser db
+        User::LeaveIfError( db.GetUids( *uids, KFavouritesRootUid, aTypeFilter ) );
+
+        // delete entries from db
+        for ( TInt i = 0; i < uids->Count(); i++ )
+            {
+            db.Delete( uids->At(i) );
+            }
+        
+        // db.Commit() seems to panic with EFavouritesNoTransaction
+        // deletion is successful even without commit, so not calling it
+        CleanupStack::PopAndDestroy( uids );
+        }
+       
+    // entries deleted, remove the Browser related registry
+    aEntryIds.Reset();
+    iEngine->RemoveStoreL( aDictUid );
+
+    CleanupStack::PopAndDestroy( &db );
+    CleanupStack::PopAndDestroy( &session );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_browserelement.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,215 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#include "creator_browserelement.h"
+#include "creator_traces.h"
+#include "creator_browser.h"
+
+using namespace creatorbrowser;
+
+/*
+ * 
+ */
+CCreatorBrowserElement* CCreatorBrowserElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext )
+    {
+    CCreatorBrowserElement* self = new (ELeave) CCreatorBrowserElement(aEngine);
+    CleanupStack::PushL(self);
+    self->ConstructL(aName, aContext);
+    CleanupStack::Pop(self);
+    return self;
+    }
+/*
+ * 
+ */
+CCreatorBrowserElement::CCreatorBrowserElement(CCreatorEngine* aEngine) 
+: 
+CCreatorScriptElement(aEngine)
+    {
+    iIsCommandElement = ETrue;
+    }
+
+
+/*
+ * 
+ */
+void CCreatorBrowserElement::ExecuteCommandL()
+    {
+    const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount);
+    TInt entryAmount = 1;
+    TBool addAll = EFalse;
+    if( amountAttr )
+        {
+        entryAmount = ConvertStrToIntL(amountAttr->Value());
+        }
+    // Get 'fields' element 
+    CCreatorScriptElement* fieldsElement = FindSubElement(KFields);
+    if( fieldsElement )
+        {
+        // Get sub-elements
+        const RPointerArray<CCreatorScriptElement>& fields = fieldsElement->SubElements();
+        // Create browser entries, the amount of entries is defined by entryAmount:
+        for( TInt cI = 0; cI < entryAmount; ++cI )
+            {
+            CBrowserParameters* param = 0;
+            
+            if( fields.Count() > 0 )
+            	param = new (ELeave) CBrowserParameters;
+            else
+            	{
+            	// No fields defined --> Add all fields with random values:
+            	addAll = ETrue;
+            	break;
+            	}
+            
+            CleanupStack::PushL(param);
+            
+            for( TInt i = 0; i < fields.Count(); ++i )
+                {
+                CCreatorScriptElement* field = fields[i];
+                TPtrC elemName = field->Name();                
+                TPtrC elemContent = field->Content();
+                const CCreatorScriptAttribute* randomAttr = fields[i]->FindAttributeByName(KRandomLength);
+                if( elemName == KName )
+                    {
+                    if( randomAttr || elemContent.Length() == 0)
+                        {
+                        elemContent.Set(iEngine->RandomString(CCreatorEngine::ECompany));
+                        }
+                    if( iName->Des() == KBookmark )
+                        {
+                        SetContentToTextParamL(param->iBookmarkName, elemContent);                        
+                        }
+                    else if( iName->Des() == KBookmarkFolder )
+                        {
+                        SetContentToTextParamL(param->iBookmarkFolderName, elemContent);
+                        }
+                    else if( iName->Des() == KSavedPage )
+                        {
+                        SetContentToTextParamL(param->iSavedDeckLinkName, elemContent);
+                        }
+                    else if( iName->Des() == KSavedPageFolder )
+                        {
+                        SetContentToTextParamL(param->iSavedDeckFolderName, elemContent);
+                        }
+                    }
+                
+                else if( elemName == KPath )
+                    {                    
+                    if( randomAttr || elemContent.Length() == 0)
+                        {
+                        SetContentToTextParamL(param->iSavedDeckLocalAddress, iEngine->TestDataPathL(CCreatorEngine::ESavedDeck_1kB));
+                        }
+                    else
+                        {
+                        SetContentToTextParamL(param->iSavedDeckLocalAddress, elemContent);
+                        }
+                    }
+                else if( elemName == KUsername )
+                    {
+                    if( randomAttr || elemContent.Length() == 0)
+                        {
+                        // Set username and password to same string
+                        if( param->iBookmarkPassword && param->iBookmarkPassword->Length() > 0 )
+                            {
+                            SetContentToTextParamL(param->iBookmarkUsername, param->iBookmarkPassword->Des());
+                            }
+                        else
+                            {
+                            SetContentToTextParamL(param->iBookmarkUsername, iEngine->RandomString(CCreatorEngine::EFirstName));
+                            }
+                        }
+                    else
+                        {
+                        SetContentToTextParamL(param->iBookmarkUsername, elemContent);
+                        }
+                    }
+                else if( elemName == KPassword )
+                    {
+                    if( randomAttr || elemContent.Length() == 0)
+                        {
+                        // Set username and password to same string
+                        if( param->iBookmarkUsername && param->iBookmarkUsername->Length() > 0 )
+                            {
+                            SetContentToTextParamL(param->iBookmarkPassword, param->iBookmarkUsername->Des());
+                            }
+                        else
+                            {
+                            SetContentToTextParamL(param->iBookmarkPassword, iEngine->RandomString(CCreatorEngine::EFirstName));                                                    
+                            }
+                        }
+                    else
+                        {
+                        SetContentToTextParamL(param->iBookmarkPassword, elemContent);
+                        }
+                    }
+                else if( elemName == KUrl )
+                    {
+                    if( randomAttr || elemContent.Length() == 0)
+                        {
+                        TDesC* tmpUrl = iEngine->CreateHTTPUrlLC();
+                        if( tmpUrl )
+                            {
+                            SetContentToTextParamL(param->iBookmarkAddress, *tmpUrl );
+                            }
+                        CleanupStack::PopAndDestroy(); // tmpUrl                        
+                        }
+                    else
+                        {
+                        SetContentToTextParamL(param->iBookmarkAddress, elemContent);
+                        }
+                    }
+                }
+            iEngine->AppendToCommandArrayL(GetBrowserCommandL(), param);
+            CleanupStack::Pop(); // param
+            }
+        }
+    else
+    	{
+    	addAll = ETrue;
+    	}
+    
+    if( addAll )
+    	{
+    	iEngine->AppendToCommandArrayL(GetBrowserCommandL(), 0, entryAmount);
+    	}
+    }
+
+TInt CCreatorBrowserElement::GetBrowserCommandL() const
+    {
+    if( iName->Des() == KBookmark )
+        {
+        return ECmdCreateBrowserBookmarkEntries;
+        }
+    else if( iName->Des() == KBookmarkFolder )
+        {
+        return ECmdCreateBrowserBookmarkFolderEntries;
+        }
+    else if( iName->Des() == KSavedPage )
+        {
+        return ECmdCreateBrowserSavedPageEntries;
+        }
+    else if( iName->Des() == KSavedPageFolder )
+        {
+        return ECmdCreateBrowserSavedPageFolderEntries;
+        }
+    
+    LOGSTRING("CCreatorFileElement::GetBrowserCommandL: Unknown browser entry");
+    User::Leave(KErrGeneral);
+    return 0; // Not reached, but disables compiler warning...
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_calendar.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,1601 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include "creator_calendar.h" 
+#include "creator_traces.h"
+#include "creator_scriptentry.h"
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+#include "creator_contactsetcache.h"
+#include "creator_virtualphonebook.h"
+#endif
+#include <e32base.h>
+#include <e32math.h>
+#include <calrrule.h> 
+#include <calalarm.h>
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+#include <MVPbkFieldType.h>
+#include <MVPbkContactOperationBase.h>
+#include <MVPbkStoreContactFieldCollection.h>
+#include <MVPbkContactFieldTextData.h>
+#include <CVPbkContactManager.h>
+#include <MVPbkStoreContact.h>
+#include <CVPbkContactStoreUriArray.h>
+#include <TVPbkContactStoreUriPtr.h>
+#include <VPbkContactStoreUris.h>
+#include <MVPbkContactStoreList.h>
+#include <MVPbkContactStore.h>
+#include <MVPbkContactStoreProperties.h>
+#include <VPbkEng.rsg>
+#endif
+
+static const TInt KCalendarFieldLength = 128;
+
+
+CCreatorCalenderAttendee::CCreatorCalenderAttendee() 
+    {}
+
+CCreatorCalenderAttendee::~CCreatorCalenderAttendee()
+    {
+    delete iCommonName;
+    delete iEmailAddress;
+    }
+
+CCreatorCalenderAttendee* CCreatorCalenderAttendee::NewL()
+    {
+    CCreatorCalenderAttendee* self = new (ELeave) CCreatorCalenderAttendee;
+    return self;
+    }
+
+void CCreatorCalenderAttendee::SetCommonNameL(const TDesC& aName)
+    {
+    delete iCommonName;
+    iCommonName = 0;
+    iCommonName = HBufC::NewL(aName.Length());
+    iCommonName->Des().Copy(aName);
+    }
+
+void CCreatorCalenderAttendee::SetEmailAddressL(const TDesC& aEmail)
+    {
+    delete iEmailAddress;
+    iEmailAddress = 0;
+    iEmailAddress = HBufC::NewL(aEmail.Length());
+    iEmailAddress->Des().Copy(aEmail);
+    }
+
+void CCreatorCalenderAttendee::SetRole(CCalAttendee::TCalRole aRole)
+    {
+    iRole = aRole;
+    }
+
+void CCreatorCalenderAttendee::SetStatus(CCalAttendee::TCalStatus aStatus)
+    {
+    iStatus = aStatus;
+    }
+
+const TDesC& CCreatorCalenderAttendee::CommonName() const
+    {
+    if( iCommonName == 0 )
+    	return iDummy;
+    return *iCommonName;
+    }
+
+const TDesC& CCreatorCalenderAttendee::EmailAddress() const
+    {
+    if( iEmailAddress == 0 )
+    	return iDummy;
+    
+    return *iEmailAddress;
+    }
+
+CCalAttendee::TCalRole CCreatorCalenderAttendee::Role() const
+    {
+    return iRole;
+    }
+
+CCalAttendee::TCalStatus CCreatorCalenderAttendee::Status() const
+    {
+    return iStatus;
+    }
+
+TBool CCalenderInterimParameters::IsAllowedEntryStatus(CCalEntry::TType aType, CCalEntry::TStatus aStatus)
+    {
+    if( aType == CCalEntry::ETodo )
+        {
+        return  aStatus == CCalEntry::ECancelled ||
+                aStatus == CCalEntry::ETodoNeedsAction ||
+                aStatus == CCalEntry::ETodoCompleted ||
+                aStatus == CCalEntry::ETodoInProcess;
+        }
+    
+    return  aStatus == CCalEntry::ETentative ||
+            aStatus == CCalEntry::EConfirmed ||
+            aStatus == CCalEntry::ECancelled;
+    }
+
+//----------------------------------------------------------------------------
+
+CCalenderInterimParameters::CCalenderInterimParameters ( )
+    {
+    LOGSTRING("Creator: CCalenderInterimParameters::CCalenderInterimParameters");
+
+    iAppointmentLocation = HBufC::New (KCalendarFieldLength );
+    iAppointmentReason = HBufC::New (KCalendarFieldLength );
+    iEventReason = HBufC::New (KCalendarFieldLength );
+    iAnniversaryReason = HBufC::New (KCalendarFieldLength );
+    iTodoTask = HBufC::New (KCalendarFieldLength );
+    iReminderReason = HBufC::New (KCalendarFieldLength );
+    iDescription = HBufC::New (KCalendarFieldLength );
+    iSummary = HBufC::New (KCalendarFieldLength );
+    iLocation = HBufC::New (KCalendarFieldLength );
+    iOrganizerName = HBufC::New (KCalendarFieldLength );
+    iOrganizerEmail = HBufC::New (KCalendarFieldLength );
+
+    // set defaults, start date today and end date = today + 1 month
+    iRandomModeStartTime.HomeTime ( );
+    iRandomModeEndTime = iRandomModeStartTime;
+    iRandomModeEndTime += TTimeIntervalMonths (1 );
+    iAlarmTime = Time::NullTTime();
+    iUseRandomAlarmTime = EFalse;
+    iStatus = CCalEntry::ENullStatus;
+    }
+
+CCalenderInterimParameters::~CCalenderInterimParameters ( )
+    {
+    LOGSTRING("Creator: CCalenderInterimParameters::~CCalenderInterimParameters");
+
+    delete iTodoTask;
+    delete iAnniversaryReason;
+    delete iEventReason;
+    delete iAppointmentReason;
+    delete iAppointmentLocation;
+    delete iReminderReason;
+    delete iDescription;
+    delete iSummary;
+    delete iLocation;
+    delete iOrganizerName;
+    delete iOrganizerEmail;
+    iAttendees.ResetAndDestroy();
+    iAttendees.Close();
+    iAttendeeLinkIds.Reset();
+    iAttendeeLinkIds.Close();
+    }
+
+void CCalenderInterimParameters::ParseL (CCommandParser* parser,
+        TParseParams aCase )
+    {
+    LOGSTRING("Creator: CCalenderInterimParameters::ParseL");
+
+    HBufC* tempBuf= NULL;
+
+    switch (aCase )
+        {
+
+        case MCreatorModuleBaseParameters::ECalendarTodo:
+            {
+
+            parser->StrParserL (tempBuf, '|' );
+
+            CleanupStack::PushL (tempBuf );
+
+            this->iTodoDueTime = TTime (tempBuf->Des ( ) );
+
+            parser->StrParserL (this->iTodoTask, '|' );
+
+            parser->StrParserL (tempBuf, ';' );
+            this->iTodoPriority = 2;
+            if (tempBuf->Compare (_L("LOW") ) == 0 )
+                this->iTodoPriority = 3;
+            else
+                if (tempBuf->Compare (_L("HIGH") ) == 0 )
+                    this->iTodoPriority = 1;
+
+            CleanupStack::PopAndDestroy (tempBuf );
+
+            }
+
+        case MCreatorModuleBaseParameters::ECalendarMemo:
+            {
+
+            parser->StrParserL (tempBuf, '|' );
+
+            this->iStartTime = TTime (tempBuf->Des ( ) );
+
+            parser->StrParserL (tempBuf, '|' );
+            this->iEndTime = TTime (tempBuf->Des ( ) );
+
+            parser->StrParserL (this->iDescription, ';' );
+
+            CleanupStack::PopAndDestroy (tempBuf );
+            }
+
+        case MCreatorModuleBaseParameters::ECalendarMeeting:
+            {
+
+            parser->StrParserL (tempBuf, '|' );
+
+            CleanupStack::PushL (tempBuf );
+
+            this->iStartTime = TTime (tempBuf->Des ( ) );
+
+            parser->StrParserL (tempBuf, '|' );
+            this->iEndTime = TTime (tempBuf->Des ( ) );
+
+            parser->StrParserL (this->iLocation, '|' );
+            parser->StrParserL (this->iDescription, ';' );
+
+            CleanupStack::PopAndDestroy (tempBuf );
+            }
+
+        case MCreatorModuleBaseParameters::ECalendarAnniv:
+            {
+
+            parser->StrParserL (tempBuf, '|' );
+
+            CleanupStack::PushL (tempBuf );
+
+            this->iStartTime = TTime (tempBuf->Des ( ) );
+
+            parser->StrParserL (this->iDescription, ';' );
+
+            CleanupStack::PopAndDestroy (tempBuf );
+
+            }
+        default:
+            {
+            //implement 
+            }
+        }
+    }
+//----------------------------------------------------------------------------
+
+CCreatorInterimCalendar* CCreatorInterimCalendar::NewL (CCreatorEngine* aEngine )
+    {
+    CCreatorInterimCalendar* self = CCreatorInterimCalendar::NewLC (aEngine );
+    CleanupStack::Pop (self );
+    return self;
+    }
+
+CCreatorInterimCalendar* CCreatorInterimCalendar::NewLC (CCreatorEngine* aEngine )
+    {
+    CCreatorInterimCalendar* self = new (ELeave) CCreatorInterimCalendar;
+    CleanupStack::PushL (self );
+    self->ConstructL (aEngine );
+    return self;
+    }
+
+CCreatorInterimCalendar::CCreatorInterimCalendar ( )
+    {
+    }
+
+void CCreatorInterimCalendar::ConstructL (CCreatorEngine* aEngine )
+    {
+    LOGSTRING("Creator: CCreatorInterimCalendar::ConstructL");
+
+    iEngine = aEngine;
+
+    // set defaults, start date today and end date = today + 1 month
+    iRandomModeStartTime.HomeTime ( );
+    iRandomModeEndTime = iRandomModeStartTime;
+    iRandomModeEndTime += TTimeIntervalMonths (1 );
+
+    iCalSession = CCalSession::NewL ( );
+    // Create and open a calendar file
+    const TDesC& fileName = iCalSession->DefaultFileNameL ( );//default filename is: "C:Calendar"
+    TRAPD(err, iCalSession->CreateCalFileL(fileName))
+    ;
+    // ignore KErrAlreadyExists leave code
+    if (err != KErrAlreadyExists )
+        {
+        User::LeaveIfError (err );
+        }
+    // Open the calendar file
+    iCalSession->OpenL (fileName );
+    iCalEntryView = CCalEntryView::NewL (*iCalSession, *this );
+    iNumberRepeatingEntries = 0;
+    iNumberOfAttendees = 0; //iEngine->RandomNumber(2, 15);
+    iSetAlarm = EFalse;
+    iWaiter = CAsyncWaiter::NewL();
+    }
+
+CCreatorInterimCalendar::~CCreatorInterimCalendar ( )
+    {
+    LOGSTRING("Creator: CCreatorInterimCalendar::~CCreatorInterimCalendar");
+
+    if ( iEngine && iEntryIds.Count() )
+        {
+        TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iEntryIds, KUidDictionaryUidCalendar ) );
+        }
+        
+    iEntryIds.Reset();
+    iEntryIds.Close();
+        
+    if (iParameters )
+        {
+        delete iParameters;
+        }
+
+    if (iCalEntryView )
+        {
+        delete iCalEntryView;
+        }
+
+    if (iCalSession )
+        {
+        delete iCalSession;
+        }
+    delete iSoundFileArray;
+    delete iWaiter;
+    delete iTmpCN;
+    delete iTmpEmail;
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+    delete iExistingContacts;
+    delete iTempContact;
+    delete iContactManager;
+#endif
+    }
+
+//----------------------------------------------------------------------------
+
+TBool CCreatorInterimCalendar::AskDataFromUserL (TInt aCommand,
+        TInt& aNumberOfEntries )
+    {
+    LOGSTRING("Creator: CCreatorInterimCalendar::AskDataFromUserL");
+
+    if( aCommand == ECmdDeleteCalendarEntries )
+        {
+        return iEngine->YesNoQueryDialogL(_L("Delete all calendar entries?") );
+        }
+    if( aCommand == ECmdDeleteCreatorCalendarEntries )
+        {
+        return iEngine->YesNoQueryDialogL(_L("Delete all calendar entries created with Creator?") ); 
+        }
+
+    // display queries
+    if (iEngine->EntriesQueryDialogL (aNumberOfEntries, _L("How many entries to create?") ) ) // ask number of entries to create
+        {
+        if( aCommand == ECmdCreateCalendarEntryEvents ||
+            aCommand == ECmdCreateCalendarEntryAppointments)
+            {
+            _LIT(KRepeatingNum, "How many repeating (weekly) entries");
+            if( !iEngine->EntriesQueryDialogL(iNumberRepeatingEntries, KRepeatingNum, ETrue))
+                {
+                return EFalse;
+                }
+            _LIT(KAttendeesNum, "How many attendees to create");
+            if( !iEngine->EntriesQueryDialogL(iNumberOfAttendees, KAttendeesNum, ETrue))
+                {
+                return EFalse;
+                }
+            }
+        if (iEngine->TimeQueryDialogL (iRandomModeStartTime, R_START_DATE_QUERY ) ) // ask start date
+            {
+            if (iEngine->TimeQueryDialogL (iRandomModeEndTime, R_END_DATE_QUERY ) ) // ask end date
+                {
+                if (iRandomModeStartTime > iRandomModeEndTime ) // check end date is ok
+                    {
+                    CAknInformationNote* note = new (ELeave) CAknInformationNote;
+                    note->ExecuteLD (_L("End date must be after start date") );
+
+                    return EFalse;
+                    }
+                else 
+                    {
+                    if( iEngine->YesNoQueryDialogL(_L("Add default alarm?")))
+                        {
+                        iSetAlarm = ETrue;
+                        }                   
+                    }                    
+                    return ETrue;
+                }
+            else
+                return EFalse;
+            }
+        else
+            return EFalse;
+        }
+    else
+        return EFalse;
+    }
+
+//----------------------------------------------------------------------------
+
+TInt CCreatorInterimCalendar::CreateAppointmentEntryL (
+        CCreatorModuleBaseParameters *aParameters )
+    {
+    LOGSTRING("Creator: CCreatorInterimCalendar::CreateAppointmentEntryL");
+        
+    delete iParameters;
+    iParameters = 0;
+    
+    CCalenderInterimParameters* parameters = (CCalenderInterimParameters*)aParameters;   
+    
+    if( !parameters )
+        {
+        iParameters = new(ELeave) CCalenderInterimParameters;
+        parameters = iParameters;  
+        parameters->iRandomModeStartTime = iRandomModeStartTime;
+        parameters->iRandomModeEndTime = iRandomModeEndTime;    
+    
+        // difference between start and end times
+        TTimeIntervalMinutes differenceInMinutes;
+        parameters->iRandomModeEndTime.MinutesFrom (
+                parameters->iRandomModeStartTime, differenceInMinutes );
+
+        // start time (= something between the period start and end date)        
+        parameters->iStartTime = parameters->iRandomModeStartTime;
+        parameters->iStartTime
+                += TTimeIntervalMinutes (iEngine->RandomNumber (differenceInMinutes.Int ( ) ) );   
+        // set end time (= start time + some random time)    
+        parameters->iEndTime = parameters->iStartTime;    
+        parameters->iEndTime
+                += TTimeIntervalMinutes (iEngine->RandomNumber (5, 500 ) );
+        
+
+        // strings        
+        parameters->iLocation->Des ( )
+                = iEngine->RandomString (CCreatorEngine::EMeetingPlace );
+        parameters->iDescription->Des ( )
+                = iEngine->RandomString (CCreatorEngine::EMeetingReason );
+        
+        parameters->iSummary->Des()
+                        = parameters->iDescription->Des();
+        
+        parameters->iNumberRepeatingEntries = iNumberRepeatingEntries;
+        parameters->iNumberOfAttendees = iNumberOfAttendees;
+        }
+
+    TInt err = KErrNone;
+    HBufC8* guid = HBufC8::NewLC (255 );
+    TPtr8 uidP=guid->Des ( );
+    GenerateRandomId (uidP );
+    CCalEntry* entry = CCalEntry::NewL (CCalEntry::EAppt, guid,
+            CCalEntry::EMethodAdd, 0 );
+    CleanupStack::PushL (entry );
+
+    //Using same text as description and summary	
+    entry->SetDescriptionL (parameters->iDescription->Des ( ) );
+    entry->SetSummaryL (parameters->iSummary->Des ( ) );
+    entry->SetLocationL (parameters->iLocation->Des ( ) );
+
+    TCalTime startTime;
+    TCalTime endTime;
+    // Set the start and end times using time values local to the current system time zone
+    TInt month = (TInt) parameters->iStartTime.DateTime().Month();
+    TInt date = parameters->iStartTime.DateTime().Day();
+    startTime.SetTimeLocalL (parameters->iStartTime );
+    endTime.SetTimeLocalL (parameters->iEndTime );
+    entry->SetStartAndEndTimeL (startTime, endTime );       
+    
+    if( parameters->IsAllowedEntryStatus(CCalEntry::EAppt, parameters->iStatus))
+        {
+        LOGSTRING2("Creator: CCreatorInterimCalendar::CreateAppointmentEntryL setting entry status: %d", parameters->iStatus);
+        entry->SetStatusL(parameters->iStatus);
+        }
+    
+    // Repeating times:
+    AddRepeatingRuleL(startTime, *entry, parameters);
+    SetOrganizerL(*entry, parameters);
+    
+    // Alarm:    
+    if( iSetAlarm || parameters->iUseRandomAlarmTime )
+        {        
+        SetRandomAlarmL(*entry);
+        }
+    else
+        {
+        SetAlarmL(*entry, parameters);
+        }
+        
+    // Add attendees:
+    AddAttendeesL(*entry, parameters);
+    
+    RPointerArray<CCalEntry> array;
+    CleanupClosePushL (array );
+    array.AppendL (entry );
+    
+    TInt success(0);
+    //If StoreL() leaves, 'success' contains the number of entries that were stored before it failed
+    iCalEntryView->StoreL (array, success );
+
+    // id has been generated, store it for being able to delete
+    // entries created only with Creator
+    iEntryIds.Append( entry->LocalUidL() );
+    
+    //One item should be added at time
+    if (success != 1 )
+        {
+        err = 1;
+        }
+
+    CleanupStack::PopAndDestroy (&array );
+    CleanupStack::PopAndDestroy (entry );
+    CleanupStack::Pop (guid );//guid has been destroyed by entry, which has ownership to guid
+
+    return err;
+    }
+
+void CCreatorInterimCalendar::SetOrganizerL(CCalEntry& aCalEntry, CCalenderInterimParameters* parameters )
+    {    
+    HBufC* orgName = 0;
+    HBufC* orgEmail = 0;
+    _LIT(KSpace, " ");
+    
+    //
+    // Common name
+    //
+    if( parameters == 0 || 
+        parameters->iOrganizerName == 0 || 
+        parameters->iOrganizerName->Length() == 0 )
+        {     
+        // Random:
+        TPtrC firstname  = iEngine->RandomString(CCreatorEngine::EFirstName);
+        TPtrC lastname = iEngine->RandomString(CCreatorEngine::ESurname);
+        orgName = HBufC::NewL(firstname.Length() + lastname.Length() + 1 );
+        CleanupStack::PushL(orgName);
+        orgName->Des().Copy(firstname);
+        orgName->Des().Append(KSpace);
+        orgName->Des().Append(lastname);        
+        }
+    else
+        {
+        orgName = HBufC::NewL(parameters->iOrganizerName->Length());
+        CleanupStack::PushL(orgName);
+        orgName->Des().Copy(parameters->iOrganizerName->Des());
+        }
+    
+    //
+    // Email
+    //
+    if( parameters == 0 ||
+        parameters->iOrganizerEmail == 0 || 
+        parameters->iOrganizerEmail->Length() == 0 )
+        {        
+        // Random:
+        TDesC* tmp = iEngine->CreateEmailAddressLC();
+        orgEmail = HBufC::NewL(tmp->Length());
+        orgEmail->Des().Copy(*tmp);
+        CleanupStack::PopAndDestroy(); // tmp
+        CleanupStack::PushL(orgEmail);
+        }
+    else
+        {
+        orgEmail = HBufC::NewL(parameters->iOrganizerEmail->Length());
+        CleanupStack::PushL(orgEmail);
+        orgEmail->Des().Copy(parameters->iOrganizerEmail->Des());
+        }
+    
+    SetOrganizerL(aCalEntry, orgName->Des(), orgEmail->Des(), orgEmail->Des());
+    CleanupStack::PopAndDestroy(); // orgName
+    CleanupStack::PopAndDestroy(); // orgEmail
+    }
+
+void CCreatorInterimCalendar::AddRepeatingRuleL(const TCalTime& aStartTime, CCalEntry& aCalEntry, CCalenderInterimParameters* parameters )
+    {
+    RArray<TDay> days;
+    CleanupClosePushL(days);
+    
+    // Recurrence rule. Weekly event.
+    if( parameters->iNumberRepeatingEntries > 0 )
+        {
+        TCalRRule calRepeat(TCalRRule::EWeekly);   
+        calRepeat.SetDtStart(aStartTime);
+        calRepeat.SetCount(parameters->iNumberRepeatingEntries);        
+        calRepeat.SetInterval(1);
+        //days.AppendL((TDay) iEngine->RandomNumber((TInt)EMonday, (TInt) ESunday));
+        TDay tempDay(aStartTime.TimeLocalL().DayNoInWeek());
+        days.AppendL(tempDay);
+        calRepeat.SetByDay(days);        
+        aCalEntry.SetRRuleL(calRepeat);
+        }
+    else if(parameters->iRecurrentFrequency > TCalRRule::EInvalid)
+        {
+        TCalTime calTime;        
+        // Recurrent frequency
+        TCalRRule calRepeat(parameters->iRecurrentFrequency);
+        // Recurrent start        
+        calRepeat.SetDtStart(aStartTime);
+        if( parameters->iRecurrentFrequency == TCalRRule::EWeekly )
+        	{
+        	TDay tempDay(aStartTime.TimeLocalL().DayNoInWeek());
+        	days.AppendL(tempDay);        
+        	calRepeat.SetByDay(days);  
+        	}
+        else if( parameters->iRecurrentFrequency == TCalRRule::EMonthly )
+        	{
+        	RArray< TInt > daysInMonth;
+        	CleanupClosePushL(daysInMonth);
+        	daysInMonth.AppendL(aStartTime.TimeLocalL().DayNoInMonth());
+        	calRepeat.SetByMonthDay(daysInMonth);
+        	CleanupStack::PopAndDestroy(&daysInMonth);
+        	}
+        else if( parameters->iRecurrentFrequency == TCalRRule::EYearly)
+        	{
+        	RArray< TMonth > monthsInYear;
+        	CleanupClosePushL(monthsInYear);
+        	monthsInYear.AppendL(aStartTime.TimeLocalL().DateTime().Month());
+        	calRepeat.SetByMonth(monthsInYear);
+        	CleanupStack::PopAndDestroy(&monthsInYear);
+        	}
+        
+        // Recurrent interval
+        if( parameters->iRecurrentInterval > 0 )
+        	calRepeat.SetInterval(parameters->iRecurrentInterval);
+                
+        // Recurrent end. End can be given as a number of repeating entries or as an end date.
+        // End date must be later than the start date, otherwise CCalEntry::SetRRuleL() panics.
+        if( parameters->iRepeatingCount > 0 )
+            {
+            calRepeat.SetCount(parameters->iRepeatingCount);
+            aCalEntry.SetRRuleL(calRepeat);            
+            }
+        else
+            {
+            TCalTime endTime;
+            endTime.SetTimeLocalL(parameters->iRecurrentEndTime);
+            if( endTime.TimeLocalL() > aStartTime.TimeLocalL())
+            	{
+            	calRepeat.SetUntil(endTime);
+            	aCalEntry.SetRRuleL(calRepeat);
+            	}
+            }           
+        }
+    CleanupStack::PopAndDestroy(&days);
+    }
+
+void CCreatorInterimCalendar::SetAlarmL(CCalEntry& aCalEntry, CCalenderInterimParameters* params)
+    {
+    if( params->iAlarmTime != Time::NullTTime() )
+        {
+        CCalAlarm* alarm = CCalAlarm::NewL();
+        CleanupStack::PushL(alarm);
+        //if( params->iAlarmTime <= params->iStartTime )
+        //	{
+        	TTimeIntervalMinutes diff;
+        	TInt err = params->iStartTime.MinutesFrom(params->iAlarmTime, diff);
+        	if( err == KErrNone)
+        		{
+        		alarm->SetTimeOffset(diff);
+        		TRAP(err, aCalEntry.SetAlarmL(alarm));
+        		if( err != KErrNone && err !=  KErrNotSupported )
+        			{
+        			User::Leave(err);
+        			}        		
+        		}
+        //	}
+        CleanupStack::PopAndDestroy(alarm);
+        }
+    }
+
+void CCreatorInterimCalendar::SetRandomAlarmL(CCalEntry& aCalEntry)
+    {
+    CCalAlarm* alarm = CCalAlarm::NewL();
+    CleanupStack::PushL(alarm);
+    alarm->SetTimeOffset(TTimeIntervalMinutes(iEngine->RandomNumber(0, 60)));
+    
+    TRAPD(err, aCalEntry.SetAlarmL(alarm));
+    if( err != KErrNone && err !=  KErrNotSupported )
+    	{
+    	User::Leave(err);
+    	}
+    CleanupStack::PopAndDestroy(alarm);
+    }
+
+void CCreatorInterimCalendar::SetPhoneOwnerL(CCalEntry& aCalEntry, const TDesC& aCN, const TDesC& aEmail, const TDesC& aSentBy )
+    {
+    CCalUser* phOwner = CCalUser::NewL(aEmail, aSentBy);
+    CleanupStack::PushL(phOwner);
+    TRAPD(err, aCalEntry.SetPhoneOwnerL(phOwner));            
+    CleanupStack::Pop(phOwner);
+    if( err == KErrNone )
+        {
+        phOwner->SetCommonNameL(aCN);
+        }
+    else
+        {
+        delete phOwner;
+        }
+    }
+
+void CCreatorInterimCalendar::SetOrganizerL(CCalEntry& aCalEntry, const TDesC& aCN, const TDesC& aEmail, const TDesC& aSentBy)
+    {
+    CCalUser* organizer = CCalUser::NewL(aEmail, aSentBy);
+    CleanupStack::PushL(organizer);
+    TRAPD(err, aCalEntry.SetOrganizerL(organizer));
+    CleanupStack::Pop(organizer);
+    if( err == KErrNone )
+        {
+        organizer->SetCommonNameL(aCN);
+        }
+    else
+        {
+        delete organizer;
+        }
+    }
+
+void CCreatorInterimCalendar::AddAttendeesL(CCalEntry& aCalEntry, CCalenderInterimParameters* parameters )
+    {
+    if( !parameters )
+        return;
+            
+    // Random attendees:
+    TInt numOfAttendees = parameters->iNumberOfAttendees;
+    for( TInt i = 0; i < numOfAttendees; ++i )
+        {
+        TPtrC firstname  = iEngine->RandomString(CCreatorEngine::EFirstName);
+        TPtrC lastname   = iEngine->RandomString(CCreatorEngine::ESurname);
+        TPtrC company    = iEngine->RandomString(CCreatorEngine::ECompany);
+        _LIT(KCountry, "com");        
+        TDesC* emailAddr = iEngine->CreateEmailAddressLC(firstname, lastname, company, KCountry);        
+        CCalAttendee* attendee = CCalAttendee::NewL(*emailAddr);        
+        CleanupStack::PushL(attendee);
+        aCalEntry.AddAttendeeL(attendee);
+        CleanupStack::Pop(attendee);
+        attendee->SetCommonNameL(firstname);
+                
+        // Set phone owner:
+        if( i == 1 )
+            {             
+            SetPhoneOwnerL(aCalEntry, firstname, *emailAddr, *emailAddr); 
+            attendee->SetRoleL(CCalAttendee::EReqParticipant); 
+            }
+        // Set organizer:
+        else if ( i == 0 )
+            {            
+            // Organizer is the chairman of the meeting:
+            SetOrganizerL(aCalEntry, firstname, *emailAddr, *emailAddr);
+            attendee->SetRoleL(CCalAttendee::EChair);
+            }
+        else if( i % 3 == 0 )
+            {
+            // every third attendee is optional:
+            attendee->SetRoleL(CCalAttendee::EOptParticipant);
+            }
+        else
+            {
+            // Others are required attendees:
+            attendee->SetRoleL(CCalAttendee::EReqParticipant);            
+            }
+        
+        TInt attStatus = iEngine->RandomNumber(0,5);
+        attendee->SetStatusL((CCalAttendee::TCalStatus) attStatus);
+        
+        CleanupStack::PopAndDestroy(emailAddr);
+        }
+    
+    // Explicit attendees:
+    for( TInt i = 0; i < parameters->iAttendees.Count(); ++i )
+        {
+        CCreatorCalenderAttendee* attendeeInfo = parameters->iAttendees[i];
+        if( attendeeInfo && attendeeInfo->EmailAddress().Length() > 0)
+        	{
+        	CCalAttendee* attendee = CCalAttendee::NewL(attendeeInfo->EmailAddress());
+        	CleanupStack::PushL(attendee);
+        	if( attendeeInfo->CommonName().Length() > 0 )
+        		attendee->SetCommonNameL(attendeeInfo->CommonName());
+        	attendee->SetRoleL(attendeeInfo->Role());
+        	attendee->SetStatusL(attendeeInfo->Status());
+        	attendee->SetResponseRequested(ETrue);
+        	aCalEntry.AddAttendeeL(attendee);
+        	CleanupStack::Pop(); // attendee
+        	}
+        }
+    
+    // Linked attendees:
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+    
+    CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewLC();
+    uriArray->AppendL( TVPbkContactStoreUriPtr(VPbkContactStoreUris::DefaultCntDbUri()));
+    
+    if( iContactManager == 0 )
+        {
+        iContactManager = CVPbkContactManager::NewL( *uriArray, &CCoeEnv::Static()->FsSession());
+        }
+    CleanupStack::PopAndDestroy(uriArray);
+        
+    if( iContactManager )
+        {                
+        MVPbkContactStoreList& storeList = iContactManager->ContactStoresL();              
+        storeList.OpenAllL(*this);
+        iWaiter->StartAndWait(); 
+        
+        // Sum number of existing contacts:
+        for( TInt i = 0; i < parameters->iAttendeeLinkIds.Count(); ++i )
+            {
+            TLinkIdParam id = parameters->iAttendeeLinkIds[i];
+            parameters->iNumberOfExistingAttendees += ContactLinkCache::Instance()->ContactSet(id.iLinkId).NumberOfExistingContacts();
+            }
+        
+        // Existing attendees:
+        if( parameters->iNumberOfExistingAttendees > 0 )
+            {
+            _LIT(dbUri, "cntdb://c:contacts.cdb");
+            TVPbkContactStoreUriPtr uri(dbUri);                   
+            MVPbkContactStore* store = storeList.Find(uri);
+            if( store )
+                {
+                const MVPbkFieldTypeList& fieldList = store->StoreProperties().SupportedFields();
+                
+                // get contacts, results will be set to iContactResults
+                MVPbkContactOperationBase* operation = iContactManager->FindL(_L(""), fieldList , *this);
+                if (operation)
+                    {
+                    CleanupDeletePushL( operation );
+                    iWaiter->StartAndWait();//Making asynchronous FindL to synchronous
+                    CleanupStack::Pop(operation);
+                    delete operation;
+                    }
+                if( iExistingContacts )
+                    {
+                    for( TInt i = 0; i < iExistingContacts->Count() && i < parameters->iNumberOfExistingAttendees; ++i )
+                        {
+                        MVPbkContactOperationBase* operation = iContactManager->RetrieveContactL( iExistingContacts->At(i), *this );
+        
+                        if (operation)
+                            {
+                            CleanupDeletePushL( operation );
+                            iWaiter->StartAndWait(); // Making asynchronous RetrieveContactL to synchronous
+                            CleanupStack::Pop(); // operation
+                            delete operation;
+                            operation = 0;
+                            HandleSingleContactResultL();
+                            CCalAttendee* attendee = 0;
+                            if( iTmpEmail && iTmpEmail->Length() > 0 )
+                                {
+                                attendee = CCalAttendee::NewL(*iTmpEmail);
+                                }
+                            else
+                                {
+                                _LIT(KDummy, "");
+                                attendee = CCalAttendee::NewL(KDummy);
+                                }
+                            CleanupStack::PushL(attendee);                            
+                            if( iTmpCN && iTmpCN->Length() > 0 )
+                                {
+                                attendee->SetCommonNameL(*iTmpCN);
+                                }
+                            attendee->SetRoleL(CCalAttendee::EReqParticipant);
+                            attendee->SetStatusL(CCalAttendee::EAccepted);
+                            attendee->SetResponseRequested(ETrue);
+                            aCalEntry.AddAttendeeL(attendee);
+                            CleanupStack::Pop(attendee);
+                            }   
+                        }
+                    }
+                } 
+            }
+        
+        for( TInt i = 0; i < parameters->iAttendeeLinkIds.Count(); ++i )
+            {
+            TLinkIdParam id = parameters->iAttendeeLinkIds[i];
+            RPointerArray<MVPbkContactLink>& links = ContactLinkCache::Instance()->ContactLinks(id.iLinkId);
+            for( TInt j = 0; j < links.Count() && (id.iLinkAmount < 0 || j < id.iLinkAmount); ++j )
+                {
+                MVPbkContactOperationBase* operation = iContactManager->RetrieveContactL( *(links[j]), *this );
+                if (operation)
+                    {
+                    CleanupDeletePushL( operation );
+                    iWaiter->StartAndWait(); // Making asynchronous RetrieveContactL to synchronous
+                    CleanupStack::Pop(operation);
+                    delete operation;
+                    operation = 0;
+                    HandleSingleContactResultL();
+                    CCalAttendee* attendee = 0;
+                    if( iTmpEmail && iTmpEmail->Length() > 0 )
+                        {
+                        attendee = CCalAttendee::NewL(*iTmpEmail);
+                        }
+                    else
+                        {
+                        _LIT(KDummy, "");
+                        attendee = CCalAttendee::NewL(KDummy);
+                        }      
+                    CleanupStack::PushL(attendee);                    
+                    if( iTmpCN && iTmpCN->Length() > 0 )
+                        {
+                        attendee->SetCommonNameL(*iTmpCN);
+                        }
+                    attendee->SetRoleL(CCalAttendee::EReqParticipant);
+                    attendee->SetStatusL(CCalAttendee::EAccepted);
+                    attendee->SetResponseRequested(ETrue);
+                    aCalEntry.AddAttendeeL(attendee);
+                    CleanupStack::Pop(attendee);
+                    }                    
+                }
+            }
+        
+        storeList.CloseAll(*this);        
+        }    
+#endif
+    }
+//----------------------------------------------------------------------------
+
+TInt CCreatorInterimCalendar::CreateEventEntryL (
+        CCreatorModuleBaseParameters *aParameters )
+    {
+    LOGSTRING("Creator: CCreatorInterimCalendar::CreateEventEntryL");
+
+    delete iParameters;
+    iParameters = 0;
+        
+    CCalenderInterimParameters* parameters = (CCalenderInterimParameters*)aParameters;       
+    
+    // random data needed if no predefined data available
+    if (!parameters )
+        {
+        iParameters = new(ELeave) CCalenderInterimParameters;
+
+        iParameters->iRandomModeStartTime = iRandomModeStartTime;
+        iParameters->iRandomModeEndTime = iRandomModeEndTime;
+        iParameters->iNumberRepeatingEntries = iNumberRepeatingEntries;
+        iParameters->iNumberOfAttendees = iNumberOfAttendees;
+        
+        // difference between start and end times
+        TTimeIntervalMinutes differenceInMinutes;
+        iParameters->iRandomModeEndTime.MinutesFrom (
+                iParameters->iRandomModeStartTime, differenceInMinutes );
+
+        // start time (= something between the period start and end date)
+        iParameters->iStartTime = iParameters->iRandomModeStartTime;
+        iParameters->iStartTime
+                += TTimeIntervalMinutes (iEngine->RandomNumber (differenceInMinutes.Int ( ) ) );
+
+        // set end time (= start time + some random time)
+        iParameters->iEndTime = iParameters->iStartTime;
+        iParameters->iEndTime
+                += TTimeIntervalMinutes (iEngine->RandomNumber (5, 500 ) );        
+
+        // strings
+        iParameters->iDescription->Des()
+                = iEngine->RandomString (CCreatorEngine::EMemoText );
+        
+        iParameters->iSummary->Des() = iParameters->iDescription->Des();
+        
+        // Random event status:
+        iParameters->iStatus = 
+            (CCalEntry::TStatus) iEngine->RandomNumber(0, (TInt) CCalEntry::ECancelled);
+        
+        parameters = iParameters;
+        }
+
+    TInt err = KErrNone;
+    HBufC8* guid = HBufC8::NewLC (255 );
+    TPtr8 uidP=guid->Des ( );
+    GenerateRandomId (uidP );
+    CCalEntry* entry = CCalEntry::NewL (CCalEntry::EEvent, guid,
+            CCalEntry::EMethodAdd, 0 );
+    CleanupStack::PushL (entry );
+    // iEntryUids->AppendL( *guid->Alloc() );
+    
+    entry->SetDescriptionL (parameters->iDescription->Des ( ) );
+    entry->SetSummaryL (parameters->iSummary->Des ( ) );
+
+    TCalTime startTime;
+    TCalTime endTime;
+    // Set the start and end times using time values local to the current system time zone
+    startTime.SetTimeLocalL (parameters->iStartTime );
+    endTime.SetTimeLocalL (parameters->iEndTime );
+    entry->SetStartAndEndTimeL (startTime, endTime );
+
+    // Repeating times:
+    AddRepeatingRuleL(startTime, *entry, parameters);
+    
+    if( iSetAlarm || parameters->iUseRandomAlarmTime )
+        {        
+        SetRandomAlarmL(*entry);
+        }
+    else
+        {
+        SetAlarmL(*entry, parameters);
+        }
+    
+    // Add attendees:
+    AddAttendeesL(*entry, parameters);    
+    
+    if( parameters->IsAllowedEntryStatus(CCalEntry::EEvent, parameters->iStatus))
+        {
+        LOGSTRING2("Creator: CCreatorInterimCalendar::CreateEventEntryL setting entry status: %d", parameters->iStatus);
+        entry->SetStatusL(parameters->iStatus);
+        }
+        
+    RPointerArray<CCalEntry> array;
+    CleanupClosePushL (array );
+    array.AppendL (entry );
+
+    TInt success(0);
+    //If StoreL() leaves, 'success' contains the number of entries that were stored before it failed
+    iCalEntryView->StoreL (array, success );
+
+    // id has been generated, store it for being able to delete
+    // entries created only with Creator
+    iEntryIds.Append( entry->LocalUidL() );
+    
+    //One item should be added at time
+    if (success != 1 )
+        {
+        err = 1;
+        }
+
+    CleanupStack::PopAndDestroy (&array );
+    CleanupStack::PopAndDestroy (entry );
+    CleanupStack::Pop (guid );//guid has been destroyed by entry, which has ownership to guid
+    return err;
+
+    }
+
+//----------------------------------------------------------------------------
+
+
+TInt CCreatorInterimCalendar::CreateReminderEntryL (
+        CCreatorModuleBaseParameters *aParameters )
+    {
+    LOGSTRING("Creator: CCreatorInterimCalendar::CreateReminderEntryL");
+
+    delete iParameters;
+    iParameters = NULL;
+    
+    CCalenderInterimParameters* parameters = (CCalenderInterimParameters*)aParameters;
+
+    // random data needed if no predefined data available
+    if (!parameters )
+        {
+        iParameters = new(ELeave) CCalenderInterimParameters;
+
+        iParameters->iRandomModeStartTime = iRandomModeStartTime;
+        iParameters->iRandomModeEndTime = iRandomModeEndTime;
+
+        // difference between start and end times
+        TTimeIntervalDays
+                differenceInDays = iParameters->iRandomModeEndTime.DaysFrom (iParameters->iRandomModeStartTime );
+
+        // due time (= something between the period start and end date)
+        iParameters->iStartTime = iParameters->iRandomModeStartTime;
+        iParameters->iStartTime
+                += TTimeIntervalDays (iEngine->RandomNumber (differenceInDays.Int ( ) ) );
+
+        // strings
+        iParameters->iDescription->Des()
+                = iEngine->RandomString (CCreatorEngine::EReminderText );
+        
+        iParameters->iSummary->Des() = iParameters->iDescription->Des();
+
+        parameters = iParameters;
+        }
+
+    TInt err = KErrNone;
+
+    HBufC8* guid = HBufC8::NewLC (255 );
+    TPtr8 uidP=guid->Des ( );
+    GenerateRandomId (uidP );
+
+    CCalEntry* entry = CCalEntry::NewL (CCalEntry::EReminder, guid,
+            CCalEntry::EMethodAdd, 0 );
+    CleanupStack::PushL (entry );
+
+    //Using same text as description and summary    
+    entry->SetDescriptionL (parameters->iDescription->Des ( ) );
+    entry->SetSummaryL (parameters->iSummary->Des ( ) );
+
+    TCalTime startTime;
+    TCalTime endTime;
+    // Set the start and end times using time values local to the current system time zone
+    startTime.SetTimeLocalL (parameters->iStartTime );
+    TTime nullTime = Time::NullTTime ( );
+    endTime.SetTimeLocalL (nullTime );
+    entry->SetStartAndEndTimeL (startTime, endTime );
+        
+    if( parameters->IsAllowedEntryStatus(CCalEntry::EReminder, parameters->iStatus))
+        {
+        LOGSTRING2("Creator: CCreatorInterimCalendar::CreateReminderEntryL setting entry status: %d", parameters->iStatus);
+        entry->SetStatusL(parameters->iStatus);
+        }
+    
+    if( iSetAlarm || parameters->iUseRandomAlarmTime )
+        {        
+        SetRandomAlarmL(*entry);
+        }
+    else
+        {
+        SetAlarmL(*entry, parameters);
+        }
+
+    RPointerArray<CCalEntry> array;
+    CleanupClosePushL (array );
+    array.AppendL (entry );
+
+    TInt success(0);
+    //If StoreL() leaves, 'success' contains the number of entries that were stored before it failed
+    iCalEntryView->StoreL (array, success );
+
+    // id has been generated, store it for being able to delete
+    // entries created only with Creator
+    iEntryIds.Append( entry->LocalUidL() );
+    
+    //One item should be added at time
+    if (success != 1 )
+        {
+        err = 1;
+        }
+
+    CleanupStack::PopAndDestroy (&array );
+    CleanupStack::PopAndDestroy (entry );
+    CleanupStack::Pop (guid );//guid has been destroyed by entry, which has ownership to guid
+
+    return err;
+    }
+
+//----------------------------------------------------------------------------
+
+TInt CCreatorInterimCalendar::CreateAnniversaryEntryL (
+        CCreatorModuleBaseParameters *aParameters )
+    {
+    LOGSTRING("Creator: CCreatorInterimCalendar::CreateAnniversaryEntryL");
+
+    delete iParameters;
+    iParameters = NULL;
+    
+    CCalenderInterimParameters* parameters = (CCalenderInterimParameters*)aParameters;
+
+    // random data needed if no predefined data available
+    if (!parameters )
+        {
+        iParameters = new(ELeave) CCalenderInterimParameters;
+
+        iParameters->iRandomModeStartTime = iRandomModeStartTime;
+        iParameters->iRandomModeEndTime = iRandomModeEndTime;
+
+        // difference between start and end times
+        TTimeIntervalDays differenceInDays = iParameters->iRandomModeEndTime.DaysFrom(iParameters->iRandomModeStartTime);  
+
+        // start time (= something between the period start and end date)
+        iParameters->iStartTime = iParameters->iRandomModeStartTime;
+        iParameters->iStartTime += TTimeIntervalDays( iEngine->RandomNumber(differenceInDays.Int()) );        
+        
+        // strings
+        iParameters->iDescription->Des().Copy (iEngine->RandomString (CCreatorEngine::EFirstName ) );
+        iParameters->iDescription->Des().Append ( _L("'s ") );
+        iParameters->iDescription->Des().Append (iEngine->RandomString (CCreatorEngine::EAnniversaryReason ) );
+        iParameters->iSummary->Des() = iParameters->iDescription->Des();
+        parameters = iParameters;
+        }
+ 
+    TInt err = KErrNone;
+
+    HBufC8* guid = HBufC8::NewLC (255 );
+    TPtr8 uidP=guid->Des ( );
+    GenerateRandomId (uidP );
+
+    CCalEntry* entry = CCalEntry::NewL (CCalEntry::EAnniv, guid,
+            CCalEntry::EMethodNone, 0 );
+    CleanupStack::PushL (entry );
+
+    //Using same text as description and summary	
+    entry->SetDescriptionL (parameters->iDescription->Des ( ) );
+    entry->SetSummaryL (parameters->iSummary->Des ( ) );
+
+    TCalTime startTime;
+    TCalTime endTime;
+    TTime nullTime = Time::NullTTime ( );
+    endTime.SetTimeLocalL (nullTime );
+    
+    // Set the start time using time value local to the current system time zone
+    startTime.SetTimeLocalL (parameters->iStartTime );
+
+    entry->SetStartAndEndTimeL (startTime, endTime );
+
+    if( iSetAlarm || parameters->iUseRandomAlarmTime )
+        {        
+        SetRandomAlarmL(*entry);
+        }
+    else
+        {
+        SetAlarmL(*entry, parameters);
+        }
+    
+    //set repeating rule
+    TCalRRule yearlyRptRule(TCalRRule::EYearly);
+    yearlyRptRule.SetDtStart (startTime );
+    //Set repeating until forever, not setting it to stop
+    //yearlyRptRule.SetUntil(endTime);
+    entry->SetRRuleL (yearlyRptRule );
+
+    RPointerArray<CCalEntry> array;
+    CleanupClosePushL (array );
+    array.AppendL (entry );
+
+    TInt success(0);
+    //If StoreL() leaves, 'success' contains the number of entries that were stored before it failed
+    iCalEntryView->StoreL (array, success );
+
+    // id has been generated, store it for being able to delete
+    // entries created only with Creator
+    iEntryIds.Append( entry->LocalUidL() );
+    
+    //One item should be added at time
+    if (success != 1 )
+        {
+        err = 1;
+        }
+
+    CleanupStack::PopAndDestroy (&array );
+    CleanupStack::PopAndDestroy (entry );
+    CleanupStack::Pop (guid );//guid has been destroyed by entry, which has ownership to guid
+
+    return err;
+    }
+
+//----------------------------------------------------------------------------
+
+TInt CCreatorInterimCalendar::CreateTodoEntryL (
+        CCreatorModuleBaseParameters *aParameters )
+    {
+    LOGSTRING("Creator: CCreatorInterimCalendar::CreateTodoEntryL");
+
+    delete iParameters;
+    iParameters = NULL;
+    
+    CCalenderInterimParameters* parameters = (CCalenderInterimParameters*)aParameters;
+
+    // random data needed if no predefined data available
+    if (!parameters )
+        {
+        iParameters = new(ELeave) CCalenderInterimParameters;
+
+        iParameters->iRandomModeStartTime = iRandomModeStartTime;
+        iParameters->iRandomModeEndTime = iRandomModeEndTime;
+
+        // difference between start and end times
+        TTimeIntervalDays
+                differenceInDays = iParameters->iRandomModeEndTime.DaysFrom (iParameters->iRandomModeStartTime );
+
+        // due time (= something between the period start and end date)
+        iParameters->iTodoDueTime = iParameters->iRandomModeStartTime;
+        iParameters->iTodoDueTime
+                += TTimeIntervalDays (iEngine->RandomNumber (differenceInDays.Int ( ) ) );
+
+        // strings
+        iParameters->iDescription->Des ( )
+                = iEngine->RandomString (CCreatorEngine::EToDoText );
+        
+        iParameters->iSummary->Des() = iParameters->iDescription->Des();
+
+        //priority
+        iParameters->iTodoPriority = iEngine->RandomNumber (1, 3 );
+        iParameters->iStatus = (CCalEntry::TStatus) iEngine->RandomNumber((TInt) CCalEntry::ETodoNeedsAction, (TInt) CCalEntry::ETodoInProcess);
+        parameters = iParameters;
+        
+        }
+
+    TInt err = KErrNone;
+
+    HBufC8* guid = HBufC8::NewLC (255 );
+    TPtr8 uidP=guid->Des ( );
+    GenerateRandomId (uidP );
+
+    CCalEntry* entry = CCalEntry::NewL (CCalEntry::ETodo, guid,
+            CCalEntry::EMethodAdd, 0 );
+    CleanupStack::PushL (entry );
+
+    //Using same text as description and summary	
+    entry->SetDescriptionL (parameters->iDescription->Des ( ) );
+    entry->SetSummaryL (parameters->iSummary->Des ( ) );
+
+    entry->SetPriorityL (parameters->iTodoPriority );
+    
+    if( parameters->IsAllowedEntryStatus(CCalEntry::ETodo, parameters->iStatus))
+        {
+        LOGSTRING2("Creator: CCreatorInterimCalendar::CreateTodoEntryL setting entry status: %d", parameters->iStatus);
+        entry->SetStatusL(parameters->iStatus);
+        }
+
+    TCalTime startTime;
+    TCalTime endTime;
+    // Set the start and end times using time values local to the current system time zone
+    startTime.SetTimeLocalL (parameters->iTodoDueTime );
+    endTime.SetTimeLocalL (parameters->iTodoDueTime );
+    entry->SetStartAndEndTimeL (startTime, endTime );
+
+    if( iSetAlarm || parameters->iUseRandomAlarmTime )
+        {        
+        SetRandomAlarmL(*entry);
+        }
+    else
+        {
+        SetAlarmL(*entry, parameters);
+        }
+    
+    RPointerArray<CCalEntry> array;
+    CleanupClosePushL (array );
+    array.AppendL (entry );
+
+    TInt success(0);
+    //If StoreL() leaves, 'success' contains the number of entries that were stored before it failed
+    iCalEntryView->StoreL (array, success );
+
+    // id has been generated, store it for being able to delete
+    // entries created only with Creator
+    iEntryIds.Append( entry->LocalUidL() );
+    
+    //One item should be added at time
+    if (success != 1 )
+        {
+        err = 1;
+        }
+
+    CleanupStack::PopAndDestroy (&array );
+    CleanupStack::PopAndDestroy (entry );
+    CleanupStack::Pop (guid );//guid has been destroyed by entry, which has ownership to guid
+
+    return err;
+    }
+
+//----------------------------------------------------------------------------
+
+void CCreatorInterimCalendar::Progress (TInt /*aPercentageCompleted*/)
+    {
+    //Not really needed but observer need to be implement
+    }
+
+void CCreatorInterimCalendar::Completed (TInt aError )
+    {
+    //Not really needed but observer need to be implement
+    LOGSTRING2("Creator: CCreatorInterimCalendar::Completed err=%d", aError);
+    }
+
+TBool CCreatorInterimCalendar::NotifyProgress ( )
+    {
+    //Not really needed but observer need to be implement
+    return NULL;
+    }
+
+//----------------------------------------------------------------------------
+
+
+void CCreatorInterimCalendar::GenerateRandomId (TDes8& aText )
+    {
+    LOGSTRING("Creator: CCreatorInterimCalendar::GenerateRandomId");
+
+    aText.Zero ( );
+
+    TTime now;
+    now.UniversalTime ( );
+    TInt64 time = now.Int64 ( );
+
+    // The number of characters in the guid should be
+    // more than 8 (to ensure the guids are not too small)
+    // less than 255 (this is the maximum length of a guid)
+    // less than MaxLength of the descriptor passed in		
+    TInt numChar(0);
+    do
+        {
+        numChar = Math::Rand (time ) % (aText.MaxLength ( ) - 1);
+        }
+    while (numChar > 255|| numChar < 8 );
+
+    for (TInt i(0); i < numChar ; ++i )
+        {
+        TInt character = Math::Rand (time )%6;
+        character = Math::Rand (time ) % 26+ ((character == 2) ? 'A' : 'a');
+        aText.Append (character );
+        }
+
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorInterimCalendar::DeleteAllL()
+    {
+    LOGSTRING("Creator: CCreatorInterimCalendar::DeleteAllL");
+    TCalTime zeroTime;
+    zeroTime.SetTimeUtcL( TCalTime::MinTime() );
+    RArray<TUint32> allIds;
+    CleanupClosePushL( allIds );
+    iCalEntryView->GetIdsModifiedSinceDateL( zeroTime, allIds );
+    if ( allIds.Count() )
+        {
+        TInt successCount( KErrNotFound );
+        iCalEntryView->DeleteL( allIds, successCount );
+        if ( successCount != allIds.Count() )
+            {
+            User::Leave( KErrGeneral );
+            }        
+        }
+    CleanupStack::PopAndDestroy( &allIds );
+
+    // reset must be done here, because iEntryIds is stored in destructor
+    iEntryIds.Reset();
+    
+    // all entries deleted, remove the Calendar related registry
+    iEngine->RemoveStoreL( KUidDictionaryUidCalendar );
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorInterimCalendar::DeleteAllCreatedByCreatorL()
+    {
+    LOGSTRING("Creator: CCreatorInterimCalendar::DeleteAllCreatedByCreatorL");
+    iEntryIds.Reset();
+    
+    // fetch ids of entries created by Creator
+    iEngine->ReadEntryIdsFromStoreL( iEntryIds, KUidDictionaryUidCalendar );
+    
+    // delete entries
+    TInt successCount(0); // ignore
+    TRAP_IGNORE( iCalEntryView->DeleteL( iEntryIds, successCount ) );
+
+    // reset must be done here, because iEntryIds is stored in destructor
+    iEntryIds.Reset();
+    
+    // all entries deleted, remove the Calendar related registry
+    iEngine->RemoveStoreL( KUidDictionaryUidCalendar );
+    }
+
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+void CCreatorInterimCalendar::VPbkSingleContactOperationComplete(
+            MVPbkContactOperationBase& /*aOperation*/,
+            MVPbkStoreContact* aContact )
+    {
+    LOGSTRING("Creator: CCreatorInterimCalendar::VPbkSingleContactOperationComplete" );
+    iWaiter->Cancel();
+    delete iTempContact;
+    iTempContact = aContact;
+    }
+void CCreatorInterimCalendar::HandleSingleContactResultL()
+	{
+    if( iTempContact )
+        {
+        TPtrC firstName;
+        TPtrC lastName;
+        TPtrC email;
+    
+        // Put contact's name to temporary member:
+        delete iTmpCN;
+        iTmpCN = 0;
+        delete iTmpEmail;
+        iTmpEmail = 0;
+    
+        MVPbkStoreContactFieldCollection& fields = iTempContact->Fields();
+        TInt fieldCount = fields.FieldCount();
+        for (TInt i = 0; i < fieldCount; ++i)
+            {
+            MVPbkStoreContactField& field = fields.FieldAt(i);
+            MVPbkContactFieldData& fieldData = field.FieldData();
+            const MVPbkFieldType* fieldType = field.BestMatchingFieldType();
+            
+            if( fieldType ) 
+                {
+                TInt fieldId( fieldType->FieldTypeResId() );
+            
+                TVPbkFieldStorageType dataType = fieldData.DataType();
+                if( dataType == EVPbkFieldStorageTypeText)
+                    {
+                    MVPbkContactFieldTextData& textData = MVPbkContactFieldTextData::Cast(fieldData);                
+                    if( fieldId == R_VPBK_FIELD_TYPE_FIRSTNAME )
+                        {                    
+                        firstName.Set(textData.Text());
+                        }
+                    else if( fieldId == R_VPBK_FIELD_TYPE_LASTNAME )
+                        {
+                        lastName.Set(textData.Text());                          
+                        }
+                    else if( fieldId == R_VPBK_FIELD_TYPE_EMAILGEN ||
+                            fieldId == R_VPBK_FIELD_TYPE_EMAILHOME ||
+                            fieldId == R_VPBK_FIELD_TYPE_EMAILWORK )
+                        {
+                        email.Set(textData.Text());                        
+                        }
+                    }            
+                }
+            }
+        if( firstName.Length() > 0 && lastName.Length() > 0 )
+            {
+            _LIT(KSpace, " ");
+            TRAPD(err, iTmpCN = HBufC::NewL(firstName.Length() + lastName.Length() + 1 ));
+            if( err == KErrNone )
+            	{
+            	iTmpCN->Des().Copy(firstName);
+            	iTmpCN->Des().Append(KSpace);
+            	iTmpCN->Des().Append(lastName);
+            	}
+            }
+        else if( firstName.Length() > 0 )
+            {
+            TRAPD(err, iTmpCN = HBufC::NewL(firstName.Length()));
+            if( err == KErrNone )
+            	{
+            	iTmpCN->Des().Copy(firstName);
+            	}
+            }
+        else if( lastName.Length() > 0 )
+            {
+            TRAPD(err, iTmpCN = HBufC::NewL(lastName.Length()));
+            if( err == KErrNone )
+            	{
+            	iTmpCN->Des().Copy(lastName);
+            	}
+            }
+        
+        if( email.Length() > 0 )
+            {
+            TRAPD(err, iTmpEmail = HBufC::NewL(email.Length()));
+            if( err == KErrNone )
+            	{
+            	iTmpEmail->Des().Copy(email);
+            	}
+            }
+        delete iTempContact;
+        iTempContact = 0;
+        }
+    }
+    
+void CCreatorInterimCalendar::VPbkSingleContactOperationFailed(
+            MVPbkContactOperationBase& /*aOperation*/, 
+            TInt aError )
+    {
+    LOGSTRING2("Creator: CCreatorInterimCalendar::VPbkSingleContactOperationFailed - Error: %d", aError );
+    iWaiter->Cancel();
+    delete iTempContact;
+    iTempContact = 0;
+    }
+
+
+
+void CCreatorInterimCalendar::OpenComplete()
+    {    
+    LOGSTRING("Creator: CreatorInterimCalendar::OpenComplete()");
+    iWaiter->Cancel();
+    }
+
+void CCreatorInterimCalendar::StoreReady(MVPbkContactStore& /*aContactStore*/)
+    {
+    LOGSTRING("Creator: CreatorInterimCalendar::StoreReady()");
+    iWaiter->Cancel();
+    }
+
+void CCreatorInterimCalendar::StoreUnavailable(MVPbkContactStore& /*aContactStore*/, 
+        TInt /*aReason*/)
+    {
+    LOGSTRING("Creator: CreatorInterimCalendar::StoreUnavailable()");
+    iWaiter->Cancel();
+    }
+
+
+void CCreatorInterimCalendar::HandleStoreEventL(
+        MVPbkContactStore& /*aContactStore*/, 
+        TVPbkContactStoreEvent /*aStoreEvent*/)
+    {
+    LOGSTRING("Creator: CreatorInterimCalendar::HandleStoreEventL()");
+    iWaiter->Cancel();
+    }
+
+void CCreatorInterimCalendar::FindCompleteL( MVPbkContactLinkArray* aResults )
+    {
+    LOGSTRING("Creator: CreatorInterimCalendar::FindCompleteL()");
+    iWaiter->Cancel();
+    iExistingContacts = aResults;
+    }
+
+void CCreatorInterimCalendar::FindFailed( TInt aError )
+    {
+    LOGSTRING2("Creator: CreatorInterimCalendar::FindFailed() - Error: %d", aError);    
+    iWaiter->Cancel();
+    delete iExistingContacts;
+    iExistingContacts = 0;
+    }
+#endif
+//----------------------------------------------------------------------------
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_calendarelement.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,594 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include "creator_calendarelement.h"
+#include "creator_traces.h"
+#include "creator_calendar.h"
+
+using namespace creatorcalendar;
+
+CCreatorCalendarElement* CCreatorCalendarElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext )
+    {
+    CCreatorCalendarElement* self = new (ELeave) CCreatorCalendarElement(aEngine);
+    CleanupStack::PushL(self);
+    self->ConstructL(aName, aContext);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+void CCreatorCalendarElement::FillEntryParamsL(TEntryType aType, const RPointerArray<CCreatorScriptElement>& fields, CCalenderInterimParameters* parameters)
+    {
+    if( parameters == 0 )
+        return;
+    
+    TBool startResolved = EFalse;    
+    TBool endResolved = EFalse;
+    
+    for( TInt i = 0; i < fields.Count(); ++i )
+        {
+        TPtrC elemName = fields[i]->Name();
+        TPtrC elemContent = fields[i]->Content();
+        const CCreatorScriptAttribute* randomAttr = fields[i]->FindAttributeByName(KRandomLength);
+        
+        if( elemName == KSummary || elemName == KDescription )
+            {           
+            if( randomAttr || elemContent.Length() == 0 )
+                {      
+                TPtrC reason;
+                if( aType == EAppointment )
+                    {
+                    reason.Set(iEngine->RandomString (CCreatorEngine::EMeetingReason ));                    
+                    }
+                else if( aType == EEvent )
+                    {
+                    reason.Set(iEngine->RandomString(CCreatorEngine::EMemoText));                    
+                    }
+                else if( aType == EReminder )
+                    {
+                    reason.Set(iEngine->RandomString(CCreatorEngine::EReminderText));                    
+                    }
+                else if( aType == EAnniversary )
+                    {                   
+                    reason.Set(iEngine->RandomString(CCreatorEngine::EAnniversaryReason));                    
+                    }
+                else if( aType == ETodo )
+                    {
+                    reason.Set(iEngine->RandomString(CCreatorEngine::EToDoText));                    
+                    }
+                
+                if( elemName == KDescription )
+                    {
+                    delete parameters->iDescription;
+                    parameters->iDescription = 0;
+                    parameters->iDescription = HBufC::NewL(reason.Length());
+                    parameters->iDescription->Des().Copy(reason);
+                    }
+                else if(elemName == KSummary)
+                    {
+                    delete parameters->iSummary;
+                    parameters->iSummary = 0;
+                    parameters->iSummary = HBufC::NewL(reason.Length());
+                    parameters->iSummary->Des().Copy(reason);
+                    }
+                }
+            else if( elemName == KDescription )                
+                {                
+                delete parameters->iDescription;
+                parameters->iDescription = 0;
+                parameters->iDescription = HBufC::NewL(elemContent.Length());
+                parameters->iDescription->Des().Copy(elemContent);
+                }
+            else if( elemName == KSummary)
+                {
+                delete parameters->iSummary;
+                parameters->iSummary = 0;
+                parameters->iSummary = HBufC::NewL(elemContent.Length());
+                parameters->iSummary->Des().Copy(elemContent);
+                }
+            }
+        else if( elemName == KLocation )
+            {
+            delete parameters->iLocation;
+            parameters->iLocation = 0;
+            
+            if( randomAttr || elemContent.Length() == 0 )
+                {
+                TPtrC reason = iEngine->RandomString (CCreatorEngine::EMeetingPlace );
+                parameters->iLocation = HBufC::NewL(reason.Length());
+                parameters->iLocation->Des().Copy(reason);
+                }
+            else
+                {
+                parameters->iLocation = HBufC::NewL(elemContent.Length());
+                parameters->iLocation->Des().Copy(elemContent);
+                }
+            }
+        else if( elemName == KStarttime )
+            {
+            if( randomAttr || elemContent.Length() == 0 )
+                {                
+                // Random start time used. If end time is already resolved, let's use that one for the basis. 
+                if( endResolved )
+                    {                    
+                    parameters->iStartTime = iEngine->RandomTime(parameters->iEndTime, CCreatorEngine::EDatePast);                    
+                    }
+                else
+                    {
+                    // Past or future:
+                    CCreatorEngine::TRandomDateType pastOrfuture = 
+                    (CCreatorEngine::TRandomDateType) iEngine->RandomNumber((TInt) CCreatorEngine::EDatePast,
+                                                                            (TInt) CCreatorEngine::EDateFuture);
+                    
+                    parameters->iStartTime = 
+                        iEngine->RandomTime(iEngine->RandomDate(pastOrfuture), pastOrfuture);  
+                    }
+                }
+            else
+                {
+                parameters->iStartTime = ConvertToDateTimeL(elemContent);                
+                }            
+            startResolved = ETrue;
+            }
+        else if( elemName == KEndtime )
+            {
+            if( randomAttr || elemContent.Length() == 0 )
+                {
+                // Random end time used. If start time is already resolved, let's use that one.                
+                if( startResolved )
+                    {                    
+                    parameters->iEndTime = iEngine->RandomTime(parameters->iStartTime, CCreatorEngine::EDateFuture);                    
+                    }
+                else
+                    {
+                    // Past or future:
+                    CCreatorEngine::TRandomDateType pastOrfuture = 
+                    (CCreatorEngine::TRandomDateType) iEngine->RandomNumber((TInt) CCreatorEngine::EDatePast,
+                            (TInt) CCreatorEngine::EDateFuture);
+                    
+                    parameters->iEndTime = 
+                    iEngine->RandomTime(iEngine->RandomDate(pastOrfuture), pastOrfuture);  
+                    }                          
+                }
+            else
+                {
+                parameters->iEndTime = ConvertToDateTimeL(elemContent);
+                }
+            if( aType == ETodo )
+                {
+                parameters->iTodoDueTime = parameters->iEndTime;
+                }
+            }
+        else if( elemName == KRecurrentFreq )
+            {
+            TInt randomFreq = 0;
+            if( randomAttr || elemContent.Length() == 0 )
+                {
+                randomFreq = iEngine->RandomNumber(1, 4);
+                }
+            if(randomFreq == 1 || CompareIgnoreCase(elemContent, KDaily) == 0 )
+                parameters->iRecurrentFrequency = TCalRRule::EDaily;
+            else if( randomFreq == 2 || CompareIgnoreCase(elemContent, KWeekly) == 0 )
+                parameters->iRecurrentFrequency = TCalRRule::EWeekly;
+            else if( randomFreq == 3 || CompareIgnoreCase(elemContent, KMonthly) == 0 )
+                parameters->iRecurrentFrequency = TCalRRule::EMonthly;
+            else if( randomFreq == 4 || CompareIgnoreCase(elemContent, KYearly) == 0 )
+                parameters->iRecurrentFrequency = TCalRRule::EYearly;
+            else
+                parameters->iRecurrentFrequency = TCalRRule::EInvalid;            
+            }
+        else if( elemName == KRecurrentInterval )
+            {
+            if( randomAttr || elemContent.Length() == 0 )
+                {
+                parameters->iRecurrentInterval = iEngine->RandomNumber(1,7);
+                }
+            else
+                {
+                parameters->iRecurrentInterval = ConvertStrToIntL(elemContent);
+                }
+            }
+        else if( elemName == KRecurrentFrom )
+            {
+            if( randomAttr || elemContent.Length() == 0 )
+                {
+                if( startResolved )
+                    {
+                    // Let's use the start time if it's resolved.
+                    parameters->iRecurrentStartTime = parameters->iStartTime;
+                    }
+                else
+                    {
+                    parameters->iRecurrentStartTime = iEngine->RandomDate(CCreatorEngine::EDateFuture);
+                    }
+                }
+            else
+                {
+                parameters->iRecurrentStartTime = ConvertToDateTimeL(elemContent);
+                }           
+            }
+        else if( elemName == KRecurrentTo )
+            {
+            if( randomAttr || elemContent.Length() == 0 )
+                {
+                parameters->iRepeatingCount = iEngine->RandomNumber(1, 6);
+                //parameters->iRecurrentEndTime = iEngine->RandomDate(CCreatorEngine::EDateFuture);                
+                }
+            else
+                {
+                parameters->iRecurrentEndTime = ConvertToDateTimeL(elemContent);
+                }           
+            }
+        else if( elemName == KRepeatingCount )
+            {
+            if( randomAttr || elemContent.Length() == 0 )
+                {
+                parameters->iRepeatingCount = iEngine->RandomNumber(1, 52);
+                }
+            else
+                {
+                parameters->iRepeatingCount = ConvertStrToIntL(elemContent);
+                }
+            }
+        else if( elemName == KAlarmtime )
+            {
+            if( randomAttr || elemContent.Length() == 0 )
+                {                
+                parameters->iUseRandomAlarmTime = ETrue;
+                }
+            else
+                {
+                parameters->iAlarmTime = ConvertToDateTimeL(elemContent);
+                }
+            }
+        else if( elemName == KOrganizername )
+            {
+            delete parameters->iOrganizerName;
+            parameters->iOrganizerName = 0;
+            if( randomAttr || elemContent.Length() == 0 )
+                {
+                TPtrC name = iEngine->RandomString (CCreatorEngine::EFirstName );
+                parameters->iOrganizerName = HBufC::NewL(name.Length());
+                parameters->iOrganizerName->Des().Copy(name);
+                }
+            else
+                {            
+                parameters->iOrganizerName = HBufC::NewL(elemContent.Length());
+                parameters->iOrganizerName->Des().Copy(elemContent);
+                }
+            }
+        else if( elemName == KOrganizeremail )
+            {
+            delete parameters->iOrganizerEmail;
+            parameters->iOrganizerEmail = 0;
+            if( randomAttr || elemContent.Length() == 0 )
+                {
+                TDesC* email = iEngine->CreateEmailAddressLC();
+                parameters->iOrganizerEmail = (HBufC*) email;
+                CleanupStack::Pop(); // email
+                }
+            else
+                {
+                parameters->iOrganizerEmail = HBufC::NewL(elemContent.Length());
+                parameters->iOrganizerEmail->Des().Copy(elemContent);
+                }
+            }
+        else if( elemName == KStatus )
+            {
+            if( randomAttr || elemContent.Length() == 0 )
+                {
+                if( aType == ETodo )
+                	{
+                	parameters->iStatus = (CCalEntry::TStatus) iEngine->RandomNumber(CCalEntry::ETodoNeedsAction, CCalEntry::ETodoInProcess);
+                	}
+                else
+                	{
+                	parameters->iStatus = (CCalEntry::TStatus) iEngine->RandomNumber(CCalEntry::ETentative, CCalEntry::ECancelled);
+                	}
+                }
+            else if( CompareIgnoreCase(elemContent, KCalStatusTentative) == 0 )
+                {
+                parameters->iStatus = CCalEntry::ETentative;
+                }
+            else if( CompareIgnoreCase(elemContent, KCalStatusConfirmed) == 0 )
+                {
+                parameters->iStatus = CCalEntry::EConfirmed;
+                }
+            else if( CompareIgnoreCase(elemContent, KCalStatusCancelled) == 0 )
+                {
+                parameters->iStatus = CCalEntry::ECancelled;
+                }
+            else if( CompareIgnoreCase(elemContent, KCalStatusNeedsAction) == 0 )
+                {
+                parameters->iStatus = CCalEntry::ETodoNeedsAction;
+                }
+            else if( CompareIgnoreCase(elemContent, KCalStatusCompleted) == 0 )
+                {
+                parameters->iStatus = CCalEntry::ETodoCompleted;
+                }
+            else if( CompareIgnoreCase(elemContent, KCalStatusInProcess) == 0 )
+                {
+                parameters->iStatus = CCalEntry::ETodoInProcess;
+                }
+            else
+                {
+                parameters->iStatus = CCalEntry::ENullStatus;
+                }
+            }
+        else if( elemName == KPriority )
+            {
+            if( randomAttr || elemContent.Length() == 0 )
+                {
+                parameters->iTodoPriority = iEngine->RandomNumber(1,3);
+                }            
+            else if( CompareIgnoreCase(elemContent, KPriorityHigh) == 0)
+                {
+                parameters->iTodoPriority = 1;
+                }
+            else if( CompareIgnoreCase(elemContent, KPriorityMedium) == 0)
+                {
+                parameters->iTodoPriority = 2;
+                }
+            else if( CompareIgnoreCase(elemContent, KPriorityLow) == 0 )
+                {
+                parameters->iTodoPriority = 3;
+                }
+            else
+                {
+                parameters->iTodoPriority = ConvertStrToIntL(elemContent);
+                }
+            }
+        else if( elemName == KAttendees )
+            {            
+            const RPointerArray<CCreatorScriptElement>& attendeesSubElems = fields[i]->SubElements();
+            for( TInt j = 0; j < attendeesSubElems.Count(); ++j )
+                {
+                TPtrC eName = attendeesSubElems[j]->Name();
+                TPtrC eContent = attendeesSubElems[j]->Content();
+                if( eName == KContactSetRef )
+                    {
+                    AppendContactSetReferenceL(*attendeesSubElems[j], parameters->iAttendeeLinkIds);
+                    }
+                else if( eName == KAttendee )
+                    {
+                    CCreatorCalenderAttendee* calAtt = CCreatorCalenderAttendee::NewL();
+                    CleanupStack::PushL(calAtt);
+                    const RPointerArray<CCreatorScriptElement>& attendeeFields = attendeesSubElems[j]->SubElements();
+                    // Make sure that at least email is given:
+                    if(attendeeFields.Count() == 0 )
+                    	{
+                    	CCreatorScriptElement* emailField =  CCreatorScriptElement::NewL(iEngine, KEmail );
+                    	CleanupStack::PushL(emailField);
+                    	fields[i]->SubElements().AppendL(emailField);
+                    	CleanupStack::Pop(); // emailField	
+                    	}
+                    for( TInt k = 0; k < attendeeFields.Count(); ++k )
+                        {
+                        const CCreatorScriptAttribute* randomAttr = attendeeFields[k]->FindAttributeByName(KRandomLength);
+                        TPtrC attElemName = attendeeFields[k]->Name();
+                        TPtrC attElemCont = attendeeFields[k]->Content();
+                        if( attElemName == KCommonname )
+                            {
+                            if( randomAttr || attElemCont.Length() == 0)
+                                {
+                                // Random data:
+                                calAtt->SetCommonNameL(iEngine->RandomString(CCreatorEngine::EFirstName));
+                                }
+                            else
+                                {
+                                calAtt->SetCommonNameL(attElemCont);
+                                }
+                            }
+                        else if( attElemName == KEmail )
+                            {
+                            if( randomAttr || attElemCont.Length() == 0)
+                                {
+                                // Random data:
+                                TDesC* email = iEngine->CreateEmailAddressLC();
+                                calAtt->SetEmailAddressL(*email);
+                                CleanupStack::PopAndDestroy(); // email
+                                }
+                            else
+                                {                                
+                                calAtt->SetEmailAddressL(attElemCont);
+                                }
+                            }
+                        else if( attElemName == KRole )
+                            {
+                            if( randomAttr || attElemCont.Length() == 0)
+                                {
+                                // Random role:
+                                CCalAttendee::TCalRole randomRole = 
+                                    (CCalAttendee::TCalRole) iEngine->RandomNumber(
+                                            (TInt) CCalAttendee::EReqParticipant, 
+                                            (TInt) CCalAttendee::EChair);
+                                calAtt->SetRole(randomRole);
+                                }                                
+                            else if( CompareIgnoreCase(attElemCont, KRoleRequired) == 0 )
+                                {
+                                calAtt->SetRole(CCalAttendee::EReqParticipant);
+                                }
+                            else if( CompareIgnoreCase(attElemCont, KRoleOptional) == 0 )
+                                {
+                                calAtt->SetRole(CCalAttendee::EOptParticipant);
+                                }
+                            else if( CompareIgnoreCase(attElemCont, KRoleNonPart) == 0 )
+                                {
+                                calAtt->SetRole(CCalAttendee::ENonParticipant);
+                                }
+                            else if( CompareIgnoreCase(attElemCont, KRoleChair) == 0 )
+                                {
+                                calAtt->SetRole(CCalAttendee::EChair);
+                                }
+                            }
+                        else if( attElemName == KStatus )
+                            {
+                            if( randomAttr || attElemCont.Length() == 0)
+                                {
+                                // Random role:
+                                CCalAttendee::TCalStatus randomStatus = 
+                                (CCalAttendee::TCalStatus) iEngine->RandomNumber(
+                                        (TInt) CCalAttendee::ENeedsAction, 
+                                        (TInt) CCalAttendee::EInProcess);
+                                calAtt->SetStatus(randomStatus);
+                                }                                
+                            else if( CompareIgnoreCase(attElemCont, KStatusNeedsAction) == 0 )
+                                {
+                                calAtt->SetStatus(CCalAttendee::ENeedsAction);
+                                }
+                            else if( CompareIgnoreCase(attElemCont, KStatusAccepted) == 0 )
+                                {
+                                calAtt->SetStatus(CCalAttendee::EAccepted);
+                                }
+                            else if( CompareIgnoreCase(attElemCont, KStatusTentative) == 0 )
+                                {
+                                calAtt->SetStatus(CCalAttendee::ETentative);
+                                }
+                            else if( CompareIgnoreCase(attElemCont, KStatusConfirmed) == 0 )
+                                {
+                                calAtt->SetStatus(CCalAttendee::EConfirmed);
+                                }
+                            else if( CompareIgnoreCase(attElemCont, KStatusDeclined) == 0 )
+                                {
+                                calAtt->SetStatus(CCalAttendee::EDeclined);
+                                }
+                            else if( CompareIgnoreCase(attElemCont, KStatusCompleted) == 0 )
+                                {
+                                calAtt->SetStatus(CCalAttendee::ECompleted);
+                                }
+                            else if( CompareIgnoreCase(attElemCont, KStatusDelegated) == 0 )
+                                {                                
+                                calAtt->SetStatus(CCalAttendee::EDelegated);
+                                }
+                            else if( CompareIgnoreCase(attElemCont, KStatusInProcess) == 0 )
+                                {                                
+                                calAtt->SetStatus(CCalAttendee::EInProcess);
+                                }
+                            }
+                        }
+                    parameters->iAttendees.AppendL(calAtt);
+                    CleanupStack::Pop(); // calAtt
+                    }
+                }
+            }
+        }    
+    }
+
+void CCreatorCalendarElement::ExecuteCommandL()
+	{
+	LOGSTRING("Creator: CCreatorCalendarElement::ExecuteCommandL");
+	// Amount of calendar entries:
+	const CCreatorScriptAttribute* calEntryAmountAttr = this->FindAttributeByName(KAmount);
+	const CCreatorScriptAttribute* calEntryTypeAttr = this->FindAttributeByName(KType);    
+	TInt entryAmount = 1;    
+	if( calEntryAmountAttr )
+		{
+		entryAmount = ConvertStrToIntL(calEntryAmountAttr->Value());
+		}
+	if( calEntryTypeAttr == 0 )
+		{
+		LOGSTRING("ERROR in CCreatorCalendarElement::ExecuteCommandL: Type attribute is missing.");
+		User::Leave(KErrGeneral); // type is required attribute
+		}
+
+	// Find fields element:
+	CCreatorScriptElement* fieldsElement = FindSubElement(KFields);
+	
+	for( TInt cI = 0; cI < entryAmount; ++cI )
+		{
+		CCalenderInterimParameters* param = new (ELeave) CCalenderInterimParameters;
+		CleanupStack::PushL(param);
+		if( CompareIgnoreCase(calEntryTypeAttr->Value(), KCalTypeAppointment) == 0 )
+			{
+			if( fieldsElement && fieldsElement->SubElements().Count() > 0 )
+				{
+				FillEntryParamsL(EAppointment, fieldsElement->SubElements(), param);
+				iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryAppointments, param);
+				}
+			else
+				{
+				iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryAppointments, 0, entryAmount);
+				CleanupStack::PopAndDestroy(param);
+				break; // We can step out from the for-loop, because the amount is given to engine.
+				}
+			}		
+		else if( CompareIgnoreCase(calEntryTypeAttr->Value(), KCalTypeEvent ) == 0 )
+			{
+			if( fieldsElement && fieldsElement->SubElements().Count() > 0 )
+				{
+				FillEntryParamsL(EEvent, fieldsElement->SubElements(), param);
+				iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryEvents, param);
+				}
+			else
+				{
+				iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryEvents, 0, entryAmount);
+				CleanupStack::PopAndDestroy(param);
+				break;  // We can step out from the for-loop, because the amount is given to engine.
+				}
+			}
+		else if( CompareIgnoreCase(calEntryTypeAttr->Value(), KCalTypeReminder ) == 0 )
+			{
+			if( fieldsElement && fieldsElement->SubElements().Count() > 0 )
+				{
+				FillEntryParamsL(EReminder, fieldsElement->SubElements(), param);
+				iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryReminders, param);
+				}
+			else
+				{
+				iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryReminders, 0, entryAmount);
+				CleanupStack::PopAndDestroy(param);
+				break;  // We can step out from the for-loop, because the amount is given to engine.
+				}
+			}
+		else if( CompareIgnoreCase(calEntryTypeAttr->Value(), KCalTypeAnniversary ) == 0 )
+			{
+			if( fieldsElement && fieldsElement->SubElements().Count() > 0 )
+				{
+				FillEntryParamsL(EAnniversary, fieldsElement->SubElements(), param);
+				iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryAnniversaries, param);
+				}
+			else
+				{
+				iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryAnniversaries, 0, entryAmount);
+				CleanupStack::PopAndDestroy(param);
+				break;  // We can step out from the for-loop, because the amount is given to engine.
+				}
+			}
+		else if( CompareIgnoreCase(calEntryTypeAttr->Value(), KCalTypeTodo ) == 0 )
+			{
+			if( fieldsElement && fieldsElement->SubElements().Count() > 0 )
+				{
+				FillEntryParamsL(ETodo, fieldsElement->SubElements(), param);
+				iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryToDos, param);
+				}
+			else
+				{
+				iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryToDos, 0, entryAmount);
+				CleanupStack::PopAndDestroy(param);
+				break;  // We can step out from the for-loop, because the amount is given to engine.
+				}
+			}
+		CleanupStack::Pop(); // param
+		}
+	}
+
+CCreatorCalendarElement::CCreatorCalendarElement(CCreatorEngine* aEngine) 
+: 
+CCreatorScriptElement(aEngine)
+    {
+    iIsCommandElement = ETrue;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_connectionmethod.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,948 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include "creator_connectionmethod.h" 
+#include "creator_traces.h"
+
+using namespace CMManager;
+
+#include <cmpluginpacketdatadef.h>  
+#include <cmplugincsddef.h> 
+#include <cmpluginhscsddef.h> 
+#include <cmmanagerext.h>
+#include <cmdestinationext.h> 
+#include <cmpluginembdestinationdef.h>
+#include <cmpluginvpndef.h>
+#include <cmpluginlanbasedef.h> 
+#include <cmdefconnvalues.h>
+#include <cmconnectionmethoddef.h>
+
+
+#include <wlanmgmtinterface.h>
+#include <wlanmgmtclient.h>
+#include <wlanmgmtclient.inl> 
+#include <wlanmgmtcommon.h> 
+#include <wlanscaninfo.h> 
+#include <wlanscaninfo.inl> 
+#include <wlanscaninfointerface.h>
+
+//#include <WEPSecuritySettingsUI.h>//For WEP setting
+//#include <dbcreatorcommon.h>
+
+static const TInt KConnectionSettingssFieldLength = 128;
+
+_LIT(KCreatorConnectionSettingssPrefixName, "CR_");
+
+//----------------------------------------------------------------------------
+
+CConnectionSettingsParameters::CConnectionSettingsParameters()
+    {
+    LOGSTRING("Creator: CConnectionSettingsParameters::CConnectionSettingsParameters");
+        
+    iConnectionName = HBufC::New(KConnectionSettingssFieldLength);
+    iStartPage = HBufC::New(KConnectionSettingssFieldLength);
+    iLoginName = HBufC::New(KConnectionSettingssFieldLength);
+    iLoginPass = HBufC::New(KConnectionSettingssFieldLength);
+    iIPAddr = HBufC::New(KConnectionSettingssFieldLength);
+    iIP4NameServer1 = HBufC::New(KConnectionSettingssFieldLength);
+    iIP4NameServer2 = HBufC::New(KConnectionSettingssFieldLength);
+    iDefaultTelNumber = HBufC::New(KConnectionSettingssFieldLength);
+    iProxyServerAddress = HBufC::New(KConnectionSettingssFieldLength);
+    iSubnetMask = HBufC::New(KConnectionSettingssFieldLength); 
+    iGatewayAddress = HBufC::New(KConnectionSettingssFieldLength);
+    iWLANName = HBufC::New(KConnectionSettingssFieldLength);
+    iWlanIpAddr = HBufC::New(KConnectionSettingssFieldLength);
+    iIP6NameServer1 = HBufC::New(KConnectionSettingssFieldLength);
+    iIP6NameServer2 = HBufC::New(KConnectionSettingssFieldLength);
+    }
+
+CConnectionSettingsParameters::~CConnectionSettingsParameters()
+    {
+    LOGSTRING("Creator: CConnectionSettingssParameters::~CConnectionSettingssParameters");
+
+    delete iProxyServerAddress;
+    delete iDefaultTelNumber;
+    delete iIP4NameServer2;
+    delete iIP4NameServer1;
+    delete iIPAddr;    
+    delete iLoginPass;
+    delete iLoginName;
+    delete iStartPage;
+    delete iConnectionName;
+    delete iSubnetMask;  
+    delete iGatewayAddress;
+    delete iWLANName;
+    delete iWlanIpAddr;
+    delete iIP6NameServer1;
+    delete iIP6NameServer2;    
+    }
+
+//----------------------------------------------------------------------------
+
+CCreatorConnectionSettings* CCreatorConnectionSettings::NewL(CCreatorEngine* aEngine)
+    {
+    CCreatorConnectionSettings* self = CCreatorConnectionSettings::NewLC(aEngine);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CCreatorConnectionSettings* CCreatorConnectionSettings::NewLC(CCreatorEngine* aEngine)
+    {
+    CCreatorConnectionSettings* self = new (ELeave) CCreatorConnectionSettings;
+    CleanupStack::PushL(self);
+    self->ConstructL(aEngine);
+    return self;
+    }
+
+CCreatorConnectionSettings::CCreatorConnectionSettings()
+    {
+    }
+
+void CCreatorConnectionSettings::ConstructL(CCreatorEngine* aEngine)
+    {
+    LOGSTRING("Creator: CCreatorConnectionSettings::ConstructL");
+
+    iEngine = aEngine;
+    
+    iCmManagerExt.CreateTablesAndOpenL();
+    }
+
+CCreatorConnectionSettings::~CCreatorConnectionSettings()
+    {
+    LOGSTRING("Creator: CCreatorConnectionSettings::~CCreatorConnectionSettings");
+
+    if ( iEngine && iEntryIds.Count() )
+        {
+        TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iEntryIds, KUidDictionaryUidIAP ) );
+        }
+    iEntryIds.Reset();
+    iEntryIds.Close();
+    
+    if (iParameters)
+        {
+        delete iParameters;
+        }
+    
+    iCmManagerExt.Close();
+    }
+    
+
+//----------------------------------------------------------------------------
+
+TBool CCreatorConnectionSettings::AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries)
+    {
+    LOGSTRING("Creator: CCreatorConnectionSettings::AskDataFromUserL");
+
+    if( aCommand == ECmdDeleteIAPs )
+        {
+        return iEngine->YesNoQueryDialogL(_L("Delete all Connection Methods?") );
+        }
+    else if( aCommand == ECmdDeleteCreatorIAPs )
+        {
+        return iEngine->YesNoQueryDialogL(_L("Delete all Connection Methods created with Creator?") );
+        }
+    else
+        {
+        return iEngine->EntriesQueryDialogL(aNumberOfEntries, _L("How many entries to create?"));
+        }
+    }
+
+
+//----------------------------------------------------------------------------
+
+TInt CCreatorConnectionSettings::CreateConnectionSettingsEntryL(CCreatorModuleBaseParameters *aParameters)
+    {
+    LOGSTRING("Creator: CCreatorConnectionSettings::CreateConnectionSettingsEntryL");
+
+    CConnectionSettingsParameters* parameters = (CConnectionSettingsParameters*) aParameters;
+    
+    // clear any existing parameter definations 
+    delete iParameters;
+    iParameters = NULL;
+            
+    // random data needed if no predefined data available
+    if (!parameters)
+        {
+        iParameters = new (ELeave) CConnectionSettingsParameters();
+        parameters = iParameters;
+        SetRandomParametersL(*parameters);
+        }
+    
+    if( parameters->iBearerType == KRandomBearerType )
+    	{
+    	SetRandomBearerTypeL(*parameters);
+    	}
+    
+    TInt err = KErrNone;
+
+    // create unique name for each network destination
+    RCmDestinationExt dest;
+    TInt destinationError = KErrNone;
+    TInt count = 0;
+	TBuf<KConnectionSettingssFieldLength> name;
+	name.Copy(parameters->iConnectionName->Des());
+    do
+    	{
+    	TRAP(destinationError, dest = iCmManagerExt.CreateDestinationL(name));
+    	if (destinationError == KErrAlreadyExists)
+    		{
+    		name.Copy(parameters->iConnectionName->Des());
+    		count++;
+    		name.AppendFormat(_L(" (%d)"), count);
+    		}
+    	else if (destinationError != KErrNone)
+    		{
+    		User::Leave(destinationError);
+    		}
+    	}
+    while (destinationError == KErrAlreadyExists);
+    parameters->iConnectionName->Des().Copy(name);        
+
+    CleanupClosePushL(dest);
+    dest.UpdateL();
+    
+    RCmConnectionMethodExt conMethod = dest.CreateConnectionMethodL( parameters->iBearerType);//KUidPacketDataBearerType
+    CleanupClosePushL( conMethod );
+    
+    if(parameters->iBearerType == KUidWlanBearerType)
+        {
+        //IP net mask of interface
+        conMethod.SetStringAttributeL( EWlanIpNetMask, parameters->iSubnetMask->Des()  );
+
+        //IP address of EPOC.
+        conMethod.SetStringAttributeL( EWlanIpAddr, parameters->iWlanIpAddr->Des()  );
+        //
+        //following gateway ID:s is not workin, 
+        //logically ID would be EWlanIpGateway because EWlanIpNetMask
+        //is going to net mask, which is just before gateway in ui
+        //--->
+        conMethod.SetStringAttributeL( EWlanIpGateway, parameters->iGatewayAddress->Des()  );
+        //conMethod.SetStringAttributeL( EApIspIPGateway, parameters->iGatewayAddress->Des()  );
+        conMethod.SetStringAttributeL( ECmWapIPGatewayAddress, parameters->iGatewayAddress->Des()  );
+        conMethod.SetStringAttributeL( ECmIPGateway, parameters->iGatewayAddress->Des()  );
+        //<---
+        
+        //IP Address of primary and secondary name server (IP v4).
+        conMethod.SetStringAttributeL( EWlanIpNameServer1, parameters->iIP4NameServer1->Des()  );
+        conMethod.SetStringAttributeL( EWlanIpNameServer2, parameters->iIP4NameServer2->Des()  );
+        //The SSID of this WLAN connection.
+        conMethod.SetStringAttributeL( EWlanSSID, parameters->iWLANName->Des()  );
+
+        //IP6 address of primary and secondary name servers
+        conMethod.SetStringAttributeL( EWlanIp6NameServer1, parameters->iIP6NameServer1->Des()  );
+        conMethod.SetStringAttributeL( EWlanIp6NameServer2, parameters->iIP6NameServer2->Des()  );        
+
+        //
+        //Setting secure mode settings
+        //
+        
+        //Network status (default: EWlanSecModeOpen) // EWlanAuthenticationMode use instead?
+        conMethod.SetIntAttributeL( EWlanSecurityMode, parameters->iWLanSecMode );
+        //WLAN Network mode  
+        conMethod.SetIntAttributeL( EWlanConnectionMode, parameters->iWlanNetMode );
+        
+        
+        if(parameters->iWLanSecMode == EWlanSecModeOpen)
+            {}//Nothing to set when mode is open
+        else if(parameters->iWLanSecMode == EWlanSecModeWep)
+            {
+            //See WEPSecuritySettingsUI.h
+            
+            
+            ///CWEPSecuritySettings
+           // conMethod.SetIntAttributeL( EWlanSecurityMode, parameters->iWLanSecMode );
+            }
+        else if(parameters->iWLanSecMode == EWlanSecMode802_1x)
+            {
+            }
+        else if(parameters->iWLanSecMode == EWlanSecModeWpa)
+            {
+            }
+        else if(parameters->iWLanSecMode == EWlanSecModeWpa2)
+            {
+            }            
+        
+        //WLAN security setting 
+        //conMethod.SetStringAttributeL( EWlanAuthenticationMode, parameters->iIP6NameServer2->Des()  );
+        //Utilise this method
+        //conMethod.SetStringAttributeL( EWlanSecurityMode, parameters->iWLanSecMode  );
+        }
+    //Not known special attributes for packet data 
+    else if(parameters->iBearerType == KUidPacketDataBearerType)
+        {
+
+        //Access point name.
+        conMethod.SetStringAttributeL( EPacketDataAPName, parameters->iConnectionName->Des() );//crash
+        
+        //Authentication user name
+        conMethod.SetStringAttributeL( EPacketDataIFAuthName, parameters->iLoginName->Des()  );
+        ///TProtocolType a;
+        //EPdpTypeIPv4 or EPdpTypeIPv6
+        conMethod.SetIntAttributeL( EPacketDataPDPType, parameters->iProtocolType  );
+                
+        //IP6 address of primary and secondary name servers
+        conMethod.SetStringAttributeL( EPacketDataIPIP6NameServer1, parameters->iIP6NameServer1->Des()  );
+        conMethod.SetStringAttributeL( EPacketDataIPIP6NameServer2, parameters->iIP6NameServer2->Des()  );                
+        //IP address of primary name server
+        conMethod.SetStringAttributeL( EPacketDataIPNameServer1, parameters->iIP4NameServer1->Des()  );
+        //IP address of secondary name server
+        conMethod.SetStringAttributeL( EPacketDataIPNameServer2, parameters->iIP4NameServer2->Des()  );
+        
+        //Also existing but UI not showing them: EPacketDataHeaderCompression, EPacketDataDisablePlainTextAuth
+        //EPacketDataIFAuthPass, EDialIFAuthPass, EPacketDataIFPromptForAuth, EPacketDataIPAddr
+        }
+    else if(parameters->iBearerType == KUidCSDBearerType || parameters->iBearerType == KUidHSCSDBearerType)
+        {
+        //Authentication user name
+        conMethod.SetStringAttributeL( EDialIFAuthName, parameters->iLoginName->Des()  );
+        //Dial-up number
+        conMethod.SetStringAttributeL( EDialDefaultTelNum, parameters->iDefaultTelNumber->Des() );
+        //Call type
+        conMethod.SetIntAttributeL( EDialCallType , parameters->iBearerCallTypeIsdn );
+        //Maximum speed
+        conMethod.SetIntAttributeL( EDialMaxConnSpeed, parameters->iBearerSpeed );
+        //Prompt user for username and password? (Only for dial out)
+        conMethod.SetBoolAttributeL( EDialPromptForLogin, parameters->iPromptPassword );
+        //IP6 address of primary and secondary name servers
+        conMethod.SetStringAttributeL( EDialIP6NameServer1, parameters->iIP6NameServer1->Des()  );
+        conMethod.SetStringAttributeL( EDialIP6NameServer2, parameters->iIP6NameServer2->Des()  );         
+        //Disable plaintext authentication
+        conMethod.SetBoolAttributeL( EDialDisablePlainTextAuth, parameters->iDisableTextAuth );       
+        //IP address of primary name server
+        conMethod.SetStringAttributeL( EDialIPNameServer1, parameters->iIP4NameServer1->Des()  );
+        //IP address of secondary name server
+        conMethod.SetStringAttributeL( EDialIPNameServer2, parameters->iIP4NameServer2->Des()  );
+
+        //Also existing  EDialEnableIPHeaderComp; EDialIFPromptForAuth;EDialIPAddress parameters
+        
+        }
+    else if(parameters->iBearerType == KUidLanBearerType)
+        {
+
+        conMethod.SetStringAttributeL( ELanBaseIpNetMask, parameters->iSubnetMask->Des() );
+        conMethod.SetStringAttributeL( ELanBaseIpGateway, parameters->iGatewayAddress->Des());
+        conMethod.SetStringAttributeL( ELanBaseIpAddr, parameters->iIPAddr->Des() );
+        conMethod.SetStringAttributeL( ELanBaseIpNameServer1, parameters->iIP4NameServer1->Des() );
+        conMethod.SetStringAttributeL( ELanBaseIpNameServer2, parameters->iIP4NameServer2->Des() );
+        conMethod.SetStringAttributeL( ELanBaseIp6NameServer1,parameters->iIP6NameServer1->Des() );
+        conMethod.SetStringAttributeL( ELanBaseIp6NameServer2,parameters->iIP6NameServer2->Des() );
+        
+        }
+    else //KUidEmbeddedDestination and KPluginVPNBearerTypeUid
+        {
+        //NOTE: NOT Tested, because no supporting Emulator for them
+        
+        //Authentication user name
+        conMethod.SetStringAttributeL( ECmIFAuthName, parameters->iLoginName->Des()  );
+        //IP6 address of primary and secondary name servers
+        conMethod.SetStringAttributeL( ECmIP6NameServer1, parameters->iIP6NameServer1->Des()  );
+        conMethod.SetStringAttributeL( ECmIP6NameServer2, parameters->iIP6NameServer2->Des()  );        
+        //Disable plaintext authentication
+        conMethod.SetBoolAttributeL( ECmDisablePlainTextAuth, parameters->iDisableTextAuth );
+        //Prompt user for authentication
+        conMethod.SetBoolAttributeL( ECmIFPromptForAuth, parameters->iPromptPassword );
+        //Authentication password
+        conMethod.SetStringAttributeL( ECmIFAuthPass, parameters->iLoginPass->Des()  );
+        }
+    
+    //
+    //Adding common attributes, all not neccessary used with all bearer types, but should not cause any problems eather
+    //
+
+    //CM Name (Connection Method, formelly known as Access Point)         
+    conMethod.SetStringAttributeL( ECmName, parameters->iConnectionName->Des() );        
+    // Start page of CM
+    conMethod.SetStringAttributeL( ECmStartPage, parameters->iStartPage->Des() );
+    // Enable Proxy   
+    conMethod.SetBoolAttributeL( ECmProxyUsageEnabled, parameters->iUseProxy );
+    // Server Name
+    conMethod.SetStringAttributeL( ECmProxyServerName, parameters->iProxyServerAddress->Des() );
+    // Port Number
+    conMethod.SetIntAttributeL( ECmProxyPortNumber, parameters->iProxyPortNumber );
+    //Proxy login name
+    conMethod.SetStringAttributeL( ECmWapIPProxyLoginName, parameters->iLoginName->Des() );
+    //Proxy login password
+    conMethod.SetStringAttributeL( ECmWapIPProxyLoginPass, parameters->iLoginPass->Des() );
+    //IP address of gateway
+    conMethod.SetStringAttributeL( ECmIPGateway, parameters->iGatewayAddress->Des() );
+    //connection-oriented or connectionless API should be used
+    //ECmWapIPWSPOption option TWapWSPOption: ECmWapWspOptionConnectionless or ECmWapWspOptionConnectionOriented    
+    conMethod.SetIntAttributeL( ECmWapIPWSPOption, parameters->iWapWspOption );   
+    //NOT WORKING????? Attempt secure WTLS connection to the gateway
+    conMethod.SetBoolAttributeL( ECmWapIPSecurity, parameters->iSecureAuthentication );
+      
+    //
+    //Adding advanced settings (Network type, Phone IP addr, DNS addr, proxy srv name, proxy port nbr
+    //
+    
+    //IP address of interface
+    conMethod.SetStringAttributeL( ECmIPAddress, parameters->iIPAddr->Des() );    
+    //IP address of primary name server
+    conMethod.SetStringAttributeL( ECmIPNameServer1, parameters->iIP4NameServer1->Des()  );
+    //IP address of secondary name server
+    conMethod.SetStringAttributeL( ECmIPNameServer2, parameters->iIP4NameServer2->Des()  );
+      
+    
+    conMethod.UpdateL();
+
+    //If no defaults set, set the created CM as a default
+    SetDefaultCML( conMethod );
+    
+    // id has been generated, store it for being able to delete
+    // only entries created with Creator
+    iEntryIds.Append( dest.Id() );
+    
+    conMethod.Close();
+    CleanupStack::Pop(  );//conMethod
+    
+    dest.UpdateL();
+    dest.Close();
+    CleanupStack::Pop(); // dest
+        
+    return err;
+    }
+
+//----------------------------------------------------------------------------
+void CConnectionSettingsParameters::SetRandomCMNameL(CCreatorEngine& aEngine)
+    {
+    LOGSTRING("Creator: CConnectionSettingsParameters::SetRandomCMNameL");
+
+    TInt num = aEngine.RandomNumber(1, 3);
+    TBuf<10> apType;
+
+    if (num==1)
+        {
+        apType = _L("mms");
+        }            
+    else if (num==2)
+        {
+        apType = _L("wap");
+        }
+    else
+        {
+        apType = _L("internet");
+        }
+    TBuf<160> company = aEngine.RandomString(CCreatorEngine::ECompany);
+    iConnectionName->Des() = KCreatorConnectionSettingssPrefixName;
+    iConnectionName->Des().Append( company );
+    iConnectionName->Des().Append(_L(" "));
+    iConnectionName->Des().Append(apType);
+    }
+
+void CConnectionSettingsParameters::SetRandomWLANNameL(CCreatorEngine& aEngine)
+    {
+    LOGSTRING("Creator: CConnectionSettingsParameters::SetRandomWLANNameL");
+
+    TBuf<160> company = aEngine.RandomString(CCreatorEngine::ECompany);
+    iWLANName->Des() = KCreatorConnectionSettingssPrefixName;
+    iWLANName->Des().Append( company );
+    iWLANName->Des().Append( _L(" WLAN") );
+    }
+
+void CConnectionSettingsParameters::SetRandomWLANNetModeL(CCreatorEngine& aEngine)
+    {
+    LOGSTRING("Creator: CConnectionSettingsParameters::SetRandomWLANNetModeL");
+
+    TInt wlanNetModeRand = aEngine.RandomNumber(1, 2);
+    if(wlanNetModeRand == 1)
+        {
+        iWlanNetMode = EAdhoc;//Ad-Hoc mode
+        }
+    else
+        {
+        iWlanNetMode = CMManager::EInfra;//Infrastructure mode
+        } 
+    }
+
+void CConnectionSettingsParameters::SetRandomWLANSecurityModeL(CCreatorEngine& aEngine)
+    {
+    LOGSTRING("Creator: CConnectionSettingsParameters::SetRandomWLANSecurityModeL");
+
+    TInt wlanSecModeRand = aEngine.RandomNumber(1, 5);
+    if(wlanSecModeRand == 1)
+        {
+        iWLanSecMode = EWlanSecModeOpen;///< Open security mode
+        }
+    else if(wlanSecModeRand == 2)
+        {
+        iWLanSecMode = EWlanSecModeWep;///< WEP security mode
+        //See WEPSecuritySettingsUI.h
+                
+        ///CWEPSecuritySettings
+                
+        //WEP key in us
+        
+        //Authentication type
+                
+        //WEP Key settings (key len, key format, key data)        
+        }
+    else if(wlanSecModeRand == 3)
+        {
+        iWLanSecMode = EWlanSecMode802_1x; ///< 802.1x security mode
+        }
+    else if(wlanSecModeRand == 4)
+        {
+        iWLanSecMode = EWlanSecModeWpa;///< WPA security mode
+        }
+    else if(wlanSecModeRand == 5)
+        {
+        iWLanSecMode = EWlanSecModeWpa2;///< WPA@ security mode
+        }
+    }
+
+void CConnectionSettingsParameters::SetRandomLoginNameL(CCreatorEngine& aEngine)
+    {
+    iLoginName->Des() = aEngine.RandomString(CCreatorEngine::EFirstName);
+    iLoginName->Des().LowerCase();
+    }
+
+void CConnectionSettingsParameters::SetRandomLoginPassL(CCreatorEngine& aEngine)
+    {
+    iLoginPass->Des() = aEngine.RandomString(CCreatorEngine::ESurname);
+    iLoginPass->Des().LowerCase();
+    }
+
+void CConnectionSettingsParameters::SetRandomSecureAuthenticationL(CCreatorEngine& /*aEngine*/)
+    {
+    iSecureAuthentication = EFalse;
+    }
+
+void CConnectionSettingsParameters::SetRandomPromptPasswordL(CCreatorEngine& /*aEngine*/)
+    {
+    iPromptPassword = ETrue;
+    }
+
+void CConnectionSettingsParameters::SetRandomUseProxyL(CCreatorEngine& /*aEngine*/)
+    {
+    iUseProxy = ETrue;
+    }
+
+void CConnectionSettingsParameters::SetRandomProxyAddressL(CCreatorEngine& /*aEngine*/)
+    {
+    iProxyServerAddress->Des() = _L("127.0.0.1");
+    }
+
+void CConnectionSettingsParameters::SetRandomProxyPortL(CCreatorEngine& /*aEngine*/)
+    {
+    iProxyPortNumber = 80;
+    }
+
+void CConnectionSettingsParameters::SetRandomStartPageL(CCreatorEngine& aEngine)
+    {
+    LOGSTRING("Creator: CConnectionSettingsParameters::SetRandomStartPageL");
+
+    TInt num = aEngine.RandomNumber(1, 3);
+    TBuf<10> apType;
+
+    if (num==1)
+        {
+        apType = _L("mms");
+        }            
+    else if (num==2)
+        {
+        apType = _L("wap");
+        }
+    else
+        {
+        apType = _L("internet");
+        }
+    TBuf<160> company = aEngine.RandomString(CCreatorEngine::ECompany);    
+    iStartPage->Des() = _L("http://");
+    iStartPage->Des().Append(apType);
+    iStartPage->Des().Append(_L("."));
+    iStartPage->Des().Append(company);
+    iStartPage->Des().Append(_L(".com"));
+    iStartPage->Des().LowerCase();
+    }
+
+void CConnectionSettingsParameters::SetRandomIPAddressL(CCreatorEngine& /*aEngine*/)
+    {
+    iIPAddr->Des() = _L("10.10.10.10");
+    }
+
+void CConnectionSettingsParameters::SetRandomIP4NameServer1L(CCreatorEngine& /*aEngine*/)
+    {
+    iIP4NameServer1->Des() = _L("10.1.1.1");
+    }
+void CConnectionSettingsParameters::SetRandomIP4NameServer2L(CCreatorEngine& /*aEngine*/)
+    {
+    iIP4NameServer2->Des() = _L("10.2.2.2");
+    }
+
+void CConnectionSettingsParameters::SetRandomProtocolTypeL(CCreatorEngine& aEngine)
+    {
+    LOGSTRING("Creator: CConnectionSettingsParameters::SetRandomProtocolTypeL");
+
+    TInt protocolTypeRand = aEngine.RandomNumber(1, 2);
+    if(protocolTypeRand == 1)
+        {
+        iProtocolType = RPacketContext::EPdpTypeIPv4;
+        }
+    else
+        {
+        iProtocolType = RPacketContext::EPdpTypeIPv6;
+        }
+    }
+
+void CConnectionSettingsParameters::SetRandomTelephoneNumberL(CCreatorEngine& aEngine)
+    {
+    iDefaultTelNumber->Des() = aEngine.RandomString(CCreatorEngine::EPhoneNumber);
+    }
+
+void CConnectionSettingsParameters::SetRandomBearerTypeIsdnL(CCreatorEngine& /*aEngine*/)
+    {
+    iBearerCallTypeIsdn = ECmCallTypeISDNv110;
+    }
+
+void CConnectionSettingsParameters::SetRandomBearerSpeedL(CCreatorEngine& /*aEngine*/)
+    {
+    iBearerSpeed = ECmSpeed14400;
+    }
+
+void CConnectionSettingsParameters::SetRandomWapWspOptionL(CCreatorEngine& /*aEngine*/)
+    {
+    iWapWspOption = ECmWapWspOptionConnectionless;
+    }
+
+void CConnectionSettingsParameters::SetRandomSubnetMaskL(CCreatorEngine& /*aEngine*/)
+    {
+    iSubnetMask->Des() = _L("255.255.255.0");
+    }
+
+void CConnectionSettingsParameters::SetRandomGatewayAddressL(CCreatorEngine& /*aEngine*/)
+    {
+    iGatewayAddress->Des() = _L("10.0.0.1");
+    }
+
+void CConnectionSettingsParameters::SetRandomWlanIpAddrL(CCreatorEngine& /*aEngine*/)
+    {
+    iWlanIpAddr->Des() = _L("10.0.0.99");
+    }
+
+void CConnectionSettingsParameters::SetRandomIPv6NameServer1L(CCreatorEngine& /*aEngine*/)
+    {
+    iIP6NameServer1->Des() = _L("2007:abcd:1000:2000:3000:4000:5000:6001");
+    }
+
+void CConnectionSettingsParameters::SetRandomIPv6NameServer2L(CCreatorEngine& /*aEngine*/)
+    {
+    iIP6NameServer2->Des() = _L("2007:abcd:1000:2000:3000:4000:5000:6002");
+    }
+
+void CConnectionSettingsParameters::SetRandomDisableTextAuthL(CCreatorEngine& /*aEngine*/)
+    {
+    iDisableTextAuth = EFalse;
+    }
+
+void CCreatorConnectionSettings::SetRandomBearerTypeL(CConnectionSettingsParameters& parameters)
+	{
+    LOGSTRING("Creator: CCreatorConnectionSettings::SetRandomBearerTypeL");
+
+	RArray<TUint32> supportedBearers = RArray<TUint32>( 10 );
+	iCmManagerExt.SupportedBearersL(supportedBearers);
+	CleanupClosePushL( supportedBearers );
+	    
+	//In random mode, skipping KUidLanBearerType
+	//Because of Emulator migh show it as supported, when it's really not
+	//and that causes weird situation in UI when there is an item, but it can't be opened
+	TInt lanID = supportedBearers.Find(KUidLanBearerType);
+	if( lanID != KErrNotFound )
+		{
+		supportedBearers.Remove(lanID);
+		}
+	
+	// in emulator remove WLAN
+	#ifdef __WINSCW__	
+	TInt wlanID = supportedBearers.Find(KUidWlanBearerType);
+	if( wlanID != KErrNotFound )
+		{
+		supportedBearers.Remove(wlanID);
+		}
+	#endif	
+				
+	/*
+	    for(TInt i = 0; i<supportedCount; i++)
+	        {
+	        TUint bearer = supportedBearers[i];
+	        if(bearer == KUidLanBearerType)
+	            {
+	            supportedBearers.Remove(i);
+	            }
+	        }
+	    */
+	    
+	//Select random bearer type. 
+	//Also possible to use SupportedBearersL() -method to find supported methods
+	//but using that will cause problems when setting attributes.
+	TInt supportedCount = supportedBearers.Count();    
+	TInt bearerTypeID = iEngine->RandomNumber(0, supportedCount-1);
+	    
+	TUint bearerType = supportedBearers[bearerTypeID];
+	    
+	//Bearer types KUidEmbeddedDestination and KPluginVPNBearerTypeUid is not supported
+	if(bearerType == KUidWlanBearerType)//Wireless LAN
+		{            
+		parameters.iBearerType = KUidWlanBearerType;
+		}
+	else if(bearerType == KUidPacketDataBearerType)//Packet data (GPRS)
+		{
+		parameters.iBearerType = KUidPacketDataBearerType;
+		}
+	else if(bearerType == KUidCSDBearerType)//Data Call
+		{
+		parameters.iBearerType = KUidCSDBearerType;
+		}
+	else if(bearerType == KUidHSCSDBearerType) //High speed GSM
+		{
+		parameters.iBearerType = KUidHSCSDBearerType;
+		}
+	else if(bearerType == KUidEmbeddedDestination)
+		{
+		parameters.iBearerType = KUidEmbeddedDestination;
+		}
+	else// if(bearerType == KPluginVPNBearerTypeUid)
+		{
+		parameters.iBearerType = KPluginVPNBearerTypeUid;
+		}
+	/* In random mode skipping LAN type
+	    else// if(bearerType == KUidLanBearerType)
+	        {
+	        iBearerType = KUidLanBearerType;
+	        }*/
+	    
+	CleanupStack::PopAndDestroy(); // supportedBearers
+	}
+
+void CCreatorConnectionSettings::SetRandomParametersL(CConnectionSettingsParameters& parameters)
+    {
+    LOGSTRING("Creator: CCreatorConnectionSettings::SetRandomParametersL");
+        
+    // Connection method name:
+    parameters.SetRandomCMNameL(*iEngine);
+    
+    SetRandomBearerTypeL(parameters);
+ 
+    if(parameters.iBearerType == KUidWlanBearerType)//Wireless LAN
+        {           
+        // WLAN name:
+        parameters.SetRandomWLANNameL(*iEngine);
+        
+        //WLAN network mode        
+        parameters.SetRandomWLANNetModeL(*iEngine);     
+        
+        //WLAN security mode:
+        parameters.SetRandomWLANSecurityModeL(*iEngine);
+        }
+    
+    // Login name:
+    parameters.SetRandomLoginNameL(*iEngine);
+
+    // Login password:
+    parameters.SetRandomLoginPassL(*iEngine);
+
+    // Secure authentication:
+    parameters.SetRandomSecureAuthenticationL(*iEngine);
+    
+    // Prompt password:
+    parameters.SetRandomPromptPasswordL(*iEngine);    
+
+    // Use proxy:
+    parameters.SetRandomUseProxyL(*iEngine);    
+    
+    // Proxy address
+    parameters.SetRandomProxyAddressL(*iEngine);    
+    
+    // Proxy port number:
+    parameters.SetRandomProxyPortL(*iEngine);    
+
+    // Start page:
+    parameters.SetRandomStartPageL(*iEngine);
+       
+    // IP address:
+    parameters.SetRandomIPAddressL(*iEngine);    
+    
+    // IPv4 name servers:
+    parameters.SetRandomIP4NameServer1L(*iEngine);
+    parameters.SetRandomIP4NameServer2L(*iEngine);
+      
+    // Protocol type:
+    parameters.SetRandomProtocolTypeL(*iEngine);
+    
+    // Default telephone number:
+    parameters.SetRandomTelephoneNumberL(*iEngine);
+         
+    // Bearer isdn
+    parameters.SetRandomBearerTypeIsdnL(*iEngine);
+
+    // Bearer speed:
+    parameters.SetRandomBearerSpeedL(*iEngine);    
+
+    // WAP wsp option:
+    parameters.SetRandomWapWspOptionL(*iEngine);
+
+    // Subnet mask:
+    parameters.SetRandomSubnetMaskL(*iEngine);
+    
+    // Gateway address:
+    parameters.SetRandomGatewayAddressL(*iEngine);
+    
+    // WLAN ip address:
+    parameters.SetRandomWlanIpAddrL(*iEngine);
+
+    // IPv6 name servers:
+    parameters.SetRandomIPv6NameServer1L(*iEngine);
+    parameters.SetRandomIPv6NameServer2L(*iEngine);
+    
+    // Disable text authorization:
+    parameters.SetRandomDisableTextAuthL(*iEngine);    
+    }
+
+//----------------------------------------------------------------------------
+
+void CCreatorConnectionSettings::SetDefaultCML(RCmConnectionMethodExt conMethod)
+    {
+    LOGSTRING("Creator: CCreatorConnectionSettings::SetDefaultCM");
+
+    TCmDefConnValue defConnValue;
+        
+    //Returns the default connection method/SNAP.
+    TRAPD( err, iCmManagerExt.ReadDefConnL( defConnValue ) );
+    if( err ==  KErrNotSupported )
+        {
+        return; //If Default Connection NOT supported, just returning 
+        }
+    else if ( err != KErrNone )
+        {
+        User::Leave( err ); //If something else happend
+        }
+    else if ( defConnValue.iId == 0 ) // default not set
+        {       
+        TCmDefConnValue newDefaultCM;        
+        HBufC* cmName = conMethod.GetStringAttributeL( ECmName );        
+        CleanupStack::PushL( cmName );
+        newDefaultCM.iId = AccessPointNameToIdL( cmName->Des() );
+        newDefaultCM.iType = ECmDefConnDestination;
+        //Stores the default connection method/SNAP.
+        iCmManagerExt.WriteDefConnL( newDefaultCM );
+        CleanupStack::PopAndDestroy( cmName );        
+       }
+    }
+
+//----------------------------------------------------------------------------
+
+TUint32 CCreatorConnectionSettings::AccessPointNameToIdL(const TDesC& aAPName,
+                                                         TBool aAnyIfNotFound )
+    {
+    LOGSTRING("Creator: CCreatorConnectionSettings::AccessPointNameToIdL");
+
+    //RCmDestination destination
+    
+    RArray<TUint32> destIdArray = RArray<TUint32>( 10 );
+    
+    iCmManagerExt.AllDestinationsL( destIdArray );
+    
+    CleanupClosePushL( destIdArray );
+    TUint32 id = 0 ;
+    TBool found = EFalse;
+    
+    for( TInt i = 0; i < destIdArray.Count(); i++ )
+        {
+        RCmDestinationExt dest = iCmManagerExt.DestinationL( destIdArray[i] );           
+        CleanupClosePushL( dest );        
+
+        HBufC* destName = dest.NameLC();
+        
+        if (destName->CompareF(aAPName) == 0){        
+         id = dest.Id();
+         found = ETrue;
+        }
+        if ( !found && id == 0 && aAnyIfNotFound )
+            {
+            id = dest.Id();
+            }
+        CleanupStack::PopAndDestroy( 2 ); // destName , dest
+        if(found)
+            {
+            break;
+            }
+        }
+
+    CleanupStack::PopAndDestroy(); // destIdArray   
+    return id;
+    }
+
+//----------------------------------------------------------------------------
+
+void CCreatorConnectionSettings::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) // from MMsvSessionObserver
+    {
+    LOGSTRING("Creator: CCreatorConnectionSettings::HandleSessionEventL");
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorConnectionSettings::DeleteAllL()
+    {
+    LOGSTRING("Creator: CCreatorConnectionSettings::DeleteAllL");
+    DeleteAllDestinationsL( EFalse );
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorConnectionSettings::DeleteAllCreatedByCreatorL()
+    {
+    LOGSTRING("Creator: CCreatorConnectionSettings::DeleteAllCreatedByCreatorL");
+    iEntryIds.Reset();
+    
+    // fetch ids of entries created by Creator
+    iEngine->ReadEntryIdsFromStoreL( iEntryIds, KUidDictionaryUidIAP );
+    
+    // delete entries
+    DeleteAllDestinationsL( ETrue );
+    }
+
+//----------------------------------------------------------------------------
+
+void CCreatorConnectionSettings::DeleteAllDestinationsL( TBool aOnlyCreatedWithCreator )
+    {
+    LOGSTRING("Creator: CCreatorConnectionSettings::DeleteAllDestinationsL");
+    RArray<TUint32> destIdArray(5);
+    CleanupClosePushL( destIdArray );
+    iCmManagerExt.AllDestinationsL( destIdArray );    
+    
+    for( TInt i = 0; i < destIdArray.Count(); i++ )
+        {
+        TRAP_IGNORE
+            (
+            RCmDestinationExt dest = iCmManagerExt.DestinationL( destIdArray[i] );           
+            CleanupClosePushL( dest );
+            
+            if ( !aOnlyCreatedWithCreator || iEntryIds.Find( destIdArray[i]) != KErrNotFound )
+                {
+                dest.DeleteLD();
+                }
+            CleanupStack::PopAndDestroy(); // dest
+            );
+        }
+   
+    CleanupStack::PopAndDestroy(); // destIdArray 
+    
+    // reset must be done here, because iEntryIds is stored in destructor
+    iEntryIds.Reset();
+    
+    // all entries deleted, remove the IMPS related registry
+    iEngine->RemoveStoreL( KUidDictionaryUidIAP );
+    }
+//----------------------------------------------------------------------------
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_connectionmethodelement.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,754 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include "creator_connectionmethodelement.h"
+#include "creator_traces.h"
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+#include "creator_connectionmethod.h"
+#include <cmpluginpacketdatadef.h>
+#include <cmplugindialcommondefs.h>
+#include <cmplugincsddef.h>
+#include <cmpluginhscsddef.h>
+#include <cmpluginembdestinationdef.h>
+#include <cmpluginvpndef.h>
+#include <cmpluginlanbasedef.h>
+#else
+#include "creator_accesspoint.h"
+#endif
+
+
+using namespace creatorconnectionmethod;
+
+// connection name needs extra space for possible renaming
+const TInt KExtraSpace = 10;
+
+/*
+ * 
+ */
+CCreatorConnectionMethodElement* CCreatorConnectionMethodElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext )
+    {
+    CCreatorConnectionMethodElement* self = new (ELeave) CCreatorConnectionMethodElement(aEngine);
+    CleanupStack::PushL(self);
+    self->ConstructL(aName, aContext);
+    CleanupStack::Pop(self);
+    return self;
+    }
+/*
+ * 
+ */
+CCreatorConnectionMethodElement::CCreatorConnectionMethodElement(CCreatorEngine* aEngine) 
+: 
+CCreatorScriptElement(aEngine)
+    {
+    iIsCommandElement = ETrue;
+    }
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+void CCreatorConnectionMethodElement::ExecuteCommandL()
+    {
+    const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount);
+    TInt cmAmount = 1;    
+    if( amountAttr )
+        {
+        cmAmount = ConvertStrToIntL(amountAttr->Value());
+        }
+    // Get 'fields' element 
+    CCreatorScriptElement* fieldsElement = FindSubElement(KFields);
+    if( fieldsElement && fieldsElement->SubElements().Count() > 0 )
+        {
+        // Get sub-elements
+        const RPointerArray<CCreatorScriptElement>& fields = fieldsElement->SubElements();        
+        // Create connection method entries, the amount of entries is defined by cmAmount:
+        for( TInt cI = 0; cI < cmAmount; ++cI )
+            {            
+            CConnectionSettingsParameters* param = new (ELeave) CConnectionSettingsParameters;
+            CleanupStack::PushL(param);
+            
+            for( TInt i = 0; i < fields.Count(); ++i )
+                {
+                CCreatorScriptElement* field = fields[i];
+                TPtrC elemName = field->Name();
+                TPtrC elemContent = field->Content();
+                const CCreatorScriptAttribute* randomAttr = fields[i]->FindAttributeByName(KRandomLength);
+                TBool useRandom = EFalse;
+                if( randomAttr || elemContent.Length() == 0 )
+                    {
+                    useRandom = ETrue;
+                    }
+                
+                if( elemName == Kconnectionname )
+                    {
+                    if( useRandom )
+                        {
+                        param->SetRandomCMNameL(*iEngine);
+                        }
+                    else
+                        {
+                        SetContentToTextParamL(param->iConnectionName, elemContent);
+                        // reserve extra space for possible renaming
+                        TInt newLen = param->iConnectionName->Length() + KExtraSpace;
+                        param->iConnectionName = param->iConnectionName->ReAllocL(newLen);
+                        }
+                    }
+                else if( elemName == Kstartpage )
+                    {
+                    if( useRandom )
+                        {
+                        param->SetRandomStartPageL(*iEngine);
+                        }
+                    else
+                        {
+                        SetContentToTextParamL(param->iStartPage, elemContent);
+                        }
+                    }
+                else if( elemName == Kwapwspoption )
+                    {
+                    if( useRandom )
+                        {
+                        param->SetRandomWapWspOptionL(*iEngine);
+                        }
+                    else
+                        {
+                        if( CompareIgnoreCase(elemContent, Kconnectionless) == 0 )
+                        	{
+                        	param->iWapWspOption = ECmWapWspOptionConnectionless;
+                        	}
+                        else if( CompareIgnoreCase(elemContent, Kconnectionoriented) == 0 )
+                        	{
+                        	param->iWapWspOption = ECmWapWspOptionConnectionOriented;
+                        	}
+                        }
+                    }
+                else if( elemName == Kprotocoltype )
+                	{
+                	if( useRandom )
+                		{
+                		param->SetRandomProtocolTypeL(*iEngine);
+                		}
+                	else
+                		{
+                		if( CompareIgnoreCase(elemContent, Kipv4) == 0 )
+                			{
+                			param->iProtocolType = RPacketContext::EPdpTypeIPv4;
+                			}
+                		else if( CompareIgnoreCase(elemContent, Kipv6) == 0 )
+                			{
+                			param->iProtocolType = RPacketContext::EPdpTypeIPv6;
+                			}
+                		}
+                	}
+                else if( elemName == Kloginname )
+                	{
+                	if( useRandom )
+                		{
+                		param->SetRandomLoginNameL(*iEngine);                		
+                		}
+                	else
+                		{
+                		SetContentToTextParamL(param->iLoginName, elemContent);
+                		}
+                	}
+                else if( elemName == Ksecureauthentication )
+                	{
+                	if( useRandom )
+                		{
+                		param->SetRandomSecureAuthenticationL(*iEngine);
+                		}
+                	else
+                		{
+                		param->iSecureAuthentication = ConvertStrToBooleanL(elemContent);
+                		}
+                	}
+                else if( elemName == Kloginpass )
+                	{
+                	if( useRandom )
+                		{
+                		param->SetRandomLoginPassL(*iEngine);
+                		}
+                	else
+                		{
+                		SetContentToTextParamL(param->iLoginPass, elemContent);
+                		}
+                	}
+                else if( elemName == Kpromptpassword )
+                	{
+                	if( useRandom )
+                		{
+                		param->SetRandomPromptPasswordL(*iEngine);
+                		}
+                	else
+                		{
+                		param->iPromptPassword = ConvertStrToBooleanL(elemContent);
+                		}
+                	}
+                else if( elemName == Kgatewayaddress )
+                	{
+                	if( useRandom )
+                		{
+                		param->SetRandomGatewayAddressL(*iEngine);
+                		}
+                	else
+                		{
+                		SetContentToTextParamL(param->iGatewayAddress, elemContent);
+                		}
+                	}
+                else if( elemName == Ksubnetmask )
+                	{
+                	if( useRandom )
+                		{
+                		param->SetRandomSubnetMaskL(*iEngine);
+                		}
+                	else
+                		{
+                		SetContentToTextParamL(param->iSubnetMask, elemContent);
+                		}
+                	}
+                else if( elemName == Kdeviceipaddr )
+                	{
+                	if( useRandom )
+                		{
+                		param->SetRandomIPAddressL(*iEngine);
+                		}
+                	else
+                		{
+                		SetContentToTextParamL(param->iIPAddr, elemContent);
+                		}
+                	}
+                else if( elemName == Kip4nameserver1 )
+                	{
+                	if( useRandom )
+                		{
+                		param->SetRandomIP4NameServer1L(*iEngine);
+                		}
+                	else
+                		{
+                		SetContentToTextParamL(param->iIP4NameServer1, elemContent);
+                		}
+                	}
+                else if( elemName == Kip4nameserver2 )
+                	{
+                	if( useRandom )
+                		{
+                		param->SetRandomIP4NameServer2L(*iEngine);
+                		}
+                	else
+                		{
+                		SetContentToTextParamL(param->iIP4NameServer2, elemContent);
+                		}
+                	}
+                else if( elemName == Kdatacalltelnumber )
+                	{
+                	if( useRandom )
+                		{
+                		param->SetRandomTelephoneNumberL(*iEngine);
+                		}
+                	else
+                		{
+                		SetContentToTextParamL(param->iDefaultTelNumber, elemContent);
+                		}
+                	}
+                else if( elemName == Kdatacalltypeisdn )
+                	{
+                	if( useRandom )
+                		{
+                		param->SetRandomBearerTypeIsdnL(*iEngine);
+                		}
+                	else
+                		{
+                		if( CompareIgnoreCase(elemContent, Kanalogue) == 0 )
+                			param->iBearerCallTypeIsdn = CMManager::ECmCallTypeAnalogue;
+                		else if( CompareIgnoreCase( elemContent, Kisdnv110) == 0 )
+                			param->iBearerCallTypeIsdn = CMManager::ECmCallTypeISDNv110;
+                		else if( CompareIgnoreCase( elemContent, Kisdnv120) == 0 )
+                			param->iBearerCallTypeIsdn = CMManager::ECmCallTypeISDNv120;
+                		}
+                	}
+                else if( elemName == Kbearertype )
+                	{
+                	if( useRandom )
+                		{
+                		param->iBearerType = KRandomBearerType;
+                		}
+                	else
+                		{
+                		if( CompareIgnoreCase(elemContent, Kwlan) == 0 )
+                			{
+                			param->iBearerType = KUidWlanBearerType;
+                			}
+                		else if( CompareIgnoreCase(elemContent, Kgprs) == 0 )
+                			{
+                			param->iBearerType = KUidPacketDataBearerType;
+                			}
+                		else if( CompareIgnoreCase(elemContent, Kdatacall) == 0 )
+                			{
+                			param->iBearerType = KUidCSDBearerType;
+                			}
+                		else if( CompareIgnoreCase(elemContent, Khsgsm) == 0 )
+                			{
+                			param->iBearerType = KUidHSCSDBearerType;
+                			}
+                		else if( CompareIgnoreCase(elemContent, Kembedded) == 0 )
+                			{
+                			param->iBearerType = KUidEmbeddedDestination;
+                			}
+                		else if( CompareIgnoreCase(elemContent, Kvpn) == 0 )
+                			{
+                			param->iBearerType = KPluginVPNBearerTypeUid;
+                			}
+                		else if( CompareIgnoreCase(elemContent, Klan) == 0 )
+                			{
+                			param->iBearerType = KUidLanBearerType;
+                			}
+                		}
+                	}
+                else if( elemName == Kdatacalllinespeed )
+                	{
+                	if( useRandom )
+                		{
+                		param->SetRandomBearerSpeedL(*iEngine);
+                		}
+                	else
+                		{
+                		if( CompareIgnoreCase(elemContent, Kautomatic) == 0 )
+                			{                			 
+                			param->iBearerSpeed = CMManager::ECmSpeedAutobaud;
+                			}
+                		else
+                			{
+                			TUint lineSpeed = ConvertStrToUintL(elemContent);
+                			if( lineSpeed == 9600 )
+                				param->iBearerSpeed = CMManager::ECmSpeed9600;
+                			else if( lineSpeed == 14400 )
+                				param->iBearerSpeed = CMManager::ECmSpeed14400;
+                			else if( lineSpeed == 19200 )
+                				param->iBearerSpeed = CMManager::ECmSpeed19200;
+                			else if( lineSpeed == 28800 )
+                				param->iBearerSpeed = CMManager::ECmSpeed28800;
+                			else if( lineSpeed == 38400 )
+                				param->iBearerSpeed = CMManager::ECmSpeed38400;
+                			else if( lineSpeed == 43200 )
+                				param->iBearerSpeed = CMManager::ECmSpeed43200;
+                			else if( lineSpeed == 56000 )
+                				param->iBearerSpeed = CMManager::ECmSpeed56000;
+                			}                			
+                		}
+                	}
+                else if( elemName == Kuseproxy )
+                	{
+                	if( useRandom )
+                		{
+                		param->SetRandomUseProxyL(*iEngine);
+                		}
+                	else
+                		{
+                		param->iUseProxy = ConvertStrToBooleanL(elemContent);
+                		}
+                	}
+                else if( elemName == Kproxyserveraddress )
+                	{
+                	if( useRandom )
+                		{
+                		param->SetRandomProxyAddressL(*iEngine);
+                		}
+                	else
+                		{
+                		SetContentToTextParamL(param->iProxyServerAddress, elemContent);                		
+                		}
+                	}
+                else if( elemName == Kproxyportnumber )
+                	{
+                	if( useRandom )
+                		{
+                		param->SetRandomProxyPortL(*iEngine);
+                		}
+                	else
+                		{
+                		param->iProxyPortNumber = ConvertStrToUintL(elemContent);                		
+                		}
+                	}
+                else if( elemName == Kip6nameserver1 )
+                	{
+                	if( useRandom )
+                		{
+                		param->SetRandomIPv6NameServer1L(*iEngine);
+                		}
+                	else
+                		{
+                		SetContentToTextParamL(param->iIP6NameServer1, elemContent);               		                		
+                		}
+                	}
+                else if( elemName == Kip6nameserver2 )
+                	{
+                	if( useRandom )
+                		{
+                		param->SetRandomIPv6NameServer2L(*iEngine);
+                		}
+                	else
+                		{
+                		SetContentToTextParamL(param->iIP6NameServer2, elemContent);               		                		
+                		}
+                	}
+                else if( elemName == Kdisabletextauth )
+                	{
+                	if( useRandom )
+                		{
+                		param->SetRandomDisableTextAuthL(*iEngine);
+                		}
+                	else
+                		{
+                		param->iDisableTextAuth = ConvertStrToBooleanL(elemContent);
+                		}
+                	}
+                else if( elemName == Kwlanname )
+                	{
+                	if( useRandom )
+                		{
+                		param->SetRandomWLANNameL(*iEngine);
+                		}
+                	else
+                		{
+                		SetContentToTextParamL(param->iWLANName, elemContent);               		                		
+                		}
+                	}
+                else if( elemName == Kwlanipaddr )
+                	{
+                	if( useRandom )
+                		{
+                		param->SetRandomWlanIpAddrL(*iEngine);
+                		}
+                	else
+                		{
+                		SetContentToTextParamL(param->iWlanIpAddr, elemContent);               		                		
+                		}
+                	}
+                else if( elemName == Kwlansecmode )
+                	{
+                	if( useRandom )
+                		{
+                		param->SetRandomWLANSecurityModeL(*iEngine);
+                		}
+                	else
+                		{
+                		if( CompareIgnoreCase(elemContent, Kopen) == 0)
+                			param->iWLanSecMode = CMManager::EWlanSecModeOpen;
+                		else if( CompareIgnoreCase(elemContent, Kwep) == 0 )
+                			param->iWLanSecMode = CMManager::EWlanSecModeWep;
+                		else if( CompareIgnoreCase(elemContent, Ke802_1x) == 0 )
+                			param->iWLanSecMode = CMManager::EWlanSecMode802_1x;
+                		else if( CompareIgnoreCase(elemContent, Kwpa) == 0 )
+                			param->iWLanSecMode = CMManager::EWlanSecModeWpa;
+                		else if( CompareIgnoreCase(elemContent, Kwpa2) == 0 )
+                			param->iWLanSecMode = CMManager::EWlanSecModeWpa2;                		               		                		
+                		}
+                	}
+                }
+            iEngine->AppendToCommandArrayL(ECmdCreateMiscEntryAccessPoints, param);
+            CleanupStack::Pop(); // param
+            }
+        }
+    else
+    	{
+    	// No fields defined so add random entries:
+    	iEngine->AppendToCommandArrayL(ECmdCreateMiscEntryAccessPoints, 0, cmAmount);
+    	}
+    }
+#else
+void CCreatorConnectionMethodElement::ExecuteCommandL()
+	{
+	const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount);
+	TInt cmAmount = 1;    
+	if( amountAttr )
+		{
+		cmAmount = ConvertStrToIntL(amountAttr->Value());
+		}
+	// Get 'fields' element 
+	CCreatorScriptElement* fieldsElement = FindSubElement(KFields);
+	if( fieldsElement )
+		{
+		// Get sub-elements
+		const RPointerArray<CCreatorScriptElement>& fields = fieldsElement->SubElements();        
+		// Create connection method entries, the amount of entries is defined by cmAmount:
+		for( TInt cI = 0; cI < cmAmount; ++cI )
+			{            
+			CAccessPointsParameters* param = new (ELeave) CAccessPointsParameters;
+			CleanupStack::PushL(param);
+
+			for( TInt i = 0; i < fields.Count(); ++i )
+				{
+				CCreatorScriptElement* field = fields[i];
+				TPtrC elemName = field->Name();
+				TPtrC elemContent = field->Content();
+				const CCreatorScriptAttribute* randomAttr = fields[i]->FindAttributeByName(KRandomLength);
+				TBool useRandom = EFalse;
+				if( randomAttr || elemContent.Length() == 0 )
+					{
+					useRandom = ETrue;
+					}
+
+				if( elemName == Kconnectionname )
+					{
+					if( useRandom )
+						{
+						param->SetRandomCMNameL(*iEngine);
+						}
+					else
+						{
+						SetContentToTextParamL(param->iConnectionName, elemContent);
+                        // reserve extra space for possible renaming
+                        TInt newLen = param->iConnectionName->Length() + KExtraSpace;
+                        param->iConnectionName = param->iConnectionName->ReAllocL(newLen);
+
+                        SetContentToTextParamL(param->iGprsAcessPointName, elemContent);
+						}
+					}
+				else if( elemName == Kstartpage )
+					{
+					if( useRandom )
+						{
+						param->SetRandomStartPageL(*iEngine);
+						}
+					else
+						{
+						SetContentToTextParamL(param->iWapStartPage, elemContent);
+						}
+					}
+				else if( elemName == Kwapwspoption )
+					{
+					if( useRandom )
+						{
+						param->SetRandomWapWspOptionL(*iEngine);
+						}
+					else
+						{
+						if( CompareIgnoreCase(elemContent, Kconnectionless) == 0 )
+							{
+							param->iWapWspOption = EWapWspOptionConnectionless;
+							}
+						else if( CompareIgnoreCase(elemContent, Kconnectionoriented) == 0 )
+							{
+							param->iWapWspOption = EWapWspOptionConnectionOriented;
+							}
+						}
+					}
+				else if( elemName == Kloginname )
+					{
+					if( useRandom )
+						{
+						param->SetRandomLoginNameL(*iEngine);                		
+						}
+					else
+						{
+						SetContentToTextParamL(param->iIspLoginName, elemContent);
+						}
+					}
+				else if( elemName == Ksecureauthentication )
+					{
+					if( useRandom )
+						{
+						param->SetRandomSecureAuthenticationL(*iEngine);
+						}
+					else
+						{
+						param->iSecureAuthentication = ConvertStrToBooleanL(elemContent);
+						}
+					}
+				else if( elemName == Kloginpass )
+					{
+					if( useRandom )
+						{
+						param->SetRandomLoginPassL(*iEngine);
+						}
+					else
+						{
+						SetContentToTextParamL(param->iIspLoginPass, elemContent);
+						}
+					}
+				else if( elemName == Kpromptpassword )
+					{
+					if( useRandom )
+						{
+						param->SetRandomPromptPasswordL(*iEngine);
+						}
+					else
+						{
+						param->iPromptPassword = ConvertStrToBooleanL(elemContent);
+						}
+					}
+				else if( elemName == Kgatewayaddress )
+					{
+					if( useRandom )
+						{
+						param->SetRandomGatewayAddressL(*iEngine);
+						}
+					else
+						{
+						SetContentToTextParamL(param->iWapGatewayAddress, elemContent);
+						}
+					}
+				else if( elemName == Kdeviceipaddr )
+					{
+					if( useRandom )
+						{
+						param->SetRandomIPAddressL(*iEngine);
+						}
+					else
+						{
+						SetContentToTextParamL(param->iIspIPAddr, elemContent);
+						}
+					}
+				else if( elemName == Kip4nameserver1 )
+					{
+					if( useRandom )
+						{
+						param->SetRandomIP4NameServer1L(*iEngine);
+						}
+					else
+						{
+						SetContentToTextParamL(param->iIspIPNameServer1, elemContent);
+						}
+					}
+				else if( elemName == Kip4nameserver2 )
+					{
+					if( useRandom )
+						{
+						param->SetRandomIP4NameServer2L(*iEngine);
+						}
+					else
+						{
+						SetContentToTextParamL(param->iIspIPNameServer2, elemContent);
+						}
+					}
+				else if( elemName == Kdatacalltelnumber )
+					{
+					if( useRandom )
+						{
+						param->SetRandomTelephoneNumberL(*iEngine);
+						}
+					else
+						{
+						SetContentToTextParamL(param->iIspDefaultTelNumber, elemContent);
+						}
+					}
+				else if( elemName == Kdatacalltypeisdn )
+					{
+					if( useRandom )
+						{
+						param->SetRandomBearerTypeIsdnL(*iEngine);
+						}
+					else
+						{
+						if( CompareIgnoreCase(elemContent, Kanalogue) == 0 )
+							param->iIspBearerCallTypeIsdn = ECallTypeAnalogue;
+						else if( CompareIgnoreCase( elemContent, Kisdnv110) == 0 )
+							param->iIspBearerCallTypeIsdn = ECallTypeISDNv110;
+						else if( CompareIgnoreCase( elemContent, Kisdnv120) == 0 )
+							param->iIspBearerCallTypeIsdn = ECallTypeISDNv120;
+						}
+					}
+				else if( elemName == Kbearertype )
+					{
+					if( useRandom )
+						{
+						param->iBearerType = EApBearerTypeGPRS;
+						}
+					else
+						{
+						if( CompareIgnoreCase(elemContent, Kwlan) == 0 )
+							{
+							param->iBearerType = EApBearerTypeWLAN;
+							}
+						else if( CompareIgnoreCase(elemContent, Kgprs) == 0 )
+							{
+							param->iBearerType = EApBearerTypeGPRS;
+							}
+						else if( CompareIgnoreCase(elemContent, Kdatacall) == 0 )
+							{
+							param->iBearerType = EApBearerTypeCSD;
+							}
+						else if( CompareIgnoreCase(elemContent, Khsgsm) == 0 )
+							{
+							param->iBearerType = EApBearerTypeHSCSD;
+							}
+						else if( CompareIgnoreCase(elemContent, Klan) == 0 )
+							{
+							param->iBearerType = EApBearerTypeLAN;
+							}
+						}
+					}
+				else if( elemName == Kdatacalllinespeed )
+					{
+					if( useRandom )
+						{
+						param->SetRandomBearerSpeedL(*iEngine);
+						}
+					else
+						{
+						if( CompareIgnoreCase(elemContent, Kautomatic) == 0 )
+							{                			 
+							param->iIspBearerSpeed = KSpeedAutobaud;
+							}
+						else
+							{
+							TUint lineSpeed = ConvertStrToUintL(elemContent);
+							if( lineSpeed == 9600 )
+								param->iIspBearerSpeed = KSpeed9600;
+							else if( lineSpeed == 14400 )
+								param->iIspBearerSpeed = KSpeed14400;
+							else if( lineSpeed == 19200 )
+								param->iIspBearerSpeed = KSpeed19200;
+							else if( lineSpeed == 28800 )
+								param->iIspBearerSpeed = KSpeed28800;
+							else if( lineSpeed == 38400 )
+								param->iIspBearerSpeed = KSpeed38400;
+							else if( lineSpeed == 43200 )
+								param->iIspBearerSpeed = KSpeed43200;
+							else if( lineSpeed == 56000 )
+								param->iIspBearerSpeed = KSpeed56000;
+							}                			
+						}
+					}
+				else if( elemName == Kproxyserveraddress )
+					{
+					if( useRandom )
+						{
+						param->SetRandomProxyAddressL(*iEngine);
+						}
+					else
+						{
+						SetContentToTextParamL(param->iProxyServerAddress, elemContent);                		
+						}
+					}
+				else if( elemName == Kproxyportnumber )
+					{
+					if( useRandom )
+						{
+						param->SetRandomProxyPortL(*iEngine);
+						}
+					else
+						{
+						param->iProxyPortNumber = ConvertStrToUintL(elemContent);                		
+						}
+					}
+				}
+			iEngine->AppendToCommandArrayL(ECmdCreateMiscEntryAccessPoints, param);
+			CleanupStack::Pop(); // param
+			}
+		}
+	}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_contactelement.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,472 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include "creator_contactelement.h"
+#include "creator_traces.h"
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+#include "creator_virtualphonebook.h"
+#endif
+#include "creator_factory.h"
+#include "creator_contactsetcache.h"
+#include <xml/documentparameters.h>
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+#include "VPbkEng.rsg"
+#endif
+
+using namespace Xml;
+using namespace creatorcontact;
+
+/**
+ * Contact field element mappings:
+ */
+enum TContactFieldDataType
+    {
+    EDataTypeText,
+    EDataTypeBinary,
+    EDataTypeDateTime    
+    };
+    
+class FieldMapping
+{
+public:
+    TPtrC iElementName;
+    TInt  iFieldCode;
+    TContactFieldDataType iDataType;
+};
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+FieldMapping fieldMappingTbl[] = {
+       {TPtrC(KFirstname), R_VPBK_FIELD_TYPE_FIRSTNAME, EDataTypeText},
+       {TPtrC(KLastname), R_VPBK_FIELD_TYPE_LASTNAME, EDataTypeText},
+       {TPtrC(KFirstnameReading), R_VPBK_FIELD_TYPE_FIRSTNAMEREADING, EDataTypeText},
+       {TPtrC(KLastnameReading), R_VPBK_FIELD_TYPE_LASTNAMEREADING, EDataTypeText},
+       {TPtrC(KPrefix), R_VPBK_FIELD_TYPE_PREFIX, EDataTypeText},
+       {TPtrC(KSuffix), R_VPBK_FIELD_TYPE_SUFFIX, EDataTypeText},
+       {TPtrC(KSecondname), R_VPBK_FIELD_TYPE_SECONDNAME, EDataTypeText},
+       {TPtrC(KLandphoneHome), R_VPBK_FIELD_TYPE_LANDPHONEHOME, EDataTypeText},
+       
+       {TPtrC(KMobilephoneHome), R_VPBK_FIELD_TYPE_MOBILEPHONEHOME, EDataTypeText},
+       {TPtrC(KVideonumberHome), R_VPBK_FIELD_TYPE_VIDEONUMBERHOME, EDataTypeText},
+       {TPtrC(KFaxnumberHome), R_VPBK_FIELD_TYPE_FAXNUMBERHOME, EDataTypeText},
+       {TPtrC(KVoipHome), R_VPBK_FIELD_TYPE_VOIPHOME, EDataTypeText},
+       {TPtrC(KEmailHome), R_VPBK_FIELD_TYPE_EMAILHOME, EDataTypeText},
+       {TPtrC(KUrlHome), R_VPBK_FIELD_TYPE_URLHOME, EDataTypeText},
+       {TPtrC(KAddrlabelHome), R_VPBK_FIELD_TYPE_ADDRLABELHOME, EDataTypeText},
+       {TPtrC(KAddrpoHome), R_VPBK_FIELD_TYPE_ADDRPOHOME, EDataTypeText},
+       
+       {TPtrC(KAddrextHome), R_VPBK_FIELD_TYPE_ADDREXTHOME, EDataTypeText},
+       {TPtrC(KAddrstreetHome), R_VPBK_FIELD_TYPE_ADDRSTREETHOME, EDataTypeText},
+       {TPtrC(KAddrlocalHome), R_VPBK_FIELD_TYPE_ADDRLOCALHOME, EDataTypeText},
+       {TPtrC(KAddrregionHome), R_VPBK_FIELD_TYPE_ADDRREGIONHOME, EDataTypeText},
+       {TPtrC(KAddrpostcodeHome), R_VPBK_FIELD_TYPE_ADDRPOSTCODEHOME, EDataTypeText},
+       {TPtrC(KAddrcountryHome), R_VPBK_FIELD_TYPE_ADDRCOUNTRYHOME, EDataTypeText},
+       {TPtrC(KJobtitle), R_VPBK_FIELD_TYPE_JOBTITLE, EDataTypeText},
+       {TPtrC(KCompanyname), R_VPBK_FIELD_TYPE_COMPANYNAME, EDataTypeText},
+       
+       {TPtrC(KLandphoneWork), R_VPBK_FIELD_TYPE_LANDPHONEWORK, EDataTypeText},
+       {TPtrC(KMobilephoneWork), R_VPBK_FIELD_TYPE_MOBILEPHONEWORK, EDataTypeText},
+       {TPtrC(KVideonumberWork), R_VPBK_FIELD_TYPE_VIDEONUMBERWORK, EDataTypeText},
+       {TPtrC(KFaxnumberWork), R_VPBK_FIELD_TYPE_FAXNUMBERWORK, EDataTypeText},
+       {TPtrC(KVoipWork), R_VPBK_FIELD_TYPE_VOIPWORK, EDataTypeText},
+       {TPtrC(KEmailWork), R_VPBK_FIELD_TYPE_EMAILWORK, EDataTypeText},
+       {TPtrC(KUrlWork), R_VPBK_FIELD_TYPE_URLWORK, EDataTypeText},
+       {TPtrC(KAddrlabelWork), R_VPBK_FIELD_TYPE_ADDRLABELWORK, EDataTypeText},
+       
+       {TPtrC(KAddrpoWork), R_VPBK_FIELD_TYPE_ADDRPOWORK, EDataTypeText},
+       {TPtrC(KAddrextWork), R_VPBK_FIELD_TYPE_ADDREXTWORK, EDataTypeText},
+       {TPtrC(KAddrstreetWork), R_VPBK_FIELD_TYPE_ADDRSTREETWORK, EDataTypeText},
+       {TPtrC(KAddrlocalWork), R_VPBK_FIELD_TYPE_ADDRLOCALWORK, EDataTypeText},
+       {TPtrC(KAddrregionWork), R_VPBK_FIELD_TYPE_ADDRREGIONWORK, EDataTypeText},
+       {TPtrC(KAddrpostcodeWork), R_VPBK_FIELD_TYPE_ADDRPOSTCODEWORK, EDataTypeText},
+       {TPtrC(KAddrcountryWork), R_VPBK_FIELD_TYPE_ADDRCOUNTRYWORK, EDataTypeText},
+       {TPtrC(KLandphoneGen), R_VPBK_FIELD_TYPE_LANDPHONEGEN, EDataTypeText},
+       
+       {TPtrC(KMobilephoneGen), R_VPBK_FIELD_TYPE_MOBILEPHONEGEN, EDataTypeText},
+       {TPtrC(KVideonumberGen), R_VPBK_FIELD_TYPE_VIDEONUMBERGEN, EDataTypeText},
+       {TPtrC(KFaxnumberGen), R_VPBK_FIELD_TYPE_FAXNUMBERGEN, EDataTypeText},
+       {TPtrC(KVoipGen), R_VPBK_FIELD_TYPE_VOIPGEN, EDataTypeText},
+       {TPtrC(KPoc), R_VPBK_FIELD_TYPE_POC, EDataTypeText},
+       {TPtrC(KSwis), R_VPBK_FIELD_TYPE_SWIS, EDataTypeText},
+       {TPtrC(KSip), R_VPBK_FIELD_TYPE_SIP, EDataTypeText},
+       {TPtrC(KEmailGen), R_VPBK_FIELD_TYPE_EMAILGEN, EDataTypeText},
+       
+       {TPtrC(KUrlGen), R_VPBK_FIELD_TYPE_URLGEN, EDataTypeText},
+       {TPtrC(KAddrlabelGen), R_VPBK_FIELD_TYPE_ADDRLABELGEN, EDataTypeText},
+       {TPtrC(KAddrpoGen), R_VPBK_FIELD_TYPE_ADDRPOGEN, EDataTypeText},
+       {TPtrC(KAddrextGen), R_VPBK_FIELD_TYPE_ADDREXTGEN, EDataTypeText},
+       {TPtrC(KAddrstreetGen), R_VPBK_FIELD_TYPE_ADDRSTREETGEN, EDataTypeText},
+       {TPtrC(KAddrlocalGen), R_VPBK_FIELD_TYPE_ADDRLOCALGEN, EDataTypeText},
+       {TPtrC(KAddrregionGen), R_VPBK_FIELD_TYPE_ADDRREGIONGEN, EDataTypeText},
+       {TPtrC(KAddrpostcodeGen), R_VPBK_FIELD_TYPE_ADDRPOSTCODEGEN, EDataTypeText},
+       
+       {TPtrC(KAddrcountryGen), R_VPBK_FIELD_TYPE_ADDRCOUNTRYGEN, EDataTypeText},
+       {TPtrC(KPagerNumber), R_VPBK_FIELD_TYPE_PAGERNUMBER, EDataTypeText},
+       {TPtrC(KDtmfString), R_VPBK_FIELD_TYPE_DTMFSTRING, EDataTypeText},
+       {TPtrC(KWvAddress), R_VPBK_FIELD_TYPE_WVADDRESS, EDataTypeText},
+       {TPtrC(KDate), R_VPBK_FIELD_TYPE_DATE, EDataTypeDateTime},
+       {TPtrC(KNote), R_VPBK_FIELD_TYPE_NOTE, EDataTypeText},
+       {TPtrC(KThumbnailPath), R_VPBK_FIELD_TYPE_THUMBNAILPIC, EDataTypeText},
+       {TPtrC(KThumbnailId), R_VPBK_FIELD_TYPE_THUMBNAILPIC, EDataTypeText},
+       {TPtrC(KRingTone), R_VPBK_FIELD_TYPE_RINGTONE, EDataTypeText},
+       {TPtrC(KRingToneId), R_VPBK_FIELD_TYPE_RINGTONE, EDataTypeText},
+       
+       {TPtrC(KCallerobjImg), R_VPBK_FIELD_TYPE_CALLEROBJIMG, EDataTypeText},
+       {TPtrC(KCallerobjText), R_VPBK_FIELD_TYPE_CALLEROBJTEXT, EDataTypeText},
+       {TPtrC(KMiddlename), R_VPBK_FIELD_TYPE_MIDDLENAME, EDataTypeText},
+       {TPtrC(KDepartment), R_VPBK_FIELD_TYPE_DEPARTMENT, EDataTypeText},
+       {TPtrC(KAsstname), R_VPBK_FIELD_TYPE_ASSTNAME, EDataTypeText},
+       {TPtrC(KSpouse), R_VPBK_FIELD_TYPE_SPOUSE, EDataTypeText},
+       {TPtrC(KChildren), R_VPBK_FIELD_TYPE_CHILDREN, EDataTypeText},
+       {TPtrC(KAsstphone), R_VPBK_FIELD_TYPE_ASSTPHONE, EDataTypeText},
+       
+       {TPtrC(KCarphone), R_VPBK_FIELD_TYPE_CARPHONE, EDataTypeText},
+       {TPtrC(KAnniversary), R_VPBK_FIELD_TYPE_ANNIVERSARY, EDataTypeDateTime},
+       {TPtrC(KSyncclass), R_VPBK_FIELD_TYPE_SYNCCLASS, EDataTypeText},
+       {TPtrC(KLocPrivacy), R_VPBK_FIELD_TYPE_LOCPRIVACY, EDataTypeText},
+       {TPtrC(KGenlabel), R_VPBK_FIELD_TYPE_GENLABEL, EDataTypeText}
+};
+#endif 
+
+CCreatorContactElementBase* CCreatorContactElementBase::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext)
+    {
+    LOGSTRING("Creator: CCreatorContactElementBase::NewL");
+    CCreatorContactElementBase* self = new (ELeave) CCreatorContactElementBase(aEngine);
+    CleanupStack::PushL(self);
+    self->ConstructL(aName, aContext);
+    CleanupStack::Pop();
+    return self;
+    }
+CCreatorContactElementBase::CCreatorContactElementBase(CCreatorEngine* aEngine) : CCreatorScriptElement(aEngine)
+    { }
+
+CCreatorContactElement* CCreatorContactElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext)
+    {
+    LOGSTRING("Creator: CCreatorContactElement::NewL");
+    CCreatorContactElement* self = new (ELeave) CCreatorContactElement(aEngine);
+    CleanupStack::PushL(self);
+    self->ConstructL(aName, aContext);
+    CleanupStack::Pop();
+    return self;
+    }
+CCreatorContactElement::CCreatorContactElement(CCreatorEngine* aEngine) 
+: 
+CCreatorContactElementBase(aEngine)
+    { 
+    iIsCommandElement = ETrue;
+    }
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+void CCreatorContactElement::ExecuteCommandL()
+    {    
+    LOGSTRING("Creator: CCreatorContactElement::ExecuteCommandL");
+    // Find out how many contacts should we create:
+    const CCreatorScriptAttribute* contactAmountAttr = this->FindAttributeByName(KAmount);    
+    TInt contactAmount = 1;    
+    if( contactAmountAttr )
+        {
+        contactAmount = ConvertStrToIntL(contactAmountAttr->Value());
+        }
+    CCreatorScriptElement* fieldsElement = FindSubElement(KFields);
+    TInt fieldMappingTblSize = sizeof(fieldMappingTbl)/sizeof(FieldMapping);
+    for( TInt cI = 0; cI < contactAmount; ++cI )
+        {
+        CVirtualPhonebookParameters* param = (CVirtualPhonebookParameters*) TCreatorFactory::CreatePhoneBookParametersL();
+        CleanupStack::PushL(param);
+        // Loop all the field elements
+        if( fieldsElement && fieldsElement->SubElements().Count() > 0 )
+            {
+            
+            const RPointerArray<CCreatorScriptElement>& fieldList = fieldsElement->SubElements();
+            
+            if( fieldList.Count() == 0 )
+                {
+                
+                }
+            for( TInt i = 0; i < fieldList.Count(); ++i )
+                {
+                TPtrC fieldName = fieldList[i]->Name();
+                const CCreatorScriptAttribute* amountAttr = fieldList[i]->FindAttributeByName(KAmount);
+                const CCreatorScriptAttribute* rndLenAttr = fieldList[i]->FindAttributeByName(KRandomLength);
+                const CCreatorScriptAttribute* increaseAttr = fieldList[i]->FindAttributeByName(KIncrease);
+                TBool increase( EFalse );
+                if ( increaseAttr )
+                    {
+                    increase = ConvertStrToBooleanL( increaseAttr->Value() );
+                    }
+                CCreatorContactField* field = 0;
+                for( TInt j = 0; j < fieldMappingTblSize; ++j )
+                    {
+                    const FieldMapping& mapping = fieldMappingTbl[j];
+                    if( fieldName == mapping.iElementName )
+                        {
+                        TInt rndLen = 0;
+                        TPtrC content = fieldList[i]->Content();
+                                                                        
+                        MCreatorRandomDataField::TRandomLengthType randomLenType = MCreatorRandomDataField::ERandomLengthUndefined;
+                    
+                        if( content == TPtrC(KEmpty) || content == TPtrC(KNullDesC) )
+                            {
+                            if( rndLenAttr == 0 )
+                                {
+                                randomLenType = MCreatorRandomDataField::ERandomLengthDefault;
+                                }
+                            else
+                                {
+                                randomLenType = ResolveRandomDataTypeL(*rndLenAttr, rndLen);
+                                }
+                            }
+                        else
+                            {
+                            // Special handling for file id content:
+                            if( fieldName == KThumbnailId )
+                                {
+                                // Thumbnail data is copied to the contact entry, so we can use temporary file:
+                                CCreatorEngine::TTestDataPath id = (CCreatorEngine::TTestDataPath) iEngine->GetAttachmentIdL(content);
+                                content.Set(iEngine->TestDataPathL(id));
+                                }
+                            else if( fieldName == KRingToneId )
+                            	{
+                            	// Contact entry contains just a link to the sound file, so we must 
+                            	// copy the temporary file to a permanent location:
+                            	CCreatorEngine::TTestDataPath id = (CCreatorEngine::TTestDataPath) iEngine->GetAttachmentIdL(content);
+                            	TPtrC fullTargetPath(iEngine->CreateSoundFileL(id));                           	
+                            	content.Set(fullTargetPath);
+                            	}
+                            }
+                        TInt amountValue = 1;
+                        if( amountAttr )
+                            {                        
+                            amountValue = ConvertStrToIntL(amountAttr->Value());
+                            }
+                        for( TInt k = 0; k < amountValue; ++k )
+                            {
+                            if ( increase &&
+                                 ( fieldName.FindF( _L("number") ) > KErrNotFound ||
+                                 fieldName.FindF( _L("phone") ) > KErrNotFound ) )
+                                {
+                                // increase phonenumber for each copy
+                                HBufC* incNum = HBufC::NewLC( content.Length() + 3 );
+                                if ( amountValue > 1 )
+                                    {
+                                    // amount defined in number field level
+                                    IncreasePhoneNumL( content, k, incNum );
+                                    }
+                                else
+                                    {
+                                    // amount defined in contact field level
+                                    IncreasePhoneNumL( content, cI, incNum );
+                                    }
+                                field = CCreatorContactField::NewL( mapping.iFieldCode, *incNum );
+                                CleanupStack::PushL( field );
+                                field->SetRandomParametersL( randomLenType, rndLen );
+                                param->iContactFields.AppendL( field );
+                                CleanupStack::Pop( field );
+                                CleanupStack::PopAndDestroy( incNum );
+                                }
+                            else
+                                {
+                                field = CCreatorContactField::NewL(mapping.iFieldCode, content);
+                                CleanupStack::PushL(field);
+                                field->SetRandomParametersL(randomLenType, rndLen);
+                                param->iContactFields.AppendL(field);
+                                CleanupStack::Pop(field);                                
+                                }
+                            }
+                        break;
+                        }
+                    }
+                }
+            } 
+        else
+        	{
+        	// No fields specified, so add all fields with random content:
+        	for( TInt i = 0; i < fieldMappingTblSize; ++i )
+        		{
+        		if( fieldMappingTbl[i].iElementName == KThumbnailId || 
+        			fieldMappingTbl[i].iElementName == KRingToneId )
+        			{
+        			// Skip thumbnail and ringtone IDs, since they are duplicates with thumbnailpath and ringtonepath
+        			continue;
+        			}
+        		CCreatorContactField* field = 0;
+        		if(fieldMappingTbl[i].iDataType == EDataTypeText )
+        			{
+        			field = CCreatorContactField::NewL(fieldMappingTbl[i].iFieldCode, KNullDesC);
+        			}
+        		else if( fieldMappingTbl[i].iDataType == EDataTypeBinary )
+        			{
+        			field = CCreatorContactField::NewL(fieldMappingTbl[i].iFieldCode, KNullDesC8);
+        			}
+        		else if( fieldMappingTbl[i].iDataType == EDataTypeDateTime )
+        			{                    	
+        			TDateTime dateTime(Time::NullTTime().DateTime());
+        			field = CCreatorContactField::NewL(fieldMappingTbl[i].iFieldCode, dateTime);
+        			}
+        		if( field )
+        			{
+        			CleanupStack::PushL(field);
+        			field->SetRandomParametersL(MCreatorRandomDataField::ERandomLengthDefault, 0);
+        			param->iContactFields.AppendL(field);
+        			CleanupStack::Pop(field);
+        			}
+        		}
+        	}
+        iEngine->AppendToCommandArrayL(ECmdCreatePhoneBookEntryContacts, param);
+        iParameters.AppendL(param); // Save the pointer to the parametes. 
+        CleanupStack::Pop(param);
+        }
+    }
+#else
+void CCreatorContactElement::ExecuteCommandL()
+    {}
+#endif
+
+CCreatorContactSetElement* CCreatorContactSetElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext)
+    {
+    LOGSTRING("Creator: CCreatorContactSetElement::NewL");
+    CCreatorContactSetElement* self = new (ELeave) CCreatorContactSetElement(aEngine);
+    CleanupStack::PushL(self);
+    self->ConstructL(aName, aContext);
+    CleanupStack::Pop();
+    return self;
+    }
+CCreatorContactSetElement::CCreatorContactSetElement(CCreatorEngine* aEngine) 
+: 
+CCreatorContactElementBase(aEngine)
+    { }
+
+void CCreatorContactSetElement::ExecuteCommandL()
+    { }
+
+void CCreatorContactSetElement::AddToCacheL()
+    {    
+    LOGSTRING("Creator: CCreatorContactSetElement::AddToCacheL");
+    const CCreatorScriptAttribute* linkIdAttr = this->FindAttributeByName(KId);
+    const CCreatorScriptAttribute* existingElemsAttr = this->FindAttributeByName(KExistingContacts);
+    TInt numOfExistingContacts = 0;
+    if( existingElemsAttr )
+        {
+        numOfExistingContacts = ConvertStrToIntL(existingElemsAttr->Value());
+        }
+    if( linkIdAttr )
+        {
+        TInt linkId = ConvertStrToIntL(linkIdAttr->Value());
+        if( linkId > 0 )
+            {    
+            CCreatorContactSet* newSet = CCreatorContactSet::NewL(linkId, numOfExistingContacts);
+            CleanupStack::PushL(newSet);
+            ContactLinkCache::Instance()->AppendL(newSet);
+            CleanupStack::Pop(newSet);
+                 
+            // Mark sub-elements (i.e. contacts) to this contact-set:
+            for( TInt i = 0; i < iSubElements.Count(); ++i )
+                {
+                for( TInt j = 0; j < iSubElements[i]->CommandParameters().Count(); ++j)
+                    {
+                    CCreatorModuleBaseParameters* params = iSubElements[i]->CommandParameters()[j];
+                    if( params )
+                        {
+                        params->SetScriptLinkId(linkId);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+CCreatorContactGroupElement* CCreatorContactGroupElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext)
+    {
+    LOGSTRING("Creator: CCreatorContactGroupElement::NewL");
+    CCreatorContactGroupElement* self = new (ELeave) CCreatorContactGroupElement(aEngine);
+    CleanupStack::PushL(self);
+    self->ConstructL(aName, aContext);
+    CleanupStack::Pop();
+    return self;
+    }
+CCreatorContactGroupElement::CCreatorContactGroupElement(CCreatorEngine* aEngine)
+: 
+CCreatorContactElementBase(aEngine)
+    { 
+    iIsCommandElement = ETrue;
+    }
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ )
+void CCreatorContactGroupElement::ExecuteCommandL()
+    {
+    LOGSTRING("Creator: CCreatorContactGroupElement::ExecuteCommandL");
+    // Get attributes (amount and name)
+    const CCreatorScriptAttribute* groupAmountAttr = this->FindAttributeByName(KAmount);        
+    const CCreatorScriptAttribute* groupNameAttr = this->FindAttributeByName(KName);
+    // How many groups to create:
+    TInt groupAmount = 1;        
+    if( groupAmountAttr )
+        {
+        groupAmount = ConvertStrToIntL(groupAmountAttr->Value());
+        }
+    
+    for( TInt i = 0; i < groupAmount; ++i )
+        {        
+        CCreatorScriptElement* membersElement = FindSubElement(KMembers);
+        
+        if( membersElement )
+            {    
+            CVirtualPhonebookParameters* param = (CVirtualPhonebookParameters*) TCreatorFactory::CreatePhoneBookParametersL();            
+            CleanupStack::PushL(param);
+            
+            // Links to contact-sets:
+            const RPointerArray<CCreatorScriptElement>& linkList = membersElement->SubElements();
+            if( linkList.Count() > 0 )
+                {
+                for( TInt i = 0; i < linkList.Count(); ++i )
+                    {
+                    AppendContactSetReferenceL(*linkList[i], param->iLinkIds);
+                    }                
+                }
+            
+            if( groupNameAttr )
+                {
+                param->iGroupName->Des().Copy( groupNameAttr->Value() );
+                }
+            else
+                {
+                param->iGroupName->Des().Copy( iEngine->RandomString(CCreatorEngine::EGroupName) );
+                }                
+            iEngine->AppendToCommandArrayL(ECmdCreatePhoneBookEntryGroups, param);
+            CleanupStack::Pop(param);
+            }
+        }
+    }
+#else
+void CCreatorContactGroupElement::ExecuteCommandL()
+    {}
+#endif
+
+CCreatorContactFieldElement* CCreatorContactFieldElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext)
+    {
+    LOGSTRING("Creator: CCreatorContactFieldElement::NewL");
+    CCreatorContactFieldElement* self = new (ELeave) CCreatorContactFieldElement(aEngine);
+    CleanupStack::PushL(self);
+    self->ConstructL(aName, aContext);
+    CleanupStack::Pop();
+    return self;
+    }
+
+CCreatorContactFieldElement::CCreatorContactFieldElement(CCreatorEngine* aEngine) 
+: 
+CCreatorScriptElement(aEngine)
+    { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_contactsetcache.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,229 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include "creator_contactsetcache.h"
+
+
+CContactLinkCacheImp* ContactLinkCache::iImp = 0;
+
+CCreatorContactSet* CCreatorContactSet::NewL(TInt aLinkId, TInt aNumOfExistingContacts)
+    {
+    return new (ELeave) CCreatorContactSet(aLinkId, aNumOfExistingContacts);    
+    }
+
+TInt CCreatorContactSet::LinkId() const
+    {
+    return iLinkId;
+    }
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+void CCreatorContactSet::AppendL(MVPbkContactLink* aContactLink)
+    {
+    iContactLinks.AppendL(aContactLink);
+    }
+
+RPointerArray<MVPbkContactLink>& CCreatorContactSet::ContactLinks()
+    {
+    return iContactLinks;
+    }
+
+const RPointerArray<MVPbkContactLink>& CCreatorContactSet::ContactLinks() const
+    {
+    return iContactLinks;
+    }
+
+
+TInt CCreatorContactSet::NumberOfExistingContacts() const
+    {
+    return iNumOfExistingContacts;
+    }
+
+CCreatorContactSet::~CCreatorContactSet()
+    {
+    iContactLinks.Reset();
+    iContactLinks.Close();
+    }
+
+#else
+CCreatorContactSet::~CCreatorContactSet()
+    {
+    }
+#endif
+
+
+CCreatorContactSet::CCreatorContactSet(TInt aLinkId, TInt aNumOfExistingContacts)
+    {
+    iLinkId = aLinkId;
+    iNumOfExistingContacts = aNumOfExistingContacts;
+    }
+
+class CContactLinkCacheImp : public CBase, public MContactLinkCache
+{
+public:
+    static CContactLinkCacheImp* NewL();
+    virtual ~CContactLinkCacheImp();
+    virtual void AppendL(CCreatorContactSet* aContactSet);
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+    virtual RPointerArray<MVPbkContactLink>& ContactLinks(TInt aLinkId);
+    virtual const RPointerArray<MVPbkContactLink>& ContactLinks(TInt aLinkId) const;
+#endif        
+    virtual RPointerArray<CCreatorContactSet>& ContactSets();
+    virtual const RPointerArray<CCreatorContactSet>& ContactSets() const;
+    virtual const CCreatorContactSet& ContactSet(TInt aLinkId) const;
+    virtual CCreatorContactSet& ContactSet(TInt aLinkId);
+    
+private:
+    void ConstructL();
+    CContactLinkCacheImp();
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)    
+    RPointerArray<MVPbkContactLink> iEmptyLinks;
+#endif    
+    RPointerArray<CCreatorContactSet> iContactSets;
+    CCreatorContactSet* iDummyContactSet;
+};
+
+CContactLinkCacheImp* CContactLinkCacheImp::NewL()
+    {
+    CContactLinkCacheImp* self = new (ELeave) CContactLinkCacheImp();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+void CContactLinkCacheImp::ConstructL()
+    {
+    if( iDummyContactSet == 0 )
+        iDummyContactSet = CCreatorContactSet::NewL(-1, 0);    
+    }
+
+CContactLinkCacheImp::CContactLinkCacheImp()
+: iDummyContactSet(0)
+    {}
+
+CContactLinkCacheImp::~CContactLinkCacheImp()
+    {
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)    
+    iEmptyLinks.ResetAndDestroy(); // just in case...
+    iEmptyLinks.Close();
+#endif
+    iContactSets.ResetAndDestroy();
+    iContactSets.Close();
+    delete iDummyContactSet;
+    }
+void CContactLinkCacheImp::AppendL(CCreatorContactSet* aContactSet)
+    {
+    iContactSets.AppendL(aContactSet);
+    }
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+
+RPointerArray<MVPbkContactLink>& CContactLinkCacheImp::ContactLinks(TInt aLinkId)
+    {
+    for( TInt i = 0; i < iContactSets.Count(); ++i )
+        {
+        if( iContactSets[i]->LinkId() == aLinkId )
+            {
+            return iContactSets[i]->ContactLinks();
+            }
+        }
+    return iEmptyLinks;
+    }
+
+const RPointerArray<MVPbkContactLink>& CContactLinkCacheImp::ContactLinks(TInt aLinkId) const
+    {
+    for( TInt i = 0; i < iContactSets.Count(); ++i )
+        {
+        if( iContactSets[i]->LinkId() == aLinkId )
+            {
+            return iContactSets[i]->ContactLinks();
+            }
+        }
+    return iEmptyLinks;
+    }
+
+#endif
+
+const CCreatorContactSet& CContactLinkCacheImp::ContactSet(TInt aLinkId) const
+    {
+    for( TInt i = 0; i < iContactSets.Count(); ++i )
+        {
+        if( iContactSets[i]->LinkId() == aLinkId )
+            {
+            return *iContactSets[i];
+            }
+        }
+        
+    return *iDummyContactSet;
+    }
+
+CCreatorContactSet& CContactLinkCacheImp::ContactSet(TInt aLinkId)
+    {
+    for( TInt i = 0; i < iContactSets.Count(); ++i )
+        {
+        if( iContactSets[i]->LinkId() == aLinkId )
+            {
+            return *iContactSets[i];
+            }
+        }
+        
+    return *iDummyContactSet;
+    }
+
+RPointerArray<CCreatorContactSet>& CContactLinkCacheImp::ContactSets()
+    {
+    return iContactSets;
+    }
+
+const RPointerArray<CCreatorContactSet>& CContactLinkCacheImp::ContactSets() const
+    {
+    return iContactSets;
+    }
+
+
+void ContactLinkCache::InitializeL()
+    {
+    if( iImp == 0 )
+        {
+        iImp = CContactLinkCacheImp::NewL();
+        }
+    }
+
+void ContactLinkCache::DestroyL()
+    {
+    delete iImp;
+    iImp = 0;
+    }
+
+MContactLinkCache* ContactLinkCache::Instance()
+    {
+    return iImp;
+    }
+
+
+    /*{
+public:
+    static void ;
+    static void DestructLD();
+    
+    static MContactLinkCache* Instance();
+    
+private:
+    CContactLinkImp* iImp;
+};*/
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_container.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,244 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include <coemain.h>
+#include <aknnotewrappers.h>
+#include <creator.rsg>
+#include <AknDef.h>
+#include "creator_container.h"
+
+
+
+// Standard construction sequence
+CCreatorAppView* CCreatorAppView::NewL(const TRect& aRect)
+    {
+    CCreatorAppView* self = CCreatorAppView::NewLC(aRect);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CCreatorAppView* CCreatorAppView::NewLC(const TRect& aRect)
+    {
+    CCreatorAppView* self = new (ELeave) CCreatorAppView;
+    CleanupStack::PushL(self);
+    self->ConstructL(aRect);
+    return self;
+    }
+
+void CCreatorAppView::ConstructL(const TRect& aRect)
+    {
+    // Create a window for this application view
+    CreateWindowL();
+
+    // Set the windows size
+    SetRect(aRect);
+
+    // Activate the window, which makes it ready to be drawn
+    ActivateL();
+
+    }
+
+CCreatorAppView::CCreatorAppView()
+    {
+    // Add any construction code that can not leave here
+    }
+
+
+CCreatorAppView::~CCreatorAppView()
+    {
+    // Add any destruction code here
+    }
+
+
+// Draw this application's view to the screen
+void CCreatorAppView::Draw(const TRect& /*aRect*/) const
+    {
+
+    // Get the standard graphics context 
+    CWindowGc& gc = SystemGc();
+
+    // Gets the control's extent
+    TRect rect = Rect();
+
+    // Clears the screen
+    gc.Clear(rect);
+
+    // variables for memory and disk handling
+    TDriveNumber cDrive=EDriveC;
+    TDriveNumber dDrive=EDriveD;
+    TDriveNumber eDrive=EDriveE;
+    TVolumeInfo vinfo;
+    TBuf<16> cFree;
+    TBuf<16> dFree;
+    TBuf<16> eFree;
+    TBuf<16> cSize;
+    TBuf<16> dSize;
+    TBuf<16> eSize;
+    TBuf<64> cText;
+    TBuf<64> dText;
+    TBuf<64> eText;
+    TBuf<64> hText;
+
+    // get an access to file server
+    RFs& fsSession = ControlEnv()->FsSession();
+
+    // check the C-drive
+    fsSession.Volume(vinfo, cDrive);
+    cFree.Num(TInt64(vinfo.iFree/1024));
+    cSize.Num(TInt64(vinfo.iSize/1024));
+
+    // format the information about the C-drive
+    cText.Copy(_L("C: "));
+    cText.Append(cFree);
+    cText.Append(_L("kB of "));
+    cText.Append(cSize);
+    cText.Append(_L("kB"));
+
+
+    // the same thing for D-drive
+    fsSession.Volume(vinfo, dDrive);
+    dFree.Num(TInt64(vinfo.iFree/1024));
+    dSize.Num(TInt64(vinfo.iSize/1024));
+
+    dText.Copy(_L("D: "));
+    dText.Append(dFree);
+    dText.Append(_L("kB of "));
+    dText.Append(dSize);
+    dText.Append(_L("kB"));
+
+
+    // the same thing for E-drive (MMC), if it exists 
+    if (MMC_OK())
+        {
+        fsSession.Volume(vinfo, eDrive);
+        eFree.Num(TInt64(vinfo.iFree/1024));
+        eSize.Num(TInt64(vinfo.iSize/1024));
+
+        eText.Copy(_L("E: "));
+        eText.Append(eFree);
+        eText.Append(_L("kB of "));
+        eText.Append(eSize);
+        eText.Append(_L("kB"));
+        }	
+
+
+    // available work memory
+    TMemoryInfoV1Buf memory;
+    UserHal::MemoryInfo(memory);
+    TInt64 freeMemBytes=(TInt64)(memory().iFreeRamInBytes);
+    TInt64 sizeMemBytes=(TInt64)(memory().iTotalRamInBytes);
+
+    /// ...
+    TInt64 sizeWorkMemBytes = sizeMemBytes; 
+
+
+    TBuf<16> freeMem;
+    TBuf<16> sizeWorkMem;
+
+    freeMem.Num(TInt64(freeMemBytes/1024));
+    sizeWorkMem.Num(TInt64(sizeWorkMemBytes/1024));
+
+    hText.Copy(freeMem);
+    hText.Append(_L("kB of "));
+    hText.Append(sizeWorkMem);
+    hText.Append(_L("kB"));
+
+
+    // draw all the texts to the screen
+    gc.UseFont(AknLayoutUtils::FontFromId(EAknLogicalFontSecondaryFont));
+   
+    TSize mainPaneSize;
+    AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, mainPaneSize);
+    
+    TReal X_factor = TReal(mainPaneSize.iWidth) / 176;
+    TReal Y_factor = TReal(mainPaneSize.iHeight) / 144;
+
+    gc.SetPenColor(KRgbDarkBlue);
+    gc.DrawText(_L("Free RAM memory:"), TPoint(TInt(4*X_factor), TInt(15*Y_factor)));
+    gc.SetPenColor(KRgbBlack);
+    gc.DrawText(hText, TPoint(TInt(4*X_factor), TInt(30*Y_factor)));
+
+    gc.SetPenColor(KRgbDarkBlue);
+    gc.DrawText(_L("Free disk memory:"), TPoint(TInt(4*X_factor), TInt(55*Y_factor)));
+    gc.SetPenColor(KRgbBlack);
+    gc.DrawText(cText, TPoint(TInt(4*X_factor), TInt(70*Y_factor)));
+    gc.DrawText(dText, TPoint(TInt(4*X_factor), TInt(85*Y_factor)));
+
+    if (MMC_OK())
+        {
+        gc.DrawText(eText, TPoint(TInt(4*X_factor), TInt(100*Y_factor)));
+        }
+
+    }
+
+TKeyResponse CCreatorAppView::OfferKeyEventL(
+		const TKeyEvent& aKeyEvent,TEventCode aType)
+	{
+	// return the default functionality
+	return CCoeControl::OfferKeyEventL(aKeyEvent, aType);
+	}
+
+
+TCoeInputCapabilities CCreatorAppView::InputCapabilities() const
+	{
+	// this class does not implement any 'unusual' input capabilities
+	return TCoeInputCapabilities::ENone;
+	}
+
+
+void CCreatorAppView::UserDraw() const
+	{
+	ActivateGc();
+	Draw(Rect());
+	DeactivateGc();
+	}
+
+
+
+TBool CCreatorAppView::MMC_OK() const
+	{
+	TBool MMCstatus = EFalse;
+
+	TDriveNumber eDrive=EDriveE;
+    TVolumeInfo vinfo;
+
+	// check if we can access the E-drive:
+	if ( iEikonEnv->FsSession().Volume(vinfo, eDrive) == KErrNone)
+		{
+		MMCstatus = ETrue;
+		}
+	else
+		{
+		MMCstatus = EFalse;
+		}
+
+	// returns ETrue if MMC working properly
+	return MMCstatus;
+	}
+
+
+void CCreatorAppView::HandleResourceChange(TInt aType)
+    {
+    if ( aType == KEikDynamicLayoutVariantSwitch )
+        {
+        TRect mainPaneRect;
+        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+        SetRect(mainPaneRect);
+        }
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_document.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#include "creator_appui.h"
+#include "creator_document.h"
+
+
+// Standard Symbian OS construction sequence
+CCreatorDocument* CCreatorDocument::NewL(CEikApplication& aApp)
+    {
+    CCreatorDocument* self = NewLC(aApp);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CCreatorDocument* CCreatorDocument::NewLC(CEikApplication& aApp)
+    {
+    CCreatorDocument* self = new (ELeave) CCreatorDocument(aApp);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+void CCreatorDocument::ConstructL()
+    {
+    // Add any construction that can leave here
+    }    
+
+CCreatorDocument::CCreatorDocument(CEikApplication& aApp) : CAknDocument(aApp) 
+    {
+    // Add any construction that can not leave here
+    }   
+
+CCreatorDocument::~CCreatorDocument()
+    {
+    // Any destruction code here
+    }
+
+CEikAppUi* CCreatorDocument::CreateAppUiL()
+    {
+    // Create the application user interface, and return a pointer to it
+    CEikAppUi* appUi = new (ELeave) CCreatorAppUi;
+    return appUi;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_factory.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,65 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include "creator_factory.h"
+
+#if( defined __SERIES60_30__ || defined __SERIES60_31__ )
+    #include "creator_phonebook.h"
+    #include "creator_accessPoint.h"
+#else
+    #include "creator_virtualphonebook.h"
+    #include "creator_connectionmethod.h"
+#endif 
+
+CCreatorPhonebookBase* TCreatorFactory::CreatePhoneBookL(CCreatorEngine* aEngine)
+{
+#if( defined __SERIES60_30__ || defined __SERIES60_31__ )
+    return CCreatorPhonebook::NewL(aEngine);    
+#else
+    return CCreatorVirtualPhonebook::NewL(aEngine);    
+#endif 
+
+}
+
+CCreatorModuleBaseParameters* TCreatorFactory::CreatePhoneBookParametersL()
+	{
+#if( defined __SERIES60_30__ || defined __SERIES60_31__ )
+	return new(ELeave) CPhonebookParameters;
+#else
+	return new(ELeave) CVirtualPhonebookParameters;
+#endif 	
+	}
+
+CCreatorConnectionSettingsBase* TCreatorFactory::CreateConnectionSettingsL(CCreatorEngine* aEngine)
+{
+#if( defined __SERIES60_30__ || defined __SERIES60_31__ )
+    return CCreatorAccessPoints::NewL(aEngine);
+#else
+    return CCreatorConnectionSettings::NewL(aEngine);    
+#endif 
+
+}
+
+CCreatorModuleBaseParameters* TCreatorFactory::CreateConnectionSettingsParametersL()
+    {
+#if( defined __SERIES60_30__ || defined __SERIES60_31__ )
+    return new(ELeave) CAccessPointsParameters;
+#else
+    return new(ELeave) CConnectionSettingsParameters;
+#endif 
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_file.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,847 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#include "creator_file.h" 
+#include <DRMRights.h>
+#include <caf/supplier.h>
+#include <caf/importfile.h>
+#include "creator_traces.h"
+
+using namespace ContentAccess;
+
+static const TInt KFilesFieldLength = 256;
+
+//_LIT(KCreatorFilesPrefixName, "CR_");
+//_LIT(KCreatorFilesPrefixFolderName, "CR_FLDR_");
+
+//----------------------------------------------------------------------------
+
+CFilesParameters::CFilesParameters()
+    {
+    LOGSTRING("Creator: CFilesParameters::CFilesParameters");
+    iFullFilePath = HBufC::New(KFilesFieldLength);
+    }
+CFilesParameters::CFilesParameters( CFilesParameters& aCopy )
+    {
+    LOGSTRING("Creator: CFilesParameters::CFilesParameters");
+    iFullFilePath = HBufC::New(KFilesFieldLength);
+    iFullFilePath->Des().Copy( *aCopy.iFullFilePath );
+    iFileCommand = aCopy.iFileCommand;
+    iEncrypt = aCopy.iEncrypt;
+    if ( aCopy.iPermission )
+        {
+        iPermission = CDRMPermission::NewL();
+        iPermission->DuplicateL( *aCopy.iPermission );
+        }
+    }
+CFilesParameters::~CFilesParameters()
+    {
+    LOGSTRING("Creator: CFilesParameters::~CFilesParameters");
+    delete iFullFilePath;
+    delete iPermission;
+    }
+
+//----------------------------------------------------------------------------
+
+CCreatorFiles* CCreatorFiles::NewL(CCreatorEngine* aEngine)
+    {
+    CCreatorFiles* self = CCreatorFiles::NewLC(aEngine);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CCreatorFiles* CCreatorFiles::NewLC(CCreatorEngine* aEngine)
+    {
+    CCreatorFiles* self = new (ELeave) CCreatorFiles;
+    CleanupStack::PushL(self);
+    self->ConstructL(aEngine);
+    return self;
+    }
+
+CCreatorFiles::CCreatorFiles() :
+    iFs ( CEikonEnv::Static()->FsSession() )
+    {
+    }
+
+void CCreatorFiles::ConstructL(CCreatorEngine* aEngine)
+    {
+    LOGSTRING("Creator: CCreatorFiles::ConstructL");
+
+    iEngine = aEngine;
+
+    iDirectoryQueriedFromUser = HBufC::New(KFilesFieldLength);
+    User::LeaveIfError( iApaLs.Connect() );
+    
+    iFilePaths = new (ELeave) CDesCArrayFlat( 4 );
+    
+    // Restore file id 
+    CDictionaryFileStore* store = iEngine->FileStoreLC();
+    User::LeaveIfNull( store );
+    if ( store->IsPresentL( KUidDictionaryUidFiles ) )
+        {
+        RDictionaryReadStream in;
+        in.OpenLC( *store, KUidDictionaryUidFiles );
+        TRAPD( err, iFileId = in.ReadInt32L() );
+        if ( err )
+            {
+            iFileId = 1;
+            }
+        CleanupStack::PopAndDestroy(); // in
+        }
+    else
+        {
+        iFileId = 1;
+        }
+    CleanupStack::PopAndDestroy( store );
+    }
+
+CCreatorFiles::~CCreatorFiles()
+    {
+    LOGSTRING("Creator: CCreatorFiles::~CCreatorFiles");
+    
+    // this is done only once per file operation:
+    if ( iFilePaths && iFilePaths->Count() )
+        {
+        TRAP_IGNORE( StorePathsForDeleteL( *iFilePaths ) );
+        }
+    delete iFilePaths;
+    delete iDirectoryQueriedFromUser;
+    delete iParameters;
+    delete iUserParameters;
+    iApaLs.Close();
+    }
+
+//----------------------------------------------------------------------------
+
+TBool CCreatorFiles::AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries)
+    {
+    LOGSTRING("Creator: CCreatorFiles::AskDataFromUserL");
+    
+    if ( aCommand == ECmdDeleteCreatorFiles )
+        {
+        return iEngine->YesNoQueryDialogL( _L("Delete all files created with Creator?") );
+        }
+    
+    delete iUserParameters;
+    iUserParameters = NULL;
+    iUserParameters = new(ELeave) CFilesParameters();
+    
+    iDirectoryQueriedFromUser->Des().Copy( KNullDesC );
+
+    if (iEngine->EntriesQueryDialogL(aNumberOfEntries, _L("How many entries to create?")))
+        {
+        // set a default directory  (eg. c:\Nokia\Images\)
+        TFileName directory;
+        iEngine->SetDefaultPathForFileCommandL(aCommand, directory);
+
+        // directory query dialog
+        CAknTextQueryDialog* textDialog = CAknTextQueryDialog::NewL(directory, CAknQueryDialog::ENoTone);
+        textDialog->SetMaxLength(256);
+
+        TBuf<50> promptText;
+
+        if (aCommand == ECmdCreateFileEntryEmptyFolder)
+            promptText.Copy( _L("Specify the folder path and name") );
+        else
+            promptText.Copy( _L("Specify the directory") );
+
+        if (textDialog->ExecuteLD(R_DIRECTORY_QUERY, promptText))
+            {
+	        // check that the root folder is correct
+            if (directory.Length() < 3  ||  BaflUtils::CheckFolder(iFs, directory.Left(3)) != KErrNone)
+                {
+                CAknErrorNote* errorNote = new (ELeave) CAknErrorNote;
+                errorNote->ExecuteLD(_L("Invalid path"));
+                return EFalse;
+                }        
+            else
+                {
+                // check the directory contains a trailing backlash
+                if (directory.Right(1) != _L("\\"))
+                    directory.Append(_L("\\"));
+
+                // copy the directory name to a class member
+                iDirectoryQueriedFromUser->Des() = directory;
+                if ( aCommand == ECmdCreateFileEntryEmptyFolder ) return ETrue;
+                else return AskDRMDataFromUserL();
+                }
+            }        
+        else
+            return EFalse;
+        }
+    else
+        return EFalse;
+
+    }
+
+
+//----------------------------------------------------------------------------
+
+TInt CCreatorFiles::CreateFileEntryL(CFilesParameters *aParameters, TInt aCommand)
+    {
+    LOGSTRING("Creator: CCreatorFiles::CreateFileEntryL");
+
+    // clear any existing parameter definations
+    delete iParameters;
+    iParameters = NULL;
+    TFileName directoryToBeCreated;
+            
+    CFilesParameters* parameters = aParameters;
+    
+    if (!parameters)
+        {
+        if ( iUserParameters )
+            {
+            iParameters = new (ELeave) CFilesParameters( *iUserParameters );
+            // iUserParameters = NULL;
+            }
+        else
+            {
+            // random data needed if no predefined data available
+            iParameters = new (ELeave) CFilesParameters;            
+            }
+        parameters = iParameters;
+        }
+
+    TInt err = KErrNone;
+
+    // if we just create directories
+    if ( aCommand == ECmdCreateFileEntryEmptyFolder)
+        {
+        // strip the last backslash from the path
+        if( iDirectoryQueriedFromUser && iDirectoryQueriedFromUser->Des().Length() > 0)
+        	directoryToBeCreated = iDirectoryQueriedFromUser->Des();
+        else if( parameters->iFullFilePath && parameters->iFullFilePath->Des().Length() > 0 )
+        	directoryToBeCreated = parameters->iFullFilePath->Des();
+        else 
+        	return err;
+        
+        _LIT(KSlash, "\\");
+        if( directoryToBeCreated.Right(1) == KSlash )
+        	directoryToBeCreated.SetLength ( directoryToBeCreated.Length() - 1 ); 
+            
+        // generate a unique file name
+        err = CApaApplication::GenerateFileName( iFs, directoryToBeCreated);
+        if (err != KErrNone)
+            return err;
+
+        // now append the backslah back
+        directoryToBeCreated.Append( _L("\\") );
+        
+        // now create the new directory
+        err = iFs.MkDirAll( directoryToBeCreated );
+        
+        // Add directoryToBeCreated to store
+        iFilePaths->AppendL( directoryToBeCreated );
+
+        LOGSTRING3("Creator: CCreatorFiles::CreateFileEntryL creating empty directory %S returns err", &directoryToBeCreated, err);
+        }
+
+    else  // files
+        {
+        LOGSTRING2("Creator: CCreatorFiles::CreateFileEntryL file id is %d", aCommand);
+
+        // get source
+        TFileName fullSourcePath;
+        switch (aCommand)
+            {
+	        case ECmdCreateFileEntryJPEG_25kB:      { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EJPEG_25kB );  break; }
+	        case ECmdCreateFileEntryJPEG_200kB:     { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EJPEG_200kB );  break; }
+	        case ECmdCreateFileEntryJPEG_500kB:     { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EJPEG_500kB );  break; }
+	        case ECmdCreateFileEntryPNG_15kB:       { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EPNG_15kB );  break; }
+	        case ECmdCreateFileEntryGIF_2kB:        { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EGIF_2kB );  break; }
+	        case ECmdCreateFileEntryRNG_1kB:        { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::ERNG_1kB );  break; }
+	        case ECmdCreateFileEntryMIDI_10kB:      { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EMIDI_10kB );  break; }
+	        case ECmdCreateFileEntryWAV_20kB:       { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EWAVE_20kB );  break; }
+	        case ECmdCreateFileEntryAMR_20kB:       { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EAMR_20kB );  break; }
+	        case ECmdCreateFileEntryXLS_15kB:       { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EExcel_15kB );  break; }
+	        case ECmdCreateFileEntryDOC_20kB:       { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EWord_20kB );  break; }
+	        case ECmdCreateFileEntryPPT_40kB:       { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EPowerPoint_40kB );  break; }
+	        case ECmdCreateFileEntryTXT_10kB:       { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EText_10kB );  break; }
+	        case ECmdCreateFileEntryTXT_70kB:       { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EText_70kB );  break; }
+	        case ECmdCreateFileEntry3GPP_70kB:      { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::E3GPP_70kB );  break; }
+	        case ECmdCreateFileEntryMP3_250kB:      { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EMP3_250kB );  break; }
+	        case ECmdCreateFileEntryAAC_100kB:      { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EAAC_100kB );  break; }
+	        case ECmdCreateFileEntryRM_95kB:        { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::ERM_95kB );  break; }
+	        case ECmdCreateFileEntryBMP_25kB:       { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EBMP_25kB );  break; }
+	        case ECmdCreateFileEntryDeck_1kB:       { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::ESavedDeck_1kB );  break; }
+	        case ECmdCreateFileEntryHTML_20kB:      { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EHTML_20kB );  break; }
+	        case ECmdCreateFileEntryJAD_1kB:        { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EJAD_1kB );  break; }
+	        case ECmdCreateFileEntryJAR_10kB:       { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EJAR_10kB );  break; }
+	        case ECmdCreateFileEntryJP2_65kB:       { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EJP2_65kB );  break; }
+	        case ECmdCreateFileEntryMP4_200kB:      { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EMP4_200kB );  break; }
+	        case ECmdCreateFileEntryMXMF_40kB:      { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EMXMF_40kB );  break; }
+	        case ECmdCreateFileEntryRAM_1kB:        { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::ERAM_1kB );  break; }
+	        case ECmdCreateFileEntrySVG_15kB:       { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::ESVG_15kB );  break; }
+	        case ECmdCreateFileEntrySWF_15kB:       { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::ESWF_15kB );  break; }
+	        case ECmdCreateFileEntryTIF_25kB:       { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::ETIF_25kB );  break; }
+	        case ECmdCreateFileEntryVCF_1kB:        { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EVCF_1kB );  break; }
+	        case ECmdCreateFileEntryVCS_1kB:        { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EVCS_1kB );  break; }
+	        case ECmdCreateFileEntrySISX_10kB:      { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::ESISX_10kB );  break; }
+	        case ECmdCreateFileEntryWMA_50kB:       { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EWMA_50kB );  break; }
+	        case ECmdCreateFileEntryWMV_200kB:      { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EWMV_200kB );  break; }
+	        case ECmdCreateFileEntryEmptyFolder:    { User::Panic(_L("EmptyFolder"), 801); break; }
+	        default:                                { return KErrPathNotFound; }
+            }
+
+
+        // define the full target path
+        TFileName fullTargetPath;
+
+        if ( parameters->iFullFilePath && parameters->iFullFilePath->Des().Length() > 3 )
+            {
+            _LIT(KSlash, "\\");
+            // check the path is ok
+            fullTargetPath = parameters->iFullFilePath->Des();
+            
+            if(fullTargetPath.Right(1) == KSlash)
+                {
+                // Remove '\' from the end, because the filename check does not work with it:
+                fullTargetPath.SetLength ( fullTargetPath.Length() - 1 );
+                }
+            
+            if (!iFs.IsValidName( fullTargetPath ))
+		        User::Leave(KErrBadName);
+
+            // target path = directory + the file name from source path
+            TParse parser;
+            parser.Set(fullSourcePath, NULL, NULL);
+            
+            // Add '\' to the end:
+            fullTargetPath.Append(KSlash);            
+            // Add filename:
+            fullTargetPath.Append( parser.NameAndExt() );
+
+            LOGSTRING2("Creator: CCreatorFiles::CreateFileEntryL iFullFilePath used, fullTargetPath: %S", &fullTargetPath);
+            }
+    
+        else if ( iDirectoryQueriedFromUser && iDirectoryQueriedFromUser->Des().Length() > 0 )
+            {
+            // target path = directory + the file name from source path
+            TParse parser;
+            parser.Set(fullSourcePath, NULL, NULL);
+
+            fullTargetPath = iDirectoryQueriedFromUser->Des();
+            fullTargetPath.Append( parser.NameAndExt() );
+
+            LOGSTRING2("Creator: CCreatorFiles::CreateFileEntryL iDirectoryQueriedFromUser used, fullTargetPath: %S", &fullTargetPath);
+            }
+
+        else
+            {   
+            LOGSTRING("Creator: CCreatorFiles::CreateFileEntryL leaving with KErrPathNotFound");
+            User::Leave(KErrPathNotFound);
+            }
+    
+        TBool encrypt = parameters->iEncrypt; 
+        if ( encrypt ) fullTargetPath.Append( KOma2DcfExtension );
+        // check the target path has a unique filename ie we won't overwrite existing files
+        // also generates any missing directories
+        if ( BaflUtils::FileExists( iFs, fullTargetPath ) )
+            {
+            GenerateFileNameL( fullTargetPath );
+            }
+        User::LeaveIfError(CApaApplication::GenerateFileName( iFs, fullTargetPath ) );
+        
+        if ( encrypt )
+            {
+            EncryptFileL( fullSourcePath, fullTargetPath, parameters );
+            }
+        else
+            {
+            // copy the file (synchronous function)
+            err = BaflUtils::CopyFile(iFs, fullSourcePath, fullTargetPath);
+            LOGSTRING4("Creator: CCreatorFiles::CreateFileEntryL copy %S to %S, err=%d", &fullSourcePath, &fullTargetPath, err);            
+            }
+        
+        if (err != KErrNone)
+            User::Leave(err);  // leave because copying failed
+
+        // Add fullTargetPath to store
+        iFilePaths->AppendL( fullTargetPath );
+        
+		// make sure that the file won't have a read only attribute
+		TEntry fileEntry;
+		iFs.Entry(fullTargetPath, fileEntry);
+		iFs.SetEntry(fullTargetPath, fileEntry.iModified, NULL, KEntryAttReadOnly);
+
+        // clear variables
+		parameters->iFullFilePath->Des().Copy ( KNullDesC );
+        }
+
+    return err;
+    }
+
+//----------------------------------------------------------------------------
+
+void CCreatorFiles::EncryptFileL( const TDesC& aInFileName, const TDesC& aOutFileName, CFilesParameters *aParameters )
+    {
+    LOGSTRING("Creator: CCreatorFiles::EncryptFileL");
+    TBuf8<64> mime;
+    SetMimeTypeL( aInFileName, mime, aParameters );
+    CSupplier* supplier = CSupplier::NewLC();
+
+    CMetaDataArray* metaData = CMetaDataArray::NewLC();
+    
+    // Tell the agent which MIME type to use for the encrypted data
+    metaData->AddL( KOmaImportMimeTypeField, mime );
+
+    if ( aParameters && aParameters->iPermission )
+        {
+        // Combined Delivery file will be created
+        SetPermissionsL( metaData, aOutFileName, aParameters );
+        }
+    
+    supplier->SetOutputDirectoryL( *iDirectoryQueriedFromUser );
+    
+    // The KOmaImportContentType is a OMA DRM agent specific MIME type which
+    // indicates that plain content is to be encrypted
+    CImportFile* importFile = supplier->ImportFileL( KOmaImportContentType,
+                                                     *metaData,
+                                                     aOutFileName );
+    CleanupStack::PushL( importFile );
+    
+    // Peek the source file size:
+    TInt fileLen( 0 );
+    RFile file;
+    User::LeaveIfError( file.Open( iFs, aInFileName, EFileRead ) );
+    CleanupClosePushL( file );
+    User::LeaveIfError( file.Size( fileLen ) );
+    CleanupStack::PopAndDestroy( &file );
+    
+    // Read the source file to inmemory buffer
+    RFileReadStream rs;    
+    User::LeaveIfError( rs.Open( iFs,
+                                 aInFileName,
+                                 EFileStream | EFileRead ) ); 
+    CleanupClosePushL( rs );
+    HBufC8* fileBuf = HBufC8::NewLC( fileLen );
+    TPtr8 p = fileBuf->Des();
+    rs.ReadL( p, fileLen );
+    
+    // Start encryption
+    TInt err = importFile->WriteData( p );
+    if ( err == KErrCANewFileHandleRequired )
+        {
+        RFile file;
+        User::LeaveIfError( file.Create( iFs, aOutFileName, EFileWrite ) );
+        CleanupClosePushL( file );
+        importFile->ContinueWithNewOutputFile( file, aOutFileName );
+        CleanupStack::PopAndDestroy( &file );
+        }
+    else
+        {
+        User::LeaveIfError( err );
+        }
+    User::LeaveIfError( importFile->WriteDataComplete() );
+    CleanupStack::PopAndDestroy( fileBuf );
+    CleanupStack::PopAndDestroy( &rs );    
+    CleanupStack::PopAndDestroy( importFile );
+    CleanupStack::PopAndDestroy( metaData );
+    CleanupStack::PopAndDestroy( supplier );
+    }
+
+//----------------------------------------------------------------------------
+
+void CCreatorFiles::SetPermissionsL( CMetaDataArray* aMetaData, const TDesC& aOutFileName, CFilesParameters *aParameters )
+    {
+    LOGSTRING("Creator: CCreatorFiles::SetPermissionsL");
+    CDRMRights* rights = CDRMRights::NewL();
+    CleanupStack::PushL( rights );
+    
+    HBufC8* cnturi = HBufC8::NewL( KMaxFileName );
+    cnturi->Des().Copy( aOutFileName );
+    
+    CDRMAsset* asset = CDRMAsset::NewLC();
+    asset->iUid = cnturi;
+    // Set the asset to the rights class, it will duplicate the asset
+    rights->SetAssetL( *asset );
+    CleanupStack::PopAndDestroy( asset );
+    
+    rights->SetPermissionL( *aParameters->iPermission );
+    
+    // Construct externalized presentation of the rights object
+    TInt rightsSize = 1024 *100;
+    HBufC8* rightBuf = HBufC8::NewLC( rightsSize ); 
+    TPtr8 bptr = rightBuf->Des();
+    bptr.SetLength( rightsSize );
+    RMemWriteStream iWriteStream;
+    iWriteStream.Open( (TAny*)(rightBuf->Ptr() ), rightsSize );
+    CleanupClosePushL( iWriteStream );
+    iWriteStream << *rights;
+    iWriteStream.CommitL();
+    TPtr8 rp = rightBuf->Des();
+    
+    // Add rights to metadata
+    aMetaData->AddL( KOmaImportRightsField, rp );
+    CleanupStack::PopAndDestroy( &iWriteStream );
+    CleanupStack::PopAndDestroy( rightBuf );
+    CleanupStack::PopAndDestroy( rights );
+    }
+
+//----------------------------------------------------------------------------
+
+void CCreatorFiles::SetMimeTypeL( const TDesC& aFileName, TDes8& aMime, CFilesParameters *aParameters )
+    {
+    LOGSTRING("Creator: CCreatorFiles::SetMimeTypeL");
+    TUid appUid;
+    TDataType dataType;
+    User::LeaveIfError( iApaLs.AppForDocument( aFileName, appUid, dataType ) );
+    if ( dataType.Des().Length() )
+        {
+        aMime.Copy( dataType.Des() );    
+        }
+    else
+        {
+        // set default mime, because it was not recognized by iApaLs
+        aMime.Copy( _L("text/plain") );
+        }
+
+    // set DRM permissions according the type of the file
+    if ( aParameters->iPermission )
+        {
+        if ( dataType.Des().FindF( _L("image") ) > KErrNotFound )
+            {
+            aParameters->iPermission->iAvailableRights = ERightsDisplay | ERightsPrint;
+            }
+        else if ( dataType.Des().FindF( _L("audio") ) > KErrNotFound ||
+                  dataType.Des().FindF( _L("video") ) > KErrNotFound ||
+                  dataType.Des().FindF( _L("tone") ) > KErrNotFound || // e.g. application/vnd.nokia.ringing-tone
+                  dataType.Des().FindF( _L("realmedia") ) > KErrNotFound )
+            {
+            // media files
+            aParameters->iPermission->iAvailableRights = ERightsPlay;
+            }
+        else if ( dataType.Des().FindF( _L("archive") ) > KErrNotFound ||
+                  dataType.Des().FindF( _L("x-sis") ) > KErrNotFound )
+            {
+            // application/java-archive
+            // x-epoc/x-sisx-app
+            aParameters->iPermission->iAvailableRights = ERightsExecute;
+            }
+        else if ( dataType.Des().FindF( _L("application") ) > KErrNotFound ||
+                  dataType.Des().FindF( _L("text") ) > KErrNotFound )
+            {
+            // application/msexcel
+            // application/msword
+            // text/plain
+            // etc.
+            aParameters->iPermission->iAvailableRights = ERightsDisplay | ERightsPrint;
+            }
+        else
+            {
+            // other filetype
+            aParameters->iPermission->iAvailableRights = ERightsDisplay;
+            }
+        }
+    }
+
+//----------------------------------------------------------------------------
+
+TBool CCreatorFiles::AskDRMDataFromUserL()
+    {
+    LOGSTRING("Creator: CCreatorFiles::AskDRMDataFromUserL");
+    // Encryption -dialog
+    TInt encIndex( 0 );
+    CAknListQueryDialog* encDlg = new (ELeave) CAknListQueryDialog( &encIndex );
+    encDlg->PrepareLC( R_ENCRYPTION_DIALOG );
+    //Create flat array from which list is built.
+    CDesCArrayFlat* items = new(ELeave) CDesCArrayFlat(5);
+    CleanupStack::PushL(items);
+
+    // Add entires to list
+    items->AppendL( _L("None") );
+    items->AppendL( _L("DRM Forward Lock") );
+    items->AppendL( _L("DRM Combined Delivery") );
+
+    // Add items into main list
+    encDlg->SetOwnershipType( ELbmOwnsItemArray );
+    encDlg->SetItemTextArray( items );
+    CleanupStack::Pop( items );
+    encDlg->ListBox()->SetCurrentItemIndexAndDraw( 0 );
+   
+    if ( encDlg->RunLD() )
+        {
+        if ( encIndex > 0 )
+            {
+            iUserParameters->iEncrypt = ETrue;
+            }
+        if ( encIndex == 2 )
+            {
+            iUserParameters->iPermission = CDRMPermission::NewL();
+            CDRMPermission* perm = iUserParameters->iPermission; 
+            perm->iTopLevel->iActiveConstraints = EConstraintNone;
+            perm->iPlay->iActiveConstraints = EConstraintNone;
+            perm->iDisplay->iActiveConstraints = EConstraintNone;
+            perm->iPrint->iActiveConstraints = EConstraintNone;
+            perm->iExecute->iActiveConstraints = EConstraintNone;
+            perm->iUniqueID = 0;
+            // DRM Combined Delivery
+            return AskDRMCDDataFromUserL();
+            }
+        return ETrue;
+        }
+    else
+        {
+        return EFalse;
+        }
+    }
+
+//----------------------------------------------------------------------------
+
+TBool CCreatorFiles::AskDRMCDDataFromUserL()
+    {
+    LOGSTRING("Creator: CCreatorFiles::AskDRMCDDataFromUserL");
+    TInt count( 0 );
+    if ( iEngine->EntriesQueryDialogL( count, _L("How many counts\r\n(0=unlimited)?"), ETrue ) )
+        {
+        if ( count > 0 )
+            {
+            CDRMPermission* perm = iUserParameters->iPermission;
+            // apply constraints to all permission types
+            // applied type will be selected by setting iAvailableRights
+            // when determining the file type
+            perm->iDisplay->iActiveConstraints |= EConstraintCounter;
+            perm->iDisplay->iCounter = count;
+            perm->iDisplay->iOriginalCounter = count;
+
+            perm->iPlay->iActiveConstraints |= EConstraintCounter;
+            perm->iPlay->iCounter = count;
+            perm->iPlay->iOriginalCounter = count;
+
+            perm->iPrint->iActiveConstraints |= EConstraintCounter;
+            perm->iPrint->iCounter = count;
+            perm->iPrint->iOriginalCounter = count;
+            
+            perm->iExecute->iActiveConstraints |= EConstraintCounter;
+            perm->iExecute->iCounter = count;
+            perm->iExecute->iOriginalCounter = count;
+            }
+        }
+    else
+        {
+        return EFalse;
+        }
+    /*
+    TInt seconds( 0 );
+    if ( iEngine->EntriesQueryDialogL( seconds, _L("How many accumulated seconds until expire (0=unlimited)?"), ETrue ) )
+        {
+        if ( seconds > 0 )
+            {
+            CDRMPermission* perm = iUserParameters->iPermission;            
+            // apply constraints to all permission types
+            // applied type will be selected by setting iAvailableRights
+            // when determining the file type            
+            perm->iDisplay->iActiveConstraints |= EConstraintAccumulated;
+            perm->iDisplay->iEndTime = Time::MaxTTime();
+            perm->iDisplay->iStartTime = Time::MinTTime();;
+            perm->iDisplay->iAccumulatedTime = seconds;
+            
+            perm->iPlay->iActiveConstraints |= EConstraintAccumulated;
+            perm->iPlay->iEndTime = Time::MaxTTime();
+            perm->iPlay->iStartTime = Time::MinTTime();;
+            perm->iPlay->iAccumulatedTime = seconds;
+
+            perm->iPrint->iActiveConstraints |= EConstraintAccumulated;
+            perm->iPrint->iEndTime = Time::MaxTTime();
+            perm->iPrint->iStartTime = Time::MinTTime();;
+            perm->iPrint->iAccumulatedTime = seconds;
+
+            perm->iExecute->iActiveConstraints |= EConstraintAccumulated;
+            perm->iExecute->iEndTime = Time::MaxTTime();
+            perm->iExecute->iStartTime = Time::MinTTime();;
+            perm->iExecute->iAccumulatedTime = seconds;
+            }
+        }
+    else
+        {
+        return EFalse;
+        }
+    */
+    
+    TInt minutes( 0 );
+    if ( iEngine->EntriesQueryDialogL( minutes, _L("How many minutes until expire (0=unlimited)?"), ETrue ) )
+        {
+        if ( minutes > 0 )
+            {
+            CDRMPermission* perm = iUserParameters->iPermission;            
+            // apply constraints to all permission types
+            // applied type will be selected by setting iAvailableRights
+            // when determining the file type            
+            perm->iDisplay->iActiveConstraints |= EConstraintInterval;
+            perm->iDisplay->iInterval = TTimeIntervalSeconds( 60 * minutes );
+            perm->iDisplay->iIntervalStart = Time::NullTTime();
+            
+            perm->iPlay->iActiveConstraints |= EConstraintInterval;
+            perm->iPlay->iInterval = TTimeIntervalSeconds( 60 * minutes );
+            perm->iPlay->iIntervalStart = Time::NullTTime();
+
+            perm->iPrint->iActiveConstraints |= EConstraintInterval;
+            perm->iPrint->iInterval = TTimeIntervalSeconds( 60 * minutes );
+            perm->iPrint->iIntervalStart = Time::NullTTime();
+
+            perm->iExecute->iActiveConstraints |= EConstraintInterval;
+            perm->iExecute->iInterval = TTimeIntervalSeconds( 60 * minutes );
+            perm->iExecute->iIntervalStart = Time::NullTTime();
+            }
+        }
+    else
+        {
+        return EFalse;
+        }
+    
+    return ETrue;
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorFiles::DeleteAllL()
+    {
+    LOGSTRING("Creator: CCreatorFiles::DeleteAllL");
+    User::Leave( KErrNotSupported ); // will not be supported
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorFiles::DeleteAllCreatedByCreatorL()
+    {
+    LOGSTRING("Creator: CCreatorFiles::DeleteAllCreatedByCreatorL");
+    iFileId = 1;
+    CDictionaryFileStore* store = iEngine->FileStoreLC();
+    User::LeaveIfNull( store );
+        
+    if ( store->IsPresentL( KUidDictionaryUidFiles ) )
+        {
+        RDictionaryReadStream in;
+        in.OpenLC( *store, KUidDictionaryUidFiles );
+        CFileMan* fileMan = CFileMan::NewL( iFs );
+        CleanupStack::PushL( fileMan );
+        TFileName fullPath;
+        // ignore return value, don't update iFileId here:
+        TRAPD( err, in.ReadInt32L() );
+        while ( !err )
+            {
+            TInt len( KErrNotFound );
+            TRAP( err, len = in.ReadInt8L() );  // will leave with KErrEof
+            if ( !err )
+                {
+                TRAP( err, in.ReadL( fullPath, len ) );                    
+                }
+            if ( !err )
+                {
+                TEntry fileEntry;
+                iFs.Entry( fullPath, fileEntry );
+                if ( fileEntry.IsDir() )
+                    {
+                    fileMan->RmDir( fullPath ); // ignore return value
+                    }
+                else
+                    {
+                    iFs.Delete( fullPath ); // ignore return value    
+                    }                    
+                }
+            }
+        CleanupStack::PopAndDestroy( fileMan );
+        CleanupStack::PopAndDestroy( &in );
+        
+        // files deleted, remove the Creator internal file registry
+        store->Remove( KUidDictionaryUidFiles );
+        store->CommitL();
+        }
+    CleanupStack::PopAndDestroy( store );
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorFiles::StorePathsForDeleteL( CDesCArray& aPaths )
+    {
+    LOGSTRING("Creator: CCreatorFiles::StorePathsForDeleteL");
+    CDictionaryFileStore* store = iEngine->FileStoreLC();
+    User::LeaveIfNull( store );
+    
+    // backup previous filepaths from store
+    // otherwise they would be overwritten when calling out.WriteL
+    CDesCArray* previousPaths = new (ELeave) CDesCArrayFlat( 4 );
+    CleanupStack::PushL( previousPaths );
+    
+    TFileName fullPath;
+    
+    if ( store->IsPresentL( KUidDictionaryUidFiles ) )
+        {
+        RDictionaryReadStream in;
+        in.OpenLC( *store, KUidDictionaryUidFiles );
+        // ignore return value, don't update iFileId here:
+        TRAPD( err, in.ReadInt32L() );
+        while ( !err ) 
+            {
+            TRAP( err,
+                TInt len = in.ReadInt8L(); // will leave with KErrEof
+                in.ReadL( fullPath, len );
+                previousPaths->AppendL( fullPath );
+                );
+            }
+        CleanupStack::PopAndDestroy(); // in
+        }
+    
+    RDictionaryWriteStream out;       
+    out.AssignLC( *store, KUidDictionaryUidFiles );
+    
+    // write latest file id to store
+    out.WriteInt32L( iFileId );
+    
+    // restore previous paths to store
+    for ( TInt i = 0; i < previousPaths->Count(); i++ )
+        {
+        out.WriteInt8L( (*previousPaths)[i].Length() );
+        out.WriteL( (*previousPaths)[i] );            
+        }
+
+    // write new paths to store
+    for ( TInt i = 0; i < aPaths.Count(); i++ )
+        {
+        out.WriteInt8L( aPaths[i].Length() );
+        out.WriteL( aPaths[i] );            
+        }
+    
+    out.CommitL();
+    CleanupStack::PopAndDestroy(); // out
+    
+    store->CommitL();
+    CleanupStack::PopAndDestroy( previousPaths );
+    CleanupStack::PopAndDestroy( store );
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorFiles::GenerateFileNameL( TFileName& aRootName )
+    {
+    LOGSTRING("Creator: CCreatorFiles::GenerateFileNameL");
+    if ( iFileId )
+        {
+        TBuf<16> extension;
+        if ( iFileId < 10 )
+            {
+            extension.Format( _L("(0%d)"), iFileId );     
+            }
+        else
+            {
+            extension.Format( _L("(%d)"), iFileId );
+            }
+        aRootName.Insert( aRootName.Locate( '.' ), extension );
+        }
+    iFileId++;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_fileelement.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,315 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include "creator_fileelement.h"
+#include <DrmPermission.h>
+#include <DrmConstraint.h>
+#include "creator_traces.h"
+#include "creator_file.h"
+
+using namespace creatorfile;
+
+// 15 minutes per time zone, 60 seconds per minute
+const TInt KSecondsPerTimeZone = 900;
+const TInt KMinuteInMicroseconds = 60000000;
+const TInt KTimeZoneIncrement = 15;
+
+/*
+ * 
+ */
+CCreatorFileElement* CCreatorFileElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext )
+    {
+    CCreatorFileElement* self = new (ELeave) CCreatorFileElement(aEngine);
+    CleanupStack::PushL(self);
+    self->ConstructL(aName, aContext);
+    CleanupStack::Pop(self);
+    return self;
+    }
+/*
+ * 
+ */
+CCreatorFileElement::CCreatorFileElement(CCreatorEngine* aEngine) 
+: 
+CCreatorScriptElement(aEngine)
+    {
+    iIsCommandElement = ETrue;
+
+    TTime currUniversal;
+    TTime currLocal;
+    TInt64 result( 0 );
+    currUniversal.UniversalTime();
+    currLocal.HomeTime();
+    result = currLocal.Int64() - currUniversal.Int64();
+    result /= KMinuteInMicroseconds;
+    result /= KTimeZoneIncrement;
+    iTimeZone = I64INT( result );
+    }
+/*
+ * 
+ */
+void CCreatorFileElement::ExecuteCommandL()
+    {
+    const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount);
+    TInt fileAmount = 1;    
+    if( amountAttr )
+        {
+        fileAmount = ConvertStrToIntL(amountAttr->Value());
+        }
+    // Get 'fields' element 
+    CCreatorScriptElement* fieldsElement = FindSubElement(KFields);
+    if( fieldsElement && fieldsElement->SubElements().Count() > 0)
+        {
+        // Get sub-elements
+        const RPointerArray<CCreatorScriptElement>& fields = fieldsElement->SubElements();
+        // Create files, the amount of files is defined by fileAmount:
+        for( TInt cI = 0; cI < fileAmount; ++cI )
+            {
+            CFilesParameters* param = new (ELeave) CFilesParameters;
+            CleanupStack::PushL( param );
+            
+            for( TInt i = 0; i < fields.Count(); ++i )
+                {
+                CCreatorScriptElement* field = fields[i];
+                TPtrC elemName = field->Name();
+                TPtrC elemContent = field->Content();
+
+                const CCreatorScriptAttribute* randomAttr = field->FindAttributeByName( KRandomLength );
+                
+                if( elemName == KType )
+                    {
+                    param->iFileCommand = GetFileCommandL(elemContent, randomAttr || elemContent.Length() == 0);
+                    }
+                else if( elemName == KDirectory )
+                    {
+                    delete param->iFullFilePath;
+                    param->iFullFilePath = 0;
+                    if( randomAttr == 0 && elemContent.Length() > 0 )
+                    	{
+                    	param->iFullFilePath = elemContent.AllocL();
+                    	}
+                    else
+                        {
+                        TFileName defaultPath;
+                        iEngine->SetDefaultPathForFileCommandL( param->iFileCommand, defaultPath );
+                        param->iFullFilePath = defaultPath.AllocL();
+                        }
+                    }
+                else if ( elemName == KEncryption )
+                    {
+                    ParseDRMElementsL( field, param );
+                    }
+                }
+
+            if ( !param->iFileCommand )
+                {
+                param->iFileCommand = ECmdCreateFileEntryEmptyFolder;
+                }
+            iEngine->AppendToCommandArrayL( param->iFileCommand, param);
+            CleanupStack::Pop( param );
+            }
+        }
+    else
+    	{
+    	_LIT(KDummy, "");
+    	for( TInt cI = 0; cI < fileAmount; ++cI )
+    		{
+    		CFilesParameters* param = new (ELeave) CFilesParameters;
+    		CleanupStack::PushL(param);
+    		delete param->iFullFilePath;
+    		param->iFullFilePath = 0;
+    		TFileName defaultPath;
+    		param->iFileCommand = GetFileCommandL(KDummy, ETrue);
+    		iEngine->SetDefaultPathForFileCommandL(param->iFileCommand, defaultPath);                
+    		param->iFullFilePath = defaultPath.AllocL();
+    		
+    		iEngine->AppendToCommandArrayL(param->iFileCommand, param);
+    		CleanupStack::Pop(param);
+    		}
+    	}
+    }
+
+TInt CCreatorFileElement::GetFileCommandL( const TDesC& aFileIdStr, TBool aRandom ) const
+    {
+    TInt mapCount = sizeof(FileMap) / sizeof(FileMapping);
+    
+    if( aRandom )
+        {
+        return FileMap[iEngine->RandomNumber(0, mapCount-1)].CommandId();
+        }
+    
+    for( TInt i = 0; i < mapCount; ++i )
+        {
+        if( CompareIgnoreCase(FileMap[i].FileName(), aFileIdStr) == 0 )
+            return FileMap[i].CommandId();
+        }
+    LOGSTRING2("CCreatorFileElement::GetFileCommandL: Unknown file id: %S", &aFileIdStr);
+    User::Leave(KErrGeneral);
+    return 0; // Not reached, but disables compiler warning...
+    }
+
+void CCreatorFileElement::ParseDRMElementsL( CCreatorScriptElement* aField, CFilesParameters* aParam )
+    {
+    const CCreatorScriptAttribute* encryptionTypeAttr = aField->FindAttributeByName( KType );
+    if ( encryptionTypeAttr && encryptionTypeAttr->Value().Length() > 0 )
+        {
+        aParam->iEncrypt = ETrue;
+        if ( encryptionTypeAttr->Value() == KDRMCD ) 
+            {
+            delete aParam->iPermission;
+            aParam->iPermission = NULL;
+            // ownership transferred:
+            aParam->iPermission = CDRMPermission::NewL();
+            }
+        else if ( encryptionTypeAttr->Value() != KDRMFL )
+            {
+            // must be either KDRMCD or KDRMFL
+            User::Leave( KErrArgument );
+            }
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+    
+    const RPointerArray<CCreatorScriptElement>& rights = aField->SubElements();
+    
+    if ( encryptionTypeAttr->Value() == KDRMFL && rights.Count() )
+        {
+        // Right definitions not allowed with DRM Forward Lock
+        // User::Leave( KErrArgument ); // Do not leave here
+        return; // Just omit rights definitions
+        }
+    
+    // parse right elements
+    CDRMPermission* drmPermission = aParam->iPermission;
+    for ( TInt r = 0; r < rights.Count(); r++ )
+        {
+        const CCreatorScriptAttribute* rightAttr = rights[r]->FindAttributeByName( KType );
+        if ( rightAttr->Value() == KDRMPlayRight &&
+             !( drmPermission->iAvailableRights & ERightsPlay ) )
+            {
+            drmPermission->iAvailableRights |= ERightsPlay;
+            ParseDRMConstraintsL( rights[r], drmPermission->iPlay );
+            }
+        else if ( rightAttr->Value() == KDRMDisplayRight  &&
+                !( drmPermission->iAvailableRights & ERightsDisplay ))
+            {
+            drmPermission->iAvailableRights |= ERightsDisplay;
+            ParseDRMConstraintsL( rights[r], drmPermission->iDisplay );
+            }
+        else if ( rightAttr->Value() == KDRMPrintRight  &&
+                !( drmPermission->iAvailableRights & ERightsPrint ) )
+            {
+            drmPermission->iAvailableRights |= ERightsPrint;
+            ParseDRMConstraintsL( rights[r], drmPermission->iPrint );
+            }
+        else if ( rightAttr->Value() == KDRMExecuteRight  &&
+                !( drmPermission->iAvailableRights & ERightsExecute ) )
+            {
+            drmPermission->iAvailableRights |= ERightsExecute;
+            ParseDRMConstraintsL( rights[r], drmPermission->iExecute );
+            }
+        }
+    }
+
+void CCreatorFileElement::ParseDRMConstraintsL( CCreatorScriptElement* aRight, CDRMConstraint* aConstraint )
+    {
+    const RPointerArray<CCreatorScriptElement>& constraints = aRight->SubElements();
+    for ( TInt c = 0; c < constraints.Count(); c++ )
+        {
+        TPtrC elemName = constraints[c]->Name();
+        TPtrC elemContent = constraints[c]->Content();
+        if ( elemName == KDRMCount )
+            {
+            TInt count = ConvertStrToIntL( elemContent );
+            // apply count constraint
+            aConstraint->iActiveConstraints |= EConstraintCounter;
+            aConstraint->iCounter = count;
+            aConstraint->iOriginalCounter = count;
+            }
+        else if ( elemName == KDRMInterval )
+            {
+            // apply interval constraint           
+            aConstraint->iActiveConstraints |= EConstraintInterval;
+            aConstraint->iInterval = ParseTimeInterval( elemContent );
+            aConstraint->iIntervalStart = Time::NullTTime();
+            }
+        else if ( elemName == KDRMStartTime )
+            {
+            // apply start time constraint           
+            aConstraint->iActiveConstraints |= EConstraintStartTime;
+            TTimeIntervalSeconds offset( iTimeZone * KSecondsPerTimeZone );
+            aConstraint->iStartTime = ConvertToDateTimeL( elemContent ) - offset;
+            }
+        else if ( elemName == KDRMEndTime )
+            {
+            // apply end time constraint
+            aConstraint->iActiveConstraints |= EConstraintEndTime;
+            TTimeIntervalSeconds offset( iTimeZone * KSecondsPerTimeZone );
+            aConstraint->iEndTime = ConvertToDateTimeL( elemContent ) - offset;
+            }
+        else if ( elemName == KDRMAccumulated )
+            {
+            // apply accumulated time constraint
+            aConstraint->iActiveConstraints |= EConstraintAccumulated;
+            if ( aConstraint->iEndTime == Time::NullTTime() )
+                {
+                aConstraint->iEndTime = Time::MaxTTime();
+                }
+            if ( aConstraint->iStartTime == Time::NullTTime() )
+                {
+                aConstraint->iStartTime = Time::MinTTime();
+                }
+            aConstraint->iAccumulatedTime = ParseTimeInterval( elemContent );
+            }
+        }
+    }
+
+TTimeIntervalSeconds CCreatorFileElement::ParseTimeInterval( TDesC& aTimeString )
+    {
+    // Iso8601 format (P1Y2M3DT4H5M6S) to TimeIntervalSeconds
+    TLex lex;
+    TInt year = 0;
+    TInt month = 0;
+    TInt day = 0;
+    TInt hour = 0;
+    TInt minute = 0;
+    TInt second = 0;
+
+    if (aTimeString.Length() > 0)
+        {    
+        lex = aTimeString;
+        lex.Inc(); // skip 'P'
+        lex.Val(year);
+        lex.Inc();
+        lex.Val(month);
+        lex.Inc();
+        lex.Val(day);
+        lex.Inc(2);
+        lex.Val(hour);
+        lex.Inc();
+        lex.Val(minute);
+        lex.Inc();
+        lex.Val(second);
+        }
+    TTimeIntervalSeconds result( ( ( ( year * 365 + month * 30 + day ) * 24 + hour )
+                * 60 + minute ) * 60 + second );
+    return result;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_imps.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,260 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifdef __PRESENCE
+
+#include "creator_imps.h" 
+#include "creator_traces.h"
+
+#include <cimpssapsettingslist.h>
+
+static const TInt KIMPSFieldLength = 128;
+
+_LIT(KCreatorIMPSPrefixName, "CR_");
+
+
+//----------------------------------------------------------------------------
+
+CIMPSParameters::CIMPSParameters()
+    {
+    LOGSTRING("Creator: CIMPSParameters::CIMPSParameters");
+
+    iServerName = HBufC::New(KIMPSFieldLength);
+    iServerURL = HBufC::New(KIMPSFieldLength);
+    iServerUsername = HBufC::New(KIMPSFieldLength);
+    iServerPassword = HBufC::New(KIMPSFieldLength);
+    iServerAccessPointName = HBufC::New(KIMPSFieldLength);
+    // User needs to set connectionmethod manually to be able to use the IMPS setting
+    iServerAccessPointName->Des().Copy(_L("DEFAULT-IAP"));
+    }
+
+CIMPSParameters::~CIMPSParameters()
+    {
+    LOGSTRING("Creator: CIMPSParameters::~CIMPSParameters");
+
+    delete iServerAccessPointName;
+    delete iServerPassword;
+    delete iServerUsername;
+    delete iServerURL;
+    delete iServerName;
+    }
+
+void CIMPSParameters::SetRandomNameL(CCreatorEngine& aEngine)
+    {
+    if(iServerName == 0)
+        {
+        iServerName = HBufC::New(KIMPSFieldLength);
+        }
+    TBuf<160> company = aEngine.RandomString(CCreatorEngine::ECompany);
+    iServerName->Des() = KCreatorIMPSPrefixName;
+    iServerName->Des().Append( company );
+    iServerName->Des().Append( _L(" #") );
+    iServerName->Des().AppendNum( aEngine.RandomNumber(1000, 9999) );    
+    }
+
+void CIMPSParameters::SetRandomUrlL(CCreatorEngine& aEngine)
+    {
+    if(iServerURL == 0)
+        {
+        iServerURL = HBufC::New(KIMPSFieldLength);
+        }
+    TBuf<160> company = aEngine.RandomString(CCreatorEngine::ECompany);
+    iServerURL->Des() = _L("http://imps.");
+    iServerURL->Des().Append( company );
+    iServerURL->Des().Append( _L(".com:18080/CSP/csp") );
+    }
+
+void CIMPSParameters::SetRandomUsernameL(CCreatorEngine& aEngine)
+    {
+    iServerUsername->Des() = aEngine.RandomString(CCreatorEngine::EFirstName);
+    iServerUsername->Des().LowerCase();
+    }
+
+void CIMPSParameters::SetRandomPasswordL(CCreatorEngine& aEngine)
+    {
+    iServerPassword->Des() = aEngine.RandomString(CCreatorEngine::ESurname);
+    iServerPassword->Des().LowerCase();
+    }
+void CIMPSParameters::SetDefaultAccessPointL()
+    {
+    iServerAccessPointName->Des().Copy(_L("DEFAULT-IAP"));
+    }
+//----------------------------------------------------------------------------
+
+CCreatorIMPS* CCreatorIMPS::NewL(CCreatorEngine* aEngine)
+    {
+    CCreatorIMPS* self = CCreatorIMPS::NewLC(aEngine);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CCreatorIMPS* CCreatorIMPS::NewLC(CCreatorEngine* aEngine)
+    {
+    CCreatorIMPS* self = new (ELeave) CCreatorIMPS;
+    CleanupStack::PushL(self);
+    self->ConstructL(aEngine);
+    return self;
+    }
+
+CCreatorIMPS::CCreatorIMPS()
+    {
+    }
+
+void CCreatorIMPS::ConstructL(CCreatorEngine* aEngine)
+    {
+    LOGSTRING("Creator: CCreatorIMPS::ConstructL");
+
+    iEngine = aEngine;
+
+    iIMPSSAPSettingsStore = CIMPSSAPSettingsStore::NewL();    
+    }
+
+CCreatorIMPS::~CCreatorIMPS()
+    {
+    LOGSTRING("Creator: CCreatorIMPS::~CCreatorIMPS");
+
+    if ( iEngine && iEntryIds.Count() )
+        {
+        TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iEntryIds, KUidDictionaryUidIMPS ) );
+        }
+    iEntryIds.Reset();
+    iEntryIds.Close();
+    
+    delete iIMPSSAPSettingsStore;
+    
+    if (iParameters)
+        delete iParameters;
+    }
+
+//----------------------------------------------------------------------------
+
+TBool CCreatorIMPS::AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries)
+    {
+    LOGSTRING("Creator: CCreatorIMPS::AskDataFromUserL");
+    if ( aCommand == ECmdDeleteIMPSs )
+        {
+        return iEngine->YesNoQueryDialogL( _L("Delete all IMPS server entries?") );
+        }
+    else if ( aCommand ==  ECmdDeleteCreatorIMPSs )
+        {
+        return iEngine->YesNoQueryDialogL( _L("Delete all IMPS server entries created with Creator?") );
+        }
+    return iEngine->EntriesQueryDialogL(aNumberOfEntries, _L("How many entries to create?"));
+    }
+
+
+//----------------------------------------------------------------------------
+
+TInt CCreatorIMPS::CreateIMPSServerEntryL(CIMPSParameters *aParameters)
+    {
+    LOGSTRING("Creator: CCreatorIMPS::CreateIMPSServerEntryL");
+
+    // clear any existing parameter definations
+    delete iParameters;
+    iParameters = NULL;
+    
+    CIMPSParameters* parameters = aParameters;
+    
+    // random data needed if no predefined data available
+    if (!parameters)
+        {
+        iParameters = new(ELeave) CIMPSParameters;
+        parameters = iParameters;                
+        parameters->SetRandomNameL(*iEngine);
+        parameters->SetRandomUrlL(*iEngine);
+        parameters->SetRandomUsernameL(*iEngine);
+        parameters->SetRandomPasswordL(*iEngine);
+        parameters->SetDefaultAccessPointL();
+        }
+
+    TInt err = KErrNone;
+
+    // set data to save item
+    CIMPSSAPSettings* settings = CIMPSSAPSettings::NewLC();
+    TUint32 iapId = iEngine->AccessPointNameToIdL(parameters->iServerAccessPointName->Des(), ETrue );
+    err = settings->SetAccessPoint( iapId );
+    if( err != KErrNone )
+    	{
+    	LOGSTRING("Creator: CCreatorIMPS::CreateIMPSServerEntryL - Unable to resolve access point.");
+    	err = KErrNone;
+    	}
+    settings->SetSAPNameL( parameters->iServerName->Des() );
+    settings->SetSAPAddressL( parameters->iServerURL->Des() );
+    settings->SetSAPUserIdL( parameters->iServerUsername->Des() );
+    settings->SetSAPUserPasswordL( parameters->iServerPassword->Des() );
+    
+    // save the item
+    TRAP(err, iIMPSSAPSettingsStore->StoreNewSAPL( settings, EIMPSIMAccessGroup ));
+    
+    // id has been generated, store it for being able to delete
+    // only entries created with Creator
+    iEntryIds.Append( settings->Uid() );
+    
+    TRAP(err, iIMPSSAPSettingsStore->StoreNewSAPL( settings, EIMPSPECAccessGroup ));
+
+    // id has been generated, store it for being able to delete
+    // only entries created with Creator
+    iEntryIds.Append( settings->Uid() );
+    
+    CleanupStack::PopAndDestroy(); //settings
+    return err;
+    }
+
+
+//----------------------------------------------------------------------------
+void CCreatorIMPS::DeleteAllL()
+    {
+    LOGSTRING("Creator: CCreatorIMPS::DeleteAllL");
+    CIMPSSAPSettingsList* imps = CIMPSSAPSettingsList::NewLC();
+    iIMPSSAPSettingsStore->PopulateSAPSettingsListL( *imps, EIMPSAccessFilterAll );
+    for ( TInt i = 0; i < imps->Count(); i++ )
+        {
+        iIMPSSAPSettingsStore->DeleteSAPL( imps->UidForIndex( i ) ); 
+        }
+    CleanupStack::PopAndDestroy( imps );
+    
+    // reset must be done here, because iEntryIds is stored in destructor
+    iEntryIds.Reset();
+    
+    // all entries deleted, remove the IMPS related registry
+    iEngine->RemoveStoreL( KUidDictionaryUidIMPS );
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorIMPS::DeleteAllCreatedByCreatorL()
+    {
+    LOGSTRING("Creator: CCreatorIMPS::DeleteAllCreatedByCreatorL");
+    iEntryIds.Reset();
+    
+    // fetch ids of entries created by Creator
+    iEngine->ReadEntryIdsFromStoreL( iEntryIds, KUidDictionaryUidIMPS );
+    
+    // delete entries
+    for ( TInt i = 0; i < iEntryIds.Count(); i++ )
+        {
+        TRAP_IGNORE( iIMPSSAPSettingsStore->DeleteSAPL( iEntryIds[i] ) ); 
+        }
+    // reset must be done here, because iEntryIds is stored in destructor
+    iEntryIds.Reset();
+    
+    // all entries deleted, remove the IMPS related registry
+    iEngine->RemoveStoreL( KUidDictionaryUidIMPS );
+    }
+
+#endif //__PRESENCE
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_impselement.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,146 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifdef __PRESENCE
+
+#include "creator_impselement.h"
+#include "creator_traces.h"
+#include "creator_imps.h"
+
+using namespace creatorimps;
+
+/*
+ * 
+ */
+CCreatorImpsServerElement* CCreatorImpsServerElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext )
+    {
+    CCreatorImpsServerElement* self = new (ELeave) CCreatorImpsServerElement(aEngine);
+    CleanupStack::PushL(self);
+    self->ConstructL(aName, aContext);
+    CleanupStack::Pop(self);
+    return self;
+    }
+/*
+ * 
+ */
+CCreatorImpsServerElement::CCreatorImpsServerElement(CCreatorEngine* aEngine) 
+: 
+CCreatorScriptElement(aEngine)
+    {
+    iIsCommandElement = ETrue;
+    }
+
+void CCreatorImpsServerElement::ExecuteCommandL()
+    {
+    const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount);
+    TInt entryAmount = 1;    
+    if( amountAttr )
+        {
+        entryAmount = ConvertStrToIntL(amountAttr->Value());
+        }
+    // Get 'fields' element 
+    CCreatorScriptElement* fieldsElement = FindSubElement(KFields);
+    if( fieldsElement && fieldsElement->SubElements().Count() > 0 )
+        {
+        // Get sub-elements
+        const RPointerArray<CCreatorScriptElement>& fields = fieldsElement->SubElements();        
+        // Create note entries, the amount of entries is defined by entryAmount:
+        for( TInt cI = 0; cI < entryAmount; ++cI )
+            {            
+            CIMPSParameters* param = new (ELeave) CIMPSParameters;
+            CleanupStack::PushL(param);
+            
+            for( TInt i = 0; i < fields.Count(); ++i )
+                {
+                CCreatorScriptElement* field = fields[i];
+                TPtrC elemName = field->Name();
+                TPtrC elemContent = field->Content();
+                const CCreatorScriptAttribute* randomAttr = fields[i]->FindAttributeByName(KRandomLength);
+                TBool useRandom = EFalse;
+                if( randomAttr || elemContent.Length() == 0 )
+                    {
+                    useRandom = ETrue;
+                    }
+                
+                if( elemName == KName )
+                    {
+                    if( useRandom )
+                        {
+                        param->SetRandomNameL(*iEngine);
+                        }
+                    else
+                        {
+                        SetContentToTextParamL(param->iServerName, elemContent);
+                        }                    
+                    }
+                if( elemName == KUrl )
+                    {
+                    if( useRandom )
+                        {
+                        param->SetRandomUrlL(*iEngine);
+                        }
+                    else
+                        {
+                        SetContentToTextParamL(param->iServerURL, elemContent);
+                        }
+                    }
+                if( elemName == KUsername )
+                    {
+                    if( useRandom )
+                        {
+                        param->SetRandomUsernameL(*iEngine);
+                        }
+                    else
+                        {
+                        SetContentToTextParamL(param->iServerUsername, elemContent);
+                        }
+                    }
+                if( elemName == KPassword )
+                    {
+                    if( useRandom )
+                        {
+                        param->SetRandomPasswordL(*iEngine);
+                        }
+                    else
+                        {
+                        SetContentToTextParamL(param->iServerPassword, elemContent);
+                        }
+                    }
+                if( elemName == KConnectionMethodName )
+                    {
+                    if( useRandom || CompareIgnoreCase(elemContent, creatorimps::KDefault) == 0 )
+                        {
+                        param->SetDefaultAccessPointL();
+                        }
+                    else
+                        {
+                        SetContentToTextParamL(param->iServerAccessPointName, elemContent);
+                        }
+                    }
+                }
+            iEngine->AppendToCommandArrayL(ECmdCreateMiscEntryIMPSServers, param);
+            CleanupStack::Pop(); // param
+            }
+        }
+    else
+    	{
+    	iEngine->AppendToCommandArrayL(ECmdCreateMiscEntryIMPSServers, 0, entryAmount);
+    	}
+    }
+
+#endif // __PRESENCE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_landmark.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,497 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include "creator_landmark.h" 
+#include "creator_traces.h"
+
+#include <EPos_CPosLandmarkDatabase.h>
+#include <EPos_CPosLmCategoryManager.h>
+#include <lbsposition.h>
+
+_LIT(KAccommodation, "accommodation");
+_LIT(KBusiness, "business");
+_LIT(KCommunication, "communication");
+_LIT(KEducational, "educational");
+_LIT(KEntertainment, "entertainment");
+_LIT(KFoodAndBeverage, "food");
+_LIT(KGeographical, "geographical");
+_LIT(KOutdoor, "outdoor");
+_LIT(KPeople, "people");
+_LIT(KPublic, "public");
+_LIT(KReligious, "religious");
+_LIT(KShopping, "shopping");
+_LIT(KSightseeing, "sightseeing");
+_LIT(KSports, "sports");
+_LIT(KTransport, "transport");
+
+
+/**
+ * Class mapping the strings to global landmark categories
+ */
+class CategoryMapping
+{
+public:
+    CategoryMapping(TUint aId, const TDesC& aCategoryStr)
+    : 
+    iGlobalId(aId),
+    iStr(aCategoryStr)
+    {}
+
+    TPosLmGlobalCategory iGlobalId;
+    const TDesC& iStr;
+};
+
+/**
+ * Global landmark categories
+ */
+CategoryMapping LandmarkCategories[] =    {
+        CategoryMapping(3000, KAccommodation), // Accommodation
+        CategoryMapping(6000, KBusiness), // Business
+        CategoryMapping(9000, KCommunication), // Communication
+        CategoryMapping(12000, KEducational), // Educational institute
+        CategoryMapping(15000, KEntertainment), // Entertainment
+        CategoryMapping(18000, KFoodAndBeverage), // Food & Beverage
+        CategoryMapping(21000, KGeographical), // Geographical area
+        CategoryMapping(24000, KOutdoor), // Outdoor activities        
+        CategoryMapping(27000, KPeople), // People
+        CategoryMapping(30000, KPublic), // Public service
+        CategoryMapping(33000, KReligious), // Religious places
+        CategoryMapping(36000, KShopping), // Shopping
+        CategoryMapping(39000, KSightseeing), // Sightseeing
+        CategoryMapping(42000, KSports), // Sports
+        CategoryMapping(45000, KTransport)  // Transport
+};
+
+/**
+ * Return landmark global id
+ */ 
+TPosLmGlobalCategory CCreatorLandmarks::GetCategoryIdL(const TDesC& aCategoryStr)
+    {
+    TUint numOfCategories = sizeof(LandmarkCategories)/sizeof(CategoryMapping);
+    for( TUint i = 0; i < numOfCategories; ++i )
+        {
+        if( LandmarkCategories[i].iStr == aCategoryStr )
+            return LandmarkCategories[i].iGlobalId;
+        }
+    
+    return 0;
+    }
+
+/**
+ *
+ */ 
+CLandmarkParameters::CLandmarkParameters()
+    {
+    LOGSTRING("Creator: CLandmarkParameters::CLandmarkParameters");
+    }
+
+/**
+ *
+ */
+CLandmarkParameters::~CLandmarkParameters()
+    {
+    LOGSTRING("Creator: CLandmarkParameters::~CLandmarkParameters");
+    delete iName;    
+    delete iStreet;
+    delete iCity;    
+    delete iState;
+    delete iCountry;
+    delete iPostCode;    
+    delete iDescription;
+    delete iPhonenumber;
+    delete iUrl;
+    iCategories.Close();
+    }
+
+/**
+ *
+ */
+void CLandmarkParameters::SetRandomNameL(CCreatorEngine& aEngine)
+    {    
+    TPtrC name(aEngine.RandomString(CCreatorEngine::ELandmarkName));
+    delete iName;
+    iName = 0;
+    iName = HBufC::NewL(name.Length());
+    iName->Des().Copy(name);
+    }
+
+/**
+ *
+ */
+void CLandmarkParameters::SetRandomUrlL(CCreatorEngine& aEngine)
+    {
+    _LIT(KUrlPrefix, "http://www.");
+    _LIT(KUrlPostfix, ".com");
+    TPtrC company(aEngine.RandomString(CCreatorEngine::ECompany));
+    delete iUrl;
+    iUrl = 0;
+    iUrl = HBufC::NewL(KUrlPrefix().Length()+company.Length()+KUrlPostfix().Length());
+    iUrl->Des() = KUrlPrefix;
+    iUrl->Des().Append( company );
+    iUrl->Des().Append( KUrlPostfix );
+    }
+
+/**
+ *
+ */
+void CLandmarkParameters::AddRandomCategoryL(CCreatorEngine& aEngine)
+    {
+    TUint numOfCategories = sizeof(LandmarkCategories)/sizeof(CategoryMapping);
+    iCategories.AppendL(LandmarkCategories[aEngine.RandomNumber(0, numOfCategories-1)].iGlobalId);
+    }
+
+/**
+ *
+ */
+void CLandmarkParameters::SetRandomStreetL(CCreatorEngine& aEngine)
+    {
+    TPtrC street(aEngine.RandomString(CCreatorEngine::EAddress));
+    delete iStreet;
+    iStreet = 0;
+    iStreet = HBufC::NewL(street.Length());
+    iStreet->Des().Copy(street);
+    }
+ 
+/**
+ *
+ */
+void CLandmarkParameters::SetRandomCityL(CCreatorEngine& aEngine)
+    {
+    TPtrC city(aEngine.RandomString(CCreatorEngine::ECity));
+    delete iCity;
+    iCity = 0;
+    iCity = HBufC::NewL(city.Length());
+    iCity->Des().Copy(city);
+    }
+
+/**
+ *
+ */
+void CLandmarkParameters::SetRandomStateL(CCreatorEngine& aEngine)
+    {
+    TPtrC state(aEngine.RandomString(CCreatorEngine::EState));
+    delete iState;
+    iState = 0;
+    iState = HBufC::NewL(state.Length());
+    iState->Des().Copy(state);
+    }
+
+/**
+ *
+ */
+void CLandmarkParameters::SetRandomCountryL(CCreatorEngine& aEngine)
+    {
+    TPtrC country(aEngine.RandomString(CCreatorEngine::ECountry));
+    delete iCountry;
+    iCountry = 0;
+    iCountry = HBufC::NewL(country.Length());
+    iCountry->Des().Copy(country);
+    }
+
+/**
+ *
+ */
+void CLandmarkParameters::SetRandomPostCodeL(CCreatorEngine& aEngine)
+    {
+    TPtrC po(aEngine.RandomString(CCreatorEngine::EPostcode));
+    delete iPostCode;
+    iPostCode = 0;
+    iPostCode = HBufC::NewL(po.Length());
+    iPostCode->Des().Copy(po);
+    }
+
+/**
+ *
+ */
+void CLandmarkParameters::SetRandomLatitudeL(CCreatorEngine& aEngine)
+    {
+    iLatitude = aEngine.RandomNumber(-89, 89); // Degrees
+    TReal64 random = aEngine.RandomNumber(0, 9999); // Desimals 
+    iLatitude +=  random / 10000.0;
+    }
+
+/**
+ *
+ */
+void CLandmarkParameters::SetRandomLongitudeL(CCreatorEngine& aEngine)
+    {
+    TInt minDegrees = -179;
+    TInt maxDegrees = 179;
+    TInt minDecimal = 0;
+    TInt maxDecimal = 9999;
+    TReal64 divider = 10000.0;
+    iLongitude = aEngine.RandomNumber(minDegrees, maxDegrees); // Degrees
+    TReal64 random = aEngine.RandomNumber(minDecimal, maxDecimal); 
+    iLongitude += random  / divider;
+    }
+
+/**
+ *
+ */
+void CLandmarkParameters::SetRandomPositionAccuracyL(CCreatorEngine& aEngine)
+    {
+    this->iPositionAccuracy = aEngine.RandomNumber(0,5);
+    }
+
+/**
+ *
+ */
+void CLandmarkParameters::SetRandomAltitudeL(CCreatorEngine& aEngine)
+    {
+    this->iAltitude = aEngine.RandomNumber(0,120);
+    }
+
+/**
+ *
+ */
+void CLandmarkParameters::SetRandomAltitudeAccuracyL(CCreatorEngine& aEngine)
+    {
+    this->iAltitudeAccuracy = aEngine.RandomNumber(0,5);
+    }
+
+/**
+ *
+ */
+void CLandmarkParameters::SetRandomDescriptionL(CCreatorEngine& aEngine)
+    {
+    delete iDescription;
+    iDescription = 0;
+    TPtrC desc(aEngine.RandomString(CCreatorEngine::ELandmarkDescription));
+    iDescription = HBufC::NewL(desc.Length());
+    iDescription->Des().Copy(desc);
+    }
+
+/**
+ *
+ */
+void CLandmarkParameters::SetRandomPhoneNumberL(CCreatorEngine& aEngine)
+    {
+    delete iPhonenumber;
+    iPhonenumber = 0;
+    TPtrC phone(aEngine.RandomString(CCreatorEngine::EPhoneNumber));
+    iPhonenumber = HBufC::NewL(phone.Length());
+    iPhonenumber->Des().Copy(phone);
+    }
+
+/**
+ *
+ */
+CCreatorLandmarks::CCreatorLandmarks()
+    {
+    }
+
+/**
+ *
+ */
+CCreatorLandmarks* CCreatorLandmarks::NewL(CCreatorEngine* aEngine)
+    {
+    CCreatorLandmarks* self = CCreatorLandmarks::NewLC(aEngine);
+    CleanupStack::Pop(); // self
+    return self;
+    }
+
+/**
+ *
+ */
+CCreatorLandmarks* CCreatorLandmarks::NewLC(CCreatorEngine* aEngine)
+    {
+    CCreatorLandmarks* self = new (ELeave) CCreatorLandmarks;
+    CleanupStack::PushL(self);
+    self->ConstructL(aEngine);
+    return self;
+    }
+
+/**
+ *
+ */
+void CCreatorLandmarks::ConstructL(CCreatorEngine* aEngine)
+    {
+    LOGSTRING("Creator: CCreatorLandmarks::ConstructL");
+    iEngine = aEngine;
+    iLandmarkDb = CPosLandmarkDatabase::OpenL();
+    if( iLandmarkDb->IsInitializingNeeded() )
+        {
+        ExecuteAndDeleteLD(iLandmarkDb->InitializeL());
+        }
+    }
+
+/**
+ *
+ */
+CCreatorLandmarks::~CCreatorLandmarks()
+    {
+    LOGSTRING("Creator: CCreatorLandmarks::~CCreatorLandmarks");
+    if ( iEngine && iEntryIds.Count() )
+        {
+        TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iEntryIds, KUidDictionaryUidLandmarks ) );
+        }
+    iEntryIds.Reset();
+    iEntryIds.Close();
+    
+    delete iLandmarkDb;
+    delete iLmOperation;
+    delete iParameters;
+    }
+
+/**
+ *
+ */
+TBool CCreatorLandmarks::AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries)
+    {
+    LOGSTRING("Creator: CCreatorLandmarks::AskDataFromUserL");
+    if ( aCommand == ECmdDeleteLandmarks )
+        {
+        return iEngine->YesNoQueryDialogL( _L("Delete all Landmarks?") );
+        }
+    else if ( aCommand ==  ECmdDeleteCreatorLandmarks )
+        {
+        return iEngine->YesNoQueryDialogL( _L("Delete all Landmarks created with Creator?") );
+        }
+    return iEngine->EntriesQueryDialogL(aNumberOfEntries, _L("How many landmarks to create?"));    
+    }
+
+/**
+ * Convert global category id to local category id
+ */
+TPosLmItemId CCreatorLandmarks::GetCategoryIdL( TPosLmGlobalCategory aGlobalCategoryID )
+{
+    CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL( *iLandmarkDb );
+    CleanupStack::PushL( categoryManager );
+
+    // Find ID of the given global category in given database
+    TPosLmItemId id = categoryManager->GetGlobalCategoryL( aGlobalCategoryID );
+    CleanupStack::PopAndDestroy(); // categoryManager
+    return id;
+}
+
+/**
+ *
+ */
+TInt CCreatorLandmarks::CreateLandmarkEntryL(CLandmarkParameters *aParameters)
+    {
+    LOGSTRING("Creator: CCreatorLandmarks::CreateLandmarkEntryL");
+    TInt err = KErrNone;
+    // clear any existing parameter definations
+    delete iParameters;
+    iParameters = NULL;
+        
+    CLandmarkParameters* parameters = aParameters;
+        
+    // random data needed if no predefined data available
+    if (!parameters)
+        {
+        iParameters = new(ELeave) CLandmarkParameters;
+        parameters = iParameters;
+            
+        TBuf<160> company = iEngine->RandomString(CCreatorEngine::ECompany);
+
+        parameters->SetRandomNameL(*iEngine);
+        parameters->SetRandomUrlL(*iEngine);
+        parameters->AddRandomCategoryL(*iEngine);
+        parameters->SetRandomStreetL(*iEngine);
+        parameters->SetRandomCityL(*iEngine);
+        parameters->SetRandomStateL(*iEngine);
+        parameters->SetRandomCountryL(*iEngine);
+        parameters->SetRandomPostCodeL(*iEngine);
+        parameters->SetRandomLatitudeL(*iEngine);
+        parameters->SetRandomLongitudeL(*iEngine);
+        parameters->SetRandomPositionAccuracyL(*iEngine);
+        parameters->SetRandomAltitudeL(*iEngine);
+        parameters->SetRandomAltitudeAccuracyL(*iEngine);
+        parameters->SetRandomDescriptionL(*iEngine);
+        parameters->SetRandomPhoneNumberL(*iEngine);
+        }
+    
+    CPosLandmark* newLandmark = CPosLandmark::NewLC();        
+    TCoordinate crd(parameters->iLatitude, parameters->iLongitude, parameters->iAltitude);
+    TLocality loc(crd, parameters->iPositionAccuracy, parameters->iAltitudeAccuracy);
+    newLandmark->SetPositionL(loc);
+    
+    // Add categories
+    for( TInt i = 0; i < parameters->iCategories.Count(); ++i )
+        {
+        newLandmark->AddCategoryL(GetCategoryIdL(parameters->iCategories[i]));
+        }
+    if( parameters->iName )    
+        newLandmark->SetLandmarkNameL(parameters->iName->Des());    
+    if( parameters->iCountry )
+        newLandmark->SetPositionFieldL(EPositionFieldCountry, parameters->iCountry->Des());
+    if( parameters->iCity )
+        newLandmark->SetPositionFieldL(EPositionFieldCity, parameters->iCity->Des());
+    if( parameters->iPostCode )
+        newLandmark->SetPositionFieldL(EPositionFieldPostalCode, parameters->iPostCode->Des());
+    if( parameters->iState )
+        newLandmark->SetPositionFieldL(EPositionFieldState, parameters->iState->Des());
+    if( parameters->iStreet )
+        newLandmark->SetPositionFieldL(EPositionFieldStreet, parameters->iStreet->Des());
+    if( parameters->iPhonenumber )
+        newLandmark->SetPositionFieldL(EPositionFieldBuildingTelephone, parameters->iPhonenumber->Des());
+    if( parameters->iDescription )
+        newLandmark->SetLandmarkDescriptionL(parameters->iDescription->Des());    
+    if( parameters->iUrl )
+        newLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart, parameters->iUrl->Des());
+    
+    TRAP(err, iLandmarkDb->AddLandmarkL(*newLandmark));
+    
+    // id has been generated, store it for being able to delete
+    // entries created only with Creator
+    iEntryIds.Append( newLandmark->LandmarkId() );
+
+    ExecuteAndDeleteLD(iLandmarkDb->CompactL());
+    
+    CleanupStack::PopAndDestroy(newLandmark);
+    return err;
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorLandmarks::DeleteAllL()
+    {
+    LOGSTRING("Creator: CCreatorLandmarks::DeleteAllL");
+    ExecuteAndDeleteLD( iLandmarkDb->RemoveAllLandmarksL() );
+    ExecuteAndDeleteLD( iLandmarkDb->CompactL() );
+
+    // reset must be done here, because iEntryIds is stored in destructor
+    iEntryIds.Reset();
+    
+    // all entries deleted, remove the Landmarks related registry
+    iEngine->RemoveStoreL( KUidDictionaryUidLandmarks );
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorLandmarks::DeleteAllCreatedByCreatorL()
+    {
+    LOGSTRING("Creator: CCreatorLandmarks::DeleteAllCreatedByCreatorL");
+    iEntryIds.Reset();
+    
+    // fetch ids of entries created by Creator
+    iEngine->ReadEntryIdsFromStoreL( iEntryIds, KUidDictionaryUidLandmarks );
+    
+    // delete entries
+    TRAP_IGNORE(
+        ExecuteAndDeleteLD( iLandmarkDb->RemoveLandmarksL( iEntryIds ) );
+        ExecuteAndDeleteLD( iLandmarkDb->CompactL() );
+        );
+
+    // reset must be done here, because iEntryIds is stored in destructor
+    iEntryIds.Reset();
+    
+    // all entries deleted, remove the Landmarks related registry
+    iEngine->RemoveStoreL( KUidDictionaryUidLandmarks );
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_landmarkelement.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,256 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include "creator_landmarkelement.h"
+#include "creator_traces.h"
+#include "creator_landmark.h"
+
+using namespace creatorlandmark;
+
+/*
+ * 
+ */
+CCreatorLandmarkElement* CCreatorLandmarkElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext )
+    {
+    CCreatorLandmarkElement* self = new (ELeave) CCreatorLandmarkElement(aEngine);
+    CleanupStack::PushL(self);
+    self->ConstructL(aName, aContext);
+    CleanupStack::Pop(self);
+    return self;
+    }
+/*
+ * 
+ */
+CCreatorLandmarkElement::CCreatorLandmarkElement(CCreatorEngine* aEngine) 
+: 
+CCreatorScriptElement(aEngine)
+    {
+    iIsCommandElement = ETrue;
+    }
+
+void CCreatorLandmarkElement::ExecuteCommandL()
+    {
+    const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount);
+    TInt lmAmount = 1;    
+    if( amountAttr )
+        {
+        lmAmount = ConvertStrToIntL(amountAttr->Value());
+        }
+    // Get 'fields' element 
+    CCreatorScriptElement* fieldsElement = FindSubElement(KFields);
+    if( fieldsElement && fieldsElement->SubElements().Count() > 0 )
+        {
+        // Get sub-elements
+        const RPointerArray<CCreatorScriptElement>& fields = fieldsElement->SubElements();        
+        // Create note entries, the amount of entries is defined by noteAmount:
+        for( TInt cI = 0; cI < lmAmount; ++cI )
+            {            
+            CLandmarkParameters* param = new (ELeave) CLandmarkParameters;
+            CleanupStack::PushL(param);
+            
+            for( TInt i = 0; i < fields.Count(); ++i )
+                {
+                CCreatorScriptElement* field = fields[i];
+                TPtrC elemName = field->Name();
+                TPtrC elemContent = field->Content();
+                const CCreatorScriptAttribute* randomAttr = fields[i]->FindAttributeByName(KRandomLength);
+                TBool useRandom = EFalse;
+                if( randomAttr || elemContent.Length() == 0 )
+                    {
+                    useRandom = ETrue;
+                    }
+                
+                if( elemName == KName )
+                    {
+                    if( useRandom )
+                        {
+                        param->SetRandomNameL(*iEngine);
+                        }                    
+                    else
+                        {
+                        SetContentToTextParamL(param->iName, elemContent);
+                        }
+                    }
+                else if( elemName == KCategory )
+                    {
+                    if( useRandom )
+                        {
+                        param->AddRandomCategoryL(*iEngine);
+                        }                    
+                    else
+                        {
+                        TPosLmItemId categoryId = CCreatorLandmarks::GetCategoryIdL(elemContent);
+                        if( categoryId > 0 )
+                            {
+                            param->iCategories.AppendL(categoryId);
+                            }
+                        }
+                    }
+                else if( elemName == KDescription )
+                    {
+                    if( useRandom )
+                        {
+                        param->SetRandomDescriptionL(*iEngine);
+                        }                    
+                    else
+                        {
+                        SetContentToTextParamL(param->iDescription, elemContent);
+                        }
+                    }
+                else if( elemName == KStreet )
+                    {
+                    if( useRandom )
+                        {
+                        param->SetRandomStreetL(*iEngine);
+                        }                    
+                    else
+                        {
+                        SetContentToTextParamL(param->iStreet, elemContent);
+                        }
+                    }
+                else if( elemName == KPostalcode )
+                    {
+                    if( useRandom )
+                        {
+                        param->SetRandomPostCodeL(*iEngine);
+                        }                    
+                    else
+                        {
+                        SetContentToTextParamL(param->iPostCode, elemContent);
+                        }
+                    }
+                else if( elemName == KCity )
+                    {
+                    if( useRandom )
+                        {
+                        param->SetRandomCityL(*iEngine);
+                        }                    
+                    else
+                        {
+                        SetContentToTextParamL(param->iCity, elemContent);
+                        }
+                    }
+                else if( elemName == KState )
+                    {
+                    if( useRandom )
+                        {
+                        param->SetRandomStateL(*iEngine);
+                        }                    
+                    else
+                        {
+                        SetContentToTextParamL(param->iState, elemContent);
+                        }
+                    }
+                else if( elemName == KCountry )
+                    {
+                    if( useRandom )
+                        {
+                        param->SetRandomCountryL(*iEngine);
+                        }                    
+                    else
+                        {
+                        SetContentToTextParamL(param->iCountry, elemContent);
+                        }
+                    }
+                else if( elemName == KPhonenumber )
+                    {
+                    if( useRandom )
+                        {
+                        param->SetRandomPhoneNumberL(*iEngine);
+                        }                    
+                    else
+                        {
+                        SetContentToTextParamL(param->iPhonenumber, elemContent);
+                        }
+                    }
+                else if( elemName == KUrl )
+                    {
+                    if( useRandom )
+                        {
+                        param->SetRandomUrlL(*iEngine);
+                        }                    
+                    else
+                        {
+                        SetContentToTextParamL(param->iUrl, elemContent);
+                        }
+                    }
+                else if( elemName == KLatitude )
+                    {
+                    if( useRandom )
+                        {
+                        param->SetRandomLatitudeL(*iEngine);
+                        }                    
+                    else
+                        {
+                        ConvertStrToReal64L(elemContent, param->iLatitude);
+                        }
+                    }
+                else if( elemName == KLongitude )
+                    {
+                    if( useRandom )
+                        {
+                        param->SetRandomLongitudeL(*iEngine);
+                        }                    
+                    else
+                        {
+                        ConvertStrToReal64L(elemContent, param->iLongitude);
+                        }
+                    }
+                else if( elemName == KPositionaccuracy )
+                    {
+                    if( useRandom )
+                        {
+                        param->SetRandomPositionAccuracyL(*iEngine);
+                        }                    
+                    else
+                        {
+                        param->iPositionAccuracy = ConvertStrToIntL(elemContent);
+                        }
+                    }
+                else if( elemName == KAltitude )
+                    {
+                    if( useRandom )
+                        {
+                        param->SetRandomAltitudeL(*iEngine);
+                        }                    
+                    else
+                        {
+                        ConvertStrToReal32L(elemContent, param->iAltitude);
+                        }
+                    }
+                else if( elemName == KAltitudeaccuracy )
+                    {
+                    if( useRandom )
+                        {
+                        param->SetRandomAltitudeAccuracyL(*iEngine);
+                        }                    
+                    else
+                        {
+                        param->iAltitudeAccuracy = ConvertStrToIntL(elemContent);
+                        }
+                    }
+                }
+            iEngine->AppendToCommandArrayL(ECmdCreateMiscEntryLandmarks, param);
+            CleanupStack::Pop(); // param
+            }
+        }
+    else
+    	{
+    	iEngine->AppendToCommandArrayL(ECmdCreateMiscEntryLandmarks, 0, lmAmount);
+    	}
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_log.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,436 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include <cntdef.h>
+
+#include "creator_log.h" 
+#include "creator_traces.h"
+
+static const TInt KLogsFieldLength = 256;
+
+//_LIT(KCreatorLogsPrefixName, "CR_");
+
+//----------------------------------------------------------------------------
+
+CLogsParameters::CLogsParameters()
+    {
+    LOGSTRING("Creator: CLogsParameters::CLogsParameters");
+
+    iPhoneNumber = HBufC::New(KLogsFieldLength);
+    /*iMissedCallPhoneNumber = HBufC::New(KLogsFieldLength);
+    iReceivedCallPhoneNumber = HBufC::New(KLogsFieldLength);
+    iDialledNumberPhoneNumber = HBufC::New(KLogsFieldLength);*/
+    }
+
+CLogsParameters::~CLogsParameters()
+    {
+    LOGSTRING("Creator: CLogsParameters::~CLogsParameters");
+
+    delete iPhoneNumber;
+    /*delete iDialledNumberPhoneNumber;
+    delete iReceivedCallPhoneNumber;
+    delete iMissedCallPhoneNumber;*/
+    }
+
+//----------------------------------------------------------------------------
+
+CCreatorLogs* CCreatorLogs::NewL(CCreatorEngine* aEngine)
+    {
+    CCreatorLogs* self = CCreatorLogs::NewLC(aEngine);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CCreatorLogs* CCreatorLogs::NewLC(CCreatorEngine* aEngine)
+    {
+    CCreatorLogs* self = new (ELeave) CCreatorLogs;
+    CleanupStack::PushL(self);
+    self->ConstructL(aEngine);
+    return self;
+    }
+
+CCreatorLogs::CCreatorLogs() : CActive(0)
+    {
+    }
+
+void CCreatorLogs::ConstructL(CCreatorEngine* aEngine)
+    {
+    LOGSTRING("Creator: CCreatorLogs::ConstructL");
+
+    iEngine = aEngine;
+
+    iLogClient = CLogClient::NewL(CEikonEnv::Static()->FsSession());
+    iLogEvent = CLogEvent::NewL();
+
+	CActiveScheduler::Add(this); // needed by CActive
+    }
+
+CCreatorLogs::~CCreatorLogs()
+    {
+    LOGSTRING("Creator: CCreatorLogs::~CCreatorLogs");
+
+    Cancel(); //from CActive
+
+    if ( iEngine && iEntryIds.Count() )
+        {
+        TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iEntryIds, KUidDictionaryUidLogs ) );
+        }
+    iEntryIds.Reset();
+    iEntryIds.Close();
+    
+    delete iLogEvent;
+    delete iLogClient;
+
+    if (iParameters)
+        delete iParameters;
+    }
+
+//----------------------------------------------------------------------------
+
+TBool CCreatorLogs::AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries)
+    {
+    LOGSTRING("Creator: CCreatorLogs::AskDataFromUserL");
+    if ( aCommand == ECmdDeleteLogs )
+        {
+        return iEngine->YesNoQueryDialogL( _L("Delete all log entries?") );
+        }
+    else if ( aCommand ==  ECmdDeleteCreatorLogs )
+        {
+        return iEngine->YesNoQueryDialogL( _L("Delete all log entries created with Creator?") );
+        }
+    return iEngine->EntriesQueryDialogL( aNumberOfEntries, _L("How many entries to create?") );
+    }
+
+//----------------------------------------------------------------------------
+
+void CCreatorLogs::RunL()
+	{
+    LOGSTRING("Creator: CCreatorLogs::RunL");
+
+    // log writing finished, stop the async waiting
+    iLogWriteWait.AsyncStop();
+    }
+
+//----------------------------------------------------------------------------
+
+void CCreatorLogs::DoCancel()
+	{
+    }
+
+//----------------------------------------------------------------------------
+
+TInt CCreatorLogs::CreateMissedCallEntryL(CLogsParameters *aParameters)
+    {
+    LOGSTRING("Creator: CCreatorLogs::CreateMissedCallEntryL");
+
+    // clear any existing parameter definations
+    delete iParameters;
+    iParameters = NULL;
+    
+    CLogsParameters* parameters = aParameters;
+    
+    // random data needed if no predefined data available
+    if (!parameters)
+        {
+        iParameters = new(ELeave) CLogsParameters;
+        parameters = iParameters;
+
+        /*iParameters->iMissedCallPhoneNumber->Des().Zero();
+        iParameters->iMissedCallPhoneNumber->Des().AppendNum( iEngine->RandomNumber(1000000, 9999999) );
+
+        iParameters->iMissedCallEventTime.UniversalTime();
+        iParameters->iMissedCallEventTime -= TTimeIntervalMinutes( iEngine->RandomNumber(12000) );*/
+        parameters->iPhoneNumber->Des().Zero();
+        parameters->iPhoneNumber->Des().AppendNum( iEngine->RandomNumber(1000000, 9999999) );
+        
+        parameters->iEventTime.UniversalTime();
+        parameters->iEventTime -= TTimeIntervalMinutes( iEngine->RandomNumber(12000) );
+
+        }
+    
+    // defaults
+    iLogEvent->SetId( KLogNullIdCreator );    
+    iLogEvent->SetEventType( KNullUid );
+    iLogEvent->SetRemoteParty( KNullDesC );
+    iLogEvent->SetDirection( KNullDesC );
+    iLogEvent->SetTime( Time::NullTTime() );
+    iLogEvent->SetDurationType( KLogNullDurationTypeCreator );
+    iLogEvent->SetDuration( KLogNullDurationCreator );
+    iLogEvent->SetStatus( KNullDesC );
+    iLogEvent->SetSubject( KNullDesC );
+    iLogEvent->SetNumber( KNullDesC );
+    iLogEvent->SetContact( KNullContactId );
+    iLogEvent->SetLink( KLogNullLinkCreator );
+    iLogEvent->SetDescription( KNullDesC );
+    iLogEvent->SetFlags( KLogNullFlags );
+    iLogEvent->SetEventType(KLogCallEventTypeUid);
+    iLogEvent->SetSubject(_L("A"));
+
+    // set direction
+    TLogString missed;
+    iLogClient->GetString(missed, R_LOG_DIR_MISSED);
+    iLogEvent->SetDirection(missed);
+
+    // set duration
+    iLogEvent->SetDurationType( KLogDurationNoneCreator );
+    TLogDuration duration = 0;
+    iLogEvent->SetDuration(duration);
+
+    // set the phone number
+    //iLogEvent->SetNumber( iParameters->iMissedCallPhoneNumber->Des() );
+    iLogEvent->SetNumber( parameters->iPhoneNumber->Des() );
+
+    // set event time
+    //iLogEvent->SetTime( iParameters->iMissedCallEventTime );
+    iLogEvent->SetTime( parameters->iEventTime );
+
+    // start writing
+    __ASSERT_ALWAYS(!IsActive(), User::Panic(_L("LogWriter"), 150));
+	iLogClient->AddEvent(*iLogEvent, iStatus);
+	SetActive();
+
+    // wait till adding has finished
+    iLogWriteWait.Start();
+
+    // id has been generated, store it for being able to delete
+    // entries created only with Creator
+    iEntryIds.Append( iLogEvent->Id() );
+
+    return iStatus.Int();  // should be KErrNone if writing was succesful
+    }
+
+//----------------------------------------------------------------------------
+
+TInt CCreatorLogs::CreateReceivedCallEntryL(CLogsParameters *aParameters)
+    {
+    LOGSTRING("Creator: CCreatorLogs::CreateReceivedCallEntryL");
+
+    // clear any existing parameter definations
+    delete iParameters;
+    iParameters = NULL;
+    
+    CLogsParameters* parameters = aParameters;
+        
+    // random data needed if no predefined data available
+    if (!parameters)
+        {
+        iParameters = new(ELeave) CLogsParameters;
+        parameters = iParameters;
+
+        /*iParameters->iReceivedCallPhoneNumber->Des().Zero();
+        iParameters->iReceivedCallPhoneNumber->Des().AppendNum( iEngine->RandomNumber(1000000, 9999999) );
+
+        iParameters->iReceivedCallEventTime.UniversalTime();
+        iParameters->iReceivedCallEventTime -= TTimeIntervalMinutes( iEngine->RandomNumber(12000) );
+
+        iParameters->iReceivedCallDuration = iEngine->RandomNumber(7200);*/
+        parameters->iPhoneNumber->Des().Zero();
+        parameters->iPhoneNumber->Des().AppendNum( iEngine->RandomNumber(1000000, 9999999) );
+        
+        parameters->iEventTime.UniversalTime();
+        parameters->iEventTime -= TTimeIntervalMinutes( iEngine->RandomNumber(12000) );
+        
+        parameters->iDuration = iEngine->RandomNumber(7200);
+        }
+   
+    // defaults
+    iLogEvent->SetId( KLogNullIdCreator );
+    iLogEvent->SetEventType( KNullUid );
+    iLogEvent->SetRemoteParty( KNullDesC );
+    iLogEvent->SetDirection( KNullDesC );
+    iLogEvent->SetTime( Time::NullTTime() );
+    iLogEvent->SetDurationType( KLogNullDurationTypeCreator );
+    iLogEvent->SetDuration( KLogNullDurationCreator );
+    iLogEvent->SetStatus( KNullDesC );
+    iLogEvent->SetSubject( KNullDesC );
+    iLogEvent->SetNumber( KNullDesC );
+    iLogEvent->SetContact( KNullContactId );
+    iLogEvent->SetLink( KLogNullLinkCreator );
+    iLogEvent->SetDescription( KNullDesC );
+    iLogEvent->SetFlags( KLogNullFlags );
+    iLogEvent->SetEventType(KLogCallEventTypeUid);
+    iLogEvent->SetSubject(_L("A"));
+
+    // set direction
+    TLogString incoming;
+    iLogClient->GetString(incoming, R_LOG_DIR_IN);
+    iLogEvent->SetDirection(incoming);
+
+    // set duration
+    iLogEvent->SetDurationType( KLogDurationValidCreator );
+    //iLogEvent->SetDuration( iParameters->iReceivedCallDuration );
+    iLogEvent->SetDuration( parameters->iDuration );
+
+    // set the phone number
+    //iLogEvent->SetNumber( iParameters->iReceivedCallPhoneNumber->Des() );
+    iLogEvent->SetNumber( parameters->iPhoneNumber->Des() );
+
+    // set event time
+    //iLogEvent->SetTime( iParameters->iReceivedCallEventTime );
+    iLogEvent->SetTime( parameters->iEventTime );
+
+    // start writing
+    __ASSERT_ALWAYS(!IsActive(), User::Panic(_L("LogWriter"), 151));
+	iLogClient->AddEvent(*iLogEvent, iStatus);
+	SetActive();
+
+    // wait till adding has finished
+    iLogWriteWait.Start();
+
+    // id has been generated, store it for being able to delete
+    // entries created only with Creator
+    iEntryIds.Append( iLogEvent->Id() );
+
+    return iStatus.Int();  // should be KErrNone if writing was succesful
+    }
+
+//----------------------------------------------------------------------------
+
+
+TInt CCreatorLogs::CreateDialledNumberEntryL(CLogsParameters *aParameters)
+    {
+    LOGSTRING("Creator: CCreatorLogs::CreateDialledNumberEntryL");
+
+    // clear any existing parameter definations
+    delete iParameters;
+    iParameters = NULL;
+    
+    CLogsParameters* parameters = aParameters; 
+        
+    // random data needed if no predefined data available
+    if (!parameters)
+        {
+        iParameters = new(ELeave) CLogsParameters;
+        parameters = iParameters;
+
+        /*iParameters->iDialledNumberPhoneNumber->Des().Zero();
+        iParameters->iDialledNumberPhoneNumber->Des().AppendNum( iEngine->RandomNumber(1000000, 9999999) );
+
+        iParameters->iDialledNumberEventTime.UniversalTime();
+        iParameters->iDialledNumberEventTime -= TTimeIntervalMinutes( iEngine->RandomNumber(12000) );
+
+        iParameters->iDialledNumberDuration = iEngine->RandomNumber(7200);*/
+        parameters->iPhoneNumber->Des().Zero();
+        parameters->iPhoneNumber->Des().AppendNum( iEngine->RandomNumber(1000000, 9999999) );
+
+        parameters->iEventTime.UniversalTime();
+        parameters->iEventTime -= TTimeIntervalMinutes( iEngine->RandomNumber(12000) );
+
+        parameters->iDuration = iEngine->RandomNumber(7200);
+
+        }
+   
+    // defaults
+    iLogEvent->SetId( KLogNullIdCreator );
+    iLogEvent->SetEventType( KNullUid );
+    iLogEvent->SetRemoteParty( KNullDesC );
+    iLogEvent->SetDirection( KNullDesC );
+    iLogEvent->SetTime( Time::NullTTime() );
+    iLogEvent->SetDurationType( KLogNullDurationTypeCreator );
+    iLogEvent->SetDuration( KLogNullDurationCreator );
+    iLogEvent->SetStatus( KNullDesC );
+    iLogEvent->SetSubject( KNullDesC );
+    iLogEvent->SetNumber( KNullDesC );
+    iLogEvent->SetContact( KNullContactId );
+    iLogEvent->SetLink( KLogNullLinkCreator );
+    iLogEvent->SetDescription( KNullDesC );
+    iLogEvent->SetFlags( KLogNullFlags );
+    iLogEvent->SetEventType(KLogCallEventTypeUid);
+    iLogEvent->SetSubject(_L("A"));
+
+    // set direction
+    TLogString outgoing;
+    iLogClient->GetString(outgoing, R_LOG_DIR_OUT);
+    iLogEvent->SetDirection(outgoing);
+
+    // set duration
+    iLogEvent->SetDurationType( KLogDurationValidCreator );
+    //iLogEvent->SetDuration( iParameters->iDialledNumberDuration );
+    iLogEvent->SetDuration( parameters->iDuration );
+
+    // set the phone number
+    //iLogEvent->SetNumber( iParameters->iDialledNumberPhoneNumber->Des() );
+    iLogEvent->SetNumber( parameters->iPhoneNumber->Des() );
+
+    // set event time
+    //iLogEvent->SetTime( iParameters->iDialledNumberEventTime );
+    iLogEvent->SetTime( parameters->iEventTime );
+
+    // start writing
+    __ASSERT_ALWAYS(!IsActive(), User::Panic(_L("LogWriter"), 152));
+	iLogClient->AddEvent(*iLogEvent, iStatus);
+	SetActive();
+
+    // wait till adding has finished
+    iLogWriteWait.Start();
+
+    // id has been generated, store it for being able to delete
+    // only entries created with Creator
+    iEntryIds.Append( iLogEvent->Id() );
+    
+    return iStatus.Int();  // should be KErrNone if writing was succesful
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorLogs::DeleteAllL()
+    {
+    LOGSTRING("Creator: CCreatorLogs::DeleteAllL");
+    iLogClient->ClearLog( TTime( Time::MaxTTime() ), iStatus ); 
+    SetActive();
+    
+    // wait till delete has finished
+    iLogWriteWait.Start();
+    User::LeaveIfError( iStatus.Int() );
+
+    // reset must be done here, because iEntryIds is stored in destructor
+    iEntryIds.Reset();
+    
+    // all entries deleted, remove the Logs related registry
+    iEngine->RemoveStoreL( KUidDictionaryUidLogs );
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorLogs::DeleteAllCreatedByCreatorL()
+    {
+    LOGSTRING("Creator: CCreatorLogs::DeleteAllCreatedByCreatorL");
+    iEntryIds.Reset();
+    
+    // fetch ids of entries created by Creator
+    iEngine->ReadEntryIdsFromStoreL( iEntryIds, KUidDictionaryUidLogs );
+    
+    // delete entries
+    for ( TInt i = 0; i < iEntryIds.Count(); i++ )
+        {
+        // This could be implemented with while loop
+        // with additional cancel flag. That would enable 
+        // using CancelOp() and cancelling would be bit smoother.
+        // With this for loop implementation all entries will be
+        // deleted whether or not user cancels during logs operation.
+
+        iLogClient->DeleteEvent( iEntryIds[i], iStatus );
+        SetActive();        
+        // wait till delete has finished
+        iLogWriteWait.Start();
+        }
+    
+    // reset must be done here, because iEntryIds is stored in destructor
+    iEntryIds.Reset();
+    
+    // all entries deleted, remove the Logs related registry
+    iEngine->RemoveStoreL( KUidDictionaryUidLogs );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_logelement.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,170 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include "creator_logelement.h"
+#include "creator_traces.h"
+#include "creator_log.h"
+
+using namespace creatorlog;
+
+/*
+ * 
+ */
+CCreatorLogElement* CCreatorLogElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext )
+    {
+    CCreatorLogElement* self = new (ELeave) CCreatorLogElement(aEngine);
+    CleanupStack::PushL(self);
+    self->ConstructL(aName, aContext);
+    CleanupStack::Pop(self);
+    return self;
+    }
+/*
+ * 
+ */
+CCreatorLogElement::CCreatorLogElement(CCreatorEngine* aEngine) 
+: 
+CCreatorScriptElement(aEngine)
+    {
+    iIsCommandElement = ETrue;
+    }
+/*
+ * 
+ */
+void CCreatorLogElement::ExecuteCommandL()
+    {
+    const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount);
+    TInt logAmount = 1;    
+    if( amountAttr )
+        {
+        logAmount = ConvertStrToIntL(amountAttr->Value());
+        }
+    // Get 'fields' element 
+    CCreatorScriptElement* fieldsElement = FindSubElement(KFields);
+    if( fieldsElement && fieldsElement->SubElements().Count() > 0 )
+        {
+        // Get sub-elements
+        const RPointerArray<CCreatorScriptElement>& fields = fieldsElement->SubElements();        
+        // Create log entries, the amount of entries is defined by logAmount:
+        for( TInt cI = 0; cI < logAmount; ++cI )
+            {
+            TInt direction = -1;
+            CLogsParameters* param = new (ELeave) CLogsParameters;
+            CleanupStack::PushL(param);
+            
+            for( TInt i = 0; i < fields.Count(); ++i )
+                {
+                CCreatorScriptElement* field = fields[i];
+                TPtrC elemName = field->Name();
+                TPtrC elemContent = field->Content();
+                const CCreatorScriptAttribute* randomAttr = field->FindAttributeByName(KRandomLength);
+                const CCreatorScriptAttribute* increaseAttr = field->FindAttributeByName(KIncrease);
+                TBool increase( EFalse );
+                if ( increaseAttr )
+                    {
+                    increase = ConvertStrToBooleanL( increaseAttr->Value() );
+                    }
+                
+                if( elemName == KDirection )
+                    {
+                    direction = GetLogCommandL(elemContent, randomAttr || elemContent.Length() == 0); 
+                    }
+                else if( elemName == KDuration )
+                    {
+                    if( randomAttr || elemContent.Length() == 0 )
+                        {
+                        param->iDuration = iEngine->RandomNumber(7200);
+                        }
+                    else
+                        {
+                        param->iDuration = ConvertStrToIntL(elemContent);
+                        }
+                    }
+                else if( elemName == KPhonenumber )
+                    {
+                    if( randomAttr || elemContent.Length() == 0 )
+                        {
+                        SetContentToTextParamL(param->iPhoneNumber, iEngine->RandomString(CCreatorEngine::EPhoneNumber));
+                        }
+                    else
+                        {
+                        if ( increase )
+                            {
+                            delete param->iPhoneNumber;
+                            param->iPhoneNumber = NULL;
+                            param->iPhoneNumber = HBufC::NewL( elemContent.Length() + 3 );
+                            IncreasePhoneNumL( elemContent, cI, param->iPhoneNumber );
+                            }
+                        else
+                            {
+                            SetContentToTextParamL(param->iPhoneNumber, elemContent);
+                            }
+                        }                    
+                    }
+                else if( elemName == KDatetime )
+                    {
+                    if( randomAttr || elemContent.Length() == 0 )
+                        {
+                        param->iEventTime = iEngine->RandomTime(iEngine->RandomDate(CCreatorEngine::EDatePast), CCreatorEngine::EDatePast); 
+                        }
+                    else
+                        {
+                        param->iEventTime = ConvertToDateTimeL(elemContent);
+                        }
+                    }
+                }
+            
+            if( direction == -1 )
+                {
+                direction = GetLogCommandL(KEmpty, ETrue); 
+                }
+            iEngine->AppendToCommandArrayL(direction, param);
+            CleanupStack::Pop(); // param
+            }
+        }
+    else
+    	{
+    	for(TInt i = 0; i < logAmount; ++i )
+    		{
+    		iEngine->AppendToCommandArrayL(GetLogCommandL(KEmpty, ETrue), 0, 1);
+    		}
+    	}
+    }
+
+TInt CCreatorLogElement::GetLogCommandL( const TDesC& aLogCmdStr, TBool aRandom ) const
+    {      
+    if( aRandom )
+        {
+        TInt commandArray[] = {
+                    ECmdCreateLogEntryMissedCalls,
+                    ECmdCreateLogEntryReceivedCalls,
+                    ECmdCreateLogEntryDialledNumbers
+            };
+        return commandArray[iEngine->RandomNumber(0, 2)];
+        }
+    
+    if( CompareIgnoreCase(aLogCmdStr, KMissed) == 0 )
+        return ECmdCreateLogEntryMissedCalls;
+    else if( CompareIgnoreCase(aLogCmdStr, KIn) == 0 )
+        return ECmdCreateLogEntryReceivedCalls;
+    else if( CompareIgnoreCase(aLogCmdStr, KOut) == 0 )
+        return ECmdCreateLogEntryDialledNumbers;
+    
+    LOGSTRING2("CCreatorLogElement::GetLogCommandL: Unknown log direction: %S", &aLogCmdStr);
+    User::Leave(KErrNotFound);
+    return -1; // Not reached, but disables compiler warning...
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_mailbox.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,793 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#include "creator_mailbox.h" 
+#include "creator_traces.h"
+
+#include <etelmm.h>
+#include <msvapi.h>
+
+static const TInt KMailboxesFieldLength = 160;
+
+_LIT(KCreatorMailboxesPrefixName, "CR_");
+
+_LIT(KDefaultIncomingServer, "mail.example.com");
+_LIT(KDefaultOutgoingServer, "smtp.example.com");
+_LIT(KInternet, "internet");
+
+
+//----------------------------------------------------------------------------
+
+CMailboxesParameters::CMailboxesParameters()
+    {
+    LOGSTRING("Creator: CMailboxesParameters::CMailboxesParameters");
+
+    iIncomingPort = KUndef;
+    iOutgoingPort = KUndef;
+    iMaxEmailSize = KUndef;
+    iSyncRate = KUndef;
+    iAttachmentFetchSize = KUndef;
+    iAttachmentSizeLimit = KUndef;
+    iBodyTextSizeLimit = KUndef;
+    iAttachmentFetchSize = KUndef;
+    iInboxSyncLimit = -1; // -1 = All
+    iMailboxSyncLimit = -1; // -1 = All    
+    iToCCIncludeLimit = KUndef;
+    iImapIdleTimeout = KUndef;
+    
+    /*iMailboxName = HBufC::New(KMailboxesFieldLength);
+    iAccessPoint = HBufC::New(KMailboxesFieldLength);
+    iMyMailAddress = HBufC::New(KMailboxesFieldLength);
+    iOutgoingMailServer = HBufC::New(KMailboxesFieldLength);
+    iUserName = HBufC::New(KMailboxesFieldLength);
+    iPassword = HBufC::New(KMailboxesFieldLength);
+    iIncomingMailServer = HBufC::New(KMailboxesFieldLength);*/
+    }
+
+CMailboxesParameters::~CMailboxesParameters()
+    {
+    LOGSTRING("Creator: CMailboxesParameters::~CMailboxesParameters");
+
+    /*delete iIncomingMailServer;
+    delete iPassword;
+    delete iUserName;
+    delete iOutgoingMailServer;
+    delete iMyMailAddress;
+    delete iAccessPoint;
+    delete iMailboxName;*/
+    
+    delete iMailboxName;
+    delete iIncomingLoginName;
+    delete iIncomingPassword;
+    delete iIncomingServerName;
+    delete iIncomingConnectionMethod;
+    delete iIncomingFolderPath;
+    delete iPathSeparator;
+    delete iOutgoingLoginName;
+    delete iOutgoingPassword;
+    delete iOutgoingServerName;
+    delete iOutgoingConnectionMethod;
+    delete iOwnEmailAddress;
+    delete iOwnEmailAlias;
+    delete iReceiptAddress;
+    delete iReplyToAddress;
+    }
+
+//----------------------------------------------------------------------------
+
+CCreatorMailboxes* CCreatorMailboxes::NewL(CCreatorEngine* aEngine)
+    {
+    CCreatorMailboxes* self = CCreatorMailboxes::NewLC(aEngine);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CCreatorMailboxes* CCreatorMailboxes::NewLC(CCreatorEngine* aEngine)
+    {
+    CCreatorMailboxes* self = new (ELeave) CCreatorMailboxes;
+    CleanupStack::PushL(self);
+    self->ConstructL(aEngine);
+    return self;
+    }
+
+CCreatorMailboxes::CCreatorMailboxes()
+    {    
+    }
+
+void CCreatorMailboxes::ConstructL(CCreatorEngine* aEngine)
+    {
+    LOGSTRING("Creator: CCreatorMailboxes::ConstructL");
+
+    iEngine = aEngine;
+    }
+
+CCreatorMailboxes::~CCreatorMailboxes()
+    {
+    LOGSTRING("Creator: CCreatorMailboxes::~CCreatorMailboxes");
+    if ( iEngine && iEntryIds.Count() )
+        {
+        TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iEntryIds, KUidDictionaryUidMailbox ) );
+        }
+    iEntryIds.Reset();
+    iEntryIds.Close();
+    
+    if (iParameters)
+        delete iParameters;
+    }
+
+//----------------------------------------------------------------------------
+
+TBool CCreatorMailboxes::AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries)
+    {
+    LOGSTRING("Creator: CCreatorMailboxes::AskDataFromUserL");
+    if ( aCommand == ECmdDeleteMailboxes )
+        {
+        return iEngine->YesNoQueryDialogL( _L("Delete all mailboxes?") );
+        }
+    else if ( aCommand ==  ECmdDeleteCreatorMailboxes )
+        {
+        return iEngine->YesNoQueryDialogL( _L("Delete all mailboxes created with Creator?") );
+        }
+    return iEngine->EntriesQueryDialogL(aNumberOfEntries, _L("How many entries to create?"));
+    }
+
+
+//----------------------------------------------------------------------------
+
+TInt CCreatorMailboxes::CreateMailboxEntryL(CMailboxesParameters *aParameters)
+    {
+    LOGSTRING("Creator: CCreatorMailboxes::CreateMailboxEntryL");
+
+      // clear any existing parameter definations
+    delete iParameters;
+    iParameters = NULL;
+    
+    CMailboxesParameters* parameters = aParameters;
+    
+    // random data needed if no predefined data available
+    if (!parameters)
+        {
+        iParameters = new(ELeave) CMailboxesParameters;
+        parameters = iParameters;
+
+        TPtrC company(iEngine->RandomString(CCreatorEngine::ECompany));
+        TPtrC firstName(iEngine->RandomString(CCreatorEngine::EFirstName));
+        
+        delete parameters->iMailboxName;
+        parameters->iMailboxName = 0;
+        parameters->iMailboxName = HBufC::NewL(KMailboxesFieldLength);
+        parameters->iMailboxName->Des() = KCreatorMailboxesPrefixName;
+        parameters->iMailboxName->Des().Append( company );
+        parameters->iMailboxName->Des().Append(_L(" #"));
+        parameters->iMailboxName->Des().AppendNum(iEngine->RandomNumber(1, 100));
+        
+        delete parameters->iIncomingLoginName;
+        parameters->iIncomingLoginName = 0;
+        parameters->iIncomingLoginName = HBufC::NewL(KMailboxesFieldLength); 
+        delete parameters->iOutgoingLoginName;
+        parameters->iOutgoingLoginName = 0;
+        parameters->iOutgoingLoginName = HBufC::NewL(KMailboxesFieldLength); 
+        parameters->iIncomingLoginName->Des() = iEngine->RandomString(CCreatorEngine::EFirstName);
+        parameters->iIncomingLoginName->Des().LowerCase();
+        parameters->iOutgoingLoginName->Des().Copy(parameters->iIncomingLoginName->Des());
+        
+        delete parameters->iIncomingPassword;
+        parameters->iIncomingPassword = 0;
+        parameters->iIncomingPassword = HBufC::NewL(KMailboxesFieldLength); 
+        delete parameters->iOutgoingPassword;
+        parameters->iOutgoingPassword = 0;
+        parameters->iOutgoingPassword = HBufC::NewL(KMailboxesFieldLength); 
+        parameters->iIncomingPassword->Des() = iEngine->RandomString(CCreatorEngine::ESurname);
+        parameters->iIncomingPassword->Des().LowerCase();
+        parameters->iOutgoingPassword->Des().Copy(parameters->iIncomingPassword->Des());
+        
+        delete parameters->iIncomingServerName;
+        parameters->iIncomingServerName = 0;
+        parameters->iIncomingServerName = HBufC::NewL(KMailboxesFieldLength); 
+        parameters->iIncomingServerName->Des() = _L("incoming.");
+        parameters->iIncomingServerName->Des().Append(company);
+        parameters->iIncomingServerName->Des().Append(_L(".com"));
+        parameters->iIncomingServerName->Des().LowerCase();
+                
+        delete parameters->iIncomingConnectionMethod;
+        parameters->iIncomingConnectionMethod = 0;
+        parameters->iIncomingConnectionMethod = HBufC::NewL(KInternet().Length());
+        parameters->iIncomingConnectionMethod->Des() = KInternet;  // use always this one, if it's not found, default will be used instead
+        
+        delete parameters->iOutgoingServerName;
+        parameters->iOutgoingServerName = 0;
+        parameters->iOutgoingServerName = HBufC::NewL(KMailboxesFieldLength); 
+        parameters->iOutgoingServerName->Des() = _L("smtp.");
+        parameters->iOutgoingServerName->Des().Append(company);
+        parameters->iOutgoingServerName->Des().Append(_L(".com"));
+        parameters->iOutgoingServerName->Des().LowerCase();
+        
+        delete parameters->iOutgoingConnectionMethod;
+        parameters->iOutgoingConnectionMethod = 0;
+        parameters->iOutgoingConnectionMethod = HBufC::NewL(KInternet().Length());
+        parameters->iOutgoingConnectionMethod->Des() = KInternet;  // use always this one, if it's not found, default will be used instead
+
+        delete parameters->iOwnEmailAddress;
+        parameters->iOwnEmailAddress = 0;
+        parameters->iOwnEmailAddress = iEngine->CreateEmailAddressLC();
+        parameters->iOwnEmailAddress->Des().LowerCase();
+        CleanupStack::Pop(); // parameters->iOwnEmailAddress
+        
+        delete parameters->iOwnEmailAlias;
+        parameters->iOwnEmailAlias = 0;
+        parameters->iOwnEmailAlias = HBufC::NewL(firstName.Length());        
+        parameters->iOwnEmailAlias->Des().Copy(firstName);       
+
+        delete parameters->iReceiptAddress;
+        parameters->iReceiptAddress = 0;
+        parameters->iReceiptAddress = iEngine->CreateEmailAddressLC();
+        parameters->iReceiptAddress->Des().LowerCase();
+        CleanupStack::Pop(); // parameters->iReceiptAddress
+        
+        delete parameters->iReplyToAddress;
+        parameters->iReplyToAddress = 0;
+        parameters->iReplyToAddress = iEngine->CreateEmailAddressLC();
+        parameters->iReplyToAddress->Des().LowerCase();
+        CleanupStack::Pop(); // parameters->iReplyToAddress
+        
+        parameters->iIncomingSSLWrapper = iEngine->RandomNumber(0, 1);
+        parameters->iIncomingSecureSockets = iEngine->RandomNumber(0, 1);        
+        parameters->iAcknowledgeReceipts = iEngine->RandomNumber(0, 1);
+        parameters->iAutoSendOnConnect = iEngine->RandomNumber(0, 1);
+        parameters->iDeleteEmailsAtDisconnect = iEngine->RandomNumber(0, 1);
+        parameters->iImapIdleCommand = iEngine->RandomNumber(0, 1);
+        parameters->iMarkSeenInSync = iEngine->RandomNumber(0, 1);
+        parameters->iEnableExpungeMode = iEngine->RandomNumber(0, 1);
+        parameters->iUseApop = iEngine->RandomNumber(0, 1);
+        parameters->iDisconnectedUserMode = iEngine->RandomNumber(0, 1);                
+        parameters->iOutgoingSSLWrapper = iEngine->RandomNumber(0, 1);
+        parameters->iOutgoingSecureSockets = iEngine->RandomNumber(0, 1);
+        parameters->iIncludeSignature = EFalse;
+        parameters->iAddVCard = EFalse;
+        parameters->iRequestReceipts = iEngine->RandomNumber(0, 1);
+        parameters->iSmtpAuth = iEngine->RandomNumber(0, 1);
+        
+        parameters->iIncomingPort = iEngine->RandomNumber(25, 500);
+        parameters->iAttachmentSizeLimit = iEngine->RandomNumber(1, KMaxTInt);
+        parameters->iBodyTextSizeLimit = iEngine->RandomNumber(1, KMaxTInt);
+        parameters->iAttachmentFetchSize = iEngine->RandomNumber(1, 40960);
+        parameters->iImapIdleTimeout = iEngine->RandomNumber(10, 2000);
+        parameters->iMaxEmailSize = iEngine->RandomNumber(1024, KMaxTInt);
+        parameters->iSyncRate = iEngine->RandomNumber(10, 500);        
+        parameters->iInboxSyncLimit = iEngine->RandomNumber(-1, 256);
+        parameters->iMailboxSyncLimit = iEngine->RandomNumber(-1, 256);
+        parameters->iOutgoingPort = KDefaultSmtpPort;
+        parameters->iToCCIncludeLimit = iEngine->RandomNumber(0, 30);                      
+        
+        parameters->iGetEmailOptions = (CMailboxesParameters::TGetEmailOption) iEngine->RandomNumber(CMailboxesParameters::EUndef, CMailboxesParameters::EGetEmailOptionLast-1);
+        parameters->iSubscribeType = (TFolderSubscribeType) iEngine->RandomNumber(EUpdateNeither, EUpdateBoth);
+        parameters->iSyncType = (TFolderSyncType) iEngine->RandomNumber(EUseCombination, EUseRemote);
+        parameters->iSendCopyToSelf = (TImSMTPSendCopyToSelf) iEngine->RandomNumber(ESendNoCopy, ESendCopyAsBccRecipient);
+        parameters->iSendOption = (TImSMTPSendMessageOption) iEngine->RandomNumber(ESendMessageImmediately, ESendMessageOnRequest);
+        parameters->iMailboxType = (TMailboxType) iEngine->RandomNumber(EMailboxPOP3, EMailboxIMAP4);
+        }
+   
+    TInt err = KErrNone;
+    
+    // make sure we have some IMEI stored
+    if (iIMEI.Length() == 0)
+        {
+        TRAP(err, GetIMEIFromThePhoneL());
+        }
+
+    // init 
+    CImImap4Settings* imap4Set = new(ELeave) CImImap4Settings;
+    CleanupStack::PushL(imap4Set);
+    CImPop3Settings* pop3Set = new(ELeave) CImPop3Settings;
+    CleanupStack::PushL(pop3Set);
+    CImSmtpSettings* smtpSet = new(ELeave) CImSmtpSettings;
+    CleanupStack::PushL(smtpSet);
+    CImIAPPreferences* outgoingIAPSet = CImIAPPreferences::NewLC();
+    CImIAPPreferences* incomingIAPSet = CImIAPPreferences::NewLC();
+    CEmailAccounts* account = CEmailAccounts::NewLC();
+  
+    // Get SMTP settings:
+    PopulateSmtpSettingsL(*account, *smtpSet, *outgoingIAPSet, *parameters);
+  
+    // appending mailbox type to array to be able to use
+    // correct type when deleting mailboxes
+    iEntryIds.Append( parameters->iMailboxType );
+    
+    if (parameters->iMailboxType == EMailboxIMAP4)
+        {
+        // Get IMAP settings:
+        PopulateImapSettingsL(*account, *imap4Set, *incomingIAPSet, *parameters);
+        TImapAccount imapAccountId = account->CreateImapAccountL(parameters->iMailboxName->Des(), *imap4Set, *incomingIAPSet, EFalse);
+        TSmtpAccount smtpAccountId = account->CreateSmtpAccountL(imapAccountId, *smtpSet, *outgoingIAPSet, EFalse);
+        account->SetDefaultSmtpAccountL(smtpAccountId);
+
+        iEntryIds.Append( imapAccountId.iImapAccountId );
+        iEntryIds.Append( imapAccountId.iImapService );
+        iEntryIds.Append( imapAccountId.iSmtpService );      
+        iEntryIds.Append( smtpAccountId.iSmtpAccountId );
+        iEntryIds.Append( smtpAccountId.iSmtpService );
+        iEntryIds.Append( smtpAccountId.iRelatedService );
+        
+        StoreIMEIToEntryL( imapAccountId.iImapService );
+        StoreIMEIToEntryL( smtpAccountId.iSmtpService );
+        }
+    else
+        {
+        // Get POP settings:
+        PopulatePopSettingsL(*account, *pop3Set, *incomingIAPSet, *parameters);
+        TPopAccount popAccountId = account->CreatePopAccountL(parameters->iMailboxName->Des(), *pop3Set, *incomingIAPSet, EFalse);
+        TSmtpAccount smtpAccountId = account->CreateSmtpAccountL(popAccountId, *smtpSet, *outgoingIAPSet, EFalse);     
+        account->SetDefaultSmtpAccountL(smtpAccountId);
+        
+        iEntryIds.Append( popAccountId.iPopAccountId );
+        iEntryIds.Append( popAccountId.iPopService );
+        iEntryIds.Append( popAccountId.iSmtpService );
+        iEntryIds.Append( smtpAccountId.iSmtpAccountId );
+        iEntryIds.Append( smtpAccountId.iSmtpService );
+        iEntryIds.Append( smtpAccountId.iRelatedService );
+
+        StoreIMEIToEntryL( popAccountId.iPopService );
+        StoreIMEIToEntryL( smtpAccountId.iSmtpService );
+        }  
+    CleanupStack::PopAndDestroy(6); //imap4Set, pop3Set, smtpSet, outgoingIAPSet, incomingIAPSet, account 
+        
+    return err;
+    }
+
+void CCreatorMailboxes::PopulateImapSettingsL( 
+            CEmailAccounts& aEmailAccount, 
+            CImImap4Settings& aImapSettings, 
+            CImIAPPreferences& aIApSettings, 
+            const CMailboxesParameters& aParameters )
+    {
+    // Get default settings first:
+    aEmailAccount.PopulateDefaultImapSettingsL(aImapSettings, aIApSettings);
+    
+    TImIAPChoice iapChoice;
+    iapChoice.iIAP = 0;
+    if( aParameters.iIncomingConnectionMethod == 0 || 
+        aParameters.iIncomingConnectionMethod->Des().Length() == 0 )
+        {
+        TRAP_IGNORE( iapChoice.iIAP = iEngine->AccessPointNameToIdL( KInternet ));
+        }
+    else
+        {
+        TRAP_IGNORE( iapChoice.iIAP = iEngine->AccessPointNameToIdL( aParameters.iIncomingConnectionMethod->Des()));
+        }
+    iapChoice.iDialogPref = ECommDbDialogPrefDoNotPrompt;
+    aIApSettings.AddIAPL(iapChoice);
+    
+    TBuf8<256> buf8;
+    if( aParameters.iIncomingLoginName && aParameters.iIncomingLoginName->Length() > 0 )                
+        buf8.Copy(aParameters.iIncomingLoginName->Des());
+    else
+        buf8.Copy(iEngine->RandomString(CCreatorEngine::EFirstName));
+    aImapSettings.SetLoginNameL(buf8);  //8
+    
+    if( aParameters.iIncomingPassword && aParameters.iIncomingPassword->Length() > 0 )
+        buf8.Copy(aParameters.iIncomingPassword->Des());    
+    else
+        buf8.Copy(iEngine->RandomString(CCreatorEngine::EFirstName));
+    aImapSettings.SetPasswordL(buf8);  //8
+    
+    if( aParameters.iIncomingFolderPath && aParameters.iIncomingFolderPath->Length() > 0 )
+        {
+        buf8.Copy(aParameters.iIncomingFolderPath->Des());
+        aImapSettings.SetFolderPathL(buf8);
+        }
+    
+    if( aParameters.iPathSeparator && aParameters.iPathSeparator->Length() > 0 )
+        aImapSettings.SetPathSeparator(aParameters.iIncomingFolderPath->Des()[0]);
+    
+    aImapSettings.SetDisconnectedUserMode(aParameters.iDisconnectedUserMode);
+    aImapSettings.SetSynchronise(aParameters.iSyncType);
+    aImapSettings.SetSubscribe(aParameters.iSubscribeType);
+    aImapSettings.SetAutoSendOnConnect(aParameters.iAutoSendOnConnect);
+    
+    if(aParameters.iMaxEmailSize != KUndef )
+        aImapSettings.SetMaxEmailSize(aParameters.iMaxEmailSize);
+    
+    aImapSettings.SetDeleteEmailsWhenDisconnecting(aParameters.iDeleteEmailsAtDisconnect);
+    aImapSettings.SetAcknowledgeReceipts(aParameters.iAcknowledgeReceipts);
+            
+    if(aParameters.iGetEmailOptions == CMailboxesParameters::EGetBodyText )
+        aImapSettings.SetGetMailOptions(EGetImap4EmailBodyText);
+    else if(aParameters.iGetEmailOptions == CMailboxesParameters::EGetBodyTextAndAttachments )
+        aImapSettings.SetGetMailOptions(EGetImap4EmailBodyTextAndAttachments);
+    else if(aParameters.iGetEmailOptions == CMailboxesParameters::EGetAttachments )
+        aImapSettings.SetGetMailOptions(EGetImap4EmailAttachments);
+    else if(aParameters.iGetEmailOptions == CMailboxesParameters::EGetBodyAlternativeText )
+        aImapSettings.SetGetMailOptions(EGetImap4EmailBodyAlternativeText);
+    else
+        aImapSettings.SetGetMailOptions(EGetImap4EmailHeaders); // Default
+    
+    if( aParameters.iInboxSyncLimit != KUndef )
+        aImapSettings.SetInboxSynchronisationLimit(aParameters.iInboxSyncLimit);
+    
+    if( aParameters.iMailboxSyncLimit != KUndef )
+        aImapSettings.SetMailboxSynchronisationLimit(aParameters.iMailboxSyncLimit);
+    
+    aImapSettings.SetUpdatingSeenFlags(aParameters.iMarkSeenInSync);
+    
+    if( aParameters.iSyncRate != KUndef )
+        aImapSettings.SetSyncRateL(aParameters.iSyncRate);
+    
+    if( aParameters.iAttachmentFetchSize != KUndef )
+        aImapSettings.SetFetchSizeL(aParameters.iAttachmentFetchSize);
+    
+    aImapSettings.SetImapIdle(aParameters.iImapIdleCommand);
+    if( aParameters.iImapIdleTimeout != KUndef )
+        aImapSettings.SetImapIdleTimeoutL(aParameters.iImapIdleTimeout);
+    
+    if( aParameters.iBodyTextSizeLimit != KUndef )
+        aImapSettings.SetBodyTextSizeLimitL(aParameters.iBodyTextSizeLimit);
+    
+    if( aParameters.iAttachmentSizeLimit != KUndef )
+        aImapSettings.SetAttachmentSizeLimitL(aParameters.iAttachmentSizeLimit);
+    
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+    aImapSettings.SetUseExpunge(aParameters.iEnableExpungeMode);
+#endif
+    
+    if(aParameters.iIncomingServerName && aParameters.iIncomingServerName->Length() > 0 )
+        aImapSettings.SetServerAddressL(aParameters.iIncomingServerName->Des());
+    else
+        aImapSettings.SetServerAddressL(KDefaultIncomingServer);
+        
+    if( aParameters.iIncomingPort != KUndef )
+        aImapSettings.SetPort(aParameters.iIncomingPort);                 
+      
+    aImapSettings.SetSecureSockets(aParameters.iIncomingSecureSockets);
+    aImapSettings.SetSSLWrapper(aParameters.iIncomingSSLWrapper);
+    }
+
+void CCreatorMailboxes::PopulatePopSettingsL( 
+            CEmailAccounts& aEmailAccount, 
+            CImPop3Settings& aPopSettings, 
+            CImIAPPreferences& aIApSettings, 
+            const CMailboxesParameters& aParameters )
+    {
+    aEmailAccount.PopulateDefaultPopSettingsL(aPopSettings, aIApSettings);
+    
+    TImIAPChoice iapChoice;
+    iapChoice.iIAP = 0;
+    if( aParameters.iIncomingConnectionMethod == 0 || 
+        aParameters.iIncomingConnectionMethod->Des().Length() == 0 )
+        {
+        TRAP_IGNORE( iapChoice.iIAP = iEngine->AccessPointNameToIdL( KInternet ));
+        }
+    else
+        {
+        TRAP_IGNORE( iapChoice.iIAP = iEngine->AccessPointNameToIdL( aParameters.iIncomingConnectionMethod->Des() ));
+        }
+    iapChoice.iDialogPref = ECommDbDialogPrefDoNotPrompt;
+    aIApSettings.AddIAPL(iapChoice);
+    
+    TBuf8<256> buf8;
+    if( aParameters.iIncomingLoginName && aParameters.iIncomingLoginName->Length() > 0 )                
+        buf8.Copy(aParameters.iIncomingLoginName->Des());
+    else
+        buf8.Copy(iEngine->RandomString(CCreatorEngine::EFirstName));
+    aPopSettings.SetLoginNameL(buf8);  //8
+        
+    if( aParameters.iIncomingPassword && aParameters.iIncomingPassword->Length() > 0 )
+        buf8.Copy(aParameters.iIncomingPassword->Des());    
+    else
+        buf8.Copy(iEngine->RandomString(CCreatorEngine::EFirstName));
+    aPopSettings.SetPasswordL(buf8);  //8
+    
+    aPopSettings.SetAutoSendOnConnect( aParameters.iAutoSendOnConnect );
+    aPopSettings.SetApop( aParameters.iUseApop );
+    aPopSettings.SetDisconnectedUserMode( aParameters.iDisconnectedUserMode );
+    aPopSettings.SetDeleteEmailsWhenDisconnecting( aParameters.iDeleteEmailsAtDisconnect );
+    aPopSettings.SetAcknowledgeReceipts( aParameters.iAcknowledgeReceipts );
+    
+    if( aParameters.iMaxEmailSize != KUndef )
+        aPopSettings.SetMaxEmailSize(aParameters.iMaxEmailSize);
+    
+    if(aParameters.iGetEmailOptions != CMailboxesParameters::EGetHeaders && 
+            aParameters.iGetEmailOptions != CMailboxesParameters::EUndef )
+        {
+        aPopSettings.SetGetMailOptions(EGetPop3EmailMessages);
+        aPopSettings.SetPopulationLimitL( -1 ); // -1 = body and attachment
+        }
+    else
+        {
+        aPopSettings.SetGetMailOptions(EGetPop3EmailHeaders); // Default
+        aPopSettings.SetPopulationLimitL( -2 ); // -2 = headers only
+        }
+    
+    if( aParameters.iInboxSyncLimit != KUndef )
+        {
+        aPopSettings.SetInboxSynchronisationLimit(aParameters.iInboxSyncLimit);
+        }
+    
+    if(aParameters.iIncomingServerName && aParameters.iIncomingServerName->Length() > 0 )
+        aPopSettings.SetServerAddressL(aParameters.iIncomingServerName->Des());
+    else
+        aPopSettings.SetServerAddressL(KDefaultIncomingServer);
+            
+    if( aParameters.iIncomingPort != KUndef )
+        aPopSettings.SetPort(aParameters.iIncomingPort);                 
+          
+    aPopSettings.SetSecureSockets(aParameters.iIncomingSecureSockets);
+    aPopSettings.SetSSLWrapper(aParameters.iIncomingSSLWrapper);    
+    }
+
+void CCreatorMailboxes::PopulateSmtpSettingsL( 
+        CEmailAccounts& aEmailAccount, 
+        CImSmtpSettings& aSmtpSettings, 
+        CImIAPPreferences& aIApSettings, 
+        const CMailboxesParameters& aParameters )
+    {    
+    // Get default settings first: 
+    aEmailAccount.PopulateDefaultSmtpSettingsL(aSmtpSettings, aIApSettings);
+    TImIAPChoice iapChoice;
+    iapChoice.iIAP = 0;
+    if( aParameters.iOutgoingConnectionMethod == 0 || 
+        aParameters.iOutgoingConnectionMethod->Des().Length() == 0 )
+        {
+        TRAP_IGNORE( iapChoice.iIAP = iEngine->AccessPointNameToIdL( KInternet ));
+        }
+    else
+        {
+        TRAP_IGNORE( iapChoice.iIAP = iEngine->AccessPointNameToIdL( aParameters.iOutgoingConnectionMethod->Des() ));
+        }
+    iapChoice.iDialogPref = ECommDbDialogPrefDoNotPrompt;
+    aIApSettings.AddIAPL(iapChoice);
+    
+    // set SMTP preferences
+    if( aParameters.iOwnEmailAlias && aParameters.iOwnEmailAlias->Length() > 0 )
+        aSmtpSettings.SetEmailAliasL(aParameters.iOwnEmailAlias->Des());
+    
+    if( aParameters.iOwnEmailAddress && aParameters.iOwnEmailAddress->Length() > 0 )    
+        aSmtpSettings.SetEmailAddressL(aParameters.iOwnEmailAddress->Des());
+    
+    if( aParameters.iReplyToAddress && aParameters.iReplyToAddress->Length() > 0 )
+        aSmtpSettings.SetReplyToAddressL(aParameters.iReplyToAddress->Des());
+    
+    if( aParameters.iReceiptAddress && aParameters.iReceiptAddress->Length() > 0 )
+        aSmtpSettings.SetReceiptAddressL(aParameters.iReceiptAddress->Des());    
+    
+    aSmtpSettings.SetBodyEncoding(EMsgOutboxMIME);
+    aSmtpSettings.SetAddVCardToEmail(aParameters.iAddVCard);
+    aSmtpSettings.SetAddSignatureToEmail(aParameters.iIncludeSignature);
+    aSmtpSettings.SetRequestReceipts(aParameters.iRequestReceipts);
+    aSmtpSettings.SetSendCopyToSelf(aParameters.iSendCopyToSelf);    
+    aSmtpSettings.SetSendMessageOption(aParameters.iSendOption);        
+            
+    TBuf8<256> buf8;
+    if( aParameters.iOutgoingLoginName && aParameters.iOutgoingLoginName->Length() > 0 )
+        {
+        buf8.Copy(aParameters.iOutgoingLoginName->Des());
+        aSmtpSettings.SetLoginNameL(buf8);  //8
+        }
+    
+    if( aParameters.iOutgoingPassword && aParameters.iOutgoingPassword->Length() > 0)
+        {
+        buf8.Copy(aParameters.iOutgoingPassword->Des());
+        aSmtpSettings.SetPasswordL(buf8);  //8
+        }
+    
+    aSmtpSettings.SetSMTPAuth(aParameters.iSmtpAuth);
+    if( aParameters.iToCCIncludeLimit != KUndef )
+         aSmtpSettings.SetToCcIncludeLimitL(aParameters.iToCCIncludeLimit);
+    
+    if( aParameters.iOutgoingServerName && aParameters.iOutgoingServerName->Length() > 0 )
+        aSmtpSettings.SetServerAddressL(aParameters.iOutgoingServerName->Des());
+    else
+        aSmtpSettings.SetServerAddressL(KDefaultOutgoingServer);
+    
+    if( aParameters.iOutgoingPort != KUndef )
+        aSmtpSettings.SetPort(aParameters.iOutgoingPort);
+                
+    aSmtpSettings.SetSecureSockets(aParameters.iOutgoingSecureSockets);
+    aSmtpSettings.SetSSLWrapper(aParameters.iOutgoingSSLWrapper);
+    }
+
+//----------------------------------------------------------------------------
+
+void CCreatorMailboxes::StoreIMEIToEntryL(const TMsvId aMailboxId)
+    {
+    LOGSTRING("Creator: CCreatorMailboxes::StoreIMEIToEntryL");
+
+    CMsvSession* session = CMsvSession::OpenSyncL(*this);
+    CleanupStack::PushL(session);
+    
+    CMsvEntry* centry = session->GetEntryL(aMailboxId);
+    CleanupStack::PushL(centry);
+
+    TMsvEntry tentry = centry->Entry();
+    tentry.iDescription.Set(iIMEI);
+    centry->ChangeL(tentry);
+
+    CleanupStack::PopAndDestroy(2); // centry, session
+    }
+
+//----------------------------------------------------------------------------
+
+void CCreatorMailboxes::GetIMEIFromThePhoneL()
+    {
+    LOGSTRING("Creator: CCreatorMailboxes::GetIMEIFromThePhoneL");
+
+#ifndef __WINS__
+
+    RTelServer telServer;
+    User::LeaveIfError( telServer.Connect() );
+    CleanupClosePushL(telServer);
+
+    TInt numPhones = 0;
+    User::LeaveIfError( telServer.EnumeratePhones( numPhones ) );
+    if ( numPhones < 1 )
+        {
+        User::Leave( KErrNotFound );
+        }
+    RTelServer::TPhoneInfo info;
+    User::LeaveIfError( telServer.GetPhoneInfo( 0, info ) );
+    RMobilePhone mobilePhone;
+    User::LeaveIfError( mobilePhone.Open( telServer, info.iName ) );
+    CleanupClosePushL( mobilePhone );
+
+    //mobilePhone.Initialise();
+    TUint32 identityCaps;
+    User::LeaveIfError( mobilePhone.GetIdentityCaps( identityCaps ) );
+
+    if ( identityCaps & RMobilePhone::KCapsGetSerialNumber )
+        {
+        TRequestStatus status;
+        RMobilePhone::TMobilePhoneIdentityV1 mobilePhoneIdentity;
+
+        mobilePhone.GetPhoneId( status, mobilePhoneIdentity );
+
+        User::WaitForRequest( status );
+        User::LeaveIfError( status.Int() );
+
+        iIMEI.Copy( mobilePhoneIdentity.iSerialNumber );
+        }
+    else
+        {
+        User::Leave( KErrNotSupported );
+        }
+
+    CleanupStack::PopAndDestroy( &mobilePhone );
+    CleanupStack::PopAndDestroy( &telServer );
+
+#else
+
+    // use fixed IMEI for emulator
+    _LIT( KIMAEmulatorImei, "123456789012345" );
+    iIMEI.Copy( KIMAEmulatorImei );
+
+#endif // __WINS__
+
+    }
+    
+//----------------------------------------------------------------------------
+
+void CCreatorMailboxes::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) // from MMsvSessionObserver
+    {
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorMailboxes::DeleteAllL()
+    {
+    LOGSTRING("Creator: CCreatorMailboxes::DeleteAllL");
+    
+    CEmailAccounts* accountMgr = CEmailAccounts::NewLC();
+    
+    // Delete pop accounts
+    RArray<TPopAccount> popAccountsToDelete;
+    CleanupClosePushL( popAccountsToDelete );
+    accountMgr->GetPopAccountsL( popAccountsToDelete );
+    for ( TInt i = 0; i < popAccountsToDelete.Count(); i++ )
+        {
+        accountMgr->DeletePopAccountL( popAccountsToDelete[i] );
+        }
+    CleanupStack::PopAndDestroy( &popAccountsToDelete );
+    
+    // Delete imap accounts
+    RArray<TImapAccount> imapAccountsToDelete;
+    CleanupClosePushL( imapAccountsToDelete );
+    accountMgr->GetImapAccountsL( imapAccountsToDelete );
+    for ( TInt i = 0; i < imapAccountsToDelete.Count(); i++ )
+        {
+        accountMgr->DeleteImapAccountL( imapAccountsToDelete[i] );
+        }
+    CleanupStack::PopAndDestroy( &imapAccountsToDelete );
+    
+    // Delete smtp accounts
+    RArray<TSmtpAccount> smtpAccountsToDelete;
+    CleanupClosePushL( smtpAccountsToDelete );
+    accountMgr->GetSmtpAccountsL( smtpAccountsToDelete );
+    for ( TInt i = 0; i < smtpAccountsToDelete.Count(); i++ )
+        {
+        accountMgr->DeleteSmtpAccountL( smtpAccountsToDelete[i] );
+        }
+    CleanupStack::PopAndDestroy( &smtpAccountsToDelete );
+
+    iEntryIds.Reset();
+    
+    // all entries deleted, remove the Mailbox related registry
+    iEngine->RemoveStoreL( KUidDictionaryUidMailbox );
+    
+    CleanupStack::PopAndDestroy( accountMgr ); 
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorMailboxes::DeleteAllCreatedByCreatorL()
+    {
+    LOGSTRING("Creator: CCreatorMailboxes::DeleteAllCreatedByCreatorL");
+    
+    iEntryIds.Reset();
+    CEmailAccounts* accountMgr = CEmailAccounts::NewLC();
+    
+    // fetch ids of entries created by Creator
+    iEngine->ReadEntryIdsFromStoreL( iEntryIds, KUidDictionaryUidMailbox );
+    
+    TInt i(0);
+    while ( i < iEntryIds.Count() && iEntryIds.Count() > 6 ) 
+        {
+        // there should be at least 7 items in the array:
+        // one for mailbox type
+        // 3 for imap OR pop ids
+        // 3 for smtp ids
+
+        // delete entries
+        
+        TInt type = iEntryIds[i++]; // TMailboxType
+        if ( type == EMailboxPOP3 )
+            {
+            TPopAccount popAccount;
+            popAccount.iPopAccountId = iEntryIds[i++];
+            popAccount.iPopService = iEntryIds[i++];            
+            popAccount.iSmtpService = iEntryIds[i++];
+            TRAP_IGNORE( accountMgr->DeletePopAccountL( popAccount ) );            
+            }
+        else if ( type == EMailboxIMAP4 )
+            {
+            TImapAccount imapAccount;
+            imapAccount.iImapAccountId = iEntryIds[i++];
+            imapAccount.iImapService = iEntryIds[i++];
+            imapAccount.iImapService = iEntryIds[i++];
+            TRAP_IGNORE( accountMgr->DeleteImapAccountL( imapAccount ) );
+            }
+        else 
+            {
+            // ignore unknown mailbox types
+            i +=3;
+            }
+        
+        // There should be one smtp service for each pop and imap service
+        TSmtpAccount smtpAccount;
+        smtpAccount.iSmtpAccountId = iEntryIds[i++];
+        smtpAccount.iSmtpService = iEntryIds[i++];
+        smtpAccount.iRelatedService = iEntryIds[i++];
+        TRAP_IGNORE( accountMgr->DeleteSmtpAccountL( smtpAccount ) );
+        }
+
+    // reset must be done here, because iEntryIds is stored in destructor
+    iEntryIds.Reset();
+    
+    // all entries deleted, remove the mailbox related registry
+    iEngine->RemoveStoreL( KUidDictionaryUidMailbox );
+
+    CleanupStack::PopAndDestroy( accountMgr ); 
+    }
+//----------------------------------------------------------------------------
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_mailboxelement.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,495 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include "creator_mailboxelement.h"
+#include "creator_traces.h"
+#include "creator_mailbox.h"
+
+using namespace creatormailbox;
+
+/*
+ * 
+ */
+CCreatorMailboxElement* CCreatorMailboxElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext )
+    {
+    CCreatorMailboxElement* self = new (ELeave) CCreatorMailboxElement(aEngine);
+    CleanupStack::PushL(self);
+    self->ConstructL(aName, aContext);
+    CleanupStack::Pop(self);
+    return self;
+    }
+/*
+ * 
+ */
+CCreatorMailboxElement::CCreatorMailboxElement(CCreatorEngine* aEngine) 
+: 
+CCreatorScriptElement(aEngine)
+    {
+    iIsCommandElement = ETrue;
+    }
+
+TBool CCreatorMailboxElement::SetIntegerParamL(const TDesC& aElemName, const TDesC& aElemContent, CMailboxesParameters* param, TBool aSetRandom )
+    {    
+    _LIT( KAll, "all");
+    
+    if( aElemName == Kincomingport )
+        {
+        if( aSetRandom )
+            param->iIncomingPort = iEngine->RandomNumber(25, 500);
+        else        
+            param->iIncomingPort = ConvertStrToIntL(aElemContent);
+        }
+    else if( aElemName == Kattachmentsizelimit )
+        {
+        if( aSetRandom )
+            param->iAttachmentSizeLimit = iEngine->RandomNumber(1, KMaxTInt);
+        else
+            param->iAttachmentSizeLimit = ConvertStrToIntL(aElemContent);
+        }        
+    else if( aElemName == Kbodytextsizelimit )
+        {
+        if( aSetRandom )
+            param->iBodyTextSizeLimit = iEngine->RandomNumber(1, KMaxTInt);
+        else
+            param->iBodyTextSizeLimit = ConvertStrToIntL(aElemContent);
+        }     
+    else if( aElemName == Kattachmentfetchsize )
+        {
+        if( aSetRandom )
+            param->iAttachmentFetchSize = iEngine->RandomNumber(1, 40960);
+        else            
+            param->iAttachmentFetchSize = ConvertStrToIntL(aElemContent);
+        }
+    else if( aElemName == Kimapidletimeout )
+        {
+        if( aSetRandom )
+            param->iImapIdleTimeout = iEngine->RandomNumber(10, 2000);
+        else
+            param->iImapIdleTimeout = ConvertStrToIntL(aElemContent);
+        }
+    else if( aElemName == Kmaxemailsize )
+        {
+        if( aSetRandom )
+            param->iMaxEmailSize =  iEngine->RandomNumber(1024, KMaxTInt);
+        else
+            param->iMaxEmailSize = ConvertStrToIntL(aElemContent);
+        }
+    else if( aElemName == Ksyncrate )
+        {
+        if( aSetRandom )
+            param->iSyncRate = iEngine->RandomNumber(10, 500);
+        else
+            param->iSyncRate = ConvertStrToIntL(aElemContent);
+        }
+    else if( aElemName == Kinboxsynclimit )
+        {
+        if( aSetRandom )
+            param->iInboxSyncLimit = iEngine->RandomNumber(-1, 256);
+        else if( CompareIgnoreCase(aElemContent, KAll) == 0 )
+            param->iInboxSyncLimit = -1;
+        else
+            param->iInboxSyncLimit = ConvertStrToIntL(aElemContent);
+        }
+    else if( aElemName == Kmailboxsynclimit )
+        {
+        if( aSetRandom )
+            param->iMailboxSyncLimit = iEngine->RandomNumber(-1, 256);
+        else if( CompareIgnoreCase(aElemContent, KAll) == 0 )
+            param->iMailboxSyncLimit = -1;
+        else
+            param->iMailboxSyncLimit = ConvertStrToIntL(aElemContent);
+        }        
+    else if( aElemName == Koutgoingport )
+        {
+        if( aSetRandom )
+            param->iOutgoingPort = KDefaultSmtpPort;
+        else
+            param->iOutgoingPort = ConvertStrToIntL(aElemContent);
+        }
+    else if( aElemName == Ktoccincludelimit )
+        {
+        if( aSetRandom )
+            param->iToCCIncludeLimit = iEngine->RandomNumber(0, 30);
+        else
+            param->iToCCIncludeLimit = ConvertStrToIntL(aElemContent);
+        }
+    else
+        return EFalse;
+    
+    return ETrue;
+    }
+
+TBool CCreatorMailboxElement::GetBooleanValueL(const TDesC& aElemContent, TBool aSetRandom)
+    {
+    if( aSetRandom )
+        return iEngine->RandomNumber(0,1) == 1;
+    
+    return ConvertStrToBooleanL(aElemContent);
+    }
+
+TBool CCreatorMailboxElement::SetBooleanParamL(const TDesC& aElemName, const TDesC& aElemContent, CMailboxesParameters* param, TBool aSetRandom )
+    {  
+    TBool val = GetBooleanValueL(aElemContent, aSetRandom);
+    if( aElemName == Kincomingsslwrapper )
+        param->iIncomingSSLWrapper = val;
+    else if( aElemName == Kincomingsecuresockets )
+        param->iIncomingSecureSockets = val;
+    else if( aElemName == Kacknowledgereceipts )
+        param->iAcknowledgeReceipts = val;
+    else if( aElemName == Kautosendonconnect )
+        param->iAutoSendOnConnect = val;
+    else if( aElemName == Kdeletemailsatdisconnect )
+        param->iDeleteEmailsAtDisconnect = val;
+    else if( aElemName == Kimapidlecommand )
+        param->iImapIdleCommand = val;
+    else if( aElemName == Kmarkseeninsync )
+        param->iMarkSeenInSync = val;
+    else if( aElemName == Kenableexpungemode )
+        param->iEnableExpungeMode = val;
+    else if( aElemName == Kuseapopsecurelogin )
+        param->iUseApop = val;
+    else if( aElemName == Kdisconnectedusermode )
+        param->iDisconnectedUserMode = val;
+    else if( aElemName == Koutgoingsslwrapper )
+        param->iOutgoingSSLWrapper = val;
+    else if( aElemName == Koutgoingsecuresockets )
+        param->iOutgoingSecureSockets = val;
+    else if( aElemName == Kincludesignature )
+        param->iIncludeSignature = val;
+    else if( aElemName == Kaddvcard )
+        param->iAddVCard = val;
+    else if( aElemName == Krequestreceipts )
+        param->iRequestReceipts = val;
+    else if( aElemName == Ksmtpauth )
+        param->iSmtpAuth = val;
+    else
+        return EFalse;
+
+    return ETrue;
+    }
+
+TBool CCreatorMailboxElement::SetTextParamL(const TDesC& aElemName, const TDesC& aElemContent, CMailboxesParameters* param, TBool aSetRandom )
+    {   
+    _LIT(KIncomingSrvPrefix, "mail.");
+    _LIT(KOutgoingSrvPrefix, "smtp.");
+    _LIT(KSrvPostfix, ".com");
+    _LIT(KDefaultConnMethod, "internet");
+    
+    if( aElemName == Kname )
+        {
+        if( aSetRandom )
+            {
+            TPtrC company(iEngine->RandomString(CCreatorEngine::ECompany));
+            SetContentToTextParamL(param->iMailboxName, company);
+            }
+        else
+            SetContentToTextParamL(param->iMailboxName, aElemContent);
+        }
+    else if( aElemName == Kincomingloginname )
+        {
+        if( aSetRandom )
+            {
+            TPtrC random(iEngine->RandomString(CCreatorEngine::EFirstName));
+            SetContentToTextParamL(param->iIncomingLoginName, random);
+            param->iIncomingLoginName->Des().LowerCase();
+            }
+        else
+            SetContentToTextParamL(param->iIncomingLoginName, aElemContent);
+        }
+    else if( aElemName == Kincomingpassword )
+        {
+        if( aSetRandom )
+            {
+            TPtrC random(iEngine->RandomString(CCreatorEngine::EFirstName));
+            SetContentToTextParamL(param->iIncomingPassword, random);
+            param->iIncomingPassword->Des().LowerCase();
+            }
+        else
+            SetContentToTextParamL(param->iIncomingPassword, aElemContent);
+        }
+    else if( aElemName == Kincomingservername )
+        {
+        if( aSetRandom )
+            {
+            TPtrC random(iEngine->RandomString(CCreatorEngine::ECompany));
+            HBufC* srvName = HBufC::NewLC(KIncomingSrvPrefix().Length()+random.Length()+KSrvPostfix().Length());
+            srvName->Des().Copy(KIncomingSrvPrefix);
+            srvName->Des().Append(random);
+            srvName->Des().Append(KSrvPostfix);
+            SetContentToTextParamL(param->iIncomingServerName, srvName->Des());
+            CleanupStack::PopAndDestroy(); // srvName
+            }
+        else
+            SetContentToTextParamL(param->iIncomingServerName, aElemContent);
+        }
+    else if( aElemName == Kincomingconnectionmethod )
+        {
+        if( aSetRandom )                        
+            SetContentToTextParamL(param->iIncomingConnectionMethod, KDefaultConnMethod);            
+        else
+            SetContentToTextParamL(param->iIncomingConnectionMethod, aElemContent);
+        }
+    else if( aElemName == Kincomingfolderpath )
+        SetContentToTextParamL(param->iIncomingFolderPath, aElemContent);
+    else if( aElemName == Kpathseparator )
+        SetContentToTextParamL(param->iPathSeparator, aElemContent);
+    else if( aElemName == Koutgoingloginname )
+        {
+        if( aSetRandom )
+            {
+            TPtrC random(iEngine->RandomString(CCreatorEngine::EFirstName));
+            SetContentToTextParamL(param->iOutgoingLoginName, random);
+            param->iOutgoingLoginName->Des().LowerCase();
+            }
+        else
+            SetContentToTextParamL(param->iOutgoingLoginName, aElemContent);
+        }
+    else if( aElemName == Koutgoingpassword )
+        {
+        if( aSetRandom )
+            {
+            TPtrC random(iEngine->RandomString(CCreatorEngine::EFirstName));
+            SetContentToTextParamL(param->iOutgoingPassword, random);
+            param->iOutgoingPassword->Des().LowerCase();
+            }
+        else
+            SetContentToTextParamL(param->iOutgoingPassword, aElemContent);
+        }
+    else if( aElemName == Koutgoingservername )
+        {
+        if( aSetRandom )
+            {
+            TPtrC random(iEngine->RandomString(CCreatorEngine::ECompany));
+            HBufC* srvName = HBufC::NewLC(KOutgoingSrvPrefix().Length()+random.Length()+KSrvPostfix().Length());
+            srvName->Des().Copy(KOutgoingSrvPrefix);
+            srvName->Des().Append(random);
+            srvName->Des().Append(KSrvPostfix);
+            SetContentToTextParamL(param->iOutgoingServerName, srvName->Des());
+            CleanupStack::PopAndDestroy(); // srvName
+            }
+        else
+            SetContentToTextParamL(param->iOutgoingServerName, aElemContent);
+        }
+    else if( aElemName == Koutgoingconnectionmethod )
+        {
+        if( aSetRandom )            
+            SetContentToTextParamL(param->iOutgoingConnectionMethod, KDefaultConnMethod);            
+        else
+            SetContentToTextParamL(param->iOutgoingConnectionMethod, aElemContent);
+        }
+    else if( aElemName == Kownemail )
+        {
+        if( aSetRandom )
+            {
+            TDesC* email = iEngine->CreateEmailAddressLC();
+            SetContentToTextParamL(param->iOwnEmailAddress, *email);
+            CleanupStack::PopAndDestroy(); // email
+            }
+        else
+            SetContentToTextParamL(param->iOwnEmailAddress, aElemContent);
+        }
+    else if( aElemName == Kemailalias )
+        {
+        if( aSetRandom )
+            {
+            _LIT(KSpace, " ");
+            TPtrC firstName(iEngine->RandomString(CCreatorEngine::EFirstName));
+            TPtrC lastName(iEngine->RandomString(CCreatorEngine::ESurname));
+            HBufC* alias = HBufC::NewLC(firstName.Length() + lastName.Length() + KSpace().Length());
+            alias->Des().Copy(firstName);
+            alias->Des().Append(KSpace);
+            alias->Des().Append(lastName);
+            SetContentToTextParamL(param->iOwnEmailAlias, alias->Des());
+            CleanupStack::PopAndDestroy(); // alias
+            }
+        else        
+            SetContentToTextParamL(param->iOwnEmailAlias, aElemContent);
+        }
+    else if( aElemName == Kreceiptaddress )
+        {
+        if( aSetRandom )
+            {
+            TDesC* email = iEngine->CreateEmailAddressLC();
+            SetContentToTextParamL(param->iReceiptAddress, *email);
+            CleanupStack::PopAndDestroy(); // email
+            }
+        else
+            SetContentToTextParamL(param->iReceiptAddress, aElemContent);
+        }
+    else if( aElemName == Kreplytoaddress )
+        {
+        if( aSetRandom )
+            {
+            TDesC* email = iEngine->CreateEmailAddressLC();
+            SetContentToTextParamL(param->iReceiptAddress, *email);
+            CleanupStack::PopAndDestroy(); // email
+            }
+        else
+            SetContentToTextParamL(param->iReplyToAddress, aElemContent);
+        }
+    else
+        return EFalse;
+    
+    return ETrue;
+    }
+
+TBool CCreatorMailboxElement::SetEnumParamL(const TDesC& aElemName, const TDesC& aElemContent, CMailboxesParameters* param, TBool aSetRandom )
+    {
+    // Get email options:
+    if( aElemName == Kgetemailoptions )
+        {
+        if( aSetRandom )
+            param->iGetEmailOptions = (CMailboxesParameters::TGetEmailOption) iEngine->RandomNumber(
+                                                    CMailboxesParameters::EGetHeaders, 
+                                                    CMailboxesParameters::EGetEmailOptionLast-1);
+        else if( CompareIgnoreCase(aElemContent, Kgetheaders ) == 0 )
+            param->iGetEmailOptions = CMailboxesParameters::EGetHeaders;
+        else if( CompareIgnoreCase(aElemContent, Kgetbodytext) == 0 )
+            param->iGetEmailOptions = CMailboxesParameters::EGetBodyText;
+        else if( CompareIgnoreCase(aElemContent, Kgetbodytextandattachments) == 0 )
+            param->iGetEmailOptions = CMailboxesParameters::EGetBodyTextAndAttachments;
+        else if( CompareIgnoreCase(aElemContent, Kgetattachments) == 0 )
+            param->iGetEmailOptions = CMailboxesParameters::EGetAttachments;
+        else if( CompareIgnoreCase(aElemContent, Kgetbodyalternativetext) == 0 )
+            param->iGetEmailOptions = CMailboxesParameters::EGetBodyAlternativeText;
+        else 
+            param->iGetEmailOptions = CMailboxesParameters::EUndef;
+        }
+    
+    // Subscribe type:
+    else if( aElemName == Ksubscribetype )
+        {
+        if( aSetRandom )
+            param->iSubscribeType = (TFolderSubscribeType) iEngine->RandomNumber( EUpdateNeither, EUpdateBoth );
+        else if( CompareIgnoreCase( aElemContent, Kupdatelocal) == 0 )
+            param->iSubscribeType = EUpdateLocal;            
+        else if( CompareIgnoreCase( aElemContent, Kupdateremote) == 0 )
+            param->iSubscribeType = EUpdateRemote;
+        else if( CompareIgnoreCase( aElemContent, Kupdateboth) == 0 )
+            param->iSubscribeType = EUpdateBoth;
+        else
+            param->iSubscribeType = EUpdateNeither;
+        }
+    
+    // Folder synchronization type:
+    else if( aElemName == Kfoldersynctype)
+        {
+        if( aSetRandom )
+            param->iSyncType = (TFolderSyncType) iEngine->RandomNumber(EUseCombination, EUseRemote);
+        else if( CompareIgnoreCase( aElemContent, Kuselocal) == 0 )
+            param->iSyncType = EUseLocal;
+        else if( CompareIgnoreCase( aElemContent, Kuseremote) == 0 )
+            param->iSyncType = EUseRemote;
+        else
+            param->iSyncType = EUseCombination;
+        }
+     
+    // Send copy to self option:
+    else if( aElemName == Kcopytoself )
+        {
+        if( aSetRandom )
+            param->iSendCopyToSelf = (TImSMTPSendCopyToSelf) iEngine->RandomNumber(ESendNoCopy, ESendCopyAsBccRecipient);
+        else if( CompareIgnoreCase( aElemContent, Kto) == 0 )
+            param->iSendCopyToSelf = ESendCopyAsToRecipient;
+        else if( CompareIgnoreCase( aElemContent, Kcc) == 0 )
+            param->iSendCopyToSelf = ESendCopyAsCcRecipient;
+        else if( CompareIgnoreCase( aElemContent, Kbcc) == 0 )
+            param->iSendCopyToSelf = ESendCopyAsBccRecipient;
+        else
+            param->iSendCopyToSelf = ESendNoCopy;
+        }
+    
+    // Send option:
+    else if( aElemName == Ksendoption )
+        {
+        if( aSetRandom )
+            param->iSendOption = (TImSMTPSendMessageOption) iEngine->RandomNumber(ESendMessageImmediately, ESendMessageOnRequest);
+        else if( CompareIgnoreCase( aElemContent, Konnextconnection) == 0 )
+            param->iSendOption = ESendMessageOnNextConnection;
+        else if( CompareIgnoreCase( aElemContent, Konrequest) == 0 )
+            param->iSendOption = ESendMessageOnRequest;
+        else
+            param->iSendOption = ESendMessageImmediately;
+        }
+    else
+        {
+        return EFalse;
+        }
+    return ETrue;
+    }
+
+void CCreatorMailboxElement::ExecuteCommandL()
+    {
+    const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount);
+    const CCreatorScriptAttribute* typeAttr = FindAttributeByName(KMailboxType);
+    TInt amount = 1;    
+    if( amountAttr )
+        {
+        amount = ConvertStrToIntL(amountAttr->Value());
+        }
+    
+    TMailboxType mailboxType = EMailboxPOP3;
+    
+    if( typeAttr && CompareIgnoreCase(typeAttr->Value(), Kimap4) == 0 )
+        {
+        mailboxType = EMailboxIMAP4;
+        }
+    
+    // Get 'fields' element 
+    CCreatorScriptElement* fieldsElement = FindSubElement(KFields);
+    if( fieldsElement && fieldsElement->SubElements().Count() > 0)
+        {
+        // Get sub-elements
+        const RPointerArray<CCreatorScriptElement>& fields = fieldsElement->SubElements();        
+        // Create mailbox entries, the amount of entries is defined by amount:
+        for( TInt cI = 0; cI < amount; ++cI )
+            {            
+            CMailboxesParameters* param = new (ELeave) CMailboxesParameters;
+            CleanupStack::PushL(param);
+            
+            param->iMailboxType = mailboxType;
+            
+            for( TInt i = 0; i < fields.Count(); ++i )
+                {
+                CCreatorScriptElement* field = fields[i];
+                TPtrC elemName = field->Name();
+                TPtrC elemContent = field->Content();
+                const CCreatorScriptAttribute* randomAttr = fields[i]->FindAttributeByName(KRandomLength);
+                TBool useRandom = EFalse;
+                if( randomAttr || elemContent.Length() == 0 )
+                    {
+                    useRandom = ETrue;
+                    }
+                
+                if( SetTextParamL(elemName, elemContent, param, useRandom ) == EFalse &&
+                    SetBooleanParamL(elemName, elemContent, param, useRandom ) == EFalse &&
+                    SetIntegerParamL(elemName, elemContent, param, useRandom ) == EFalse &&
+                    SetEnumParamL(elemName, elemContent, param, useRandom ) )
+                    {
+                    LOGSTRING2("CCreatorMailboxElement::ExecuteCommandL: Unknown mailbox field: %S", &elemName);
+                    }
+                }
+            iEngine->AppendToCommandArrayL(ECmdCreateMessagingEntryMailboxes, param);
+            CleanupStack::Pop(); // param
+            }
+        }
+    else
+    	{
+    	iEngine->AppendToCommandArrayL(ECmdCreateMessagingEntryMailboxes, 0, amount);
+    	}
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_message.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,2225 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#include "creator_message.h" 
+#include "creator_traces.h"
+#include "creator_contactsetcache.h"
+#include <apgcli.h>
+#include <MuiuMsvUiServiceUtilities.h>
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+#include <MVPbkFieldType.h>
+#include <MVPbkContactOperationBase.h>
+#include <MVPbkStoreContactFieldCollection.h>
+#include <MVPbkContactFieldTextData.h>
+#include <CVPbkContactManager.h>
+#include <MVPbkStoreContact.h>
+
+#include <CVPbkContactStoreUriArray.h>
+#include <TVPbkContactStoreUriPtr.h>
+#include <VPbkContactStoreUris.h>
+#include <MVPbkContactStoreList.h>
+#include <MVPbkContactStore.h>
+#include <MVPbkContactStoreProperties.h>
+#include <VPbkEng.rsg>
+#include <cmsvrecipientlist.h>
+#endif
+#include <mmf/common/mmfcontrollerpluginresolver.h> // for CleanupResetAndDestroyPushL
+
+
+//static const TInt KMessagesFieldLength = 1024;
+
+//_LIT(KCreatorMessagesPrefixName, "CR_");
+//_LIT(KCreatorMessagesPrefixFolderName, "CR_FLDR_");
+
+
+const TUid KUidBIOBusinessCardMsg =  {0x10005531}; 
+_LIT(KEmpty, "");
+
+//----------------------------------------------------------------------------
+
+CMessagesParameters::CMessagesParameters()
+    {
+    LOGSTRING("Creator: CMessagesParameters::CMessagesParameters");
+
+    iSenderAddress = HBufC::New(128);
+    iRecipientAddress = HBufC::New(128);
+    iMessageSubject = HBufC::New(128);
+    iMessageBodyText = HBufC::New(10240);
+    TRAP_IGNORE(iAttachments = new(ELeave) CArrayFixFlat<TInt>(64));
+    iCreateAsUnread = ETrue;
+    }
+
+CMessagesParameters::~CMessagesParameters()
+    {
+    LOGSTRING("Creator: CMessagesParameters::~CMessagesParameters");
+
+
+    delete iMessageBodyText;
+    delete iMessageSubject;
+    delete iRecipientAddress;
+    delete iSenderAddress;
+    delete iAttachments;
+    iAttachmentPaths.ResetAndDestroy();
+    iAttachmentPaths.Close(); 
+    iRecipientAddressArray.ResetAndDestroy();
+    iRecipientAddressArray.Close();
+    iRecipientLinkIds.Close();
+    iSenderLinkIds.Close();
+    }
+
+//----------------------------------------------------------------------------
+
+CCreatorMessages* CCreatorMessages::NewL(CCreatorEngine* aEngine)
+    {
+    CCreatorMessages* self = CCreatorMessages::NewLC(aEngine);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CCreatorMessages* CCreatorMessages::NewLC(CCreatorEngine* aEngine)
+    {
+    CCreatorMessages* self = new (ELeave) CCreatorMessages;
+    CleanupStack::PushL(self);
+    self->ConstructL(aEngine);
+    return self;
+    }
+
+CCreatorMessages::CCreatorMessages()
+:
+iSession(0)
+    {
+    }
+
+void CCreatorMessages::ConstructL(CCreatorEngine* aEngine)
+    {
+    LOGSTRING("Creator: CCreatorMessages::ConstructL");
+    iEngine = aEngine;
+    
+    TRAP_IGNORE(iAttachments = new(ELeave) CArrayFixFlat<TInt>(64));
+    iWaiter = CAsyncWaiter::NewL();
+    }
+
+CCreatorMessages::~CCreatorMessages()
+    {
+    LOGSTRING("Creator: CCreatorMessages::~CCreatorMessages");
+
+    if ( iEngine && iEntryIds.Count() )
+        {
+        TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iEntryIds, KUidDictionaryUidMessages ) );
+        }
+    iEntryIds.Reset();
+    iEntryIds.Close();
+    
+    delete iParameters;
+    delete iWaiter;
+    delete iTmpPhoneNumber;
+    delete iTmpEmail;
+    delete iAttachments;
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+    delete iExistingContacts;
+    if( iContactManager )
+    	iContactManager->ContactStoresL().CloseAll(*this);
+    delete iContactManager;
+    delete iTempContact;
+#endif
+    iRecipientArray.ResetAndDestroy();
+    iRecipientArray.Close();
+    iSenderArray.ResetAndDestroy();
+    iSenderArray.Close();
+    delete iSession;
+    }
+
+//----------------------------------------------------------------------------
+
+TBool CCreatorMessages::AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries)
+    {
+    LOGSTRING("Creator: CCreatorMessages::AskDataFromUserL");
+
+    if ( aCommand == ECmdDeleteMessages )
+        {
+        return iEngine->YesNoQueryDialogL( _L("Delete all messages?") );
+        }
+    else if ( aCommand ==  ECmdDeleteCreatorMessages )
+        {
+        return iEngine->YesNoQueryDialogL( _L("Delete all messages created with Creator?") );
+        }
+
+    if (iEngine->EntriesQueryDialogL(aNumberOfEntries, _L("How many entries to create?")))
+        {
+        
+        // message type query
+        CAknListQueryDialog* dlg1 = new(ELeave) CAknListQueryDialog( (TInt*) &iMessageType );
+        if (dlg1->ExecuteLD(R_MESSAGE_TYPE_QUERY))
+            {
+            TInt folderTypeQueryResource(R_FOLDER_TYPE_QUERY);
+            
+            /*
+            if (iMessageType == EEmail)
+                folderTypeQueryResource = R_FOLDER_TYPE_WITH_MAILBOX_QUERY;
+            */
+
+            // folder query
+            CAknListQueryDialog* dlg2 = new(ELeave) CAknListQueryDialog( (TInt*) &iFolderType );
+            if (dlg2->ExecuteLD(folderTypeQueryResource))
+                {
+                /*
+                if (iFolderType == EMailbox)
+                    {
+                    // array to hold mailbox names
+                    CDesCArray* names = new (ELeave) CDesCArrayFlat(16);
+                    CleanupStack::PushL(names);                    
+                    
+                    CMsvSession* session = CMsvSession::OpenSyncL(*this);
+                    CleanupStack::PushL(session);
+    
+                    // generate list of mailboxes
+                    CMsvEntrySelection* entrySelection = MsvUiServiceUtilities::GetListOfAccountsWithMTML(*session, KUidMsgTypeSMTP, ETrue);
+                    CleanupStack::PushL(entrySelection);
+
+                    TBool doReturn(EFalse);
+                    
+                    if (entrySelection->Count() == 0)
+                        {
+                        CAknInformationNote* note = new(ELeave) CAknInformationNote;
+                        note->ExecuteLD(_L("No mailboxes found"));
+
+                        doReturn = ETrue;
+                        }
+                    else
+                        {
+                        // get mailbox names
+                        for (TInt i=0; i<entrySelection->Count(); i++)
+                            {
+                            CMsvEntry* centry = session->GetEntryL(entrySelection->At(i));
+                            CleanupStack::PushL(centry);
+
+                            TMsvEntry tentry = centry->Entry();
+                            names->AppendL(tentry.iDetails);
+                            CleanupStack::PopAndDestroy(); //centry
+                            }
+                        
+                        // show query
+                        TInt index(0);
+                        CAknListQueryDialog* dlg = new(ELeave) CAknListQueryDialog(&index);
+                        dlg->PrepareLC(R_MAILBOX_SELECTION_QUERY);
+                        dlg->SetItemTextArray(names);
+                        dlg->SetOwnershipType(ELbmDoesNotOwnItemArray);
+
+                        if(dlg->RunLD())
+                            {
+                            iUserSelectedMailbox = entrySelection->At(index);
+
+                            doReturn = EFalse;
+                            }
+                        else
+                            {
+                            doReturn = ETrue;
+                            }    
+                        
+                        }
+                    
+                    CleanupStack::PopAndDestroy(3); // names, session, entrySelection
+                    
+                    if (doReturn)
+                        return EFalse;                    
+                    }
+                */
+                
+                // query create as unread
+                CAknListQueryDialog* dlg3 = new(ELeave) CAknListQueryDialog( (TInt*) &iCreateAsUnread );
+                if (dlg3->ExecuteLD(R_UNREAD_QUERY))
+                    {                
+
+                    // query number of characters in msg body
+                    switch (iMessageType)
+                        {
+                        case ESMS:
+                        case EMMS:
+                        case EEmail:
+                            {
+                            iDefinedMessageLength = 100;
+                            if (iEngine->EntriesQueryDialogL(iDefinedMessageLength, _L("Amount of characters in message body?"), ETrue))
+                                {
+                                ;
+                                }
+                            else
+                                return EFalse;
+
+                            break;
+                            }
+                        case EAMS:
+                        	{
+                        	iDefinedMessageLength = 0;
+                        	break;
+                        	}
+                        default: break;
+                        }
+
+                    // query attachments
+                    iAttachments->Reset();
+              
+                    switch (iMessageType)
+                        {
+                        case EMMS:
+                        case EEmail:
+                            {
+                            CAknListQueryDialog* dlg4 = new(ELeave) CAknListQueryDialog( iAttachments );
+                            if (dlg4->ExecuteLD(R_ATTACHMENT_MULTI_SELECTION_QUERY))
+                                {
+                                // "none" is selected
+                                if (iAttachments->At(0) == 0)
+                                    iAttachments->Reset();
+                                else  // otherwise fix indexes
+                                    {
+                                    for (TInt i=0; i<iAttachments->Count(); i++)
+                                        iAttachments->At(i)--;  // decrease value by one 
+
+                                    }
+                                }
+                            else
+                                return EFalse;
+                            
+                            break;
+                            }
+                        case EAMS:
+                        	{
+                            iAttachments->AppendL( TInt(0) );
+
+                            CAknListQueryDialog* dlg5 = new(ELeave) CAknListQueryDialog( &iAttachments->At(0) );
+                            if (dlg5->ExecuteLD(R_AMS_ATTACHMENT_SINGLE_SELECTION_QUERY))
+                                {
+                                ;
+                                }
+                            else
+                                return EFalse;                        
+
+                            break;
+                        	}
+                            
+                        case EIrMessage:
+                        case EBTMessage:
+                            {
+                            iAttachments->AppendL( TInt(0) );
+
+                            CAknListQueryDialog* dlg5 = new(ELeave) CAknListQueryDialog( &iAttachments->At(0) );
+                            if (dlg5->ExecuteLD(R_ATTACHMENT_SINGLE_SELECTION_QUERY))
+                                {
+                                ;
+                                }
+                            else
+                                return EFalse;                        
+
+                            break;
+                            }
+                        default: break;
+                        }
+                    
+                    return ETrue;  // all queries accepted
+
+                    }
+                else
+                    return EFalse;
+                }
+            else
+                return EFalse;
+            }
+        else
+            return EFalse;
+        }
+    else
+        return EFalse;
+    }
+
+//----------------------------------------------------------------------------
+
+TInt CCreatorMessages::CreateRandomMessageEntryL(TInt aCommand)
+    {
+    LOGSTRING2("Creator: CCreatorMessages::CreateRandomMessageEntryL - Command: %d", aCommand);
+
+    TInt err = KErrNone;
+    
+    iDefinedMessageLength = iEngine->RandomNumber(100, 300);
+
+
+    switch (aCommand)
+        {
+	    case ECmdCreateRandomEntrySMSInbox:     { iMessageType=ESMS; iFolderType=EInbox; err=CreateMessageEntryL(NULL); break;}
+	    case ECmdCreateRandomEntrySMSDrafts:    { iMessageType=ESMS; iFolderType=EDrafts; err=CreateMessageEntryL(NULL); break;}
+	    case ECmdCreateRandomEntrySMSOutbox:    { iMessageType=ESMS; iFolderType=EOutbox; err=CreateMessageEntryL(NULL); break;}
+	    case ECmdCreateRandomEntrySMSSent:      { iMessageType=ESMS; iFolderType=ESent; err=CreateMessageEntryL(NULL); break;}
+	    
+        case ECmdCreateRandomEntryMMSInbox:     { iMessageType=EMMS; iFolderType=EInbox; err=CreateMessageEntryL(NULL); break;}
+	    case ECmdCreateRandomEntryMMSDrafts:    { iMessageType=EMMS; iFolderType=EDrafts; err=CreateMessageEntryL(NULL); break;}
+	    case ECmdCreateRandomEntryMMSOutbox:    { iMessageType=EMMS; iFolderType=EOutbox; err=CreateMessageEntryL(NULL); break;}    
+	    case ECmdCreateRandomEntryMMSSent:      { iMessageType=EMMS; iFolderType=ESent; err=CreateMessageEntryL(NULL); break;}
+	    
+        case ECmdCreateRandomEntryEmailInbox:   { iMessageType=EEmail; iFolderType=EInbox; err=CreateMessageEntryL(NULL); break;}
+	    case ECmdCreateRandomEntryEmailDrafts:  { iMessageType=EEmail; iFolderType=EDrafts; err=CreateMessageEntryL(NULL); break;}
+	    case ECmdCreateRandomEntryEmailOutbox:  { iMessageType=EEmail; iFolderType=EOutbox; err=CreateMessageEntryL(NULL); break;}
+	    case ECmdCreateRandomEntryEmailSent:    { iMessageType=EEmail; iFolderType=ESent; err=CreateMessageEntryL(NULL); break;}
+	    
+        case ECmdCreateRandomEntryBIOInbox:     { iMessageType=ESmartMessage; iFolderType=EInbox; err=CreateMessageEntryL(NULL); break;}
+	    case ECmdCreateRandomEntryBIODrafts:    { iMessageType=ESmartMessage; iFolderType=EDrafts; err=CreateMessageEntryL(NULL); break;}
+	    case ECmdCreateRandomEntryBIOOutbox:    { iMessageType=ESmartMessage; iFolderType=EOutbox; err=CreateMessageEntryL(NULL); break;}
+	    case ECmdCreateRandomEntryBIOSent:      { iMessageType=ESmartMessage; iFolderType=ESent; err=CreateMessageEntryL(NULL); break;}
+	    
+        case ECmdCreateRandomEntryIRInbox:      { iMessageType=EIrMessage; iFolderType=EInbox; iAttachments->Reset(); iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) ); err=CreateMessageEntryL(NULL); break;}
+	    case ECmdCreateRandomEntryIRDrafts:     { iMessageType=EIrMessage; iFolderType=EDrafts; iAttachments->Reset(); iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) ); err=CreateMessageEntryL(NULL); break;}
+	    case ECmdCreateRandomEntryIROutbox:     { iMessageType=EIrMessage; iFolderType=EOutbox; iAttachments->Reset(); iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) ); err=CreateMessageEntryL(NULL); break;}
+	    case ECmdCreateRandomEntryIRSent:       { iMessageType=EIrMessage; iFolderType=ESent; iAttachments->Reset(); iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) ); err=CreateMessageEntryL(NULL); break;}
+	    
+        case ECmdCreateRandomEntryBTInbox:      { iMessageType=EBTMessage; iFolderType=EInbox; iAttachments->Reset(); iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) ); err=CreateMessageEntryL(NULL); break;}
+	    case ECmdCreateRandomEntryBTDrafts:     { iMessageType=EBTMessage; iFolderType=EDrafts; iAttachments->Reset(); iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) ); err=CreateMessageEntryL(NULL); break;}
+	    case ECmdCreateRandomEntryBTOutbox:     { iMessageType=EBTMessage; iFolderType=EOutbox; iAttachments->Reset(); iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) ); err=CreateMessageEntryL(NULL); break;}
+	    case ECmdCreateRandomEntryBTSent:       { iMessageType=EBTMessage; iFolderType=ESent; iAttachments->Reset(); iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) ); err=CreateMessageEntryL(NULL); break;}
+        
+	    case ECmdCreateRandomEntryAMSInbox:     { iMessageType=EAMS; iFolderType=EInbox; iAttachments->Reset(); iAttachments->AppendL( CCreatorEngine::EMP3_250kB); err=CreateMessageEntryL(NULL); break;}
+	    case ECmdCreateRandomEntryAMSDrafts:     { iMessageType=EAMS; iFolderType=EDrafts; iAttachments->Reset(); iAttachments->AppendL( CCreatorEngine::EMP3_250kB); err=CreateMessageEntryL(NULL); break;}
+	    case ECmdCreateRandomEntryAMSOutbox:     { iMessageType=EAMS; iFolderType=EOutbox; iAttachments->Reset(); iAttachments->AppendL( CCreatorEngine::EMP3_250kB); err=CreateMessageEntryL(NULL); break;}
+	    case ECmdCreateRandomEntryAMSSent:     { iMessageType=EAMS; iFolderType=ESent; iAttachments->Reset(); iAttachments->AppendL( CCreatorEngine::EMP3_250kB); err=CreateMessageEntryL(NULL); break;}
+
+	    default: { User::Panic(_L("MessageCommand"), 901);  break;}
+        }
+
+    return err;
+    }
+
+//----------------------------------------------------------------------------
+
+TInt CCreatorMessages::CreateMessageEntryL(CMessagesParameters *aParameters, TBool /*aTakeUserGivenParameters*/)
+    {
+    LOGSTRING("Creator: CCreatorMessages::CreateMessageEntryL");
+    
+    delete iParameters;
+    iParameters = 0;   
+    
+    CMessagesParameters* parameters = aParameters;
+           
+    // random data needed if no predefined data available
+    if (!parameters)
+        {
+        iParameters = new(ELeave) CMessagesParameters;
+        parameters = iParameters;
+        // check if values from ui needed
+        //if (aTakeUserGivenParameters)
+        //    {            
+            parameters->iMessageType = iMessageType;
+            parameters->iFolderType = iFolderType;
+            parameters->iDefinedMessageLength = iDefinedMessageLength;
+            parameters->iCreateAsUnread = iCreateAsUnread;
+
+            for (TInt i=0; i<iAttachments->Count(); i++)
+                parameters->iAttachments->AppendL(iAttachments->At(i)); 
+        //    }
+        //else
+        //    {
+            // message length
+        //    parameters->iDefinedMessageLength = iEngine->RandomNumber(100, 300);
+        //    }    
+
+        if (parameters->iMessageType == EEmail)
+            {
+            parameters->iSenderAddress->Des().Copy( iEngine->RandomString(CCreatorEngine::EFirstName) );
+            parameters->iSenderAddress->Des().Append( _L("@") );
+            parameters->iSenderAddress->Des().Append( iEngine->RandomString(CCreatorEngine::ECompany) );
+            parameters->iSenderAddress->Des().Append( _L(".com") );
+
+            parameters->iRecipientAddress->Des().Copy( iEngine->RandomString(CCreatorEngine::EFirstName) );
+            parameters->iRecipientAddress->Des().Append( _L("@") );
+            parameters->iRecipientAddress->Des().Append( iEngine->RandomString(CCreatorEngine::ECompany) );
+            parameters->iRecipientAddress->Des().Append( _L(".net") );
+            }
+        else if (parameters->iMessageType == EIrMessage || parameters->iMessageType == EBTMessage)
+            {
+            parameters->iSenderAddress->Des().Copy( iEngine->RandomString(CCreatorEngine::EFirstName) );
+            parameters->iRecipientAddress->Des().Copy( iEngine->RandomString(CCreatorEngine::EFirstName) );
+            }
+        else
+            {
+            parameters->iSenderAddress->Des().Copy( iEngine->RandomString(CCreatorEngine::EPhoneNumber) );
+            parameters->iRecipientAddress->Des().Copy( iEngine->RandomString(CCreatorEngine::EPhoneNumber) );
+            }
+
+        // subject
+        parameters->iMessageSubject->Des() = iEngine->RandomString(CCreatorEngine::EMessageSubject);
+
+        // message body
+        parameters->iMessageBodyText->Des().Copy(_L(""));
+        TPtrC randText = iEngine->RandomString(CCreatorEngine::EMessageText);
+        for (TInt i=0; i<parameters->iDefinedMessageLength / randText.Length() +1; i++)
+            {
+            parameters->iMessageBodyText->Des().Append( randText );
+            parameters->iMessageBodyText->Des().Append( _L(" ") );
+            }
+        parameters->iMessageBodyText->Des() = parameters->iMessageBodyText->Des().Left(parameters->iDefinedMessageLength);
+
+        // BIO message type (from bitsids.h)  // TO-DO: add support for all BIO message types...
+        parameters->iBIOMessageType = KUidBIOBusinessCardMsg;
+        }
+    
+    
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+    
+    // Get number of existing senders and recipients:
+    for( TInt i = 0; i < parameters->iRecipientLinkIds.Count(); ++i )
+        {       
+        
+        TLinkIdParam recipientId = parameters->iRecipientLinkIds[i];        
+        // Is maximum number limited:
+        if(recipientId.iLinkAmount == KUndef || 
+           recipientId.iLinkAmount >= ContactLinkCache::Instance()->ContactSet(recipientId.iLinkId).NumberOfExistingContacts() )
+            {
+            parameters->iNumberOfExistingRecipients += ContactLinkCache::Instance()->ContactSet(recipientId.iLinkId).NumberOfExistingContacts();
+            }
+        else
+            {
+            parameters->iNumberOfExistingRecipients += recipientId.iLinkAmount;
+            }
+        }
+    for( TInt i = 0; i < parameters->iSenderLinkIds.Count(); ++i )
+        {
+        TLinkIdParam senderId = parameters->iSenderLinkIds[i];
+        // Is maximum number limited:
+        if( senderId.iLinkAmount == KUndef ||
+            senderId.iLinkAmount >= ContactLinkCache::Instance()->ContactSet(senderId.iLinkId).NumberOfExistingContacts())
+            {
+            parameters->iNumberOfExistingSenders += ContactLinkCache::Instance()->ContactSet(senderId.iLinkId).NumberOfExistingContacts();
+            }
+        else
+            {
+            parameters->iNumberOfExistingSenders += senderId.iLinkAmount;
+            }            
+        }
+    
+#endif
+
+    TInt err = KErrNone;
+
+    switch (parameters->iMessageType)
+        {
+        case ESMS:          { err = CreateSMSEntryL(*parameters);  break; }
+        case EMMS:          { err = CreateMMSEntryL(*parameters);  break; }
+        case EAMS:          { err = CreateAMSEntryL(*parameters);  break; }
+        case EEmail:        { err = CreateEmailEntryL(*parameters);  break; }
+        case ESmartMessage: { err = CreateSmartMessageEntryL(*parameters);  break; }
+        case EIrMessage:    { err = CreateObexEntryL( TUid::Uid(KUidMsgTypeIrTInt32), *parameters );  break; }    
+        case EBTMessage:    { err = CreateObexEntryL( TUid::Uid(KUidMsgTypeBtTInt32), *parameters );  break; }
+        default:            { User::Panic(_L("MsgType"), 851);  break;}
+
+        }
+
+    iSenderArray.ResetAndDestroy();
+    iRecipientArray.ResetAndDestroy();
+    return err;
+    }
+
+//----------------------------------------------------------------------------
+
+TInt CCreatorMessages::CreateSMSEntryL(const CMessagesParameters& parameters)
+    {
+    LOGSTRING("Creator: CCreatorMessages::CreateSMSEntryL");
+
+    TInt err = KErrNone;
+               
+    // init    
+    if( iSession == 0 )
+        {
+        iSession = CMsvSession::OpenSyncL(*this);
+        }
+
+    CClientMtmRegistry* registry = CClientMtmRegistry::NewL(*iSession);
+    CleanupStack::PushL(registry);
+
+    // get the client mtm and return if it isn't supported in the system        
+    CSmsClientMtm* clientMtm = NULL;
+    TRAP(err, clientMtm = static_cast<CSmsClientMtm*>(registry->NewMtmL(KUidMsgTypeSMS)));
+    if (err || !clientMtm)
+        {
+        CAknErrorNote* note = new(ELeave) CAknErrorNote;
+        note->ExecuteLD(_L("SMS: Message type module not found"));
+        CleanupStack::PopAndDestroy(2);
+        User::Leave(KErrNotFound);
+        }  
+    CleanupStack::PushL(clientMtm);   
+
+    // create a new object to access an existing entry
+    CMsvEntry* msvEntry = CMsvEntry::NewL(*iSession, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering());
+    CleanupStack::PushL(msvEntry);
+  
+    // get default service
+    TMsvId defaultServiceId = 0;
+    TRAP(err, defaultServiceId = clientMtm->DefaultServiceL());
+    if (err)
+        {
+        CAknErrorNote* note = new(ELeave) CAknErrorNote;
+        note->ExecuteLD(_L("SMS: Define a SMS centre first"));
+        CleanupStack::PopAndDestroy(2);
+        User::Leave(KErrNotFound);
+        } 
+    
+    // set folder type
+    switch (parameters.iFolderType)
+        {
+        case EInbox:    { msvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);   break; }
+        case EDrafts:   { msvEntry->SetEntryL(KMsvDraftEntryId);              break; }
+        case EOutbox:   { msvEntry->SetEntryL(KMsvGlobalOutBoxIndexEntryId);  break; }
+        case ESent:     { msvEntry->SetEntryL(KMsvSentEntryId);               break; }
+        default:        { User::Panic(_L("Folder Type"), 871);                break; } 
+        }
+        
+    // mtm takes ownership of entry context	
+    CleanupStack::Pop(msvEntry);
+    clientMtm->SetCurrentEntryL(msvEntry);    
+    
+    // create a new message
+    clientMtm->CreateMessageL(defaultServiceId);
+
+    // set the from field to sms header
+    if (parameters.iFolderType == EInbox)
+        {
+        CSmsHeader& smsHeader = clientMtm->SmsHeader();
+
+        if( parameters.iSenderAddress )
+            {
+            smsHeader.SetFromAddressL( parameters.iSenderAddress->Des() );
+            }
+        else
+            {
+            smsHeader.SetFromAddressL(KEmpty);
+            }
+        }       
+
+    // set body
+    clientMtm->Body().Reset();
+    clientMtm->Body().InsertL(0, parameters.iMessageBodyText->Des());        
+
+    // get the entry of the message
+    TMsvEntry messageEntry = clientMtm->Entry().Entry();
+
+    // set the details field
+    if (parameters.iFolderType == EInbox)
+        {
+        SetSenderToEntryDetails(messageEntry, parameters, EFalse);        
+        }
+    else
+        {
+        SetRecipientToEntryDetails(messageEntry, parameters, EFalse);
+        // Add all recipients to clientMtm
+        // iRecipientArray is up-to-date so don't call AddRecipientsL here 
+        for( TInt i = 0; i < iRecipientArray.Count(); i++ )
+            {
+            clientMtm->AddAddresseeL( iRecipientArray[i]->Des() );
+            }
+        }
+
+    // set the sending state for outbox message
+    // to avoid SMSMtmUI:15 panic in messages application
+    if (parameters.iFolderType == EOutbox )
+        {
+        messageEntry.SetSendingState( KMsvSendStateWaiting );
+        }
+
+    // set the description field same as the first part of the message body
+    messageEntry.iDescription.Set( parameters.iMessageBodyText->Des().Left(KSmsDescriptionLength) );
+
+    // save the changes done above
+    clientMtm->Entry().ChangeL(messageEntry);
+
+    // save the message     
+    clientMtm->SaveMessageL();
+    	
+	// final fine tuning
+    messageEntry.SetAttachment(EFalse);
+    messageEntry.iDate.HomeTime();
+    messageEntry.SetVisible(ETrue);
+    messageEntry.SetInPreparation(EFalse);
+   
+    if (parameters.iCreateAsUnread)
+        {
+        messageEntry.SetUnread(ETrue);
+        messageEntry.SetNew(ETrue);
+        }
+    else
+        {
+        messageEntry.SetUnread(EFalse);
+        messageEntry.SetNew(EFalse);
+        }
+    
+    messageEntry.SetComplete(ETrue);
+    messageEntry.iServiceId = defaultServiceId;
+    messageEntry.iRelatedId = 0;
+    clientMtm->Entry().ChangeL(messageEntry);
+
+    // id has been generated, store it for being able to delete
+    // only entries created with Creator
+    iEntryIds.Append( messageEntry.Id() );
+    
+    CleanupStack::PopAndDestroy(2); //registry, clientMtm
+        
+    return err;
+
+    }
+
+//----------------------------------------------------------------------------
+
+TInt CCreatorMessages::CreateMMSEntryL(const CMessagesParameters& parameters)
+    {
+    LOGSTRING("Creator: CCreatorMessages::CreateMMSEntryL");
+
+    TInt err = KErrNone;
+
+        
+    // init    
+    if( iSession == 0 )
+        {
+        iSession = CMsvSession::OpenSyncL(*this);
+        }
+    
+    CClientMtmRegistry* registry = CClientMtmRegistry::NewL(*iSession);
+    CleanupStack::PushL(registry);
+
+    // get the client mtm and return if it isn't supported in the system        
+    CMmsClientMtm* clientMtm = NULL;
+    TRAP(err, clientMtm = static_cast<CMmsClientMtm*>(registry->NewMtmL(KUidMsgTypeMultimedia)));
+    if (err || !clientMtm)
+        {
+        CAknErrorNote* note = new(ELeave) CAknErrorNote;
+        note->ExecuteLD(_L("MMS: Message type module not found"));
+        CleanupStack::PopAndDestroy(2);
+        User::Leave(KErrNotFound);
+        }  
+    CleanupStack::PushL(clientMtm);   
+
+    // create a new object to access an existing entry
+    CMsvEntry* msvEntry = CMsvEntry::NewL(*iSession, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering());
+    CleanupStack::PushL(msvEntry);
+  
+    // get default service
+    TMsvId defaultServiceId = 0;
+    TRAP(err, defaultServiceId = clientMtm->DefaultServiceL());
+    if (err)
+        {
+        CAknErrorNote* note = new(ELeave) CAknErrorNote;
+        note->ExecuteLD(_L("MMS: Define MMS settings first"));
+        CleanupStack::PopAndDestroy(4);
+        User::Leave(KErrNotFound);
+        } 
+    
+    // set folder type
+    switch (parameters.iFolderType)
+        {
+        case EInbox:    { msvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);   break; }
+        case EDrafts:   { msvEntry->SetEntryL(KMsvDraftEntryId);              break; }
+        case EOutbox:   { msvEntry->SetEntryL(KMsvGlobalOutBoxIndexEntryId);  break; }
+        case ESent:     { msvEntry->SetEntryL(KMsvSentEntryId);               break; }
+        default:        { User::Panic(_L("Folder Type"), 871);                break; } 
+        }
+        
+    // mtm takes ownership of entry context	
+    CleanupStack::Pop(msvEntry);
+    clientMtm->SetCurrentEntryL(msvEntry);    
+    
+    // create a new message
+    clientMtm->CreateMessageL(defaultServiceId);
+
+    // set subject
+    clientMtm->SetSubjectL( parameters.iMessageSubject->Des() );
+            
+    // set some mms defaults
+    clientMtm->SetMessageClass(EMmsClassPersonal);
+    clientMtm->SetExpiryInterval(86400);
+    clientMtm->SetDeliveryTimeInterval(3600);
+    clientMtm->SetMessagePriority(EMmsPriorityLow);
+    clientMtm->SetSenderVisibility(EMmsMaximumSenderVisibility);
+    clientMtm->SetDeliveryReport(EMmsDeliveryReportYes);
+    clientMtm->SetReadReply(EMmsReadReplyYes);        
+    
+    // set the sender / addressee field
+    if (parameters.iFolderType == EInbox)
+        {        
+        AddMtmSenderL(*clientMtm, parameters, EFalse);                
+        }
+    
+    // Add all recipients to clientMtm
+    AddRecipientsL( *clientMtm, parameters, EFalse );  
+        
+    // get an access to the message store
+    CMsvStore* store = msvEntry->EditStoreL();
+    CleanupStack::PushL(store);                  
+   
+
+    // set body as an attachment
+    CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL();
+    CleanupStack::PushL(mimeHeaders);
+    mimeHeaders->SetContentTypeL( _L8("text") );
+    mimeHeaders->SetContentSubTypeL( _L8("plain") );
+    mimeHeaders->SetMimeCharset( KMmsUtf8 );
+    mimeHeaders->SetSuggestedFilenameL( _L("body.txt") );
+    
+    MMsvAttachmentManager& attachMan = store->AttachmentManagerL();
+    CMsvAttachment* attachmentInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile); // ownership of attachmentInfo will be transferred
+    CleanupStack::PushL(attachmentInfo);
+    attachmentInfo->SetAttachmentNameL( _L("body.txt") );
+    attachmentInfo->SetMimeTypeL( _L8("text/plain") );
+    mimeHeaders->StoreL( *attachmentInfo );
+    
+    RFile textFile;
+
+    CAsyncWaiter* waiter = CAsyncWaiter::NewLC();
+    attachMan.CreateAttachmentL(_L("body.txt"), textFile, attachmentInfo, waiter->iStatus );
+    CleanupStack::Pop(); // waiter
+    CleanupStack::Pop(); // attachmentInfo
+    CleanupStack::PushL(waiter);
+    waiter->StartAndWait();
+    CleanupStack::PopAndDestroy(waiter);        
+   
+    HBufC8* tempBuf = HBufC8::NewLC( parameters.iMessageBodyText->Des().Length() );
+    tempBuf->Des().Copy( parameters.iMessageBodyText->Des() );
+    textFile.Write( tempBuf->Des() );        
+    textFile.Close();
+    CleanupStack::PopAndDestroy(); //tempBuf
+    
+    CleanupStack::PopAndDestroy(); //mimeHeaders
+
+    
+    // get the entry of the message
+    TMsvEntry messageEntry = clientMtm->Entry().Entry();        
+    
+    // set the details field
+    if (parameters.iFolderType == EInbox)
+        {
+        SetSenderToEntryDetails(messageEntry, parameters, EFalse);        
+        }
+    else
+        {
+        SetRecipientToEntryDetails(messageEntry, parameters, EFalse);
+        }    
+
+    // set the description field same as the message subject
+    messageEntry.iDescription.Set( parameters.iMessageSubject->Des().Left(KSmsDescriptionLength) );
+
+    // save the changes done above
+    clientMtm->Entry().ChangeL(messageEntry);        
+    
+
+      // save the attachments
+    HandleAttachementsL(parameters, store, err );
+//    for (TInt i=0; i<parameters.iAttachments->Count(); i++)
+//        {
+//        TFileName sourceFileName = iEngine->TestDataPathL( (CCreatorEngine::TTestDataPath) parameters.iAttachments->At(i) );
+//
+//        TParse parser;
+//        parser.Set(sourceFileName, NULL, NULL);
+//        TFileName shortFileName = parser.NameAndExt();
+//
+//        // get the mime type
+//        RApaLsSession ls;
+//        User::LeaveIfError(ls.Connect());
+//        CleanupClosePushL<RApaLsSession>(ls);
+//        TUid appUid;
+//        TDataType dataType;
+//        ls.AppForDocument(sourceFileName, appUid, dataType);
+//        CleanupStack::PopAndDestroy(); //ls
+//        TPtrC8 mimeType = dataType.Des8();
+//        
+//        // attachment settings
+//        MMsvAttachmentManager& attachMan = store->AttachmentManagerL();
+//        CMsvAttachment* attachmentInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile); // ownership of attachmentInfo will be transferred
+//        attachmentInfo->SetAttachmentNameL( shortFileName );        
+//        attachmentInfo->SetMimeTypeL( mimeType );        
+//
+//        // save
+//        CAsyncWaiter* waiter = CAsyncWaiter::NewLC();
+//        
+//        TRAP(err, attachMan.AddAttachmentL(sourceFileName, attachmentInfo, waiter->iStatus ));
+//        if (err == KErrNone)
+//            waiter->StartAndWait();
+//        else
+//            LOGSTRING2("Creator: CCreatorMessages::CreateMMSEntryL failed to attach %S", &sourceFileName);
+//
+//        CleanupStack::PopAndDestroy(waiter);  
+//        }
+
+    // save the changes made to the message store
+    store->CommitL();
+    CleanupStack::PopAndDestroy(store);   
+           
+    
+    // save the message      
+    clientMtm->SaveMessageL();
+    	
+	// final fine tuning
+	messageEntry.SetAttachment(ETrue);
+    messageEntry.iDate.HomeTime();
+    messageEntry.SetVisible(ETrue);
+    messageEntry.SetInPreparation(EFalse);
+    if (parameters.iCreateAsUnread)
+        {
+        messageEntry.SetUnread(ETrue);
+        messageEntry.SetNew(ETrue);
+        }
+    else
+        {
+        messageEntry.SetUnread(EFalse);
+        messageEntry.SetNew(EFalse);
+        }
+    messageEntry.SetComplete(ETrue);
+    messageEntry.iServiceId = defaultServiceId;
+    messageEntry.iRelatedId = 0;
+    
+    if (parameters.iFolderType == EDrafts) 
+        messageEntry.SetReadOnly(EFalse);
+    else
+        messageEntry.SetReadOnly(ETrue);
+
+	messageEntry.iMtmData1 = KMmsMessageMRetrieveConf | KMmsMessageMobileTerminated;
+	
+    clientMtm->Entry().ChangeL(messageEntry);
+    
+    // id has been generated, store it for being able to delete
+    // only entries created with Creator
+    iEntryIds.Append( messageEntry.Id() );
+    
+    CleanupStack::PopAndDestroy(2); // registry, clientMtm        
+        
+
+    return err;
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorMessages::HandleAttachementsL(const CMessagesParameters& parameters, CMsvStore* store, TInt err )
+    {
+    // save the attachments (added with id's)
+  for (TInt i=0; i<parameters.iAttachments->Count(); i++)
+      {
+      TFileName sourceFileName = iEngine->TestDataPathL( (CCreatorEngine::TTestDataPath) parameters.iAttachments->At(i) );
+      HandleAttachementL(store, err, sourceFileName );
+
+      }    
+  //Adding attachmentpaths
+  for (TInt i=0; i<parameters.iAttachmentPaths.Count(); i++)
+      {
+      HBufC* point = parameters.iAttachmentPaths[i];
+      TFileName sourceFileName(point->Des());      
+      HandleAttachementL(store, err, sourceFileName );
+      }
+    }
+//----------------------------------------------------------------------------
+
+void CCreatorMessages::HandleAttachementL(CMsvStore* store, TInt err, TFileName& sourceFileName )
+    {
+    TParse parser;
+    parser.Set(sourceFileName, NULL, NULL);
+    TFileName shortFileName = parser.NameAndExt();
+
+    // get the mime type
+    RApaLsSession ls;
+    User::LeaveIfError(ls.Connect());
+    CleanupClosePushL<RApaLsSession>(ls);
+    TUid appUid;
+    TDataType dataType;
+    ls.AppForDocument(sourceFileName, appUid, dataType);
+    CleanupStack::PopAndDestroy(); //ls
+    TPtrC8 mimeType = dataType.Des8();
+    
+    // attachment settings
+    MMsvAttachmentManager& attachMan = store->AttachmentManagerL();
+    CMsvAttachment* attachmentInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile); // ownership of attachmentInfo will be transferred
+    CleanupStack::PushL(attachmentInfo);
+    attachmentInfo->SetAttachmentNameL( shortFileName );        
+    attachmentInfo->SetMimeTypeL( mimeType );
+    
+    if ( mimeType == _L8("text/plain") )
+        {
+        // CMsvMimeHeaders needs to be stored in case of text file 
+        CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL();
+        CleanupStack::PushL(mimeHeaders);
+        mimeHeaders->SetContentTypeL( _L8("text") );
+        mimeHeaders->SetContentSubTypeL( _L8("plain") );
+        mimeHeaders->SetMimeCharset( KMmsUtf8 );
+        mimeHeaders->StoreL( *attachmentInfo );
+        CleanupStack::PopAndDestroy( mimeHeaders );
+        }
+
+    // save
+    
+    CAsyncWaiter* waiter = CAsyncWaiter::NewLC();
+    TRAP(err, attachMan.AddAttachmentL(sourceFileName, attachmentInfo, waiter->iStatus ));
+    if (err == KErrNone)
+    	{
+        waiter->StartAndWait();
+        CleanupStack::PopAndDestroy(waiter);
+        CleanupStack::Pop(); // attachmentInfo, the ownership is transferred
+    	}
+    else
+    	{
+    	CleanupStack::PopAndDestroy(waiter);
+    	CleanupStack::PopAndDestroy(); // attachmentInfo, ownership is not transferred (leave occurs)
+        LOGSTRING2("Creator: CCreatorMessages::HandleAttachementsL failed to attach %S", &sourceFileName);
+    	}
+    }
+      //----------------------------------------------------------------------------
+
+TInt CCreatorMessages::CreateAMSEntryL(const CMessagesParameters& parameters)
+    {
+    LOGSTRING("Creator: CCreatorMessages::CreateAMSEntryL");
+
+    TInt err = KErrNone;
+
+        
+    // init    
+    if( iSession == 0 )
+        {
+        iSession = CMsvSession::OpenSyncL(*this);
+        }
+
+    CClientMtmRegistry* registry = CClientMtmRegistry::NewL(*iSession);
+    CleanupStack::PushL(registry);
+
+    // get the client mtm and return if it isn't supported in the system        
+    CMmsClientMtm* clientMtm = NULL;
+    TRAP(err, clientMtm = static_cast<CMmsClientMtm*>(registry->NewMtmL(KUidMsgTypeMultimedia)));
+    if (err || !clientMtm)
+        {
+        CAknErrorNote* note = new(ELeave) CAknErrorNote;
+        note->ExecuteLD(_L("MMS: Message type module not found"));
+        CleanupStack::PopAndDestroy(2);
+        User::Leave(KErrNotFound);
+        }  
+    CleanupStack::PushL(clientMtm);   
+
+    // create a new object to access an existing entry
+    CMsvEntry* msvEntry = CMsvEntry::NewL(*iSession, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering());
+    CleanupStack::PushL(msvEntry);
+  
+    // get default service
+    TMsvId defaultServiceId = 0;
+    TRAP(err, defaultServiceId = clientMtm->DefaultServiceL());
+    if (err)
+        {
+        CAknErrorNote* note = new(ELeave) CAknErrorNote;
+        note->ExecuteLD(_L("MMS: Define MMS settings first"));
+        CleanupStack::PopAndDestroy(2);
+        User::Leave(KErrNotFound);
+        } 
+    
+    // set folder type
+    switch (parameters.iFolderType)
+        {
+        case EInbox:    { msvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);   break; }
+        case EDrafts:   { msvEntry->SetEntryL(KMsvDraftEntryId);              break; }
+        case EOutbox:   { msvEntry->SetEntryL(KMsvGlobalOutBoxIndexEntryId);  break; }
+        case ESent:     { msvEntry->SetEntryL(KMsvSentEntryId);               break; }
+        default:        { User::Panic(_L("Folder Type"), 871);                break; } 
+        }
+        
+    // mtm takes ownership of entry context	
+    CleanupStack::Pop(msvEntry);
+    clientMtm->SetCurrentEntryL(msvEntry);    
+    
+    // create a new message
+    clientMtm->CreateMessageL(defaultServiceId);
+
+    // set subject
+    clientMtm->SetSubjectL(parameters.iMessageSubject->Des() );
+            
+    // set some mms defaults
+    clientMtm->SetMessageClass(EMmsClassPersonal);
+    clientMtm->SetExpiryInterval(86400);
+    clientMtm->SetDeliveryTimeInterval(3600);
+    clientMtm->SetMessagePriority(EMmsPriorityLow);
+    clientMtm->SetSenderVisibility(EMmsMaximumSenderVisibility);
+    clientMtm->SetDeliveryReport(EMmsDeliveryReportYes);
+    clientMtm->SetReadReply(EMmsReadReplyYes);        
+    
+    // set the sender / addressee field
+    if (parameters.iFolderType == EInbox)
+        {
+        AddMtmSenderL(*clientMtm, parameters, EFalse);                
+        }
+
+    // Add all recipients to clientMtm
+    AddRecipientsL( *clientMtm, parameters, EFalse );
+    
+        
+    // get an access to the message store
+    CMsvStore* store = msvEntry->EditStoreL();
+    CleanupStack::PushL(store);                  
+   
+    // get the entry of the message
+    TMsvEntry messageEntry = clientMtm->Entry().Entry();        
+    
+    // set the details field
+    if (parameters.iFolderType == EInbox)
+        {
+        SetSenderToEntryDetails(messageEntry, parameters, EFalse);        
+        }  
+    else
+        {
+        SetRecipientToEntryDetails(messageEntry, parameters, EFalse);
+        }
+
+    // set the description field same as the message subject
+    messageEntry.iDescription.Set( parameters.iMessageSubject->Des().Left(KSmsDescriptionLength) );
+    messageEntry.iBioType = KUidMsgSubTypeMmsAudioMsg.iUid;
+    
+    // save the changes done above
+    clientMtm->Entry().ChangeL(messageEntry);        
+    
+
+    TFileName sourceFileName = iEngine->TestDataPathL( CCreatorEngine::EAMR_20kB );
+    TParse parser;
+    parser.Set(sourceFileName, NULL, NULL);
+    TFileName shortFileName = parser.NameAndExt();
+
+    // get the mime type
+    RApaLsSession ls;
+    User::LeaveIfError(ls.Connect());
+    CleanupClosePushL<RApaLsSession>(ls);
+    TUid appUid;
+    TDataType dataType;
+    ls.AppForDocument(sourceFileName, appUid, dataType);
+    CleanupStack::PopAndDestroy(); //ls
+    TPtrC8 mimeType = dataType.Des8();
+        
+    // attachment settings
+    MMsvAttachmentManager& attachMan = store->AttachmentManagerL();
+    CMsvAttachment* attachmentInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile); // ownership of attachmentInfo will be transferred
+    attachmentInfo->SetAttachmentNameL( shortFileName );        
+    attachmentInfo->SetMimeTypeL( mimeType );        
+
+    // save
+    CAsyncWaiter* waiter = CAsyncWaiter::NewLC();
+      
+    TRAP(err, attachMan.AddAttachmentL(sourceFileName, attachmentInfo, waiter->iStatus ));
+    if (err == KErrNone)
+        waiter->StartAndWait();
+    else
+        LOGSTRING2("Creator: CCreatorMessages::CreateAMSEntryL failed to attach %S", &sourceFileName);
+
+    CleanupStack::PopAndDestroy(waiter);  
+
+    // save the changes made to the message store
+    store->CommitL();
+    CleanupStack::PopAndDestroy(store);   
+           
+    
+    // save the message      
+    clientMtm->SaveMessageL();
+    	
+	// final fine tuning
+	messageEntry.SetAttachment(ETrue);
+    messageEntry.iDate.HomeTime();
+    messageEntry.SetVisible(ETrue);
+    messageEntry.SetInPreparation(EFalse);
+    if (parameters.iCreateAsUnread)
+        {
+        messageEntry.SetUnread(ETrue);
+        messageEntry.SetNew(ETrue);
+        }
+    else
+        {
+        messageEntry.SetUnread(EFalse);
+        messageEntry.SetNew(EFalse);
+        }
+    messageEntry.SetComplete(ETrue);
+    messageEntry.iServiceId = defaultServiceId;
+    messageEntry.iRelatedId = 0;
+    
+    if (parameters.iFolderType == EDrafts) 
+        messageEntry.SetReadOnly(EFalse);
+    else
+        messageEntry.SetReadOnly(ETrue);
+
+	messageEntry.iMtmData1 = KMmsMessageMRetrieveConf | KMmsMessageMobileTerminated;
+	
+    clientMtm->Entry().ChangeL(messageEntry);
+    
+    // id has been generated, store it for being able to delete
+    // only entries created with Creator
+    iEntryIds.Append( messageEntry.Id() );
+    
+    CleanupStack::PopAndDestroy(2); // registry, clientMtm        
+        
+
+    return err;
+    }
+
+//----------------------------------------------------------------------------
+
+TInt CCreatorMessages::CreateEmailEntryL(const CMessagesParameters& parameters)
+    {
+    LOGSTRING("Creator: CCreatorMessages::CreateEmailEntryL");
+
+    TInt err = KErrNone;
+
+    // init    
+    if( iSession == 0 )
+        {
+        iSession = CMsvSession::OpenSyncL(*this);
+        }
+    
+    CClientMtmRegistry* registry = CClientMtmRegistry::NewL(*iSession);
+    CleanupStack::PushL(registry);
+    
+    // get the client mtm and return if it isn't supported in the system        
+    CSmtpClientMtm* clientMtm = NULL;
+    TRAP(err, clientMtm = static_cast<CSmtpClientMtm*>(registry->NewMtmL(KUidMsgTypeSMTP)));
+    
+    if (err || !clientMtm)
+        {
+        CAknErrorNote* note = new(ELeave) CAknErrorNote;
+        note->ExecuteLD(_L("Email: Message type module not found"));
+        CleanupStack::PopAndDestroy(2);
+        User::Leave(KErrNotFound);
+        }  
+    CleanupStack::PushL(clientMtm);   
+
+    // create a new object to access an existing entry
+    CMsvEntry* msvEntry = CMsvEntry::NewL(*iSession, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering());
+    CleanupStack::PushL(msvEntry);
+  
+    // get default service
+    TMsvId defaultServiceId(0);
+    TRAP(err, defaultServiceId = clientMtm->DefaultServiceL());
+    if (err)
+        {
+        CAknErrorNote* note = new(ELeave) CAknErrorNote;
+        note->ExecuteLD(_L("Email: Define a mailbox first"));
+        CleanupStack::PopAndDestroy(2);
+        User::Leave(KErrNotFound);
+        } 
+                
+    // set folder type
+    switch (parameters.iFolderType)
+        {
+        case EInbox:    { msvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);   break; }
+        case EDrafts:   { msvEntry->SetEntryL(KMsvDraftEntryId);              break; }
+        case EOutbox:   { msvEntry->SetEntryL(KMsvGlobalOutBoxIndexEntryId);  break; }
+        case ESent:     { msvEntry->SetEntryL(KMsvSentEntryId);               break; }
+        case EMailbox:  { msvEntry->SetEntryL(iUserSelectedMailbox);          break; }
+        default:        { User::Panic(_L("Folder Type"), 871);                break; } 
+        }
+        
+    // mtm takes ownership of entry context	
+    CleanupStack::Pop(msvEntry);
+    clientMtm->SetCurrentEntryL(msvEntry); 
+
+    // create a new message
+    clientMtm->CreateMessageL(defaultServiceId);
+
+    // set subject
+    clientMtm->SetSubjectL( parameters.iMessageSubject->Des() );
+    
+    // set body
+    clientMtm->Body().Reset();
+    clientMtm->Body().InsertL(0, parameters.iMessageBodyText->Des()); 
+
+    // get the entry of the message
+    TMsvEntry messageEntry = clientMtm->Entry().Entry();
+    
+    // set the address fields
+    if (parameters.iFolderType == EInbox)
+        {
+        AddSenderToMtmAddresseeL(*clientMtm, parameters, ETrue );
+        SetSenderToEntryDetails(messageEntry, parameters, ETrue);
+        messageEntry.iMtm = KUidMsgTypeIMAP4;  // or any other than KUidMsgTypeSMTP to display 'from' field instead of 'to' field 
+        }
+    else
+        {
+        // Add all recipients to clientMtm
+        AddRecipientsL( *clientMtm, parameters, ETrue );
+        SetRecipientToEntryDetails(messageEntry, parameters, EFalse);        
+        }
+
+    // set the description field same as the message subject
+    messageEntry.iDescription.Set( parameters.iMessageSubject->Des().Left(KSmsDescriptionLength) );
+
+    // save the changes done above
+    clientMtm->Entry().ChangeL(messageEntry);
+    
+    // get an access to the message store
+    CMsvStore* store = msvEntry->EditStoreL();
+    CleanupStack::PushL(store); 
+    
+    // save the attachments
+    HandleAttachementsL(parameters, store, err);
+//    for (TInt i=0; i<parameters.iAttachments->Count(); i++)
+//        {
+//        TFileName sourceFileName = iEngine->TestDataPathL( (CCreatorEngine::TTestDataPath) parameters.iAttachments->At(i) );
+//
+//        TParse parser;
+//        parser.Set(sourceFileName, NULL, NULL);
+//        TFileName shortFileName = parser.NameAndExt();
+//
+//        // get the mime type
+//        RApaLsSession ls;
+//        User::LeaveIfError(ls.Connect());
+//        CleanupClosePushL<RApaLsSession>(ls);
+//        TUid appUid;
+//        TDataType dataType;
+//        ls.AppForDocument(sourceFileName, appUid, dataType);
+//        CleanupStack::PopAndDestroy(); //ls
+//        TPtrC8 mimeType = dataType.Des8();
+//        
+//        // attachment settings
+//        MMsvAttachmentManager& attachMan = store->AttachmentManagerL();
+//        CMsvAttachment* attachmentInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile); // ownership of attachmentInfo will be transferred
+//        attachmentInfo->SetAttachmentNameL( shortFileName );        
+//        attachmentInfo->SetMimeTypeL( mimeType );        
+//
+//        // save
+//        CAsyncWaiter* waiter = CAsyncWaiter::NewLC();
+//
+//        TRAP(err, attachMan.AddAttachmentL(sourceFileName, attachmentInfo, waiter->iStatus ));
+//        if (err == KErrNone)
+//            waiter->StartAndWait();
+//        else
+//            LOGSTRING2("Creator: CCreatorMessages::CreateEmailEntryL failed to attach %S", &sourceFileName);
+//
+//        CleanupStack::PopAndDestroy(waiter);  
+//        }
+
+    // save the changes made to the message store
+    store->CommitL();
+    CleanupStack::PopAndDestroy(store); 
+            
+    // save the message      
+    clientMtm->SaveMessageL();
+    	
+	// final fine tuning
+	TMsvEmailEntry temailEntry = static_cast<TMsvEmailEntry>(messageEntry);
+    temailEntry.SetMessageFolderType(EFolderTypeUnknown);
+    temailEntry.SetDisconnectedOperation(ENoDisconnectedOperations);
+    temailEntry.SetEncrypted(EFalse);
+    temailEntry.SetSigned(EFalse);
+    temailEntry.SetVCard(EFalse);
+    temailEntry.SetVCalendar(EFalse);
+    temailEntry.SetReceipt(EFalse);
+    temailEntry.SetMHTMLEmail(EFalse);
+    temailEntry.SetBodyTextComplete(ETrue);
+    
+	if (parameters.iAttachments->Count() > 0)
+        temailEntry.SetAttachment(ETrue);
+    else
+        temailEntry.SetAttachment(EFalse);
+	
+    temailEntry.iDate.HomeTime();
+    temailEntry.SetVisible(ETrue);
+    temailEntry.SetInPreparation(EFalse);
+    if (parameters.iCreateAsUnread)
+        {
+        temailEntry.SetUnread(ETrue);
+        temailEntry.SetNew(ETrue);
+        }
+    else
+        {
+        temailEntry.SetUnread(EFalse);
+        temailEntry.SetNew(EFalse);
+        }
+    temailEntry.SetComplete(ETrue);
+    temailEntry.iServiceId = defaultServiceId;
+    temailEntry.iRelatedId = 0;
+    
+    clientMtm->Entry().ChangeL(temailEntry);
+
+    // reset email headers
+    CImHeader* header = CImHeader::NewLC();
+    CMsvStore* msvStore = msvEntry->EditStoreL();
+    CleanupStack::PushL(msvStore);
+    header->RestoreL(*msvStore);
+    header->SetSubjectL( parameters.iMessageSubject->Des() );
+    if( iSenderArray.Count() == 0 )
+        {
+        GetSendersL(iSenderArray, parameters, ETrue, 1 );
+        }
+    
+    if( iSenderArray.Count() > 0 )
+        {
+        header->SetFromL(iSenderArray[0]->Des());
+        }
+    else
+        {
+        header->SetFromL( parameters.iSenderAddress->Des() );
+        }
+    if( parameters.iRecipientAddress->Length() > 0 )
+        {
+        header->SetReceiptAddressL( parameters.iRecipientAddress->Des() );
+        }
+    else if( parameters.iRecipientAddressArray.Count() > 0 )
+        {
+        header->SetReceiptAddressL( parameters.iRecipientAddressArray[0]->Des());
+        }
+    
+    header->StoreL( *msvStore );
+    msvStore->CommitL();
+    CleanupStack::PopAndDestroy(2); // msvStore, header
+    
+    // id has been generated, store it for being able to delete
+    // only entries created with Creator
+    iEntryIds.Append( messageEntry.Id() );
+    
+    CleanupStack::PopAndDestroy(2); // registry, clientMtm 
+
+    return err;
+    }
+
+//----------------------------------------------------------------------------
+
+TInt CCreatorMessages::CreateSmartMessageEntryL(const CMessagesParameters& parameters)
+    {
+    LOGSTRING("Creator: CCreatorMessages::CreateSmartMessageEntryL");
+
+    TInt err = KErrNone;
+
+    // init    
+    if( iSession == 0 )
+        {
+        iSession = CMsvSession::OpenSyncL(*this);
+        }
+    
+    CClientMtmRegistry* registry = CClientMtmRegistry::NewL(*iSession);
+    CleanupStack::PushL(registry);
+
+    // get the client mtm and return if it isn't supported in the system        
+    CSmsClientMtm* clientMtm = NULL;
+    TRAP(err, clientMtm = static_cast<CSmsClientMtm*>(registry->NewMtmL(KUidMsgTypeSMS)));
+    if (err || !clientMtm)
+        {
+        CAknErrorNote* note = new(ELeave) CAknErrorNote;
+        note->ExecuteLD(_L("BIO: Message type module not found"));
+        CleanupStack::PopAndDestroy(2);
+        User::Leave(KErrNotFound);
+        }  
+    CleanupStack::PushL(clientMtm);   
+
+    // create a new object to access an existing entry
+    CMsvEntry* msvEntry = CMsvEntry::NewL(*iSession, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering());
+    CleanupStack::PushL(msvEntry);
+  
+    // get default service
+    TMsvId defaultServiceId = 0;
+    TRAP(err, defaultServiceId = clientMtm->DefaultServiceL());
+    if (err)
+        {
+        CAknErrorNote* note = new(ELeave) CAknErrorNote;
+        note->ExecuteLD(_L("SMS: Define a SMS centre first"));
+        CleanupStack::PopAndDestroy(2);
+        User::Leave(KErrNotFound);
+        } 
+    
+    // set folder type
+    switch (parameters.iFolderType)
+        {
+        case EInbox:    { msvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);   break; }
+        case EDrafts:   { msvEntry->SetEntryL(KMsvDraftEntryId);              break; }
+        case EOutbox:   { msvEntry->SetEntryL(KMsvGlobalOutBoxIndexEntryId);  break; }
+        case ESent:     { msvEntry->SetEntryL(KMsvSentEntryId);               break; }
+        default:        { User::Panic(_L("Folder Type"), 871);                break; } 
+        }
+        
+    // mtm takes ownership of entry context	
+    CleanupStack::Pop(msvEntry);
+    clientMtm->SetCurrentEntryL(msvEntry);    
+    
+    // create a new message
+    clientMtm->CreateMessageL(defaultServiceId);
+
+     // set the from field to sms header
+    if (parameters.iFolderType == EInbox)
+        {
+        CSmsHeader& smsHeader = clientMtm->SmsHeader();
+        
+        if( parameters.iSenderAddress )
+            {
+            smsHeader.SetFromAddressL( parameters.iSenderAddress->Des() );
+            }
+        else
+            {
+            smsHeader.SetFromAddressL(KEmpty);
+            }
+        }       
+
+    // set body, the BIO message itself
+    clientMtm->Body().Reset();
+    clientMtm->Body().InsertL(0, _L("Business Card\nTester Mike\nThe Company Ltd.\nSoftware Engineer\ntel +358 66 1234567\n")); 
+
+    // get the entry of the message
+    TMsvEntry messageEntry = clientMtm->Entry().Entry();
+
+    // TO-DO: Add support for all BIO messages, currently just insert a business card message ... :
+    // set the message type
+    // parameters.iBIOMessageType ...
+    clientMtm->BioTypeChangedL(KUidBIOBusinessCardMsg);
+    messageEntry.iBioType = KUidBIOBusinessCardMsg.iUid;
+
+    // set the details field
+    if (parameters.iFolderType == EInbox)
+        {
+        SetSenderToEntryDetails(messageEntry, parameters, EFalse);        
+        }        
+    else
+        {
+        SetRecipientToEntryDetails(messageEntry, parameters, EFalse);
+        }
+
+    // set the subject line
+    messageEntry.iDescription.Set( parameters.iMessageSubject->Des().Left(KSmsDescriptionLength) );
+
+    // set correct MTM type
+    messageEntry.iMtm= KUidBIOMessageTypeMtm;
+
+    // save the changes done above
+    clientMtm->Entry().ChangeL(messageEntry);
+
+    // save the message     
+    clientMtm->SaveMessageL();
+    	
+	// final fine tuning
+    messageEntry.SetAttachment(EFalse);
+    messageEntry.iDate.HomeTime();
+    messageEntry.SetVisible(ETrue);
+    messageEntry.SetInPreparation(EFalse);
+    if (parameters.iCreateAsUnread)
+        {
+        messageEntry.SetUnread(ETrue);
+        messageEntry.SetNew(ETrue);
+        }
+    else
+        {
+        messageEntry.SetUnread(EFalse);
+        messageEntry.SetNew(EFalse);
+        }
+    messageEntry.SetComplete(ETrue);
+    messageEntry.iServiceId = defaultServiceId;
+    messageEntry.iRelatedId = 0;
+    clientMtm->Entry().ChangeL(messageEntry);
+    
+    // id has been generated, store it for being able to delete
+    // only entries created with Creator
+    iEntryIds.Append( messageEntry.Id() );
+    
+    CleanupStack::PopAndDestroy(2); // registry, clientMtm
+        
+    
+    return err;
+    }
+
+//----------------------------------------------------------------------------
+
+TInt CCreatorMessages::CreateObexEntryL(TUid aMtm, const CMessagesParameters& parameters)
+    {
+    LOGSTRING("Creator: CCreatorMessages::CreateObexEntryL");
+
+    TInt err = KErrNone;
+
+    // init    
+    if( iSession == 0 )
+        {
+        iSession = CMsvSession::OpenSyncL(*this);
+        }    
+    CClientMtmRegistry* registry = CClientMtmRegistry::NewL(*iSession);
+    CleanupStack::PushL(registry);
+
+    // get the client mtm and return if it isn't supported in the system        
+    CObexClientMtm* clientMtm = NULL;
+    TRAP(err, clientMtm = static_cast<CObexClientMtm*>(registry->NewMtmL(aMtm)));
+    if (err || !clientMtm)
+        {
+        CAknErrorNote* note = new(ELeave) CAknErrorNote;
+        note->ExecuteLD(_L("Obex: Message type module not found"));
+        CleanupStack::PopAndDestroy(2);
+        User::Leave(KErrNotFound);
+        }  
+    CleanupStack::PushL(clientMtm);   
+
+    // create a new object to access an existing entry
+    CMsvEntry* msvEntry = CMsvEntry::NewL(*iSession, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering());
+    CleanupStack::PushL(msvEntry);
+  
+    // define default service
+    TMsvId defaultServiceId = 0;
+    
+    // set folder type
+    switch (parameters.iFolderType)
+        {
+        case EInbox:    { msvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);   break; }
+        case EDrafts:   { msvEntry->SetEntryL(KMsvDraftEntryId);              break; }
+        case EOutbox:   { msvEntry->SetEntryL(KMsvGlobalOutBoxIndexEntryId);  break; }
+        case ESent:     { msvEntry->SetEntryL(KMsvSentEntryId);               break; }
+        default:        { User::Panic(_L("Folder Type"), 871);                break; } 
+        }
+        
+    // mtm takes ownership of entry context	
+    CleanupStack::Pop(msvEntry);
+    clientMtm->SetCurrentEntryL(msvEntry);    
+    
+    // create a new message
+    clientMtm->CreateMessageL(defaultServiceId);
+
+    // get the entry of the message
+    TMsvEntry messageEntry = clientMtm->Entry().Entry();
+
+    // set subject
+    clientMtm->SetSubjectL( parameters.iMessageSubject->Des() );
+    messageEntry.iDescription.Set( parameters.iMessageSubject->Des().Left(KSmsDescriptionLength) );
+
+    // set body, must be empty for obex messages
+    clientMtm->Body().Reset();
+
+    // set the details field and
+    if (parameters.iFolderType == EInbox)
+        {
+        SetSenderToEntryDetails(messageEntry, parameters, EFalse);
+        }        
+    else
+        {
+        SetRecipientToEntryDetails(messageEntry, parameters, EFalse);
+        }
+    
+    // set mtm
+    messageEntry.iMtm = aMtm;
+    messageEntry.iType = KUidMsvMessageEntry;
+    messageEntry.iServiceId = KMsvUnknownServiceIndexEntryId;
+
+    // save the changes done above
+    clientMtm->Entry().ChangeL(messageEntry);
+
+    // save the message      
+    clientMtm->SaveMessageL();
+    	
+	// final fine tuning
+    messageEntry.iDate.HomeTime();
+    messageEntry.SetVisible(ETrue);
+    messageEntry.SetInPreparation(EFalse);
+    if (parameters.iCreateAsUnread)
+        {
+        messageEntry.SetUnread(ETrue);
+        messageEntry.SetNew(ETrue);
+        }
+    else
+        {
+        messageEntry.SetUnread(EFalse);
+        messageEntry.SetNew(EFalse);
+        }
+    messageEntry.SetComplete(ETrue);
+    clientMtm->Entry().ChangeL(messageEntry);
+    
+    // save the attachment
+    if (parameters.iAttachments->Count() >= 1)
+        {
+        // create a new entry for the attachment
+        TMsvEntry attachTEntry;
+        attachTEntry.iType      = KUidMsvAttachmentEntry;
+        attachTEntry.iServiceId = KMsvUnknownServiceIndexEntryId;   
+        attachTEntry.iMtm       = KUidMsgTypeBt; //save as bt message
+        
+        msvEntry->CreateL(attachTEntry);
+        
+        CMsvEntry* attachEntry = iSession->GetEntryL(attachTEntry.Id());
+        clientMtm->SetCurrentEntryL(attachEntry);
+                
+        // get source file
+        TFileName sourceFileName = iEngine->TestDataPathL( (CCreatorEngine::TTestDataPath) parameters.iAttachments->At(0) );
+
+        // get the mime type
+        RApaLsSession ls;
+        User::LeaveIfError(ls.Connect());
+        CleanupClosePushL<RApaLsSession>(ls);
+        TUid appUid;
+        TDataType mimeType;
+        ls.AppForDocument(sourceFileName, appUid, mimeType);
+        CleanupStack::PopAndDestroy(); //ls
+        
+        CAsyncWaiter* waiter = CAsyncWaiter::NewLC();
+
+        // add an attachment to the current message entry
+        TRAP(err, clientMtm->AddAttachmentL( sourceFileName, mimeType.Des8(), 0, waiter->iStatus ));
+        if (err == KErrNone)
+            waiter->StartAndWait();
+        else
+            LOGSTRING2("Creator: CCreatorMessages::CreateObexEntryL failed to attach %S", &sourceFileName);
+        
+        CleanupStack::PopAndDestroy(waiter);
+        }
+    
+    // id has been generated, store it for being able to delete
+    // only entries created with Creator
+    iEntryIds.Append( messageEntry.Id() );
+    
+    CleanupStack::PopAndDestroy(2); // registry, clientMtm 
+
+
+    return err;
+    }
+
+//----------------------------------------------------------------------------
+
+void CCreatorMessages::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) // from MMsvSessionObserver
+    {
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorMessages::SetSenderToEntryDetails(TMsvEntry& aMsgEntry, const CMessagesParameters& aParameters, TBool aUseEmailAddress)
+    {        
+    // Only one sender allowed:
+    if( iSenderArray.Count() == 0 )
+        {
+        GetSendersL(iSenderArray, aParameters, aUseEmailAddress, 1 );
+        }
+    if( iSenderArray.Count() > 0 )
+        {        
+        aMsgEntry.iDetails.Set( iSenderArray[0]->Des() );        
+        }
+    else
+        {
+        aMsgEntry.iDetails.Set(KEmpty);
+        }        
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorMessages::SetRecipientToEntryDetails(TMsvEntry& aMsgEntry, const CMessagesParameters& aParameters, TBool aUseEmailAddress)
+    {        
+    // Only one sender allowed:
+    GetAllRecipientsL(iRecipientArray, aParameters, aUseEmailAddress);
+    if( iRecipientArray.Count() > 0 )
+        {
+        const TDesC& temp = iRecipientArray[0]->Des();
+        aMsgEntry.iDetails.Set( temp );
+        }
+    else
+        {
+        aMsgEntry.iDetails.Set(KEmpty);
+        }        
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorMessages::AddSenderToMtmAddresseeL(CBaseMtm& aMtm, const CMessagesParameters& aParameters, TBool aUseEmailAddress )
+    {    
+    // Only one sender allowed:
+    if( iSenderArray.Count() == 0 )
+        {
+        GetSendersL(iSenderArray, aParameters, aUseEmailAddress, 1 );
+        }
+    
+    for( TInt i = 0; i < iSenderArray.Count(); ++i )
+        {
+        aMtm.AddAddresseeL( iSenderArray[i]->Des() );        
+        }    
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorMessages::AddMtmSenderL(CMmsClientMtm& aMtm, const CMessagesParameters& aParameters, TBool aUseEmailAddress )
+    {    
+    // Only one sender allowed:
+    if( iSenderArray.Count() == 0 )
+        {
+        GetSendersL(iSenderArray, aParameters, aUseEmailAddress, 1 );
+        }
+    
+    if( iSenderArray.Count() > 0 )
+        {
+        aMtm.SetSenderL( iSenderArray[0]->Des() );        
+        }    
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorMessages::GetSendersL(RPointerArray<HBufC>& aSenderArray, const CMessagesParameters& aParameters, TBool aUseEmailAddress, TInt aMaxNum )
+    {
+    TInt counter = 0;
+    
+    if( counter < aMaxNum || aMaxNum == KUndef )
+        {
+        if( aParameters.iSenderAddress && aParameters.iSenderAddress->Length() > 0 )
+            {
+            HBufC* temp = HBufC::NewL(aParameters.iSenderAddress->Length());
+            CleanupStack::PushL(temp);
+            temp->Des().Copy(aParameters.iSenderAddress->Des());
+            aSenderArray.AppendL( temp );
+            CleanupStack::Pop(); // temp
+            ++counter;
+            }
+        }
+            
+    if( counter < aMaxNum || aMaxNum == KUndef )
+        {
+        RPointerArray<HBufC> tempArray;
+        CleanupResetAndDestroyPushL( tempArray );
+        GetLinkedAddressesL(tempArray, aParameters.iSenderLinkIds, aUseEmailAddress, aParameters.iNumberOfExistingSenders);
+        for( TInt i = 0; i < tempArray.Count() && (counter < aMaxNum || aMaxNum == KUndef); ++i )
+            {
+            HBufC* temp = tempArray[i]->AllocLC();
+            aSenderArray.AppendL(temp);
+            CleanupStack::Pop(); // temp
+            ++counter;
+            }
+        CleanupStack::PopAndDestroy(); // tempArray
+        }    
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorMessages::AddRecipientsL(CBaseMtm& aMtm, const CMessagesParameters& aParameters, TBool aUseEmailAddress )
+    {
+    GetAllRecipientsL(iRecipientArray, aParameters, aUseEmailAddress);
+    for( TInt i = 0; i < iRecipientArray.Count(); ++i )
+        {
+        aMtm.AddAddresseeL( iRecipientArray[i]->Des() );        
+        }    
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorMessages::GetAllRecipientsL(RPointerArray<HBufC>& aRecipientArray, const CMessagesParameters& aParameters, TBool aUseEmailAddress )
+    {
+    
+    // If iRecipientAddress is given, add it to the array:
+    if( aParameters.iRecipientAddress && aParameters.iRecipientAddress->Length() > 0 )
+        {
+        HBufC* temp = HBufC::NewL(aParameters.iRecipientAddress->Length());
+        CleanupStack::PushL(temp);
+        temp->Des().Copy(aParameters.iRecipientAddress->Des());
+        aRecipientArray.AppendL( temp );
+        CleanupStack::Pop(); // temp
+        }
+    
+    // Add all recipients listed in iRecipientAddressArray:
+    for( TInt i = 0; i < aParameters.iRecipientAddressArray.Count(); ++i )
+        {
+        HBufC* temp = HBufC::NewL(aParameters.iRecipientAddressArray[i]->Length());
+        CleanupStack::PushL(temp);
+        temp->Des().Copy(aParameters.iRecipientAddressArray[i]->Des());
+        aRecipientArray.AppendL( temp );
+        CleanupStack::Pop(); // temp        
+        }
+    
+    // Get all linked addresses. 
+    GetLinkedAddressesL(aRecipientArray, aParameters.iRecipientLinkIds, aUseEmailAddress, aParameters.iNumberOfExistingRecipients);
+    }
+
+/*
+ * Get all linked addresses. This method gets addresses that are linked with contact-set id and 
+ * existing addresses from the contact database, if required.
+ */
+void CCreatorMessages::GetLinkedAddressesL(
+        RPointerArray<HBufC>& aAddressArray, 
+        const RArray<TLinkIdParam>& aLinkIds, 
+        TBool aUseEmailAddress,
+        TInt aNumOfExistingAddresses )
+    {
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+    
+    if( aNumOfExistingAddresses > 0 || aLinkIds.Count() > 0 )
+        {
+        // First create contact manager:
+        if( iContactManager == 0)
+        	{
+        	CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewLC();
+        	uriArray->AppendL( TVPbkContactStoreUriPtr(VPbkContactStoreUris::DefaultCntDbUri()));
+        	iContactManager = CVPbkContactManager::NewL( *uriArray, &CCoeEnv::Static()->FsSession());
+        	CleanupStack::PopAndDestroy(uriArray);
+
+        
+            // Then open the stores:
+                
+            MVPbkContactStoreList& storeList = iContactManager->ContactStoresL();              
+            storeList.OpenAllL(*this);
+            iWaiter->StartAndWait(); 
+            _LIT(dbUri, "cntdb://c:contacts.cdb");
+            TVPbkContactStoreUriPtr uri(dbUri);                   
+            iStore = storeList.Find(uri);
+        	}
+        // Existing attendees:
+        if( aNumOfExistingAddresses > 0 )
+        	{        	
+        	if( iStore )
+        		{
+        		const MVPbkFieldTypeList& fieldList = iStore->StoreProperties().SupportedFields();
+
+        		// get contacts, results will be set to iExistingContacts
+        		MVPbkContactOperationBase* operation = iContactManager->FindL(_L(""), fieldList , *this);
+        		if (operation)
+        			{
+        			CleanupDeletePushL( operation );
+        			iWaiter->StartAndWait();//Making asynchronous FindL to synchronous
+        			CleanupStack::Pop(operation);
+        			delete operation;
+        			}
+        		if( iExistingContacts )
+        			{
+        			// Loop the links pointing to the existing contacts:
+        			TInt addedContacts = 0;
+        			for( TInt i = 0; i < iExistingContacts->Count() && addedContacts < aNumOfExistingAddresses; ++i )
+        				{
+        				// Get the address of the actual contact based on the contact link. Results are stored in
+        				// iTmpEmail and iTmpPhoneNumber
+        				MVPbkContactOperationBase* operation = iContactManager->RetrieveContactL( iExistingContacts->At(i), *this );
+        				if (operation)
+        					{
+        					CleanupDeletePushL( operation );
+        					iWaiter->StartAndWait(); // Making asynchronous RetrieveContactL to synchronous
+        					CleanupStack::Pop(); // operation
+        					delete operation;
+        					operation = 0;
+        					HandleSingleContactResultL();
+        					if( aUseEmailAddress && iTmpEmail && iTmpEmail->Length() > 0 )
+        						{
+        						HBufC* temp = HBufC::NewL(iTmpEmail->Length());
+        						CleanupStack::PushL(temp);
+        						temp->Des().Copy(iTmpEmail->Des());
+        						aAddressArray.AppendL(temp);
+        						CleanupStack::Pop(); // temp
+        						delete iTmpEmail;
+        						iTmpEmail = 0; // The pointer is owned by the aAddressArray now.    
+        						++addedContacts;
+        						}
+        					else if( !aUseEmailAddress && iTmpPhoneNumber && iTmpPhoneNumber->Length() > 0 )
+        						{
+        						HBufC* temp = HBufC::NewL(iTmpPhoneNumber->Length());
+        						CleanupStack::PushL(temp);
+        						temp->Des().Copy(iTmpPhoneNumber->Des());
+        						aAddressArray.AppendL(temp);
+        						CleanupStack::Pop(); // temp
+        						delete iTmpPhoneNumber;
+        						iTmpPhoneNumber = 0; // The pointer is owned by the aAddressArray now.
+        						++addedContacts;
+        						}
+        					}                            
+        				}
+        			}
+        		} 
+        	}
+
+        // Loop linked contact-set ids:
+        for( TInt i = 0; i < aLinkIds.Count(); ++i )
+        	{
+        	TLinkIdParam id = aLinkIds[i];
+        	// Get all contact links in the contact-set...
+        	RPointerArray<MVPbkContactLink>& links = ContactLinkCache::Instance()->ContactLinks(id.iLinkId);
+        	// ... and loop the links:
+        	TInt addedContacts = 0;
+        	for( TInt j = 0; j < links.Count() && (id.iLinkAmount < 0 || addedContacts < id.iLinkAmount); ++j )
+        		{
+        		// Again retrieve contact based on the contact link. Results are stored in
+        		// iTmpEmail and iTmpPhoneNumber:
+        		MVPbkContactOperationBase* operation = iContactManager->RetrieveContactL( *(links[j]), *this );
+        		if (operation)
+        			{
+        			CleanupDeletePushL( operation );
+        			iWaiter->StartAndWait(); // Making asynchronous RetrieveContactL to synchronous
+        			CleanupStack::Pop(operation);
+        			delete operation;
+        			operation = 0;
+        			HandleSingleContactResultL();
+        			if( aUseEmailAddress && iTmpEmail && iTmpEmail->Length() > 0 )
+        				{                                    
+        				aAddressArray.AppendL(iTmpEmail);
+        				iTmpEmail = 0; // The pointer is owned by the aAddressArray now.
+        				++addedContacts;
+        				}
+        			else if( !aUseEmailAddress && iTmpPhoneNumber && iTmpPhoneNumber->Length() > 0 )
+        				{
+        				aAddressArray.AppendL(iTmpPhoneNumber);
+        				iTmpPhoneNumber = 0; // The pointer is owned by the aAddressArray now.
+        				++addedContacts;
+        				}
+        			}                 
+        		}
+        	}
+
+        //if( iContactManager )
+        //	iContactManager->ContactStoresL().CloseAll(*this);
+        }
+#endif
+}
+
+//----------------------------------------------------------------------------
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+void CCreatorMessages::VPbkSingleContactOperationComplete(
+            MVPbkContactOperationBase& /*aOperation*/,
+            MVPbkStoreContact* aContact )
+    {
+    LOGSTRING("Creator: CCreatorMessages::VPbkSingleContactOperationComplete" );
+    iWaiter->Cancel();
+    delete iTempContact;    
+    iTempContact = aContact;
+    }
+
+void CCreatorMessages::HandleSingleContactResultL()
+	{
+    if( iTempContact )
+        {        
+        TPtrC phoneNumber;        
+        TPtrC email;
+       
+        // Put contact's name to temporary member:
+        delete iTmpPhoneNumber;
+        iTmpPhoneNumber = 0;
+        delete iTmpEmail;
+        iTmpEmail = 0;
+       
+        TBool phFound = EFalse;
+        TBool emailFound = EFalse;
+        
+        MVPbkStoreContactFieldCollection& fields = iTempContact->Fields();
+        TInt fieldCount = fields.FieldCount();
+        for (TInt i = 0; i < fieldCount; ++i)
+            {
+            MVPbkStoreContactField& field = fields.FieldAt(i);
+            MVPbkContactFieldData& fieldData = field.FieldData();
+            const MVPbkFieldType* fieldType = field.BestMatchingFieldType();
+            
+            if( fieldType ) 
+                {
+                // Find phone number and email:
+                TInt fieldId( fieldType->FieldTypeResId() );
+            
+                TVPbkFieldStorageType dataType = fieldData.DataType();
+                if( dataType == EVPbkFieldStorageTypeText)
+                    {
+                    MVPbkContactFieldTextData& textData = MVPbkContactFieldTextData::Cast(fieldData);                
+                    if( !phFound &&
+                        (fieldId == R_VPBK_FIELD_TYPE_LANDPHONEGEN ||
+                        fieldId == R_VPBK_FIELD_TYPE_LANDPHONEHOME ||
+                        fieldId == R_VPBK_FIELD_TYPE_LANDPHONEWORK ||                      
+                        fieldId == R_VPBK_FIELD_TYPE_MOBILEPHONEGEN ||
+                        fieldId == R_VPBK_FIELD_TYPE_MOBILEPHONEHOME ||
+                        fieldId == R_VPBK_FIELD_TYPE_MOBILEPHONEWORK ))
+                        {                    
+                        phoneNumber.Set(textData.Text());
+                        phFound = ETrue;
+                        }
+                    else if( !emailFound &&
+                            (fieldId == R_VPBK_FIELD_TYPE_EMAILGEN ||
+                            fieldId == R_VPBK_FIELD_TYPE_EMAILHOME ||
+                            fieldId == R_VPBK_FIELD_TYPE_EMAILWORK ))
+                        {
+                        email.Set(textData.Text());
+                        emailFound = ETrue;
+                        }
+                    
+                    if( phFound && emailFound )
+                        break; // No need to loop more fields.
+                    }            
+                }
+            }
+        if( phoneNumber.Length() > 0 )
+            {
+            delete iTmpPhoneNumber;
+            iTmpPhoneNumber = 0;
+            iTmpPhoneNumber = HBufC::NewL(phoneNumber.Length());
+            iTmpPhoneNumber->Des().Copy(phoneNumber); 
+            }                
+        if( email.Length() > 0 )
+            {
+            delete iTmpEmail;
+            iTmpEmail = 0;
+            iTmpEmail = HBufC::NewL(email.Length());            	
+            iTmpEmail->Des().Copy(email);
+            }
+        delete iTempContact;
+        iTempContact = 0;
+        }
+    }
+    
+void CCreatorMessages::VPbkSingleContactOperationFailed(
+            MVPbkContactOperationBase& /*aOperation*/, 
+            TInt aError )
+    {
+    LOGSTRING2("Creator: CCreatorMessages::VPbkSingleContactOperationFailed - Error: %d", aError );
+    iWaiter->Cancel();
+    }
+
+void CCreatorMessages::OpenComplete()
+    {    
+    LOGSTRING("Creator: CCreatorMessages::OpenComplete()");
+    iWaiter->Cancel();
+    }
+
+void CCreatorMessages::StoreReady(MVPbkContactStore& /*aContactStore*/)
+    {
+    LOGSTRING("Creator: CCreatorMessages::StoreReady()");
+    iWaiter->Cancel();
+    }
+
+void CCreatorMessages::StoreUnavailable(MVPbkContactStore& /*aContactStore*/, 
+        TInt /*aReason*/)
+    {
+    LOGSTRING("Creator: CCreatorMessages::StoreUnavailable()");
+    iWaiter->Cancel();
+    }
+
+
+void CCreatorMessages::HandleStoreEventL(
+        MVPbkContactStore& /*aContactStore*/, 
+        TVPbkContactStoreEvent /*aStoreEvent*/)
+    {
+    LOGSTRING("Creator: CCreatorMessages::HandleStoreEventL()");
+    iWaiter->Cancel();
+    }
+
+void CCreatorMessages::FindCompleteL( MVPbkContactLinkArray* aResults )
+    {
+    LOGSTRING("Creator: CCreatorMessages::FindCompleteL()");
+    iWaiter->Cancel();
+    delete iExistingContacts;
+    iExistingContacts = aResults;
+    }
+
+void CCreatorMessages::FindFailed( TInt aError )
+    {
+    LOGSTRING2("Creator: CCreatorMessages:FindFailed() - Error: %d", aError);    
+    iWaiter->Cancel();
+    delete iExistingContacts;
+    iExistingContacts = 0;
+    }
+#endif
+
+
+//----------------------------------------------------------------------------
+void CCreatorMessages::DeleteAllL()
+    {
+    LOGSTRING("Creator: CCreatorMessages::DeleteAllL");
+    DeleteAllMessagesL( EFalse );
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorMessages::DeleteAllMessagesL( TBool aOnlyCreatedWithCreator )
+    {
+    LOGSTRING("Creator: CCreatorMessages::DeleteAllMessagesL");
+    TInt err( KErrNone );
+    
+    // init    
+    if( iSession == 0 )
+        {
+        iSession = CMsvSession::OpenSyncL(*this);
+        }
+    
+    CClientMtmRegistry* registry = CClientMtmRegistry::NewL(*iSession);
+    CleanupStack::PushL( registry );
+
+    // get the client mtm and return if it isn't supported in the system        
+    CSmsClientMtm* clientMtm( NULL );
+    TRAP( err, clientMtm = static_cast<CSmsClientMtm*>( registry->NewMtmL( KUidMsgTypeSMS ) ) );
+    if ( err || !clientMtm )
+        {
+        CAknErrorNote* note = new (ELeave) CAknErrorNote();
+        note->ExecuteLD( _L( "SMS: Message type module not found" ) );
+        CleanupStack::PopAndDestroy( 2 );
+        User::Leave( KErrNotFound );
+        }
+    CleanupStack::PushL( clientMtm );
+    
+    TRAP_IGNORE( DeleteAllFromFolderL( KMsvGlobalInBoxIndexEntryId, iSession, clientMtm, aOnlyCreatedWithCreator ) );
+    TRAP_IGNORE( DeleteAllFromFolderL( KMsvDraftEntryId, iSession, clientMtm, aOnlyCreatedWithCreator ) );
+    TRAP_IGNORE( DeleteAllFromFolderL( KMsvGlobalOutBoxIndexEntryId, iSession, clientMtm, aOnlyCreatedWithCreator ) );
+    TRAP_IGNORE( DeleteAllFromFolderL( KMsvSentEntryId, iSession, clientMtm, aOnlyCreatedWithCreator ) );
+    
+    // reset must be done here, because iEntryIds is stored in destructor
+    iEntryIds.Reset();
+    
+    // all entries deleted, remove the Messages related registry
+    iEngine->RemoveStoreL( KUidDictionaryUidMessages );
+
+    CleanupStack::PopAndDestroy( clientMtm );
+    CleanupStack::PopAndDestroy( registry );    
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorMessages::DeleteAllFromFolderL( const TMsvId aContext, 
+                                             CMsvSession* aSession,
+                                             CSmsClientMtm* aClientMtm,
+                                             TBool aOnlyCreatedWithCreator )
+    {
+    LOGSTRING("Creator: CCreatorMessages::DeleteAllFromFolderL");
+    
+    TMsvSelectionOrdering sort;
+    sort.SetShowInvisibleEntries( ETrue );
+
+    CMsvEntry* inboxContext = CMsvEntry::NewL( *aSession, aContext, sort );
+    CleanupStack::PushL( inboxContext );
+
+    CMsvEntrySelection* entries = inboxContext->ChildrenL();
+    CleanupStack::PushL( entries );
+
+    TInt msgCount = entries->Count();
+    for ( TInt i = 0; i < entries->Count(); i++)
+        {
+        TMsvId entryID = entries->At(i);
+        aClientMtm->SwitchCurrentEntryL( entryID );
+
+        if ( !aOnlyCreatedWithCreator || iEntryIds.Find( entryID ) != KErrNotFound )
+            {
+            CMsvEntry* entry = aSession->GetEntryL( (*entries)[i] );
+            CleanupStack::PushL( entry );
+
+            entry->DeleteL( entries->At(i) );
+            CleanupStack::PopAndDestroy( entry );            
+            }
+        }
+    
+    CleanupStack::PopAndDestroy( entries );
+    CleanupStack::PopAndDestroy( inboxContext );
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorMessages::DeleteAllCreatedByCreatorL()
+    {
+    LOGSTRING("Creator: CCreatorMessages::DeleteAllCreatedByCreatorL");
+    
+    iEntryIds.Reset();
+    
+    // fetch ids of entries created by Creator
+    iEngine->ReadEntryIdsFromStoreL( iEntryIds, KUidDictionaryUidMessages );
+    
+    // delete them
+    DeleteAllMessagesL( ETrue );
+    }
+
+CRecipientInfo::CRecipientInfo() 
+    {
+    
+    }
+
+CRecipientInfo::~CRecipientInfo()
+    {
+    delete iPhoneNumber;
+    delete iEmailAddress;
+    }
+
+void CRecipientInfo::SetPhoneNumber(HBufC* aPhone)
+    {
+    delete iPhoneNumber;    
+    iPhoneNumber = aPhone;    
+    }
+
+void CRecipientInfo::SetEmailAddress(HBufC* aEmail)
+    {
+    delete iEmailAddress;    
+    iEmailAddress = aEmail;    
+    }
+
+const HBufC* CRecipientInfo::PhoneNumber() const
+    {
+    return iPhoneNumber;
+    }
+
+const HBufC* CRecipientInfo::EmailAddress() const
+    {
+    return iEmailAddress;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_messageelement.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,474 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include "creator_messageelement.h"
+#include "creator_traces.h"
+#include "creator_message.h"
+
+using namespace creatormsg;
+
+/*
+ * 
+ */
+CCreatorMessageElement* CCreatorMessageElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext )
+    {
+    CCreatorMessageElement* self = new (ELeave) CCreatorMessageElement(aEngine);
+    CleanupStack::PushL(self);
+    self->ConstructL(aName, aContext);
+    CleanupStack::Pop(self);
+    return self;
+    }
+/*
+ * 
+ */
+CCreatorMessageElement::CCreatorMessageElement(CCreatorEngine* aEngine) 
+: 
+CCreatorScriptElement(aEngine)
+    {
+    iIsCommandElement = ETrue;
+    }
+/*
+ * Sets message type
+ */
+void CCreatorMessageElement::SetMessageTypeL(CMessagesParameters& aParameters, const TDesC& aMsgTypeStr ) const
+    {
+    if( CompareIgnoreCase(aMsgTypeStr, KSms) == 0 )
+        {
+        aParameters.iMessageType = ESMS;
+        }
+    else if( CompareIgnoreCase(aMsgTypeStr, KMms) == 0 )
+        {
+        aParameters.iMessageType = EMMS;
+        }
+    else if( CompareIgnoreCase(aMsgTypeStr, KAms) == 0 )
+        {
+        aParameters.iMessageType = EAMS;
+        }
+    else if( CompareIgnoreCase(aMsgTypeStr, KEmail) == 0 )
+        {
+        aParameters.iMessageType = EEmail;
+        }
+    else if( CompareIgnoreCase(aMsgTypeStr, KSmart) == 0 )
+        {
+        aParameters.iMessageType = ESmartMessage;
+        }
+    else if( CompareIgnoreCase(aMsgTypeStr, KIr) == 0 )
+        {
+        aParameters.iMessageType = EIrMessage;
+        }
+    else if( CompareIgnoreCase(aMsgTypeStr, KBt) == 0 )
+        {
+        aParameters.iMessageType = EBTMessage;
+        }
+    else
+        {
+        LOGSTRING2("ERROR in CCreatorMessageElement::SetMessageTypeL: Unknown message type: %S", &aMsgTypeStr);
+        User::Leave(KErrGeneral);
+        }
+    }
+/*
+ * Returns maximum length of the body text, when randomlength=max is used.
+ */
+TInt CCreatorMessageElement::GetMaxBodyLength( const TDesC& aMsgType ) const
+    {
+    TInt len = 0;
+    if( CompareIgnoreCase(aMsgType, KSms) == 0 )
+        {
+        len = 160;
+        }
+    else if( CompareIgnoreCase(aMsgType, KMms) == 0 )
+        {
+        len = 160;
+        }    
+    else if( CompareIgnoreCase(aMsgType, KEmail) == 0 )
+        {
+        len = 1024;
+        }
+    else
+        {
+        len = KUndef;
+        }
+    return len;
+    }
+/*
+ * Returns random body text length
+ */
+TInt CCreatorMessageElement::GetRandomBodyLengthL(const TDesC& aRandomLenStr, const TDesC& aMsgType ) const
+    {
+    TInt len = 0;
+    if( aRandomLenStr == KMax )
+        {
+        len = GetMaxBodyLength(aMsgType);
+        }
+    else if( aRandomLenStr == KDefault )
+        {
+        len = KUndef;        
+        }
+    else
+        {
+        len = ConvertStrToIntL(aRandomLenStr);
+        }
+    return len;
+    }
+
+/*
+ * Creates random message address (To/From)
+ * Returns phone number for SMS, MMS, AMS and Smart messages.
+ * Email address for others
+ */
+HBufC* CCreatorMessageElement::CreateMessageAddressLC(const TDesC& msgType)
+    {
+    HBufC* toAddr;
+    if( CompareIgnoreCase(msgType, KSms) == 0 || 
+        CompareIgnoreCase(msgType, KMms) == 0 || 
+        CompareIgnoreCase(msgType, KAms) == 0 || 
+        CompareIgnoreCase(msgType, KSmart) == 0)
+        {
+        TPtrC temp = iEngine->RandomString(CCreatorEngine::EPhoneNumber);
+        toAddr = HBufC::NewL(temp.Length());
+        CleanupStack::PushL(toAddr);
+        toAddr->Des().Copy(temp);
+        }
+    else
+        {
+        toAddr = iEngine->CreateEmailAddressLC();
+        }
+    return toAddr;
+    }
+
+/*
+ *
+ */
+void CCreatorMessageElement::ExecuteCommandL()
+    {
+    LOGSTRING("Creator: CCreatorMessageElement::ExecuteCommandL");
+    
+    // Find out the message type:
+    const CCreatorScriptAttribute* msgTypeAttr = this->FindAttributeByName(KType);
+    TPtrC msgType;
+    if( msgTypeAttr )
+        {
+        msgType.Set(msgTypeAttr->Value());
+        }
+    else
+        {
+        LOGSTRING("ERROR in CCreatorMessageElement::ExecuteCommandL: Type attribute is missing.");
+        User::Leave(KErrGeneral); // type is required attribute
+        }
+    
+    // Find out the amount of calendar entries:
+    const CCreatorScriptAttribute* msgAmountAttr = this->FindAttributeByName(KAmount);
+    TInt msgAmount = 1;    
+    if( msgAmountAttr )
+        {
+        msgAmount = ConvertStrToIntL(msgAmountAttr->Value());
+        }    
+    
+    // Get 'fields' element 
+    CCreatorScriptElement* fieldsElement = FindSubElement(KFields);
+    if( fieldsElement && fieldsElement->SubElements().Count() > 0 )
+        {
+        // Get sub-elements (i.e the message field elements)
+        const RPointerArray<CCreatorScriptElement>& fields = fieldsElement->SubElements();
+        
+        // Create message entries, the amount of entries is defined by msgAmount:
+        for( TInt cI = 0; cI < msgAmount; ++cI )
+            {
+            CMessagesParameters* param = new (ELeave) CMessagesParameters;
+            CleanupStack::PushL(param);
+            
+            // Message type:
+            if( msgTypeAttr )
+                {
+                SetMessageTypeL(*param, msgTypeAttr->Value());
+                }           
+            
+            // Loop all the message field elements:
+            for( TInt i = 0; i < fields.Count(); ++i )
+                {
+                CCreatorScriptElement* field = fields[i];
+                TPtrC elemName = field->Name();
+                TPtrC elemContent = field->Content();
+                const RPointerArray<CCreatorScriptElement>& contactReferences = field->SubElements();
+                const CCreatorScriptAttribute* randomAttr = field->FindAttributeByName(KRandomLength);
+                const CCreatorScriptAttribute* amountAttr = field->FindAttributeByName(KAmount);
+                const CCreatorScriptAttribute* increaseAttr = field->FindAttributeByName(KIncrease);
+                TBool increase( EFalse );
+                if ( increaseAttr )
+                    {
+                    increase = ConvertStrToBooleanL( increaseAttr->Value() );
+                    }
+                TInt fieldAmount = 1;
+                if( amountAttr )
+                    {
+                    fieldAmount = ConvertStrToIntL(amountAttr->Value());
+                    }               
+                
+                if( elemName == KTo )
+                    {
+                    // Recipient ('to'-field)
+                    for( TInt amountIndex = 0; amountIndex < fieldAmount; ++amountIndex )
+                        {
+                        if( (randomAttr || elemContent.Length() == 0 ) && contactReferences.Count() == 0 )
+                            {                        
+                            // Random content
+                            HBufC* toAddr = CreateMessageAddressLC(msgType);
+                            if( toAddr )
+                                {
+                                param->iRecipientAddressArray.AppendL(toAddr);
+                                CleanupStack::Pop(); // toAddr
+                                }
+                            }
+                        else
+                            {                            
+                            if( elemContent.Length() > 0 && contactReferences.Count() == 0)
+                                {
+                                // Explicit recipient given
+                                HBufC* recipient = HBufC::NewL( elemContent.Length() + 3 );
+                                CleanupStack::PushL(recipient);
+                                if ( increase )
+                                    {
+                                    IncreasePhoneNumL( elemContent, cI, recipient );
+                                    }
+                                else
+                                    {
+                                    recipient->Des().Copy(elemContent);
+                                    }
+                                param->iRecipientAddressArray.AppendL(recipient);
+                                CleanupStack::Pop(); // recipient
+                                }
+                            else
+                                {
+                                // Recipients specified with contact-set-references (if any)
+                                for( TInt csI = 0; csI < contactReferences.Count(); ++csI )
+                                    {                            
+                                    CCreatorScriptElement* contactSetRef = contactReferences[csI];
+                                    AppendContactSetReferenceL(*contactSetRef, param->iRecipientLinkIds);                                
+                                    }
+                                }
+                            }
+                        }
+                    }
+                else if( elemName == KFrom )
+                    {
+                    // Sender ('from'-field)
+                    // Amount attribute for sender is ignored, because there can be only one sender                 
+                    delete param->iSenderAddress;
+                    param->iSenderAddress = 0;
+                    if( (randomAttr || elemContent.Length() == 0 ) && contactReferences.Count() == 0 )
+                        {
+                        // Get random address
+                        param->iSenderAddress = CreateMessageAddressLC(msgType);
+                        CleanupStack::Pop(); // param->iSenderAddress
+                        }
+                    else
+                        {                        
+                        if( elemContent.Length() > 0 && contactReferences.Count() == 0)
+                            {
+                            // Explicit sender address given
+                            param->iSenderAddress = HBufC::NewL(elemContent.Length());
+                            if ( increase )
+                                {
+                                IncreasePhoneNumL( elemContent, cI, param->iSenderAddress );
+                                }
+                            else
+                                {
+                                param->iSenderAddress->Des().Copy(elemContent);
+                                }
+                            }
+                        else
+                            {
+                            // Senders specified with contact-set-references (if any)
+                            for( TInt csI = 0; csI < contactReferences.Count(); ++csI )
+                                {                            
+                                CCreatorScriptElement* contactSetRef = contactReferences[csI];
+                                AppendContactSetReferenceL(*contactSetRef, param->iSenderLinkIds);                                
+                                }
+                            }                           
+                        }
+                    }
+                else if( elemName == KFolder )              
+                    {
+                    // Folder type
+                    if( CompareIgnoreCase(elemContent, KSent) == 0 )
+                        {
+                        param->iFolderType = ESent;
+                        }
+                    else if( CompareIgnoreCase(elemContent, KInbox) == 0 )
+                        {
+                        param->iFolderType = EInbox;
+                        }
+                    else if( CompareIgnoreCase(elemContent, KOutbox) == 0 )
+                        {
+                        param->iFolderType = EOutbox;
+                        }
+                    else if( CompareIgnoreCase(elemContent, KDraft) == 0 )
+                        {
+                        param->iFolderType = EDrafts;
+                        }                        
+                    }
+                else if( elemName == KSubject )
+                    {
+                    // Message subject
+                    delete param->iMessageSubject;
+                    param->iMessageSubject = 0;
+                    
+                    if( randomAttr || elemContent.Length() == 0 )
+                        {
+                        // Random data should be used
+                        TPtrC temp = iEngine->RandomString(CCreatorEngine::EMessageSubject);
+                        param->iMessageSubject = HBufC::NewL(temp.Length());
+                        param->iMessageSubject->Des().Copy(temp);
+                        }
+                    else
+                        {                        
+                        param->iMessageSubject = HBufC::NewL(elemContent.Length());
+                        param->iMessageSubject->Des().Copy(elemContent);
+                        }
+                    }
+                else if( elemName == KText )
+                    {
+                    // Body text
+                    delete param->iMessageBodyText;
+                    param->iMessageBodyText = 0;
+                    
+                    if( randomAttr || elemContent.Length() == 0 )
+                        {
+                        // Put random text:
+                        if( randomAttr && randomAttr->Value() != KDefault )
+                            {
+                            // Get the random length
+                            TInt len = GetRandomBodyLengthL(randomAttr->Value(), msgTypeAttr->Value());
+                            if( len != KUndef )
+                                {
+                                param->iMessageBodyText = iEngine->CreateRandomStringLC(len);
+                                CleanupStack::Pop(); // param->iMessageBodyText
+                                }
+                            }
+                        else
+                            {
+                            // Use default random data
+                            TPtrC temp = iEngine->RandomString(CCreatorEngine::EMessageText);
+                            param->iMessageBodyText = HBufC::NewL(temp.Length());
+                            param->iMessageBodyText->Des().Copy(temp);
+                            }
+                        }
+                    else
+                        {
+                        param->iMessageBodyText = HBufC::NewL(elemContent.Length());
+                        param->iMessageBodyText->Des().Copy(elemContent);
+                        }
+                    }
+                else if( elemName == KAttachmentId )
+                    {
+                    // Attachment file id
+                    for( TInt amountIndex = 0; amountIndex < fieldAmount; ++amountIndex )
+                        {                        
+                        if( randomAttr  || elemContent.Length() == 0)
+                            {
+                            //When type is AMS, attachement will be audio
+                            if(param->iMessageType == EAMS)
+                                {
+                                param->iAttachments->AppendL(CCreatorEngine::EMP3_250kB);
+                                }
+                            //Otherwise attachement can be any file
+                            else
+                                {
+                                //EJPEG_25kB is first (0) in the enum and LAST_FILE_ID is last in the enum, so real last item id is one before LAST_FILE_ID
+                                param->iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) );                                
+                                }
+                            }
+                        else
+                            {
+                            //When user has been set attechment by it self, we trust user selection (not validating value, e.g. if message is SMS and there is attachement)
+                            TInt id = iEngine->GetAttachmentIdL(elemContent);
+                            if( id != KUndef )
+                                {
+                                param->iAttachments->AppendL( id );
+                                }
+                            }
+                        }
+                    }
+                // Attachment file path handling 
+                //E.g. C:\data\others\DOC-20kB.doc
+                else if( elemName == KAttachmentPath )
+                    {
+                    // Attachment file id
+                    for( TInt amountIndex = 0; amountIndex < fieldAmount; ++amountIndex )
+                        {
+                        //Path is random, getting one of the files (not even using path attribute, but id with random)
+                        if( randomAttr  || elemContent.Length() == 0)
+                            {
+                            //EJPEG_25kB is first (0) in the enum and LAST_FILE_ID is last in the enum, so real last item id is one before LAST_FILE_ID
+                            param->iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID -1) );
+                            }
+                        //Otherwise adding attachement path as it is to paths.
+                        else
+                            {
+                            //Adding Attachement file path
+                            HBufC* elemData = elemContent.AllocLC();
+                            param->iAttachmentPaths.AppendL( elemData );     
+                            CleanupStack::Pop(elemData);
+                            }
+                        }
+                    }
+                else if ( elemName == KStatus )
+                    {
+                    if( CompareIgnoreCase( elemContent, KNew ) == 0 )
+                        {
+                        param->iCreateAsUnread = ETrue;
+                        }
+                    else if( CompareIgnoreCase( elemContent, KRead ) == 0 )
+                        {
+                        param->iCreateAsUnread = EFalse;
+                        }
+                    }
+                }
+            iEngine->AppendToCommandArrayL(ECmdCreateMessagingEntryMessagesViaScript, param);
+            CleanupStack::Pop(); // param
+            }
+        }
+    else
+    	{
+    	for( TInt i = 0; i < msgAmount; ++i )
+    		{
+    		TInt randMsg = 0;
+    		if( msgType == KSms )
+    			randMsg = iEngine->RandomNumber(ECmdCreateRandomEntrySMSInbox, ECmdCreateRandomEntrySMSSent);
+    		else if( msgType == KMms )
+    			randMsg = iEngine->RandomNumber(ECmdCreateRandomEntryMMSInbox, ECmdCreateRandomEntryMMSSent);
+    		else if( msgType == KAms )
+    			randMsg = iEngine->RandomNumber(ECmdCreateRandomEntryAMSInbox, ECmdCreateRandomEntryAMSSent);
+    		else if( msgType == KEmail )
+    			randMsg = iEngine->RandomNumber(ECmdCreateRandomEntryEmailInbox, ECmdCreateRandomEntryEmailSent);
+    		else if( msgType == KSmart )
+    			randMsg = iEngine->RandomNumber(ECmdCreateRandomEntryBIOInbox, ECmdCreateRandomEntryBIOSent);
+    		else if( msgType == KBt )
+    			randMsg = iEngine->RandomNumber(ECmdCreateRandomEntryBTInbox, ECmdCreateRandomEntryBTSent);
+    		else if( msgType == KIr )
+    			randMsg = iEngine->RandomNumber(ECmdCreateRandomEntryIRInbox, ECmdCreateRandomEntryIRSent);
+    			
+    		if( randMsg > 0 )
+    			{
+    			iEngine->AppendToCommandArrayL(randMsg, 0, 1);
+    			}
+    		}
+    	}
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_model.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,2554 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#include <cntdb.h>//For Math
+
+#include "creator_model.h"
+#include "creator_traces.h"
+#include "creator_factory.h"
+#include "creator_scriptparser.h"
+#include "creator_appui.h"
+#include "creator_app.h" // KUidCreatorApp
+#include "creator_file.h"
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+  #include "creator_contactsetcache.h"
+#endif
+
+#include <apparc.h>
+#include <eikappui.h>
+#include <eikapp.h>
+#include <bitmaptransforms.h>
+
+_LIT(KTempPathDrive, "d");
+_LIT(KTempPath, ":\\Creator\\");
+_LIT(KSavingText, "Saving");
+_LIT(KDeletingText, "Deleting");
+const TInt KRegisterDrive = EDriveC;
+_LIT(KRegisterFileName, "creator_created_items.dat");
+
+
+// ---------------------------------------------------------------------------
+
+CCreatorEngine* CCreatorEngine::NewL(CCreatorAppUi* aAppUi)
+    {
+    LOGSTRING("Creator: CCreatorEngine::NewL");
+    CCreatorEngine* self = new(ELeave) CCreatorEngine;
+    CleanupStack::PushL(self);
+    self->ConstructL(aAppUi);
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+
+CCreatorEngine::CCreatorEngine() 
+: 
+CActive(0)
+{}
+
+// ---------------------------------------------------------------------------
+
+void CCreatorEngine::ConstructL(CCreatorAppUi* aAppUi)
+    {
+    LOGSTRING("Creator: CCreatorEngine::ConstructL");
+
+    iEnv = CEikonEnv::Static();
+    User::LeaveIfError(iTimer.CreateLocal());
+
+    iAppUi = aAppUi;
+
+    // these are needed by the random data generator
+    TTime now;
+    now.HomeTime();
+    iSeed=now.Int64();
+    
+    iTempPath = HBufC::NewL(KTempPathDrive().Length() + KTempPath().Length());
+    iTempPath->Des().Copy(KTempPathDrive);
+    iTempPath->Des().Append(KTempPath);
+
+    GetRandomDataFromFileL(KNullDesC);
+        
+    CActiveScheduler::Add(this);
+
+    }
+
+// ---------------------------------------------------------------------------
+
+CCreatorEngine::~CCreatorEngine()
+    {
+    LOGSTRING("Creator: CCreatorEngine::~CCreatorEngine");
+
+    Cancel();
+    
+    for( TInt i = 0; i < iStringArrays.Count(); ++i )
+        {
+        delete iStringArrays[i].iArrayPtr;
+        }
+    iStringArrays.Close();
+    iAllocatedFilePaths.ResetAndDestroy();
+    iAllocatedFilePaths.Close();
+    iTimer.Close();
+    
+    delete iPictureFileArray;
+    delete iSoundFileArray;
+    delete iTempPath;
+    delete iFrameImageData;
+    delete iEncoder;
+    delete iScaler;
+    delete iDecoder;
+    delete iScaledBitmap;
+    delete iBitmap;
+    delete iBitmapData;
+    }
+
+void CCreatorEngine::CopyFileL(const TFileName& aSourceFile, const TFileName& aTargetFile, TBool aOverwrite )
+	{
+	if( !aOverwrite && ConeUtils::FileExists(aTargetFile))
+		{
+		// File already exists
+		return;
+		}
+	
+	// Make sure that the path exists. Creates the directory if it does not exist already:
+	ConeUtils::EnsurePathExistsL(aTargetFile);	
+	User::LeaveIfError(BaflUtils::CopyFile(CEikonEnv::Static()->FsSession(), aSourceFile, aTargetFile));
+	}
+// ---------------------------------------------------------------------------
+
+void CCreatorEngine::ExecuteFirstCommandL(const TDesC& aText)
+    {
+    LOGSTRING("Creator: CCreatorEngine::ExecuteFirstCommand");
+
+    // init the progress bar
+    iProgressDialog = new(ELeave)CAknProgressDialog((reinterpret_cast<CEikDialog**>(&iProgressDialog)), ETrue);
+    iProgressDialog->SetCallback(this);
+    iProgressDialog->PrepareLC(R_PROGRESS_NOTE);
+    iProgressDialog->SetCurrentLabelL( EAknCtNote, aText );
+    iProgressInfo = iProgressDialog->GetProgressInfoL();
+    iProgressInfo->SetFinalValue( CommandArrayCount() );
+    iProgressDialog->RunLD();
+    iProgressDialog->MakeVisible( ETrue );
+    
+    iFailedCommands = 0;
+
+    // starts executing commands
+    ExecuteCommand();
+    }
+
+// ---------------------------------------------------------------------------
+
+void CCreatorEngine::ExecuteCommand()
+    {
+    LOGSTRING("Creator: CCreatorEngine::ExecuteCommand");
+
+    // make sure the engine isn't active, should never happen
+    __ASSERT_ALWAYS(!IsActive(), User::Panic(_L("IsActive"), 500));
+
+    // execute a command after a very short delay (75ms)
+    iTimer.After(iStatus, 75);
+    SetActive();
+    }
+
+// ---------------------------------------------------------------------------
+
+void CCreatorEngine::RunL()
+    {
+    LOGSTRING("Creator: CCreatorEngine::RunL");
+    LOGSTRING2("Creator: CCreatorEngine::RunL iCommandId=%d", iCommandArray->At(iCurrentEntry).iCommandId);
+    
+    if ( iUserCancelled ) return;
+    
+    if (!iCommandArray->At(iCurrentEntry).iParameters)
+        {
+        LOGSTRING("Creator: CCreatorEngine::RunL - iParameters==NULL !");
+        }
+
+    // launch a command
+
+    TCreatorIds cmd = (TCreatorIds)iCommandArray->At(iCurrentEntry).iCommandId; 
+    switch( cmd )
+        {
+	    case ECmdCreateBrowserBookmarkEntries: { iBrowser->CreateBookmarkEntryL(reinterpret_cast<CBrowserParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
+	    case ECmdCreateBrowserBookmarkFolderEntries: { iBrowser->CreateBookmarkFolderEntryL(reinterpret_cast<CBrowserParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
+	    case ECmdCreateBrowserSavedPageEntries: { iBrowser->CreateSavedDeckEntryL(reinterpret_cast<CBrowserParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
+	    case ECmdCreateBrowserSavedPageFolderEntries: { iBrowser->CreateSavedDeckFolderEntryL(reinterpret_cast<CBrowserParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
+	    
+        case ECmdCreateCalendarEntryAppointments: { iCalendar->CreateAppointmentEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break;
+	    case ECmdCreateCalendarEntryEvents: { iCalendar->CreateEventEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break;
+	    case ECmdCreateCalendarEntryAnniversaries: { iCalendar->CreateAnniversaryEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break;
+	    case ECmdCreateCalendarEntryToDos: { iCalendar->CreateTodoEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break;
+        case ECmdCreateCalendarEntryReminders: { iCalendar->CreateReminderEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break;
+
+	    
+	    case ECmdCreatePhoneBookEntryContacts: { iPhonebook->CreateContactEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break;
+	    case ECmdCreatePhoneBookEntryGroups: { iPhonebook->CreateGroupEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break;
+	    case ECmdCreatePhoneBookEntrySubscribedContacts: { iPhonebook->CreateSubscribedContactEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break;
+
+	    case ECmdCreateMiscEntryNotes: { iNotepad->CreateNoteEntryL(reinterpret_cast<CNotepadParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
+
+	    case ECmdCreateLogEntryMissedCalls: { iLogs->CreateMissedCallEntryL(reinterpret_cast<CLogsParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
+	    case ECmdCreateLogEntryReceivedCalls: { iLogs->CreateReceivedCallEntryL(reinterpret_cast<CLogsParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
+	    case ECmdCreateLogEntryDialledNumbers: { iLogs->CreateDialledNumberEntryL(reinterpret_cast<CLogsParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
+
+        case ECmdCreateMiscEntryAccessPoints: { iAccessPoints->CreateConnectionSettingsEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break;
+        case ECmdDeleteIAPs: { iAccessPoints->DeleteAllL(); } break;
+        case ECmdDeleteCreatorIAPs: { iAccessPoints->DeleteAllCreatedByCreatorL(); } break;
+
+        case ECmdCreateMiscEntryLandmarks: { iLandmarks->CreateLandmarkEntryL(reinterpret_cast<CLandmarkParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
+        
+	    case ECmdCreateMessagingEntryMailboxes: { iMailboxes->CreateMailboxEntryL(reinterpret_cast<CMailboxesParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
+
+        #ifdef __PRESENCE
+  	     case ECmdCreateMiscEntryIMPSServers: { iIMPS->CreateIMPSServerEntryL(reinterpret_cast<CIMPSParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
+        #endif
+
+	    case ECmdCreateMessagingEntryMessages:  { iMessages->CreateMessageEntryL(reinterpret_cast<CMessagesParameters*>(iCommandArray->At(iCurrentEntry).iParameters), ETrue); } break;
+	    case ECmdCreateMessagingEntryMessagesViaScript:  { iMessages->CreateMessageEntryL(reinterpret_cast<CMessagesParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
+
+	    case ECmdCreateRandomEntrySMSInbox:
+	    case ECmdCreateRandomEntrySMSDrafts:
+	    case ECmdCreateRandomEntrySMSOutbox:
+	    case ECmdCreateRandomEntrySMSSent:
+	    case ECmdCreateRandomEntryMMSInbox:
+	    case ECmdCreateRandomEntryMMSDrafts:
+	    case ECmdCreateRandomEntryMMSOutbox:
+	    case ECmdCreateRandomEntryMMSSent:
+	    case ECmdCreateRandomEntryAMSInbox:
+	    case ECmdCreateRandomEntryAMSDrafts:
+	    case ECmdCreateRandomEntryAMSOutbox:
+	    case ECmdCreateRandomEntryAMSSent:
+	    case ECmdCreateRandomEntryEmailInbox:
+	    case ECmdCreateRandomEntryEmailDrafts:
+	    case ECmdCreateRandomEntryEmailOutbox:
+	    case ECmdCreateRandomEntryEmailSent:
+	    case ECmdCreateRandomEntryBIOInbox:
+	    case ECmdCreateRandomEntryBIODrafts:
+	    case ECmdCreateRandomEntryBIOOutbox:
+	    case ECmdCreateRandomEntryBIOSent:
+	    case ECmdCreateRandomEntryIRInbox:
+	    case ECmdCreateRandomEntryIRDrafts:
+	    case ECmdCreateRandomEntryIROutbox:
+	    case ECmdCreateRandomEntryIRSent:
+	    case ECmdCreateRandomEntryBTInbox:
+	    case ECmdCreateRandomEntryBTDrafts:
+	    case ECmdCreateRandomEntryBTOutbox:
+	    case ECmdCreateRandomEntryBTSent:
+	            { iMessages->CreateRandomMessageEntryL(iCommandArray->At(iCurrentEntry).iCommandId); } break;
+
+        case ECmdCreateFileEntryEmptyFolder:
+        case ECmdCreateFileEntry3GPP_70kB:
+        case ECmdCreateFileEntryAAC_100kB:
+        case ECmdCreateFileEntryAMR_20kB:
+        case ECmdCreateFileEntryBMP_25kB:
+        case ECmdCreateFileEntryDeck_1kB:
+        case ECmdCreateFileEntryDOC_20kB:
+        case ECmdCreateFileEntryGIF_2kB:
+        case ECmdCreateFileEntryHTML_20kB:
+        case ECmdCreateFileEntryJAD_1kB:
+        case ECmdCreateFileEntryJAR_10kB:
+        case ECmdCreateFileEntryJP2_65kB:
+        case ECmdCreateFileEntryJPEG_200kB:
+        case ECmdCreateFileEntryJPEG_25kB:
+        case ECmdCreateFileEntryJPEG_500kB:
+        case ECmdCreateFileEntryMIDI_10kB:
+        case ECmdCreateFileEntryMP3_250kB:
+        case ECmdCreateFileEntryMP4_200kB:
+        case ECmdCreateFileEntryMXMF_40kB:
+        case ECmdCreateFileEntryPNG_15kB:
+        case ECmdCreateFileEntryPPT_40kB:
+        case ECmdCreateFileEntryRAM_1kB:
+        case ECmdCreateFileEntryRM_95kB:
+        case ECmdCreateFileEntryRNG_1kB:
+        case ECmdCreateFileEntrySVG_15kB:
+        case ECmdCreateFileEntrySWF_15kB:
+        case ECmdCreateFileEntryTIF_25kB:
+        case ECmdCreateFileEntryTXT_10kB:
+        case ECmdCreateFileEntryTXT_70kB:
+        case ECmdCreateFileEntryVCF_1kB:
+        case ECmdCreateFileEntryVCS_1kB:
+        case ECmdCreateFileEntryWAV_20kB:
+        case ECmdCreateFileEntryXLS_15kB:
+        case ECmdCreateFileEntrySISX_10kB:
+        case ECmdCreateFileEntryWMA_50kB:
+        case ECmdCreateFileEntryWMV_200kB:
+	            { iFiles->CreateFileEntryL( reinterpret_cast<CFilesParameters*>(iCommandArray->At(iCurrentEntry).iParameters), iCommandArray->At(iCurrentEntry).iCommandId ); } break;
+        case ECmdDeleteContacts:
+            {
+            iPhonebook->DeleteAllL();
+            break;
+            }
+        case ECmdDeleteContactGroups:
+            {
+            iPhonebook->DeleteAllGroupsL();
+            break;            
+            }
+        case ECmdDeleteCreatorContacts:
+            {
+            iPhonebook->DeleteAllCreatedByCreatorL();
+            break;
+            }
+        case ECmdDeleteCreatorContactGroups:
+            {
+            iPhonebook->DeleteAllGroupsCreatedByCreatorL();
+            break;            
+            }
+        case ECmdDeleteCalendarEntries:
+            {
+            iCalendar->DeleteAllL();
+            break;
+            }
+        case ECmdDeleteCreatorCalendarEntries:
+            {
+            iCalendar->DeleteAllCreatedByCreatorL();
+            break;
+            }
+        case ECmdDeleteLogs:
+            {
+            iLogs->DeleteAllL();
+            break;
+            }
+        case ECmdDeleteCreatorLogs:
+            {
+            iLogs->DeleteAllCreatedByCreatorL();
+            break;
+            }
+        case ECmdDeleteMessages:
+            {
+            iMessages->DeleteAllL();
+            break;
+            }
+        case ECmdDeleteCreatorMessages:
+            {
+            iMessages->DeleteAllCreatedByCreatorL();
+            break;
+            }
+        case ECmdDeleteLandmarks:
+            {
+            iLandmarks->DeleteAllL();
+            break;
+            }
+        case ECmdDeleteCreatorLandmarks:
+            {
+            iLandmarks->DeleteAllCreatedByCreatorL();
+            break;
+            }
+        case ECmdDeleteMailboxes:
+            {
+            iMailboxes->DeleteAllL();
+            break;
+            }
+        case ECmdDeleteCreatorMailboxes:
+            {
+            iMailboxes->DeleteAllCreatedByCreatorL();
+            break;
+            }
+        case ECmdDeleteNotes:
+            {
+            iNotepad->DeleteAllL();
+            break;
+            }
+        case ECmdDeleteIMPSs:
+            {
+            iIMPS->DeleteAllL();
+            break;
+            }
+        case ECmdDeleteCreatorIMPSs:
+            {
+            iIMPS->DeleteAllCreatedByCreatorL();
+            break;
+            }
+        case ECmdDeleteBrowserBookmarks:
+            {
+            iBrowser->DeleteAllBookmarksL();
+            break;
+            }
+        case ECmdDeleteCreatorBrowserBookmarks:
+            {
+            iBrowser->DeleteAllBookmarksCreatedByCreatorL();
+            break;
+            }
+        case ECmdDeleteBrowserBookmarkFolders:
+            {
+            iBrowser->DeleteAllBookmarkFoldersL();
+            break;
+            }
+        case ECmdDeleteCreatorBrowserBookmarkFolders:
+            {
+            iBrowser->DeleteAllBookmarkFoldersCreatedByCreatorL();
+            break;
+            }
+        case ECmdDeleteBrowserSavedPages:
+            {
+            iBrowser->DeleteAllSavedPagesL();
+            break;
+            }
+        case ECmdDeleteCreatorBrowserSavedPages:
+            {
+            iBrowser->DeleteAllSavedPagesCreatedByCreatorL();
+            break;
+            }
+        case ECmdDeleteBrowserSavedPageFolders:
+            {
+            iBrowser->DeleteAllSavedPageFoldersL();
+            break;
+            }
+        case ECmdDeleteCreatorBrowserSavedPageFolders:
+            {
+            iBrowser->DeleteAllSavedPageFoldersCreatedByCreatorL();
+            break;
+            }
+        case ECmdDeleteCreatorFiles:
+            {
+            iFiles->DeleteAllCreatedByCreatorL();
+            break;
+            }
+        default:
+            User::Panic (_L("ExecuteOptionsMenuCommandL"), 205);
+            break;
+        }
+
+    TRAP_IGNORE( CheckForMoreCommandsL() );
+
+    }
+    
+CDesCArrayFlat* CCreatorEngine::PictureFilesL()
+    {
+    if( iPictureFileArray == 0 )
+        {
+        _LIT(KImageFile, "JPEG*.jpg");
+        _LIT(KImageFileDir, "C:\\Data\\");
+        _LIT(KImageFileDir2, "Z:\\Data\\");
+        iPictureFileArray = new (ELeave) CDesCArrayFlat(8);        
+        TInt err = CreatorFileUtils::FindFilesRecursiveL(iPictureFileArray, KImageFile, KImageFileDir);
+        if( iPictureFileArray->Count() == 0 )
+            {
+            err = CreatorFileUtils::FindFilesRecursiveL(iPictureFileArray, KImageFile, KImageFileDir2);
+            }
+        }
+    return iPictureFileArray;
+    }
+
+CDesCArrayFlat* CCreatorEngine::SoundFilesL()
+    {
+    if( iSoundFileArray == 0 )
+        {
+        _LIT(KSoundFile, "*.aac");
+        _LIT(KSoundFileDir, "Z:\\data\\Sounds\\");
+        iSoundFileArray = new (ELeave) CDesCArrayFlat(8);                  
+        TInt err = CreatorFileUtils::FindFilesRecursiveL(iSoundFileArray, KSoundFile, KSoundFileDir);
+        }
+    return iSoundFileArray;
+    }
+// ---------------------------------------------------------------------------
+
+TInt CCreatorEngine::RunError(TInt aError)
+    {
+    LOGSTRING2("Creator: CCreatorEngine::RunError %d", aError);
+    
+    iFailedCommands++;
+    
+    _LIT(KMessage, "Command error %d");
+    TBuf<128> noteMsg;
+    noteMsg.Format(KMessage, aError);
+    iEnv->InfoMsg(noteMsg);
+    
+    TRAP_IGNORE( CheckForMoreCommandsL() );
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+
+void CCreatorEngine::CheckForMoreCommandsL()
+    {
+    LOGSTRING("Creator: CCreatorEngine::CheckForMoreCommandsL");
+    if ( iUserCancelled ) return;
+    // update the progress bar
+    iProgressInfo->IncrementAndDraw(1);
+
+	// check if we have more commands to be executed
+	if (iCurrentEntry >= CommandArrayCount() - 1)
+		{
+        LOGSTRING("Creator: CCreatorEngine::CheckForMoreCommandsL all done");
+
+        // all done, free resources and show a note
+        ShutDownEnginesL();
+
+		iProgressDialog->ProcessFinishedL();
+		
+		if (iFailedCommands == 0)
+		    {
+		    _LIT(KMessage, "Done");
+
+    		CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+    		note->ExecuteLD(KMessage);
+		    }
+		else
+		    {
+		    _LIT(KMessage, "Done, %d commands failed");
+            TBuf<128> noteMsg;
+            noteMsg.Format(KMessage, iFailedCommands);
+            
+    		CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+    		note->ExecuteLD(noteMsg);
+		    }
+		
+	    iAppUi->RunScriptDone();
+
+		}
+	else
+		{
+		// maintain requests
+		iCurrentEntry++;
+
+        LOGSTRING2("Creator: CCreatorEngine::CheckForMoreCommandsL iCurrentEntry=%d", iCurrentEntry);
+
+        ExecuteCommand();
+		}
+    }
+
+// ---------------------------------------------------------------------------
+
+// This callback function is called when cancel button of the progress bar was pressed
+void CCreatorEngine::DialogDismissedL(TInt aButtonId)
+    {
+    LOGSTRING("Creator: CCreatorEngine::DialogDismissedL");
+
+    // check if cancel button was pressed
+    if (aButtonId == EAknSoftkeyCancel)
+        {
+        iUserCancelled = ETrue;
+        // cancel the active object, command executer 
+        Cancel();
+
+        // delete parameters from the command array, otherwise there might be memory leaks
+        for (TInt i=iCurrentEntry; i<CommandArrayCount(); i++)
+            {
+            if ( iCommandArray->At(i).iParameters )
+                delete iCommandArray->At(i).iParameters;
+                iCommandArray->At(i).iParameters = NULL;
+            }
+        
+        if ( iPhonebook && iPhonebook->IsActive() )
+            {
+            // virtual phonebook is known to require asynchronous
+            // cancelling of operation
+            iPhonebook->CancelOperation();
+            }
+        else if ( iDecoder  )
+            {
+            iDecoder->Cancel();
+            // CancelComplete() will be called from GenerateSourceImageFileL
+            }
+        else if ( iScaler )
+            {
+            iScaler->Cancel();
+            // CancelComplete() will be called from GenerateSourceImageFileL
+            }
+        else if ( iEncoder  )
+            {
+            iEncoder->Cancel();
+            // CancelComplete() will be called from GenerateSourceImageFileL
+            }
+        else
+            {
+            // free resources and show a note
+            ShutDownEnginesL();
+
+            CAknInformationNote* note = new (ELeave) CAknInformationNote;
+            note->ExecuteLD(_L("Cancelled"));
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+void CCreatorEngine::StartEnginesL()
+    {
+    LOGSTRING("Creator: CCreatorEngine::StartEnginesL");
+    
+    // reset user cancel flag
+    iUserCancelled = EFalse;
+    
+    // start from the beginning
+    iCurrentEntry = 0;
+
+    // we'll retrieve a correct number for this later
+    iEntriesToBeCreated = 0;
+
+    // init the command array
+    __ASSERT_ALWAYS(!iCommandArray, User::Panic(_L("iCommandArray"), 701));
+    iCommandArray = new(ELeave) CCommandArray(10000);
+
+    // init all modules here
+    TInt err(KErrNone);
+    TRAP(err, iBrowser = CCreatorBrowser::NewL(this));
+    TRAP(err, iCalendar = CCreatorInterimCalendar::NewL(this));
+    TRAP(err, iPhonebook = (CCreatorPhonebookBase*)TCreatorFactory::CreatePhoneBookL(this));
+    TRAP(err, iNotepad = CCreatorNotepad::NewL(this));
+    TRAP(err, iLogs = CCreatorLogs::NewL(this));
+    TRAP(err, iAccessPoints = (CCreatorConnectionSettingsBase*)TCreatorFactory::CreateConnectionSettingsL(this));
+    TRAP(err, iMailboxes = CCreatorMailboxes::NewL(this));
+    TRAP(err, iFiles = CCreatorFiles::NewL(this));
+    TRAP(err, iMessages = CCreatorMessages::NewL(this));
+    TRAP(err, iLandmarks = CCreatorLandmarks::NewL(this));
+
+    #ifdef __PRESENCE
+      TRAP(err, iIMPS = CCreatorIMPS::NewL(this));
+    #endif 
+    
+      
+      
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)     
+    // Initialize contact-set cache:
+   ContactLinkCache::InitializeL();
+#endif
+    // ...
+    // ...
+    // ...
+
+    }
+// ---------------------------------------------------------------------------
+
+void CCreatorEngine::ShutDownEnginesL()
+    {
+    LOGSTRING("Creator: CCreatorEngine::ShutDownEnginesL");
+
+        
+    // delete all modules here and free resources which aren't anymore needed
+
+
+    #ifdef __PRESENCE
+     delete iIMPS;
+     iIMPS = NULL;
+    #endif
+
+    delete iMessages;
+    iMessages = NULL;
+    delete iFiles;
+    iFiles = NULL;
+    delete iMailboxes;
+    iMailboxes = NULL;
+    delete iAccessPoints;
+    iAccessPoints = NULL;
+    delete iLogs;
+    iLogs = NULL;
+    delete iNotepad;
+    iNotepad = NULL;
+    delete iPhonebook;
+    iPhonebook = NULL;
+    delete iCalendar;
+    iCalendar = NULL;
+    delete iBrowser;
+    iBrowser = NULL;
+    delete iLandmarks;
+    iLandmarks = NULL;
+    
+    // ...
+    // ...
+    // ...
+
+
+    // now delete the command array
+    delete iCommandArray;
+    iCommandArray = NULL;
+    
+    
+    iParameterArray.ResetAndDestroy();
+    iParameterArray.Close();
+    
+    
+	// clear temp drive
+	CFileMan* fileMan = CFileMan::NewL( iEnv->FsSession() );
+	CleanupStack::PushL( fileMan );
+	fileMan->RmDir( iTempPath->Des() );
+	CleanupStack::PopAndDestroy(); //fileMan
+	
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)	
+	// Cleanup the contact-set cache:
+	ContactLinkCache::DestroyL();
+#endif    
+	
+    }
+
+// ---------------------------------------------------------------------------
+
+void CCreatorEngine::DoCancel()
+    {
+    LOGSTRING("Creator: CCreatorEngine::DoCancel");
+
+    iTimer.Cancel();
+    }
+
+// ---------------------------------------------------------------------------
+
+void CCreatorEngine::RunScriptL()
+    {
+    LOGSTRING("Creator: CCreatorEngine::RunScriptL");
+
+    // startup modules (also inits the command array):
+    StartEnginesL();
+
+    // use the command parser module to init the command array from a script file
+    CCommandParser* commandParser = CCommandParser::NewLC(this);
+    RFile scriptFile;
+    TBool ret = commandParser->OpenScriptL(scriptFile);
+    CleanupClosePushL(scriptFile);
+    if( ret )
+        {
+        // wait dialog
+        CAknGlobalNote* waitDialog = CAknGlobalNote::NewLC();
+        waitDialog->SetSoftkeys( R_AVKON_SOFTKEYS_CANCEL );
+        TInt dialogId = waitDialog->ShowNoteL( EAknGlobalWaitNote, _L("Parsing") );
+        
+        TInt parseErr( KErrNone );
+        TRAPD( parserErr,
+               CCreatorScriptParser* scriptParser = CCreatorScriptParser::NewLC(this);
+               scriptParser->ParseL(scriptFile);
+               parseErr = scriptParser->GetError();
+               CleanupStack::PopAndDestroy( scriptParser );
+             );
+        waitDialog->CancelNoteL( dialogId );
+        CleanupStack::PopAndDestroy( waitDialog );
+        User::LeaveIfError( parserErr );
+        
+        if(parseErr != KErrNone)
+            {
+            // show error note
+            CAknErrorNote* note = new (ELeave) CAknErrorNote;
+            _LIT(KErrMsg, "Parser error: %d");
+            TBuf<32> msgBuf;
+            msgBuf.Format(KErrMsg, parseErr);
+            note->ExecuteLD(msgBuf);
+            CleanupStack::PopAndDestroy(); //commandParser   
+            ShutDownEnginesL();
+            return;
+            }         
+        }
+    CleanupStack::PopAndDestroy( &scriptFile );
+    CleanupStack::PopAndDestroy( commandParser );   
+
+    // start executing commands if commands in the command array
+    if (CommandArrayCount() > 0)
+        {
+        ExecuteFirstCommandL( KSavingText );
+        }
+    else
+        {
+        ShutDownEnginesL();
+        }
+
+    }
+/*
+void CCreatorEngine::RunScriptL()
+    {
+    LOGSTRING("Creator: CCreatorEngine::RunScriptL");
+
+    // startup modules (also inits the command array):
+    StartEnginesL();
+
+    // use the command parser module to init the command array from a script file
+    CCommandParser* commandParser = CCommandParser::NewLC(this);
+    commandParser->OpenScriptL();
+
+    CleanupStack::PopAndDestroy(); //commandExecuter
+
+    // start executing commands if commands in the command array
+    if (CommandArrayCount() > 0)
+        {
+        ExecuteFirstCommandL(KSavingText);
+        }
+    else
+        {
+        ShutDownEnginesL();
+        }
+
+    }
+
+*/
+
+// ---------------------------------------------------------------------------
+
+TInt CCreatorEngine::RunScriptL(const TDesC& aScriptFile)
+    {
+    LOGSTRING("Creator: CCreatorEngine::RunScriptL");
+
+    // startup modules (also inits the command array):
+    StartEnginesL();
+
+    RFile scriptFile;
+    if (scriptFile.Open(CEikonEnv::Static()->FsSession(), aScriptFile, EFileRead) != KErrNone)
+    	{
+    	ShutDownEnginesL();
+    	return KErrNotFound; // file error
+    	}
+    
+    CleanupClosePushL(scriptFile);
+    CCreatorScriptParser* scriptParser = CCreatorScriptParser::NewLC(this);
+    scriptParser->ParseL(scriptFile);
+    TInt err = scriptParser->GetError();
+    CleanupStack::PopAndDestroy(); //scriptParser
+    CleanupStack::Pop(); // scriptFile
+    scriptFile.Close();
+        
+    if (err != KErrNone)
+        {
+        ShutDownEnginesL();
+        return KErrCorrupt; // parser error
+        }         
+
+    // start executing commands if commands in the command array
+    if (CommandArrayCount() > 0)
+        {
+        ExecuteFirstCommandL( KSavingText );
+        return KErrNone; // executing commands is started
+        }
+    else
+        {
+        ShutDownEnginesL();
+        return KErrCompletion; // nothing to do
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+void CCreatorEngine::ExecuteOptionsMenuCommandL(TInt aCommand)
+    {
+    LOGSTRING("Creator: CCreatorEngine::ExecuteOptionsMenuCommandL");
+
+    // startup modules (also inits the command array):
+    StartEnginesL();
+
+    // set the home module
+    switch(aCommand)
+        {
+	    case ECmdCreateBrowserBookmarkEntries:
+	    case ECmdCreateBrowserBookmarkFolderEntries:
+	    case ECmdCreateBrowserSavedPageEntries:
+	    case ECmdCreateBrowserSavedPageFolderEntries:
+	    case ECmdDeleteBrowserBookmarks:
+	    case ECmdDeleteBrowserBookmarkFolders:
+	    case ECmdDeleteBrowserSavedPages:
+	    case ECmdDeleteBrowserSavedPageFolders:
+        case ECmdDeleteCreatorBrowserBookmarks:
+        case ECmdDeleteCreatorBrowserBookmarkFolders:
+        case ECmdDeleteCreatorBrowserSavedPages:
+        case ECmdDeleteCreatorBrowserSavedPageFolders:
+            {
+            iUsedOptionsMenuModule = iBrowser;
+            }
+            break;
+	    
+        case ECmdCreateCalendarEntryAppointments:
+	    case ECmdCreateCalendarEntryEvents:
+	    case ECmdCreateCalendarEntryAnniversaries:
+	    case ECmdCreateCalendarEntryToDos:
+	    case ECmdCreateCalendarEntryReminders:
+	    case ECmdDeleteCalendarEntries:
+	    case ECmdDeleteCreatorCalendarEntries:
+            {
+            iUsedOptionsMenuModule = iCalendar;
+            }
+            break;
+
+	    case ECmdCreatePhoneBookEntryContacts:
+	    case ECmdCreatePhoneBookEntryGroups:
+	    case ECmdCreatePhoneBookEntrySubscribedContacts:
+	    case ECmdDeleteContacts:
+	    case ECmdDeleteCreatorContacts:
+        case ECmdDeleteContactGroups:
+        case ECmdDeleteCreatorContactGroups:
+            {
+            iUsedOptionsMenuModule = iPhonebook;
+            }
+            break;
+
+	    case ECmdCreateMiscEntryNotes:
+	    case ECmdDeleteNotes:
+            {
+            iUsedOptionsMenuModule = iNotepad;
+            }
+            break;
+
+	    case ECmdCreateLogEntryMissedCalls:
+	    case ECmdCreateLogEntryReceivedCalls:
+	    case ECmdCreateLogEntryDialledNumbers:
+	    case ECmdDeleteLogs:
+	    case ECmdDeleteCreatorLogs:
+            {
+            iUsedOptionsMenuModule = iLogs;
+            }
+            break;
+
+	    case ECmdCreateMiscEntryAccessPoints:
+	    case ECmdDeleteIAPs:
+	    case ECmdDeleteCreatorIAPs:
+            {
+            iUsedOptionsMenuModule = iAccessPoints;
+            }
+            break;
+
+	    case ECmdCreateMessagingEntryMailboxes:
+	    case ECmdDeleteMailboxes:
+	    case ECmdDeleteCreatorMailboxes:
+            {
+            iUsedOptionsMenuModule = iMailboxes;
+            }
+            break;
+
+        #ifdef __PRESENCE
+	      case ECmdCreateMiscEntryIMPSServers:
+	      case ECmdDeleteIMPSs:
+	      case ECmdDeleteCreatorIMPSs:
+            {
+            iUsedOptionsMenuModule = iIMPS;
+            }
+            break;
+        #endif
+
+	      case ECmdCreateFileEntryEmptyFolder:
+	      case ECmdCreateFileEntry3GPP_70kB:
+	      case ECmdCreateFileEntryAAC_100kB:
+	      case ECmdCreateFileEntryAMR_20kB:
+	      case ECmdCreateFileEntryBMP_25kB:
+	      case ECmdCreateFileEntryDeck_1kB:
+	      case ECmdCreateFileEntryDOC_20kB:
+	      case ECmdCreateFileEntryGIF_2kB:
+	      case ECmdCreateFileEntryHTML_20kB:
+	      case ECmdCreateFileEntryJAD_1kB:
+	      case ECmdCreateFileEntryJAR_10kB:
+	      case ECmdCreateFileEntryJP2_65kB:
+	      case ECmdCreateFileEntryJPEG_200kB:
+	      case ECmdCreateFileEntryJPEG_25kB:
+	      case ECmdCreateFileEntryJPEG_500kB:
+	      case ECmdCreateFileEntryMIDI_10kB:
+	      case ECmdCreateFileEntryMP3_250kB:
+	      case ECmdCreateFileEntryMP4_200kB:
+	      case ECmdCreateFileEntryMXMF_40kB:
+	      case ECmdCreateFileEntryPNG_15kB:
+	      case ECmdCreateFileEntryPPT_40kB:
+	      case ECmdCreateFileEntryRAM_1kB:
+	      case ECmdCreateFileEntryRM_95kB:
+	      case ECmdCreateFileEntryRNG_1kB:
+	      case ECmdCreateFileEntrySVG_15kB:
+	      case ECmdCreateFileEntrySWF_15kB:
+	      case ECmdCreateFileEntryTIF_25kB:
+	      case ECmdCreateFileEntryTXT_10kB:
+	      case ECmdCreateFileEntryTXT_70kB:
+	      case ECmdCreateFileEntryVCF_1kB:
+	      case ECmdCreateFileEntryVCS_1kB:
+	      case ECmdCreateFileEntryWAV_20kB:
+	      case ECmdCreateFileEntryXLS_15kB:
+	      case ECmdCreateFileEntrySISX_10kB:
+	      case ECmdCreateFileEntryWMA_50kB:
+	      case ECmdCreateFileEntryWMV_200kB:
+	      case ECmdDeleteCreatorFiles:
+
+            {
+            iUsedOptionsMenuModule = iFiles;
+            }
+            break;
+
+
+        case ECmdCreateMessagingEntryMessages:
+        case ECmdDeleteMessages:
+        case ECmdDeleteCreatorMessages:
+            {
+            iUsedOptionsMenuModule = iMessages;
+            }
+            break;
+            
+        case ECmdCreateMiscEntryLandmarks:
+        case ECmdDeleteLandmarks:
+        case ECmdDeleteCreatorLandmarks:
+            {
+            iUsedOptionsMenuModule = iLandmarks;
+            }
+            break;
+        case ECmdDeleteAllEntries:
+        case ECmdDeleteAllCreatorEntries:
+            {
+            break;
+            }
+        default:
+            User::Panic (_L("ExecuteOptionsMenuCommandL"), 201);
+            break;
+        }
+
+
+    //If it's a delete command, asking do you really want to delete
+    if( IsDeleteCommand( aCommand ) )
+        {
+        if ( aCommand == ECmdDeleteAllEntries )
+            {
+            if ( YesNoQueryDialogL( _L("Delete all entries?") ) )
+                {
+                AppendToCommandArrayL( ECmdDeleteContacts, NULL, 1 );
+                AppendToCommandArrayL( ECmdDeleteContactGroups, NULL, 1 );
+                AppendToCommandArrayL( ECmdDeleteCalendarEntries, NULL, 1 );
+                AppendToCommandArrayL( ECmdDeleteBrowserBookmarks, NULL, 1 );
+                AppendToCommandArrayL( ECmdDeleteBrowserBookmarkFolders, NULL, 1 );
+                AppendToCommandArrayL( ECmdDeleteBrowserSavedPages, NULL, 1 );
+                AppendToCommandArrayL( ECmdDeleteBrowserSavedPageFolders, NULL, 1 );
+                AppendToCommandArrayL( ECmdDeleteLogs, NULL, 1 );
+                AppendToCommandArrayL( ECmdDeleteMessages, NULL, 1 );
+                AppendToCommandArrayL( ECmdDeleteIAPs, NULL, 1 );
+                AppendToCommandArrayL( ECmdDeleteIMPSs, NULL, 1 );
+                AppendToCommandArrayL( ECmdDeleteNotes, NULL, 1 );
+                AppendToCommandArrayL( ECmdDeleteLandmarks, NULL, 1 );
+                AppendToCommandArrayL( ECmdDeleteCreatorFiles, NULL, 1 );
+                
+                // started exucuting delete commands
+                ExecuteFirstCommandL( KDeletingText );
+                }
+            else
+                {
+                // cancelled, free resources
+                ShutDownEnginesL();
+                }
+            }
+        else if ( aCommand == ECmdDeleteAllCreatorEntries )
+            {
+            if ( YesNoQueryDialogL( _L("Delete all entries created with Creator?") ) )
+                {
+                AppendToCommandArrayL( ECmdDeleteCreatorContacts, NULL, 1 );
+                AppendToCommandArrayL( ECmdDeleteCreatorContactGroups, NULL, 1 );
+                AppendToCommandArrayL( ECmdDeleteCreatorCalendarEntries, NULL, 1 );
+                AppendToCommandArrayL( ECmdDeleteCreatorBrowserBookmarks, NULL, 1 );
+                AppendToCommandArrayL( ECmdDeleteCreatorBrowserBookmarkFolders, NULL, 1 );
+                AppendToCommandArrayL( ECmdDeleteCreatorBrowserSavedPages, NULL, 1 );
+                AppendToCommandArrayL( ECmdDeleteCreatorBrowserSavedPageFolders, NULL, 1 );
+                AppendToCommandArrayL( ECmdDeleteCreatorFiles, NULL, 1 );
+                AppendToCommandArrayL( ECmdDeleteCreatorLogs, NULL, 1 );
+                AppendToCommandArrayL( ECmdDeleteCreatorMessages, NULL, 1 );
+                AppendToCommandArrayL( ECmdDeleteCreatorIAPs, NULL, 1 );
+                AppendToCommandArrayL( ECmdDeleteCreatorIMPSs, NULL, 1 );
+                AppendToCommandArrayL( ECmdDeleteCreatorLandmarks, NULL, 1 );
+                
+                // started exucuting delete commands
+                ExecuteFirstCommandL( KDeletingText );
+                }
+            else
+                {
+                // cancelled, free resources
+                ShutDownEnginesL();
+                }
+            }
+        else if ( iUsedOptionsMenuModule->AskDataFromUserL( aCommand, iEntriesToBeCreated )  )
+            {
+            // add this command to command array
+            AppendToCommandArrayL( aCommand, NULL, 1 );
+    
+            // started exucuting commands
+            ExecuteFirstCommandL( KDeletingText );        
+            }
+        else
+            {
+            // cancelled, free resources
+            ShutDownEnginesL();
+            }
+        }
+
+    // ask user data, if query accepted start processing...
+    else if (iUsedOptionsMenuModule->AskDataFromUserL(aCommand, iEntriesToBeCreated))
+        {
+        // add this command to command array
+        AppendToCommandArrayL(aCommand, NULL, iEntriesToBeCreated);
+
+        // started exucuting commands
+        ExecuteFirstCommandL( KSavingText );
+        }
+     else
+        {
+        // cancelled, free resources
+        ShutDownEnginesL();
+        }
+    }
+
+
+
+TBool CCreatorEngine::IsDeleteCommand(TInt aCommand)
+    {
+    LOGSTRING("Creator: CCreatorEngine::IsDeleteCommand");
+
+    switch(aCommand)
+        {
+        //Add supported delete command here        
+        case ECmdDeleteAllEntries:
+        case ECmdDeleteAllCreatorEntries:
+        case ECmdDeleteEntries:
+        case ECmdDeleteContacts:
+        case ECmdDeleteCreatorContacts:
+        case ECmdDeleteContactGroups:
+        case ECmdDeleteCreatorContactGroups:
+        case ECmdDeleteCalendarEntries:
+        case ECmdDeleteCreatorCalendarEntries:
+        case ECmdDeleteBrowserBookmarks:
+        case ECmdDeleteCreatorBrowserBookmarks:
+        case ECmdDeleteBrowserBookmarkFolders:
+        case ECmdDeleteCreatorBrowserBookmarkFolders:
+        case ECmdDeleteBrowserSavedPages:
+        case ECmdDeleteCreatorBrowserSavedPages:
+        case ECmdDeleteBrowserSavedPageFolders:
+        case ECmdDeleteCreatorBrowserSavedPageFolders:
+        case ECmdDeleteCreatorFiles:
+        case ECmdDeleteLogs:
+        case ECmdDeleteCreatorLogs:
+        case ECmdDeleteMessages:
+        case ECmdDeleteCreatorMessages:
+        case ECmdDeleteMailboxes:
+        case ECmdDeleteCreatorMailboxes:
+        case ECmdDeleteIAPs:
+        case ECmdDeleteCreatorIAPs:
+        case ECmdDeleteIMPSs:
+        case ECmdDeleteCreatorIMPSs:
+        case ECmdDeleteNotes:
+        case ECmdDeleteLandmarks:
+        case ECmdDeleteCreatorLandmarks:
+            {
+            return ETrue;
+            }
+        default:
+            {
+            return EFalse;
+            }
+        }
+     
+    }
+
+// ---------------------------------------------------------------------------
+
+TBool CCreatorEngine::GetRandomDataFilenameL(TDes& aFilename)
+	{
+    CCommandParser* commandParser = CCommandParser::NewLC(this);
+	TBool ret = commandParser->GetRandomDataFilenameL(aFilename);
+    CleanupStack::PopAndDestroy(commandParser);
+    return ret;
+	}
+
+// ---------------------------------------------------------------------------
+
+TBool CCreatorEngine::GetRandomDataFromFileL(const TDesC& aFilename)
+	{
+    // wait dialog
+    CAknGlobalNote* waitDialog = CAknGlobalNote::NewLC();
+    waitDialog->SetSoftkeys(R_AVKON_SOFTKEYS_CANCEL);
+    TInt dialogId = waitDialog->ShowNoteL(EAknGlobalWaitNote, _L("Reading random data"));
+
+    for (TInt i = 0; i < iStringArrays.Count(); ++i)
+        {
+        delete iStringArrays[i].iArrayPtr;
+        }
+    iStringArrays.Reset();
+
+    TBool errorDetected = EFalse;
+
+    // NOTE: These must be exactly in same order as in enumeration:
+    
+    if (ReadRandomDataL(EFirstName, R_DATA_FIRSTNAMES, aFilename, CCreatorRandomDataParser::EFirstName) != KErrNone)
+    	{
+    	errorDetected = ETrue;
+    	}
+    if (ReadRandomDataL(ESurname, R_DATA_SURNAMES, aFilename, CCreatorRandomDataParser::ESurname) != KErrNone)
+    	{
+    	errorDetected = ETrue;
+    	}
+    if (ReadRandomDataL(ECompany, R_DATA_COMPANIES, aFilename, CCreatorRandomDataParser::ECompany) != KErrNone)
+    	{
+    	errorDetected = ETrue;
+    	}
+    if (ReadRandomDataL(EAddress, R_DATA_ADDRESSES, aFilename, CCreatorRandomDataParser::EAddress) != KErrNone)
+    	{
+    	errorDetected = ETrue;
+    	}
+    if (ReadRandomDataL(EJobTitle, R_DATA_JOBTITLES, aFilename, CCreatorRandomDataParser::EJobTitle) != KErrNone)
+    	{
+    	errorDetected = ETrue;
+    	}
+    if (ReadRandomDataL(EPhoneNumber, R_DATA_PHONENUMBERS, aFilename, CCreatorRandomDataParser::EPhoneNumber) != KErrNone)
+    	{
+    	errorDetected = ETrue;
+    	}
+    if (ReadRandomDataL(EGroupName, R_DATA_GROUPNAMES, aFilename, CCreatorRandomDataParser::EGroupName) != KErrNone)
+    	{
+    	errorDetected = ETrue;
+    	}
+    if (ReadRandomDataL(EMeetingReason, R_DATA_MEETINGREASONS, aFilename, CCreatorRandomDataParser::EMeetingReason) != KErrNone)
+    	{
+    	errorDetected = ETrue;
+    	}
+    if (ReadRandomDataL(EMeetingPlace, R_DATA_MEETINGPLACES, aFilename, CCreatorRandomDataParser::EMeetingPlace) != KErrNone)
+    	{
+    	errorDetected = ETrue;
+    	}
+    if (ReadRandomDataL(EMemoText, R_DATA_MEMOS, aFilename, CCreatorRandomDataParser::EMemoText) != KErrNone)
+    	{
+    	errorDetected = ETrue;
+    	}
+    if (ReadRandomDataL(EAnniversaryReason, R_DATA_ANNIVERSARIES, aFilename, CCreatorRandomDataParser::EAnniversaryReason) != KErrNone)
+    	{
+    	errorDetected = ETrue;
+    	}
+    if (ReadRandomDataL(EToDoText, R_DATA_TODOS, aFilename, CCreatorRandomDataParser::EToDoText) != KErrNone)
+    	{
+    	errorDetected = ETrue;
+    	}
+    if (ReadRandomDataL(EReminderText, R_DATA_REMINDERS, aFilename, CCreatorRandomDataParser::EReminderText) != KErrNone)
+    	{
+    	errorDetected = ETrue;
+    	}
+    if (ReadRandomDataL(EMessageSubject, R_DATA_MESSAGESUBJECTS, aFilename, CCreatorRandomDataParser::EMessageSubject) != KErrNone)
+    	{
+    	errorDetected = ETrue;
+    	}
+    if (ReadRandomDataL(EMessageText, R_DATA_MESSAGETEXTS, aFilename, CCreatorRandomDataParser::EMessageText) != KErrNone)
+    	{
+    	errorDetected = ETrue;
+    	}
+    if (ReadRandomDataL(ECity, R_DATA_CITIES, aFilename, CCreatorRandomDataParser::ECity) != KErrNone)
+    	{
+    	errorDetected = ETrue;
+    	}
+    if (ReadRandomDataL(ECountry, R_DATA_COUNTRIES, aFilename, CCreatorRandomDataParser::ECountry) != KErrNone)
+    	{
+    	errorDetected = ETrue;
+    	}
+    if (ReadRandomDataL(EPostcode, R_DATA_POSTCODES, aFilename, CCreatorRandomDataParser::EPostcode) != KErrNone)
+    	{
+    	errorDetected = ETrue;
+    	}
+    if (ReadRandomDataL(EState, R_DATA_STATES, aFilename, CCreatorRandomDataParser::EState) != KErrNone)
+    	{
+    	errorDetected = ETrue;
+    	}
+    if (ReadRandomDataL(EPobox, R_DATA_POBOXES, aFilename, CCreatorRandomDataParser::EPobox) != KErrNone)
+    	{
+    	errorDetected = ETrue;
+    	}
+    if (ReadRandomDataL(EPrefix, R_DATA_PREFIXES, aFilename, CCreatorRandomDataParser::EPrefix) != KErrNone)
+    	{
+    	errorDetected = ETrue;
+    	}
+    if (ReadRandomDataL(ESuffix, R_DATA_SUFFIXES, aFilename, CCreatorRandomDataParser::ESuffix) != KErrNone)
+    	{
+    	errorDetected = ETrue;
+    	}
+    if (ReadRandomDataL(ELandmarkName, R_DATA_LANDMARK_NAMES, aFilename, CCreatorRandomDataParser::ELandmarkName) != KErrNone)
+    	{
+    	errorDetected = ETrue;
+    	}
+    if (ReadRandomDataL(ELandmarkDescription, R_DATA_LANDMARK_DESCRIPTIONS, aFilename, CCreatorRandomDataParser::ELandmarkDescription) != KErrNone)
+    	{
+    	errorDetected = ETrue;
+    	}
+    
+    // remove the wait dialog
+    waitDialog->CancelNoteL(dialogId);
+    CleanupStack::PopAndDestroy(waitDialog);
+    
+    if (errorDetected)
+    	{
+		CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+		note->ExecuteLD(_L("Error in reading random data."));
+   	}
+    
+    return !errorDetected;
+	}
+
+// ---------------------------------------------------------------------------
+
+TInt CCreatorEngine::ReadRandomDataL(const TRandomStringType aRandomStringType,
+		                             const TInt aResourceId,
+		                             const TDesC& aFilename,
+		                             const CCreatorRandomDataParser::TRandomDataType aRandomDataType)
+	{
+	TInt error = KErrNone;
+	if (aFilename == KNullDesC)
+		{
+        iStringArrays.AppendL(TStringArrayPtr(aRandomStringType, iEnv->ReadDesCArrayResourceL(aResourceId)));
+		}
+	else
+		{
+	    CCreatorRandomDataParser* dataParser = CCreatorRandomDataParser::NewLC();
+		CDesCArrayFlat* array = NULL;
+	
+		TRAP(error, array = dataParser->ParseL(aFilename, aRandomDataType));
+		if (error == KErrNone)
+			{
+			error = dataParser->GetError();
+			}
+	    if ((error == KErrNone) && (array->MdcaCount() > 0))
+	    	{
+	    	iStringArrays.AppendL(TStringArrayPtr(aRandomStringType, array));
+	    	}
+	    else
+	    	{
+	    	if (array)
+	    		{
+	    		array->Reset();
+	    		delete array;
+	    		}
+	        iStringArrays.AppendL(TStringArrayPtr(aRandomStringType, iEnv->ReadDesCArrayResourceL(aResourceId)));
+	    	}
+		CleanupStack::PopAndDestroy(dataParser);
+		}
+	return error;
+	}
+
+// ---------------------------------------------------------------------------
+
+void CCreatorEngine::AppendToCommandArrayL(TInt aCommand, CCreatorModuleBaseParameters* aParameters, TInt aNumberOfEntries)
+    {
+    LOGSTRING("Creator: CCreatorEngine::AppendToCommandArrayL");
+    iParameterArray.AppendL(aParameters);
+
+    for (TInt i=0; i<aNumberOfEntries; i++)
+        iCommandArray->AppendL( TCommand(aCommand, aParameters) );
+    }
+
+// ---------------------------------------------------------------------------
+
+TInt CCreatorEngine::CommandArrayCount()
+    {
+    TInt count(0);
+    
+    if (iCommandArray)
+        count = iCommandArray->Count();
+    
+    LOGSTRING2("Creator: CCreatorEngine::CommandArrayCount returns %d", count);
+    
+    return count;
+    }
+
+// ---------------------------------------------------------------------------
+
+//returs fileid by its name, eg. 1 in 
+TInt CCreatorEngine::GetAttachmentIdL( const TDesC& aAttachmentIdStr ) const
+    {
+    TInt mapCount = sizeof(FileMap) / sizeof(FileMapping);
+    
+    for( TInt i = 0; i < mapCount; ++i )
+        {
+        if( FileMap[i].FileName() == aAttachmentIdStr )
+            return FileMap[i].FileId();
+        }
+    LOGSTRING2("CCreatorEngine::GetAttachmentIdL: Unknown attachment file id: %s", &aAttachmentIdStr);
+    User::Leave(KErrGeneral);
+    return KErrNotFound; // Not reached, but disables a compiler warning
+    }
+
+// ---------------------------------------------------------------------------
+
+// returns a random string from the resource files
+TPtrC CCreatorEngine::TestDataPathL (enum TTestDataPath aTestDataPath )
+    {
+    LOGSTRING("Creator: CCreatorEngine::TestDataPathL");
+
+    TFileName filePath;
+
+    switch (aTestDataPath )
+        {
+        case ESavedDeck_1kB:
+            {
+            filePath.Copy (_L("Deck-1kB.saveddeck") );
+            }
+            break;
+    
+        case EJPEG_25kB:
+            {
+            filePath.Copy (_L("JPEG-25kB.jpg") );
+            }
+            break;
+    
+        case EJPEG_200kB:
+            {
+            filePath.Copy (_L("JPEG-200kB.jpg") );
+            }
+            break;
+    
+        case EJPEG_500kB:
+            {
+            filePath.Copy (_L("JPEG-500kB.jpg") );
+            }
+            break;
+    
+        case EPNG_15kB:
+            {
+            filePath.Copy (_L("PNG-15kB.png") );
+            }
+            break;
+    
+        case EGIF_2kB:
+            {
+            filePath.Copy (_L("GIF-2kB.gif") );
+            }
+            break;
+    
+        case ERNG_1kB:
+            {
+            filePath.Copy (_L("RNG-1kB.rng") );
+            }
+            break;
+    
+        case EMIDI_10kB:
+            {
+            filePath.Copy (_L("MIDI-10kB.mid") );
+            }
+            break;
+    
+        case EWAVE_20kB:
+            {
+            filePath.Copy (_L("WAV-20kB.wav") );
+            }
+            break;
+    
+        case EAMR_20kB:
+            {
+            filePath.Copy (_L("AMR-20kB.amr") );
+            }
+            break;
+    
+        case EExcel_15kB:
+            {
+            filePath.Copy (_L("XLS-15kB.xls") );
+            }
+            break;
+    
+        case EWord_20kB:
+            {
+            filePath.Copy (_L("DOC-20kB.doc") );
+            }
+            break;
+    
+        case EPowerPoint_40kB:
+            {
+            filePath.Copy (_L("PPT-40kB.ppt") );
+            }
+            break;
+    
+        case EText_10kB:
+            {
+            filePath.Copy (_L("TXT-10kB.txt") );
+            }
+            break;
+    
+        case EText_70kB:
+            {
+            filePath.Copy (_L("TXT-70kB.txt") );
+            }
+            break;
+    
+        case E3GPP_70kB:
+            {
+            filePath.Copy (_L("3GPP-70kB.3gpp") );
+            }
+            break;
+    
+        case EMP3_250kB:
+            {
+            filePath.Copy (_L("MP3-250kB.mp3") );
+            }
+            break;
+    
+        case EAAC_100kB:
+            {
+            filePath.Copy (_L("AAC-100kB.aac") );
+            }
+            break;
+    
+        case ERM_95kB:
+            {
+            filePath.Copy (_L("RM-95kB.rm") );
+            }
+            break;
+    
+        case EBMP_25kB:
+            {
+            filePath.Copy (_L("BMP-25kB.bmp") );
+            }
+            break;
+        case EHTML_20kB:
+            {
+            filePath.Copy (_L("HTML-20kB.html") );
+            }
+            break;
+        case EJAD_1kB:
+            {
+            filePath.Copy (_L("JAD-1kB.jad") );
+            }
+            break;
+        case EJAR_10kB:
+            {
+            filePath.Copy (_L("JAR-10kB.jar") );
+            }
+            break;
+        case EJP2_65kB:
+            {
+            filePath.Copy (_L("JP2-65kB.jp2") );
+            }
+            break;
+        case EMP4_200kB:
+            {
+            filePath.Copy (_L("MP4-200kB.mp4") );
+            }
+            break;
+        case EMXMF_40kB:
+            {
+            filePath.Copy (_L("MXMF-40kB.mxmf") );
+            }
+            break;
+        case ERAM_1kB:
+            {
+            filePath.Copy (_L("RAM-1kB.ram") );
+            }
+            break;
+        case ESVG_15kB:
+            {
+            filePath.Copy (_L("SVG-15kB.svg") );
+            }
+            break;
+        case ESWF_15kB:
+            {
+            filePath.Copy (_L("SWF-15kB.swf") );
+            }
+            break;
+        case ETIF_25kB:
+            {
+            filePath.Copy (_L("TIF-25kB.tif") );
+            }
+            break;
+        case EVCF_1kB:
+            {
+            filePath.Copy (_L("VCF-1kB.vcf") );
+            }
+            break;
+        case EVCS_1kB:
+            {
+            filePath.Copy (_L("VCS-1kB.vcs") );
+            }
+            break;
+        case ESISX_10kB:
+            {
+            filePath.Copy (_L("SISX-10kB.sisx") );
+            }
+            break;
+        case EWMA_50kB:
+            {
+            filePath.Copy (_L("WMA-50kB.wma") );
+            }
+            break;
+        case EWMV_200kB:
+            {
+            filePath.Copy (_L("WMV-200kB.wmv") );
+            }
+            break;
+
+        default:
+            User::Panic (_L("Test data"), 401 );
+            break;
+        }
+
+    TFileName fullTargetPath;
+    fullTargetPath.Copy( iTempPath->Des() );
+    fullTargetPath.Append( filePath );
+    if (ConeUtils::FileExists(fullTargetPath))
+        {        
+        // No need to copy, if the file already exists.
+        LOGSTRING2("Creator: CCreatorEngine::TestDataPathL %S already exists", &fullTargetPath);
+        return fullTargetPath;
+        }
+
+    // Define the path where the testdata can be retrieved
+	// get the data from the private directory in secure platform
+    TFileName fullAppPath = iEnv->EikAppUi()->Application()->AppFullName();
+	TChar driveLetter = fullAppPath[0];
+	TInt driveNumber;
+	
+	iEnv->FsSession().CharToDrive(driveLetter, driveNumber);
+	iEnv->FsSession().SetSessionToPrivate( driveNumber );   // "\\private\\20011383\\"
+ 
+
+    // check the file exists
+    if (!ConeUtils::FileExists(filePath))
+        {
+        LOGSTRING2("Creator: CCreatorEngine::TestDataPathL %S not found", &filePath);
+
+        TInt generatingError( KErrNone );
+        
+        // The file could be on C drive
+        iEnv->FsSession().SetSessionToPrivate( KRegisterDrive );
+        
+        if ( !ConeUtils::FileExists( filePath ) )
+            {
+            // The file is not on C drive, see if we can generate it
+            
+            // Make sure that the private path of this app in c-drive exists
+            iEnv->FsSession().CreatePrivatePath( KRegisterDrive );
+            
+            TFileName privatePath;
+            iEnv->FsSession().PrivatePath( privatePath );
+            privatePath.Append( filePath );
+            TChar privateDriveChar;
+            iEnv->FsSession().DriveToChar( KRegisterDrive, privateDriveChar );
+            TFileName fullPrivatePath; // full path of a file to be generated
+            fullPrivatePath.Append( privateDriveChar );
+            fullPrivatePath.Append( ':' );
+            fullPrivatePath.Append( privatePath );
+
+            switch ( aTestDataPath )
+                {
+                case EJPEG_25kB:
+                case EJPEG_200kB:
+                case EJPEG_500kB:
+                case EBMP_25kB:
+                case EGIF_2kB:
+                    {
+                    TRAP( generatingError, GenerateSourceImageFileL( aTestDataPath, fullPrivatePath ) );
+                    // GenerateSourceImageFileL calls TestDataPathL -> private session points to z
+                    // change it back to KRegisterDrive, because generated source file is there
+                    // and we need to copy it at the end of this function.
+                    iEnv->FsSession().SetSessionToPrivate( KRegisterDrive );
+                    break;
+                    }
+                case EText_10kB:
+                    {
+                    TRAP( generatingError, GenereteSourceTextFileL( fullPrivatePath, 10000 ) );
+                    // GenerateSourceImageFileL calls TestDataPathL -> private session points to z
+                    // change it back to KRegisterDrive, because generated source file is there
+                    // and we need to copy it at the end of this function.
+                    iEnv->FsSession().SetSessionToPrivate( KRegisterDrive );
+                    break;
+                    }
+                case EText_70kB:
+                    {
+                    TRAP( generatingError, GenereteSourceTextFileL( fullPrivatePath, 70000 ) );
+                    break;
+                    }
+                default:
+                    {
+                    generatingError = KErrNotSupported;
+                    break;
+                    }
+                }
+            }
+        
+        if ( iUserCancelled )
+            {
+            LOGSTRING("Creator: CCreatorEngine::TestDataPathL iUserCancelled" );
+            User::Leave( KErrCancel );
+            }
+        
+        if ( generatingError )
+            {
+            // Generating the file failed
+            
+            // cancel the dialog
+            iProgressDialog->ProcessFinishedL();
+            DialogDismissedL(EAknSoftkeyBack);
+
+            // show error note
+            CAknErrorNote* note = new (ELeave) CAknErrorNote;
+            note->ExecuteLD(_L("Test data missing"));
+
+            User::Leave(KErrPathNotFound);
+            }
+        }
+
+	// now copy the data to D-drive to make the file public
+	iEnv->FsSession().MkDirAll( iTempPath->Des() );
+	TInt copyErr = BaflUtils::CopyFile(iEnv->FsSession(), filePath, fullTargetPath);
+	LOGSTRING4("Creator: CCreatorEngine::TestDataPathL copy %S to %S returns=%d", &filePath, &fullTargetPath, copyErr);
+	
+	// make sure that the file won't have a read only attribute
+	TEntry fileEntry;
+	iEnv->FsSession().Entry(fullTargetPath, fileEntry);
+	iEnv->FsSession().SetEntry(fullTargetPath, fileEntry.iModified, NULL, KEntryAttReadOnly);
+	
+	filePath = fullTargetPath;  // change the reference to the temp path
+    return filePath;
+    }
+
+// ---------------------------------------------------------------------------
+
+// a generic query which can be used by the modules
+TBool CCreatorEngine::EntriesQueryDialogL(TInt& aNumberOfEntries, const TDesC& aPrompt, TBool aAcceptsZero)
+    {
+    LOGSTRING("Creator: CCreatorEngine::EntriesQueryDialogL");
+
+    CAknNumberQueryDialog* dialog = CAknNumberQueryDialog::NewL(aNumberOfEntries, CAknQueryDialog::ENoTone);
+    dialog->SetMinimumAndMaximum (1, 99999);
+
+    if(dialog->ExecuteLD(R_ENTRY_QUERY, aPrompt))
+        {
+        if (aAcceptsZero)
+            {
+            if (aNumberOfEntries>=0)
+                return ETrue;
+            else
+                return EFalse;
+            }
+        else
+            {
+            if (aNumberOfEntries>0)
+                return ETrue;
+            else
+                return EFalse;
+            }
+        }
+    else
+        return EFalse; // cancelled
+
+
+    }
+
+// ---------------------------------------------------------------------------
+
+// a generic query which can be used by the modules
+TBool CCreatorEngine::TimeQueryDialogL(TTime& aTime, TInt aResourceId)
+    {
+    LOGSTRING("Creator: CCreatorEngine::TimeQueryDialogL");
+
+    CAknTimeQueryDialog* dialog = CAknTimeQueryDialog::NewL(aTime, CAknQueryDialog::ENoTone);
+    return dialog->ExecuteLD(aResourceId);
+    }
+
+// ---------------------------------------------------------------------------
+
+// a generic YES NO query which can be used by the modules
+TBool CCreatorEngine::YesNoQueryDialogL(const TDesC& aPrompt)
+    {
+    LOGSTRING("Creator: CCreatorEngine::YesNoQueryDialogL");
+
+    CAknQueryDialog* dialog = CAknQueryDialog::NewL( );
+    
+    TInt yes = dialog->ExecuteLD(R_YES_NO_DIALOG, aPrompt);    
+
+    return  (TBool)yes;
+
+    }
+
+// ---------------------------------------------------------------------------
+
+
+
+// a method to return a default Internet Access Point
+TUint32 CCreatorEngine::GetDefaultIAPL()
+	{
+    LOGSTRING("Creator: CCreatorEngine::GetDefaultIAPL");
+
+	TUint32 lIAPid = 1; // Default value
+
+	CCommsDatabase* cDatabase = CCommsDatabase::NewL();
+	CleanupStack::PushL(cDatabase);
+
+	CCommsDbTableView* tableView = cDatabase->OpenTableLC(TPtrC(IAP));
+
+	TInt errorCode = tableView->GotoFirstRecord();
+		
+	if ( errorCode == KErrNone ) 
+		{
+		TUint32	iValue;
+		tableView->ReadUintL(TPtrC(COMMDB_ID),iValue);
+		lIAPid = iValue;
+		}
+
+	CleanupStack::PopAndDestroy(2); // cDatabase,tableView
+
+	return lIAPid;
+	}
+
+// ---------------------------------------------------------------------------
+
+TUint32 CCreatorEngine::AccessPointNameToIdL(const TDesC& aAPName, TBool aAnyIfNotFound )
+    {
+    LOGSTRING("Creator: CCreatorEngine::AccessPointNameToIdL");
+    // Accespoint impl moved from engine to accespoint implementations for supporting 3.0-3.1 and 3.2->
+    return iAccessPoints->AccessPointNameToIdL(aAPName, aAnyIfNotFound );
+    }
+
+static CCreatorEngine::TTestDataPath SoundFiles[] = {
+        CCreatorEngine::EMIDI_10kB,
+        CCreatorEngine::EWAVE_20kB,  
+        CCreatorEngine::EMP3_250kB,
+        CCreatorEngine::EAAC_100kB
+        };
+
+static CCreatorEngine::TTestDataPath PictureFiles[] = 
+    {
+    CCreatorEngine::EJPEG_25kB,
+    CCreatorEngine::EJPEG_200kB,
+    CCreatorEngine::EJPEG_500kB,
+    CCreatorEngine::EPNG_15kB,
+    CCreatorEngine::EGIF_2kB
+    };
+
+TPtrC CCreatorEngine::CreateSoundFileL(TTestDataPath aId)
+{
+	TPtrC tempPath(TestDataPathL(aId));
+	// Copy file to permanent location:
+    TParse parser;
+    parser.Set(tempPath, NULL, NULL);
+    TPtrC fileName(parser.NameAndExt());
+    HBufC* fullTargetPath = HBufC::NewLC( KMaxFileName );
+    fullTargetPath->Des().Copy( PathInfo::PhoneMemoryRootPath() );
+    fullTargetPath->Des().Append( PathInfo::DigitalSoundsPath() );
+    
+    fullTargetPath->Des().Append(fileName);
+    CopyFileL(tempPath, *fullTargetPath);
+    iAllocatedFilePaths.AppendL(fullTargetPath);
+    CleanupStack::Pop(); // fullTargetPath
+    return fullTargetPath->Des(); 
+}
+TPtrC CCreatorEngine::CreateRandomSoundFileL()
+{
+    TInt numOfFiles = sizeof(SoundFiles) / sizeof(TTestDataPath);
+    return CreateSoundFileL(SoundFiles[RandomNumber(0, numOfFiles-1)]);
+}
+TPtrC CCreatorEngine::RandomSoundFileL()
+{
+    TInt numOfFiles = sizeof(SoundFiles) / sizeof(TTestDataPath);
+    return TestDataPathL(SoundFiles[RandomNumber(0, numOfFiles-1)]);
+}
+    
+TPtrC CCreatorEngine::RandomPictureFileL()
+{
+    TInt numOfFiles = sizeof(PictureFiles) / sizeof(TTestDataPath);
+    return TestDataPathL(PictureFiles[RandomNumber(0, numOfFiles-1)]);
+}
+// ---------------------------------------------------------------------------
+
+// returns a random string from the resource files
+TPtrC CCreatorEngine::RandomString(enum TRandomStringType aRandomStringType)
+    {
+    LOGSTRING("Creator: CCreatorEngine::RandomString");
+    
+    // Let's see if the array is OK and the string arrays are in correct order:
+    if( ((TInt) aRandomStringType) < iStringArrays.Count() && 
+        iStringArrays[aRandomStringType].iStringType == aRandomStringType)
+        {        
+        TInt rand = (TInt) (iStringArrays[aRandomStringType].iArrayPtr->Count() * Math::FRand(iSeed));
+        return (*iStringArrays[aRandomStringType].iArrayPtr)[rand];
+        }
+    
+    // Now let's loop the arrays and try to find one with the type:
+    for( TInt i = 0; i < iStringArrays.Count(); ++i )
+        {
+        if( iStringArrays[i].iStringType == aRandomStringType )
+            {
+            TInt rand = (TInt) (iStringArrays[i].iArrayPtr->Count() * Math::FRand(iSeed));
+            return (*iStringArrays[i].iArrayPtr)[rand];
+            }
+        }
+
+    User::Panic (_L("Random string"), 402);    
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+
+// returns a random number
+TInt CCreatorEngine::RandomNumber(TInt aRange)
+    {
+    LOGSTRING2("Creator: CCreatorEngine::RandomNumber aRange=%d", aRange);
+
+    return (TInt) (aRange*Math::FRand(iSeed));
+    }
+
+// ---------------------------------------------------------------------------
+
+// returns a random number
+TInt CCreatorEngine::RandomNumber(TInt aMin, TInt aMax)
+    {
+    LOGSTRING3("Creator: CCreatorEngine::RandomNumber aMin=%d aMax=%d", aMin, aMax);
+
+    TInt range = (aMax > aMin ? aMax - aMin : aMin - aMax) + 1;
+    TInt random = (TInt) (range*Math::FRand(iSeed));
+    
+    random = (random % range) + aMin;
+
+    if (random > aMax)
+        random = aMax;
+    else if (random < aMin)
+        random = aMin;
+    
+    return random;
+    }
+
+TTime CCreatorEngine::RandomTime(TTime baseTime, TRandomDateType type, TInt aMinHours, TInt aMaxHours, TInt aMinMinutes, TInt aMaxMinutes )
+    {
+    TInt randomHours = RandomNumber(aMinHours, aMaxHours);
+    TInt randomMinutes = RandomNumber(aMinMinutes, aMaxMinutes);
+    
+    switch( type )
+    {
+    case EDatePast:
+        return (baseTime - TTimeIntervalHours(randomHours)) - TTimeIntervalMinutes(randomMinutes);
+    case EDateFuture:
+        return (baseTime + TTimeIntervalHours(randomHours)) + TTimeIntervalMinutes(randomMinutes);
+    default:
+        break;
+    }
+    return baseTime;
+    }
+
+TTime CCreatorEngine::RandomDate(TTime baseTime, TRandomDateType type, TInt aMinDays, TInt aMaxDays)
+    {
+    TInt random = RandomNumber(aMinDays, aMaxDays);
+    
+    switch( type )
+    {
+    case EDatePast:
+        return baseTime - TTimeIntervalDays(random);
+    case EDateFuture:
+        return baseTime + TTimeIntervalDays(random);
+    default:
+        break;
+    }
+        
+    return baseTime;
+    }
+
+TTime CCreatorEngine::RandomDate(TRandomDateType type, TInt aMinDays, TInt aMaxDays)
+    {    
+    TTime time;
+    // Set to current time:
+    time.HomeTime();
+    return RandomDate(time, type, aMinDays, aMaxDays);
+    }
+
+HBufC* CCreatorEngine::CreateEmailAddressLC()
+    {
+    _LIT(KCountry, "com");    
+    return CreateEmailAddressLC(RandomString(EFirstName), RandomString(ESurname), RandomString(ECompany), KCountry);
+    }
+
+HBufC* CCreatorEngine::CreateHTTPUrlLC()
+    {
+    _LIT(KProtocol, "http://");
+    _LIT(KPrefix, "www");
+    _LIT(KCountry, "com");
+    return CreateUrlLC(KProtocol, KPrefix, RandomString(ECompany), KCountry);
+    }
+
+HBufC* CCreatorEngine::CreateRandomStringLC(TInt aStrLen)
+    {
+    TInt minAscii = 65;
+    TInt maxAscii = 90;
+    HBufC* str = HBufC::NewL(aStrLen);
+    CleanupStack::PushL(str);
+    for( TInt i = 0; i < aStrLen; ++i )
+        {
+        TInt random = RandomNumber(minAscii, maxAscii);
+        TChar randomChar = TChar((TUint) random);
+        str->Des().Append(randomChar);
+        }    
+    return str;
+    }
+
+HBufC* CCreatorEngine::CreateEmailAddressLC(
+        const TDesC& firstname,
+        const TDesC& lastname,
+        const TDesC& domain,
+        const TDesC& country ) const
+        {
+        HBufC* email = HBufC::New(firstname.Length() + lastname.Length() + domain.Length() + country.Length() + 3);
+        CleanupStack::PushL(email);        
+        _LIT(KEmailAddr, "%S.%S@%S.%S");
+        email->Des().Format(KEmailAddr, &firstname, &lastname, &domain, &country);
+        return email;
+        }
+        
+HBufC* CCreatorEngine::CreateUrlLC(
+        const TDesC& protocol,
+        const TDesC& prefix,
+        const TDesC& domain,
+        const TDesC& country) const
+    {
+    HBufC* url = HBufC::New(protocol.Size() + prefix.Size() + domain.Size() + country.Size() + 2);
+    CleanupStack::PushL(url);
+    _LIT(KUrl, "%S%S.%S.%S");
+    url->Des().Format(KUrl, &protocol, &prefix, &domain, &country);    
+    return url;
+    }
+// ---------------------------------------------------------------------------
+
+void CCreatorEngine::SetDefaultPathForFileCommandL(TInt aCommand, TFileName& aPath)
+	{
+	aPath.Copy( PathInfo::PhoneMemoryRootPath() );
+	switch (aCommand)
+	{
+	case ECmdCreateFileEntryJPEG_25kB:
+	case ECmdCreateFileEntryJPEG_200kB:
+	case ECmdCreateFileEntryJPEG_500kB:
+	case ECmdCreateFileEntryPNG_15kB:
+	case ECmdCreateFileEntryGIF_2kB:
+	case ECmdCreateFileEntryBMP_25kB:
+	case ECmdCreateFileEntrySVG_15kB:
+	case ECmdCreateFileEntryTIF_25kB:
+	case ECmdCreateFileEntryJP2_65kB:
+
+		{  aPath.Append( PathInfo::ImagesPath() );  break;  }
+
+	case ECmdCreateFileEntryRNG_1kB:
+		{  aPath.Append( PathInfo::SimpleSoundsPath() );  break;  }
+
+	case ECmdCreateFileEntryMIDI_10kB:
+	case ECmdCreateFileEntryWAV_20kB:
+	case ECmdCreateFileEntryAMR_20kB:
+	case ECmdCreateFileEntryMP3_250kB:
+	case ECmdCreateFileEntryAAC_100kB:
+	case ECmdCreateFileEntryWMA_50kB:
+		{  aPath.Append( PathInfo::DigitalSoundsPath() );  break;  }
+
+	case ECmdCreateFileEntry3GPP_70kB:
+	case ECmdCreateFileEntryRM_95kB:
+	case ECmdCreateFileEntryMP4_200kB:
+	case ECmdCreateFileEntryWMV_200kB:
+
+		{  aPath.Append( PathInfo::VideosPath() );  break;  }
+
+	case ECmdCreateFileEntryEmptyFolder:
+		{  aPath.Append( _L("MyFolder\\") );  break;  }
+
+	default:
+		{  aPath.Append( PathInfo::OthersPath() );  break;  }
+
+	}
+	}
+
+
+// ---------------------------------------------------------------------------
+
+void CCreatorEngine::CancelComplete()
+    {
+    LOGSTRING("Creator: CCreatorEngine::CancelComplete");
+    // free resources and show a note
+    TRAP_IGNORE( ShutDownEnginesL() );
+
+    TRAP_IGNORE(
+        CAknInformationNote* note = new (ELeave) CAknInformationNote;
+        note->ExecuteLD(_L("Cancelled"));
+        );
+    }
+
+// ---------------------------------------------------------------------------
+
+TCommand::TCommand(TInt aCommandId, CCreatorModuleBaseParameters* aParameters)
+    {
+    iCommandId = aCommandId;
+    iParameters = aParameters;
+    }
+
+// ---------------------------------------------------------------------------
+
+TCommand::~TCommand()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+
+CAsyncWaiter* CAsyncWaiter::NewL(TInt aPriority)
+	{
+	CAsyncWaiter* self = new(ELeave) CAsyncWaiter(aPriority);
+	return self;
+	}
+
+CAsyncWaiter* CAsyncWaiter::NewLC(TInt aPriority)
+	{
+	CAsyncWaiter* self = new(ELeave) CAsyncWaiter(aPriority);
+	CleanupStack::PushL(self);
+	return self;
+	}
+	
+CAsyncWaiter::CAsyncWaiter(TInt aPriority) : CActive(aPriority)
+	{
+	CActiveScheduler::Add(this);
+	}	
+
+CAsyncWaiter::~CAsyncWaiter()
+	{
+	Cancel();
+	}
+	
+void CAsyncWaiter::StartAndWait()
+	{
+    LOGSTRING("Creator: CAsyncWaiter::StartAndWait");
+
+    iStatus = KRequestPending;
+    SetActive();
+    iWait.Start();
+	}
+	
+TInt CAsyncWaiter::Result() const
+	{
+	return iError;
+	}
+	
+void CAsyncWaiter::RunL()
+	{
+    LOGSTRING("Creator: CAsyncWaiter::RunL");
+
+	iError = iStatus.Int();
+	CAknEnv::StopSchedulerWaitWithBusyMessage( iWait );
+	}
+	
+void CAsyncWaiter::DoCancel()
+	{
+    LOGSTRING("Creator: CAsyncWaiter::DoCancel");
+
+	iError = KErrCancel;
+    if( iStatus == KRequestPending )
+        {
+        TRequestStatus* s=&iStatus;
+        User::RequestComplete( s, KErrCancel );
+        }
+
+    CAknEnv::StopSchedulerWaitWithBusyMessage( iWait );
+	}
+	
+FileMapping::FileMapping( const TDesC& aAttName, TInt aAttId, TInt aCommandId )
+    :
+    iFileName(aAttName),
+    iFileId(aAttId),
+    iCommandId(aCommandId)
+    {}
+
+    const TDesC& FileMapping::FileName() const
+    {
+        return iFileName;
+    }
+
+    TInt FileMapping::FileId() const
+    {
+        return iFileId;
+    }   
+
+    TInt FileMapping::CommandId() const
+    {
+        return iCommandId;
+    }
+    
+// ---------------------------------------------------------------------------  
+CDictionaryFileStore* CCreatorEngine::FileStoreLC()
+    {
+    LOGSTRING("Creator: CCreatorEngine::FileStoreLC");
+    CDictionaryFileStore* store;
+    
+    // make sure that the private path of this app in c-drive exists
+    CEikonEnv::Static()->FsSession().CreatePrivatePath( KRegisterDrive ); // c:\\private\\20011383\\
+
+    // handle register always in the private directory 
+    User::LeaveIfError( CEikonEnv::Static()->FsSession().SetSessionToPrivate( KRegisterDrive ) );
+    store = CDictionaryFileStore::OpenLC( CEikonEnv::Static()->FsSession(), KRegisterFileName, KUidCreatorApp );
+    return store;
+    }
+    
+// ---------------------------------------------------------------------------
+void CCreatorEngine::ReadEntryIdsFromStoreL( RArray<TInt>& aEntryIds, const TUid aModuleUid )
+    {
+    LOGSTRING("Creator: CCreatorEngine::ReadEntryIdsFromStoreL");
+    CDictionaryFileStore* store = FileStoreLC();
+    User::LeaveIfNull( store );
+    if ( store->IsPresentL( aModuleUid ) )
+        {
+        RDictionaryReadStream in;
+        in.OpenLC( *store, aModuleUid );
+        TFileName fullPath;
+        TInt err( KErrNone );
+        TInt id( KErrNotFound );
+        while ( !err )
+            {
+            TRAP( err, id = in.ReadInt32L() );  // will leave with KErrEof
+            if ( !err )
+                {
+                aEntryIds.Append( id );
+                }
+            }
+        CleanupStack::PopAndDestroy( &in );
+        }
+    CleanupStack::PopAndDestroy( store );
+    }
+
+// ---------------------------------------------------------------------------
+void CCreatorEngine::WriteEntryIdsToStoreL( RArray<TInt>& aEntryIds, const TUid aModuleUid )
+    {
+    LOGSTRING("Creator: CCreatorEngine::WriteEntryIdsToStoreL");
+    CDictionaryFileStore* store = FileStoreLC();
+    User::LeaveIfNull( store );
+    
+    // backup previous ids from store
+    // otherwise they would be overwritten when calling out.WriteL
+    RArray<TInt> previousIds;
+    CleanupClosePushL( previousIds );
+    
+    if ( store->IsPresentL( aModuleUid ) )
+        {
+        RDictionaryReadStream in;
+        in.OpenLC( *store, aModuleUid );        
+        TInt err( KErrNone );
+        TInt id( KErrNotFound );
+        while ( !err ) 
+            {
+            TRAP( err, id = in.ReadInt32L() ); // will leave with KErrEof
+            if ( !err )
+                {
+                previousIds.Append( id );
+                }
+            }
+        CleanupStack::PopAndDestroy( &in );
+        }
+    
+    RDictionaryWriteStream out;       
+    out.AssignLC( *store, aModuleUid );
+    
+    // restore previous ids to store
+    for ( TInt i = 0; i < previousIds.Count(); i++ )
+        {
+        out.WriteInt32L( previousIds[i] );            
+        }
+
+    // write new ids to store
+    for ( TInt i = 0; i < aEntryIds.Count(); i++ )
+        {
+        out.WriteInt32L( aEntryIds[i] );        
+        }
+    
+    out.CommitL();
+    CleanupStack::PopAndDestroy( &out );
+    
+    store->CommitL();
+    CleanupStack::PopAndDestroy( &previousIds );
+    CleanupStack::PopAndDestroy( store );
+    }
+
+// ---------------------------------------------------------------------------
+void CCreatorEngine::ReadEntryIdsFromStoreL( RArray<TUint32>& aEntryIds, const TUid aModuleUid )
+    {
+    LOGSTRING("Creator: CCreatorEngine::ReadEntryIdsFromStoreL");
+    CDictionaryFileStore* store = FileStoreLC();
+    User::LeaveIfNull( store );
+    if ( store->IsPresentL( aModuleUid ) )
+        {
+        RDictionaryReadStream in;
+        in.OpenLC( *store, aModuleUid );
+        TFileName fullPath;
+        TInt err( KErrNone );
+        TUint32 id( KErrNone ); 
+        while ( !err )
+            {
+            TRAP( err, id = in.ReadUint32L() );  // will leave with KErrEof
+            if ( !err )
+                {
+                aEntryIds.Append( id );
+                }
+            }
+        CleanupStack::PopAndDestroy( &in );
+        }
+    CleanupStack::PopAndDestroy( store );
+    }
+
+// ---------------------------------------------------------------------------
+void CCreatorEngine::WriteEntryIdsToStoreL( RArray<TUint32>& aEntryIds, const TUid aModuleUid )
+    {
+    LOGSTRING("Creator: CCreatorEngine::WriteEntryIdsToStoreL");
+    CDictionaryFileStore* store = FileStoreLC();
+    User::LeaveIfNull( store );
+    
+    // backup previous ids from store
+    // otherwise they would be overwritten when calling out.WriteL
+    RArray<TUint32> previousIds;
+    CleanupClosePushL( previousIds );
+    
+    if ( store->IsPresentL( aModuleUid ) )
+        {
+        RDictionaryReadStream in;
+        in.OpenLC( *store, aModuleUid );
+        TInt err( KErrNone );
+        TUint32 id( KErrNone );
+        while ( !err ) 
+            {
+            TRAP( err, id = in.ReadUint32L() ); // will leave with KErrEof
+            if ( !err )
+                {
+                previousIds.Append( id );
+                }
+            }
+        CleanupStack::PopAndDestroy( &in );
+        }
+    
+    RDictionaryWriteStream out;       
+    out.AssignLC( *store, aModuleUid );
+    
+    // restore previous ids to store
+    for ( TInt i = 0; i < previousIds.Count(); i++ )
+        {
+        out.WriteUint32L( previousIds[i] );            
+        }
+
+    // write new ids to store
+    for ( TInt i = 0; i < aEntryIds.Count(); i++ )
+        {
+        out.WriteUint32L( aEntryIds[i] );        
+        }
+    
+    out.CommitL();
+    CleanupStack::PopAndDestroy( &out );
+    
+    store->CommitL();
+    CleanupStack::PopAndDestroy( &previousIds );
+    CleanupStack::PopAndDestroy( store );
+    }
+
+// ---------------------------------------------------------------------------
+void CCreatorEngine::RemoveStoreL( const TUid aModuleUid )
+    {
+    LOGSTRING("Creator: CCreatorEngine::RemoveStoreL");
+    CDictionaryFileStore* store = FileStoreLC();
+    User::LeaveIfNull( store );
+    if ( store->IsPresentL( aModuleUid ) )
+        {        
+        // entries of this module should be deleted by now,
+        // remove the Creator internal registry for this module
+        store->Remove( aModuleUid );
+        store->CommitL();
+        }
+    CleanupStack::PopAndDestroy( store );
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorEngine::GenerateSourceImageFileL(
+    const CCreatorEngine::TTestDataPath aFileType,
+    const TDesC& aFileName )
+    {
+    LOGSTRING("Creator: CCreatorEngine::GenerateSourceImageFileL");
+    
+    // Peek file size
+    RFile file;
+    TInt fileSize( 0 );
+    // Using png file as the source file
+    TFileName fileName = TestDataPathL( CCreatorEngine::EPNG_15kB );
+    User::LeaveIfError( file.Open( iEnv->FsSession(),
+                                   fileName,
+                                   EFileRead | EFileShareAny ) );
+    CleanupClosePushL( file );
+    User::LeaveIfError( file.Size( fileSize ) );
+    CleanupStack::PopAndDestroy( &file );
+    
+    // Using heap variables, because bitmaps 
+    // may reserve large amount of memory.
+    
+    // Read data from the file
+    RFileReadStream ws;    
+    User::LeaveIfError( ws.Open( iEnv->FsSession(),
+                                 fileName,
+                                 EFileStream | EFileRead | EFileShareAny ) );
+    CleanupClosePushL( ws );
+    delete iBitmapData;
+    iBitmapData = NULL;
+    iBitmapData = HBufC8::NewL( fileSize );
+    TPtr8 dataPtr = iBitmapData->Des();
+    ws.ReadL( dataPtr, fileSize );
+    CleanupStack::PopAndDestroy( &ws );
+       
+    // Create decoder for the data
+    delete iDecoder;
+    iDecoder = NULL;
+    iDecoder = CImageDecoder::DataNewL( iEnv->FsSession(), dataPtr );
+    iFrameinfo = iDecoder->FrameInfo();
+    
+    // Create bitmap handle for the source image
+    iBitmap = new (ELeave) CFbsBitmap();
+    User::LeaveIfError( iBitmap->Create( iFrameinfo.iFrameCoordsInPixels.Size(), EColor16M ) );
+    
+    // Convert the data from the file into bitmap format (inmemory)  
+    CAsyncWaiter* waiter = CAsyncWaiter::NewLC();
+    iDecoder->Convert( &waiter->iStatus, *iBitmap );
+    waiter->StartAndWait();
+    delete iDecoder;
+    iDecoder = NULL;
+    delete iBitmapData;
+    iBitmapData = NULL;
+    if ( iUserCancelled )
+        {
+        CancelComplete();
+        User::Leave( KErrCancel );
+        }
+    User::LeaveIfError( waiter->Result() );
+    
+    // Define the target dimensions and image quality
+    // so that the generated file size will match required size.
+    // Quality and scaling factors are defined experimentally.
+    delete iScaler;
+    iScaler = NULL;
+    iScaler = CBitmapScaler::NewL();
+    iScaledBitmap = new (ELeave) CFbsBitmap();
+    // use original size as base
+    TSize scaledSize( iFrameinfo.iFrameCoordsInPixels.Size() );
+    delete iFrameImageData;
+    iFrameImageData = NULL;
+    iFrameImageData = CFrameImageData::NewL();
+    TBuf8<64> mimeType;
+    TJpegImageData* jpegImageData( NULL );
+    TBmpImageData* bmpImageData( NULL );
+    switch ( aFileType )
+        {
+        case CCreatorEngine::EJPEG_25kB:
+            // QualityFactor = 93 and size factor = 2 -> 25kB jpeg file
+            mimeType.Copy( _L8("image/jpeg") );
+            jpegImageData = new (ELeave) TJpegImageData;
+            // Set some format specific data
+            jpegImageData->iSampleScheme = TJpegImageData::EColor444;
+            jpegImageData->iQualityFactor = 93; // 0..100
+            // ownership passed to iFrameImageData after AppendImageData
+            User::LeaveIfError( iFrameImageData->AppendImageData( jpegImageData ) );
+            scaledSize.iHeight *= 2;
+            scaledSize.iWidth *= 2;
+            break;
+        case CCreatorEngine::EJPEG_200kB:
+            {
+            mimeType.Copy( _L8("image/jpeg") );
+            jpegImageData = new (ELeave) TJpegImageData;
+            // Set some format specific data
+            jpegImageData->iSampleScheme = TJpegImageData::EColor444;
+#ifdef __WINS__
+            // QualityFactor = 95 and size factor = 7 -> 196kB jpeg file
+            jpegImageData->iQualityFactor = 95; // 0..100
+            scaledSize.iHeight *= 7;
+            scaledSize.iWidth *= 7;
+#else
+            // In hw the image compression seems to work
+            // more efficiently. Need to set greater values.
+            jpegImageData->iQualityFactor = 100; // 0..100
+            scaledSize.iHeight *= 7;
+            scaledSize.iWidth *= 7;
+            // 100, 7, 7 -> 213kB
+#endif
+            // ownership passed to iFrameImageData after AppendImageData
+            User::LeaveIfError( iFrameImageData->AppendImageData( jpegImageData ) );
+            break;
+            }
+        case CCreatorEngine::EJPEG_500kB:
+            {
+            mimeType.Copy( _L8("image/jpeg") );
+            jpegImageData = new (ELeave) TJpegImageData;
+            // Set some format specific data
+            jpegImageData->iSampleScheme = TJpegImageData::EColor444;
+#ifdef __WINS__
+            // QualityFactor = 99 and size factor = 8 -> 514kB jpeg file
+            jpegImageData->iQualityFactor = 99; // 0..100
+            scaledSize.iHeight *= 8;
+            scaledSize.iWidth *= 8;
+#else
+            // In hw the image compression seems to work
+            // more efficiently. Need to set greater values. 
+            jpegImageData->iQualityFactor = 100; // 0..100
+            scaledSize.iHeight *= 13;
+            scaledSize.iWidth *= 13;
+            // 100, 13, 13 -> 535kB
+#endif
+            // ownership passed to iFrameImageData after AppendImageData
+            User::LeaveIfError( iFrameImageData->AppendImageData( jpegImageData ) );
+            break;
+            }
+        case CCreatorEngine::EBMP_25kB:
+            {
+            // bit depyh 8 and 11/10 size factor -> 25kB bmp
+            mimeType.Copy( _L8("image/bmp") );
+            bmpImageData = new (ELeave) TBmpImageData;
+            bmpImageData->iBitsPerPixel = 8;
+            // ownership passed to iFrameImageData after AppendImageData
+            User::LeaveIfError( iFrameImageData->AppendImageData( bmpImageData ) );
+            scaledSize.iHeight *= 11;
+            scaledSize.iWidth *= 11;
+            scaledSize.iHeight /= 10;
+            scaledSize.iWidth /= 10;
+            break;
+            }
+        case CCreatorEngine::EGIF_2kB:
+            {
+            // size factor 1/2 -> 2560B gif
+            mimeType.Copy( _L8("image/gif") );
+            // GIF encoder is not configurable, only the size matters here
+            scaledSize.iHeight /= 2;
+            scaledSize.iWidth /= 2;
+            break;
+            }
+        default: break;
+        }
+
+    // Scale to reach target size
+    User::LeaveIfError( iScaledBitmap->Create( scaledSize, EColor16M ) );
+    iScaler->Scale( &waiter->iStatus, *iBitmap, *iScaledBitmap );
+    waiter->StartAndWait();
+    delete iBitmap;
+    iBitmap = NULL;
+    delete iScaler;
+    iScaler = NULL;
+    if ( iUserCancelled )
+        {
+        CancelComplete();
+        User::Leave( KErrCancel );
+        }
+    User::LeaveIfError( waiter->Result() );
+    
+    // Encode to target format
+    delete iEncoder;
+    iEncoder = NULL;
+    // Creating CImageEncoder opens the target file
+    iEncoder = CImageEncoder::FileNewL( iEnv->FsSession(), aFileName, mimeType );
+
+    // Do the conversion to target format, this will write to the file
+    iEncoder->Convert( &waiter->iStatus, *iScaledBitmap, iFrameImageData );
+    waiter->StartAndWait();
+    delete iEncoder;
+    iEncoder = NULL;
+    delete iFrameImageData;
+    iFrameImageData = NULL;
+    delete iScaledBitmap;
+    iScaledBitmap = NULL;
+    if ( iUserCancelled )
+        {
+        CancelComplete();
+        User::Leave( KErrCancel );
+        }
+    User::LeaveIfError( waiter->Result() );
+    CleanupStack::PopAndDestroy( waiter );
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorEngine::GenereteSourceTextFileL( const TDesC& aFileName, TInt aSize )
+    {
+    LOGSTRING("Creator: CCreatorEngine::GenereteSourceTextFileL");
+    RFile txtFile;
+    _LIT8( KTestContent, "Testing... ");
+    _LIT8( KTestContentCRLF, "\r\n");
+    txtFile.Create( iEnv->FsSession(),
+                    aFileName,
+                    EFileStreamText | EFileWrite | EFileShareAny );
+    CleanupClosePushL( txtFile );
+    for ( TInt i = 1; i*KTestContent().Length() < aSize; i++ )
+        {
+        User::LeaveIfError( txtFile.Write( KTestContent ) );
+        if ( !( i % 10 ) ) // linefeed for every 10th
+            {
+            User::LeaveIfError( txtFile.Write( KTestContentCRLF ) );
+            }
+        }
+    CleanupStack::PopAndDestroy( &txtFile );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_note.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,179 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include "creator_note.h" 
+#include "creator_traces.h"
+
+const TInt KCreatorDiskSpaceNeededForSingleDeletion( 8192 );
+_LIT( KCreatorNotepadFile, "c:Notepad.dat" );
+
+// @see \s60\app\organizer\notepad\notepad1\LibSrc\NpdCoreModel.cpp KSecureUid.Name()
+_LIT( KCreatorNotepadFormat, "SECURE[101F8878]" ); 
+_LIT( KCreatorNotepadDeleteAllSQL, "DELETE FROM Table1");
+
+//----------------------------------------------------------------------------
+
+CNotepadParameters::CNotepadParameters()
+    {
+    LOGSTRING("Creator: CNotepadParameters::CNotepadParameters");
+
+    iNoteText = HBufC::New(KNotepadFieldLength);
+    }
+
+CNotepadParameters::~CNotepadParameters()
+    {
+    LOGSTRING("Creator: CNotepadParameters::~CNotepadParameters");
+
+    delete iNoteText;
+    }
+
+//----------------------------------------------------------------------------
+
+CCreatorNotepad* CCreatorNotepad::NewL(CCreatorEngine* aEngine)
+    {
+    CCreatorNotepad* self = CCreatorNotepad::NewLC(aEngine);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CCreatorNotepad* CCreatorNotepad::NewLC(CCreatorEngine* aEngine)
+    {
+    CCreatorNotepad* self = new (ELeave) CCreatorNotepad;
+    CleanupStack::PushL(self);
+    self->ConstructL(aEngine);
+    return self;
+    }
+
+CCreatorNotepad::CCreatorNotepad() : iFs ( CEikonEnv::Static()->FsSession() )
+    {
+    }
+
+void CCreatorNotepad::ConstructL(CCreatorEngine* aEngine)
+    {
+    LOGSTRING("Creator: CCreatorNotepad::ConstructL");
+
+    iEngine = aEngine;
+
+    iNotepadApi = CNotepadApi::NewL();
+    }
+
+CCreatorNotepad::~CCreatorNotepad()
+    {
+    LOGSTRING("Creator: CCreatorNotepad::~CCreatorNotepad");
+    
+    delete iNotepadApi;
+    
+    if (iParameters)
+        delete iParameters;
+    }
+
+//----------------------------------------------------------------------------
+
+TBool CCreatorNotepad::AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries)
+    {
+    LOGSTRING("Creator: CCreatorNotepad::AskDataFromUserL");
+
+    if ( aCommand == ECmdDeleteNotes )
+        {
+        return iEngine->YesNoQueryDialogL( _L("Delete all Notes?") );
+        }
+    
+    // By Creator not supported because 
+    // note id is not available via Notepad API
+
+    return iEngine->EntriesQueryDialogL(aNumberOfEntries, _L("How many entries to create?"));
+    }
+
+
+//----------------------------------------------------------------------------
+
+TInt CCreatorNotepad::CreateNoteEntryL(CNotepadParameters *aParameters)
+    {
+    LOGSTRING("Creator: CCreatorNotepad::CreateNoteEntryL");
+
+    // clear any existing parameter definations
+    delete iParameters;
+    iParameters = NULL;
+    
+    CNotepadParameters* parameters = aParameters;
+    
+    // random data needed if no predefined data available
+    if (!parameters)
+        {
+        iParameters = new(ELeave) CNotepadParameters;
+        parameters = iParameters;
+        parameters->iNoteText->Des() = iEngine->RandomString(CCreatorEngine::EMessageText);
+        }
+    
+    TInt err = KErrNone;
+
+    iNotepadApi->AddContentL(parameters->iNoteText->Des());
+    
+    return err;
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorNotepad::DeleteAllL()
+    {
+    LOGSTRING("Creator: CCreatorNotepad::DeleteAllL");
+    // Open Notes db
+    RDbs dbs;
+    User::LeaveIfError( dbs.Connect() );
+    CleanupClosePushL( dbs );
+    RDbNamedDatabase db;
+    TInt openErr( db.Open( dbs, KCreatorNotepadFile, KCreatorNotepadFormat ) );
+    CleanupClosePushL( db );
+    
+    if ( openErr && openErr !=  KErrNotFound )
+        {
+        User::Leave( openErr );
+        }
+    
+    // do not leave if openErr == KErrNotFound, 
+    // it means there is no notes (file) created -> no need to delete
+    
+    if ( openErr !=  KErrNotFound )
+        {
+        TInt retval = iFs.ReserveDriveSpace( KDefaultDrive, KCreatorDiskSpaceNeededForSingleDeletion );
+        if ( retval == KErrNone )
+            {
+            retval = iFs.GetReserveAccess( KDefaultDrive );
+            }
+
+        // Delete all Notes. Ignore rowCount returnvalue
+        db.Execute( KCreatorNotepadDeleteAllSQL );            
+        
+        User::LeaveIfError( db.Compact() );
+        
+        if ( retval == KErrNone )
+            {
+            retval = iFs.ReleaseReserveAccess( KDefaultDrive );
+            }
+        }
+    
+    CleanupStack::PopAndDestroy( &db );
+    CleanupStack::PopAndDestroy( &dbs );
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorNotepad::DeleteAllCreatedByCreatorL()
+    {
+    LOGSTRING("Creator: CCreatorNotepad::DeleteAllCreatedByCreatorL");
+    // Not supported because note id is not available via Notepad API
+    User::Leave( KErrNotSupported );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_noteelement.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,107 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include "creator_noteelement.h"
+#include "creator_traces.h"
+#include "creator_note.h"
+
+using namespace creatornote;
+
+/*
+ * 
+ */
+CCreatorNoteElement* CCreatorNoteElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext )
+    {
+    CCreatorNoteElement* self = new (ELeave) CCreatorNoteElement(aEngine);
+    CleanupStack::PushL(self);
+    self->ConstructL(aName, aContext);
+    CleanupStack::Pop(self);
+    return self;
+    }
+/*
+ * 
+ */
+CCreatorNoteElement::CCreatorNoteElement(CCreatorEngine* aEngine) 
+: 
+CCreatorScriptElement(aEngine)
+    {
+    iIsCommandElement = ETrue;
+    }
+
+void CCreatorNoteElement::ExecuteCommandL()
+    {
+    const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount);
+    TInt noteAmount = 1;    
+    if( amountAttr )
+        {
+        noteAmount = ConvertStrToIntL(amountAttr->Value());
+        }
+    // Get 'fields' element 
+    CCreatorScriptElement* fieldsElement = FindSubElement(KFields);
+    if( fieldsElement && fieldsElement->SubElements().Count() > 0)
+        {
+        // Get sub-elements
+        const RPointerArray<CCreatorScriptElement>& fields = fieldsElement->SubElements();        
+        // Create note entries, the amount of entries is defined by noteAmount:
+        for( TInt cI = 0; cI < noteAmount; ++cI )
+            {            
+            CNotepadParameters* param = new (ELeave) CNotepadParameters;
+            CleanupStack::PushL(param);
+            
+            for( TInt i = 0; i < fields.Count(); ++i )
+                {
+                CCreatorScriptElement* field = fields[i];
+                TPtrC elemName = field->Name();
+                TPtrC elemContent = field->Content();
+                const CCreatorScriptAttribute* randomAttr = fields[i]->FindAttributeByName(KRandomLength);
+                TBool useMax = EFalse;
+                if( randomAttr && randomAttr->Value() == KMax )
+                    {
+                    useMax = ETrue;
+                    }
+                
+                if( elemName == KText )
+                    {
+                    if( randomAttr || elemContent.Length() == 0 )
+                        {
+                        if( useMax )
+                            {
+                            TDesC* temp = iEngine->CreateRandomStringLC(KNotepadFieldLength);                            
+                            SetContentToTextParamL(param->iNoteText, *temp);
+                            CleanupStack::PopAndDestroy(); // temp
+                            }
+                        else
+                            {
+                            SetContentToTextParamL(param->iNoteText, iEngine->RandomString(CCreatorEngine::EMessageText));
+                            }
+                        }
+                    else
+                        {
+                        SetContentToTextParamL(param->iNoteText, elemContent);
+                        }
+                    }
+                }
+            iEngine->AppendToCommandArrayL(ECmdCreateMiscEntryNotes, param);
+            CleanupStack::Pop(); // param
+            }
+        }
+    else
+    	{
+    	iEngine->AppendToCommandArrayL(ECmdCreateMiscEntryNotes, 0, noteAmount);
+    	}
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_phonebook.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,514 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#include "creator_phonebook.h" 
+#include "creator_traces.h"
+
+#include <cpbkcontactiter.h>
+
+//----------------------------------------------------------------------------
+
+CPhonebookParameters::CPhonebookParameters()
+    {
+    LOGSTRING("Creator: CPhonebookParameters::CPhonebookParameters");
+
+    iContactFirstName = HBufC::New(KPhonebookFieldLength);
+    iContactLastName = HBufC::New(KPhonebookFieldLength);
+    iContactCompanyName = HBufC::New(KPhonebookFieldLength);
+    iContactJobTitle = HBufC::New(KPhonebookFieldLength);
+    iContactPostalAddress = HBufC::New(KPhonebookFieldLength);
+    iWvUserId = HBufC::New(KPhonebookFieldLength);
+    iRingingtone = HBufC::New(KPhonebookFieldLength);
+    iThumbnailImage = HBufC::New(KPhonebookFieldLength);
+    iContactPhoneNumberGeneral = HBufC::New(KPhonebookFieldLength);
+    iContactURL = HBufC::New(KPhonebookFieldLength);
+    iContactEmailAddress = HBufC::New(KPhonebookFieldLength);
+    iGroupName = HBufC::New(KPhonebookFieldLength);
+    }
+
+CPhonebookParameters::~CPhonebookParameters()
+    {
+    LOGSTRING("Creator: CPhonebookParameters::~CPhonebookParameters");
+
+    delete iGroupName;
+    delete iContactEmailAddress;
+    delete iContactURL;
+    delete iContactPhoneNumberGeneral;
+    delete iThumbnailImage;
+    delete iRingingtone;
+    delete iWvUserId;
+    delete iContactPostalAddress;
+    delete iContactJobTitle;
+    delete iContactCompanyName;
+    delete iContactLastName;
+    delete iContactFirstName;
+    }
+void CPhonebookParameters::ParseL (CCommandParser* parser, TParseParams /*aCase = 0*/)
+	{
+	parser->StrParserL (iContactFirstName, '|');
+	parser->StrParserL (iContactLastName, '|');
+	parser->StrParserL (iContactCompanyName, '|');
+	parser->StrParserL (iContactJobTitle, '|');
+	parser->StrParserL (iContactPostalAddress, '|');
+	parser->StrParserL (iContactPhoneNumberGeneral, '|');
+	parser->StrParserL (iContactURL, '|');
+	parser->StrParserL (iContactEmailAddress, '|');
+	parser->StrParserL (iWvUserId, '|');
+	parser->StrParserL (iRingingtone, '|');
+	parser->StrParserL (iThumbnailImage, ';');
+	}
+//----------------------------------------------------------------------------
+
+CCreatorPhonebook* CCreatorPhonebook::NewL(CCreatorEngine* aEngine)
+    {
+    CCreatorPhonebook* self = CCreatorPhonebook::NewLC(aEngine);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CCreatorPhonebook* CCreatorPhonebook::NewLC(CCreatorEngine* aEngine)
+    {
+    CCreatorPhonebook* self = new (ELeave) CCreatorPhonebook;
+    CleanupStack::PushL(self);
+    self->ConstructL(aEngine);
+    return self;
+    }
+
+CCreatorPhonebook::CCreatorPhonebook()
+    {
+    }
+
+void CCreatorPhonebook::ConstructL(CCreatorEngine* aEngine)
+    {
+    LOGSTRING("Creator: CCreatorPhonebook::ConstructL");
+
+    iEngine = aEngine;  
+    iContactDBEngine = CPbkContactEngine::NewL();
+    iOpCounter = 0;
+    SetDefaultParameters();
+    }
+
+CCreatorPhonebook::~CCreatorPhonebook()
+    {
+    LOGSTRING("Creator: CCreatorPhonebook::~CCreatorPhonebook");
+
+    if ( iEngine && iContactIds.Count() )
+        {
+        TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iContactIds, KUidDictionaryUidContacts ) );
+        }
+    iContactIds.Reset();
+    iContactIds.Close();
+
+    if ( iEngine && iGroupIds.Count() )
+        {
+        TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iGroupIds, KUidDictionaryUidContactGroups ) );
+        }
+    iGroupIds.Reset();
+    iGroupIds.Close();
+       
+    iEntriesToDelete.Reset();
+    iEntriesToDelete.Close();
+    
+    CompactPbkDatabase( ETrue );
+
+    delete iContactDBEngine;
+
+    if (iParameters)
+        delete iParameters;
+    }
+
+//----------------------------------------------------------------------------
+TInt CCreatorPhonebook::CreateContactEntryL(CCreatorModuleBaseParameters *aParameters)
+    {
+    LOGSTRING("Creator: CCreatorPhonebook::CreateContactEntryL");
+    
+    delete iParameters;
+    iParameters = 0;
+    
+    CPhonebookParameters* parameters = (CPhonebookParameters*) aParameters;
+    
+    // random data needed if no predefined data available
+    if (!parameters)
+        {
+        iParameters = new(ELeave) CPhonebookParameters;
+        
+        iParameters->iNumberOfPhoneNumberFields = iNumberOfPhoneNumberFields;
+        iParameters->iNumberOfURLFields = iNumberOfURLFields;
+        iParameters->iNumberOfEmailAddressFields = iNumberOfEmailAddressFields;        
+        
+        iParameters->iNumberOfPhoneNumberFields = iNumberOfPhoneNumberFields;
+        iParameters->iNumberOfURLFields = iNumberOfURLFields;
+        iParameters->iNumberOfEmailAddressFields = iNumberOfEmailAddressFields;
+        
+        iParameters->iContactFirstName->Des() = iEngine->RandomString(CCreatorEngine::EFirstName);
+        iParameters->iContactLastName->Des() = iEngine->RandomString(CCreatorEngine::ESurname);
+        iParameters->iContactCompanyName->Des() = iEngine->RandomString(CCreatorEngine::ECompany);
+        iParameters->iContactJobTitle->Des() = iEngine->RandomString(CCreatorEngine::EJobTitle);
+        iParameters->iContactPostalAddress->Des() = iEngine->RandomString(CCreatorEngine::EAddress);
+        
+        iParameters->iWvUserId->Des().Copy(_L("wv:"));
+        iParameters->iWvUserId->Des().Append(iParameters->iContactFirstName->Des());
+
+        // TO-DO.....
+        //iParameters->iRingingtone->Des() = KNullDesC;
+        //iParameters->iThumbnailImage->Des() = KNullDesC;
+
+        iParameters->iContactPhoneNumberGeneral->Des() = iEngine->RandomString(CCreatorEngine::EPhoneNumber);
+  
+        iParameters->iContactURL->Des().Copy( _L("http://www.") );
+        iParameters->iContactURL->Des().Append( iParameters->iContactCompanyName->Des() );
+        iParameters->iContactURL->Des().Append( _L(".com/") );
+
+        iParameters->iContactEmailAddress->Des().Copy( iParameters->iContactFirstName->Des() );
+        iParameters->iContactEmailAddress->Des().Append( _L("@") );
+        iParameters->iContactEmailAddress->Des().Append( iParameters->iContactCompanyName->Des() );
+        iParameters->iContactEmailAddress->Des().Append( _L(".com") );
+
+        }
+    else
+        {
+        iParameters = parameters;
+        }
+
+    TInt err = KErrNone;
+
+    // create a new contact item based on the default template
+	CPbkContactItem* newContact = iContactDBEngine->CreateEmptyContactL();
+	CleanupStack::PushL(newContact);
+
+    AddFieldToContactItemL (*newContact, EPbkFieldIdFirstName, iParameters->iContactFirstName->Des());
+    AddFieldToContactItemL (*newContact, EPbkFieldIdLastName, iParameters->iContactLastName->Des());
+    AddFieldToContactItemL (*newContact, EPbkFieldIdCompanyName, iParameters->iContactCompanyName->Des());
+    AddFieldToContactItemL (*newContact, EPbkFieldIdJobTitle, iParameters->iContactJobTitle->Des());
+    AddFieldToContactItemL (*newContact, EPbkFieldIdPostalAddress, iParameters->iContactPostalAddress->Des());
+    
+    AddFieldToContactItemL (*newContact, EPbkFieldIdWVID, iParameters->iWvUserId->Des());
+    AddFieldToContactItemL (*newContact, EPbkFieldIdPersonalRingingToneIndication, iParameters->iRingingtone->Des());
+    AddFieldToContactItemL (*newContact, EPbkFieldIdThumbnailImage, iParameters->iThumbnailImage->Des());
+
+    for (TInt i=0; i<iParameters->iNumberOfPhoneNumberFields; i++)
+        {
+        if (i%6 == 0)
+            AddFieldToContactItemL (*newContact, EPbkFieldIdPhoneNumberGeneral, iParameters->iContactPhoneNumberGeneral->Des());
+        else if (i%6 == 1)
+            AddFieldToContactItemL (*newContact, EPbkFieldIdPhoneNumberMobile, iParameters->iContactPhoneNumberGeneral->Des());
+        else if (i%6 == 2)
+            AddFieldToContactItemL (*newContact, EPbkFieldIdFaxNumber, iParameters->iContactPhoneNumberGeneral->Des());
+        else if (i%6 == 3)
+            AddFieldToContactItemL (*newContact, EPbkFieldIdPagerNumber, iParameters->iContactPhoneNumberGeneral->Des());
+        else if (i%6 == 4)
+            AddFieldToContactItemL (*newContact, EPbkFieldIdPhoneNumberHome, iParameters->iContactPhoneNumberGeneral->Des());
+        else 
+            AddFieldToContactItemL (*newContact, EPbkFieldIdPhoneNumberWork, iParameters->iContactPhoneNumberGeneral->Des());
+        }
+
+    for (TInt j=0; j<iParameters->iNumberOfURLFields; j++)
+        AddFieldToContactItemL (*newContact, EPbkFieldIdURL, iParameters->iContactURL->Des());
+
+    for (TInt k=0; k<iParameters->iNumberOfEmailAddressFields; k++)
+        AddFieldToContactItemL (*newContact, EPbkFieldIdEmailAddress, iParameters->iContactEmailAddress->Des());
+
+
+    // add the contact item to the database
+	iContactDBEngine->AddNewContactL(*newContact);
+
+    // id has been generated, store it for being able to delete
+    // entries created only with Creator
+	iContactIds.Append( newContact->Id() );
+
+	CleanupStack::PopAndDestroy(); // newContact
+
+    CompactPbkDatabase();
+
+    return err;
+    }
+
+//----------------------------------------------------------------------------
+
+TInt CCreatorPhonebook::CreateGroupEntryL(CCreatorModuleBaseParameters *aParameters) 
+    { 
+    LOGSTRING("Creator: CCreatorPhonebook::CreateGroupEntryL"); 
+
+    // clear any existing parameter definations 
+    if (iParameters) 
+        { 
+        delete iParameters; 
+        iParameters = NULL; 
+        } 
+        
+    // random data needed if no predefined data available 
+    if (!aParameters) 
+        { 
+        iParameters = new(ELeave) CPhonebookParameters; 
+        
+        iParameters->iContactsInGroup = iContactsInGroup; 
+
+        iParameters->iGroupName->Des().Copy( iEngine->RandomString(CCreatorEngine::EGroupName) ); 
+        iParameters->iGroupName->Des().Append( _L(" #") ); 
+        iParameters->iGroupName->Des().AppendNum( iEngine->RandomNumber(1000, 9999) ); 
+        } 
+    else 
+        { 
+        // otherwise replace the parameters object 
+        iParameters = (CPhonebookParameters*) aParameters; 
+        } 
+
+    TInt err(KErrNone); 
+
+    // create contact iterator 
+    CPbkContactIter* contactIter = iContactDBEngine->CreateContactIteratorLC(); 
+    
+    // create contact id array 
+    CContactIdArray* contactIdArray = CContactIdArray::NewLC();  
+
+    // get all contacts    
+    TBool getFirstContact(ETrue); 
+    TContactItemId contactId; 
+    
+    for (;;) 
+        { 
+        if (getFirstContact) 
+            { 
+            // get first contact 
+            contactId = contactIter->FirstL(); 
+            getFirstContact = EFalse; 
+            } 
+        else 
+            { 
+            // get next contact 
+            contactId = contactIter->NextL(); 
+            } 
+        
+        // check if valid contact id received 
+        if (contactId == KNullContactId) 
+            { 
+            // no more contacts, so break 
+            break; 
+            } 
+        else 
+            { 
+            // append to array 
+            contactIdArray->AddL(contactId); 
+            }    
+        } 
+
+    // create a new contact group 
+    CContactGroup* newGroup = iContactDBEngine->CreateContactGroupL( iParameters->iGroupName->Des() ); 
+    CleanupStack::PushL(newGroup); 
+
+    // define amounts of contacts to be added to the group 
+    TInt amountOfContactsToBeAdded; 
+    if (iParameters->iContactsInGroup == KCreateRandomAmountOfGroups) 
+        amountOfContactsToBeAdded = iEngine->RandomNumber(30); 
+    else     
+        amountOfContactsToBeAdded = iParameters->iContactsInGroup; 
+    
+    
+    // a simple way to randomise order of contacts in the array 
+    if (iEngine->RandomNumber(1, 2) == 1) 
+        contactIdArray->ReverseOrder(); 
+    
+    // assign contacts from the array to the group if any contacts available        
+    if (contactIdArray->Count() > 0) 
+        { 
+        // get random start number which defines from which position to start adding contacts 
+        TInt arrayPosCounter = iEngine->RandomNumber(contactIdArray->Count()-1); 
+        TInt addedContacsCounter(0); 
+    
+        for (TInt y=0; y<amountOfContactsToBeAdded; y++) 
+            { 
+            // add contact to group 
+            iContactDBEngine->AddContactToGroupL((*contactIdArray)[arrayPosCounter], newGroup->Id()); 
+            addedContacsCounter++; 
+            arrayPosCounter++; 
+            
+            // no need to add more contacts than actually available 
+            if (addedContacsCounter >= contactIdArray->Count()) 
+                break; 
+
+            // if limit reached, start from the beginning 
+            if (arrayPosCounter >= contactIdArray->Count()) 
+                arrayPosCounter = 0; 
+            } 
+        }
+    
+    // id has been generated, store it for being able to delete
+    // entries created only with Creator
+    iGroupIds.Append( newGroup->Id() );
+    
+    CleanupStack::PopAndDestroy(3); // newGroup, contactIdArray, contactIter 
+
+    CompactPbkDatabase(); 
+
+    return err; 
+    } 
+
+
+//----------------------------------------------------------------------------
+
+TInt CCreatorPhonebook::CreateSubscribedContactEntryL(CCreatorModuleBaseParameters* /*aParameters*/)
+    {
+    LOGSTRING("Creator: CCreatorPhonebook::CreateSubscribedContactEntryL");
+
+    return KErrNotSupported;
+    }
+
+//----------------------------------------------------------------------------
+
+void CCreatorPhonebook::AddFieldToContactItemL(CPbkContactItem& aItem, TPbkFieldId aFieldId, const TDesC& aFieldText)
+	{
+    //LOGSTRING("Creator: CCreatorPhonebook::AddFieldToContactItemL");
+
+    CPbkFieldInfo* fieldInfo = iContactDBEngine->FieldsInfo().Find( aFieldId );
+    if( fieldInfo ) // field was found
+        {
+        // add the field and value to contact
+        TPbkContactItemField* itemField = aItem.AddOrReturnUnusedFieldL( *fieldInfo );
+
+        if( itemField && aFieldText.Length() > 0 ) // add text also
+            {
+            if( itemField->ItemField().StorageType() == KStorageTypeText )
+                {
+		        CContactTextField* textField = itemField->ItemField().TextStorage();
+                
+                // clip the text if it doesn't fit to the field
+	            textField->SetTextL( aFieldText.Left( fieldInfo->MaxLength() ) );
+	    	    }
+    		}
+        }
+    }
+
+//----------------------------------------------------------------------------
+
+void CCreatorPhonebook::CompactPbkDatabase(TBool aCompressImmediately)
+    {
+    LOGSTRING("Creator: CCreatorPhonebook::CompactPbkDatabase");
+
+    iOpCounter++;
+
+    // compress the database immediately or after each 100th operation
+    if (aCompressImmediately || iOpCounter%100 == 0)
+        {
+        CContactDatabase& db = iContactDBEngine->Database();
+
+        if (db.CompressRequired())
+            {
+            LOGSTRING("Creator: CCreatorPhonebook::CompactPbkDatabase - Compacting...");
+            TRAP_IGNORE( db.CompactL() );
+            }
+        }
+    }
+//----------------------------------------------------------------------------
+void CCreatorPhonebook::DeleteAllL()
+    {
+    LOGSTRING("Creator: CCreatorPhonebook::DeleteAllL");
+    DeleteAllItemsL( KUidDictionaryUidContacts );
+    iContactIds.Reset();
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorPhonebook::DeleteAllCreatedByCreatorL()
+    {
+    LOGSTRING("Creator: CCreatorPhonebook::DeleteAllCreatedByCreatorL");
+    DeleteItemsCreatedWithCreatorL( KUidDictionaryUidContacts );
+    iContactIds.Reset();
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorPhonebook::DeleteAllGroupsL()
+    {
+    LOGSTRING("Creator: CCreatorPhonebook::DeleteAllGroupsL");
+    DeleteAllItemsL( KUidDictionaryUidContactGroups );
+    iGroupIds.Reset();
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorPhonebook::DeleteAllGroupsCreatedByCreatorL()
+    {
+    LOGSTRING("Creator: CCreatorPhonebook::DeleteAllGroupsCreatedByCreatorL");
+    DeleteItemsCreatedWithCreatorL( KUidDictionaryUidContactGroups );
+    iGroupIds.Reset();
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorPhonebook::DeleteAllItemsL( TUid aStoreUid )
+    {
+    LOGSTRING("Creator: CCreatorPhonebook::DeleteItemsL");
+    __ASSERT_ALWAYS( aStoreUid == KUidDictionaryUidContacts || 
+                     aStoreUid == KUidDictionaryUidContactGroups,
+                     User::Panic( _L("CCreatorPb"), KErrArgument ) );
+    
+    CContactIdArray* allContacts = iContactDBEngine->FindLC( _L("") );
+    
+    CPbkContactItem* item;
+    TInt i(0);
+    // remove that type of item ids from the array
+    // that we don't want to delete
+    while( allContacts && i < allContacts->Count() )
+        {
+        item = iContactDBEngine->ReadContactL( (*allContacts)[i] );
+        if ( ( aStoreUid == KUidDictionaryUidContactGroups ) == 
+             ( item->Type() != KUidContactGroup ) )
+            {
+            allContacts->Remove( i );
+            }
+        else
+            {
+            i++;
+            }
+        delete item;
+        item = NULL;
+        }
+    iContactDBEngine->DeleteContactsL( *allContacts );
+    CleanupStack::PopAndDestroy( allContacts );
+
+    // contacts deleted, remove the store
+    CDictionaryFileStore* store = iEngine->FileStoreLC();
+    if ( store )
+        {
+        store->Remove( aStoreUid );
+        store->CommitL();        
+        }
+    CleanupStack::PopAndDestroy( store );
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorPhonebook::DeleteItemsCreatedWithCreatorL( TUid aStoreUid )
+    {
+    LOGSTRING("Creator: CCreatorPhonebook::DeleteItemsCreatedWithCreatorL");
+    __ASSERT_ALWAYS( aStoreUid == KUidDictionaryUidContacts || 
+                     aStoreUid == KUidDictionaryUidContactGroups,
+                     User::Panic( _L("CCreatorPb"), KErrArgument ) );
+    
+    iEntriesToDelete.Reset();
+    
+    // fetch ids of entries created by Creator
+    iEngine->ReadEntryIdsFromStoreL( iEntriesToDelete, aStoreUid );
+    
+    // delete entries
+    for ( TInt i = 0; i < iEntriesToDelete.Count(); i++ )
+        {
+        TRAP_IGNORE( iContactDBEngine->DeleteContactL( iEntriesToDelete[i] ) );
+        }
+    
+    iEntriesToDelete.Reset();
+    
+    // all entries deleted, remove the Logs related registry
+    iEngine->RemoveStoreL( aStoreUid );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_phonebookbase.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,119 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include "creator_phonebookbase.h"
+#include "creator_model.h"
+#include "creator_traces.h"
+
+TBool CCreatorPhonebookBase::AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries)
+    {
+    LOGSTRING("Creator: CCreatorPhonebook::AskDataFromUserL");
+    
+    if( aCommand == ECmdDeleteContacts )
+        {
+        return iEngine->YesNoQueryDialogL(_L("Delete all contacts?") );
+        }
+    if( aCommand == ECmdDeleteCreatorContacts )
+        {
+        return iEngine->YesNoQueryDialogL(_L("Delete all contacts created with Creator?") ); 
+        }
+    if( aCommand == ECmdDeleteContactGroups )
+        {
+        return iEngine->YesNoQueryDialogL(_L("Delete all contact groups?") );
+        }
+    if( aCommand == ECmdDeleteCreatorContactGroups )
+        {
+        return iEngine->YesNoQueryDialogL(_L("Delete all contact groups created with Creator?") ); 
+        }    
+    // display queries
+    if (iEngine->EntriesQueryDialogL(aNumberOfEntries, _L("How many entries to create?"))) // ask number of entries to create
+        {
+        if (aCommand == ECmdCreatePhoneBookEntryContacts)
+            {
+            TInt index = 0;
+            CAknListQueryDialog* dlg1 = new(ELeave) CAknListQueryDialog(&index);
+            if (dlg1->ExecuteLD(R_CONTACT_CREATION_TYPE_QUERY))
+                {
+                if (index == 0) //first item
+                    {
+                    iDefaultFieldsSelected = ETrue;
+                    return ETrue;    
+                    }
+                else  // detailed mode selected
+                    {
+                    iDefaultFieldsSelected = EFalse;
+                    if (iEngine->EntriesQueryDialogL(iNumberOfPhoneNumberFields, _L("Amount of phone number fields in one contact?"), ETrue))
+                        {
+                        if (iEngine->EntriesQueryDialogL(iNumberOfURLFields, _L("Amount of URL fields in one contact?"), ETrue))
+                            {
+                            if (iEngine->EntriesQueryDialogL(iNumberOfEmailAddressFields, _L("Amount of email fields in one contact?"), ETrue))
+                                {                                
+                                return ETrue;
+                                }
+                            else
+                                return EFalse;
+                            }
+                            else
+                                return EFalse;
+                        }
+                    else
+                        return EFalse;
+                    }
+                }
+            else
+                return EFalse;
+            }
+        else if (aCommand == ECmdCreatePhoneBookEntryGroups)
+            {
+            TInt index = 0;
+            CAknListQueryDialog* dlg1 = new(ELeave) CAknListQueryDialog(&index);
+            if (dlg1->ExecuteLD(R_GROUP_CREATION_TYPE_QUERY))
+                {
+                if (index == 0) //first item
+                    {
+                    iContactsInGroup = KCreateRandomAmountOfGroups;
+                    return ETrue;
+                    }
+                else
+                    {
+                    if (iEngine->EntriesQueryDialogL(iContactsInGroup, _L("Amount of contacts in one group?"), ETrue))
+                        {
+                        return ETrue;
+                        }
+                    else
+                        return EFalse;
+                    }
+                }
+            else
+                return EFalse;
+            }
+        else
+            return ETrue;
+        }
+    else
+        return EFalse;
+    }
+
+void CCreatorPhonebookBase::SetDefaultParameters()
+    {
+    iNumberOfPhoneNumberFields = 1;
+    iNumberOfURLFields = 0;
+    iNumberOfEmailAddressFields = 0;
+    iContactsInGroup = 50;
+    iDefaultFieldsSelected = EFalse;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_randomdataparser.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,324 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include <f32file.h>
+#include <utf.h>
+#include <xml/documentparameters.h>
+#include "creator_randomdataparser.h"
+#include "creator_traces.h"
+
+// XML element names
+_LIT(KRootElement, "creatordata");
+_LIT(KFirstName, "firstname");
+_LIT(KSurname, "surname");
+_LIT(KCompany, "company");
+_LIT(KAddress, "address");
+_LIT(KJobTitle, "jobtitle");
+_LIT(KPhoneNumber, "phonenumber");
+_LIT(KGroupName, "groupname");
+_LIT(KMeetingReason, "meetingreason");
+_LIT(KMeetingPlace, "meetingplace");
+_LIT(KMemoText, "memo");
+_LIT(KAnniversaryReason, "anniversary");
+_LIT(KToDoText, "todo");
+_LIT(KReminderText, "reminder");
+_LIT(KMessageSubject, "messagesubject");
+_LIT(KMessageText, "messagetext");
+_LIT(KCity, "city");
+_LIT(KCountry, "country");
+_LIT(KPostcode, "postcode");
+_LIT(KState, "state");
+_LIT(KPobox, "pobox");
+_LIT(KPrefix, "prefix");
+_LIT(KSuffix, "suffix");
+_LIT(KLandmarkName, "landmarkname");
+_LIT(KLandmarkDescription, "landmarkdescription");
+
+using namespace Xml;
+
+CCreatorRandomDataParser::CCreatorRandomDataParser() 
+    {        
+    }
+
+void CCreatorRandomDataParser::ConstructL()
+    {
+    LOGSTRING("Creator: CCreatorRandomDataParser::ConstructL");
+	iElementNameArray = new (ELeave) CDesCArrayFlat(32);
+	iElementNameArray->InsertL(EFirstName, KFirstName);
+	iElementNameArray->InsertL(ESurname, KSurname);
+	iElementNameArray->InsertL(ECompany, KCompany);
+	iElementNameArray->InsertL(EAddress, KAddress);
+	iElementNameArray->InsertL(EJobTitle, KJobTitle);
+	iElementNameArray->InsertL(EPhoneNumber, KPhoneNumber);
+	iElementNameArray->InsertL(EGroupName, KGroupName);
+	iElementNameArray->InsertL(EMeetingReason, KMeetingReason);
+	iElementNameArray->InsertL(EMeetingPlace, KMeetingPlace);
+	iElementNameArray->InsertL(EMemoText, KMemoText);
+	iElementNameArray->InsertL(EAnniversaryReason, KAnniversaryReason);
+	iElementNameArray->InsertL(EToDoText, KToDoText);
+	iElementNameArray->InsertL(EReminderText, KReminderText);
+	iElementNameArray->InsertL(EMessageSubject, KMessageSubject);
+	iElementNameArray->InsertL(EMessageText, KMessageText);
+	iElementNameArray->InsertL(ECity, KCity);
+	iElementNameArray->InsertL(ECountry, KCountry);
+	iElementNameArray->InsertL(EPostcode, KPostcode);
+	iElementNameArray->InsertL(EState, KState);
+	iElementNameArray->InsertL(EPobox, KPobox);
+	iElementNameArray->InsertL(EPrefix, KPrefix);
+	iElementNameArray->InsertL(ESuffix, KSuffix);
+	iElementNameArray->InsertL(ELandmarkName, KLandmarkName);
+	iElementNameArray->InsertL(ELandmarkDescription, KLandmarkDescription);
+	iContentData = HBufC::NewL(16);
+    iResultArray = new (ELeave) CDesCArrayFlat(16);
+    }
+
+CCreatorRandomDataParser* CCreatorRandomDataParser::NewL()
+    {
+    LOGSTRING("Creator: CCreatorRandomDataParser::NewL");
+    CCreatorRandomDataParser* self = CCreatorRandomDataParser::NewLC();    
+    CleanupStack::Pop();
+    return self;
+    }
+
+CCreatorRandomDataParser* CCreatorRandomDataParser::NewLC()
+    {
+    LOGSTRING("Creator: CCreatorRandomDataParser::NewLC");
+    CCreatorRandomDataParser* self = new (ELeave) CCreatorRandomDataParser;
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+CCreatorRandomDataParser::~CCreatorRandomDataParser()
+    {
+    delete iParser;
+    delete iResultArray;
+    delete iContentData;
+    delete iElementNameArray;
+    }
+
+void CCreatorRandomDataParser::GetTextFileMode(RFile& aFile, TInt& aFileSize) 
+    { 
+    LOGSTRING("Creator: CCreatorRandomDataParser::GetTextFileMode");
+    iScriptTextFormat = EFormatANSIASCII; 
+
+    // if we are working with text files, check the type first   
+    TBuf8<4> BOM; 
+
+    // first check for UTF-16 
+    if (aFileSize >= 2 && aFile.Read(0, BOM, 2) == KErrNone) 
+        { 
+        if (BOM.Length()==2 && BOM[0]==0xFF && BOM[1]==0xFE) 
+            { 
+            iScriptTextFormat = EFormatUTF16LE; 
+            aFileSize -= 2; 
+            return; 
+            } 
+        else if (BOM.Length()==2 && BOM[0]==0xFE && BOM[1]==0xFF) 
+            { 
+            iScriptTextFormat = EFormatUTF16BE; 
+            aFileSize -= 2; 
+            return;                 
+            }       
+        }
+        // then check for UTF-8 
+    if (aFileSize >= 3 && aFile.Read(0, BOM, 3) == KErrNone) 
+        { 
+        if (BOM.Length()==3 && BOM[0]==0xEF && BOM[1]==0xBB && BOM[2]==0xBF) 
+            { 
+            iScriptTextFormat = EFormatUTF8; 
+            aFileSize -= 3; 
+            return; 
+            } 
+        }
+        
+    // none of those, seek back to beginning 
+    TInt pos(0); 
+    aFile.Seek(ESeekStart, pos); 
+    }    
+ 
+
+
+CDesCArrayFlat* CCreatorRandomDataParser::ParseL(const TDesC& aFileName, const TRandomDataType aDataType)
+    {
+    LOGSTRING2("Creator: CCreatorRandomDataParser::ParseL: %S", &aFileName);
+    
+    iDataType = aDataType;
+    
+    // Create and start XML-parser
+    if( iParser == 0)
+        {
+        _LIT8(KXmlMimeType, "text/xml");
+        iParser = CParser::NewL(KXmlMimeType, *this);        
+        }
+
+    RFs filesession;
+    CleanupClosePushL(filesession);
+    User::LeaveIfError( filesession.Connect() );
+    
+    iResultArray->Reset();
+    
+    Xml::ParseL(*iParser, filesession, aFileName);
+    
+    CleanupStack::PopAndDestroy(&filesession); // filesession 
+    
+    CDesCArrayFlat* tempArray = new (ELeave) CDesCArrayFlat(8);
+    CleanupStack::PushL(tempArray);
+    for (TInt i = 0; i < iResultArray->MdcaCount(); i++)
+    	{
+    	tempArray->AppendL(iResultArray->MdcaPoint(i));
+    	}
+    CleanupStack::Pop(tempArray);
+    return tempArray;
+    }
+
+void CCreatorRandomDataParser::OnStartDocumentL(const Xml::RDocumentParameters& /*aDocParam*/, TInt aErrorCode)
+    {
+    LOGSTRING2("Creator: CCreatorRandomDataParser::OnStartDocumentL (Error code: %d)", aErrorCode);
+    User::LeaveIfError(aErrorCode);    
+    iInsideRootElement = EFalse;
+	iContentParsingActive = EFalse;
+    }
+
+void CCreatorRandomDataParser::OnEndDocumentL(TInt aErrorCode)
+    {
+    LOGSTRING2("Creator: CCreatorRandomDataParser::OnEndDocumentL (Error code: %d)", aErrorCode);
+    User::LeaveIfError(aErrorCode);
+    }
+
+void CCreatorRandomDataParser::OnStartPrefixMappingL(const RString& /*aPrefix*/, 
+                                                     const RString& /*aUri*/, 
+                                                     TInt aErrorCode)
+    {
+    LOGSTRING2("Creator: CCreatorRandomDataParser::OnStartPrefixMappingL (Error code: %d)", aErrorCode);
+    User::LeaveIfError(aErrorCode);
+    }
+
+void CCreatorRandomDataParser::OnEndPrefixMappingL(const RString& /*aPrefix*/, TInt aErrorCode)
+    {
+    LOGSTRING2("Creator: CCreatorRandomDataParser::OnEndPrefixMappingL (Error code: %d)", aErrorCode);
+    User::LeaveIfError(aErrorCode);
+    }
+
+void CCreatorRandomDataParser::OnIgnorableWhiteSpaceL(const TDesC8& /*aBytes*/, TInt aErrorCode)
+    {
+    LOGSTRING2("Creator: CCreatorRandomDataParser::OnIgnorableWhiteSpaceL (Error code: %d)", aErrorCode);
+    User::LeaveIfError(aErrorCode);
+    }
+
+void CCreatorRandomDataParser::OnSkippedEntityL(const RString& /*aName*/, TInt aErrorCode)
+    {
+    LOGSTRING2("Creator: CCreatorRandomDataParser::OnSkippedEntityL (Error code: %d)", aErrorCode);
+    User::LeaveIfError(aErrorCode);
+    }
+
+void CCreatorRandomDataParser::OnProcessingInstructionL(const TDesC8& /*aTarget*/, 
+                                                        const TDesC8& /*aData*/, 
+                                                        TInt aErrorCode)
+    {
+    LOGSTRING2("Creator: CCreatorRandomDataParser::OnProcessingInstructionL (Error code: %d)", aErrorCode);
+    User::LeaveIfError(aErrorCode);
+    }
+
+void CCreatorRandomDataParser::OnError(TInt aErrorCode)
+    {
+    LOGSTRING2("Creator: CCreatorRandomDataParser::OnError: %d", aErrorCode);
+    
+    iLastError = aErrorCode;
+    }
+
+TAny* CCreatorRandomDataParser::GetExtendedInterface(const TInt32 aUid)
+    {
+    LOGSTRING2("Creator: CCreatorRandomDataParser::GetExtendedInterface (UID: %d)", aUid);
+    return this;
+    }
+
+void CCreatorRandomDataParser::OnStartElementL(const Xml::RTagInfo& aElement,
+                                               const Xml::RAttributeArray& /*aAttributes*/,
+                                               TInt aErrorCode)
+    {
+    LOGSTRING2("Creator: CCreatorRandomDataParser::OnStartElementL (Error code: %d)", aErrorCode);
+    User::LeaveIfError(aErrorCode);
+
+    const TDesC8& elementName8 = aElement.LocalName().DesC();        
+    HBufC* elementName16 = Convert8BitTo16BitLC(elementName8);
+    if (iInsideRootElement || (elementName16->Des() == KRootElement))
+    	{
+    	iInsideRootElement = ETrue;
+    	}
+    if (iInsideRootElement && (elementName16->Des() == iElementNameArray->MdcaPoint(iDataType)))
+    	{
+        iContentParsingActive = ETrue;
+        iContentData->Des().Zero();
+    	}
+    CleanupStack::PopAndDestroy(elementName16);
+    }
+
+void CCreatorRandomDataParser::OnEndElementL(const Xml::RTagInfo& aElement, TInt aErrorCode)
+    {
+    LOGSTRING2("Creator: CCreatorRandomDataParser::OnEndElementL (Error code: %d)", aErrorCode);
+    User::LeaveIfError(aErrorCode);
+
+    const TDesC8& elementName8 = aElement.LocalName().DesC();
+    HBufC* elementName16 = Convert8BitTo16BitLC(elementName8);
+    if (!iInsideRootElement || (elementName16->Des() == KRootElement))
+    	{
+    	iInsideRootElement = EFalse;
+    	}
+    CleanupStack::PopAndDestroy(elementName16);
+
+    if (iContentParsingActive)
+		{
+	    if (iContentData->Des().Length() > 0)
+	    	{
+	    	iResultArray->AppendL(*iContentData);
+	    	}
+        iContentParsingActive = EFalse;
+		}
+    }
+
+void CCreatorRandomDataParser::OnContentL(const TDesC8& aBytes, TInt aErrorCode)
+    {
+    LOGSTRING2("Creator: CCreatorRandomDataParser::OnContentL (Error code: %d)", aErrorCode);
+    User::LeaveIfError(aErrorCode);
+    
+    if (iContentParsingActive)
+    	{
+        HBufC* data16 = Convert8BitTo16BitLC(aBytes);
+        TInt newLen = iContentData->Des().Length() + data16->Des().Length();
+        iContentData = iContentData->ReAllocL(newLen);
+        iContentData->Des().Append(*data16);
+        CleanupStack::PopAndDestroy(data16);
+    	}
+    }
+
+HBufC16* CCreatorRandomDataParser::Convert8BitTo16BitLC(const TDesC8& aInput) 
+    {     
+    LOGSTRING("Creator: CCreatorRandomDataParser::Convert8BitTo16BitLC");
+    HBufC16* output = NULL;
+    
+    output = CnvUtfConverter::ConvertToUnicodeFromUtf8L(aInput);
+    
+    CleanupStack::PushL(output);
+    return output;          
+    } 
+
+TInt CCreatorRandomDataParser::GetError() const 
+	{
+    return iLastError;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_scriptelement.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,721 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include "creator_traces.h"
+#include "creator_scriptelement.h"
+#include <xml/documentparameters.h>
+#include <collate.h>
+#include <etel3rdparty.h> // KMaxTelNumberSize
+
+using namespace Xml;
+
+CCreatorScriptElementCache* CCreatorScriptElementCache::NewL()
+{
+    CCreatorScriptElementCache* self = new (ELeave) CCreatorScriptElementCache;
+    CleanupStack::PushL(self);
+    
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+}
+
+CCreatorScriptElementCache::CCreatorScriptElementCache()
+    {
+    
+    }
+
+void CCreatorScriptElementCache::ConstructL()
+    {
+    
+    }
+ 
+CCreatorScriptElementCache::~CCreatorScriptElementCache()
+    {
+    iElementCache.Reset();
+    iElementCache.Close();
+    }
+    
+void CCreatorScriptElementCache::RemoveElements()
+    {
+    iElementCache.Reset();
+    }
+
+        
+void CCreatorScriptElementCache::AddElementL(CCreatorScriptElement* aElement)
+    {
+    iElementCache.AppendL(aElement);
+    }
+
+/**
+ * 
+ */
+CCreatorScriptAttribute* CCreatorScriptAttribute::NewLC(const TDesC& aName, const TDesC& aValue)
+    {
+    CCreatorScriptAttribute* self = new(ELeave) CCreatorScriptAttribute();
+    CleanupStack::PushL(self);
+    self->ConstructL(aName, aValue);
+    return self;
+    }
+
+CCreatorScriptAttribute* CCreatorScriptAttribute::NewL(const TDesC& aName, const TDesC& aValue)
+    {
+    CCreatorScriptAttribute* self = CCreatorScriptAttribute::NewLC(aName, aValue);
+    CleanupStack::Pop(); // self    
+    return self;
+    }
+
+CCreatorScriptAttribute::~CCreatorScriptAttribute()
+    {
+    delete iName;
+    delete iValue;
+    }
+    
+TPtrC CCreatorScriptAttribute::Name() const
+    {
+    return iName->Des();
+    }
+
+void CCreatorScriptAttribute::SetNameL(const TDesC& aName) 
+    {
+    if( iName )
+        {
+        delete iName;
+        iName = 0;
+        }    
+    iName = HBufC::NewL(aName.Length());
+    iName->Des() = aName; 
+    }       
+    
+TPtrC CCreatorScriptAttribute::Value() const
+    {
+    return iValue->Des();
+    }
+
+void CCreatorScriptAttribute::SetValueL(const TDesC& aValue)
+    {
+    if( iValue )
+        {
+        delete iValue;
+        iValue = 0;
+        }
+    iValue = HBufC::NewL(aValue.Length());
+    iValue->Des() = aValue; 
+    }   
+
+CCreatorScriptAttribute::CCreatorScriptAttribute()
+    {    
+    }
+
+void CCreatorScriptAttribute::ConstructL(const TDesC& aName, const TDesC& aValue)
+    {
+    SetNameL(aName);
+    SetValueL(aValue);
+    }
+
+/**
+ * CCreatorScriptElement
+ */
+
+CCreatorScriptElement* CCreatorScriptElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext)
+    {
+    CCreatorScriptElement* self = new (ELeave) CCreatorScriptElement(aEngine);
+    CleanupStack::PushL(self);
+    self->ConstructL(aName, aContext);
+    CleanupStack::Pop();
+    return self;
+    }
+
+CCreatorScriptElement::~CCreatorScriptElement()
+    {
+    LOGSTRING("Creator: CCreatorScriptElement::~CCreatorScriptElement");
+    iSubElements.ResetAndDestroy();
+    iAttributes.ResetAndDestroy();
+    iSubElements.Close();
+    iAttributes.Close();
+    iParameters.Reset();
+    iParameters.Close();
+    delete iName;
+    delete iContent;
+    delete iContext;
+    }
+
+RPointerArray<CCreatorScriptElement> const& CCreatorScriptElement::SubElements() const
+    {
+    return iSubElements;
+    }
+
+RPointerArray<CCreatorScriptElement>& CCreatorScriptElement::SubElements()
+    {
+    return iSubElements;
+    }
+    
+CCreatorScriptElement* CCreatorScriptElement::SubElement(TInt aIndex)
+    {
+    return iSubElements[aIndex];
+    }
+
+CCreatorScriptElement* CCreatorScriptElement::FindSubElement(const TDesC& aName)
+    {
+    for( TInt i = 0; i < iSubElements.Count(); ++i )
+        {
+        if( iSubElements[i]->Name() == aName )
+            {
+            return iSubElements[i];
+            }            
+        }
+    return 0;
+    }
+    
+void CCreatorScriptElement::RemoveSubElements()
+    {
+    iSubElements.ResetAndDestroy();
+    }
+    
+void CCreatorScriptElement::RemoveSubElementL(TInt aIndex)
+    {
+    if( aIndex < iSubElements.Count())
+        {
+        delete iSubElements[aIndex];
+        iSubElements.Remove(aIndex);
+        }
+    else
+        {
+        User::Leave(KErrArgument);
+        }
+    }
+    
+void CCreatorScriptElement::AddSubElementL(CCreatorScriptElement* aElem, TInt aIndex )
+    {
+    if( aIndex == -1 || aIndex == iSubElements.Count() )
+        {
+        iSubElements.AppendL(aElem);
+        }
+    else if( aIndex < iSubElements.Count())
+        {
+        iSubElements.Insert(aElem, aIndex);
+        }
+    else
+        {
+        User::Leave(KErrArgument);
+        }
+    }
+  
+RPointerArray<CCreatorScriptAttribute> const& CCreatorScriptElement::Attributes() const
+    {
+    return iAttributes;
+    }
+
+        
+ CCreatorScriptAttribute* CCreatorScriptElement::Attribute(TInt aIndex)
+     {
+     return iAttributes[aIndex];
+     }
+    
+void CCreatorScriptElement::RemoveAttributes()
+    {
+    iAttributes.ResetAndDestroy();
+    }
+    
+ 
+void CCreatorScriptElement::RemoveAttributeL(TInt aIndex)
+    {
+    if( aIndex < iAttributes.Count())
+        {
+        delete iAttributes[aIndex];
+        iAttributes.Remove(aIndex);
+        }
+    else
+        {
+        User::Leave(KErrArgument);
+        }
+    }
+ 
+void CCreatorScriptElement::AddAttributeL(CCreatorScriptAttribute* aAttribute, TInt aIndex )
+    {
+    if( aIndex == -1 || aIndex == iAttributes.Count() )
+        {
+        iAttributes.AppendL(aAttribute);
+        }
+    else if( aIndex < iAttributes.Count())
+        {
+        iAttributes.Insert(aAttribute, aIndex);        
+        }
+    else
+        {
+        User::Leave(KErrArgument);
+        }
+    }
+
+TPtrC CCreatorScriptElement::Name() const
+    {
+    if( iName )
+        return iName->Des();
+    return TPtrC();
+    }
+
+void CCreatorScriptElement::SetNameL(const TDesC& aName)
+    {
+    if( iName )
+        {
+        delete iName;
+        iName = 0;
+        }    
+    iName = HBufC::NewL(aName.Length());
+    iName->Des() = aName; 
+    }
+
+ 
+TPtrC CCreatorScriptElement::Content() const
+    {
+    if (iContent)
+        return iContent->Des();
+    return TPtrC();
+    }
+    
+void CCreatorScriptElement::SetContentL(const TDesC& aContent)
+    {
+    if( iContent )
+        {
+        delete iContent;
+        iContent = 0;
+        }    
+    iContent = HBufC::NewL(aContent.Length());
+    iContent->Des() = aContent;
+    }
+
+void CCreatorScriptElement::AppendContentL(const TDesC& aContent)
+    {
+    if( iContent == 0 )
+        {
+        SetContentL(aContent);
+        return;
+        }
+            
+    iContent = iContent->ReAllocL(iContent->Length() + aContent.Length() );
+    
+    TPtr ptr(iContent->Des());
+    ptr += aContent;
+    }
+
+TPtrC CCreatorScriptElement::Context() const
+    {
+    if( iContext )
+        return iContext->Des();
+    return TPtrC();
+    }
+    
+void CCreatorScriptElement::SetContextL(const TDesC& aContext)
+    {
+    if( iContext )
+        {
+        delete iContext;
+        iContext = 0;
+        }    
+    iContext = HBufC::NewL(aContext.Length());
+    iContext->Des() = aContext;
+    }
+
+const CCreatorScriptAttribute* CCreatorScriptElement::FindAttributeByName(const TDesC& aName) const
+    {
+    for( TInt i = 0; i < iAttributes.Count(); ++i )
+        {
+        CCreatorScriptAttribute* attr = iAttributes[i];
+        if( attr->Name() == aName )
+            {
+            return attr;
+            }
+        }
+    return 0;
+    }
+
+CCreatorScriptAttribute* CCreatorScriptElement::FindAttributeByName(const TDesC& aName)
+    {    
+    for( TInt i = 0; i < iAttributes.Count(); ++i )
+        {
+        CCreatorScriptAttribute* attr = iAttributes[i];
+        if( attr->Name() == aName )
+            {
+            return attr;
+            }
+        }
+    return 0;
+    }
+
+TBool CCreatorScriptElement::IsCacheNeeded()
+    {
+    _LIT(KIDAttrName, "id");
+    const CCreatorScriptAttribute* attr = FindAttributeByName(KIDAttrName);
+    return attr != 0;
+    }
+
+void CCreatorScriptElement::AddToCacheL(CCreatorScriptElementCache& aCache)
+    {
+    aCache.AddElementL(this);
+    }
+
+RPointerArray<CCreatorModuleBaseParameters>& CCreatorScriptElement::CommandParameters()
+    {
+    return iParameters;
+    }
+
+const RPointerArray<CCreatorModuleBaseParameters>& CCreatorScriptElement::CommandParameters() const
+    {
+    return iParameters;
+    }
+
+void CCreatorScriptElement::AddToCacheL()
+    {    
+    }
+
+TBool CCreatorScriptElement::IsCommandElement() const
+    {
+    return iIsCommandElement;
+    }
+
+void CCreatorScriptElement::ExecuteCommandL()
+    {
+    
+    }
+   
+TBool CCreatorScriptElement::IsRoot() const
+    {
+    _LIT(KRootName, "creatorscript");
+    if(iName->Des() == KRootName)
+        return ETrue;
+    return EFalse;
+    }
+
+CCreatorScriptElement::CCreatorScriptElement(CCreatorEngine* aEngine)
+: 
+iIsCommandElement(EFalse),
+iIsRoot(EFalse),
+iEngine(aEngine)
+    {}
+    
+void CCreatorScriptElement::ConstructL(const TDesC& aName, const TDesC& aContext)
+    {
+    SetNameL(aName);
+    SetContextL(aContext);
+    }
+    
+TBool CCreatorScriptElement::IsSubElementSupported(const CCreatorScriptElement& /*aElem*/) const
+    {
+    return ETrue;
+    }
+
+TBool CCreatorScriptElement::ConvertStrToBooleanL(const TDesC& aStr) const
+    {
+    TBool boolVal = EFalse;
+    _LIT(KYes, "yes");
+    _LIT(KTrue, "true");
+    if( CompareIgnoreCase(aStr, KYes) == 0 ||
+        CompareIgnoreCase(aStr, KTrue) == 0 )
+        {
+        boolVal = ETrue;
+        }    
+    return boolVal;
+    }
+
+TInt CCreatorScriptElement::ConvertStrToIntL(const TDesC& aStr) const
+    {
+    TInt intVal = 0;
+    TLex lex(aStr);
+    TInt errorCode=lex.Val(intVal);
+    User::LeaveIfError(errorCode);
+    return intVal;
+    }
+
+TUint CCreatorScriptElement::ConvertStrToUintL(const TDesC& aStr) const
+	{
+	TUint uintVal = 0;
+	TLex lex(aStr);
+	TInt errorCode=lex.Val(uintVal);
+	User::LeaveIfError(errorCode);
+	return uintVal;
+	}
+void CCreatorScriptElement::ConvertStrToReal64L(const TDesC& aStr, TReal64& aVal) const
+    {    
+    TLex lex(aStr);
+    TInt errorCode=lex.Val(aVal);
+    User::LeaveIfError(errorCode);    
+    }
+
+void CCreatorScriptElement::ConvertStrToReal32L(const TDesC& aStr, TReal32& aVal) const
+    {    
+    TLex lex(aStr);
+    TInt errorCode=lex.Val(aVal);
+    User::LeaveIfError(errorCode);    
+    }
+
+MCreatorRandomDataField::TRandomLengthType CCreatorScriptElement::ResolveRandomDataTypeL(const CCreatorScriptAttribute& aAttr, TInt& aRandomLen) const
+    {    
+    TPtrC attrVal = aAttr.Value();
+    if(attrVal == KMax )
+        return MCreatorRandomDataField::ERandomLengthMax;
+    if(attrVal == KDefault)
+        return MCreatorRandomDataField::ERandomLengthDefault;
+    
+    // Let's see if the value is numeric:
+    TInt val = 0;
+    TLex lex(attrVal);
+    TInt errorCode=lex.Val(val);
+    if( errorCode == KErrNone )   
+        {
+        aRandomLen = val;
+        return MCreatorRandomDataField::ERandomLengthExplicit;
+        }
+    return MCreatorRandomDataField::ERandomLengthUndefined;
+    }
+
+void CCreatorScriptElement::AppendContactSetReferenceL(
+        const CCreatorScriptElement& aContactSetRefElem, 
+        RArray<TLinkIdParam>& aLinkArray ) const
+        {
+        const TDesC& eName = aContactSetRefElem.Name();
+        if( eName != KContactSetRef )
+            return;
+        
+        const CCreatorScriptAttribute* linkIdAttr = aContactSetRefElem.FindAttributeByName(KId);
+        if( linkIdAttr )
+            {
+            TInt linkId = ConvertStrToIntL(linkIdAttr->Value());
+            if( linkId > 0 )
+                {
+                TLinkIdParam linkParams;
+                // Add contact-set-reference id to links
+                linkParams.iLinkId = linkId;
+                linkParams.iLinkAmount = KUndef; // undefined
+                // Resolve maxamount:
+                const CCreatorScriptAttribute* maxAmount = aContactSetRefElem.FindAttributeByName(KMaxAmount);
+                if( maxAmount )
+                    {                                
+                    TInt maxAmountVal = ConvertStrToIntL(maxAmount->Value());
+                    if( maxAmountVal > 0 )
+                        {
+                        linkParams.iLinkAmount = maxAmountVal;
+                        }
+                    }
+                aLinkArray.AppendL(linkParams);
+                }
+            }
+        }       
+
+TTime CCreatorScriptElement::ConvertToDateTimeL(const TDesC& aDtStr) const
+    {
+    _LIT(KDateFieldSeparator, "-");
+    _LIT(KTimeFieldSeparator, ":");    
+    _LIT(KDateTimeSeparator, "T");    
+    _LIT(KTimeSuffix, ".");
+    _LIT(KDateSuffix, ":");
+    // Format date-time string:
+    HBufC* formatted = HBufC::NewLC(aDtStr.Length());
+    formatted->Des().Copy(aDtStr);
+    
+    TBool hasTimePart = EFalse; 
+    TBool hasDateTimeSeparator = EFalse;
+    TInt pos = 0;
+    
+    // Date and month numbering starts from 0 in Symbian, so first
+    // we need to decrease the date and month by one. Script format is following:
+    // yyyy-mm-ddThh:mm:ss
+    // Remove also date field separators ('-')
+    while( (pos = formatted->Find(KDateFieldSeparator)) != KErrNotFound )
+        {
+        // decrease month or date by one
+        
+        // First char. Can be zero also:
+        TInt newValue = 0;
+        const TPtrC& char1 = formatted->Des().Mid(pos+1).Left(1);
+        newValue = 10 * ConvertStrToIntL(char1);
+        // Next char:
+        const TPtrC& char2 = formatted->Des().Mid(pos+2).Left(1);
+        newValue += ConvertStrToIntL(char2);
+       
+        if( newValue > 0 )
+            {
+            --newValue;
+            }
+        
+        _LIT(KTemp, "%d");
+        HBufC* formatBuf = KTemp().AllocLC();
+        HBufC* buf = 0;
+        if( newValue < 10 )
+            buf = HBufC::NewLC(1);            
+        else
+            buf = HBufC::NewLC(2);
+                        
+        TPtr temp(buf->Des());
+        temp.Format(*formatBuf, newValue);
+        if( newValue < 10 )
+            {
+            formatted->Des()[pos+1] = TChar('0');
+            formatted->Des()[pos+2] = buf->Des()[0];
+            }
+        else
+            {
+            formatted->Des()[pos+1] = buf->Des()[0];
+            formatted->Des()[pos+2] = buf->Des()[1];
+            }
+        // Finally, delete the '-' separator:
+        formatted->Des().Delete(pos, 1);        
+        CleanupStack::PopAndDestroy(2);
+        }
+    
+    while( (pos = formatted->Find(KTimeFieldSeparator)) != KErrNotFound )
+        {
+        formatted->Des().Delete(pos, 1);
+        hasTimePart = ETrue;
+        }
+    
+    // Replace 'T' with ':':
+    if( (pos = formatted->Find(KDateTimeSeparator)) != KErrNotFound )
+        {
+        formatted->Des().Replace(pos, 1, KDateSuffix);
+        hasDateTimeSeparator = ETrue;
+        }
+    
+    if( hasTimePart )
+        formatted->Des().Append(KTimeSuffix);
+    else if( !hasDateTimeSeparator )
+        formatted->Des().Append(KDateSuffix);
+    
+    
+    TTime ret;
+    ret.Set(*formatted);    
+    CleanupStack::PopAndDestroy(); // formatted
+    return ret;
+    }
+
+TInt CCreatorScriptElement::CompareIgnoreCase(const TDesC& aStr1, const TDesC& aStr2 ) const
+    {
+    // Get default collation method:
+    TCollationMethod defaultCollationMethod = *Mem::CollationMethodByIndex(0); 
+    
+    // Add ignore case flag:
+    defaultCollationMethod.iFlags |= TCollationMethod::EFoldCase;
+    
+    return aStr1.CompareF(aStr2);
+    }
+
+void CCreatorScriptElement::SetContentToTextParamL(HBufC*& aPtr, const TDesC& aContent )
+    {
+    delete aPtr;
+    aPtr = 0;
+    aPtr = HBufC::NewL(aContent.Length());
+    aPtr->Des().Copy(aContent);
+    }
+
+/**
+ * Increases phonenumber by aDelta.
+ */
+void CCreatorScriptElement::IncreasePhoneNumL( const TDesC& aOriginal, TInt aDelta, HBufC* aIncreased ) const
+    {
+    LOGSTRING("Creator: CCreatorMessageElement::IncreasePhoneNumL");
+    __ASSERT_ALWAYS( aDelta >= 0, User::Panic( _L("IncreasePhoneNumL"), KErrArgument ) );
+    
+    // special cases, that are handled:
+    // +9          -> +9, +10, +11...
+    // +3584098#99 -> +3584098#99, +3584098#100, +3584098#101...
+    // #           -> #0, #1, #2...
+    // 123#        -> 123#0, 123#1, 123#2... 
+    // 099         -> 099, 100, 101...
+    
+    // find out if there are any special characters, like # p or *, in the original number
+    TInt startIndex( aOriginal.Length() -1 );
+    while ( startIndex >= 0 && 
+            aOriginal[startIndex] >= '0' &&
+            aOriginal[startIndex] <= '9' )
+        {
+        startIndex--;
+        }
+    startIndex++;
+    
+    // append original head that may contain any non number characters 
+    aIncreased->Des().Append( aOriginal.Left( startIndex ) );
+    
+    TBuf<CTelephony::KMaxTelNumberSize> tailBuf;
+    if ( aOriginal.Length() > startIndex )
+        {
+        tailBuf.Copy( aOriginal.Right( aOriginal.Length() -startIndex ) );
+        }
+    
+    // parse the tail part of the original number
+    TInt64 intVal = 0;
+    if ( aOriginal.Length() > startIndex )
+        {
+        TLex lex( tailBuf );
+        User::LeaveIfError( lex.Val( intVal ) ); // this loses leading zeros
+        }
+    
+    // increase
+    intVal += aDelta;
+    
+    // restore leading zeros to tail, if any
+    TBuf<CTelephony::KMaxTelNumberSize> resultTailNoZeros;
+    resultTailNoZeros.AppendNum( intVal );
+    TInt tailLeadingZerosToRestore = tailBuf.Length() - resultTailNoZeros.Length();
+    for ( TInt i = 0; i < tailLeadingZerosToRestore; i++ )
+        {
+        aIncreased->Des().AppendNum( 0 );
+        }
+
+    // and finally, append the increased value as tail part of the result
+    aIncreased->Des().Append( resultTailNoZeros );    
+    }
+
+CCreatorScriptRoot* CCreatorScriptRoot::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext)
+    {
+    CCreatorScriptRoot* self = new (ELeave) CCreatorScriptRoot(aEngine);
+    CleanupStack::PushL(self);
+    self->ConstructL(aName, aContext);
+    CleanupStack::Pop();
+    return self;
+    }
+CCreatorScriptRoot::CCreatorScriptRoot(CCreatorEngine* aEngine)
+:
+CCreatorScriptElement(aEngine)
+    {
+    iIsRoot=ETrue;
+    }
+
+
+CCreatorCalendarElementBase* CCreatorCalendarElementBase::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext)
+    {
+    CCreatorCalendarElementBase* self = new (ELeave) CCreatorCalendarElementBase(aEngine);
+    CleanupStack::PushL(self);
+    self->ConstructL(aName, aContext);
+    CleanupStack::Pop();
+    return self;
+    }
+CCreatorCalendarElementBase::CCreatorCalendarElementBase(CCreatorEngine* aEngine) 
+: 
+CCreatorScriptElement(aEngine)
+    { }
+
+CCreatorMessageElementBase* CCreatorMessageElementBase::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext)
+    {
+    CCreatorMessageElementBase* self = new (ELeave) CCreatorMessageElementBase(aEngine);
+    CleanupStack::PushL(self);
+    self->ConstructL(aName, aContext);
+    CleanupStack::Pop();
+    return self;
+    }
+CCreatorMessageElementBase::CCreatorMessageElementBase(CCreatorEngine* aEngine) 
+: 
+CCreatorScriptElement(aEngine)
+    { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_scriptelementfactory.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,112 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include "creator_traces.h"
+#include "creator_scriptelementfactory.h"
+#include "creator_contactelement.h"
+#include "creator_calendarelement.h"
+#include "creator_messageelement.h"
+#include "creator_fileelement.h"
+#include "creator_browserelement.h"
+#include "creator_logelement.h"
+#include "creator_noteelement.h"
+#include "creator_impselement.h"
+#include "creator_landmarkelement.h"
+#include "creator_mailboxelement.h"
+#include "creator_connectionmethodelement.h"
+
+CCreatorScriptElement* TCreatorScriptElementFactory::CreateElementL(CCreatorEngine* aEngine, const TDesC& aElementName, const TDesC& aContext )
+    {   
+    LOGSTRING2("TCreatorScriptElementFactory::CreateElementL: %S", &aElementName);
+    
+    if( aContext.Length() >= KFields().Length() && 
+    	aContext.Right(KFields().Length()) == KFields)
+    	{
+    	// This is a field element under 'fields'.
+    	return CCreatorScriptElement::NewL(aEngine, aElementName, aContext);
+    	}    
+    else if( aElementName == creatorcontact::KContact )
+        {
+        return CCreatorContactElement::NewL(aEngine, aElementName, aContext);  
+        }
+    else if( aElementName == creatorcontact::KContactSet)
+        {
+        return CCreatorContactSetElement::NewL(aEngine, aElementName, aContext);
+        }
+    else if( aElementName == creatorcontact::KContactGroup )
+        {
+        return CCreatorContactGroupElement::NewL(aEngine, aElementName, aContext);
+        }
+    else if( aElementName == KFields)
+        {
+        return CCreatorScriptElement::NewL(aEngine, aElementName, aContext);
+        }
+    else if( aElementName == KScript )
+        {
+        return CCreatorScriptRoot::NewL(aEngine, aElementName, aContext);
+        }
+    else if( aElementName == creatorcalendar::KCalendar )
+        {
+        return CCreatorCalendarElement::NewL(aEngine, aElementName, aContext);
+        }
+    else if( aElementName == creatormsg::KMessage )
+        {
+        return CCreatorMessageElement::NewL(aEngine, aElementName, aContext);
+        }
+    else if( aElementName == creatorfile::KFile )
+        {
+        return CCreatorFileElement::NewL(aEngine, aElementName, aContext);
+        }
+    else if( aElementName == creatorbrowser::KBookmark ||
+            aElementName == creatorbrowser::KBookmarkFolder ||
+            aElementName == creatorbrowser::KSavedPage ||
+            aElementName == creatorbrowser::KSavedPageFolder )
+        {
+        return CCreatorBrowserElement::NewL(aEngine, aElementName, aContext);
+        }
+    else if( aElementName == creatorlog::KLog )
+        {
+        return CCreatorLogElement::NewL(aEngine, aElementName, aContext);
+        }
+    else if( aElementName == creatornote::KNote )
+        {
+        return CCreatorNoteElement::NewL(aEngine, aElementName, aContext);
+        }
+	#ifdef __PRESENCE
+    else if( aElementName == creatorimps::KImpsServer )
+        {
+        return CCreatorImpsServerElement::NewL(aEngine, aElementName, aContext);
+        }
+	#endif // __PRESENCE
+    else if( aElementName == creatorlandmark::KLandmark )
+        {
+        return CCreatorLandmarkElement::NewL(aEngine, aElementName, aContext);
+        }
+    else if( aElementName == creatormailbox::Kmailbox )
+        {
+        return CCreatorMailboxElement::NewL(aEngine, aElementName, aContext);
+        }
+    else if( aElementName == creatorconnectionmethod::KCm )
+    	{
+    	return CCreatorConnectionMethodElement::NewL(aEngine, aElementName, aContext);
+    	}
+    else
+        {
+        return CCreatorScriptElement::NewL(aEngine, aElementName, aContext);
+        }       
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_scriptentry.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,728 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include "creator_model.h"
+#include "creator_traces.h"
+#include "creator_factory.h"
+
+#include <aknlists.h> 
+#include <AknsSkinInstance.h>
+
+
+#include <data_caging_path_literals.hrh>
+
+
+const TInt KReadBufSize = 8192;
+
+// Creator random data file filter
+_LIT(KRandomDataFileFilter, "*.creatordataxml");
+
+// ---------------------------------------------------------------------------
+
+
+CCommandParser* CCommandParser::NewL(CCreatorEngine* aEngine)
+    {
+    CCommandParser* self = CCommandParser::NewLC(aEngine);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CCommandParser* CCommandParser::NewLC(CCreatorEngine* aEngine)
+    {
+    CCommandParser* self = new (ELeave) CCommandParser;
+    CleanupStack::PushL(self);
+    self->ConstructL(aEngine);
+    return self;
+    }
+
+CCommandParser::CCommandParser()
+	{
+	}
+
+void CCommandParser::ConstructL(CCreatorEngine* aEngine)
+	{
+    LOGSTRING("Creator: CCommandParser::ConstructL");
+
+    iEngine = aEngine;
+
+    iReadBuf = HBufC8::NewL(KReadBufSize);
+	}
+
+CCommandParser::~CCommandParser()
+	{
+    LOGSTRING("Creator: CCommandParser::~CCommandParser");
+
+    if (iSearchArray)
+        delete iSearchArray;
+
+    if (iReadBuf)
+        delete iReadBuf;
+	}
+
+
+// ---------------------------------------------------------------------------
+//#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+void CCommandParser::OpenScriptL() {}
+TBool CCommandParser::OpenScriptL(RFile& aScriptFile)
+    {    
+    LOGSTRING("Creator: CCommandParser::OpenScriptL");
+    TBool ret = EFalse;
+
+    // init the search array
+    iSearchArray = new(ELeave) CDesCArrayFlat(500);
+
+    // wait dialog
+    CAknGlobalNote* waitDialog = CAknGlobalNote::NewLC();
+    waitDialog->SetSoftkeys(R_AVKON_SOFTKEYS_CANCEL);
+    TInt dialogId = waitDialog->ShowNoteL(EAknGlobalWaitNote, _L("Searching"));
+
+
+    // search all the .creator files from the phone
+    TInt err;
+    TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\")));
+
+    TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\system\\apps\\Creator\\")));
+
+    TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\data\\")));
+    TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\data\\")));
+    
+    TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\documents\\")));
+    TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\documents\\")));
+
+    TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\creator\\")));
+    TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\creator\\")));
+    
+    TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\scripts\\")));
+    TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\scripts\\")));
+    
+    TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\temp\\")));
+    TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\temp\\")));
+    
+    TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\system\\temp\\")));
+    TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\system\\temp\\")));
+
+    TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\private\\20011383\\")));
+    TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\private\\20011383\\")));
+
+    TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\private\\1000484b\\")));
+
+
+    // remove the wait dialog
+    waitDialog->CancelNoteL(dialogId);
+    CleanupStack::PopAndDestroy(); //waitDialog;
+
+
+    if ( iSearchArray->MdcaCount() > 0)
+        {
+        // create a file name array based on the iSearchArray
+        CDesCArray* fileNameArray = new(ELeave) CDesCArrayFlat(iSearchArray->MdcaCount());
+        CleanupStack::PushL(fileNameArray);
+        
+        for (TInt i=0; i<iSearchArray->MdcaCount(); i++)
+            {
+            
+            TParse filename; // file name parser
+            filename.Set(iSearchArray->MdcaPoint(i), NULL, NULL);
+
+            if ( filename.Drive()[0] == 'e' || filename.Drive()[0] == 'E')  // MMC
+                {
+                TFileName nameMMC;
+                nameMMC.Append(filename.Name());
+                nameMMC.Append(_L("\t0"));        // MMC icon
+                fileNameArray->AppendL(nameMMC);
+                }
+            else
+                {
+                fileNameArray->AppendL(filename.Name());
+                }
+            }
+        CleanupStack::Pop(fileNameArray);
+
+
+        // create a popup list
+        CAknSinglePopupMenuStyleListBox* listBox = new(ELeave) CAknSinglePopupMenuStyleListBox;
+        CleanupStack::PushL(listBox);
+        CAknPopupList* popupList = CAknPopupList::NewL( listBox, R_AVKON_SOFTKEYS_SELECT_CANCEL, AknPopupLayouts::EMenuWindow );
+        CleanupStack::PushL(popupList);
+        popupList->SetTitleL(_L("Select script"));
+        listBox->ConstructL( popupList, EAknListBoxSelectionList|EAknListBoxLoopScrolling );
+        listBox->CreateScrollBarFrameL( ETrue );
+        listBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
+        listBox->Model()->SetItemTextArray( fileNameArray );
+        listBox->Model()->SetOwnershipType( ELbmOwnsItemArray );  // !!!
+        listBox->HandleItemAdditionL();
+
+
+        // define MMC icon 
+        MAknsSkinInstance* skin = AknsUtils::SkinInstance();
+        _LIT( KFLDMemoryCardUiBitmapFile, "z:aknmemorycardui.mbm" );
+        CAknIconArray* iconArray = new( ELeave ) CAknIconArray( 1 );
+        listBox->ItemDrawer()->ColumnData()->SetIconArray( iconArray );
+
+        TParse* fp = new(ELeave) TParse();
+        fp->Set(KFLDMemoryCardUiBitmapFile, &KDC_APP_BITMAP_DIR, NULL);
+        TFileName resourceFileName( fp->FullName() );
+        delete fp;
+
+        CGulIcon* icon = AknsUtils::CreateGulIconL( skin, KAknsIIDQgnIndiMmcAdd,
+            resourceFileName,
+            EMbmAknmemorycarduiQgn_indi_mmc_add,
+            EMbmAknmemorycarduiQgn_indi_mmc_add_mask );
+        CleanupStack::PushL( icon );
+        iconArray->AppendL( icon );
+        CleanupStack::Pop( icon );
+
+
+        // execute dialog
+        TBool result = popupList->ExecuteLD();
+        CleanupStack::Pop();  // popupList
+
+        if ( result ) 
+            {
+            // open the file for reading
+            //RFile file;
+            TRAPD(err, aScriptFile.Open(CEikonEnv::Static()->FsSession(), iSearchArray->MdcaPoint(listBox->CurrentItemIndex()), EFileRead));
+            if( err != KErrNone)
+                {
+                aScriptFile.Close();
+                User::Leave(err);
+                }
+            ret = ETrue;
+            }
+        CleanupStack::PopAndDestroy();  //listBox
+        }
+    else  // no scripts found from the search paths
+        {
+        CAknInformationNote* note = new (ELeave) CAknInformationNote;
+        note->ExecuteLD(_L("No scripts found"));
+        }
+
+    delete iSearchArray;
+    iSearchArray = NULL;
+    return ret;
+    }
+/*
+#else
+// ---------------------------------------------------------------------------
+void CCommandParser::OpenScriptL()
+    {
+    LOGSTRING("Creator: CCommandParser::OpenScriptL");
+
+    // init the search array
+    iSearchArray = new(ELeave) CDesCArrayFlat(500);
+
+    // wait dialog
+    CAknGlobalNote* waitDialog = CAknGlobalNote::NewLC();
+    waitDialog->SetSoftkeys(R_AVKON_SOFTKEYS_CANCEL);
+    TInt dialogId = waitDialog->ShowNoteL(EAknGlobalWaitNote, _L("Searching"));
+
+
+    // search all the .creator files from the phone
+    TInt err;
+    TRAP(err, FindFiles(_L("*.creator"), _L("\\")));
+
+    TRAP(err, FindFiles(_L("*.creator"), _L("\\system\\apps\\Creator\\")));
+
+    TRAP(err, FindFiles(_L("*.creator"), _L("\\data\\")));
+    TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\data\\")));
+    
+    TRAP(err, FindFiles(_L("*.creator"), _L("\\documents\\")));
+    TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\documents\\")));
+
+    TRAP(err, FindFiles(_L("*.creator"), _L("\\creator\\")));
+    TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\creator\\")));
+    
+    TRAP(err, FindFiles(_L("*.creator"), _L("\\scripts\\")));
+    TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\scripts\\")));
+    
+    TRAP(err, FindFiles(_L("*.creator"), _L("\\temp\\")));
+    TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\temp\\")));
+    
+    TRAP(err, FindFiles(_L("*.creator"), _L("\\system\\temp\\")));
+    TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\system\\temp\\")));
+
+    TRAP(err, FindFiles(_L("*.creator"), _L("\\private\\101FA751\\")));
+    TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\private\\101FA751\\")));
+
+    TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\private\\1000484b\\")));
+
+
+    // remove the wait dialog
+    waitDialog->CancelNoteL(dialogId);
+    CleanupStack::PopAndDestroy(); //waitDialog;
+
+
+    if ( iSearchArray->MdcaCount() > 0)
+        {
+        // create a file name array based on the iSearchArray
+        CDesCArray* fileNameArray = new(ELeave) CDesCArrayFlat(iSearchArray->MdcaCount());
+        CleanupStack::PushL(fileNameArray);
+        
+        for (TInt i=0; i<iSearchArray->MdcaCount(); i++)
+            {
+            
+            TParse filename; // file name parser
+            filename.Set(iSearchArray->MdcaPoint(i), NULL, NULL);
+
+            if ( filename.Drive()[0] == 'e' || filename.Drive()[0] == 'E')  // MMC
+                {
+                TFileName nameMMC;
+                nameMMC.Append(filename.Name());
+                nameMMC.Append(_L("\t0"));        // MMC icon
+                fileNameArray->AppendL(nameMMC);
+                }
+            else
+                {
+                fileNameArray->AppendL(filename.Name());
+                }
+            }
+        CleanupStack::Pop(fileNameArray);
+
+
+        // create a popup list
+        CAknSinglePopupMenuStyleListBox* listBox = new(ELeave) CAknSinglePopupMenuStyleListBox;
+        CleanupStack::PushL(listBox);
+        CAknPopupList* popupList = CAknPopupList::NewL( listBox, R_AVKON_SOFTKEYS_SELECT_CANCEL, AknPopupLayouts::EMenuWindow );
+        CleanupStack::PushL(popupList);
+        popupList->SetTitleL(_L("Select script"));
+        listBox->ConstructL( popupList, EAknListBoxSelectionList|EAknListBoxLoopScrolling );
+        listBox->CreateScrollBarFrameL( ETrue );
+        listBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
+        listBox->Model()->SetItemTextArray( fileNameArray );
+        listBox->Model()->SetOwnershipType( ELbmOwnsItemArray );  // !!!
+        listBox->HandleItemAdditionL();
+
+
+        // define MMC icon 
+        MAknsSkinInstance* skin = AknsUtils::SkinInstance();
+        _LIT( KFLDMemoryCardUiBitmapFile, "z:aknmemorycardui.mbm" );
+        CAknIconArray* iconArray = new( ELeave ) CAknIconArray( 1 );
+        listBox->ItemDrawer()->ColumnData()->SetIconArray( iconArray );
+
+        TParse* fp = new(ELeave) TParse();
+        fp->Set(KFLDMemoryCardUiBitmapFile, &KDC_APP_BITMAP_DIR, NULL);
+        TFileName resourceFileName( fp->FullName() );
+        delete fp;
+
+        CGulIcon* icon = AknsUtils::CreateGulIconL( skin, KAknsIIDQgnIndiMmcAdd,
+            resourceFileName,
+            EMbmAknmemorycarduiQgn_indi_mmc_add,
+            EMbmAknmemorycarduiQgn_indi_mmc_add_mask );
+        CleanupStack::PushL( icon );
+        iconArray->AppendL( icon );
+        CleanupStack::Pop( icon );
+
+
+        // execute dialog
+        TBool result = popupList->ExecuteLD();
+        CleanupStack::Pop();  // popupList
+
+        if ( result ) 
+            {
+            // open the file for reading
+            RFile file;
+            User::LeaveIfError(file.Open(CEikonEnv::Static()->FsSession(), iSearchArray->MdcaPoint(listBox->CurrentItemIndex()), EFileRead));
+            while (ReadLineFromFileL(file) == KErrNone)
+                {
+                iReadBuf->Des().Trim();  // delete leading and trailing white space
+
+                if (iReadBuf->Length() < 5)  // command too short, ignoring...
+                    {
+                    //CEikonEnv::Static()->InfoMsg(_L("Corrupted line"));
+                    }
+        
+                // check it's a valid line: first char is A-Z and the line ends to ';'
+                else if (iReadBuf->Des()[0] >= 'A' && iReadBuf->Des()[0] <= 'Z' && iReadBuf->Des()[iReadBuf->Length()-1] == ';')
+                    {
+                    // this line is valid -> parse the command
+                    ParseCommandFromDescriptorL();
+                    }
+                else
+                    {
+                    //CEikonEnv::Static()->InfoMsg(_L("Not a valid line"));
+                    }
+
+                }
+
+            file.Close();
+
+            // show a note if there were no valid commands in the script
+            if (iEngine->CommandArrayCount() == 0)
+                {
+                CAknInformationNote* note = new(ELeave) CAknInformationNote;
+                note->ExecuteLD(_L("No valid commands in this script"));
+                }
+
+            }
+
+        CleanupStack::PopAndDestroy();  //listBox
+        }
+    
+    else  // no scripts found from the search paths
+        {
+        CAknInformationNote* note = new (ELeave) CAknInformationNote;
+        note->ExecuteLD(_L("No scripts found"));
+        }
+
+
+    delete iSearchArray;
+    iSearchArray = NULL;
+
+    }
+#endif
+*/
+
+TBool CCommandParser::GetRandomDataFilenameL(TDes& aFilename)
+    {    
+    LOGSTRING("Creator: CCommandParser::GetRandomDataFilenameL");
+    TBool ret = EFalse;
+
+    // init the search array
+    if (iSearchArray)
+    	{
+    	delete iSearchArray;
+    	iSearchArray = NULL;
+    	}
+    iSearchArray = new(ELeave) CDesCArrayFlat(500);
+
+    // wait dialog
+    CAknGlobalNote* waitDialog = CAknGlobalNote::NewLC();
+    waitDialog->SetSoftkeys(R_AVKON_SOFTKEYS_CANCEL);
+    TInt dialogId = waitDialog->ShowNoteL(EAknGlobalWaitNote, _L("Searching"));
+
+
+    // search all the creator random data files from the phone
+    TInt err;
+    TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\")));
+
+    TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\system\\apps\\Creator\\")));
+
+    TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\data\\")));
+    TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\data\\")));
+    
+    TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\documents\\")));
+    TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\documents\\")));
+
+    TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\creator\\")));
+    TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\creator\\")));
+    
+    TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\scripts\\")));
+    TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\scripts\\")));
+    
+    TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\temp\\")));
+    TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\temp\\")));
+    
+    TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\system\\temp\\")));
+    TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\system\\temp\\")));
+
+    TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\private\\20011383\\")));
+    TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\private\\20011383\\")));
+
+    TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\private\\1000484b\\")));
+
+
+    // remove the wait dialog
+    waitDialog->CancelNoteL(dialogId);
+    CleanupStack::PopAndDestroy(); //waitDialog;
+
+
+    if (iSearchArray->MdcaCount() > 0)
+        {
+        // create a file name array based on the iSearchArray
+        CDesCArray* fileNameArray = new(ELeave) CDesCArrayFlat(iSearchArray->MdcaCount() + 1);
+        CleanupStack::PushL(fileNameArray);
+
+        for (TInt i=0; i<iSearchArray->MdcaCount(); i++)
+            {
+            
+            TParse filename; // file name parser
+            filename.Set(iSearchArray->MdcaPoint(i), NULL, NULL);
+
+            if ( filename.Drive()[0] == 'e' || filename.Drive()[0] == 'E')  // MMC
+                {
+                TFileName nameMMC;
+                nameMMC.Append(filename.Name());
+                nameMMC.Append(_L("\t0"));        // MMC icon
+                fileNameArray->AppendL(nameMMC);
+                }
+            else
+                {
+                fileNameArray->AppendL(filename.Name());
+                }
+            }
+
+        // add "default" (resource file) to list
+        fileNameArray->AppendL(_L("Default"));
+
+        CleanupStack::Pop(fileNameArray);
+
+
+        // create a popup list
+        CAknSinglePopupMenuStyleListBox* listBox = new(ELeave) CAknSinglePopupMenuStyleListBox;
+        CleanupStack::PushL(listBox);
+        CAknPopupList* popupList = CAknPopupList::NewL( listBox, R_AVKON_SOFTKEYS_SELECT_CANCEL, AknPopupLayouts::EMenuWindow );
+        CleanupStack::PushL(popupList);
+        popupList->SetTitleL(_L("Select random data file"));
+        listBox->ConstructL( popupList, EAknListBoxSelectionList|EAknListBoxLoopScrolling );
+        listBox->CreateScrollBarFrameL( ETrue );
+        listBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
+        listBox->Model()->SetItemTextArray( fileNameArray );
+        listBox->Model()->SetOwnershipType( ELbmOwnsItemArray );  // !!!
+        listBox->HandleItemAdditionL();
+
+
+        // define MMC icon 
+        MAknsSkinInstance* skin = AknsUtils::SkinInstance();
+        _LIT( KFLDMemoryCardUiBitmapFile, "z:aknmemorycardui.mbm" );
+        CAknIconArray* iconArray = new( ELeave ) CAknIconArray( 1 );
+        listBox->ItemDrawer()->ColumnData()->SetIconArray( iconArray );
+
+        TParse* fp = new(ELeave) TParse();
+        fp->Set(KFLDMemoryCardUiBitmapFile, &KDC_APP_BITMAP_DIR, NULL);
+        TFileName resourceFileName( fp->FullName() );
+        delete fp;
+
+        CGulIcon* icon = AknsUtils::CreateGulIconL( skin, KAknsIIDQgnIndiMmcAdd,
+            resourceFileName,
+            EMbmAknmemorycarduiQgn_indi_mmc_add,
+            EMbmAknmemorycarduiQgn_indi_mmc_add_mask );
+        CleanupStack::PushL( icon );
+        iconArray->AppendL( icon );
+        CleanupStack::Pop( icon );
+
+
+        // execute dialog
+        TBool result = popupList->ExecuteLD();
+        CleanupStack::Pop();  // popupList
+
+        if ( result ) 
+            {
+            if (listBox->CurrentItemIndex() == (fileNameArray->Count() - 1))
+            	{
+            	// "default" (resource file) selected
+            	aFilename.Copy(KNullDesC);
+            	}
+            else
+            	{
+            	// xml file selected
+            	aFilename.Copy(iSearchArray->MdcaPoint(listBox->CurrentItemIndex()));
+            	}
+            ret = ETrue;
+            }
+        CleanupStack::PopAndDestroy();  //listBox
+        }
+    else  // no random data files found from the search paths
+        {
+        CAknInformationNote* note = new (ELeave) CAknInformationNote;
+        note->ExecuteLD(_L("No random data files found"));
+        }
+
+    delete iSearchArray;
+    iSearchArray = NULL;
+    return ret;
+    }
+
+TInt CCommandParser::FindFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath)
+    {
+    return CreatorFileUtils::FindFilesRecursiveL(iSearchArray, aFileName, aPath);
+    }
+TInt CreatorFileUtils::FindFilesRecursiveL(CDesCArrayFlat* aFileArray, const TDesC& aFileName, const TDesC& aPath)
+	{
+    TInt err = KErrNone;
+    CDirScan* scan = CDirScan::NewLC(CEikonEnv::Static()->FsSession());
+    scan->SetScanDataL(aPath, KEntryAttDir, ESortNone);
+    CDir* dirEntries = NULL;
+
+    for(;;)
+        {
+        TRAP(err, scan->NextL(dirEntries));
+        if (!dirEntries  || (err!=KErrNone))
+            break;
+
+        for (TInt i=0; i<dirEntries->Count(); i++) 
+            {
+            TFileName path(scan->FullPath());
+            path.Append((*dirEntries)[i].iName);
+            path.Append(_L("\\"));
+            FindFiles(aFileArray, aFileName, path);
+            }
+        delete(dirEntries);
+        }
+
+    CleanupStack::PopAndDestroy(scan);
+    return err;
+    }
+
+TInt CreatorFileUtils::FindFiles(CDesCArrayFlat* aFileArray, const TDesC& aFileName, const TDesC& aPath)
+    {
+    TFindFile fileFinder(CEikonEnv::Static()->FsSession());
+    CDir* fileList; 
+    TInt err = fileFinder.FindWildByDir(aFileName, aPath, fileList);
+
+    while (err == KErrNone)
+        {
+        for (TInt i=0; i<fileList->Count(); i++)
+            {
+            TParse fullentry;
+            fullentry.Set((*fileList)[i].iName, &fileFinder.File(), NULL);
+            
+            TRAP(err, aFileArray->AppendL(fullentry.FullName())); 
+            }
+
+        delete fileList;
+        err = fileFinder.FindWild(fileList);
+        }
+    return err;
+    }
+// ---------------------------------------------------------------------------
+
+TInt CCommandParser::FindFiles(const TDesC& aFileName, const TDesC& aPath)
+    {
+    return CreatorFileUtils::FindFiles(iSearchArray, aFileName, aPath);
+    }
+
+// ---------------------------------------------------------------------------
+
+TInt CCommandParser::ReadLineFromFileL(RFile& aInputFile)
+    {
+    LOGSTRING("Creator: CCommandParser::ReadLineFromFile");
+
+	_LIT8(KImcvCRLF, "\r\n");
+
+    TInt err = KErrNone;
+
+    //  Read into the buffer
+    HBufC8* tempLine = HBufC8::NewLC(KReadBufSize);
+    TPtr8 buffer = tempLine->Des();
+
+    // clear the targer
+    iReadBuf->Des().Copy(_L(""));
+
+    //  Get the current file position
+    TInt filePos = 0;
+    aInputFile.Seek(ESeekCurrent, filePos);
+
+    //  Read the buffer
+    err = aInputFile.Read(buffer);
+
+    //end of file?
+    TInt s = buffer.Length();
+    if  ( s == 0)
+        err = KErrEof;
+
+    if  (err == KErrNone)
+        {
+        //  Copy to the lfcr and then set the file pointer to the point after that
+        TInt pos = buffer.Find(KImcvCRLF);
+        if      ( pos != -1)
+            {
+            iReadBuf->Des().Justify(buffer, pos, ELeft, ' ');
+            filePos += (pos+2);
+
+            //  Set the file pointer back to after the lfcr
+            aInputFile.Seek(ESeekStart, filePos);
+            }
+        //  Else fill the whole buffer
+        else
+            {
+            iReadBuf->Des().Copy(buffer);
+            }
+        }
+
+    CleanupStack::PopAndDestroy(); // tempLine
+    return err;
+    }
+
+// ---------------------------------------------------------------------------
+
+void CCommandParser::StrParserL(HBufC*& aDestinationBuf, TUint aToken)
+    {
+    // store old position
+	iParserOldPosition = iParserPosition;
+
+    // make sure we are not reading outside of buffer
+    if (iParserPosition >= iReadBuf->Length() - 1)
+        return;
+    
+    // read until asked token
+	do
+	    {
+	    iParserPosition++;
+	    }
+	while (iReadBuf->Des()[iParserPosition] != aToken && iParserPosition < iReadBuf->Des().Length()-1);
+	
+	// calculate length of the destination buffer
+	TInt bufferLength = iParserPosition-iParserOldPosition-1;
+	
+	// reset the destination buffer
+	if (aDestinationBuf)
+	    {
+        delete aDestinationBuf;
+        aDestinationBuf = NULL;
+	    }
+
+    // allocate memory for the destination buffer
+	aDestinationBuf = HBufC::NewL(bufferLength);
+
+	// copy data from the read buffer to the destination buffer
+    aDestinationBuf->Des().Copy(iReadBuf->Des().Mid(iParserOldPosition+1, bufferLength));
+    }
+
+// ---------------------------------------------------------------------------
+
+void CCommandParser::StrParserL(HBufC8*& aDestinationBuf, TUint aToken)
+    {
+    // store old position
+	iParserOldPosition = iParserPosition;
+
+    // make sure we are not reading outside of buffer
+    if (iParserPosition >= iReadBuf->Length() - 1)
+        return;
+    
+    // read until asked token
+	do
+	    {
+	    iParserPosition++;
+	    }
+	while (iReadBuf->Des()[iParserPosition] != aToken && iParserPosition < iReadBuf->Des().Length()-1);
+	
+	// calculate length of the destination buffer
+	TInt bufferLength = iParserPosition-iParserOldPosition-1;
+	
+	// reset the destination buffer
+	if (aDestinationBuf)
+	    {
+        delete aDestinationBuf;
+        aDestinationBuf = NULL;
+	    }
+
+    // allocate memory for the destination buffer
+	aDestinationBuf = HBufC8::NewL(bufferLength);
+
+	// copy data from the read buffer to the destination buffer
+    aDestinationBuf->Des().Copy(iReadBuf->Des().Mid(iParserOldPosition+1, bufferLength));
+    }
+
+//----------------------------------------------------------------------------
+
+void CCommandParser::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) // from MMsvSessionObserver
+    {
+    }
+
+//----------------------------------------------------------------------------
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_scriptparser.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,393 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include <f32file.h>
+#include <utf.h>
+#include <xml/documentparameters.h>
+#include "creator_scriptparser.h"
+#include "creator_scriptelementfactory.h"
+#include "creator_traces.h"
+
+using namespace Xml;
+
+CCreatorScriptParser::CCreatorScriptParser() 
+: iDefaultElement(TCreatorScriptElementInfo(TCreatorScriptElementInfo::EStatusUndefined, 0))
+    {        
+    }
+void CCreatorScriptParser::ConstructL(CCreatorEngine* aEngine)
+    {
+    LOGSTRING("Creator: CCreatorScriptParser::ConstructL");
+    iEngine = aEngine;
+    }
+
+CCreatorScriptParser* CCreatorScriptParser::NewL(CCreatorEngine* aEngine)
+    {
+    LOGSTRING("Creator: CCreatorScriptParser::NewL");
+    CCreatorScriptParser* self = CCreatorScriptParser::NewLC(aEngine);    
+    CleanupStack::Pop();
+    return self;
+    }
+CCreatorScriptParser* CCreatorScriptParser::NewLC(CCreatorEngine* aEngine)
+    {
+    LOGSTRING("Creator: CCreatorScriptParser::NewLC");
+    CCreatorScriptParser* self = new (ELeave) CCreatorScriptParser;
+    CleanupStack::PushL(self);
+    self->ConstructL(aEngine);
+    return self;
+    }
+
+CCreatorScriptParser::~CCreatorScriptParser()
+    {
+    delete iParser;
+    if( iElementStack.Count() > 0 )
+        {
+        delete iElementStack[0].iElement;        
+        }
+    iElementStack.Reset();
+    iElementStack.Close();
+    }
+
+void CCreatorScriptParser::GetTextFileMode(RFile& aFile, TInt& aFileSize) 
+    { 
+    LOGSTRING("Creator: CCreatorScriptParser::GetTextFileMode");
+    iScriptTextFormat = EFormatANSIASCII; 
+
+    // if we are working with text files, check the type first   
+    TBuf8<4> BOM; 
+
+    // first check for UTF-16 
+    if (aFileSize >= 2 && aFile.Read(0, BOM, 2) == KErrNone) 
+        { 
+        if (BOM.Length()==2 && BOM[0]==0xFF && BOM[1]==0xFE) 
+            { 
+            iScriptTextFormat = EFormatUTF16LE; 
+            aFileSize -= 2; 
+            return; 
+            } 
+        else if (BOM.Length()==2 && BOM[0]==0xFE && BOM[1]==0xFF) 
+            { 
+            iScriptTextFormat = EFormatUTF16BE; 
+            aFileSize -= 2; 
+            return;                 
+            }       
+        }
+        // then check for UTF-8 
+    if (aFileSize >= 3 && aFile.Read(0, BOM, 3) == KErrNone) 
+        { 
+        if (BOM.Length()==3 && BOM[0]==0xEF && BOM[1]==0xBB && BOM[2]==0xBF) 
+            { 
+            iScriptTextFormat = EFormatUTF8; 
+            aFileSize -= 3; 
+            return; 
+            } 
+        }
+        
+    // none of those, seek back to beginning 
+    TInt pos(0); 
+    aFile.Seek(ESeekStart, pos); 
+    }    
+ 
+
+
+void CCreatorScriptParser::ParseL(const TDesC& aFileName)
+    {
+    LOGSTRING2("Creator: CCreatorScriptParser::ParseL: %S", &aFileName);
+    // Create and start XML-parser
+    if( iParser == 0)
+        {
+        _LIT8(KXmlMimeType, "text/xml");
+        iParser = CParser::NewL(KXmlMimeType, *this);        
+        }
+
+    RFs filesession;
+    CleanupClosePushL(filesession);
+    User::LeaveIfError( filesession.Connect() );
+    Xml::ParseL(*iParser, filesession, aFileName);
+    
+    CleanupStack::PopAndDestroy(&filesession); // filesession    
+    }
+
+void CCreatorScriptParser::ParseL(RFile& aFile)
+    {
+    LOGSTRING("Creator: CCreatorScriptParser::ParseL");
+    TInt filesize = 0;
+    aFile.Size(filesize);
+    GetTextFileMode(aFile, filesize);
+    // Create and start XML-parser    
+    if( iParser == 0)
+        {
+        _LIT8(KXmlMimeType, "text/xml");
+        iParser = CParser::NewL(KXmlMimeType, *this);        
+        }
+    Xml::ParseL(*iParser, aFile);
+    }
+
+void CCreatorScriptParser::OnStartDocumentL(const Xml::RDocumentParameters& aDocParam, TInt aErrorCode)
+    {
+    LOGSTRING2("Creator: CCreatorScriptParser::OnStartDocumentL (Error code: %d)", aErrorCode);
+    User::LeaveIfError(aErrorCode);    
+    const TDesC8& charSet = aDocParam.CharacterSetName().DesC();
+    }
+
+void CCreatorScriptParser::OnEndDocumentL(TInt aErrorCode)
+    {
+    LOGSTRING2("Creator: CCreatorScriptParser::OnEndDocumentL (Error code: %d)", aErrorCode);
+    User::LeaveIfError(aErrorCode);
+    }
+
+void CCreatorScriptParser::OnStartPrefixMappingL(   const RString& /*aPrefix*/, 
+                                                    const RString& /*aUri*/, 
+                                                    TInt aErrorCode)
+    {
+    LOGSTRING2("Creator: CCreatorScriptParser::OnStartPrefixMappingL (Error code: %d)", aErrorCode);
+    User::LeaveIfError(aErrorCode);
+    }
+
+void CCreatorScriptParser::OnEndPrefixMappingL(const RString& /*aPrefix*/, TInt aErrorCode)
+    {
+    LOGSTRING2("Creator: CCreatorScriptParser::OnEndPrefixMappingL (Error code: %d)", aErrorCode);
+    User::LeaveIfError(aErrorCode);
+    }
+void CCreatorScriptParser::OnIgnorableWhiteSpaceL(const TDesC8& /*aBytes*/, TInt aErrorCode)
+    {
+    LOGSTRING2("Creator: CCreatorScriptParser::OnIgnorableWhiteSpaceL (Error code: %d)", aErrorCode);
+    User::LeaveIfError(aErrorCode);
+    }
+void CCreatorScriptParser::OnSkippedEntityL(const RString& /*aName*/, TInt aErrorCode)
+    {
+    LOGSTRING2("Creator: CCreatorScriptParser::OnSkippedEntityL (Error code: %d)", aErrorCode);
+    User::LeaveIfError(aErrorCode);
+    }
+void CCreatorScriptParser::OnProcessingInstructionL(  const TDesC8& /*aTarget*/, 
+                                    const TDesC8& /*aData*/, 
+                                    TInt aErrorCode)
+    {
+    LOGSTRING2("Creator: CCreatorScriptParser::OnProcessingInstructionL (Error code: %d)", aErrorCode);
+    User::LeaveIfError(aErrorCode);
+    }
+void CCreatorScriptParser::OnError(TInt aErrorCode)
+    {
+    LOGSTRING2("Creator: CCreatorScriptParser::OnError: %d", aErrorCode);
+    
+    iLastError = aErrorCode;
+    
+    // Delete all elements from the stack:
+    while(iElementStack.Count() > 0 )
+        {
+        TCreatorScriptElementInfo previousElem = LastElementInfo();    
+        delete previousElem.iElement;
+        previousElem.iElement = 0;
+        iElementStack.Remove(iElementStack.Count()-1);
+        }
+    }
+TAny* CCreatorScriptParser::GetExtendedInterface(const TInt32 aUid)
+    {
+    LOGSTRING2("Creator: CCreatorScriptParser::GetExtendedInterface (UID: %d)", aUid);
+    return this;
+    }
+
+const TCreatorScriptElementInfo& CCreatorScriptParser::LastElementInfo() const
+{
+    LOGSTRING("Creator: CCreatorScriptParser::LastElementInfo");
+    if(iElementStack.Count() > 0)
+        {
+        return iElementStack[iElementStack.Count()-1];
+        }
+    return iDefaultElement;
+}
+
+/**
+ * Create an element and add attributes to it.
+ */
+void CCreatorScriptParser::OnStartElementL(  const RTagInfo& aElement,
+                                            const RAttributeArray& aAttributes,
+                                            TInt aErrorCode)
+    {
+    LOGSTRING2("Creator: CCreatorScriptParser::OnStartElementL (Error code: %d)", aErrorCode);
+    User::LeaveIfError(aErrorCode);
+    const TDesC8& elementName8 = aElement.LocalName().DesC();        
+    HBufC* elementName16 = Convert8BitTo16BitLC(elementName8);
+        
+    const TCreatorScriptElementInfo& context = LastElementInfo();
+    
+    CCreatorScriptElement* element = 0;
+    if( context.iElement )
+        {
+        HBufC* fullContext = HBufC::NewL(
+                context.iElement->Context().Length() + 
+                context.iElement->Name().Length() + 
+                2);        
+        CleanupStack::PushL(fullContext);
+        if(context.iElement->Context() != KNullDesC && 
+           context.iElement->Context().Length() > 0 )
+            {
+            fullContext->Des().Copy(context.iElement->Context());
+            _LIT(KContextSeparator, "::");
+            fullContext->Des().Append(TPtrC(KContextSeparator));
+            }
+        const TDesC& parentName = context.iElement->Name();
+        if(parentName.Length() > 0 )
+            {            
+            fullContext->Des().Append(parentName);
+            }
+        element = TCreatorScriptElementFactory::CreateElementL( iEngine,
+                                                                elementName16->Des(), 
+                                                                fullContext->Des());
+        CleanupStack::PopAndDestroy(fullContext); // fullContext        
+        }
+    else
+        {
+        element = TCreatorScriptElementFactory::CreateElementL(iEngine, elementName16->Des());        
+        }
+        
+    CleanupStack::PopAndDestroy(elementName16);
+    CleanupStack::PushL(element);
+    
+    if( element == 0 )
+        {
+        // Add NULL pointer to stack. Otherwise the stack would go out of sync. in ::OnEndElement().
+        TCreatorScriptElementInfo info(TCreatorScriptElementInfo::EStatusParsing, element);
+        iElementStack.AppendL(info);   
+        CleanupStack::Pop(element);
+        return;        
+        }
+        
+    // Add attributes to the element:
+    TInt attrCount = aAttributes.Count();
+    for(TInt i = 0; i < attrCount; ++i)
+        {
+        const RAttribute& attribute = aAttributes[i];
+        const RTagInfo& nameInfo = attribute.Attribute();
+        const TDesC8& attrName8 = nameInfo.LocalName().DesC();
+        const TDesC8& value8 = attribute.Value().DesC();
+        // Convert data to 16 bit:
+        HBufC* attrName16 = Convert8BitTo16BitLC(attrName8);
+        HBufC* value16 = Convert8BitTo16BitLC(value8);
+        CCreatorScriptAttribute* scriptAttr = CCreatorScriptAttribute::NewLC(attrName16->Des(), value16->Des());
+        element->AddAttributeL(scriptAttr);
+        CleanupStack::Pop(scriptAttr);
+        CleanupStack::PopAndDestroy(value16);
+        CleanupStack::PopAndDestroy(attrName16);
+        }
+    
+    // Save element to the stack:
+    TCreatorScriptElementInfo info(TCreatorScriptElementInfo::EStatusParsing, element);
+    iElementStack.AppendL(info);
+    CleanupStack::Pop(element);
+    }
+
+/**
+ * Executes the command if needed. Also caches the element for future use, if needed.
+ */
+void CCreatorScriptParser::OnEndElementL(const RTagInfo& /*aElement*/, TInt aErrorCode)
+    {
+    LOGSTRING2("Creator: CCreatorScriptParser::OnEndElementL (Error code: %d)", aErrorCode);
+    User::LeaveIfError(aErrorCode);
+     
+    if( iElementStack.Count() == 0 )
+        {
+        return;
+        }
+    // Get element from the stack:    
+    TCreatorScriptElementInfo elementInfo = LastElementInfo();
+    
+    if( elementInfo.iElement == 0 )
+        {
+        // Remove element from the stack:        
+        iElementStack.Remove(iElementStack.Count()-1);
+        return;
+        }
+        
+    // Execute the command if this is a command element:
+    if( elementInfo.iElement->IsCommandElement() )
+        {
+        elementInfo.iElement->ExecuteCommandL();
+        }
+    
+    // Remove element from the stack:
+    iElementStack.Remove(iElementStack.Count()-1);
+    
+    // Get the previous element from the stack:
+    if( iElementStack.Count() > 0 )
+        {
+        TCreatorScriptElementInfo previousElem = LastElementInfo();
+        
+        if( previousElem.iElement->IsRoot() )
+            {
+            // This element is not a sub-element (except of the root element, of course).        
+            if( elementInfo.iElement->IsCacheNeeded() )
+                {
+                // Add element to the cache, since it will be needed in future.            
+                elementInfo.iElement->AddToCacheL();
+                }
+            //else
+            //    {
+                // Not needed anymore, so element can be deleted:
+                delete elementInfo.iElement;
+                elementInfo.iElement = 0;
+           //     }
+            }
+        else
+            {
+            // There is a parent element (other than root), so we add this element
+            // as a sub-element fot it.
+            previousElem.iElement->AddSubElementL(elementInfo.iElement);
+            }
+        }
+    else
+        {
+        // Delete root element, which will delete recursively all sub-elements:
+        delete elementInfo.iElement;
+        elementInfo.iElement = 0;
+        }
+    }
+
+/**
+ * Add content to element.
+ */
+void CCreatorScriptParser::OnContentL(const TDesC8& aBytes, TInt aErrorCode)
+    {
+    LOGSTRING2("Creator: CCreatorScriptParser::OnContentL (Error code: %d)", aErrorCode);
+    User::LeaveIfError(aErrorCode);
+    if( iElementStack.Count() > 0 )
+        {
+        HBufC* contentData = Convert8BitTo16BitLC(aBytes);
+        TCreatorScriptElementInfo elementInfo = iElementStack[iElementStack.Count()-1];
+        if( elementInfo.iElement )
+            {
+            elementInfo.iElement->AppendContentL(*contentData);
+            }
+        CleanupStack::PopAndDestroy(contentData);
+        }
+    }
+
+HBufC16* CCreatorScriptParser::Convert8BitTo16BitLC(const TDesC8& aInput) 
+    {     
+    LOGSTRING("Creator: CCreatorScriptParser::Convert8BitTo16BitLC");
+    HBufC16* output = NULL;
+    
+    output = CnvUtfConverter::ConvertToUnicodeFromUtf8L(aInput);
+    
+    CleanupStack::PushL(output);
+    return output;          
+    } 
+
+TInt CCreatorScriptParser::GetError() const 
+{
+    return iLastError;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_virtualphonebook.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,1802 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#include "creator_virtualphonebook.h" 
+#include "creator_traces.h"
+#include "creator_contactsetcache.h"
+
+#include <CVPbkContactStoreUriArray.h>
+#include <VPbkContactStoreUris.h>
+#include <TVPbkContactStoreUriPtr.h>
+#include <MVPbkContactGroup.h>
+#include <MVPbkContactStore.h>
+#include <CVPbkContactManager.h>
+#include <MVPbkContactStoreList.h>
+#include <MVPbkContactStoreListObserver.h>
+#include <MVPbkContactOperationBase.h>
+#include <MVPbkStoreContact.h>
+#include <MVPbkContactStoreProperties.h>
+#include <MVPbkContactFieldData.h>
+#include <MVPbkFieldType.h>
+#include <MVPbkContactFieldTextData.h>
+#include <MVPbkContactFieldBinaryData.h>
+#include <MVPbkContactFieldDateTimeData.h>
+#include <CVPbkContactViewDefinition.h>
+#include <MVPbkContactView.h>
+
+#include <VPbkContactView.hrh>
+#include <VPbkEng.rsg>
+
+typedef struct {
+TInt iFieldCode;
+TInt iRandomType;
+} FieldInfo;
+static const TInt RND_TYPE_UNDEF = -99;
+FieldInfo CreatorVPbkMiscTextFields[] = {        
+        {R_VPBK_FIELD_TYPE_FIRSTNAME, (TInt) CCreatorEngine::EFirstName},
+        {R_VPBK_FIELD_TYPE_FIRSTNAMEREADING, (TInt) CCreatorEngine::EFirstName},
+        {R_VPBK_FIELD_TYPE_LASTNAME, (TInt) CCreatorEngine::ESurname},
+        {R_VPBK_FIELD_TYPE_LASTNAMEREADING, (TInt) CCreatorEngine::ESurname},
+        {R_VPBK_FIELD_TYPE_COMPANYNAME, (TInt) CCreatorEngine::ECompany},
+        {R_VPBK_FIELD_TYPE_JOBTITLE, (TInt) CCreatorEngine::EJobTitle},
+        {R_VPBK_FIELD_TYPE_PREFIX, (TInt) CCreatorEngine::EPrefix},
+        {R_VPBK_FIELD_TYPE_SUFFIX, (TInt) CCreatorEngine::ESuffix},
+        {R_VPBK_FIELD_TYPE_SECONDNAME, (TInt) CCreatorEngine::EFirstName},
+        {R_VPBK_FIELD_TYPE_ADDRLABELGEN, (TInt) CCreatorEngine::EAddress},
+        {R_VPBK_FIELD_TYPE_ADDRPOGEN, (TInt) CCreatorEngine::EPobox},
+        {R_VPBK_FIELD_TYPE_ADDREXTGEN, (TInt) CCreatorEngine::EAddress},
+        {R_VPBK_FIELD_TYPE_ADDRSTREETGEN, (TInt) CCreatorEngine::EAddress},
+        {R_VPBK_FIELD_TYPE_ADDRLOCALGEN, (TInt) CCreatorEngine::ECity},
+        {R_VPBK_FIELD_TYPE_ADDRREGIONGEN, (TInt) CCreatorEngine::EState},
+        {R_VPBK_FIELD_TYPE_ADDRPOSTCODEGEN, (TInt) CCreatorEngine::EPostcode},
+        {R_VPBK_FIELD_TYPE_ADDRCOUNTRYGEN, (TInt) CCreatorEngine::ECountry},
+        {R_VPBK_FIELD_TYPE_ADDRLABELHOME, (TInt) CCreatorEngine::EAddress},
+        {R_VPBK_FIELD_TYPE_ADDRPOHOME, (TInt) CCreatorEngine::EPobox},
+        {R_VPBK_FIELD_TYPE_ADDREXTHOME, (TInt) CCreatorEngine::EAddress},
+        {R_VPBK_FIELD_TYPE_ADDRSTREETHOME, (TInt) CCreatorEngine::EAddress},
+        {R_VPBK_FIELD_TYPE_ADDRLOCALHOME, (TInt) CCreatorEngine::ECity},
+        {R_VPBK_FIELD_TYPE_ADDRREGIONHOME, (TInt) CCreatorEngine::EState},
+        {R_VPBK_FIELD_TYPE_ADDRPOSTCODEHOME, (TInt) CCreatorEngine::EPostcode},
+        {R_VPBK_FIELD_TYPE_ADDRCOUNTRYHOME, (TInt) CCreatorEngine::ECountry},
+        {R_VPBK_FIELD_TYPE_ADDRLABELWORK, (TInt) CCreatorEngine::EAddress},
+        {R_VPBK_FIELD_TYPE_ADDRPOWORK, (TInt) CCreatorEngine::EPobox},
+        {R_VPBK_FIELD_TYPE_ADDREXTWORK, (TInt) CCreatorEngine::EAddress},
+        {R_VPBK_FIELD_TYPE_ADDRSTREETWORK, (TInt) CCreatorEngine::EAddress},
+        {R_VPBK_FIELD_TYPE_ADDRLOCALWORK, (TInt) CCreatorEngine::ECity},
+        {R_VPBK_FIELD_TYPE_ADDRREGIONWORK, (TInt) CCreatorEngine::EState},
+        {R_VPBK_FIELD_TYPE_ADDRPOSTCODEWORK, (TInt) CCreatorEngine::EPostcode},
+        {R_VPBK_FIELD_TYPE_ADDRCOUNTRYWORK, (TInt) CCreatorEngine::ECountry},
+        {R_VPBK_FIELD_TYPE_POC, (TInt) CCreatorEngine::EPhoneNumber},
+        {R_VPBK_FIELD_TYPE_SWIS, (TInt) CCreatorEngine::EPhoneNumber},
+        {R_VPBK_FIELD_TYPE_SIP, (TInt) CCreatorEngine::EPhoneNumber},
+        {R_VPBK_FIELD_TYPE_DTMFSTRING, (TInt) CCreatorEngine::EFirstName},
+        {R_VPBK_FIELD_TYPE_NOTE,(TInt)  CCreatorEngine::EMemoText},
+        {R_VPBK_FIELD_TYPE_MIDDLENAME, (TInt) CCreatorEngine::EFirstName},
+        {R_VPBK_FIELD_TYPE_DEPARTMENT, (TInt) CCreatorEngine::ECompany},
+        {R_VPBK_FIELD_TYPE_ASSTNAME, (TInt) CCreatorEngine::EFirstName},
+        {R_VPBK_FIELD_TYPE_SPOUSE, (TInt) CCreatorEngine::EFirstName},
+        {R_VPBK_FIELD_TYPE_CHILDREN, (TInt) CCreatorEngine::EFirstName},
+        {R_VPBK_FIELD_TYPE_SYNCCLASS, RND_TYPE_UNDEF},
+        {R_VPBK_FIELD_TYPE_LOCPRIVACY, RND_TYPE_UNDEF},
+        {R_VPBK_FIELD_TYPE_GENLABEL, (TInt) CCreatorEngine::EFirstName},
+        {R_VPBK_FIELD_TYPE_WVADDRESS, (TInt) CCreatorEngine::EPhoneNumber},
+        {R_VPBK_FIELD_TYPE_RINGTONE, RND_TYPE_UNDEF},
+        {R_VPBK_FIELD_TYPE_THUMBNAILPIC, RND_TYPE_UNDEF},
+        {R_VPBK_FIELD_TYPE_CALLEROBJTEXT, (TInt) CCreatorEngine::EFirstName}
+        };
+                    
+TInt CreatorVPbkBinaryFields[] = {
+        R_VPBK_FIELD_TYPE_CALLEROBJIMG//,
+        //R_VPBK_FIELD_TYPE_THUMBNAILPATH
+        };
+
+TInt CreatorVPbkDateTimeFields[] = {
+        R_VPBK_FIELD_TYPE_ANNIVERSARY
+        };
+
+//----------------------------------------------------------------------------
+TInt CreatorVPbkPhoneNumberFields[] =
+    {
+    R_VPBK_FIELD_TYPE_LANDPHONEGEN,
+    R_VPBK_FIELD_TYPE_LANDPHONEHOME,
+    R_VPBK_FIELD_TYPE_LANDPHONEWORK,                        
+    R_VPBK_FIELD_TYPE_MOBILEPHONEGEN,
+    R_VPBK_FIELD_TYPE_MOBILEPHONEHOME,
+    R_VPBK_FIELD_TYPE_MOBILEPHONEWORK,
+    R_VPBK_FIELD_TYPE_FAXNUMBERGEN,
+    R_VPBK_FIELD_TYPE_FAXNUMBERHOME,
+    R_VPBK_FIELD_TYPE_FAXNUMBERWORK,
+    R_VPBK_FIELD_TYPE_PAGERNUMBER,           
+    R_VPBK_FIELD_TYPE_VIDEONUMBERGEN,
+    R_VPBK_FIELD_TYPE_VIDEONUMBERHOME,
+    R_VPBK_FIELD_TYPE_VIDEONUMBERWORK,
+    R_VPBK_FIELD_TYPE_VOIPGEN,
+    R_VPBK_FIELD_TYPE_VOIPHOME,
+    R_VPBK_FIELD_TYPE_VOIPWORK,
+    R_VPBK_FIELD_TYPE_ASSTPHONE,
+    R_VPBK_FIELD_TYPE_CARPHONE
+    };
+
+TInt CreatorVPbkUrlFields[] =
+    {
+    R_VPBK_FIELD_TYPE_URLGEN,
+    R_VPBK_FIELD_TYPE_URLHOME,
+    R_VPBK_FIELD_TYPE_URLWORK
+    };
+
+TInt CreatorVPbkEmailFields[] =
+    {
+    R_VPBK_FIELD_TYPE_EMAILGEN,
+    R_VPBK_FIELD_TYPE_EMAILHOME,
+    R_VPBK_FIELD_TYPE_EMAILWORK
+    };
+
+//----------------------------------------------------------------------------
+
+CVirtualPhonebookParameters::CVirtualPhonebookParameters()
+    {
+    LOGSTRING("Creator: CVirtualPhonebookParameters::CVirtualPhonebookParameters");
+    iGroupName = HBufC::New(KPhonebookFieldLength);  
+    }
+
+CVirtualPhonebookParameters::~CVirtualPhonebookParameters()
+    {
+    LOGSTRING("Creator: CVirtualPhonebookParameters::~CVirtualPhonebookParameters");
+
+    delete iGroupName;   
+    iContactFields.ResetAndDestroy();
+    iContactFields.Close();
+    iLinkIds.Reset();
+    iLinkIds.Close();
+    }
+
+void CVirtualPhonebookParameters::ParseL(CCommandParser* /*parser*/, TParseParams /*aCase = 0*/)
+	{
+	}
+
+TInt CVirtualPhonebookParameters::ScriptLinkId() const
+    {
+    return iLinkId;
+    }
+
+void CVirtualPhonebookParameters::SetScriptLinkId(TInt aLinkId)
+    {
+    iLinkId = aLinkId;
+    }
+
+//----------------------------------------------------------------------------
+
+CCreatorVirtualPhonebook* CCreatorVirtualPhonebook::NewL(CCreatorEngine* aEngine)
+    {
+    CCreatorVirtualPhonebook* self = CCreatorVirtualPhonebook::NewLC(aEngine);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CCreatorVirtualPhonebook* CCreatorVirtualPhonebook::NewLC(CCreatorEngine* aEngine)
+    {
+    CCreatorVirtualPhonebook* self = new (ELeave) CCreatorVirtualPhonebook;
+    CleanupStack::PushL(self);
+    self->ConstructL(aEngine);
+    return self;
+    }
+
+CCreatorVirtualPhonebook::CCreatorVirtualPhonebook()
+    {    
+    iAddAllFields = EFalse;
+    }
+
+void CCreatorVirtualPhonebook::ConstructL(CCreatorEngine* aEngine)
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::ConstructL");
+
+    iContactLinkArray = CVPbkContactLinkArray::NewL();
+    iContactsToDelete = CVPbkContactLinkArray::NewL();
+    iContactGroupsToDelete = CVPbkContactLinkArray::NewL();
+    
+    iEngine = aEngine;
+    SetDefaultParameters();
+    
+    // initialize virtual phonebook
+    CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewLC();
+    uriArray->AppendL( TVPbkContactStoreUriPtr(VPbkContactStoreUris::DefaultCntDbUri()));
+    iContactManager = CVPbkContactManager::NewL( *uriArray, &CCoeEnv::Static()->FsSession());
+    CleanupStack::PopAndDestroy(uriArray);
+    
+    //When the contact manager is created, the stores is opened
+    MVPbkContactStoreList& storeList = iContactManager->ContactStoresL();
+    
+    iWaiter = CAsyncWaiter::NewL();
+
+    //MVPbkContactStoreListObserver must give as parameter    
+    storeList.OpenAllL(*this);
+    // wait for OpenComplete() callback
+    iWaiter->StartAndWait();
+    
+    _LIT(dbUri, "cntdb://c:contacts.cdb");
+    const TVPbkContactStoreUriPtr uri = TVPbkContactStoreUriPtr(dbUri);
+       
+    iStore = storeList.Find(uri);    
+    iOpCounter = 0;    
+    }
+
+TBool CCreatorVirtualPhonebook::IsActive()
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::IsActive");
+    return iOperation != NULL;
+    }
+
+void CCreatorVirtualPhonebook::CancelOperation()
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::CancelOperation");
+    iCancelCbRequested = ETrue;    
+    }
+
+CCreatorVirtualPhonebook::~CCreatorVirtualPhonebook()
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::~CCreatorVirtualPhonebook");
+    
+    // this is done only once per phonebook operation
+    if ( iContactsToDelete && iContactsToDelete->Count() )
+        {
+        TRAP_IGNORE( StoreLinksForDeleteL( *iContactsToDelete, KUidDictionaryUidContacts ) );
+        }
+    delete iContactsToDelete;
+    if ( iContactGroupsToDelete && iContactGroupsToDelete->Count() )
+        {
+        TRAP_IGNORE( StoreLinksForDeleteL( *iContactGroupsToDelete, KUidDictionaryUidContactGroups ) );
+        }
+    delete iContactGroupsToDelete;
+    
+    iPreviousDeleteLinks.ResetAndDestroy();
+    
+    delete iOperation;
+    
+    TInt err = 0;
+    TRAP(err, CompactPbkDatabaseL( ETrue ));
+
+    if(iContactResults)
+    	{
+    	delete iContactResults;
+    	}
+    
+    delete iContactLinkArray;
+    delete iContactGroupsInStore;
+    
+    if(iContactManager)
+    	{
+    	TRAP(err, iContactManager->ContactStoresL().CloseAll(*this));
+    	delete iContactManager;
+    	}
+    if(iWaiter)
+    	{
+    	delete iWaiter;    
+    	}
+    if (iParameters)
+    	{
+        delete iParameters;
+    	}
+    }
+
+//----------------------------------------------------------------------------
+TBool CCreatorVirtualPhonebook::AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries)
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::AskDataFromUserL");
+    TBool ret = CCreatorPhonebookBase::AskDataFromUserL(aCommand, aNumberOfEntries);
+   
+    if(ret && aCommand == ECmdCreatePhoneBookEntryContacts && !iDefaultFieldsSelected)    
+        {
+        iAddAllFields = iEngine->YesNoQueryDialogL(_L("Add all the other fields to contacts?"));
+        }
+    return ret;
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorVirtualPhonebook::DeleteAllL()
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::DeleteAllL");
+    
+    // Delete all contacts, not contact groups
+    
+    //get field types
+    const MVPbkFieldTypeList& fieldList = iStore->StoreProperties().SupportedFields();
+        
+    // get all contact links, results will be set to iContactResults
+    MVPbkContactOperationBase* operation = iContactManager->FindL( _L(""), fieldList , *this );
+    if ( operation )
+        {
+        iWaiter->StartAndWait(); //Making asynchronous FindL to synchronous
+        delete operation;
+        }
+    
+    while( iContactResults->Count() && 
+           !iCancelCbRequested &&
+           HasOtherThanGroupsL( iContactResults ) )
+        {
+        // delete all found contacts
+        DeleteContactsL( iContactResults, EFalse );
+        
+        if ( !iCancelCbRequested )
+            {
+            // find next set of contacts to delete
+            MVPbkContactOperationBase* operation = iContactManager->FindL( _L(""), fieldList , *this );
+            if ( operation )
+                {
+                iWaiter->StartAndWait(); //Making asynchronous FindL to synchronous
+                delete operation;
+                }
+            }
+        }
+    
+    if ( iCancelCbRequested && iEngine )
+        {
+        // User cancelled, must callback to finish terminatio sequence
+        iEngine->CancelComplete();
+        }
+    else
+        {
+        // contacts deleted, remove the Creator internal contact registry
+        // (no callback required)
+        CDictionaryFileStore* store = iEngine->FileStoreLC();
+        if ( store )
+            {
+            store->Remove( KUidDictionaryUidContacts );
+            store->CommitL();        
+            }
+        CleanupStack::PopAndDestroy( store );
+        }    
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorVirtualPhonebook::DeleteAllCreatedByCreatorL()
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::DeleteAllCreatedByCreatorL");
+    DeleteItemsCreatedWithCreatorL( KUidDictionaryUidContacts );
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorVirtualPhonebook::DeleteAllGroupsL()
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::DeleteAllGroupsL");
+    User::LeaveIfNull( iStore );
+    MVPbkContactLinkArray* groups = iStore->ContactGroupsLC();
+    DeleteContactsL( groups, ETrue );
+    CleanupStack::PopAndDestroy(); // cannot use groups as parameter
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorVirtualPhonebook::DeleteAllGroupsCreatedByCreatorL()
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::DeleteAllGroupsCreatedByCreatorL");
+    DeleteItemsCreatedWithCreatorL( KUidDictionaryUidContactGroups );
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorVirtualPhonebook::DeleteContactsL( MVPbkContactLinkArray* aContacts, TBool aGroup )
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::DeleteContactsL");
+    const MVPbkContactLink* link( NULL );
+    delete iOperation;
+    iOperation = NULL;
+    TInt i(0);
+    while ( aContacts && i < aContacts->Count() && !iCancelCbRequested )
+        {
+        link = &aContacts->At( i++ );
+        if ( aGroup == IsContactGroupL( *link ) )
+            {
+            iOperation = iContactManager->RetrieveContactL( *link, *this );
+            // see VPbkSingleContactOperationComplete
+            if ( iOperation )
+                {
+                iWaiter->StartAndWait();
+                delete iOperation;
+                iOperation = NULL;
+                }            
+            }
+        link = NULL;
+        }
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorVirtualPhonebook::DeleteItemsCreatedWithCreatorL( TUid aStoreUid )
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::DeleteItemsCreatedWithCreatorL");
+    __ASSERT_ALWAYS( aStoreUid == KUidDictionaryUidContacts || 
+                     aStoreUid == KUidDictionaryUidContactGroups,
+                     User::Panic( _L("CCreatorVPb"), KErrArgument ) );
+    CDictionaryFileStore* store = iEngine->FileStoreLC();
+    User::LeaveIfNull( store );
+    if ( store->IsPresentL( aStoreUid ) )
+        {
+        TRAP_IGNORE( DoDeleteItemsCreatedWithCreatorL( aStoreUid, store ) );
+
+        if ( iCancelCbRequested && iEngine )
+            {
+            iEngine->CancelComplete();
+            }
+        else
+            {
+            // contacts deleted, remove the Creator internal contact registry
+            store->Remove( aStoreUid );
+            store->CommitL();            
+            }
+        }
+    CleanupStack::PopAndDestroy( store );
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorVirtualPhonebook::DoDeleteItemsCreatedWithCreatorL( TUid aStoreUid, CDictionaryFileStore* aStore )
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::DoDeleteItemsCreatedWithCreatorL");
+    RDictionaryReadStream in;
+    in.OpenLC( *aStore, aStoreUid );
+    MVPbkContactLinkArray* contactsToDelete = NULL;
+    // fetch contact links from store
+    while ( ( contactsToDelete = iContactManager->CreateLinksLC( in ) ) != NULL && // will leave with KErrEof
+            !iCancelCbRequested ) 
+        {
+        DeleteContactsL( contactsToDelete, aStoreUid == KUidDictionaryUidContactGroups );
+        // PopAndDestroy for contactsToDelete causes E32USER-CBase:90
+        // however there is no mem-leak even if not deleting contactsToDelete object
+        }
+    CleanupStack::PopAndDestroy(); // in
+    }
+
+//----------------------------------------------------------------------------
+TBool CCreatorVirtualPhonebook::HasOtherThanGroupsL( MVPbkContactLinkArray* aContacts )
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::HasOtherThanGroupsL");
+    TBool result( EFalse );
+    TInt i(0);
+    while ( aContacts && i < aContacts->Count() && !iCancelCbRequested && !result )
+        {
+        if ( !IsContactGroupL( aContacts->At( i++ ) ) )
+            {
+            result = ETrue;
+            }
+        }
+    return result;
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorVirtualPhonebook::VPbkSingleContactOperationComplete(
+                MVPbkContactOperationBase& /*aOperation*/,
+                MVPbkStoreContact* aContact )
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::VPbkSingleContactOperationComplete");
+    
+    // This callback is currently used only for deleting a contact
+    // See DeleteContactsL
+    
+    TRAP_IGNORE( 
+            aContact->PushL();
+            aContact->DeleteL( *this );
+            CleanupStack::PopAndDestroy( aContact );
+        );
+    }
+
+void CCreatorVirtualPhonebook::VPbkSingleContactOperationFailed(
+                MVPbkContactOperationBase& /*aOperation*/, 
+                TInt /*aError*/ )
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::VPbkSingleContactOperationFailed");
+    iWaiter->Cancel();
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorVirtualPhonebook::StoreLinksForDeleteL( MVPbkContactLinkArray& aLinks, TUid aStoreUid )
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::StoreLinksForDeleteL");
+    CDictionaryFileStore* store = iEngine->FileStoreLC();
+    User::LeaveIfNull( store );
+    
+    // backup previous contact links from store
+    // otherwise they would be overwritten when calling out.WriteL
+    MVPbkContactLinkArray* previousLinks( NULL );
+    if ( store->IsPresentL( aStoreUid ) )
+        {
+        RDictionaryReadStream in;
+        in.OpenLC( *store, aStoreUid );        
+        TRAP_IGNORE( 
+            while ( ( previousLinks = iContactManager->CreateLinksLC( in )) != NULL ) // will leave with KErrEof
+                {
+                CleanupStack::Pop(); // previousLinks
+                iPreviousDeleteLinks.Append( previousLinks );
+                previousLinks = NULL;
+                }
+            );
+        CleanupStack::PopAndDestroy(); // in
+        }
+
+    RDictionaryWriteStream out;       
+    out.AssignLC( *store, aStoreUid );
+    
+    // restore previous links
+    for ( TInt i = 0; i < iPreviousDeleteLinks.Count(); i++ )
+        {
+        out.WriteL( *iPreviousDeleteLinks[i]->PackLC() );
+        CleanupStack::PopAndDestroy(); // PackLC            
+        }
+    iPreviousDeleteLinks.ResetAndDestroy();
+    
+    // write new links
+    out.WriteL( *aLinks.PackLC() );
+    out.CommitL();
+    CleanupStack::PopAndDestroy(); // aLinks.PackLC
+    CleanupStack::PopAndDestroy(); // out
+    
+    store->CommitL();
+    CleanupStack::PopAndDestroy( store );
+    }
+
+//----------------------------------------------------------------------------
+void CCreatorVirtualPhonebook::AddFieldToParamsL(TInt aFieldType, const TDesC& aData)
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::AddFieldToParamsL(TInt aFieldType, const TDesC& aData)");
+    if(iParameters == 0)
+        return;
+    CCreatorContactField* field = CCreatorContactField::NewL(aFieldType, aData);
+    CleanupStack::PushL(field);
+    iParameters->iContactFields.AppendL(field);
+    CleanupStack::Pop();
+    }
+
+void CCreatorVirtualPhonebook::AddFieldToParamsL(TInt aFieldType, const TDesC8& aData)
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::AddFieldToParamsL(TInt aFieldType, const TDesC8& aData)");
+    if(iParameters == 0)
+        return;
+    CCreatorContactField* field = CCreatorContactField::NewL(aFieldType, aData);
+    CleanupStack::PushL(field);
+    iParameters->iContactFields.AppendL(field);
+    CleanupStack::Pop();
+    }
+
+void CCreatorVirtualPhonebook::AddFieldToParamsL(TInt aFieldType, const TTime& aData)
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::AddFieldToParamsL(TInt aFieldType, const TTime& aData)");
+    if(iParameters == 0)
+        return;
+    CCreatorContactField* field = CCreatorContactField::NewL(aFieldType, aData);
+    CleanupStack::PushL(field);
+    iParameters->iContactFields.AppendL(field);
+    CleanupStack::Pop();
+    }
+       
+//----------------------------------------------------------------------------
+TInt CCreatorVirtualPhonebook::iPhoneNumberFields[] =
+    {
+    R_VPBK_FIELD_TYPE_LANDPHONEGEN,
+    R_VPBK_FIELD_TYPE_LANDPHONEHOME,
+    R_VPBK_FIELD_TYPE_LANDPHONEWORK,                        
+    R_VPBK_FIELD_TYPE_MOBILEPHONEGEN,
+    R_VPBK_FIELD_TYPE_MOBILEPHONEHOME,
+    R_VPBK_FIELD_TYPE_MOBILEPHONEWORK,
+    R_VPBK_FIELD_TYPE_FAXNUMBERGEN,
+    R_VPBK_FIELD_TYPE_FAXNUMBERHOME,
+    R_VPBK_FIELD_TYPE_FAXNUMBERWORK,
+    R_VPBK_FIELD_TYPE_PAGERNUMBER,           
+    R_VPBK_FIELD_TYPE_VIDEONUMBERGEN,
+    R_VPBK_FIELD_TYPE_VIDEONUMBERHOME,
+    R_VPBK_FIELD_TYPE_VIDEONUMBERWORK,
+    R_VPBK_FIELD_TYPE_VOIPGEN,
+    R_VPBK_FIELD_TYPE_VOIPHOME,
+    R_VPBK_FIELD_TYPE_VOIPWORK,
+    R_VPBK_FIELD_TYPE_ASSTPHONE,
+    R_VPBK_FIELD_TYPE_CARPHONE
+    };
+
+TInt CCreatorVirtualPhonebook::iUrlFields[] =
+    {
+    R_VPBK_FIELD_TYPE_URLGEN,
+    R_VPBK_FIELD_TYPE_URLHOME,
+    R_VPBK_FIELD_TYPE_URLWORK
+    };
+
+TInt CCreatorVirtualPhonebook::iEmailFields[] =
+    {
+    R_VPBK_FIELD_TYPE_EMAILGEN,
+    R_VPBK_FIELD_TYPE_EMAILHOME,
+    R_VPBK_FIELD_TYPE_EMAILWORK
+    };
+
+void CCreatorVirtualPhonebook::InitializeContactParamsL(/*CCreatorModuleBaseParameters* aParameters*/)
+    {
+    LOGSTRING("Creator: CCreatorPhonebook::InitializeContactParamsL");        
+    iParameters = new (ELeave) CVirtualPhonebookParameters;
+        
+    iParameters->iNumberOfPhoneNumberFields = iNumberOfPhoneNumberFields;
+    iParameters->iNumberOfURLFields = iNumberOfURLFields;
+    iParameters->iNumberOfEmailAddressFields = iNumberOfEmailAddressFields;       
+        
+    TPtrC firstname = iEngine->RandomString(CCreatorEngine::EFirstName);
+    TPtrC lastname  = iEngine->RandomString(CCreatorEngine::ESurname);               
+                    
+    if( iAddAllFields )
+        {
+        // Add text fields:
+        TInt textFieldCount = sizeof(CreatorVPbkMiscTextFields) / sizeof(FieldInfo);
+        for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex )
+            {                
+            CCreatorContactField* field = CCreatorContactField::NewL(CreatorVPbkMiscTextFields[tfIndex].iFieldCode, KNullDesC);
+            CleanupStack::PushL(field);
+            field->SetRandomParametersL(CCreatorContactField::ERandomLengthDefault);
+            iParameters->iContactFields.AppendL(field);
+            CleanupStack::Pop(field);
+            }
+            
+        // Add binary fields:
+        TInt binFieldCount = sizeof(CreatorVPbkBinaryFields) / sizeof(TInt);
+        for( TInt bfIndex = 0; bfIndex < binFieldCount; ++bfIndex )
+            {                
+            CCreatorContactField* field = CCreatorContactField::NewL(CreatorVPbkBinaryFields[bfIndex], KNullDesC8);
+            CleanupStack::PushL(field);
+            field->SetRandomParametersL(CCreatorContactField::ERandomLengthDefault);
+            iParameters->iContactFields.AppendL(field);
+            CleanupStack::Pop(field);
+            }
+            
+        // Add date-time fields:
+        TInt dtFieldCount = sizeof(CreatorVPbkDateTimeFields) / sizeof(TInt);
+        for( TInt dtIndex = 0; dtIndex < dtFieldCount; ++dtIndex )
+            {
+            AddFieldToParamsL(CreatorVPbkDateTimeFields[dtIndex], iEngine->RandomDate(CCreatorEngine::EDateFuture));
+            }
+
+        AddFieldToParamsL(R_VPBK_FIELD_TYPE_CALLEROBJIMG, KNullDesC8);        
+        AddFieldToParamsL(R_VPBK_FIELD_TYPE_THUMBNAILPIC, KNullDesC8);        
+        AddFieldToParamsL(R_VPBK_FIELD_TYPE_CALLEROBJTEXT, firstname);
+        }
+    else
+        {                      
+        AddFieldToParamsL(R_VPBK_FIELD_TYPE_FIRSTNAME, firstname);            
+        AddFieldToParamsL(R_VPBK_FIELD_TYPE_LASTNAME, lastname);            
+        }
+                    
+    // Phone numbers:
+    TInt arraySize = sizeof(iPhoneNumberFields)/sizeof(TInt);
+    TInt index = 0;
+    for (TInt i=0; i<iParameters->iNumberOfPhoneNumberFields; i++ )
+        {            
+        if( index >= arraySize )
+            {
+            index = 0;
+            }
+        if( arraySize > 0  )
+            {
+            CCreatorContactField* field = CCreatorContactField::NewL(iPhoneNumberFields[index], KNullDesC);
+            CleanupStack::PushL(field);
+            field->SetRandomParametersL(CCreatorContactField::ERandomLengthDefault);
+            iParameters->iContactFields.AppendL(field);
+            CleanupStack::Pop(field);
+            }
+        ++index;
+        }
+            
+       
+    // URLs:
+    arraySize = sizeof(iUrlFields)/sizeof(TInt);
+    index = 0;
+    for( TInt i = 0; i < iParameters->iNumberOfURLFields; ++i)
+        {
+        if( index >= arraySize )
+            {
+            index = 0;
+            }
+        if( arraySize > 0  )
+            {
+            CCreatorContactField* field = CCreatorContactField::NewL(iUrlFields[index], KNullDesC);
+            CleanupStack::PushL(field);
+            field->SetRandomParametersL(CCreatorContactField::ERandomLengthDefault);
+            iParameters->iContactFields.AppendL(field);
+            CleanupStack::Pop(field);            
+            }
+        ++index;
+        }
+                    
+    // EMail addresses:
+    arraySize = sizeof(iEmailFields)/sizeof(TInt);
+    index = 0;
+    for( TInt i = 0; i < iParameters->iNumberOfEmailAddressFields; ++i)
+        {
+        if( index >= arraySize )
+            {
+            index = 0;
+            }
+        if( arraySize > 0  )
+            {
+            CCreatorContactField* field = CCreatorContactField::NewL(iEmailFields[index], KNullDesC);
+            CleanupStack::PushL(field);
+            field->SetRandomParametersL(CCreatorContactField::ERandomLengthDefault);
+            iParameters->iContactFields.AppendL(field);
+            CleanupStack::Pop(field);               
+            }
+        ++index;
+        }
+    }
+
+TInt CCreatorVirtualPhonebook::CreateContactEntryL(CCreatorModuleBaseParameters *aParameters)
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::CreateContactEntryL");
+    
+    delete iParameters;
+    iParameters = 0;
+    CVirtualPhonebookParameters* parameters = 0;
+    
+    if( aParameters == 0 )
+        {
+        InitializeContactParamsL();
+        parameters = iParameters;
+        }
+    else
+        {
+        parameters = (CVirtualPhonebookParameters*) aParameters;
+        }
+    
+    TInt err = KErrNone;
+
+    // create a new contact item
+    MVPbkStoreContact* newContact = iStore->CreateNewContactLC();
+    for( TInt i = 0; i < parameters->iContactFields.Count(); ++i )
+        {
+        CCreatorContactField* cField = parameters->iContactFields[i];
+        if( cField )
+            {
+            cField->AddToContactL(iEngine, *newContact, this);
+            }
+        }
+
+    RArray<MVPbkStoreContact*> contacts;
+    CleanupClosePushL( contacts );    
+    contacts.Append(newContact);        
+    
+    delete iOperation;
+    iOperation = NULL;
+    iLastError = KErrNone;
+    iOperation = iContactManager->CommitContactsL( contacts.Array(), *this );    
+    if ( iOperation )
+        {
+        iWaiter->StartAndWait();//Making asynchronous CommitContctsL to synchronous
+        delete iOperation;
+        iOperation = NULL;
+        }
+    User::LeaveIfError(iLastError);
+    
+    // store the link to contact, so that Creator is able to delete
+    // it when user requests deletion of contacts that are created by Creator 
+    MVPbkContactLink* linkToContact = newContact->CreateLinkLC();
+    if( linkToContact )
+        {
+        iContactsToDelete->AppendL( linkToContact );
+        CleanupStack::Pop(); // linkToContact
+        
+        // If this contact has a link id in script (i.e. belongs to a contact-set), we must cache the contact id:
+        if( parameters->ScriptLinkId() > 0 )
+            {                
+            RPointerArray<CCreatorContactSet>& contactsets = ContactLinkCache::Instance()->ContactSets();
+            TBool setFound(EFalse);
+            for(TInt i = 0; i < contactsets.Count(); ++i )
+                {
+                if( contactsets[i]->LinkId() == parameters->ScriptLinkId())
+                    {
+                    MVPbkContactLink* linkToContact = newContact->CreateLinkLC();
+                    if( linkToContact )
+                        {
+                        contactsets[i]->AppendL(linkToContact);
+                        iContactLinkArray->AppendL(linkToContact);
+                        CleanupStack::Pop(); // linkToContact
+                        }
+                    setFound = ETrue;
+                    break;
+                    }
+                }
+            if( !setFound )
+                {
+                LOGSTRING2("Error: Contact set id %d not found.", parameters->ScriptLinkId());
+                }
+            }
+        }
+    
+    CleanupStack::Pop();//contacts
+    contacts.Close();
+    CompactPbkDatabaseL();
+    CleanupStack::PopAndDestroy();//newContact
+    if ( iCancelCbRequested && iEngine ) iEngine->CancelComplete();
+    return err;
+    }
+
+
+//----------------------------------------------------------------------------
+
+void CCreatorVirtualPhonebook::AddImageToContactL(MVPbkStoreContact& aContact, TInt aFieldResId, const TDesC& aFileName)
+    {
+    LOGSTRING("Creator: CCreatorPhonebook::AddImageToContactL");
+    CPbk2ImageManager* imageMgr = CPbk2ImageManager::NewL(*iContactManager);
+    CleanupStack::PushL(imageMgr);
+    const MVPbkFieldTypeList& fieldList = aContact.ParentStore().StoreProperties().SupportedFields();        
+    const MVPbkFieldType* fieldType = fieldList.Find(aFieldResId);
+    if( fieldType == 0 )
+        {
+        return;
+        }
+    MPbk2ImageOperation* imageOp = 0;
+    TRAPD(err, imageOp = imageMgr->SetImageAsyncL(aContact, *fieldType, *this, aFileName));   
+    if( err == KErrNone)
+        {
+        if (imageOp)
+            {
+            CleanupDeletePushL( imageOp );
+            iWaiter->StartAndWait(); // Making asynchronous SetImageAsyncL to synchronous
+            CleanupStack::Pop(imageOp);
+            delete imageOp;
+            }
+        }    
+    else if(err != KErrNotSupported)
+        {
+        User::Leave(err);
+        }
+    CleanupStack::PopAndDestroy(imageMgr);        
+    }
+
+// Checks if the link is a group or not
+TBool CCreatorVirtualPhonebook::IsContactGroupL(const MVPbkContactLink& aLink)
+	{
+	LOGSTRING("Creator: CCreatorPhonebook::IsContactGroupL");
+	if( iStore )
+		{
+		delete iContactGroupsInStore;
+		iContactGroupsInStore = 0;
+		// Save contact group links here
+		iContactGroupsInStore = iStore->ContactGroupsLC();
+		CleanupStack::Pop();
+		}
+		
+	if( iContactGroupsInStore )
+		{
+		// Loop all the groups and check if any of them matches to the given link.
+		for( TInt i = 0; i < iContactGroupsInStore->Count(); ++i )
+			{
+			if( (*iContactGroupsInStore)[i].IsSame(aLink) )
+				return ETrue;
+			}
+		}
+	return EFalse;
+	}
+
+TInt CCreatorVirtualPhonebook::CreateGroupEntryL(CCreatorModuleBaseParameters *aParameters)
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::CreateGroupEntryL");
+    delete iParameters;
+    iParameters = 0;
+    
+    CVirtualPhonebookParameters* parameters = (CVirtualPhonebookParameters*) aParameters;
+    
+    if( !parameters )
+        {
+        iParameters = new (ELeave) CVirtualPhonebookParameters;
+        iParameters->iContactsInGroup = iContactsInGroup;
+        iParameters->iGroupName->Des().Copy( iEngine->RandomString(CCreatorEngine::EGroupName) );
+        iParameters->iGroupName->Des().Append( _L(" #") );
+        iParameters->iGroupName->Des().AppendNum( iEngine->RandomNumber(1000, 9999) );
+        parameters = iParameters;
+        }
+
+    TInt err = KErrNone;
+ 
+    // create a new contact group    
+    MVPbkContactGroup* newGroup = iStore->CreateNewContactGroupLC();
+    
+    newGroup->SetGroupLabelL(parameters->iGroupName->Des());
+        
+    // define amounts of contacts to be added to the group
+    TInt amountOfContactsToBeAdded = 0;
+    if (parameters->iContactsInGroup == KCreateRandomAmountOfGroups)
+    	{
+        amountOfContactsToBeAdded = iEngine->RandomNumber(30);
+    	}
+    else 
+    	{
+        amountOfContactsToBeAdded = parameters->iContactsInGroup;
+    	}
+    
+    if( parameters->iLinkIds.Count() > 0 )
+        {
+        for( TInt i = 0; i < parameters->iLinkIds.Count(); ++i )
+            {
+            const CCreatorContactSet& set = ContactLinkCache::Instance()->ContactSet(parameters->iLinkIds[i].iLinkId);
+            
+            const RPointerArray<MVPbkContactLink>& links = set.ContactLinks();
+            TInt numberOfExplicitLinks = links.Count(); // Number of defined contacts in contact-set
+            TInt numberOfExistingContacts = set.NumberOfExistingContacts(); // Number of existing contacts in contact-set
+            TInt maxAmount = numberOfExplicitLinks + numberOfExistingContacts;
+            
+            if( parameters->iLinkIds[i].iLinkAmount > 0 )
+                maxAmount = parameters->iLinkIds[i].iLinkAmount; // Max amount is limited
+            
+            TInt addedMembers = 0;
+            
+            for( TInt j = 0; j < links.Count() && addedMembers < maxAmount; ++j )
+                {
+                MVPbkContactLink* link = links[j]; 
+                if( link && IsContactGroupL(*link) == EFalse )
+                    {
+                    TRAPD(err, newGroup->AddContactL(*link));
+                    if( err != KErrAlreadyExists )
+                    	{
+                    	// Ignore "allready exists" -error
+                    	User::LeaveIfError(err);
+                    	++addedMembers;
+                    	}                    
+                    }
+                }
+            if( addedMembers < maxAmount )
+            	{
+            	// Add existing contacts, withing the limits set by maxAmount:
+            	amountOfContactsToBeAdded += maxAmount - addedMembers;
+            	}
+            }
+        }
+    if( amountOfContactsToBeAdded > 0 )
+        {    
+        CVPbkContactViewDefinition* viewDef = CVPbkContactViewDefinition::NewL();
+        CleanupStack::PushL( viewDef );
+        viewDef->SetType( EVPbkContactsView );
+        MVPbkContactView* contactView = iStore->CreateViewLC( 
+                *viewDef, 
+                *this, 
+                iStore->StoreProperties().SupportedFields() );
+        iWaiter->StartAndWait();//Making asynchronous CreateViewLC to synchronous
+
+        TInt cnt = 0;
+        // assign some random contacts to the group
+        for ( TInt y = 0; cnt < amountOfContactsToBeAdded && y < contactView->ContactCountL(); ++y )
+            {
+            MVPbkContactLink* link = contactView->CreateLinkLC( y );
+            if( link )
+                {
+                TRAPD( err, newGroup->AddContactL( *link ) );
+                CleanupStack::PopAndDestroy(); // link
+                if( err != KErrAlreadyExists )
+                    {
+                    // Ignore "allready exists" -error
+                    User::LeaveIfError( err );
+                    ++cnt;
+                    }
+                }
+            }
+        CleanupStack::PopAndDestroy(); // contactView
+        CleanupStack::PopAndDestroy( viewDef );
+        }
+    
+    newGroup->CommitL(*this);
+    iWaiter->StartAndWait(); //Making asynchronous CommitL to synchronous
+
+    // store the link to contact, so that Creator is able to delete
+    // it when user requests deletion of contacts that were created with Creator 
+    MVPbkContactLink* linkToContact = newGroup->CreateLinkLC();
+    if( linkToContact )
+        {
+        iContactGroupsToDelete->AppendL( linkToContact );
+        CleanupStack::Pop(); // linkToContact
+        }
+    
+    CleanupStack::PopAndDestroy(); // newGroup
+   
+    CompactPbkDatabaseL();
+
+    return err;
+
+    }
+
+//----------------------------------------------------------------------------
+
+TInt CCreatorVirtualPhonebook::CreateSubscribedContactEntryL(CCreatorModuleBaseParameters* /*aParameters*/)
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::CreateSubscribedContactEntryL");
+
+    return KErrNotSupported;
+    }
+
+//----------------------------------------------------------------------------
+
+void CCreatorVirtualPhonebook::AddFieldToContactItemL(
+		MVPbkStoreContact& newContact, TPbkFieldId aFieldId, const TDesC& aFieldText)
+	{
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::AddFieldToContactItemL");
+
+    // Get field type object
+    const MVPbkFieldTypeList& fieldList = newContact.ParentStore().StoreProperties().SupportedFields();        
+    const MVPbkFieldType* fieldType = fieldList.Find(aFieldId);
+    if( fieldType == 0 )
+        return; // field type is not supported
+    
+    // Create a new field
+	MVPbkStoreContactField* newField = newContact.CreateFieldLC(*fieldType);	
+	if( !newField )
+	    {
+	    User::Leave(KErrNotSupported);
+	    }
+	
+	MVPbkContactFieldData& fieldData = newField->FieldData();
+	
+	//data type must be text in this case
+	TVPbkFieldStorageType dataType = fieldData.DataType();
+
+	if(dataType == EVPbkFieldStorageTypeText)
+	    {
+		//set text to field	
+		MVPbkContactFieldTextData& tmpData = MVPbkContactFieldTextData::Cast(fieldData);
+		tmpData.SetTextL(aFieldText);
+		//set field to contact		
+		newContact.AddFieldL(newField);//This object takes ownership of the field.
+		CleanupStack::Pop(newField);			
+	    }
+	else
+		{
+		User::Leave(KErrArgument);
+		}
+	
+    }
+
+//----------------------------------------------------------------------------
+
+void CCreatorVirtualPhonebook::AddFieldToContactItemL(
+		MVPbkStoreContact& newContact, TPbkFieldId aFieldId, const TDesC8& aFieldText)
+	{
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::AddFieldToContactItemL");
+
+	//get field types
+	const MVPbkFieldTypeList& fieldList = newContact.ParentStore().StoreProperties().SupportedFields();
+	
+	//get wanted field type
+	const MVPbkFieldType* fieldType = fieldList.Find(aFieldId);
+	
+	//create a new field
+	MVPbkStoreContactField* newField =
+	            newContact.CreateFieldLC(*fieldType);
+	//get field data	
+	MVPbkContactFieldData& fieldData = newField->FieldData();
+	
+	//data type must be text in this case
+	TVPbkFieldStorageType dataType = fieldData.DataType();
+
+	if(dataType == EVPbkFieldStorageTypeBinary){
+		//set bindata to field	
+		MVPbkContactFieldBinaryData& tmpData = MVPbkContactFieldBinaryData::Cast(fieldData);		
+		tmpData.SetBinaryDataL(aFieldText);
+		//set field to contact		
+		newContact.AddFieldL(newField);//This object takes ownership of the field.
+		CleanupStack::Pop(newField);			
+	}
+	else
+		{
+		CleanupStack::PopAndDestroy(newField);
+		}
+	
+    }
+
+void CCreatorVirtualPhonebook::AddFieldToContactItemL(
+        MVPbkStoreContact& newContact, TPbkFieldId aFieldId, const TTime& aFieldText)
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::AddFieldToContactItemL");
+    //get field types
+    const MVPbkFieldTypeList& fieldList = newContact.ParentStore().StoreProperties().SupportedFields();
+        
+    //get wanted field type
+    const MVPbkFieldType* fieldType = fieldList.Find(aFieldId);
+        
+    //create a new field
+    MVPbkStoreContactField* newField = newContact.CreateFieldLC(*fieldType);
+    //get field data    
+    MVPbkContactFieldData& fieldData = newField->FieldData();
+        
+    //data type must be datetime in this case
+    TVPbkFieldStorageType dataType = fieldData.DataType();
+
+    if(dataType == EVPbkFieldStorageTypeDateTime)
+        {
+        //set bindata to field  
+        MVPbkContactFieldDateTimeData& tmpData = MVPbkContactFieldDateTimeData::Cast(fieldData);        
+        tmpData.SetDateTime(aFieldText);
+        //set field to contact      
+        newContact.AddFieldL(newField);//This object takes ownership of the field.
+        CleanupStack::Pop(newField);            
+        }
+    else
+        {
+        CleanupStack::PopAndDestroy(newField);
+        }
+    }
+
+//----------------------------------------------------------------------------
+
+void CCreatorVirtualPhonebook::CompactPbkDatabaseL(TBool aCompressImmediately)
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::CompactPbkDatabase");
+
+    iOpCounter++;
+
+    // compress the database immediately or after each 100th operation
+    if (aCompressImmediately || iOpCounter%100 == 0)
+        {
+        MVPbkContactOperationBase* operation= iContactManager->CompressStoresL(*this);
+        if (operation)
+            {
+            CleanupDeletePushL( operation );
+            iWaiter->StartAndWait();//Making asynchronous CompressStoresL to synchronous
+            CleanupStack::Pop(operation);
+            delete operation;
+            }             		 
+        }
+    }
+
+//----------------------------------------------------------------------------
+//Observer implementations for MVPbkContactStoreListObserver 
+//(and it's super class MVPbkContactStoreObserver)
+
+void CCreatorVirtualPhonebook::OpenComplete()
+	{
+	LOGSTRING("Creator: CCreatorVirtualPhonebook::OpenComplete()");
+    iWaiter->Cancel();
+	}
+
+void CCreatorVirtualPhonebook::StoreReady(MVPbkContactStore& /*aContactStore*/)
+	{
+	LOGSTRING("Creator: CCreatorVirtualPhonebook::StoreReady()");
+	}
+
+
+void CCreatorVirtualPhonebook::StoreUnavailable(MVPbkContactStore& /*aContactStore*/, 
+        TInt /*aReason*/)
+	{
+	LOGSTRING("Creator: CCreatorVirtualPhonebook::StoreUnavailable()");
+	}
+
+
+void CCreatorVirtualPhonebook::HandleStoreEventL(
+        MVPbkContactStore& /*aContactStore*/, 
+        TVPbkContactStoreEvent /*aStoreEvent*/)
+	{
+	LOGSTRING("Creator: CCreatorVirtualPhonebook::HandleStoreEventL()");
+	}
+
+
+ TAny* CCreatorVirtualPhonebook::ContactStoreObserverExtension(
+		 TUid /*aExtensionUid*/) 
+        
+ { 
+ LOGSTRING("Creator: CCreatorVirtualPhonebook::ContactStoreObserverExtension()");
+ return NULL; 
+ }
+ 
+ 
+//----------------------------------------------------------------------------
+//Observer implementation for MVPbkBatchOperationObserver
+
+void CCreatorVirtualPhonebook::StepComplete( 
+     MVPbkContactOperationBase& /*aOperation*/,
+     TInt /*aStepSize*/ )
+	{
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::StepComplete" );
+    
+	}
+
+
+TBool CCreatorVirtualPhonebook::StepFailed(
+     MVPbkContactOperationBase& /*aOperation*/,
+     TInt /*aStepSize*/, TInt aError )
+{
+	LOGSTRING2("Creator: CCreatorVirtualPhonebook::StepFailed - Error: %d", aError );
+	iLastError = aError;
+	iWaiter->Cancel();
+	return EFalse;
+}
+
+
+void CCreatorVirtualPhonebook::OperationComplete( 
+     MVPbkContactOperationBase& /*aOperation*/ )
+	{
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::OperationComplete" );
+    //Canceling waiter when operation is done.
+    iWaiter->Cancel();
+	}
+
+
+TAny* CCreatorVirtualPhonebook::BatchOperationObserverExtension( 
+     TUid /*aExtensionUid*/ ) 
+     {
+     LOGSTRING("Creator: CCreatorVirtualPhonebook::BatchOperationObserverExtension" );
+     return NULL;
+     }
+
+//----------------------------------------------------------------------------
+//Observer implementation for MVPbkContactFindObserver
+void CCreatorVirtualPhonebook::FindCompleteL( MVPbkContactLinkArray* aResults )
+  	 {
+  	 LOGSTRING("Creator: CCreatorVirtualPhonebook::FindCompleteL" );
+  	 if(iContactResults)
+  		 {
+  		 delete iContactResults;
+  		 iContactResults = NULL;
+  		 }
+  	 iContactResults = aResults;
+  	 iWaiter->Cancel();
+   	 }
+
+void CCreatorVirtualPhonebook::FindFailed( TInt aError )
+ 	 {
+ 	LOGSTRING2("Creator: CCreatorVirtualPhonebook::FindFailed - Error: %d", aError );
+ 	iLastError = aError;
+ 	iWaiter->Cancel();
+  	 }
+
+TAny* CCreatorVirtualPhonebook::ContactFindObserverExtension( 
+	                TUid /*aExtensionUid*/ )
+	 {
+	 LOGSTRING("Creator: CCreatorVirtualPhonebook::ContactFindObserverExtension" );
+	 return NULL;
+	 }	                
+
+
+//Observer implementation for MVPbkContactObserver
+//----------------------------------------------------------------------------
+
+void CCreatorVirtualPhonebook::ContactOperationCompleted(TContactOpResult aResult)
+	{
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::ContactOperationCompleted" );
+            
+	TContactOp op = aResult.iOpCode; 		 
+    switch ( op )
+        {
+        case EContactCommit:
+        case EContactDelete:
+            {
+            iWaiter->Cancel();
+            break;
+            }
+        case EContactLock:
+        default: break;
+        }
+	}
+	
+void CCreatorVirtualPhonebook::ContactOperationFailed
+			(TContactOp /*aOpCode*/, TInt aErrorCode, TBool /*aErrorNotified*/)
+	{
+    LOGSTRING2("Creator: CCreatorVirtualPhonebook::ContactOperationFailed - Error: %d", aErrorCode );
+    iLastError = aErrorCode;
+    iWaiter->Cancel();
+	}
+	
+TAny* CCreatorVirtualPhonebook::ContactObserverExtension(TUid /*aExtensionUid*/) 
+	{
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::ContactObserverExtension" );
+    return NULL;
+	}
+
+void CCreatorVirtualPhonebook::Pbk2ImageSetComplete(MPbk2ImageOperation& /*aOperation*/)
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::Pbk2ImageSetComplete" );
+    //Canceling waiter when operation is done.
+    iWaiter->Cancel();
+    }
+
+void CCreatorVirtualPhonebook::Pbk2ImageSetFailed(MPbk2ImageOperation& /*aOperation*/, TInt /*aError*/)
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::Pbk2ImageSetFailed" );
+    //Canceling waiter when operation is done.
+    iWaiter->Cancel();
+    }
+
+
+//Observer implementation for MVPbkContactViewObserver
+//----------------------------------------------------------------------------
+void CCreatorVirtualPhonebook::ContactViewReady( MVPbkContactViewBase& /*aView*/ )
+    {
+    LOGSTRING("Creator: CCreatorVirtualPhonebook::ContactViewReady" );
+    iWaiter->Cancel();
+    }
+
+void CCreatorVirtualPhonebook::ContactViewUnavailable(
+        MVPbkContactViewBase& /*aView*/ )
+    {
+    iWaiter->Cancel();
+    }
+
+void CCreatorVirtualPhonebook::ContactAddedToView(
+        MVPbkContactViewBase& /*aView*/, 
+        TInt /*aIndex*/, 
+        const MVPbkContactLink& /*aContactLink*/ )
+    {
+    }
+
+void CCreatorVirtualPhonebook::ContactRemovedFromView(
+        MVPbkContactViewBase& /*aView*/, 
+        TInt /*aIndex*/, 
+        const MVPbkContactLink& /*aContactLink*/ )
+    {
+    }
+        
+void CCreatorVirtualPhonebook::ContactViewError(
+        MVPbkContactViewBase& /*aView*/, 
+        TInt /*aError*/, 
+        TBool /*aErrorNotified*/ )
+    {
+    iWaiter->Cancel();
+    }
+
+/**
+ * CCreatorContactFieldImpl Base class for contact field implementations
+ */
+class CCreatorContactFieldImpl : public CBase
+    {
+public:        
+    virtual ~CCreatorContactFieldImpl() {};
+    
+    virtual void AddToContactL(CCreatorEngine* aEngine, MVPbkStoreContact& aContact, CCreatorVirtualPhonebook* aVPbk);
+    virtual void SetRandomParametersL(CCreatorContactField::TRandomLengthType aRandomLenType = CCreatorContactField::ERandomLengthDefault, TInt aRandomLen = 0 );
+    virtual void ParseL(CCommandParser* parser);
+     
+    virtual TInt FieldType();
+protected:
+    CCreatorContactFieldImpl(TInt aFieldType);    
+    TInt iFieldType;    
+    CCreatorContactField::TRandomLengthType iRandomLenType;
+    TInt iRandomLen;
+    };
+    
+void CCreatorContactFieldImpl::AddToContactL(CCreatorEngine* /*aEngine*/, MVPbkStoreContact& /*aContact*/, CCreatorVirtualPhonebook* /*aVPbk*/ )
+    {}
+
+void CCreatorContactFieldImpl::SetRandomParametersL(CCreatorContactField::TRandomLengthType aRandomLenType, TInt aRandomLen )
+    {    
+    iRandomLenType = aRandomLenType;
+    iRandomLen = aRandomLen;
+    }
+
+void CCreatorContactFieldImpl::ParseL(CCommandParser* /*parser*/)
+    {}
+    
+CCreatorContactFieldImpl::CCreatorContactFieldImpl(TInt aFieldType)
+    {
+    iFieldType = aFieldType;
+    }
+
+TInt CCreatorContactFieldImpl::FieldType()
+    {
+    return iFieldType;    
+    }
+
+
+/**
+ * CCreatorContactTextField Text field implementation
+ */
+class CCreatorContactTextField : public CCreatorContactFieldImpl
+    {
+    public:
+    static CCreatorContactTextField* NewL(TInt aFieldType, const TDesC& aData);
+    ~CCreatorContactTextField();
+    virtual void AddToContactL(CCreatorEngine* aEngine, MVPbkStoreContact& aContact, CCreatorVirtualPhonebook* aVPbk);    
+    virtual void ParseL(CCommandParser* parser);
+    
+    protected:
+    virtual void SetDefaultRandomContentL(CCreatorEngine* aEngine);
+    virtual void SetExplicitRandomContentL(CCreatorEngine* aEngine, TInt aRandomLen);
+    
+    private:    
+    CCreatorContactTextField(TInt aFieldType);
+    void ConstructL(const TDesC& aData);
+    HBufC* iPtr;    
+    };
+    
+CCreatorContactTextField::CCreatorContactTextField(TInt aFieldType) 
+: CCreatorContactFieldImpl(aFieldType)
+    { }
+CCreatorContactTextField::~CCreatorContactTextField()
+    { 
+    delete iPtr; 
+    }
+ void CCreatorContactTextField::AddToContactL(CCreatorEngine* aEngine, MVPbkStoreContact& aContact, CCreatorVirtualPhonebook* aVPbk)
+     {
+     LOGSTRING("Creator: CCreatorContactTextField::AddToContactL"); 
+     if( aVPbk == 0 )
+         User::Leave(KErrArgument);
+               
+     if( iPtr == 0 || iPtr->Length() == 0)
+         {
+         switch( iRandomLenType )
+         {
+         case CCreatorContactField::ERandomLengthDefault:
+             {
+             SetDefaultRandomContentL(aEngine);
+             break;
+             }
+         case CCreatorContactField::ERandomLengthMax:
+             {
+             const MVPbkFieldTypeList& fieldList = aContact.ParentStore().StoreProperties().SupportedFields();
+             const MVPbkFieldType* fieldType = fieldList.Find(iFieldType);
+             if( fieldType == 0 )
+                 return; // field type is not supported
+                 
+             // Create a new field
+             MVPbkStoreContactField* newField = aContact.CreateFieldLC(*fieldType);    
+             if( !newField )
+                 {
+                 User::Leave(KErrNotSupported);
+                 }
+                 
+             MVPbkContactFieldData& fieldData = newField->FieldData();  
+             //data type must be text in this case
+             TVPbkFieldStorageType dataType = fieldData.DataType();
+
+             if(dataType == EVPbkFieldStorageTypeText)
+                 {
+                 //set text to field 
+                 MVPbkContactFieldTextData& tmpData = MVPbkContactFieldTextData::Cast(fieldData);
+                 iRandomLen = tmpData.MaxLength();
+                 if( iRandomLen == KVPbkUnlimitedFieldLength )
+                     iRandomLen = 128;
+                 }
+             CleanupStack::PopAndDestroy(newField);       
+             SetExplicitRandomContentL(aEngine, iRandomLen);
+             break;
+             }
+         case CCreatorContactField::ERandomLengthExplicit:
+             {
+             SetExplicitRandomContentL(aEngine, iRandomLen);
+             break;
+             }
+         default:
+             break;
+         }
+         }
+     if( iPtr )
+         {
+         if( iFieldType == R_VPBK_FIELD_TYPE_THUMBNAILPIC )
+             {
+             if( iPtr && iPtr->Length() > 0 )
+            	 {
+            	 aVPbk->AddImageToContactL(aContact, iFieldType, iPtr->Des());
+            	 }
+             }
+         //Thumbnail id handling
+         /*else if( iFieldType == FIELD_TYPE_THUMBNAILPIC_ID )
+             {
+             if( iPtr && iPtr->Length() > 0 )
+                 {
+                 TInt id = aEngine->GetAttachmentIdL(iPtr->Des());
+                 if( id != KUndef )
+                     {
+                     //get picture path by id
+                     TFileName sourceFileName = aEngine->TestDataPathL((CCreatorEngine::TTestDataPath)id);// (CCreatorEngine::TTestDataPath) parameters.iAttachments->At(i)
+                     //set image to contact
+                     aVPbk->AddImageToContactL(aContact, R_VPBK_FIELD_TYPE_THUMBNAILPIC, sourceFileName);                     
+                     }
+                 }
+             }*/         
+         else
+             {
+             if( iPtr && iPtr->Length() > 0 )
+            	 {
+            	 aVPbk->AddFieldToContactItemL(aContact, iFieldType, iPtr->Des());
+            	 }
+             }
+         }
+     }
+
+ void CCreatorContactTextField::SetDefaultRandomContentL(CCreatorEngine* aEngine)
+     {
+     LOGSTRING("Creator: CCreatorContactTextField::SetDefaultRandomContentL");
+     if( aEngine == 0 )
+         return;
+     
+     if( iPtr )
+         {
+         delete iPtr;
+         iPtr = 0;
+         }
+     TPtrC contentData;
+     
+     TInt textFieldCount = sizeof(CreatorVPbkMiscTextFields) / sizeof(FieldInfo);
+     TBool found = EFalse;
+     for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex )
+         {
+         if( iFieldType == CreatorVPbkMiscTextFields[tfIndex].iFieldCode )
+             {
+             found = ETrue;
+             if( CreatorVPbkMiscTextFields[tfIndex].iRandomType != RND_TYPE_UNDEF )
+                 {
+                 contentData.Set(aEngine->RandomString((CCreatorEngine::TRandomStringType) CreatorVPbkMiscTextFields[tfIndex].iRandomType));
+                 }
+             else
+                 {
+                 switch( iFieldType )
+                 {
+                 case R_VPBK_FIELD_TYPE_RINGTONE:
+                     {
+                     contentData.Set(aEngine->CreateRandomSoundFileL());
+                     break;                 
+                     }
+                 //Thumbnail (path) and thumbnailid handling with random is the same, only in script they have different handling
+                 case R_VPBK_FIELD_TYPE_THUMBNAILPIC:                 
+                     {
+                     contentData.Set(aEngine->RandomPictureFileL());
+                     break;
+                     }
+                 case R_VPBK_FIELD_TYPE_SYNCCLASS:
+                 case R_VPBK_FIELD_TYPE_LOCPRIVACY:
+                     {
+                     _LIT(KPublic, "Public");
+                     contentData.Set(KPublic);
+                     break;
+                     }
+                 default:
+                     break;
+                 }
+                 }
+             break;
+             }
+         }
+     
+     if( found == EFalse )
+         {
+         TInt phNumFieldCount = sizeof(CreatorVPbkPhoneNumberFields) / sizeof(TInt);
+         for( TInt phIndex = 0; phIndex < phNumFieldCount; ++phIndex )
+             {
+             if( iFieldType == CreatorVPbkPhoneNumberFields[phIndex] )
+                 {
+                 contentData.Set(aEngine->RandomString(CCreatorEngine::EPhoneNumber));
+                 found = ETrue;
+                 break;
+                 }
+             }
+         }
+     
+     if( found == EFalse )
+         {
+         TInt emailFieldCount = sizeof(CreatorVPbkEmailFields) / sizeof(TInt);
+         for( TInt eIndex = 0; eIndex < emailFieldCount; ++eIndex )
+             {
+             if( iFieldType == CreatorVPbkEmailFields[eIndex] )
+                 {
+                 iPtr = aEngine->CreateEmailAddressLC();
+                 CleanupStack::Pop();
+                 return;
+                 }
+             }
+         }
+     iPtr = HBufC::NewL(contentData.Length());
+     iPtr->Des().Copy(contentData);
+     }
+ 
+ void CCreatorContactTextField::SetExplicitRandomContentL(CCreatorEngine* aEngine, TInt aRandomLen)
+     {     
+     LOGSTRING("Creator: CCreatorContactTextField::SetExplicitRandomContentL");
+     if( iPtr )
+         {
+         delete iPtr;
+         iPtr = 0;
+         }
+     iPtr = aEngine->CreateRandomStringLC(aRandomLen);
+     CleanupStack::Pop(); // iPtr
+     }
+ 
+ void CCreatorContactTextField::ParseL(CCommandParser* parser)
+     {
+     parser->StrParserL(iPtr, '|');
+     }
+ 
+ void CCreatorContactTextField::ConstructL(const TDesC& aData)
+      {     
+      iPtr = HBufC::New(KPhonebookFieldLength);
+      iPtr->Des().Copy(aData);
+      }
+ 
+ CCreatorContactTextField* CCreatorContactTextField::NewL(TInt aFieldType, const TDesC& aData)
+     {
+     CCreatorContactTextField* self = new (ELeave) CCreatorContactTextField(aFieldType);
+     CleanupStack::PushL(self);
+     self->ConstructL(aData);
+     CleanupStack::Pop();
+     return self;
+     }
+ /**
+  * CCreatorContactBinaryField Binary field implementation
+  */
+ class CCreatorContactBinaryField : public CCreatorContactFieldImpl
+    {
+public:
+    static CCreatorContactBinaryField* NewL(TInt aFieldType, const TDesC8& aData);
+    ~CCreatorContactBinaryField();  
+    virtual void AddToContactL(CCreatorEngine* aEngine, MVPbkStoreContact& aContact, CCreatorVirtualPhonebook* aVPbk);
+    virtual void ParseL(CCommandParser* parser);
+    virtual void SetDefaultRandomContentL(CCreatorEngine* aEngine);
+private:
+    CCreatorContactBinaryField(TInt aFieldType);
+    void ConstructL(const TDesC8& aData);
+    HBufC8* iPtr;    
+    };
+ 
+ CCreatorContactBinaryField::CCreatorContactBinaryField(TInt aFieldType) 
+ : CCreatorContactFieldImpl(aFieldType)
+     { }
+ CCreatorContactBinaryField::~CCreatorContactBinaryField()
+     { 
+     delete iPtr; 
+     }
+   
+ void CCreatorContactBinaryField::ConstructL(const TDesC8& aData)
+     {
+     iPtr = HBufC8::New(KPhonebookFieldLength);
+     iPtr->Des() = aData;
+     }
+ 
+ CCreatorContactBinaryField* CCreatorContactBinaryField::NewL(TInt aFieldType, const TDesC8& aData)
+      {
+      CCreatorContactBinaryField* self = new (ELeave) CCreatorContactBinaryField(aFieldType);
+      CleanupStack::PushL(self);
+      self->ConstructL(aData);
+      CleanupStack::Pop();
+      return self;
+      }
+ 
+void CCreatorContactBinaryField::AddToContactL(CCreatorEngine* /*aEngine*/, MVPbkStoreContact& aContact, CCreatorVirtualPhonebook* aVPbk)
+    {
+    LOGSTRING("Creator: CCreatorContactBinaryField::AddToContactL");
+    if( aVPbk == 0 )
+        User::Leave(KErrArgument);
+    if( iPtr )
+        {
+            aVPbk->AddFieldToContactItemL(aContact, iFieldType, iPtr->Des());
+        }
+    }
+void CCreatorContactBinaryField::ParseL(CCommandParser* parser)
+     {
+     parser->StrParserL(iPtr, '&');
+     }
+
+void CCreatorContactBinaryField::SetDefaultRandomContentL(CCreatorEngine* /*aEngine*/)
+    {
+    LOGSTRING("Creator: CCreatorContactBinaryField::SetDefaultRandomContentL");
+    }
+
+/**
+ * CCreatorContactDateTimeField
+ */ 
+class CCreatorContactDateTimeField : public CCreatorContactFieldImpl
+    {
+public:
+    static CCreatorContactDateTimeField* NewL(TInt aFieldType, const TTime& aData);
+    ~CCreatorContactDateTimeField();  
+    virtual void AddToContactL(CCreatorEngine* aEngine, MVPbkStoreContact& aContact, CCreatorVirtualPhonebook* aVPbk);
+    virtual void ParseL(CCommandParser* parser);    
+private:
+CCreatorContactDateTimeField(TInt aFieldType);
+    void ConstructL(const TTime& aData);
+    TTime iPtr;    
+    };
+ 
+CCreatorContactDateTimeField::CCreatorContactDateTimeField(TInt aFieldType) 
+: CCreatorContactFieldImpl(aFieldType)
+     { }
+CCreatorContactDateTimeField::~CCreatorContactDateTimeField()
+     {
+     }
+   
+ void CCreatorContactDateTimeField::ConstructL(const TTime& aData)
+     {
+     iPtr = aData;
+     }
+ 
+ CCreatorContactDateTimeField* CCreatorContactDateTimeField::NewL(TInt aFieldType, const TTime& aData)
+      {
+      CCreatorContactDateTimeField* self = new (ELeave) CCreatorContactDateTimeField(aFieldType);
+      CleanupStack::PushL(self);
+      self->ConstructL(aData);
+      CleanupStack::Pop();
+      return self;
+      }
+ 
+void CCreatorContactDateTimeField::AddToContactL(CCreatorEngine* aEngine, MVPbkStoreContact& aContact, CCreatorVirtualPhonebook* aVPbk)
+    {
+    LOGSTRING("Creator: CCreatorContactDateTimeField::AddToContactL");
+    if( aVPbk == 0 )
+        User::Leave(KErrArgument);
+    
+    //TTime undefTime();
+    if( iPtr == Time::NullTTime() )
+        {
+        iPtr = aEngine->RandomDate(CCreatorEngine::EDateFuture);
+        }
+    
+    aVPbk->AddFieldToContactItemL(aContact, iFieldType, iPtr);    
+    }
+void CCreatorContactDateTimeField::ParseL(CCommandParser* /*parser*/)
+     {
+     //parser->StrParserL(iPtr, '&');
+     }
+
+/**
+ * CCreatorContactField Contact field API
+ */
+CCreatorContactField* CCreatorContactField::NewL(TInt aFieldType, const TDesC& aData)
+    {
+    CCreatorContactField* self = new (ELeave) CCreatorContactField();
+    CleanupStack::PushL(self);
+    self->ConstructL(aFieldType, aData);
+    CleanupStack::Pop();
+    return self;
+    }
+
+CCreatorContactField* CCreatorContactField::NewL(TInt aFieldType, const TDesC8& aData)
+    {
+    CCreatorContactField* self = new (ELeave) CCreatorContactField();
+    CleanupStack::PushL(self);
+    self->ConstructL(aFieldType, aData);
+    CleanupStack::Pop();
+    return self;
+    }
+
+CCreatorContactField* CCreatorContactField::NewL(TInt aFieldType, const TTime& aData)
+    {
+    CCreatorContactField* self = new (ELeave) CCreatorContactField();
+    CleanupStack::PushL(self);
+    self->ConstructL(aFieldType, aData);
+    CleanupStack::Pop();
+    return self;
+    }
+
+void CCreatorContactField::ConstructL(TInt aFieldType, const TDesC& aData)
+    {
+    pImpl = CCreatorContactTextField::NewL(aFieldType, aData); 
+    }
+
+void CCreatorContactField::ConstructL(TInt aFieldType, const TDesC8& aData)
+    {
+    pImpl = CCreatorContactBinaryField::NewL(aFieldType, aData);    
+    }
+
+void CCreatorContactField::ConstructL(TInt aFieldType, const TTime& aData)
+    {
+    pImpl = CCreatorContactDateTimeField::NewL(aFieldType, aData);    
+    }
+
+CCreatorContactField::CCreatorContactField()
+    {}
+CCreatorContactField::~CCreatorContactField()
+    {
+    delete pImpl;
+    }
+ 
+TInt CCreatorContactField::FieldType()
+    {
+    return pImpl->FieldType();
+    }
+void CCreatorContactField::AddToContactL(CCreatorEngine* aEngine, MVPbkStoreContact& aContact, CCreatorVirtualPhonebook* aVPbk)
+    {
+    pImpl->AddToContactL(aEngine, aContact, aVPbk);
+    }
+void CCreatorContactField::ParseL(CCommandParser* parser)
+    {
+    pImpl->ParseL(parser);
+    }
+
+void CCreatorContactField::SetRandomParametersL(TRandomLengthType aRandomLenType, TInt aRandomLen )
+    {
+    pImpl->SetRandomParametersL(aRandomLenType, aRandomLen);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creator/src/creator_wepsecuritysettings.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,144 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include "creator_traces.h"
+#include "creator_wepsecuritysettings.h"
+#include <commdb.h>
+//#include <featmgr.h>
+#include <wlancdbcols.h>
+
+//#include <commsdattypesv1_1.h>
+//#include <cmmanagertablefields.h>
+//#include <wlancontainer.h>
+
+
+
+//----------------------------------------------------------------------------
+
+CCreatorWEPSecuritySettings* CCreatorWEPSecuritySettings::NewL()
+    {
+    CCreatorWEPSecuritySettings* self = CCreatorWEPSecuritySettings::NewLC();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CCreatorWEPSecuritySettings* CCreatorWEPSecuritySettings::NewLC()
+    {
+    CCreatorWEPSecuritySettings* self = new (ELeave) CCreatorWEPSecuritySettings;
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+CCreatorWEPSecuritySettings::CCreatorWEPSecuritySettings()
+    {
+    }
+
+void CCreatorWEPSecuritySettings::ConstructL()
+    {
+    LOGSTRING("Creator: CCreatorWEPSecuritySettings::ConstructL");
+    }
+
+CCreatorWEPSecuritySettings::~CCreatorWEPSecuritySettings()
+    {
+    LOGSTRING("Creator: CCreatorWEPSecuritySettings::~CCreatorWEPSecuritySettings");
+
+    
+    }
+
+    
+
+//----------------------------------------------------------------------------
+
+
+
+// ---------------------------------------------------------
+// CWEPSecuritySettingsImpl::SaveL
+// ---------------------------------------------------------
+//
+void CCreatorWEPSecuritySettings::SaveL( TUint32 /*aIapId*/, 
+                                      CCommsDatabase& /*aCommsDb*/ ) const
+    {
+    /*
+    // Data of the key
+    TBuf8<KMaxLengthOfKeyData> iKeyData[KMaxNumberofKeys];    
+    
+    CCommsDbTableView* wLanServiceTable;
+
+    // Caller MUST initiate a transaction, WE WILL NOT.
+
+    wLanServiceTable = aCommsDb.OpenViewMatchingUintLC( 
+                    TPtrC( WLAN_SERVICE ), TPtrC( WLAN_SERVICE_ID ), aIapId );
+    TInt errorCode = wLanServiceTable->GotoFirstRecord();
+
+    if ( errorCode == KErrNone )
+        {
+        wLanServiceTable->UpdateRecord();
+        }
+    else
+        {
+        TUint32 dummyUid( 0 ); //was KUidNone
+        User::LeaveIfError( wLanServiceTable->InsertRecord( dummyUid ) );
+
+        // Save link to LAN service
+        wLanServiceTable->WriteUintL( TPtrC( WLAN_SERVICE_ID ), aIapId );
+        }
+
+    // Save index of key in use
+    wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_INDEX ), 
+                                 ( TUint32& ) iKeyInUse );
+
+    // Save index of key in use
+    wLanServiceTable->WriteUintL( TPtrC( NU_WLAN_AUTHENTICATION_MODE ), 
+                                 ( TUint32& ) iAuthentication );
+
+    // Save first WEP key
+    wLanServiceTable->WriteTextL( TPtrC( NU_WLAN_WEP_KEY1 ), 
+                                  iKeyData[KFirstKey] );
+
+    // Save second WEP key
+    wLanServiceTable->WriteTextL( TPtrC( NU_WLAN_WEP_KEY2 ), 
+                                  iKeyData[KSecondKey] );
+
+    // Save third WEP key
+    wLanServiceTable->WriteTextL( TPtrC( NU_WLAN_WEP_KEY3 ), 
+                                  iKeyData[KThirdKey] );
+
+    // Save fourth WEP key
+    wLanServiceTable->WriteTextL( TPtrC( NU_WLAN_WEP_KEY4 ), 
+                                  iKeyData[KFourthKey] );
+
+    // Save the format of the keys
+    wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_KEY1_FORMAT ), 
+                                 ( TUint32& ) iKeyFormat[KFirstKey] );
+
+    wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_KEY2_FORMAT ), 
+                                 ( TUint32& ) iKeyFormat[KSecondKey] );
+
+    wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_KEY3_FORMAT ), 
+                                 ( TUint32& ) iKeyFormat[KThirdKey] );
+
+    wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_KEY4_FORMAT ), 
+                                 ( TUint32& ) iKeyFormat[KFourthKey] );
+
+    wLanServiceTable->PutRecordChanges();
+
+    CleanupStack::PopAndDestroy( wLanServiceTable );  // wLanServiceTable
+    */
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/data/filebrowser.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,1599 @@
+/*
+* 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 "FB.hrh"
+#include <data_caging_paths_strings.hrh>
+#include <appinfo.rh>
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)
+    #include <filebrowser_extraicons.mbg> // for r_filebrowser_toolbar_info_extension
+#endif
+
+
+// ---------------------------------------------------------
+//   
+//    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
+    {
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)
+    custom_app_info_extension = r_filebrowser_toolbar_info_extension;
+#endif
+    }
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)
+
+RESOURCE EIK_APP_INFO_EXT r_filebrowser_toolbar_info_extension
+    {
+    popup_toolbar = r_filebrowser_toolbar;
+    }
+
+RESOURCE AVKON_TOOLBAR r_filebrowser_toolbar
+    {
+    lines = 1;
+    flags = KAknToolbarFixed ;
+
+    items =
+        {
+        TBAR_CTRL
+            {
+            type = EAknCtButton;
+            id = EFileBrowserCmdFileBack;
+            control = AVKON_BUTTON
+                {
+                flags = 0;
+                states =
+                    {
+                    AVKON_BUTTON_STATE
+                        {
+                        helptxt = "Up one level";
+                        bmpfile = APP_BITMAP_DIR"\\filebrowser_extraicons.mif";
+                        bmpid = EMbmFilebrowser_extraiconsQgn_indi_tb_filebrowser_folder_parent;
+                        bmpmask = EMbmFilebrowser_extraiconsQgn_indi_tb_filebrowser_folder_parent_mask;
+                        }
+                    };
+                };
+            },
+        TBAR_CTRL
+            {
+            type = EAknCtButton;
+            id = EFileBrowserCmdFileSearch;
+            control = AVKON_BUTTON
+                {
+                flags = 0;
+                states =
+                    {
+                    AVKON_BUTTON_STATE
+                        {
+                        helptxt = "Open/Close filter view";
+                        bmpfile = APP_BITMAP_DIR"\\filebrowser_extraicons.mif";
+                        bmpid = EMbmFilebrowser_extraiconsQgn_indi_tb_filebrowser_find;
+                        bmpmask = EMbmFilebrowser_extraiconsQgn_indi_tb_filebrowser_find_mask;
+                        }
+                    };
+                };
+            },
+        TBAR_CTRL
+            {
+            type = EAknCtButton;
+            id = EFileBrowserCmdEditSelect;
+            control = AVKON_BUTTON
+                {
+                flags = KAknButtonReportOnLongPress;
+                states =
+                    {
+                    AVKON_BUTTON_STATE
+                        {
+                        helptxt = "Select/Unselect item";
+                        bmpfile = APP_BITMAP_DIR"\\filebrowser_extraicons.mif";
+                        bmpid = EMbmFilebrowser_extraiconsQgn_indi_tb_filebrowser_selection;
+                        bmpmask = EMbmFilebrowser_extraiconsQgn_indi_tb_filebrowser_selection_mask;
+                        },
+                    AVKON_BUTTON_STATE
+                        {
+                        helptxt = "Select/Unselect item";
+                        bmpfile = APP_BITMAP_DIR"\\filebrowser_extraicons.mif";
+                        bmpid = EMbmFilebrowser_extraiconsQgn_indi_tb_filebrowser_selection_active;
+                        bmpmask = EMbmFilebrowser_extraiconsQgn_indi_tb_filebrowser_selection_active_mask;
+                        }
+                    };
+                };
+            }
+        };
+    }
+#endif
+
+//----------------------------------------------------
+//   
+//    r_filebrowser_hotkeys
+//
+//----------------------------------------------------
+//
+RESOURCE HOTKEYS r_filebrowser_hotkeys
+    {
+    control=
+        {
+        HOTKEY { command=EAknCmdExit; key='e'; }
+        };
+    }
+
+//----------------------------------------------------
+//   
+//    r_filebrowser_view_filelist
+//
+//----------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_filebrowser_view_filelist
+    {
+    hotkeys=r_filebrowser_hotkeys;
+    menubar=r_filebrowser_menubar_view_filelist;  
+    cba=R_AVKON_SOFTKEYS_OPTIONS_EXIT;    
+    }
+
+//----------------------------------------------------
+//   
+//    r_filebrowser_menubar_view_filelist
+//
+//----------------------------------------------------
+//
+RESOURCE MENU_BAR r_filebrowser_menubar_view_filelist
+    {
+    titles=
+        {
+        MENU_TITLE { menu_pane=r_filebrowser_app_menu; txt="App"; },
+        MENU_TITLE { menu_pane=r_filebrowser_view_filelist_menu; txt="View"; }
+        };
+    }
+
+//----------------------------------------------------
+//   
+//    r_filebrowser_view_filelist_menu
+//
+//----------------------------------------------------
+//
+RESOURCE MENU_PANE r_filebrowser_view_filelist_menu
+    {
+    items=
+        {
+        MENU_ITEM { command=EFileBrowserCmdFile; txt="File"; cascade=r_filebrowser_file_submenu; },
+        MENU_ITEM { command=EFileBrowserCmdEdit; txt="Edit"; cascade=r_filebrowser_edit_submenu; },
+        MENU_ITEM { command=EFileBrowserCmdView; txt="View"; cascade=r_filebrowser_view_submenu; },
+        MENU_ITEM { command=EFileBrowserCmdDiskAdmin; txt="Disk admin"; cascade=r_filebrowser_diskadmin_submenu; },
+        MENU_ITEM { command=EFileBrowserCmdTools; txt="Tools"; cascade=r_filebrowser_tools_submenu; },
+        MENU_ITEM { command=EFileBrowserCmdSettings; txt="Settings"; },
+        MENU_ITEM { command=EFileBrowserCmdAbout; txt="About"; },
+        MENU_ITEM { command=EAknCmdExit; txt="Exit"; }
+        };
+    }
+
+RESOURCE MENU_PANE r_filebrowser_file_submenu
+    {
+    items = 
+        {
+        MENU_ITEM { command=EFileBrowserCmdFileBack; txt="Back/Move up (<-)"; },
+        MENU_ITEM { command=EFileBrowserCmdFileOpen; txt="Open"; cascade=r_filebrowser_file_open_submenu; },
+        MENU_ITEM { command=EFileBrowserCmdFileOpenDrive; txt="Open drive (->)"; },
+        MENU_ITEM { command=EFileBrowserCmdFileOpenDirectory; txt="Open directory (->)"; },
+        MENU_ITEM { command=EFileBrowserCmdFileView; txt="View"; cascade=r_filebrowser_file_view_submenu; },
+        MENU_ITEM { command=EFileBrowserCmdFileEdit; txt="Edit"; cascade=r_filebrowser_file_edit_submenu; },
+        MENU_ITEM { command=EFileBrowserCmdFileSearch; txt="Search..."; },
+        MENU_ITEM { command=EFileBrowserCmdFileSendTo; txt="Send to"; },
+        MENU_ITEM { command=EFileBrowserCmdFileNew; txt="New"; cascade=r_filebrowser_file_new_submenu; },
+        MENU_ITEM { command=EFileBrowserCmdFileDelete; txt="Delete"; },
+        MENU_ITEM { command=EFileBrowserCmdFileRename; txt="Rename"; },
+        MENU_ITEM { command=EFileBrowserCmdFileTouch; txt="Touch"; },
+        MENU_ITEM { command=EFileBrowserCmdFileProperties; txt="Properties"; },
+        MENU_ITEM { command=EFileBrowserCmdFileChecksums; txt="Checksums"; cascade=r_filebrowser_file_checksums_submenu; },
+        MENU_ITEM { command=EFileBrowserCmdFileSetAttributes; txt="Set attributes..."; },
+        MENU_ITEM { command=EFileBrowserCmdFileCompress; txt="Compress with GZip"; },
+        MENU_ITEM { command=EFileBrowserCmdFileDecompress; txt="Decompress with GZip"; }
+        };
+    }
+
+RESOURCE MENU_PANE r_filebrowser_file_open_submenu
+    {
+    items = 
+        {
+        MENU_ITEM { command=EFileBrowserCmdFileOpenApparc; txt="AppArc"; },
+        MENU_ITEM { command=EFileBrowserCmdFileOpenDocHandlerEmbed; txt="DocHandler embed"; },
+        MENU_ITEM { command=EFileBrowserCmdFileOpenDocHandlerStandAlone; txt="DocHandler stand-alone"; },
+        MENU_ITEM { command=EFileBrowserCmdFileOpenFileService; txt="Choose a file service..."; }
+        };
+    }
+
+RESOURCE MENU_PANE r_filebrowser_file_view_submenu
+    {
+    items = 
+        {
+        MENU_ITEM { command=EFileBrowserCmdFileViewText; txt="As text"; },
+        MENU_ITEM { command=EFileBrowserCmdFileViewHex; txt="As hex"; }
+        };
+    }
+    
+RESOURCE MENU_PANE r_filebrowser_file_edit_submenu
+    {
+    items = 
+        {
+        MENU_ITEM { command=EFileBrowserCmdFileEditText; txt="As text"; },
+        MENU_ITEM { command=EFileBrowserCmdFileEditHex; txt="As hex"; }
+        };
+    }
+        
+RESOURCE MENU_PANE r_filebrowser_file_new_submenu
+    {
+    items = 
+        {
+        MENU_ITEM { command=EFileBrowserCmdFileNewFile; txt="File"; },
+        MENU_ITEM { command=EFileBrowserCmdFileNewDirectory; txt="Directory"; }
+        };
+    }
+
+RESOURCE MENU_PANE r_filebrowser_file_checksums_submenu
+    {
+    items = 
+        {
+        MENU_ITEM { command=EFileBrowserCmdFileChecksumsMD5; txt="MD5"; },
+        MENU_ITEM { command=EFileBrowserCmdFileChecksumsMD2; txt="MD2"; },
+        MENU_ITEM { command=EFileBrowserCmdFileChecksumsSHA1; txt="SHA-1"; }
+        };
+    }
+RESOURCE MENU_PANE r_filebrowser_edit_submenu
+    {
+    items = 
+        {
+        MENU_ITEM { command=EFileBrowserCmdSnapShot; txt="Snap shot to E:"; },
+        MENU_ITEM { command=EFileBrowserCmdEditCut; txt="Cut"; },
+        MENU_ITEM { command=EFileBrowserCmdEditCopy; txt="Copy"; },
+        MENU_ITEM { command=EFileBrowserCmdEditPaste; txt="Paste"; },
+        MENU_ITEM { command=EFileBrowserCmdEditCopyToFolder; txt="Copy to folder..."; },
+        MENU_ITEM { command=EFileBrowserCmdEditMoveToFolder; txt="Move to folder..."; },
+        MENU_ITEM { command=EFileBrowserCmdEditSelect; txt="Select"; },
+        MENU_ITEM { command=EFileBrowserCmdEditUnselect; txt="Unselect"; },
+        MENU_ITEM { command=EFileBrowserCmdEditSelectAll; txt="Select all"; },
+        MENU_ITEM { command=EFileBrowserCmdEditUnselectAll; txt="Unselect all"; }
+        };
+    }
+
+RESOURCE MENU_PANE r_filebrowser_view_submenu
+    {
+    items = 
+        {
+        MENU_ITEM { command=EFileBrowserCmdViewSort; txt="Sort"; cascade=r_filebrowser_view_sort_submenu; },
+        MENU_ITEM { command=EFileBrowserCmdViewOrder; txt="Order"; cascade=r_filebrowser_view_order_submenu; },
+        MENU_ITEM { command=EFileBrowserCmdViewFilterEntries; txt="Filter entries"; },
+        MENU_ITEM { command=EFileBrowserCmdViewRefresh; txt="Refresh"; }
+        };
+    }
+
+RESOURCE MENU_PANE r_filebrowser_view_sort_submenu
+    {
+    items = 
+        {
+        MENU_ITEM { command=EFileBrowserCmdViewSortByName; txt="By name"; flags = EEikMenuItemRadioStart | EEikMenuItemSymbolOn; },
+        MENU_ITEM { command=EFileBrowserCmdViewSortByExtension; txt="By extension"; flags = EEikMenuItemRadioMiddle; },
+        MENU_ITEM { command=EFileBrowserCmdViewSortByDate; txt="By date"; flags = EEikMenuItemRadioMiddle; },
+        MENU_ITEM { command=EFileBrowserCmdViewSortBySize; txt="By size"; flags = EEikMenuItemRadioEnd; }
+        };
+    }
+    
+RESOURCE MENU_PANE r_filebrowser_view_order_submenu
+    {
+    items = 
+        {
+        MENU_ITEM { command=EFileBrowserCmdViewOrderAscending; txt="Ascending"; flags = EEikMenuItemRadioStart | EEikMenuItemSymbolOn; },
+        MENU_ITEM { command=EFileBrowserCmdViewOrderDescending; txt="Descending"; flags = EEikMenuItemRadioEnd; }
+        };
+    }
+
+RESOURCE MENU_PANE r_filebrowser_diskadmin_submenu
+    {
+    items = 
+        {
+        MENU_ITEM { command=EFileBrowserCmdDiskAdminSetDrivePassword; txt="Set drive password"; },
+        MENU_ITEM { command=EFileBrowserCmdDiskAdminUnlockDrive; txt="Unlock drive"; },
+        MENU_ITEM { command=EFileBrowserCmdDiskAdminClearDrivePassword; txt="Clear drive password"; },
+        MENU_ITEM { command=EFileBrowserCmdDiskAdminEraseDrivePassword; txt="Erase drive password"; },
+        MENU_ITEM { command=EFileBrowserCmdDiskAdminFormatDrive; txt="Format drive"; },
+        MENU_ITEM { command=EFileBrowserCmdDiskAdminQuickFormatDrive; txt="Quick format drive"; },
+        MENU_ITEM { command=EFileBrowserCmdDiskAdminCheckDisk; txt="Check disk"; },
+        MENU_ITEM { command=EFileBrowserCmdDiskAdminScanDrive; txt="Scan drive"; },
+        MENU_ITEM { command=EFileBrowserCmdDiskAdminSetDriveName; txt="Set drive name"; },
+        MENU_ITEM { command=EFileBrowserCmdDiskAdminSetDriveVolumeLabel; txt="Set drive volume label"; },
+        MENU_ITEM { command=EFileBrowserCmdDiskAdminEjectDrive; txt="Eject drive"; },
+        MENU_ITEM { command=EFileBrowserCmdDiskAdminDismountFileSystem; txt="Dismount drive"; },
+        MENU_ITEM { command=EFileBrowserCmdDiskAdminEraseMBR; txt="Erase MBR"; },
+        MENU_ITEM { command=EFileBrowserCmdDiskAdminDrivePartition; txt="Partition drive"; }
+        };
+    }
+    
+RESOURCE MENU_PANE r_filebrowser_tools_submenu
+    {
+    items = 
+        {
+        MENU_ITEM { command=EFileBrowserCmdToolsInstalledApps; txt="All apps to a text file"; },
+        MENU_ITEM { command=EFileBrowserCmdToolsAllFiles; txt="All files to a text file"; },
+        MENU_ITEM { command=EFileBrowserCmdToolsAvkonIconCache; txt="Avkon icon cache"; cascade=r_filebrowser_tools_avkoniconcache_submenu; },
+        MENU_ITEM { command=EFileBrowserCmdToolsDisableExtErrors; txt="Disable extended errors"; },
+        MENU_ITEM { command=EFileBrowserCmdToolsMsgStoreWalk; txt="Dump msg. store walk"; },
+        MENU_ITEM { command=EFileBrowserCmdToolsEditDataTypes; txt="Edit data types"; },
+        MENU_ITEM { command=EFileBrowserCmdToolsEnableExtErrors; txt="Enable extended errors"; },
+        MENU_ITEM { command=EFileBrowserCmdToolsErrorSimulate; txt="Error simulate"; cascade=r_filebrowser_tools_errorsimulate_submenu; },
+        MENU_ITEM { command=EFileBrowserCmdToolsLocalConnectivity; txt="Local connectivity"; cascade=r_filebrowser_tools_localconnectivity_submenu; },
+        MENU_ITEM { command=EFileBrowserCmdToolsMsgAttachments; txt="Message attachments"; cascade=r_filebrowser_tools_msgattachments_submenu; },
+        MENU_ITEM { command=EFileBrowserCmdToolsMemoryInfo; txt="Memory info"; },
+        MENU_ITEM { command=EFileBrowserCmdToolsSecureBackup; txt="Secure backup"; cascade=r_filebrowser_tools_securebackup_submenu; },
+        MENU_ITEM { command=EFileBrowserCmdToolsSetDebugMask; txt="Set debug mask"; },
+        MENU_ITEM { command=EFileBrowserCmdToolsOpenFiles; txt="Show open files here"; }
+        };
+    }    
+
+RESOURCE MENU_PANE r_filebrowser_tools_avkoniconcache_submenu
+    {
+    items = 
+        {
+        MENU_ITEM { command=EFileBrowserCmdToolsAvkonIconCacheEnable; txt="Enable"; },
+        MENU_ITEM { command=EFileBrowserCmdToolsAvkonIconCacheDisable; txt="Clear and disable"; }
+        };
+    }
+
+RESOURCE MENU_PANE r_filebrowser_tools_errorsimulate_submenu
+    {
+    items = 
+        {
+        MENU_ITEM { command=EFileBrowserCmdToolsErrorSimulateLeave; txt="Leave"; },
+        MENU_ITEM { command=EFileBrowserCmdToolsErrorSimulatePanic; txt="Panic"; },
+        MENU_ITEM { command=EFileBrowserCmdToolsErrorSimulateException; txt="Exception"; }
+        };
+    }
+        
+RESOURCE MENU_PANE r_filebrowser_tools_localconnectivity_submenu
+    {
+    items = 
+        {
+        MENU_ITEM { command=EFileBrowserCmdToolsLocalConnectivityActivateInfrared; txt="Activate infrared"; },
+        MENU_ITEM { command=EFileBrowserCmdToolsLocalConnectivityLaunchBTUI; txt="Launch BT UI"; },
+        MENU_ITEM { command=EFileBrowserCmdToolsLocalConnectivityLaunchUSBUI; txt="Launch USB UI"; }
+        };
+    }
+
+RESOURCE MENU_PANE r_filebrowser_tools_msgattachments_submenu
+    {
+    items = 
+        {
+        MENU_ITEM { command=EFileBrowserCmdToolsMsgAttachmentsInbox; txt="Inbox"; },
+        MENU_ITEM { command=EFileBrowserCmdToolsMsgAttachmentsDrafts; txt="Drafts"; },
+        MENU_ITEM { command=EFileBrowserCmdToolsMsgAttachmentsSentItems; txt="Sent items"; },
+        MENU_ITEM { command=EFileBrowserCmdToolsMsgAttachmentsOutbox; txt="Outbox"; }
+        };
+    }        
+
+RESOURCE MENU_PANE r_filebrowser_tools_securebackup_submenu
+    {
+    items = 
+        {
+        MENU_ITEM { command=EFileBrowserCmdToolsSecureBackupStartBackup; txt="Start backup"; },
+        MENU_ITEM { command=EFileBrowserCmdToolsSecureBackupStartRestore; txt="Start restore"; },
+        MENU_ITEM { command=EFileBrowserCmdToolsSecureBackupStop; txt="Stop"; }
+        };
+    } 
+            
+//----------------------------------------------------
+//   
+//    r_filebrowser_app_menu
+//
+//----------------------------------------------------
+//
+RESOURCE MENU_PANE r_filebrowser_app_menu
+    {
+    items=
+        {
+        };
+    }
+
+//----------------------------------------------------
+//
+//    r_filebrowser_settings_dialog
+//    Dialog for setting list
+//
+//----------------------------------------------------
+//
+RESOURCE DIALOG r_filebrowser_settings_dialog
+    {
+    flags =
+        EEikDialogFlagNoDrag | EEikDialogFlagFillAppClientRect |
+        EEikDialogFlagButtonsRight | EEikDialogFlagCbaButtons |
+        EEikDialogFlagWait | EEikDialogFlagNoTitleBar;
+    buttons = R_AVKON_SOFTKEYS_OPTIONS_BACK;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtSettingListBox;
+            id = EFileBrowserSettingItemList;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = LISTBOX
+                {
+                flags = EAknListBoxSelectionList;
+                };
+            }
+        };
+    }
+
+//----------------------------------------------------
+//    r_filebrowser_settings_menubar
+//----------------------------------------------------
+//
+RESOURCE MENU_BAR r_filebrowser_settings_menubar
+    {
+    titles =
+        {
+        MENU_TITLE
+            {
+            menu_pane = r_filebrowser_settings_menupane;
+            txt = " ";   // dummy
+            }
+        };
+    }
+
+RESOURCE MENU_PANE r_filebrowser_settings_menupane
+    {
+    items =
+        {
+        MENU_ITEM
+            {
+            command = EFileBrowserCmdSettingsChange;
+            txt = "Change";
+            },
+        MENU_ITEM
+            {
+            command = EFileBrowserCmdSettingsExit;
+            txt = "Exit";
+            }
+        };
+    }
+
+//----------------------------------------------------
+//    r_filebrowser_fileviewer_dialog
+//----------------------------------------------------
+//
+RESOURCE DIALOG r_filebrowser_fileviewer_dialog
+    {
+    flags =
+        EEikDialogFlagNoDrag | EEikDialogFlagFillAppClientRect |
+        EEikDialogFlagButtonsRight | EEikDialogFlagCbaButtons |
+        EEikDialogFlagWait | EEikDialogFlagNoTitleBar;
+    buttons = R_AVKON_SOFTKEYS_OPTIONS_BACK;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EFileViewerDialogControl;
+            id = EFileEditorDialogId;
+            }
+        };
+    }
+
+//----------------------------------------------------
+//    r_filebrowser_fileeditor_dialog
+//----------------------------------------------------
+//
+RESOURCE DIALOG r_filebrowser_fileeditor_dialog
+    {
+    flags =
+        EEikDialogFlagNoDrag | EEikDialogFlagFillAppClientRect |
+        EEikDialogFlagButtonsRight | EEikDialogFlagCbaButtons |
+        EEikDialogFlagWait | EEikDialogFlagNoTitleBar;
+    buttons = R_AVKON_SOFTKEYS_OPTIONS_BACK;
+    }
+
+//----------------------------------------------------
+//    r_filebrowser_fileviewer_menubar
+//----------------------------------------------------
+//
+RESOURCE MENU_BAR r_filebrowser_fileviewer_menubar
+    {
+    titles =
+        {
+        MENU_TITLE
+            {
+            menu_pane = r_filebrowser_fileviewer_menupane;
+            txt = " ";   // dummy
+            }
+        };
+    }
+
+RESOURCE MENU_PANE r_filebrowser_fileviewer_menupane
+    {
+    items =
+        {
+        MENU_ITEM { command = EFileBrowserCmdFileEditorViewAsText; txt = "View as text"; },
+        MENU_ITEM { command = EFileBrowserCmdFileEditorViewAsHex; txt = "View as hex"; },
+        MENU_ITEM { command = EFileBrowserCmdFileEditorExit; txt = "Exit"; }
+        };
+    }
+    
+//----------------------------------------------------
+//    r_filebrowser_fileeditor_menubar
+//----------------------------------------------------
+//
+
+RESOURCE MENU_BAR r_filebrowser_fileeditor_menubar
+    {
+    titles =
+        {
+        MENU_TITLE
+            {
+            menu_pane = r_filebrowser_fileeditor_menupane;
+            txt = " ";   // dummy
+            }
+        };
+    }
+
+RESOURCE MENU_PANE r_filebrowser_fileeditor_menupane
+    {
+    items =
+        {
+        MENU_ITEM { command = EFileBrowserCmdFileEditorSave; txt = "Save"; },
+        MENU_ITEM { command = EFileBrowserCmdFileEditorSaveAs; txt = "Save as..."; },
+        MENU_ITEM { command = EFileBrowserCmdFileEditorSaveFormat; txt = "Save format"; cascade=r_filebrowser_fileeditor_saveformat_submenu; },
+        MENU_ITEM { command = EFileBrowserCmdFileEditorEditAsText; txt = "Edit as text"; },
+        MENU_ITEM { command = EFileBrowserCmdFileEditorEditAsHex; txt = "Edit as hex"; },
+        MENU_ITEM { command = EFileBrowserCmdFileEditorExit; txt = "Exit"; }
+        };
+    }
+
+RESOURCE MENU_PANE r_filebrowser_fileeditor_saveformat_submenu
+    {
+    items = 
+        {
+        MENU_ITEM { command=EFileBrowserCmdFileEditorSaveFormatANSIASCII; txt="ANSI/ASCII"; flags = EEikMenuItemRadioStart | EEikMenuItemSymbolOn; },
+        MENU_ITEM { command=EFileBrowserCmdFileEditorSaveFormatUTF8; txt="UTF-8"; flags = EEikMenuItemRadioMiddle; },
+        MENU_ITEM { command=EFileBrowserCmdFileEditorSaveFormatUTF16LE; txt="UTF-16 LE"; flags = EEikMenuItemRadioMiddle; },
+        MENU_ITEM { command=EFileBrowserCmdFileEditorSaveFormatUTF16BE; txt="UTF-16 BE"; flags = EEikMenuItemRadioEnd; }
+        };
+    }
+    
+//----------------------------------------------------
+//   
+//    Setting item resources
+//
+//----------------------------------------------------
+//
+RESOURCE POPUP_SETTING_LIST r_popup_setting_list_editor
+	{
+	}
+
+
+//
+// resources for display mode selection
+//
+RESOURCE TBUF r_displaymodeselection_setting_title
+    {
+    buf = "Display mode";
+    }
+RESOURCE AVKON_SETTING_PAGE r_displaymodeselection_setting_page
+	{
+    number = EAknSettingPageNoOrdinalDisplayed; 
+	type = EAknCtPopupSettingList;
+	editor_resource_id = r_popup_setting_list_editor;
+	}
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_displaymodeselection_setting_texts
+	{
+	setting_texts_resource = r_displaymodeselection_text_array;
+	}
+RESOURCE ARRAY r_displaymodeselection_text_array
+	{
+	items =
+		{
+		AVKON_ENUMERATED_TEXT { value=EDisplayModeFullScreen; text = "Full screen"; },
+		AVKON_ENUMERATED_TEXT { value=EDisplayModeNormal; text = "Normal"; }
+		};
+	}
+
+
+//
+// resources for file view mode selection
+//
+RESOURCE TBUF r_fileviewmodeselection_setting_title
+    {
+    buf = "File view";
+    }
+RESOURCE AVKON_SETTING_PAGE r_fileviewmodeselection_setting_page
+	{
+    number = EAknSettingPageNoOrdinalDisplayed; 
+	type = EAknCtPopupSettingList;
+	editor_resource_id = r_popup_setting_list_editor;
+	}
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_fileviewmodeselection_setting_texts
+	{
+	setting_texts_resource = r_fileviewmodeselection_text_array;
+	}
+RESOURCE ARRAY r_fileviewmodeselection_text_array
+	{
+	items =
+		{
+		AVKON_ENUMERATED_TEXT { value=EFileViewModeSimple; text = "Simple"; },
+		AVKON_ENUMERATED_TEXT { value=EFileViewModeExtended; text = "Extended"; }
+		};
+	}
+
+
+//
+// resources for binary selections
+//
+RESOURCE TBUF r_showsubdirectoryinfoselection_setting_title
+    {
+    buf = "Show subdirectory info";
+    }
+RESOURCE TBUF r_showassociatediconsselection_setting_title
+    {
+    buf = "Show associated icons";
+    }
+RESOURCE TBUF r_rememberlastpathselection_setting_title
+    {
+    buf = "Remember folder on exit"; 
+    }
+RESOURCE TBUF r_rememberfolderselection_setting_title
+    {
+    buf = "Remember last folder";
+    }
+RESOURCE TBUF r_enabletoolbar_setting_title
+    {
+    buf = "Show toolbar";
+    }
+RESOURCE TBUF r_supportnetworkdrivesselection_setting_title
+    {
+    buf = "Support net drives";
+    }
+RESOURCE TBUF r_bypassplatformsecurityselection_setting_title
+    {
+    buf = "Bypass plat. security";
+    }
+RESOURCE TBUF R_REMOVEFILELOCKSSELECTION_SETTING_TITLE
+    {
+    buf = "Unlock files via SB";
+    }        
+RESOURCE TBUF R_IGNOREPROTECTIONATTSSELECTION_SETTING_TITLE
+    {
+    buf = "Ign. protection atts";
+    } 
+RESOURCE TBUF R_REMOVEROMWRITEPROTECTIONSELECTION_SETTING_TITLE
+    {
+    buf = "No RO-att copy from Z:";
+    } 
+RESOURCE AVKON_SETTING_PAGE r_binary_setting_page
+    {   
+    number = EAknSettingPageNoOrdinalDisplayed;
+    type = EAknCtPopupSettingList;
+	editor_resource_id = r_popup_setting_list_editor;
+    }
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_yesno_binaryselection_texts
+	{
+	setting_texts_resource = r_yesno_binaryselection_text_array;
+	}
+RESOURCE ARRAY r_yesno_binaryselection_text_array
+	{
+	items =
+		{
+		AVKON_ENUMERATED_TEXT { value=0; text = "No"; },
+		AVKON_ENUMERATED_TEXT { value=1; text = "Yes"; }
+		};
+	}
+		
+  
+// ---------------------------------------------------------
+//   
+//   r_filebrowser_about_dialog
+//   About dialog - show version and copyright info etc.
+//
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_filebrowser_about_dialog
+    {
+    flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow;
+    buttons = R_AVKON_SOFTKEYS_OK_EMPTY;
+    items=
+        {
+        DLG_LINE
+            {
+            type = EAknCtPopupHeadingPane;
+            id = EAknMessageQueryHeaderId;
+            control = AVKON_HEADING
+                {
+                label = "About FileBrowser";
+                headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE;
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtMessageQuery;
+            id = EAknMessageQueryContentId;
+            control = AVKON_MESSAGE_QUERY
+                {
+                message = "Version 4.5.2 - 10th December 2009. Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0.";
+                };
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+//   
+//   r_general_confirmation_query
+//   
+//
+// ---------------------------------------------------------
+//
+
+RESOURCE DIALOG r_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_general_text_query
+//   
+//
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_general_text_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items=
+        {
+        DLG_LINE
+            {
+            type = EAknCtQuery;
+            id = EGeneralQuery;
+            control = AVKON_DATA_QUERY
+                {
+                layout = EDataLayout;
+                control = EDWIN
+                    {
+                    width = 256;
+                    lines = 3;
+                    maxlength = 256;
+                    };
+                };
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+//   
+//   r_general_numeric_query
+//   
+//
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_general_numeric_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtQuery;
+            id = EGeneralQuery;
+            control= AVKON_DATA_QUERY
+                {
+                layout = ENumberLayout;
+                control = AVKON_INTEGER_EDWIN
+                    {
+                    min = -999999;
+                    max = 999999;
+                    };
+                };
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+//   
+//   r_general_progress_note
+//   
+//
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_general_progress_note
+    {
+    flags = EAknProgressNoteFlags;
+    buttons = R_AVKON_SOFTKEYS_CANCEL;
+    items=
+        {
+        DLG_LINE
+            {
+            type = EAknCtNote;
+            id = EFileBrowserProgressNote;
+            control = AVKON_NOTE
+                {
+                layout = EProgressLayout;
+                singular_label = "Processing";
+                };
+            }
+        };
+    }
+    
+// ---------------------------------------------------------
+//   
+//   r_general_wait_note
+//   
+//
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_general_wait_note
+    {
+    flags = EAknWaitNoteFlags | EEikDialogFlagNotifyEsc;
+    buttons = R_AVKON_SOFTKEYS_CANCEL;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtNote;
+            id = EFileBrowserWaitNote;
+            control= AVKON_NOTE 
+                { 
+                layout = EWaitLayout;
+                animation = R_QGN_GRAF_WAIT_BAR_ANIM;
+                };
+            }
+        };
+    }
+    
+// ---------------------------------------------------------
+//   
+//   r_entry_overwrite_type_query
+//   
+//
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_entry_overwrite_type_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            control= AVKON_LIST_QUERY_CONTROL
+                {
+				listtype = EAknCtSinglePopupMenuListBox;
+				listbox = AVKON_LIST_QUERY_LIST
+					{
+					array_id = r_entry_overwrite_type_query_array;
+					};
+				heading = "Overwrite?";				
+			    };
+            }
+        };
+    }
+
+RESOURCE ARRAY r_entry_overwrite_type_query_array
+	{
+	items =
+		{
+		LBUF {txt = "Overwrite all"; },
+		LBUF {txt = "Skip all existing"; },
+		LBUF {txt = "Gen. unique filenames"; },
+		LBUF {txt = "Query postfix"; }
+		};
+	}
+
+// ---------------------------------------------------------
+//   
+//   r_app_selection_query
+//   
+//
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_app_selection_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            control= AVKON_LIST_QUERY_CONTROL
+                {
+				listtype = EAknCtSinglePopupMenuListBox;
+				listbox = AVKON_LIST_QUERY_LIST
+					{
+					};
+				heading = "Choose app:";				
+			    };
+            }
+        };
+    }        
+
+// ---------------------------------------------------------
+//   
+//   r_copy_to_folder_selection_query
+//   
+//
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_copy_to_folder_selection_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            control= AVKON_LIST_QUERY_CONTROL
+                {
+				listtype = EAknCtSingleGraphicPopupMenuListBox;
+				listbox = AVKON_LIST_QUERY_LIST
+					{
+					};
+				heading = "Copy To";				
+			    };
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+//   
+//   r_move_to_folder_selection_query
+//   
+//
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_move_to_folder_selection_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            control= AVKON_LIST_QUERY_CONTROL
+                {
+				listtype = EAknCtSingleGraphicPopupMenuListBox;
+				listbox = AVKON_LIST_QUERY_LIST
+					{
+					};
+				heading = "Move To";				
+			    };
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+//   r_memoryinfo_dialog
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_memoryinfo_dialog
+    {
+    flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow;
+    buttons = R_AVKON_SOFTKEYS_OK_EMPTY;
+    items=
+        {
+        DLG_LINE
+            {
+            type = EAknCtPopupHeadingPane;
+            id = EAknMessageQueryHeaderId;
+            control = AVKON_HEADING
+                {
+                label = "Memory info";
+                headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE;
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtMessageQuery;
+            id = EAknMessageQueryContentId;
+            control = AVKON_MESSAGE_QUERY
+                {
+                message = ".";
+                };
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+//   r_checksums_dialog
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_checksums_dialog
+    {
+    flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow;
+    buttons = R_AVKON_SOFTKEYS_OK_EMPTY;
+    items=
+        {
+        DLG_LINE
+            {
+            type = EAknCtPopupHeadingPane;
+            id = EAknMessageQueryHeaderId;
+            control = AVKON_HEADING
+                {
+                label = "Checksums";
+                headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE;
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtMessageQuery;
+            id = EAknMessageQueryContentId;
+            control = AVKON_MESSAGE_QUERY
+                {
+                message = ".";
+                };
+            }
+        };
+    }
+    
+// ---------------------------------------------------------
+//   r_attribute_editor_form_dialog
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_attribute_editor_form_dialog
+    {
+    flags = EAknDialogGenericFullScreen;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    form = r_attribute_editor_form;
+    }
+
+RESOURCE FORM r_attribute_editor_form
+    {
+    flags = EEikFormEditModeOnly;
+    items = 
+        {
+        DLG_LINE
+            {
+            type = EAknCtPopupFieldText;
+            prompt = "Archive";
+            id = EFileBrowserAttributeEditorSetArchive;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = POPUP_FIELD_TEXT
+                {
+                popupfield = POPUP_FIELD
+                    {
+                    width = 100;
+                    };
+                textarray = r_attribute_editor_attmode_textarray;
+                active = 0;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtPopupFieldText;
+            prompt = "Hidden";
+            id = EFileBrowserAttributeEditorSetHidden;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = POPUP_FIELD_TEXT
+                {
+                popupfield = POPUP_FIELD
+                    {
+                    width = 100;
+                    };
+                textarray = r_attribute_editor_attmode_textarray;
+                active = 0;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtPopupFieldText;
+            prompt = "Read only";
+            id = EFileBrowserAttributeEditorSetReadOnly;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = POPUP_FIELD_TEXT
+                {
+                popupfield = POPUP_FIELD
+                    {
+                    width = 100;
+                    };
+                textarray = r_attribute_editor_attmode_textarray;
+                active = 0;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtPopupFieldText;
+            prompt = "System";
+            id = EFileBrowserAttributeEditorSetSystem;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = POPUP_FIELD_TEXT
+                {
+                popupfield = POPUP_FIELD
+                    {
+                    width = 100;
+                    };
+                textarray = r_attribute_editor_attmode_textarray;
+                active = 0;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtPopupFieldText;
+            prompt = "Recurse";
+            id = EFileBrowserAttributeEditorSetRecurse;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = POPUP_FIELD_TEXT
+                {
+                popupfield = POPUP_FIELD
+                    {
+                    width = 100;
+                    };
+                textarray = r_attribute_editor_recurse_textarray;
+                active = 0;    
+                };
+            }
+        };
+    }
+
+RESOURCE ARRAY r_attribute_editor_attmode_textarray
+    {
+    items =
+        {
+        LBUF { txt = "Skip"; },
+        LBUF { txt = "On"; },
+        LBUF { txt = "Off"; }
+        };
+    }    
+
+RESOURCE ARRAY r_attribute_editor_recurse_textarray
+    {
+    items =
+        {
+        LBUF { txt = "Recursive"; },
+        LBUF { txt = "Non-recursive"; }
+        };
+    } 
+
+// ---------------------------------------------------------
+//   r_search_query_form_dialog
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_search_query_form_dialog
+    {
+    flags = EAknDialogGenericFullScreen;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    form = r_search_query_form;
+    }
+
+RESOURCE FORM r_search_query_form
+    {
+    flags = EEikFormEditModeOnly;
+    items = 
+        {
+        DLG_LINE
+            {
+            type = EEikCtEdwin;
+            prompt = "Search dir";
+            id = EFileBrowserSearchQuerySearchDir;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = EDWIN
+                {
+                width = 255;    
+                maxlength = 255;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EEikCtEdwin;
+            prompt = "Wildcards";
+            id = EFileBrowserSearchQueryWildCards;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = EDWIN
+                {
+                width = 255;    
+                maxlength = 255;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EEikCtEdwin;
+            prompt = "Has string";
+            id = EFileBrowserSearchQueryTextInFile;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = EDWIN
+                {
+                width = 255;    
+                maxlength = 255;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtPopupFieldText;
+            prompt = "Recurse";
+            id = EFileBrowserSearchQueryRecurse;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = POPUP_FIELD_TEXT
+                {
+                popupfield = POPUP_FIELD
+                    {
+                    width = 100;
+                    };
+                textarray = r_search_query_recurse_textarray;
+                active = 0;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EEikCtNumberEditor;
+            prompt = "Min size";
+            id = EFileBrowserSearchQueryMinSize;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = NUMBER_EDITOR
+                {
+                min = 0;    
+                max = 999999999;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EEikCtNumberEditor;
+            prompt = "Max size";
+            id = EFileBrowserSearchQueryMaxSize;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = NUMBER_EDITOR
+                {
+                min = 0;    
+                max = 999999999;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EEikCtDateEditor;
+            prompt = "Min date";
+            id = EFileBrowserSearchQueryMinDate;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = DATE_EDITOR
+                {
+                minDate = DATE { day =  0; month =  0; year = 1980; };    
+                maxDate = DATE { day = 30; month = 11; year = 2060; };    
+                };
+            },
+        DLG_LINE
+            {
+            type = EEikCtDateEditor;
+            prompt = "Max date";
+            id = EFileBrowserSearchQueryMaxDate;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = DATE_EDITOR
+                {
+                minDate = DATE { day =  0; month =  0; year = 1980; };    
+                maxDate = DATE { day = 30; month = 11; year = 2060; };    
+                };
+            }
+        };
+    }
+
+RESOURCE ARRAY r_search_query_recurse_textarray
+    {
+    items =
+        {
+        LBUF { txt = "Non-recursive"; },
+        LBUF { txt = "Recursive"; }
+        };
+    } 
+
+// ---------------------------------------------------------
+//   r_data_types_dialog
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_data_types_dialog
+    {
+    flags =
+        EEikDialogFlagNoDrag | EEikDialogFlagFillAppClientRect |
+        EEikDialogFlagButtonsRight | EEikDialogFlagCbaButtons |
+        EEikDialogFlagWait | EEikDialogFlagNoTitleBar;
+    buttons = R_AVKON_SOFTKEYS_OPTIONS_BACK;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtSingleGraphicListBox;
+            id = EFileBrowserDataTypesList;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = LISTBOX
+                {
+                flags = EAknListBoxSelectionList;
+                };
+            }
+        };
+    }
+
+//----------------------------------------------------
+//    r_filebrowser_data_types_menubar
+//----------------------------------------------------
+//
+
+RESOURCE MENU_BAR r_filebrowser_data_types_menubar
+    {
+    titles =
+        {
+        MENU_TITLE
+            {
+            menu_pane = r_filebrowser_data_types_menupane;
+            txt = " ";   // dummy
+            }
+        };
+    }
+
+RESOURCE MENU_PANE r_filebrowser_data_types_menupane
+    {
+    items =
+        {
+        MENU_ITEM
+            {
+            command = EFileBrowserCmdDataTypesChangeMapping;
+            txt = "Change mapping";
+            },
+        MENU_ITEM
+            {
+            command = EFileBrowserCmdDataTypesSetDefaultMapping;
+            txt = "Set to default mapping";
+            },
+        MENU_ITEM
+            {
+            command = EFileBrowserCmdDataTypesRefresh;
+            txt = "Refresh";
+            },
+        MENU_ITEM
+            {
+            command = EFileBrowserCmdDataTypesExit;
+            txt = "Exit";
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+//   r_data_type_priority_query
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_data_type_priority_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            control= AVKON_LIST_QUERY_CONTROL
+                {
+				listtype = EAknCtSinglePopupMenuListBox;
+				listbox = AVKON_LIST_QUERY_LIST
+					{
+					array_id = r_data_type_priority_query_array;
+					};
+				heading = "Select priority";				
+			    };
+            }
+        };
+    }
+
+RESOURCE ARRAY r_data_type_priority_query_array
+	{
+	items =
+		{
+		LBUF {txt = "Maximum"; },
+		LBUF {txt = "High"; },
+		LBUF {txt = "Normal"; },
+		LBUF {txt = "Low"; },
+		LBUF {txt = "Last resort"; }
+		};
+	}
+
+// ---------------------------------------------------------
+//   r_securebackup_state_query
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_securebackup_state_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            control= AVKON_LIST_QUERY_CONTROL
+                {
+				listtype = EAknCtSinglePopupMenuListBox;
+				listbox = AVKON_LIST_QUERY_LIST
+					{
+					array_id = r_securebackup_state_query_array;
+					};
+				heading = "Select state";				
+			    };
+            }
+        };
+    }
+
+RESOURCE ARRAY r_securebackup_state_query_array
+	{
+	items =
+		{
+		LBUF {txt = "Full"; },
+		LBUF {txt = "Partial"; }
+		};
+	}
+
+// ---------------------------------------------------------
+//   r_securebackup_type_query
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_securebackup_type_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            control= AVKON_LIST_QUERY_CONTROL
+                {
+				listtype = EAknCtSinglePopupMenuListBox;
+				listbox = AVKON_LIST_QUERY_LIST
+					{
+					array_id = r_securebackup_type_query_array;
+					};
+				heading = "Select type";				
+			    };
+            }
+        };
+    }
+
+RESOURCE ARRAY r_securebackup_type_query_array
+	{
+	items =
+		{
+		LBUF {txt = "Base (all data)"; },
+		LBUF {txt = "Increment"; }
+		};
+	}
+	
+// ---------------------------------------------------------
+//   r_partition_amount_query
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_partition_amount_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            control= AVKON_LIST_QUERY_CONTROL
+                {
+				listtype = EAknCtSinglePopupMenuListBox;
+				listbox = AVKON_LIST_QUERY_LIST
+					{
+					array_id = r_partition_amount_query_array;
+					};
+				heading = "Partitions?";
+			    };
+            }
+        };
+    }
+
+RESOURCE ARRAY r_partition_amount_query_array
+	{
+	items =
+		{
+		LBUF {txt = "1"; },
+		LBUF {txt = "2"; },
+		LBUF {txt = "3"; },
+		LBUF {txt = "4"; }
+		};
+	} 	
+
+// ---------------------------------------------------------
+//   r_common_file_action_query
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_common_file_action_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            control= AVKON_LIST_QUERY_CONTROL
+                {
+				listtype = EAknCtSinglePopupMenuListBox;
+				listbox = AVKON_LIST_QUERY_LIST
+					{
+					array_id = r_common_file_action_query_array;
+					};
+				heading = "";
+			    };
+            }
+        };
+    }
+
+RESOURCE ARRAY r_common_file_action_query_array
+	{
+	items =
+		{
+		LBUF {txt = "View as text/hex"; },
+		LBUF {txt = "Open w/ AppArc"; },
+		LBUF {txt = "Open w/ DocH. embed"; }
+		};
+	} 
+		        
+// ---------------------------------------------------------
+//   
+// RESOURCE LOCALISABLE_APP_INFO r_filebrowser_localisable_app_info
+//
+// ---------------------------------------------------------
+//
+RESOURCE LOCALISABLE_APP_INFO r_filebrowser_localisable_app_info
+    {
+    short_caption = "FileBrowser";
+    caption_and_icon = 
+    CAPTION_AND_ICON_INFO
+        {
+        caption = "FileBrowser";
+
+        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"\\filebrowser_aif.mif";
+        };
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/data/filebrowser_reg.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,35 @@
+/*
+* 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 <filebrowser.rsg>
+#include <appinfo.rh>
+#include <data_caging_paths_strings.hrh>
+
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0x102828D6
+
+
+RESOURCE APP_REGISTRATION_INFO
+    {
+    app_file = "FileBrowser";
+    localisable_resource_file = APP_RESOURCE_DIR"\\FileBrowser";
+    localisable_resource_id = R_FILEBROWSER_LOCALISABLE_APP_INFO;
+    group_name = "RnD Tools";    
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/envpatcher/EnvPatcher.pl	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,544 @@
+#
+# 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;    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/envpatcher/ReadMe.txt	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,46 @@
+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".
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/fileopclient/BWINS/FileBrowserFileOpClientU.DEF	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,14 @@
+EXPORTS
+	??1CFBFileOpClient@@UAE@XZ @ 1 NONAME ; CFBFileOpClient::~CFBFileOpClient(void)
+	?Attribs@CFBFileOpClient@@QAEHABVTDesC16@@IIABVTTime@@I@Z @ 2 NONAME ; int CFBFileOpClient::Attribs(class TDesC16 const &, unsigned int, unsigned int, class TTime const &, unsigned int)
+	?Copy@CFBFileOpClient@@QAEHABVTDesC16@@0I@Z @ 3 NONAME ; int CFBFileOpClient::Copy(class TDesC16 const &, class TDesC16 const &, unsigned int)
+	?CreateEmptyFile@CFBFileOpClient@@QAEHABVTDesC16@@@Z @ 4 NONAME ; int CFBFileOpClient::CreateEmptyFile(class TDesC16 const &)
+	?Delete@CFBFileOpClient@@QAEHABVTDesC16@@I@Z @ 5 NONAME ; int CFBFileOpClient::Delete(class TDesC16 const &, unsigned int)
+	?EraseMBR@CFBFileOpClient@@QAEHI@Z @ 6 NONAME ; int CFBFileOpClient::EraseMBR(unsigned int)
+	?MkDirAll@CFBFileOpClient@@QAEHABVTDesC16@@@Z @ 7 NONAME ; int CFBFileOpClient::MkDirAll(class TDesC16 const &)
+	?NewL@CFBFileOpClient@@SAPAV1@XZ @ 8 NONAME ; class CFBFileOpClient * CFBFileOpClient::NewL(void)
+	?PartitionDrive@CFBFileOpClient@@QAEHII@Z @ 9 NONAME ; int CFBFileOpClient::PartitionDrive(unsigned int, unsigned int)
+	?Rename@CFBFileOpClient@@QAEHABVTDesC16@@0I@Z @ 10 NONAME ; int CFBFileOpClient::Rename(class TDesC16 const &, class TDesC16 const &, unsigned int)
+	?RmDir@CFBFileOpClient@@QAEHABVTDesC16@@I@Z @ 11 NONAME ; int CFBFileOpClient::RmDir(class TDesC16 const &, unsigned int)
+	?CancelOp@CFBFileOpClient@@QAEXXZ @ 12 NONAME ; void CFBFileOpClient::CancelOp(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/fileopclient/eabi/FileBrowserFileOpClientu.def	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,20 @@
+EXPORTS
+	_ZN15CFBFileOpClient14PartitionDriveEjj @ 1 NONAME
+	_ZN15CFBFileOpClient15CreateEmptyFileERK7TDesC16 @ 2 NONAME
+	_ZN15CFBFileOpClient4CopyERK7TDesC16S2_j @ 3 NONAME
+	_ZN15CFBFileOpClient4NewLEv @ 4 NONAME
+	_ZN15CFBFileOpClient5RmDirERK7TDesC16j @ 5 NONAME
+	_ZN15CFBFileOpClient6DeleteERK7TDesC16j @ 6 NONAME
+	_ZN15CFBFileOpClient6RenameERK7TDesC16S2_j @ 7 NONAME
+	_ZN15CFBFileOpClient7AttribsERK7TDesC16jjRK5TTimej @ 8 NONAME
+	_ZN15CFBFileOpClient8EraseMBREj @ 9 NONAME
+	_ZN15CFBFileOpClient8MkDirAllERK7TDesC16 @ 10 NONAME
+	_ZN15CFBFileOpClientD0Ev @ 11 NONAME
+	_ZN15CFBFileOpClientD1Ev @ 12 NONAME
+	_ZN15CFBFileOpClientD2Ev @ 13 NONAME
+	_ZTI15CFBFileOpClient @ 14 NONAME ; #<TI>#
+	_ZTV15CFBFileOpClient @ 15 NONAME ; #<VT>#
+	_ZN15CFBFileOpClient8CancelOpEv @ 16 NONAME
+	_ZTI18CAsyncWaiterClient @ 17 NONAME ; #<TI>#
+	_ZTV18CAsyncWaiterClient @ 18 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/fileopclient/group/FBFileOpClient.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+
+TARGET        FileBrowserFileOpClient.dll
+TARGETTYPE    dll
+
+CAPABILITY 	  CAP_GENERAL_DLL
+
+SMPSAFE
+
+UID           0x102828D7
+VENDORID      VID_DEFAULT
+
+
+USERINCLUDE       ../inc
+SOURCEPATH        ../src
+OS_LAYER_SYSTEMINCLUDE
+
+
+SOURCE        FBFileOpClient.cpp
+
+LIBRARY       euser.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/fileopclient/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,20 @@
+/*
+* 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:  
+*
+*/
+
+
+PRJ_MMPFILES
+FBFileOpClient.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/fileopclient/inc/FBFileOpClient.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,108 @@
+/*
+* 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 __FBFILEOPCLIENT_H__
+#define __FBFILEOPCLIENT_H__
+
+// INCLUDES
+#include <e32base.h>
+#include <f32file.h>
+#include "FBFileOpClientServer.h" // TFileOpArgs
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATIONS
+
+class RFBFileOpServerSession : public RSessionBase
+	{
+public:
+	TInt Connect();
+	
+	void Copy(const TDesC& aSourceFullName, const TDesC& aTargetFullName, TUint aSwitch, TRequestStatus& aStatus);
+    TInt Rename(const TDesC& anOld, const TDesC& aNew, TUint aSwitch); 
+    TInt Attribs(const TDesC& aName, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch); 
+    void RmDir(const TDesC& aDirName, TUint aSwitch, TRequestStatus& aStatus); 
+    void Delete(const TDesC& aName, TUint aSwitch, TRequestStatus& aStatus); 
+    TInt MkDirAll(const TDesC& aPath); 
+    TInt CreateEmptyFile(const TDesC& aName); 
+    TInt EraseMBR(TUint aDriveNumber); 
+    TInt PartitionDrive(TUint aDriveNumber, TUint aNumberOfPartitions);
+    TInt CancelOp();
+
+private:
+	TVersion Version() const;
+	TPckgBuf<TFileOpArgs> iPckgBuf;
+	};
+
+
+class CFBFileOpClient : public CBase
+    {
+public:
+    IMPORT_C static CFBFileOpClient* NewL();
+    IMPORT_C ~CFBFileOpClient();
+	IMPORT_C TInt Copy(const TDesC& aSourceFullName, const TDesC& aTargetFullName, TUint aSwitch); 
+    IMPORT_C TInt Rename(const TDesC& anOld, const TDesC& aNew, TUint aSwitch); 
+    IMPORT_C TInt Attribs(const TDesC& aName, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch); 
+    IMPORT_C TInt RmDir(const TDesC& aDirName, TUint aSwitch); 
+    IMPORT_C TInt Delete(const TDesC& aName, TUint aSwitch); 
+    IMPORT_C TInt MkDirAll(const TDesC& aPath); 
+    IMPORT_C TInt CreateEmptyFile(const TDesC& aName); 
+    IMPORT_C TInt EraseMBR(TUint aDriveNumber); 
+    IMPORT_C TInt PartitionDrive(TUint aDriveNumber, TUint aNumberOfPartitions); 
+    IMPORT_C void CancelOp();
+    
+private:
+    CFBFileOpClient();
+    void ConstructL();
+    
+ private :
+    RFBFileOpServerSession  iFBFileOpServerSession;
+    };
+
+
+/**
+ * Similar class as CAsyncWaiter defined in FBUtils.h, except
+ * CAsyncWaiterClient uses iWait.AsyncStop() instead of   
+ * CAknEnv::StopSchedulerWaitWithBusyMessage( iWait )
+ * to stop the nested loop. This class can be utilized
+ * if CAknEnv is not running.
+ */
+class CAsyncWaiterClient : public CActive
+    {
+public:
+    static CAsyncWaiterClient* NewL( TInt aPriority = EPriorityStandard );
+    static CAsyncWaiterClient* NewLC( TInt aPriority = EPriorityStandard );
+    ~CAsyncWaiterClient();
+    
+    void StartAndWait();
+    TInt Result() const;
+    
+private:
+    CAsyncWaiterClient( TInt aPriority );
+    
+    // from CActive
+    void RunL();
+    void DoCancel();
+    
+private:
+    CActiveSchedulerWait iWait;
+    TInt iError;
+    };
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/fileopclient/inc/FBFileOpClientServer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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 __FBCLIENTSERVER_H__
+#define __FBCLIENTSERVER_H__
+
+#include <e32std.h>
+
+const TUint KCopyServMajorVersionNumber = 1;
+const TUint KCopyServMinorVersionNumber = 0;
+const TUint KCopyServBuildVersionNumber = 0;
+
+_LIT(KMyServerName, "FileBrowserFileOpServer");
+_LIT(KMyServerImg, "FileBrowserFileOpServer");		// EXE name
+const TUid KServerUid3 = {0x102828D8};
+
+enum TFileOpMessages
+	{
+	EFileOpCopy,
+	EFileOpRename,
+	EFileOpAttribs,
+	EFileOpRmDir,
+	EFileOpDelete,
+	EFileOpMkDirAll,
+	EFileOpCreateEmptyFile,
+	EFileOpEraseMBR,
+	EFileOpPartitionDrive,
+	EFileOpCancel
+	};
+
+class TFileOpArgs
+    {
+public:
+    TFileName   iBuf1;
+    TFileName   iBuf2;
+    TUint       iUint1;
+    TUint       iUint2;
+    TUint       iUint3;
+    TTime       iTime1;
+    };
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/fileopclient/src/FBFileOpClient.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,481 @@
+/*
+* 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:  
+*
+*/
+
+
+// needed for client interface
+#include "FBFileOpClient.h"
+
+const TUint KDefaultMessageSlots=4;
+
+// --------------------------------------------------------------------------------------------
+
+static TInt StartServer()
+//
+// Start the server process. Simultaneous launching
+// of two such processes should be detected when the second one attempts to
+// create the server object, failing with KErrAlreadyExists.
+//
+	{
+	const TUidType serverUid(KNullUid,KNullUid,KServerUid3);
+	RProcess server;
+	TInt r=server.Create(KMyServerImg,KNullDesC,serverUid);
+	if (r!=KErrNone)
+		return r;
+	TRequestStatus stat;
+	server.Rendezvous(stat);
+	if (stat!=KRequestPending)
+		server.Kill(0);		// abort startup
+	else
+		server.Resume();	// logon OK - start the server
+	User::WaitForRequest(stat);		// wait for start or death
+	// we can't use the 'exit reason' if the server panicked as this
+	// is the panic 'reason' and may be '0' which cannot be distinguished
+	// from KErrNone
+	r=(server.ExitType()==EExitPanic) ? KErrGeneral : stat.Int();
+	server.Close();
+	return r;
+	}
+
+// --------------------------------------------------------------------------------------------
+
+TVersion RFBFileOpServerSession::Version(void) const
+	{
+	return(TVersion(KCopyServMajorVersionNumber,KCopyServMinorVersionNumber,KCopyServBuildVersionNumber));
+	}
+
+// --------------------------------------------------------------------------------------------
+
+TInt RFBFileOpServerSession::Connect()
+//
+// Connect to the server, attempting to start it if necessary
+//
+	{
+	TInt retry=2;
+	for (;;)
+		{
+		TInt r=CreateSession(KMyServerName,Version(),KDefaultMessageSlots);
+		if (r!=KErrNotFound && r!=KErrServerTerminated)
+			return r;
+		if (--retry==0)
+			return r;
+		r=StartServer();
+		if (r!=KErrNone && r!=KErrAlreadyExists)
+			return r;
+		}
+	}
+
+// --------------------------------------------------------------------------------------------
+
+void RFBFileOpServerSession::Copy(const TDesC& aSourceFullName, const TDesC& aTargetFullName, TUint aSwitch, TRequestStatus& aStatus) 
+    {
+    TFileOpArgs argsStruct = TFileOpArgs();
+    argsStruct.iBuf1.Copy(aSourceFullName);
+    argsStruct.iBuf2.Copy(aTargetFullName);
+    argsStruct.iUint1 = aSwitch;
+    
+    iPckgBuf = argsStruct;
+    TIpcArgs args(&iPckgBuf);
+    SendReceive(EFileOpCopy, args, aStatus);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt RFBFileOpServerSession::Rename(const TDesC& anOld, const TDesC& aNew, TUint aSwitch) 
+    {
+    TFileOpArgs argsStruct = TFileOpArgs();
+    argsStruct.iBuf1.Copy(anOld);
+    argsStruct.iBuf2.Copy(aNew);
+    argsStruct.iUint1 = aSwitch;
+    
+    TPckgBuf<TFileOpArgs> pckgBuf;
+    pckgBuf = argsStruct;
+	TIpcArgs args(&pckgBuf);
+	return SendReceive(EFileOpRename, args);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt RFBFileOpServerSession::Attribs(const TDesC& aName, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch) 
+    {
+    TFileOpArgs argsStruct = TFileOpArgs();
+    argsStruct.iBuf1.Copy(aName);
+    argsStruct.iUint1 = aSetMask;
+    argsStruct.iUint2 = aClearMask;
+    argsStruct.iTime1 = aTime;
+    argsStruct.iUint3 = aSwitch;
+    
+    TPckgBuf<TFileOpArgs> pckgBuf;
+    pckgBuf = argsStruct;
+	TIpcArgs args(&pckgBuf);
+	return SendReceive(EFileOpAttribs, args);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void RFBFileOpServerSession::RmDir( const TDesC& aDirName,
+                                    TUint aSwitch,
+                                    TRequestStatus& aStatus ) 
+    {
+    TFileOpArgs argsStruct = TFileOpArgs();
+    argsStruct.iBuf1.Copy(aDirName);
+    argsStruct.iUint1 = aSwitch;
+
+    iPckgBuf = argsStruct;
+    TIpcArgs args(&iPckgBuf);
+	SendReceive(EFileOpRmDir, args, aStatus);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void RFBFileOpServerSession::Delete(const TDesC& aName, TUint aSwitch, TRequestStatus& aStatus) 
+    {
+    TFileOpArgs argsStruct = TFileOpArgs();
+    argsStruct.iBuf1.Copy(aName);
+    argsStruct.iUint1 = aSwitch;
+
+    iPckgBuf = argsStruct;
+    TIpcArgs args(&iPckgBuf);
+	SendReceive(EFileOpDelete, args, aStatus);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt RFBFileOpServerSession::MkDirAll(const TDesC& aPath) 
+    {
+    TFileOpArgs argsStruct = TFileOpArgs();
+    argsStruct.iBuf1.Copy(aPath);
+    
+    TPckgBuf<TFileOpArgs> pckgBuf;
+    pckgBuf = argsStruct;
+	TIpcArgs args(&pckgBuf);
+	return SendReceive(EFileOpMkDirAll, args);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt RFBFileOpServerSession::CreateEmptyFile(const TDesC& aName) 
+    {
+    TFileOpArgs argsStruct = TFileOpArgs();
+    argsStruct.iBuf1.Copy(aName);
+    
+    TPckgBuf<TFileOpArgs> pckgBuf;
+    pckgBuf = argsStruct;
+	TIpcArgs args(&pckgBuf);
+	return SendReceive(EFileOpCreateEmptyFile, args);
+    }
+// --------------------------------------------------------------------------------------------
+
+TInt RFBFileOpServerSession::EraseMBR(TUint aDriveNumber) 
+    {
+    TFileOpArgs argsStruct = TFileOpArgs();
+    argsStruct.iUint1 = aDriveNumber;
+        
+    TPckgBuf<TFileOpArgs> pckgBuf;
+    pckgBuf = argsStruct;
+	TIpcArgs args(&pckgBuf);
+	return SendReceive(EFileOpEraseMBR, args);
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TInt RFBFileOpServerSession::PartitionDrive(TUint aDriveNumber, TUint aNumberOfPartitions) 
+    {
+    TFileOpArgs argsStruct = TFileOpArgs();
+    argsStruct.iUint1 = aDriveNumber;
+    argsStruct.iUint2 = aNumberOfPartitions;
+        
+    TPckgBuf<TFileOpArgs> pckgBuf;
+    pckgBuf = argsStruct;
+	TIpcArgs args(&pckgBuf);
+	return SendReceive(EFileOpPartitionDrive, args);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt RFBFileOpServerSession::CancelOp() 
+    {
+    TIpcArgs args( NULL );
+    return SendReceive( EFileOpCancel, args );
+    }
+
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+EXPORT_C CFBFileOpClient* CFBFileOpClient::NewL()
+    {
+    CFBFileOpClient* self = new(ELeave) CFBFileOpClient;
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+EXPORT_C CFBFileOpClient::~CFBFileOpClient()
+    {
+    iFBFileOpServerSession.Close();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CFBFileOpClient::CFBFileOpClient()
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFBFileOpClient::ConstructL()
+    {	
+    User::LeaveIfError(iFBFileOpServerSession.Connect());
+    }
+
+// --------------------------------------------------------------------------------------------
+
+EXPORT_C TInt CFBFileOpClient::Copy( const TDesC& aSourceFullName,
+                                     const TDesC& aTargetFullName,
+                                     TUint aSwitch ) 
+    {
+    CAsyncWaiterClient* waiter = CAsyncWaiterClient::NewLC();
+    iFBFileOpServerSession.Copy( aSourceFullName, aTargetFullName, aSwitch, waiter->iStatus );
+    waiter->StartAndWait();
+    TInt err = waiter->Result();
+    
+    if ( err == KErrServerTerminated )
+        {
+        User::LeaveIfError( iFBFileOpServerSession.Connect() );
+        iFBFileOpServerSession.Copy( aSourceFullName, aTargetFullName, aSwitch, waiter->iStatus );
+        waiter->StartAndWait();
+        err = waiter->Result();
+        }
+    CleanupStack::PopAndDestroy( waiter );
+    return err;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+EXPORT_C TInt CFBFileOpClient::Rename(const TDesC& anOld, const TDesC& aNew, TUint aSwitch) 
+    {
+    TInt err = iFBFileOpServerSession.Rename(anOld, aNew, aSwitch);
+        
+    if (err == KErrServerTerminated)
+        {
+        User::LeaveIfError(iFBFileOpServerSession.Connect());
+        err = iFBFileOpServerSession.Rename(anOld, aNew, aSwitch);
+        }
+    
+    return err;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+EXPORT_C TInt CFBFileOpClient::Attribs(const TDesC& aName, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch) 
+    {
+    TInt err = iFBFileOpServerSession.Attribs(aName, aSetMask, aClearMask, aTime, aSwitch);
+    
+    if (err == KErrServerTerminated)
+        {
+        User::LeaveIfError(iFBFileOpServerSession.Connect());
+        err = iFBFileOpServerSession.Attribs(aName, aSetMask, aClearMask, aTime, aSwitch);
+        }
+    
+    return err;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+EXPORT_C TInt CFBFileOpClient::RmDir(const TDesC& aDirName, TUint aSwitch)
+    {
+    CAsyncWaiterClient* waiter = CAsyncWaiterClient::NewLC();
+    iFBFileOpServerSession.RmDir( aDirName, aSwitch, waiter->iStatus );
+    waiter->StartAndWait();
+    TInt err = waiter->Result();
+    
+    if ( err == KErrServerTerminated )
+        {
+        User::LeaveIfError( iFBFileOpServerSession.Connect() );
+        iFBFileOpServerSession.RmDir( aDirName, aSwitch, waiter->iStatus );
+        waiter->StartAndWait();
+        err = waiter->Result();
+        }
+    CleanupStack::PopAndDestroy( waiter );
+    return err;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+EXPORT_C TInt CFBFileOpClient::Delete(const TDesC& aName, TUint aSwitch)
+    {
+    CAsyncWaiterClient* waiter = CAsyncWaiterClient::NewLC();
+    iFBFileOpServerSession.Delete(aName, aSwitch, waiter->iStatus );
+    waiter->StartAndWait();
+    TInt err = waiter->Result();
+    
+    if ( err == KErrServerTerminated )
+        {
+        User::LeaveIfError( iFBFileOpServerSession.Connect() );
+        iFBFileOpServerSession.Delete(aName, aSwitch, waiter->iStatus );
+        waiter->StartAndWait();
+        err = waiter->Result();
+        }
+    CleanupStack::PopAndDestroy( waiter );
+    return err;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+EXPORT_C TInt CFBFileOpClient::MkDirAll(const TDesC& aPath) 
+    {
+    TInt err = iFBFileOpServerSession.MkDirAll(aPath);
+    
+    if (err == KErrServerTerminated)
+        {
+        User::LeaveIfError(iFBFileOpServerSession.Connect());
+        err = iFBFileOpServerSession.MkDirAll(aPath);
+        }
+            
+    return err;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+EXPORT_C TInt CFBFileOpClient::CreateEmptyFile(const TDesC& aName) 
+    {
+    TInt err = iFBFileOpServerSession.CreateEmptyFile(aName);
+    
+    if (err == KErrServerTerminated)
+        {
+        User::LeaveIfError(iFBFileOpServerSession.Connect());
+        err = iFBFileOpServerSession.CreateEmptyFile(aName);
+        }
+
+    return err;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+EXPORT_C TInt CFBFileOpClient::EraseMBR(TUint aDriveNumber) 
+    {
+    TInt err = iFBFileOpServerSession.EraseMBR(aDriveNumber);
+    
+    if (err == KErrServerTerminated)
+        {
+        User::LeaveIfError(iFBFileOpServerSession.Connect());
+        err = iFBFileOpServerSession.EraseMBR(aDriveNumber);
+        }
+
+    return err;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+EXPORT_C TInt CFBFileOpClient::PartitionDrive(TUint aDriveNumber, TUint aNumberOfPartitions) 
+    {
+    TInt err = iFBFileOpServerSession.PartitionDrive(aDriveNumber, aNumberOfPartitions);
+    
+    if (err == KErrServerTerminated)
+        {
+        User::LeaveIfError(iFBFileOpServerSession.Connect());
+        err = iFBFileOpServerSession.PartitionDrive(aDriveNumber, aNumberOfPartitions);
+        }
+
+    return err;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+EXPORT_C void CFBFileOpClient::CancelOp() 
+    {
+    TInt err = iFBFileOpServerSession.CancelOp();
+    
+    if ( err == KErrServerTerminated )
+        {
+        User::LeaveIfError( iFBFileOpServerSession.Connect() );
+        err = iFBFileOpServerSession.CancelOp(); // Ignore return value this time
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+CAsyncWaiterClient* CAsyncWaiterClient::NewL( TInt aPriority )
+    {
+    CAsyncWaiterClient* self = new(ELeave) CAsyncWaiterClient( aPriority );
+    return self;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CAsyncWaiterClient* CAsyncWaiterClient::NewLC( TInt aPriority )
+    {
+    CAsyncWaiterClient* self = new (ELeave) CAsyncWaiterClient( aPriority );
+    CleanupStack::PushL( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------------------------
+    
+CAsyncWaiterClient::CAsyncWaiterClient( TInt aPriority ) : CActive( aPriority )
+    {
+    CActiveScheduler::Add( this );
+    }   
+
+// --------------------------------------------------------------------------------------------
+
+CAsyncWaiterClient::~CAsyncWaiterClient()
+    {
+    Cancel();
+    }
+
+// --------------------------------------------------------------------------------------------
+    
+void CAsyncWaiterClient::StartAndWait()
+    {
+    SetActive();
+    iWait.Start();
+    }
+
+// --------------------------------------------------------------------------------------------
+    
+TInt CAsyncWaiterClient::Result() const
+    {
+    return iError;
+    }
+
+// --------------------------------------------------------------------------------------------
+    
+void CAsyncWaiterClient::RunL()
+    {
+    iError = iStatus.Int();
+    iWait.AsyncStop();
+    }
+
+// --------------------------------------------------------------------------------------------
+    
+void CAsyncWaiterClient::DoCancel()
+    {
+    iError = KErrCancel;
+    if( iStatus == KRequestPending )
+        {
+        TRequestStatus* s = &iStatus;
+        User::RequestComplete( s, KErrCancel );
+        }
+    iWait.AsyncStop();
+    }
+
+// --------------------------------------------------------------------------------------------
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/fileopserver/group/FBFileOpServer.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,44 @@
+/*
+* 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        FileBrowserFileOpServer.exe
+TARGETTYPE    exe
+UID           0 0x102828D8
+VENDORID      VID_DEFAULT
+
+CAPABILITY    CAP_FILE_SERVER
+
+SMPSAFE
+
+USERINCLUDE   ../inc
+USERINCLUDE   ../../fileopclient/inc
+OS_LAYER_SYSTEMINCLUDE
+//SYSTEMINCLUDE /epoc32/include/kernel
+SOURCEPATH    ../src
+
+
+SOURCE        FBFileOpServer.cpp
+SOURCE        FBDrivePartitioner.cpp
+
+LIBRARY       euser.lib
+LIBRARY       efsrv.lib
+LIBRARY       efile.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/fileopserver/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,20 @@
+/*
+* 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:  
+*
+*/
+
+
+PRJ_MMPFILES
+FBFileOpServer.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/fileopserver/inc/FBDrivePartitioner.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,35 @@
+/*
+* 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 __FBDRIVEPARTITIONER_H__
+#define __FBDRIVEPARTITIONER_H__
+
+#include <e32base.h>
+#include <f32file.h>
+
+class FBDrivePartioner
+    {
+public:
+    static TInt FindLocalDriveNumber(RFs& aFs, TInt aDriveNumber, TInt& aLocalDriveNum);
+    static TInt EraseMBR(RFs& aFs, TInt aDriveNumber);
+    static TInt CreatePartitions(RFs& aFs, TInt aDriveNumber, TInt aPartCount);
+    static TInt FormatPartitions(RFs& aFs, TInt aDriveNumber, TInt aPartCount);    
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/fileopserver/inc/FBFileOpServer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,186 @@
+/*
+* 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 __FBFILEOPSERVER_H__
+#define __FBFILEOPSERVER_H__
+
+#include <e32base.h>
+#include <f32file.h>
+#include "FBFileOpClientServer.h"
+
+// needed for creating server thread.
+//const TUint KDefaultHeapSize=0x10000;
+
+// reasons for server panic
+enum TMyPanic
+	{
+	EPanicBadDescriptor,
+	EPanicIllegalFunction
+	};
+
+class CShutdown : public CTimer
+	{
+	enum {KMyShutdownDelay=0x200000};	// approx 2s
+
+public :
+	inline CShutdown();
+	inline void ConstructL();
+	inline void Start();
+
+private :
+	void RunL();
+	};
+
+//**********************************
+//CFBFileOpServer
+//**********************************
+/**
+Our server class - an active object - and therefore derived ultimately from CActive.
+It accepts requests from client threads and forwards
+them to the client session to be dealt with. It also handles the creation
+of the server-side client session.
+*/
+class CFBFileOpServer : public CServer2
+	{
+
+public :
+	static CServer2* NewLC();
+	void AddSession();
+	void DropSession();
+
+protected :
+
+private :
+	CFBFileOpServer();
+	void ConstructL();
+	CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
+
+public :
+
+private :
+	TInt iSessionCount;
+	CShutdown iShutdown;
+	
+	};
+
+//**********************************
+//CRequestObserver
+//**********************************
+/**
+This class is for monitoring asynchronous request
+and for completing related RMessage2 object.
+*/
+class CRequestObserver : public CActive
+    {
+public:
+    CRequestObserver( TInt aPriority );
+    virtual ~CRequestObserver();
+    
+    void StartWaiting( const RMessage2& aMsg );
+    
+private:
+    // from CActive
+    void RunL();
+    void DoCancel();
+    
+private:
+    RMessage2 iMsg;
+    };
+
+
+//**********************************
+//CFBFileOpServerSession
+//**********************************
+/**
+This class represents a session with the  server.
+Functions are provided to respond appropriately to client messages.
+*/
+class CFBFileOpServerSession : public CSession2,
+                               public MFileManObserver
+	{
+
+public :
+	CFBFileOpServerSession();
+
+private: // From MFileManObserver
+    
+    TControl NotifyFileManStarted();
+    TControl NotifyFileManOperation();
+    TControl NotifyFileManEnded();
+    
+protected :
+	// panic the client
+	void PanicClient(const RMessage2& aMessage,TInt aPanic) const;
+
+private :
+	~CFBFileOpServerSession();
+	inline CFBFileOpServer& Server();
+	void CreateL();
+	
+	//service requests
+	void ServiceL(const RMessage2& aMessage);
+	void DispatchMessageL(const RMessage2& aMessage, TBool& aComplete);
+	
+	void CopyL(const RMessage2& aMessage);
+	void RenameL(const RMessage2& aMessage);
+	void AttribsL(const RMessage2& aMessage);
+	void RmDirL(const RMessage2& aMessage, TBool& aComplete);
+	void DeleteL(const RMessage2& aMessage);
+	void MkDirAllL(const RMessage2& aMessage);
+	void CreateEmptyFileL(const RMessage2& aMessage);
+	void EraseMBRL(const RMessage2& aMessage);
+	void PartitionDriveL(const RMessage2& aMessage);
+
+	void ServiceError(const RMessage2& aMessage, TInt aError);
+	
+	void CancelOp();
+					
+private :
+	RFs iFs;
+	RFile iFile;
+	CFileMan* iFileMan;
+	MFileManObserver::TControl iFileManObserverResult;
+	CRequestObserver* iReqObserver;
+	};
+
+
+//**********************************
+//Inlines
+//**********************************
+
+inline CShutdown::CShutdown()
+	:CTimer(-1)
+	{CActiveScheduler::Add(this);}
+
+inline void CShutdown::ConstructL()
+	{CTimer::ConstructL();}
+
+inline void CShutdown::Start()
+	{After(KMyShutdownDelay);}
+
+inline CFBFileOpServer::CFBFileOpServer()
+	:CServer2(0,ESharableSessions)
+	{}
+
+inline CFBFileOpServerSession::CFBFileOpServerSession()
+	{}
+
+inline CFBFileOpServer& CFBFileOpServerSession::Server()
+	{return *static_cast<CFBFileOpServer*>(const_cast<CServer2*>(CSession2::Server()));}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/fileopserver/src/FBDrivePartitioner.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,454 @@
+/*
+* 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 <e32test.h>
+#include <e32std.h>
+#include <f32fsys.h>
+#include <e32property.h>
+
+#include "FBDrivePartitioner.h"
+
+
+// copied from coreapplicationuisdomainpskeys.h
+const TUid KPSUidCoreApplicationUIs = { 0x101F8767 };
+const TUint32 KCoreAppUIsMmcRemovedWithoutEject = 0x00000109;
+enum TCoreAppUIsMmcRemovedWithoutEject
+    {
+    ECoreAppUIsEjectCommandUsedUninitialized = 0,
+    ECoreAppUIsEjectCommandNotUsed,
+    ECoreAppUIsEjectCommandUsed,
+    ECoreAppUIsEjectCommandUsedToDrive // Low 16-bits contain this value and high 16-bits TDriveNumber to eject
+    };
+
+
+// trace macros
+#define TRACE(a) {_LIT( KMsg, a ); RDebug::Print(KMsg);}
+#define TRACE1(a,b) {_LIT( KMsg, a ); RDebug::Print(KMsg,b);}
+#define TRACE2(a,b,c) {_LIT( KMsg, a ); RDebug::Print(KMsg,b,c);}
+
+	
+// Set the partition alignment boundary
+const TInt KPartitionAlignment = 0x1000; // 4kB
+const TInt KMBRSize = 512;
+const TInt KSectorSize = 512;
+const TInt KMBRPartitionInfoOffset = 0x1BE;
+const TInt KLargeFAT16Partition = 0x2000000; // 32MB
+const TInt KPartitionEntrySize = 16;
+
+// Set for the iX86BootIndicator
+//const TInt KPartitionBootable = 0x80;
+const TInt KPartitionNonBootable = 0x0;
+
+
+class TMBRPartition
+	{
+public:
+	TUint8 iX86BootIndicator;
+	TUint8 iStartHead;
+	TUint8 iStartSector;
+	TUint8 iStartCylinder;
+	TUint8 iPartitionType;
+	TUint8 iEndHead;
+	TUint8 iEndSector;
+	TUint8 iEndCylinder;
+	TUint32 iFirstSector;
+	TUint32 iNumSectors;
+	};
+
+
+// --------------------------------------------------------------------------------------------
+
+TInt FBDrivePartioner::FindLocalDriveNumber(RFs& aFs, TInt aDriveNumber, TInt& aLocalDriveNum)
+    {
+    TRACE1( "FBDrivePartitioner::FindLocalDriveNumber: start aDriveNumber=%d", aDriveNumber );
+
+    TInt err(KErrNone);
+    
+    TDriveInfo driveInfo;
+    err = aFs.Drive(driveInfo, aDriveNumber);
+
+    TRACE1( "FBDrivePartitioner::FindLocalDriveNumber: get DriveInfo err=%d", err );
+
+
+    TVolumeInfo vi;
+    err = aFs.Volume(vi, aDriveNumber);
+
+    TRACE1( "FBDrivePartitioner::FindLocalDriveNumber: get VolumeInfo err=%d", err );
+
+
+    TMediaSerialNumber serialNum;
+    err = aFs.GetMediaSerialNumber(serialNum, aDriveNumber);
+
+    TRACE1( "FBDrivePartitioner::FindLocalDriveNumber: get MediaSerialNumber err=%d", err );
+
+
+    TInt len = serialNum.Length();
+    TInt n(0);
+    for (n=0; n<len; n+=16)
+        {
+        TBuf16<16*3 +1> buf;
+        for (TInt m=n; m<n+16; m++)
+            {
+            TBuf16<3> hexBuf;
+            hexBuf.Format(_L("%02X "),serialNum[m]);
+            buf.Append(hexBuf);
+            }
+        buf.Append(_L("\n"));
+        }
+
+    TBusLocalDrive drv;
+    TBool chg(EFalse);
+    aLocalDriveNum = -1;
+    for (n=0; n<KMaxLocalDrives; n++)
+        {
+        TRACE1( "FBDrivePartitioner::FindLocalDriveNumber: drv.Connect drive %d", n );
+        err = drv.Connect(n, chg); //for user area
+        TRACE1( "FBDrivePartitioner::FindLocalDriveNumber: drv.Connect returns %d", err );
+
+        if(err != KErrNone)
+            {
+            continue;
+            }    
+
+        TLocalDriveCapsV5Buf capsBuf;
+        TLocalDriveCapsV5& caps = capsBuf();
+        err = drv.Caps(capsBuf);
+        TRACE1( "FBDrivePartitioner::FindLocalDriveNumber: drv.Caps returns %d", err );
+
+        if(err != KErrNone)
+            {
+            continue;
+            }    
+
+        TPtrC8 localSerialNum(caps.iSerialNum, caps.iSerialNumLength);
+        if (serialNum.Compare(localSerialNum) == 0)
+            {
+            TBool sizeMatch = (vi.iSize < caps.iSize)?ETrue:EFalse;
+            if (sizeMatch)
+                {
+                aLocalDriveNum = n;
+                TRACE1( "FBDrivePartitioner::FindLocalDriveNumber: sizeMatch for localDrive %d", n );
+                }
+            else
+                {
+                TRACE1( "FBDrivePartitioner::FindLocalDriveNumber: sizeMatch failed for localDrive %d", n );
+                }
+
+            }
+
+        drv.Disconnect();
+        }
+
+    TRACE1( "FBDrivePartitioner::FindLocalDriveNumber: localDriveNum=%d", aLocalDriveNum );
+
+    err = aLocalDriveNum == -1 ? KErrNotFound : KErrNone;
+    
+    TRACE1( "FBDrivePartitioner::FindLocalDriveNumber: returns %d", err );
+    return err;    
+
+    }
+	
+// --------------------------------------------------------------------------------------------
+
+TInt FBDrivePartioner::EraseMBR(RFs& aFs, TInt aDriveNumber)
+	{
+    TRACE1( "FBDrivePartitioner::EraseMBR: start aDriveNumber=%d", aDriveNumber );
+
+    // Prevent SysAp shutting down applications
+    RProperty::Set(
+        KPSUidCoreApplicationUIs,
+        KCoreAppUIsMmcRemovedWithoutEject,
+        ECoreAppUIsEjectCommandUsed );
+
+	TInt err(KErrNone);
+
+	TInt localDriveNumber;
+	err = FindLocalDriveNumber(aFs, aDriveNumber, localDriveNumber);
+	
+	if (err != KErrNone)
+	    {
+    	TRACE1("FBDrivePartitioner::EraseMBR: FindLocalDriveNumber err=%d returning", err); 
+	    return err;
+	    }
+	
+	TRACE1("FBDrivePartitioner::EraseMBR: connecting to local drive %d", localDriveNumber); 
+
+	TBusLocalDrive drv;
+	TBool chg(EFalse);
+	err = drv.Connect(localDriveNumber, chg); //for user area
+
+	TRACE1("FBDrivePartitioner::EraseMBR: drv.Connect %d", err);
+
+	
+	TRACE("FBDrivePartitioner::EraseMBR: Now start to invalidate MBR"); 
+
+	// create a buffers of zeros
+	TBuf8<KMBRSize> mbrBuf;
+	mbrBuf.Fill(0, mbrBuf.MaxLength());
+
+/*	
+	// write the next 16 sectors with the buffer. Usually you only write the first one, but this one should erase any following invalid sectors
+	for (TInt i=0; i<16; i++)
+	    {
+    	err = drv.Write(i*KMBRSize, KMBRSize, &mbrBuf, -1 , 0, 0x40000000);  // RLocalDrive::ELocDrvWholeMedia==0x40000000
+       	TRACE2("FBDrivePartitioner::EraseMBR: sector %d, write returns %d", i+1, err); 
+	    }
+*/
+
+    // erase the MBR
+	err = drv.Write(0, KMBRSize, &mbrBuf, -1 , 0, 0x40000000);  // RLocalDrive::ELocDrvWholeMedia==0x40000000
+   	TRACE1("FBDrivePartitioner::EraseMBR: write returns %d", err); 
+
+	drv.Disconnect();
+
+	// force a remount, if this is the protected area, then it will have to be remounted
+    TRACE1( "FBDrivePartitioner::EraseMBR: Remounting drive number %d", aDriveNumber );
+	TInt err2 = aFs.RemountDrive(aDriveNumber, NULL, 0);
+    TRACE1( "FBDrivePartitioner::EraseMBR: RemountDrive err2=%d", err2 );
+
+    TRACE1( "FBDrivePartitioner::EraseMBR: returns %d", err );
+    return err;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt FBDrivePartioner::CreatePartitions(RFs& aFs, TInt aDriveNumber, TInt aPartCount)
+	{
+    TRACE2( "FBDrivePartitioner::CreatePartitions: start aDriveNumber=%d aPartCount=%d", aDriveNumber, aPartCount );
+	TInt err(KErrNone);
+
+    TUint8 MBRPartitionInfo[ KPartitionEntrySize*KMBRMaxPrimaryPartitions ];
+
+    // Prevent SysAp shutting down applications
+    RProperty::Set(
+        KPSUidCoreApplicationUIs,
+        KCoreAppUIsMmcRemovedWithoutEject,
+        ECoreAppUIsEjectCommandUsed );
+
+	// Force the system to read the memory card erased MBR
+	err = aFs.RemountDrive( aDriveNumber );
+	TRACE1( "FBDrivePartitioner::CreatePartitions: Remount result %d", err );
+	
+	// Get the number of partitions from user
+    TUint8 partitionCount(aPartCount);
+	TBool change = EFalse;
+	TInt mcDriveNbr(2);
+	TLocalDriveCapsV4 dc;
+	TInt64 diskSpace(0);
+
+/*
+	err = FindLocalDriveNumber(aFs, aDriveNumber, mcDriveNbr);
+	
+	if (err != KErrNone)
+	    {
+    	TRACE1("FBDrivePartitioner::CreatePartitions: FindLocalDriveNumber err=%d returning", err); 
+	    return err;
+	    }
+*/
+
+	// Seek through the system drives to find memory card drive
+	for (TInt i = 0; i < KMaxLocalDrives; ++i)
+		{
+		RLocalDrive	d;
+		change = EFalse;
+		err = d.Connect(i, change);
+		if (err == KErrNone)
+			{
+			TPckg<TLocalDriveCapsV4> capsPack(dc);
+			
+			if (d.Caps(capsPack) == KErrNone)
+				{
+				if (dc.iType == EMediaHardDisk)
+					{
+					mcDriveNbr = i;
+					diskSpace  = dc.iSize;
+                 	TRACE1( "FBDrivePartitioner::CreatePartitions: found hard drive %d:", mcDriveNbr );
+					}
+				}
+			d.Close();
+			}
+		}
+
+	// Connect to the local drive we found
+	RLocalDrive	localDrive;
+	change = EFalse;
+    err = localDrive.Connect( mcDriveNbr, change );
+ 	TRACE2( "FBDrivePartitioner::CreatePartitions: localDrive.Connect %d: %d", mcDriveNbr, err );
+	TRACE1( "FBDrivePartitioner::CreatePartitions: diskSpace in sectors 0x%x, %d", diskSpace / KSectorSize );
+
+	// Let's read the MBR by using RLocalDrive
+	TUint8 data[KMBRSize];
+	TPtr8 buf( &data[0], KMBRSize );
+	err = localDrive.Read( 0, KMBRSize, buf );
+	TRACE1( "FBDrivePartitioner::CreatePartitions: localDrive.Read %d", err );
+	// Let's check the current drive layout here
+	memcpy( MBRPartitionInfo, &data[KMBRPartitionInfoOffset],(sizeof(TMBRPartition)<<2)); 
+	TMBRPartition *partitionInfo = (TMBRPartition*) MBRPartitionInfo;
+
+	// Clean the rest of the MBR buffer
+	buf.FillZ();
+
+	// Print out the partition info
+	for( TInt i = 0; i<KMBRMaxPrimaryPartitions; i++ )
+		{
+		TRACE1( "FBDrivePartitioner::CreatePartitions: Partition %d", i+1 );
+		TRACE1( "FBDrivePartitioner::CreatePartitions: iX86BootIndicator %x", partitionInfo[i].iX86BootIndicator );
+		TRACE1( "FBDrivePartitioner::CreatePartitions: iStartHead        %x", partitionInfo[i].iStartHead );
+		TRACE1( "FBDrivePartitioner::CreatePartitions: iStartSector      %x", partitionInfo[i].iStartSector );
+		TRACE1( "FBDrivePartitioner::CreatePartitions: iStartCylinder    %x", partitionInfo[i].iStartCylinder );
+		TRACE1( "FBDrivePartitioner::CreatePartitions: iPartitionType    %x", partitionInfo[i].iPartitionType );
+		TRACE1( "FBDrivePartitioner::CreatePartitions: iEndHead          %x", partitionInfo[i].iEndHead );
+		TRACE1( "FBDrivePartitioner::CreatePartitions: iEndSector        %x", partitionInfo[i].iEndSector );
+		TRACE1( "FBDrivePartitioner::CreatePartitions: iEndCylinder      %x", partitionInfo[i].iEndCylinder );
+		TRACE1( "FBDrivePartitioner::CreatePartitions: iFirstSector      %x", partitionInfo[i].iFirstSector );
+		TRACE1( "FBDrivePartitioner::CreatePartitions: iNumSectors       %x", partitionInfo[i].iNumSectors );
+		}
+
+	// Calculate partition size	
+	TRACE( "FBDrivePartitioner::CreatePartitions: Calculating partition size" );
+	TInt64 partitionSize = (diskSpace / partitionCount) - KPartitionAlignment;
+	//TRACE1( "FBDrivePartitioner::CreatePartitions: PartitionSize in sectors 0x%x", partitionSize/KSectorSize );
+	TRACE1( "FBDrivePartitioner::CreatePartitions: Size of the partition is %Ld bytes", partitionSize );
+
+	// Activate the specified amount of partitions 
+	for( TInt i = 0; i < KMBRMaxPrimaryPartitions; i++ )
+		{
+		if( i < partitionCount )
+			{
+			if( partitionSize <= KLargeFAT16Partition )
+				{
+				partitionInfo[i].iPartitionType = KPartitionTypeFAT16small;
+				}
+			else
+				{
+				partitionInfo[i].iPartitionType = KPartitionTypeFAT16;
+				}
+			partitionInfo[i].iX86BootIndicator = KPartitionNonBootable;
+			}
+		else
+			{
+			partitionInfo[i].iX86BootIndicator = 0;
+			partitionInfo[i].iPartitionType = 0;
+			}
+		}
+
+	TRACE( "FBDrivePartitioner::CreatePartitions: Set first partition start address and change to sector addresses" );
+
+	// Set first partition start address
+	TInt64 offSet = KPartitionAlignment;
+	// Change to sector addresses
+	offSet = offSet / KSectorSize;
+
+	// Align and set the partitions
+	for( TInt i = 0; i < KMBRMaxPrimaryPartitions; i++ )
+		{
+		if( i < partitionCount )
+			{
+			// Start sector
+			partitionInfo[i].iFirstSector = offSet;
+			// Number of sectors in a partition
+			partitionInfo[i].iNumSectors = partitionSize / KSectorSize;
+			// Start of the next partition
+			offSet += ((partitionSize &~ (KPartitionAlignment - 1)) / KSectorSize);
+			}
+		else
+			{
+			partitionInfo[i].iFirstSector = 0;
+			partitionInfo[i].iNumSectors = 0;
+			}
+		// Start address HDD
+		partitionInfo[i].iStartHead = 0;
+		partitionInfo[i].iStartSector = 0;
+		partitionInfo[i].iStartCylinder = 0;
+		// End address HDD
+		partitionInfo[i].iEndHead = 0;
+		partitionInfo[i].iEndSector = 0;
+		partitionInfo[i].iEndCylinder = 0;
+
+		}
+
+	// Print out the new partition boot record
+ 	TRACE( "FBDrivePartitioner::CreatePartitions: Partitions created" );
+	for( TInt i = 0; i<KMBRMaxPrimaryPartitions; i++ )
+		{
+		TRACE1("FBDrivePartitioner::CreatePartitions: Partition %d", i+1 );
+		TRACE1( "FBDrivePartitioner::CreatePartitions: iX86BootIndicator %x", partitionInfo[i].iX86BootIndicator );
+		TRACE1( "FBDrivePartitioner::CreatePartitions: iStartHead        %x", partitionInfo[i].iStartHead );
+		TRACE1( "FBDrivePartitioner::CreatePartitions: iStartSector      %x", partitionInfo[i].iStartSector );
+		TRACE1( "FBDrivePartitioner::CreatePartitions: iStartCylinder    %x", partitionInfo[i].iStartCylinder );
+		TRACE1( "FBDrivePartitioner::CreatePartitions: iPartitionType    %x", partitionInfo[i].iPartitionType );
+		TRACE1( "FBDrivePartitioner::CreatePartitions: iEndHead          %x", partitionInfo[i].iEndHead );
+		TRACE1( "FBDrivePartitioner::CreatePartitions: iEndSector        %x", partitionInfo[i].iEndSector );
+		TRACE1( "FBDrivePartitioner::CreatePartitions: iEndCylinder      %x", partitionInfo[i].iEndCylinder );
+		TRACE1( "FBDrivePartitioner::CreatePartitions: iFirstSector      %x", partitionInfo[i].iFirstSector );
+		TRACE1( "FBDrivePartitioner::CreatePartitions: iNumSectors       %x", partitionInfo[i].iNumSectors );
+		}
+
+	// Copy the new layout to MBR buffer
+ 	TRACE( "FBDrivePartitioner::CreatePartitions: Copy the new layout to MBR buffer" );
+	memcpy( &data[KMBRPartitionInfoOffset], MBRPartitionInfo, (sizeof(TMBRPartition)<<2) ); 
+
+	// Make sure we have a valid signature
+ 	TRACE( "FBDrivePartitioner::CreatePartitions: Make sure we have a valid signature" );
+	*(TUint16*)(&data[KMBRSignatureOffset]) = 0xAA55;
+
+	// Now flush the new partition layout
+ 	TRACE( "FBDrivePartitioner::CreatePartitions: Flush the new partition layout" );
+	err = localDrive.Write( 0, buf );
+	TRACE1( "FBDrivePartitioner::CreatePartitions: localDrive.Write err=%d", err );
+	localDrive.Close();
+
+    TRACE1( "FBDrivePartitioner::CreatePartitions: returns %d", err );
+    
+    return err;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt FBDrivePartioner::FormatPartitions(RFs& aFs, TInt aDriveNumber, TInt aPartCount)
+	{
+    TRACE2( "FBDrivePartitioner::FormatPartitions: aDriveNumber=%d aPartCount=%d", aDriveNumber, aPartCount );
+    TInt err(KErrNone);
+
+    for( TInt i = 0; i < aPartCount; i++ )
+        {
+        TDriveName name(TDriveUnit(aDriveNumber + i).Name());
+        TRACE1( "FBDrivePartitioner::FormatPartitions: Format %S start", &name );
+        RFormat fmt;
+        TInt count(0);
+        err = fmt.Open(aFs, name, EQuickFormat, count);
+        TRACE1( "FBDrivePartitioner::FormatPartitions: Format open=%d", err );
+        while (count > 0)
+            {
+            err = fmt.Next(count);
+            if (err != KErrNone)
+                {
+                TRACE1( "FBDrivePartitioner::FormatPartitions: Format error=%d", err );
+                break;
+                }
+            }
+        fmt.Close();
+        TRACE1( "FBDrivePartitioner::FormatPartitions: Format %S end", &name );
+	    }
+
+    TRACE1("FBDrivePartitioner::FormatPartitions returns %d", err);
+    
+    return err;
+    }
+
+// --------------------------------------------------------------------------------------------
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/fileopserver/src/FBFileOpServer.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,474 @@
+/*
+* 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 "FBFileOpServer.h"
+#include "FBDrivePartitioner.h"
+
+#include <e32svr.h>
+#include <bautils.h>
+
+// --------------------------------------------------------------------------------------------
+
+//***********************************
+//CFBFileOpServer - implementations
+//***********************************
+
+CServer2* CFBFileOpServer::NewLC()
+	{
+	CFBFileOpServer* self = new(ELeave) CFBFileOpServer;
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+// --------------------------------------------------------------------------------------------
+
+//
+// 2nd phase construction - ensure the timer and server objects are running
+//
+void CFBFileOpServer::ConstructL()
+	{
+	StartL(KMyServerName);
+	iShutdown.ConstructL();
+	// ensure that the server still exits even if the 1st client fails to connect
+	iShutdown.Start();
+	}
+
+// --------------------------------------------------------------------------------------------
+
+//
+// Cretae a new client session. This should really check the version number.
+//
+CSession2* CFBFileOpServer::NewSessionL(const TVersion&,const RMessage2&) const
+	{
+	return new(ELeave) CFBFileOpServerSession();
+	}
+
+// --------------------------------------------------------------------------------------------
+
+//
+// A new session is being created
+// Cancel the shutdown timer if it was running
+//
+void CFBFileOpServer::AddSession()
+	{
+	++iSessionCount;
+	iShutdown.Cancel();
+	}
+
+// --------------------------------------------------------------------------------------------
+
+//
+// A session is being destroyed
+// Start the shutdown timer if it is the last session.
+//
+void CFBFileOpServer::DropSession()
+	{
+	if (--iSessionCount==0)
+		iShutdown.Start();
+	}
+
+// --------------------------------------------------------------------------------------------
+    
+CRequestObserver::CRequestObserver( TInt aPriority ) : CActive( aPriority )
+    {
+    CActiveScheduler::Add( this );
+    }   
+
+CRequestObserver::~CRequestObserver()
+    {
+    Cancel();
+    }
+    
+void CRequestObserver::StartWaiting( const RMessage2& aMsg )
+    {
+    iMsg = aMsg;
+    SetActive();
+    }
+    
+void CRequestObserver::RunL()
+    {
+    iMsg.Complete( iStatus.Int() );
+    }
+    
+void CRequestObserver::DoCancel()
+    {
+    iMsg.Complete( KErrCancel );
+    }
+
+// --------------------------------------------------------------------------------------------
+
+//***********************************
+//CFBFileOpServerSession - implementations
+//***********************************
+
+//
+// 2nd phase construct for sessions - called by the CServer framework
+//
+void CFBFileOpServerSession::CreateL()
+	{
+	User::LeaveIfError(iFs.Connect());
+	iFileMan = CFileMan::NewL( iFs, this );
+	iReqObserver = new (ELeave) CRequestObserver( CActive::EPriorityStandard );
+	Server().AddSession();
+	}
+
+// --------------------------------------------------------------------------------------------
+
+CFBFileOpServerSession::~CFBFileOpServerSession()
+	{
+	if (iFileMan)
+		{
+		delete iFileMan;
+		iFileMan = NULL;
+		}
+	iFs.Close();
+	delete iReqObserver;
+	Server().DropSession();
+	}
+
+// --------------------------------------------------------------------------------------------
+	
+/**
+Services a client request.
+*/
+void CFBFileOpServerSession::ServiceL(const RMessage2& aMessage)
+	{
+	TBool completeImmediately( ETrue );
+	TRAPD( err,DispatchMessageL( aMessage, completeImmediately ) );
+	if ( completeImmediately ) aMessage.Complete( err );
+	}
+
+// --------------------------------------------------------------------------------------------
+
+/**
+Called by ServiceL()
+
+It tests the function code and then delegates to
+the appropriate function.
+*/
+void CFBFileOpServerSession::DispatchMessageL(const RMessage2& aMessage, TBool& aComplete)
+	{
+	switch (aMessage.Function())
+        {
+        case EFileOpCopy:
+            CopyL(aMessage);
+            aComplete = EFalse;
+            return;
+
+        case EFileOpRename:
+            RenameL(aMessage);
+            return;            
+
+        case EFileOpAttribs:
+            AttribsL(aMessage);
+            return; 
+
+        case EFileOpRmDir:
+            RmDirL(aMessage, aComplete);
+            return; 
+
+        case EFileOpDelete:
+            DeleteL(aMessage);
+            aComplete = EFalse;
+            return; 
+
+        case EFileOpMkDirAll:
+            MkDirAllL(aMessage);
+            return;             
+
+        case EFileOpCreateEmptyFile:
+            CreateEmptyFileL(aMessage);
+            return;            
+
+        case EFileOpEraseMBR:
+            EraseMBRL(aMessage);
+            return;
+            
+        case EFileOpPartitionDrive:
+            PartitionDriveL(aMessage);
+            return;
+            
+        case EFileOpCancel: 
+            CancelOp();
+            return; 
+            
+        default:
+            PanicClient(aMessage, EPanicIllegalFunction);
+            return;
+        }
+	}
+
+// --------------------------------------------------------------------------------------------
+
+void CFBFileOpServerSession::CopyL( const RMessage2& aMessage )
+    {
+    __ASSERT_ALWAYS( iReqObserver && !iReqObserver->IsActive(), User::Leave( KErrServerBusy ) );
+    TPckgBuf<TFileOpArgs> pckgBuf;
+    aMessage.ReadL( 0, pckgBuf, 0 );
+    TFileOpArgs argsStruct = pckgBuf();
+
+    TInt err = iFileMan->Copy( argsStruct.iBuf1, argsStruct.iBuf2, argsStruct.iUint1, iReqObserver->iStatus );
+    User::LeaveIfError( err );
+    iFileManObserverResult = MFileManObserver::EContinue;
+    iReqObserver->StartWaiting( aMessage ); // start asynchronous waiting
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFBFileOpServerSession::RenameL(const RMessage2& aMessage)
+    {
+    TPckgBuf<TFileOpArgs> pckgBuf;
+    aMessage.ReadL(0, pckgBuf, 0);
+    TFileOpArgs argsStruct = pckgBuf();
+    
+    iFileManObserverResult = MFileManObserver::EContinue;
+    User::LeaveIfError(iFileMan->Rename(argsStruct.iBuf1, argsStruct.iBuf2, argsStruct.iUint1));
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFBFileOpServerSession::AttribsL(const RMessage2& aMessage)
+    {
+    TPckgBuf<TFileOpArgs> pckgBuf;
+    aMessage.ReadL(0, pckgBuf, 0);
+    TFileOpArgs argsStruct = pckgBuf();
+    
+    iFileManObserverResult = MFileManObserver::EContinue;
+    User::LeaveIfError(iFileMan->Attribs(argsStruct.iBuf1, argsStruct.iUint1, argsStruct.iUint2, argsStruct.iTime1, argsStruct.iUint3));
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFBFileOpServerSession::RmDirL( const RMessage2& aMessage, TBool& aComplete )
+    {
+    TPckgBuf<TFileOpArgs> pckgBuf;
+    aMessage.ReadL( 0, pckgBuf, 0 );
+    TFileOpArgs argsStruct = pckgBuf();
+    
+    if ( argsStruct.iUint1 & CFileMan::ERecurse )
+        {
+        __ASSERT_ALWAYS( iReqObserver && !iReqObserver->IsActive(), User::Leave( KErrServerBusy ) );
+        User::LeaveIfError( iFileMan->RmDir( argsStruct.iBuf1, iReqObserver->iStatus ) );
+        iFileManObserverResult = MFileManObserver::EContinue;
+        aComplete = EFalse;
+        iReqObserver->StartWaiting( aMessage ); // start asynchronous waiting
+        }
+    else
+        {
+        iFileManObserverResult = MFileManObserver::EContinue;
+        User::LeaveIfError( iFs.RmDir( argsStruct.iBuf1 ) );
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFBFileOpServerSession::DeleteL( const RMessage2& aMessage )
+    {
+    __ASSERT_ALWAYS( iReqObserver && !iReqObserver->IsActive(), User::Leave( KErrServerBusy ) );
+    TPckgBuf<TFileOpArgs> pckgBuf;
+    aMessage.ReadL( 0, pckgBuf, 0 );
+    TFileOpArgs argsStruct = pckgBuf();
+    
+    User::LeaveIfError( iFileMan->Delete(argsStruct.iBuf1, argsStruct.iUint1, iReqObserver->iStatus ) ); 
+    iFileManObserverResult = MFileManObserver::EContinue;
+    iReqObserver->StartWaiting( aMessage ); // start asynchronous waiting
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFBFileOpServerSession::MkDirAllL(const RMessage2& aMessage)
+    {
+    TPckgBuf<TFileOpArgs> pckgBuf;
+    aMessage.ReadL(0, pckgBuf, 0);
+    TFileOpArgs argsStruct = pckgBuf();
+    
+    User::LeaveIfError(iFs.MkDirAll(argsStruct.iBuf1));
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFBFileOpServerSession::CreateEmptyFileL(const RMessage2& aMessage)
+    {
+    TPckgBuf<TFileOpArgs> pckgBuf;
+    aMessage.ReadL(0, pckgBuf, 0);
+    TFileOpArgs argsStruct = pckgBuf();
+    
+    TInt err(KErrNone);
+    RFile newFile;
+    err = newFile.Create(iFs, argsStruct.iBuf1, EFileShareExclusive);
+    if (err == KErrNone)
+        err = newFile.Flush(); 
+    newFile.Close(); 
+    
+    User::LeaveIfError(err);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFBFileOpServerSession::EraseMBRL(const RMessage2& aMessage)
+    {
+    TPckgBuf<TFileOpArgs> pckgBuf;
+    aMessage.ReadL(0, pckgBuf, 0);
+    TFileOpArgs argsStruct = pckgBuf();
+
+	RFs fs;
+	CleanupClosePushL(fs);
+	User::LeaveIfError(fs.Connect());
+
+    User::LeaveIfError(FBDrivePartioner::EraseMBR(fs, argsStruct.iUint1));
+
+    CleanupStack::PopAndDestroy(); //fs
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CFBFileOpServerSession::PartitionDriveL(const RMessage2& aMessage)
+    {
+    TPckgBuf<TFileOpArgs> pckgBuf;
+    aMessage.ReadL(0, pckgBuf, 0);
+    TFileOpArgs argsStruct = pckgBuf();
+
+	RFs fs;
+	CleanupClosePushL(fs);
+	User::LeaveIfError(fs.Connect());
+
+    FBDrivePartioner::CreatePartitions(fs, argsStruct.iUint1, argsStruct.iUint2);
+    User::LeaveIfError(FBDrivePartioner::FormatPartitions(fs, argsStruct.iUint1, argsStruct.iUint2));
+
+    CleanupStack::PopAndDestroy(); //fs
+    }
+               
+// --------------------------------------------------------------------------------------------
+
+//
+// Panics the client
+//
+void CFBFileOpServerSession::PanicClient(const RMessage2& aMessage, TInt aPanic) const
+	{
+	_LIT(KTxtServer,"FBFileOpServer");
+	aMessage.Panic(KTxtServer, aPanic);
+	}
+
+// --------------------------------------------------------------------------------------------
+
+//
+// Handle an error from CFBFileOpServerSession::ServiceL()
+// A bad descriptor error implies a badly programmed client, so panic it;
+// otherwise use the default handling (report the error to the client)
+//
+void CFBFileOpServerSession::ServiceError(const RMessage2& aMessage, TInt aError)
+	{
+	if (aError==KErrBadDescriptor)
+		PanicClient(aMessage,EPanicBadDescriptor);
+	CSession2::ServiceError(aMessage,aError);
+	}
+
+// --------------------------------------------------------------------------------------------
+
+MFileManObserver::TControl CFBFileOpServerSession::NotifyFileManStarted()
+    {
+    return iFileManObserverResult;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+MFileManObserver::TControl CFBFileOpServerSession::NotifyFileManOperation()
+    {
+    return iFileManObserverResult;
+    }
+// --------------------------------------------------------------------------------------------
+
+MFileManObserver::TControl CFBFileOpServerSession::NotifyFileManEnded()
+    {
+    return iFileManObserverResult;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFBFileOpServerSession::CancelOp()
+    {
+    iFileManObserverResult = MFileManObserver::ECancel;
+    iReqObserver->Cancel();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+//**********************************
+//Global functions
+//**********************************
+
+//
+// Initiate server exit when the timer expires
+//
+void CShutdown::RunL()
+	{
+	CActiveScheduler::Stop();
+	}
+
+// --------------------------------------------------------------------------------------------
+
+//
+// Perform all server initialisation, in particular creation of the
+// scheduler and server and then run the scheduler
+//
+static void RunServerL()
+	{
+	// naming the server thread after the server helps to debug panics
+	User::LeaveIfError(RThread::RenameMe(KMyServerName));
+	//
+	// create and install the active scheduler we need
+	CActiveScheduler* s=new(ELeave) CActiveScheduler;
+	CleanupStack::PushL(s);
+	CActiveScheduler::Install(s);
+	//
+	// create the server (leave it on the cleanup stack)
+	CFBFileOpServer::NewLC();
+	//
+	// Initialisation complete, now signal the client
+	RProcess::Rendezvous(KErrNone);
+	//
+	// Ready to run
+	CActiveScheduler::Start();
+	//
+	// Cleanup the server and scheduler
+	CleanupStack::PopAndDestroy(2);
+	}
+
+// --------------------------------------------------------------------------------------------
+
+//
+// Server process entry-point
+//
+TInt E32Main()
+	{
+	__UHEAP_MARK;
+	//
+	CTrapCleanup* cleanup=CTrapCleanup::New();
+	TInt r=KErrNoMemory;
+	if (cleanup)
+		{
+		TRAP(r,RunServerL());
+		delete cleanup;
+		}
+	//
+	__UHEAP_MARKEND;
+	return r;
+	}
+
+// --------------------------------------------------------------------------------------------
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/group/ReleaseNotes_FileBrowser.txt	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,245 @@
+===============================================================================
+
+RELEASE NOTES - FILEBROWSER v4.5.2
+RELEASED 10th December 2009
+
+SUPPORTS S60 3.0+
+
+===============================================================================
+
+Product Description:
+====================
+The FileBrowser tool can be used to browse directory hierarchies and perform 
+file operations under the S60 environment. It also contains some smaller tools 
+and functionalities that help RnD development and verification.
+
+Main Features:
+==============
+- Showing a drive list
+- Browsing through directory hierarchies
+- Disk admin tools for generic disk operations
+- Searching files with different parameters
+- Full clipboard functionality
+- Copying/moving files with the help of a separate dialog
+- Creating new files and directories
+- Showing properties of files, directories and disks
+- Sending, deleting, renaming, touching, setting attributes,
+  compressing and uncompressing of files
+- Recursive directory support
+- Sorting and ordering file view
+- Filtering entries with a search field
+- Text and hex viewer for files
+- A settings screen for altering different kind of settings
+- Data type viewer/editor
+- Ability to give TCB capability for file operations
+- Showing message attachments from Symbian messaging store
+- Touch UI toolbar (S60 5.x only)
+
+===============================================================================
+
+What's New in v4.5.2
+====================
+- Fix: UI layout problems fixed
+- Fix: Filebrowser crashes with too long filenames
+
+===============================================================================
+
+Installation Notes:
+===================
+FileBrowser 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.
+
+FileBrowser is provided as full and lite version. Lite version is aimed for
+those who cannot sign with TCB capability. Lite version can be generated by
+defining FILEBROWSER_LITE flag and then by recompiling the application and
+regenerating the sis file.
+
+When signing with own developer certificate, the following capabilities are
+needed in the lite version:
+  ReadDeviceData
+  WriteDeviceData
+  DiskAdmin
+  AllFiles
+  SwEvent
+  NetworkServices
+  LocalServices
+  ReadUserData
+  WriteUserData
+  Location
+  UserEnvironment
+  
+The full version requires these addtional capabilities:
+  CommDD
+  PowerMgmt
+  MultimediaDD
+  DRM
+  TrustedUI
+  ProtServ
+  NetworkControl
+  SurroundingsDD
+  TCB
+
+When builing FileBrowser 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:
+=============
+N/A
+
+===============================================================================
+
+Version History:
+================
+
+Version 4.5.1 - 15th May 2009
+-----------------------------
+- Fix: Refreshing display does not work well when starting FileBrowser
+- Fix: Internal Mass storage drive is displayed as Memory Card
+
+Version 4.5.0 - 13th February 2009 
+----------------------------------
+- Feature: Touch UI toolbar introduced with Navigate Up, Filter and Select
+  functionalities (S60 5.x only)
+- Fix: Date and directory attributes don't work correctly with search
+
+Version 4.4.0 - 12th December 2008 
+----------------------------------
+- Feature: "Remember last folder": File list view now remembers which folder
+  had the last focus before navigating deeper in a directory, and selects that
+  folder instead of the root of the directory when navigating back upwards.
+- Fix: Execution of long file operations may cause WSERV 11 panic
+- Fix: Allow formatting even if files are in use
+
+Version 4.3.3 - 8th August 2008 
+-------------------------------
+- Fix: Calculation of partition size with 64-bit values caused unwanted side
+  effects
+  
+Version 4.3.2 - 5th May 2008
+------------------------------
+- Fix: Size of drive partitions should be calculated with 64-bit values
+
+Version 4.3.1 - 7th March 2008
+------------------------------
+- Fix: Crash when search field was active and changing file view mode 
+
+Version 4.3.0 - 28th January 2008
+---------------------------------
+- Feature: Extended file view now displays also the directory/file time
+- Feature: Text file viewer/editor supports also in UTF-8, UTF-16 little endian
+  and UTF-16 big endian formats
+- Change: Opening with apparc is not anymore a default opening action but now
+  a list of another common actions appears
+- Change: Font size in file list view has been adjusted to suit better in
+  currently used resolution
+- Change: In first time start, extended view is activated in QHD resolution     
+- Change: Font size in file viewer and editor is now smaller so that more text
+  fits to the screen
+- Change: Settings are now saved in dictionary store instead of cenreps  
+- Fix: Copy/move to folder functionality was broken
+- Fix: Scroll bar did not work properly in text viewer when used via touch UI
+- Fix: Last line of hex viewer was not warpped correctly 
+- Fix: Menu bars of file viewer and editor did not work properly
+- Fix: Search should not return directories when searching a string
+- Fix: Hash key selection should not be active in qwerty mode  
+
+Version 4.2.0 - 14th January 2008
+---------------------------------
+- Feature: User mapped remote drives are visible in drive list view as normal
+  drive when setting is turned on
+- Feature: Files can be edited in both text and hex modes
+- Feature: Show checksums (message digests) on different algorithms for a file
+- Feature: Error strings are now displayed for various operations instead of
+  generic error messages
+- Feature: Disk can be ejected and dismounted via disk admin
+- Change: Increased maximum heap usage to 32Mb to allow loading large files to
+  file editor    
+- Fix: Trying to create a directory which already exists did not return an
+  error
+- Fix: In the file list view active item not visible when deleting last item in
+  the view
+- Fix: Some file specific commands were visibile in menus also for directory
+  entries  
+- Fix: Utilizing secure backup leaked memory 
+
+Version 4.1.0 - 17th December 2007
+----------------------------------
+- Feature: File operations are now started asynchronously with own recursion
+  handler which allows removing file locks and any protection attributes
+- Feature: Status of each file operation can be monitored via RDebug 
+- Feature: Remove file locks via Secure Backup
+- Feature: File operation functionality can be customized via the settings
+  dialog
+- Feature: Multidrive support with erasing MBR and drive partition for drives
+  which support it
+- Change: Remove screen capture support since the same functionality can be
+  done with the ScreenGrabber tool
+- Fix: Forms were incorrectly constructed in search dialog and attribute editor
+
+Version 4.0.7 - 16th November 2007
+--------------------------------
+- Feature: In the list view, left/right arrow keys can be simulated with drag to
+  left/right gestures
+- Fix: Touch click in the listbox view
+- Fix: Scroll bar in the hex/text viewer can be scrolled on a touch UI
+
+Version 4.0.6 - 9th October 2007
+--------------------------------
+- Feature: Data type editor
+- Fix: Layout in hex/text viewer in mirrored mode
+  
+Version 4.0.5 - 27th August 2007
+--------------------------------
+- Fix: Wrong functionality while moving a folder
+- Change: Handle backup session while formatting a drive
+
+Version 4.0.4 - 23th May 2007
+-----------------------------
+- Feature: Modify debug mask
+- Feature: Simulate Symbian OS error types
+- Feature: Enable/disable icon server cache
+
+Version 4.0.3 - 28th February 2007
+----------------------------------
+- Feature: Drive snapshot functionality under the main drive selection list
+
+Version 4.0.2 - 31st January 2007
+---------------------------------
+- Feature: Dump message store walk into a text file
+- Change: Enhance hex/text viewer
+- Fix: Enhance folder browsing speed in Z-drive
+
+Version 4.0.1 - 17th January 2007
+---------------------------------
+- Fix: Opening of search field
+- Fix: Enabling extended errors if c:\resource directory does not already
+  exist
+
+===============================================================================
+
+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".
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/group/backup_registration.xml	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,8 @@
+<?xml version="1.0" standalone="yes"?>
+<backup_registration>
+  <passive_backup>
+    <include_directory name="\"/>
+  </passive_backup>
+  <system_backup/>
+  <restore requires_reboot = "no"/>
+</backup_registration>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,65 @@
+/*
+* 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>
+
+#ifndef FILEBROWSER_LITE
+  #include "../fileopserver/group/bld.inf"
+  #include "../fileopclient/group/bld.inf"
+#endif
+
+PRJ_EXPORTS
+../group/backup_registration.xml    Z:/private/102828D6/backup_registration.xml
+../rom/filebrowser.iby CORE_IBY_EXPORT_PATH(tools,filebrowser.iby)
+
+
+PRJ_MMPFILES
+#if defined(__SERIES60_30__) || defined(__SERIES60_31__) || defined(__S60_32__)
+  gnumakefile filebrowser_icons_aif.mk
+  gnumakefile filebrowser_extraicons.mk
+
+  #ifdef MARM
+  gnumakefile filebrowser_stub_sis.mk
+  #endif
+#endif
+
+filebrowser.mmp
+
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)
+  PRJ_EXTENSIONS
+  START EXTENSION s60/mifconv
+  OPTION TARGETFILE filebrowser_aif.mif
+  OPTION SOURCEDIR ../icons
+  OPTION SOURCES -c8,8 qgn_menu_filebrowser
+  END
+
+  START EXTENSION s60/mifconv
+  OPTION TARGETFILE filebrowser_extraicons.mif
+  OPTION HEADERFILE filebrowser_extraicons.mbg
+  OPTION SOURCEDIR ../icons
+  OPTION SOURCES -c8,8 qgn_indi_tb_filebrowser_folder_parent -c8,8 qgn_indi_tb_filebrowser_find -c8,8 qgn_indi_tb_filebrowser_selection -c8,8 qgn_indi_tb_filebrowser_selection_active
+  END
+  
+  #ifdef MARM
+  START EXTENSION app-services/buildstubsis
+  OPTION SRCDIR ../sis
+  OPTION SISNAME FileBrowser_stub
+  END
+  #endif  
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/group/filebrowser.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,116 @@
+/*
+* 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            FileBrowser.exe
+TARGETTYPE        exe
+EPOCSTACKSIZE     0x5000
+EPOCHEAPSIZE      0x10000 0x2000000  // Min 64kB, Max 32MB
+
+UID               0x100039CE 0x102828D6
+
+VENDORID          VID_DEFAULT
+CAPABILITY        CAP_APPLICATION AllFiles DiskAdmin
+
+SMPSAFE
+
+LANG              SC
+
+
+START RESOURCE    ../data/filebrowser.rss
+HEADER
+TARGETPATH        APP_RESOURCE_DIR
+END
+
+START RESOURCE    ../data/filebrowser_reg.rss
+DEPENDS           filebrowser.rsg
+TARGETPATH        /private/10003a3f/apps
+END
+
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE     /epoc32/include/connect
+USERINCLUDE       ../inc
+#ifndef FILEBROWSER_LITE 
+  USERINCLUDE       ../fileopclient/inc 
+#endif
+SOURCEPATH        ../src
+
+
+SOURCE            FBApp.cpp
+SOURCE            FBDocument.cpp 
+SOURCE            FBAppUi.cpp
+SOURCE            FBFileListView.cpp 
+SOURCE            FBFileListContainer.cpp 
+SOURCE            FBModel.cpp
+SOURCE            FBSettingViewDlg.cpp
+SOURCE            FBFileUtils.cpp
+SOURCE            FBFileOps.cpp
+SOURCE            FBFileDlgs.cpp
+SOURCE            FBFileEditor.cpp
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)
+  SOURCE            FBToolbar.cpp
+#endif
+
+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           CentralRepository.lib
+LIBRARY           mediaclientaudio.lib
+LIBRARY           estor.lib
+LIBRARY           gdi.lib
+LIBRARY           eikctl.lib
+LIBRARY           eikcdlg.lib
+LIBRARY           eikdlg.lib
+LIBRARY           aknicon.lib
+LIBRARY           egul.lib
+LIBRARY           commonui.lib
+LIBRARY           apmime.lib
+LIBRARY           sendui.lib
+LIBRARY           msgs.lib
+LIBRARY           ezlib.lib
+LIBRARY           cdlengine.lib 
+LIBRARY           remconcoreapi.lib
+LIBRARY           remconinterfacebase.lib
+LIBRARY           sbeclient.lib
+LIBRARY           hash.lib
+LIBRARY           etext.lib
+LIBRARY           charconv.lib
+LIBRARY           AknLayout2Scalable.lib
+LIBRARY           tzclient.lib
+
+#ifndef FILEBROWSER_LITE
+  LIBRARY           filebrowserfileopclient.lib
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/group/filebrowser_extraicons.mk	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,63 @@
+#
+# 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:  
+#
+
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z
+else
+ZDIR=\epoc32\data\z
+endif
+
+TARGETDIR=$(ZDIR)\resource\apps
+ICONTARGETFILENAME=$(TARGETDIR)\filebrowser_extraicons.mif
+
+HEADERDIR=\epoc32\include
+HEADERFILENAME=$(HEADERDIR)\filebrowser_extraicons.mbg
+
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN :
+	@if exist $(ICONTARGETFILENAME) erase $(ICONTARGETFILENAME)
+	@if exist $(HEADERFILENAME) erase $(HEADERFILENAME)
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+RESOURCE : $(ICONTARGETFILENAME)
+
+$(ICONTARGETFILENAME) (HEADERFILENAME) : ..\icons\qgn_indi_tb_filebrowser_folder_parent.svg ..\icons\qgn_indi_tb_filebrowser_find.svg ..\icons\qgn_indi_tb_filebrowser_selection.svg ..\icons\qgn_indi_tb_filebrowser_selection_active.svg
+	mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \
+		/c8,8 ..\icons\qgn_indi_tb_filebrowser_folder_parent.svg \
+		/c8,8 ..\icons\qgn_indi_tb_filebrowser_find.svg \
+		/c8,8 ..\icons\qgn_indi_tb_filebrowser_selection.svg \
+		/c8,8 ..\icons\qgn_indi_tb_filebrowser_selection_active.svg
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(HEADERFILENAME) && \
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/group/filebrowser_icons_aif.mk	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,54 @@
+#
+# 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:  
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z
+else
+ZDIR=\epoc32\data\z
+endif
+
+TARGETDIR=$(ZDIR)\resource\apps
+ICONTARGETFILENAME=$(TARGETDIR)\filebrowser_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_filebrowser.svg
+	mifconv $(ICONTARGETFILENAME) \
+		/c8,8 ..\icons\qgn_menu_filebrowser.svg
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/group/filebrowser_stub_sis.mk	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,56 @@
+#
+# 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:  
+#
+
+
+TARGETDIR=$(EPOCROOT)EPOC32\Data\Z\System\Install
+
+SISNAME=FileBrowser_stub
+PKGNAME=FileBrowser_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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/helpertools/snapshot_compare_dirs.pl	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,202 @@
+#
+# 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:  
+#
+
+use strict;
+
+use Getopt::Std;
+use Digest::MD5 qw( md5 );
+use File::Basename;
+use File::Copy;
+use File::Find;
+use File::Path;
+
+my @changed_files=();
+my $dir_1_length;
+my $dir_2_length;
+my $directory1;
+my $directory2;
+my %list1=();
+my %list2=();
+my %opts=();
+my $switch= 0;
+my $result_dir;
+
+###################################################
+##  usage()                                      ##
+##  Prints the usage                             ##
+###################################################
+sub usage
+{
+  print "\nUsage\n\tsnapshot_compare_dirs.pl -1 <original dir> -2 <updated dir>  -r <result dir>\n";
+  print "\nWhere\n\t-1  Original directory\n\t-2  Updated directory\n\t-r  Result directory\n";
+  exit;
+}
+
+###################################################
+##  get_param()                                  ##
+##  Gets command line parameters                 ##
+###################################################
+sub get_param
+{
+  getopts('h1:2:r:', \%opts);
+
+  if ( $opts{'h'} ) {
+    usage();
+  }
+
+  if ( $opts{'1'} ) {
+    $directory1 = $opts{'1'};
+    if ( ! -d $directory1 ) {
+      print "\nError:\t Directory \"$directory1\" doesn't exist\n";
+      exit;
+    }
+  } else {
+    usage();
+  }
+
+  if ( $opts{'2'} ) {
+    $directory2 = $opts{'2'};
+    if ( ! -d $directory2 ) {
+      print "\nError:\t Directory \"$directory2\" doesn't exist\n";
+      exit;
+    }
+  } else {
+    usage();
+  }
+
+  if ( $opts{'r'} ) {
+    $result_dir = $opts{'r'};
+    if ( ! -d $result_dir ) {
+        mkdir $result_dir;
+    }
+  } else {
+    usage();
+  }
+
+}
+
+###################################################
+##  calculate_hash()  Reads file content and     ##
+##                    calculates MD5 hash        ##
+###################################################
+sub calculate_hash
+{
+  my ( $file_name ) = @_;
+
+  open( FILE, $file_name ) or die "Error: Cannot open $file_name\n";
+  my @file_stat = stat FILE;
+  binmode( FILE );
+
+  my ( $buffer, $hash_value );
+  read( FILE, $buffer, $file_stat[7] );
+
+  close FILE;
+
+  $hash_value = md5( $buffer );
+
+  return $hash_value;
+}
+
+###################################################
+##  copy_file()                                  ##
+##  Copies files with same directory structure   ##
+###################################################
+sub copy_file
+{
+    my ( $file1, $file2 ) = @_;
+    my $dir_name = dirname( $file2 );
+
+    mkpath( $dir_name, 0, 0777 );
+
+    copy( $file1, $file2 );
+}
+
+###################################################
+##  process_files()                              ##
+##  Indexes files                                ##
+###################################################
+sub process_files
+{
+  my $file = $File::Find::name;
+
+  if ( -f $file ) {
+    if ($switch eq 0 ) {
+      $file = substr( $file, $dir_1_length );
+      $list1{$file} = 1;;
+    } else {
+      $file = substr( $file, $dir_2_length );
+      $list2{$file} = 1;
+    }
+  }
+}
+
+###################################################
+##  main()                                       ##
+##  Main function                                ##
+###################################################
+sub main
+{
+  get_param();
+
+  $dir_1_length = length( $directory1 );
+  $dir_2_length = length( $directory2 );
+
+  print "Info:\tProcessing files. This may take some time\n";
+
+  $switch = 0;
+  find( \&process_files, $directory1 );
+
+  $switch = 1;
+  find( \&process_files, $directory2 );
+
+  print "Info:\tFiles only exist in \"$directory2\" :\n\n";
+  my $counter = 0;
+  my $file;
+  my $key;
+  my $hash1;
+  my $hash2;
+
+  foreach $key ( sort keys %list2 ){
+    if ( $list1{$key} ne 1 ) {
+       $key =~ s/\//\\/g;
+       print "\t$key\n";
+       copy_file( "$directory2$key", "$result_dir$key" );
+       $counter++;
+    } else {
+       $hash1 = calculate_hash("$directory1$key");
+       $hash2 = calculate_hash("$directory2$key");
+       if ($hash1 ne $hash2) {
+         push @changed_files, $key;
+       }
+    }
+  }
+
+  print "\nInfo:\tTotal $counter new file(s)\n";
+
+  print "\nInfo:\tList of the changed file\n";
+
+  $counter = 0;
+
+  foreach $file ( @changed_files ){
+      $counter++;
+      print "\t$file\n";
+  }
+
+  print "\nInfo:\tTotal $counter file(s) changed\n";
+  print "Info:\tNote: Only new files are copied to $result_dir\n";
+}
+
+main();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/icons/qgn_indi_tb_filebrowser_find.svg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentScriptType="text/ecmascript" width="24" baseProfile="tiny" zoomAndPan="magnify" contentStyleType="text/css" viewBox="0 0 24 26" height="26" preserveAspectRatio="xMidYMid meet" version="1.1">
+    <g>
+        <path fill="#496da2" d="M 5.87 16.363 L 9.6 12.516001 L 11.484 14.271001 L 7.867 18.341002 C 6.923 18.275 5.958 16.965 5.87 16.363 z "/>
+        <linearGradient x1="-919.5605" gradientTransform="matrix(3.8462 0 0 -3.8462 3548.5244 5040.7637)" y1="1308.8418" x2="-917.7734" gradientUnits="userSpaceOnUse" y2="1308.0825" xlink:type="simple" xlink:actuate="onLoad" id="XMLID_3_" xlink:show="other">
+            <stop stop-color="#a2c2dd" offset="0"/>
+            <stop stop-color="#ffffff" offset="1"/>
+        </linearGradient>
+        <path fill="url(#XMLID_3_)" d="M 19.906 7.722 C 19.479 10.514 16.677 12.9279995 13.645 13.106 C 10.613001 13.287 8.499001 11.166 8.924 8.374001 C 9.349 5.5810003 12.283999 2.8370004 15.316 2.6580005 C 18.352 2.478 20.334 4.925 19.906 7.722 z " fill-opacity="0.51"/>
+        <linearGradient x1="-919.0566" gradientTransform="matrix(3.8462 0 0 -3.8462 3548.5244 5040.7637)" y1="1308.6963" x2="-919.402" gradientUnits="userSpaceOnUse" y2="1309.1239" xlink:type="simple" xlink:actuate="onLoad" id="XMLID_4_" xlink:show="other">
+            <stop stop-color="#a2c2dd" offset="0"/>
+            <stop stop-color="#ffffff" offset="1"/>
+        </linearGradient>
+        <path fill="url(#XMLID_4_)" d="M 10.728 11.348 C 8.443 6.6909995 12.945999 2.518999 16.723999 3.3749995 C 13.495 3.813 10.113 7.944 10.728 11.348 z " fill-opacity="0.8"/>
+        <path fill="#496da2" d="M 21.509 8.488 C 21.181002 11.9 18.199001 15.295 13.491001 15.164 C 9.954001 15.061999 7.3900013 11.655 8.378001 7.1309996 C 9.128001 3.6999996 13.298001 1.3099995 15.648001 1.5069995 C 18.984 1.787 21.841 4.991 21.509 8.488 z M 15.252 2.298 C 12.221 2.477 9.351999 5.519 8.927 8.311 C 8.5 11.103 10.614 13.224 13.648001 13.04 C 16.679 12.86 19.48 10.448999 19.909 7.658 C 20.334 4.861 18.285 2.117 15.252 2.298 z "/>
+        <path fill="#87a8cb" d="M 7.281 14.871 C 7.2260003 15.705 8.435 16.396 9.432 16.59 L 9.639 16.94 L 4.352 22.91 C 2.7860003 23.168 0.81700015 21.84 1.0810003 20.147999 L 6.8510003 14.739999 L 7.281 14.871 z "/>
+        <path fill="#cadcec" d="M 6.851 14.74 L 7.444 14.734 C 7.5769997 15.496 8.462 16.332 9.601999 16.394001 L 9.638999 16.943 C 8.706 17.225 6.857 16.236 6.851 14.74 z "/>
+        <path fill="#496da2" d="M 8.301 15.938 L 8.03 16.614 C 8.108 16.698 9.019 17.130001 9.639999 16.944 L 9.632999 16.342001 C 9.173 16.393 8.596 16.123 8.301 15.938 z "/>
+        <path fill="#235487" d="M 8.03 16.613 L 2.547 22.556 C 2.916 22.812 3.62 22.928999 4.331 22.939 L 9.641 16.939 C 9.208 17.006 8.554 16.885 8.03 16.613 z "/>
+        <path fill="#496da2" d="M 1.081 20.148 C 0.36499995 22.087 1.4979999 23.697 4.351 22.937 C 3.318 22.938 1.153 22.451 1.081 20.148 z "/>
+        <path fill="#235487" d="M 9.63 16.363 L 11.215 14.584001 C 11.215 14.584001 11.216001 13.828001 10.672 13.500001 L 8.3 15.940001 C 8.432 16.029 9.153 16.396 9.63 16.363 z "/>
+        <path fill="#235487" d="M 18.503 11.612 C 21.16 9.036 20.831001 5.3080006 18.964 3.3960009 C 16.695 1.0740008 13.382001 1.2810009 10.725 3.859001 C 8.067 6.436001 7.7460003 10.074001 10.004001 12.402001 C 10.997001 13.430001 12.376 13.586001 13.892 13.611001 C 15.695 13.639 17.113 12.96 18.503 11.612 z M 10.756 12.027 C 8.901999 10.116 9.216999 6.7910004 11.457999 4.6170006 C 13.698999 2.4430008 17.032 2.2300005 18.889 4.1430006 C 20.741 6.0550003 20.424 9.380001 18.184 11.552 C 16.992 12.71 15.432 13.358 13.902 13.333 C 12.671 13.314 11.552 12.849 10.756 12.027 z "/>
+        <path fill="#87a8cb" d="M 19.259 3.072 C 16.997002 0.74300003 12.998001 0.94499993 10.341001 3.525 C 7.6820006 6.108 7.3570004 10.095 9.615001 12.424 C 10.607 13.45 11.990001 14.026999 13.503 14.05 C 15.309 14.079 17.141 13.3220005 18.533 11.97 C 21.189 9.396 21.517 5.403 19.259 3.072 z M 17.796 11.216 C 16.605 12.375999 15.046 13.021999 13.518 12.997 C 12.285 12.976 11.167 12.513 10.37 11.691 C 8.516 9.78 8.832 6.455 11.073999 4.283 C 13.313999 2.1069999 16.647 1.894 18.504 3.81 C 20.354 5.718 20.039 9.043 17.796 11.216 z "/>
+    </g>
+    <rect width="24" fill="none" height="26"/>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/icons/qgn_indi_tb_filebrowser_folder_parent.svg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,372 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   version="1.0"
+   width="88"
+   height="88"
+   viewBox="0 0 88 88"
+   id="svg2705">
+  <defs
+     id="defs2833" />
+  <rect
+     width="61.599998"
+     height="61.599998"
+     x="23.295238"
+     y="9.1999998"
+     id="rect2707"
+     style="fill:none" />
+  <linearGradient
+     x1="-734.38959"
+     y1="2417.3193"
+     x2="-725.01208"
+     y2="2428.2275"
+     id="XMLID_1294_"
+     gradientUnits="userSpaceOnUse"
+     gradientTransform="matrix(0.79548,0,0,0.79548,649.13352,-1878.4228)">
+    <stop
+       id="stop2710"
+       style="stop-color:#a2c2dd;stop-opacity:1"
+       offset="0" />
+    <stop
+       id="stop2712"
+       style="stop-color:#a2c2dd;stop-opacity:1"
+       offset="0.1" />
+    <stop
+       id="stop2714"
+       style="stop-color:#6c83bb;stop-opacity:1"
+       offset="0.71350002" />
+    <stop
+       id="stop2716"
+       style="stop-color:#003d6d;stop-opacity:1"
+       offset="0.98879999" />
+    <stop
+       id="stop2718"
+       style="stop-color:#003d6d;stop-opacity:1"
+       offset="1" />
+  </linearGradient>
+  <path
+     d="M 51.431738,18.1306 L 48.121438,19.1603 C 48.121438,19.1603 45.954238,26.3738 45.730238,27.1207 C 44.988938,26.9926 39.813838,26.1057 39.813838,26.1057 L 34.360838,28.097199 L 39.311938,49.239298 L 68.769338,58.302197 L 79.150338,26.487197 C 79.150338,26.487197 66.138738,24.522997 65.326738,24.401897 C 65.352636,23.696297 65.490538,20.138897 65.490538,20.138897 L 51.538138,18.094897 L 51.431738,18.1306 z"
+     id="path2720"
+     style="fill:url(#XMLID_1294_)" />
+  <linearGradient
+     x1="-765.96832"
+     y1="2409.7793"
+     x2="-720.93799"
+     y2="2409.7793"
+     id="XMLID_1295_"
+     gradientUnits="userSpaceOnUse"
+     gradientTransform="matrix(1.1364,0,0,1.1364,894.0547,-2696.604)">
+    <stop
+       id="stop2723"
+       style="stop-color:#ffffff;stop-opacity:1"
+       offset="0" />
+    <stop
+       id="stop2725"
+       style="stop-color:#ffffff;stop-opacity:1"
+       offset="0.15000001" />
+    <stop
+       id="stop2727"
+       style="stop-color:#a2c2dd;stop-opacity:1"
+       offset="1" />
+  </linearGradient>
+  <polygon
+     points="23.609,56.738 35.967,14.777 56.066,18.003 55.922,24.229 74.781,27.391 64.507,68.961 23.609,56.738 "
+     transform="matrix(0.7,0,0,0.7,23.295238,9.2)"
+     id="polygon2729"
+     style="fill:url(#XMLID_1295_)" />
+  <linearGradient
+     x1="-741.08398"
+     y1="2422.0742"
+     x2="-773.96033"
+     y2="2394.2329"
+     id="XMLID_1296_"
+     gradientUnits="userSpaceOnUse"
+     gradientTransform="matrix(1.1364,0,0,1.1364,894.0547,-2696.604)">
+    <stop
+       id="stop2732"
+       style="stop-color:#e2e6e4;stop-opacity:1"
+       offset="0" />
+    <stop
+       id="stop2734"
+       style="stop-color:#a3740a;stop-opacity:1"
+       offset="1" />
+  </linearGradient>
+  <polygon
+     points="64.508,68.566 23.408,56.719 16.631,27.439 57.546,35.639 64.508,68.566 "
+     transform="matrix(0.7,0,0,0.7,23.295238,9.2)"
+     id="polygon2736"
+     style="fill:url(#XMLID_1296_)" />
+  <linearGradient
+     x1="-751.48633"
+     y1="435.74609"
+     x2="-747.08618"
+     y2="445.71939"
+     id="XMLID_1297_"
+     gradientUnits="userSpaceOnUse"
+     gradientTransform="matrix(1.1364,0,0,-1.1364,894.0547,525.935)">
+    <stop
+       id="stop2739"
+       style="stop-color:#e2e6e4;stop-opacity:1"
+       offset="0" />
+    <stop
+       id="stop2741"
+       style="stop-color:#a3740a;stop-opacity:1"
+       offset="1" />
+  </linearGradient>
+  <polygon
+     points="64.469,31.873 23.665,24.873 16.631,27.439 57.652,35.797 64.469,31.873 "
+     transform="matrix(0.7,0,0,0.7,23.295238,9.2)"
+     id="polygon2743"
+     style="fill:url(#XMLID_1297_)" />
+  <linearGradient
+     x1="-745.625"
+     y1="2389.1016"
+     x2="-743.54358"
+     y2="2383.4521"
+     id="XMLID_1298_"
+     gradientUnits="userSpaceOnUse"
+     gradientTransform="matrix(1.1364,0,0,1.1364,894.0547,-2696.604)">
+    <stop
+       id="stop2746"
+       style="stop-color:#ffffff;stop-opacity:1"
+       offset="0" />
+    <stop
+       id="stop2748"
+       style="stop-color:#ffffff;stop-opacity:1"
+       offset="0.05" />
+    <stop
+       id="stop2750"
+       style="stop-color:#a2c2dd;stop-opacity:1"
+       offset="1" />
+  </linearGradient>
+  <polygon
+     points="59.557,16.232 40.406,13.427 36.004,14.797 56.066,18.003 59.557,16.232 "
+     transform="matrix(0.7,0,0,0.7,23.295238,9.2)"
+     id="polygon2752"
+     style="fill:url(#XMLID_1298_)" />
+  <linearGradient
+     x1="-728.38379"
+     y1="2397.2881"
+     x2="-726.25159"
+     y2="2391.501"
+     id="XMLID_1299_"
+     gradientUnits="userSpaceOnUse"
+     gradientTransform="matrix(1.1364,0,0,1.1364,894.0547,-2696.604)">
+    <stop
+       id="stop2755"
+       style="stop-color:#ffffff;stop-opacity:1"
+       offset="0" />
+    <stop
+       id="stop2757"
+       style="stop-color:#ffffff;stop-opacity:1"
+       offset="0.05" />
+    <stop
+       id="stop2759"
+       style="stop-color:#a2c2dd;stop-opacity:1"
+       offset="1" />
+  </linearGradient>
+  <polygon
+     points="78.871,25.267 59.32,22.318 55.922,24.229 74.781,27.391 78.871,25.267 "
+     transform="matrix(0.7,0,0,0.7,23.295238,9.2)"
+     id="polygon2761"
+     style="fill:url(#XMLID_1299_)" />
+  <linearGradient
+     x1="-721.13037"
+     y1="2414.3672"
+     x2="-735.64697"
+     y2="2419.4033"
+     id="XMLID_1300_"
+     gradientUnits="userSpaceOnUse"
+     gradientTransform="matrix(1.1364,0,0,1.1364,894.0547,-2696.604)">
+    <stop
+       id="stop2764"
+       style="stop-color:#e6eef4;stop-opacity:1"
+       offset="0" />
+    <stop
+       id="stop2766"
+       style="stop-color:#a3740a;stop-opacity:1"
+       offset="0.4438" />
+    <stop
+       id="stop2768"
+       style="stop-color:#474105;stop-opacity:1"
+       offset="0.9382" />
+    <stop
+       id="stop2770"
+       style="stop-color:#474105;stop-opacity:1"
+       offset="1" />
+  </linearGradient>
+  <polygon
+     points="64.469,31.873 64.512,69.279 57.547,35.854 64.469,31.873 "
+     transform="matrix(0.7,0,0,0.7,23.295238,9.2)"
+     id="polygon2772"
+     style="fill:url(#XMLID_1300_)" />
+  <linearGradient
+     x1="-738.81592"
+     y1="2399.9473"
+     x2="-719.41608"
+     y2="2418.4653"
+     id="XMLID_1301_"
+     gradientUnits="userSpaceOnUse"
+     gradientTransform="matrix(1.1364,0,0,1.1364,894.0547,-2696.604)">
+    <stop
+       id="stop2775"
+       style="stop-color:#a2c2dd;stop-opacity:1"
+       offset="0" />
+    <stop
+       id="stop2777"
+       style="stop-color:#a2c2dd;stop-opacity:1"
+       offset="0.1" />
+    <stop
+       id="stop2779"
+       style="stop-color:#6c83bb;stop-opacity:1"
+       offset="0.71350002" />
+    <stop
+       id="stop2781"
+       style="stop-color:#003d6d;stop-opacity:1"
+       offset="0.98879999" />
+    <stop
+       id="stop2783"
+       style="stop-color:#003d6d;stop-opacity:1"
+       offset="1" />
+  </linearGradient>
+  <polygon
+     points="78.871,25.267 64.525,69.025 74.781,27.391 78.871,25.267 "
+     transform="matrix(0.7,0,0,0.7,23.295238,9.2)"
+     id="polygon2785"
+     style="fill:url(#XMLID_1301_)" />
+  <linearGradient
+     x1="-757.67188"
+     y1="2379.2646"
+     x2="-714.99811"
+     y2="2401.7869"
+     id="XMLID_1302_"
+     gradientUnits="userSpaceOnUse"
+     gradientTransform="matrix(1.1364,0,0,1.1364,894.0547,-2696.604)">
+    <stop
+       id="stop2788"
+       style="stop-color:#ffffff;stop-opacity:1"
+       offset="0" />
+    <stop
+       id="stop2790"
+       style="stop-color:#a2c2dd;stop-opacity:1"
+       offset="0.34999999" />
+    <stop
+       id="stop2792"
+       style="stop-color:#6c83bb;stop-opacity:1"
+       offset="0.69999999" />
+    <stop
+       id="stop2794"
+       style="stop-color:#003d6d;stop-opacity:1"
+       offset="1" />
+  </linearGradient>
+  <polygon
+     points="56.066,18.003 55.922,24.229 59.32,22.318 59.557,16.232 56.066,18.003 "
+     transform="matrix(0.7,0,0,0.7,23.295238,9.2)"
+     id="polygon2796"
+     style="fill:url(#XMLID_1302_)" />
+  <linearGradient
+     x1="-756.70752"
+     y1="406.41599"
+     x2="-726.78888"
+     y2="437.50809"
+     id="XMLID_1303_"
+     gradientUnits="userSpaceOnUse"
+     gradientTransform="matrix(1.1364,0,0,-1.1364,894.0547,525.935)">
+    <stop
+       id="stop2799"
+       style="stop-color:#e2e6e4;stop-opacity:1"
+       offset="0" />
+    <stop
+       id="stop2801"
+       style="stop-color:#a3740a;stop-opacity:1"
+       offset="1" />
+  </linearGradient>
+  <polygon
+     points="23.609,56.738 31.348,30.449 57.604,35.847 64.525,69.025 23.609,56.738 "
+     transform="matrix(0.7,0,0,0.7,23.295238,9.2)"
+     id="polygon2803"
+     style="fill:url(#XMLID_1303_)" />
+  <linearGradient
+     x1="-675.13483"
+     y1="1794.666"
+     x2="-675.13483"
+     y2="1824.666"
+     id="XMLID_1304_"
+     gradientUnits="userSpaceOnUse"
+     gradientTransform="matrix(1.86725,0,0,2.1875,1288.8457,-3924.0162)">
+    <stop
+       id="stop2806"
+       style="stop-color:#a2c2dd;stop-opacity:1"
+       offset="0" />
+    <stop
+       id="stop2808"
+       style="stop-color:#6c83bb;stop-opacity:1"
+       offset="0.51459998" />
+    <stop
+       id="stop2810"
+       style="stop-color:#003d6d;stop-opacity:1"
+       offset="1" />
+  </linearGradient>
+  <path
+     d="M 33.144905,60.786967 L 33.144905,34.591654 L 42.57265,46.106654 L 49.761563,37.684779 L 28.19856,12.425717 L 6.6392923,37.691342 L 13.82447,46.106654 L 22.983332,34.591654 L 22.987068,72.693529 L 49.406789,72.693529 L 49.406789,60.791342 L 33.144905,60.786967 z"
+     id="path2812"
+     style="fill:url(#XMLID_1304_)" />
+  <linearGradient
+     x1="-658.87738"
+     y1="1794.6602"
+     x2="-658.87738"
+     y2="1824.6655"
+     id="XMLID_1305_"
+     gradientUnits="userSpaceOnUse"
+     gradientTransform="matrix(1.75,0,0,2.1875,1222.6362,-3924.0163)">
+    <stop
+       id="stop2815"
+       style="stop-color:#a2c2dd;stop-opacity:1"
+       offset="0" />
+    <stop
+       id="stop2817"
+       style="stop-color:#6c83bb;stop-opacity:1"
+       offset="0.51459998" />
+    <stop
+       id="stop2819"
+       style="stop-color:#003d6d;stop-opacity:1"
+       offset="1" />
+  </linearGradient>
+  <rect
+     width="7.6195002"
+     height="11.906562"
+     x="65.790535"
+     y="60.786968"
+     id="rect2821"
+     style="fill:url(#XMLID_1305_)" />
+  <linearGradient
+     x1="-651.25732"
+     y1="1794.6602"
+     x2="-651.25732"
+     y2="1824.6655"
+     id="XMLID_1306_"
+     gradientUnits="userSpaceOnUse"
+     gradientTransform="matrix(1.75,0,0,2.1875,1197.6831,-3924.0163)">
+    <stop
+       id="stop2824"
+       style="stop-color:#a2c2dd;stop-opacity:1"
+       offset="0" />
+    <stop
+       id="stop2826"
+       style="stop-color:#6c83bb;stop-opacity:1"
+       offset="0.51459998" />
+    <stop
+       id="stop2828"
+       style="stop-color:#003d6d;stop-opacity:1"
+       offset="1" />
+  </linearGradient>
+  <rect
+     width="7.6195002"
+     height="11.906562"
+     x="54.172432"
+     y="60.786968"
+     id="rect2830"
+     style="fill:url(#XMLID_1306_)" />
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/icons/qgn_indi_tb_filebrowser_selection.svg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   version="1.0"
+   width="13"
+   height="13"
+   viewBox="0 0 13 13"
+   id="svg2">
+  <defs
+     id="defs15" />
+  <g
+     transform="matrix(0.8,0,0,0.8,0.765368,1.2718615)"
+     id="g4">
+    <rect
+       width="13"
+       height="13"
+       x="0"
+       y="0"
+       id="rect6"
+       style="fill:none" />
+    <g
+       id="g8">
+      <polygon
+         points="2.509,5.772 1.665,6.475 4.831,10.096 11.814,1.838 11.078,1.182 4.86,8.38 2.509,5.772 "
+         id="polygon10" />
+      <path
+         d="M 11.008,0.115 L 4.8480005,7.2469997 L 2.583,4.735 L 0.595,6.39 L 4.8409996,11.246 L 12.858,1.7650003 L 11.008,0.115 z M 4.86,8.38 L 11.077,1.1810002 L 11.811999,1.8380003 L 4.83,10.096 L 1.665,6.475 L 2.5089998,5.773 L 4.86,8.38 z"
+         id="path12"
+         style="fill:#f8f8f8" />
+    </g>
+  </g>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/icons/qgn_indi_tb_filebrowser_selection_active.svg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   version="1.0"
+   width="13"
+   height="13"
+   viewBox="0 0 13 13"
+   id="svg2">
+  <defs
+     id="defs15" />
+  <g
+     transform="matrix(0.8,0,0,0.8,3.3766268e-2,1.3)"
+     id="g4">
+    <rect
+       width="13"
+       height="13"
+       x="0"
+       y="0"
+       id="rect6"
+       style="fill:none" />
+    <g
+       id="g8">
+      <polygon
+         points="2.509,5.772 1.665,6.475 4.831,10.096 11.814,1.838 11.078,1.182 4.86,8.38 2.509,5.772 "
+         id="polygon10" />
+      <path
+         d="M 11.008,0.115 L 4.8480005,7.2469997 L 2.583,4.735 L 0.595,6.39 L 4.8409996,11.246 L 12.858,1.7650003 L 11.008,0.115 z M 4.86,8.38 L 11.077,1.1810002 L 11.811999,1.8380003 L 4.83,10.096 L 1.665,6.475 L 2.5089998,5.773 L 4.86,8.38 z"
+         id="path12"
+         style="fill:#f8f8f8" />
+    </g>
+  </g>
+  <g
+     transform="matrix(0.8,0,0,0.8,2.5943723,1.2155844)"
+     id="g3202">
+    <rect
+       width="13"
+       height="13"
+       x="0"
+       y="0"
+       id="rect3204"
+       style="fill:none" />
+    <g
+       id="g3206">
+      <polygon
+         points="2.509,5.772 1.665,6.475 4.831,10.096 11.814,1.838 11.078,1.182 4.86,8.38 2.509,5.772 "
+         id="polygon3208" />
+      <path
+         d="M 11.008,0.115 L 4.8480005,7.2469997 L 2.583,4.735 L 0.595,6.39 L 4.8409996,11.246 L 12.858,1.7650003 L 11.008,0.115 z M 4.86,8.38 L 11.077,1.1810002 L 11.811999,1.8380003 L 4.83,10.096 L 1.665,6.475 L 2.5089998,5.773 L 4.86,8.38 z"
+         id="path3210"
+         style="fill:#f8f8f8" />
+    </g>
+  </g>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/icons/qgn_menu_filebrowser.svg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,454 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://web.resource.org/cc/"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:xlink="http://www.w3.org/1999/xlink"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   baseProfile="tiny"
+   height="100%"
+   preserveAspectRatio="xMidYMid meet"
+   version="1.0"
+   viewBox="0 0 87.9995117 88.0004883"
+   width="100%"
+   zoomAndPan="magnify"
+   id="svg76799"
+   sodipodi:version="0.32"
+   inkscape:version="0.44"
+   sodipodi:docname="qgn_menu_filebrowser.svg"
+   sodipodi:docbase="Z:\">
+  <metadata
+     id="metadata76883">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <defs
+     id="defs76881">
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#XMLID_4_"
+       id="linearGradient76934"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(-0.105,-0.4005,0.3754,-9.84e-2,-314.9889,-11.936)"
+       x1="-316.0620117"
+       y1="809.9614258"
+       x2="-323.5102844"
+       y2="840.2769165" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#XMLID_4_"
+       id="linearGradient76936"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(-0.105,-0.4005,0.3754,-9.84e-2,-314.9889,-11.936)"
+       x1="-316.0620117"
+       y1="809.9614258"
+       x2="-323.5102844"
+       y2="840.2769165" />
+  </defs>
+  <sodipodi:namedview
+     inkscape:window-height="820"
+     inkscape:window-width="952"
+     inkscape:pageshadow="2"
+     inkscape:pageopacity="0.0"
+     guidetolerance="10.0"
+     gridtolerance="10.0"
+     objecttolerance="10.0"
+     borderopacity="1.0"
+     bordercolor="#666666"
+     pagecolor="#ffffff"
+     id="base"
+     inkscape:zoom="4.2840671"
+     inkscape:cx="43.999756"
+     inkscape:cy="62.674088"
+     inkscape:window-x="66"
+     inkscape:window-y="87"
+     inkscape:current-layer="svg76799" />
+  <g
+     id="g76801"
+     transform="matrix(0.875332,0,0,0.875332,0.2333,0.23342)">
+    <g
+       id="g76803">
+      <rect
+         height="88.000488"
+         width="87.999512"
+         id="rect76805"
+         x="0"
+         y="0"
+         style="fill:none" />
+      <path
+         d="M 39.916016,17.900391 C 39.919434,17.900391 39.92334,17.900391 39.927246,17.900391 C 39.885742,17.900391 39.873047,17.902832 31.596191,19.527832 C 31.416992,19.476074 26.807617,18.142578 26.807617,18.142578 C 26.736816,18.128906 26.474609,18.099121 26.474609,18.099121 L 21.785645,18.360352 C 21.785645,18.360352 21.786621,18.360352 21.786621,18.36084 C 21.786621,18.369629 21.067871,18.680664 21.067871,18.680664 C 20.967774,18.724121 20.907227,18.80127 20.869629,18.903809 L 20.679199,19.42041 C 20.674317,19.433594 20.675293,19.444824 20.671875,19.456543 C 19.964844,19.278809 18.22168,18.841309 18.22168,18.841309 C 17.789551,18.730469 17.334961,18.868652 17.03711,19.200684 C 17.004883,19.236816 16.972656,19.297363 16.955078,19.342285 L 16.756348,19.858399 C 16.738281,19.905274 16.729004,19.955078 16.729004,20.004883 C 16.729004,20.026367 16.730957,20.047852 16.734375,20.068848 L 16.776367,20.324707 C 16.787109,20.368652 17.119141,21.356934 17.320801,21.956055 C 16.562012,22.062988 13.388672,22.510254 13.388672,22.510254 C 12.800293,22.592285 12.355957,23.102539 12.355957,23.697754 C 12.356445,23.719238 12.67627,28.669434 12.778809,30.25586 C 12.211426,30.143067 11.284668,29.958985 11.284668,29.958985 C 11.206543,29.951172 10.875,29.95459 10.875,29.95459 L 6.378418,30.950684 C 5.8271485,31.072266 5.440918,31.553711 5.440918,32.121094 C 5.440918,32.149902 5.440918,32.149902 6.6865235,55.366699 C 6.7143555,55.878418 7.0634766,56.315918 7.5556641,56.456543 C 7.5576172,56.45752 12.411621,57.834473 13.638184,58.184082 C 13.654785,58.691895 13.769043,62.250489 13.769043,62.250489 C 13.785156,62.762207 14.125,63.20752 14.614746,63.358887 L 53.833496,75.559082 C 53.884277,75.574707 53.937012,75.580567 53.988769,75.57666 L 54.601074,75.52002 C 54.653809,75.51416 54.70459,75.499512 54.751465,75.475098 L 76.42334,63.968262 C 76.804199,63.765137 77.04834,63.371582 77.060059,62.940918 L 78.158691,24.119629 C 78.17627,23.507324 77.729981,22.980957 77.121582,22.896973 L 40.238281,17.896484 C 40.18457,17.893066 39.916016,17.900391 39.916016,17.900391 z "
+         id="path76807"
+         style="fill:#7c6800;fill-opacity:0.25;stroke-opacity:0.25" />
+      <polygon
+         points="14.077148,31.736816 13.555664,23.698242 18.919922,22.943359 17.928711,20.003906 22.00293,21.028809 21.854492,19.558594 26.473633,19.29541 31.541992,20.761231 40.077148,19.085938 76.958496,24.085938 75.86084,62.908691 54.188965,74.414551 14.96875,62.212402 14.80957,57.268066 7.8847656,55.302246 6.640625,32.121094 11.050781,31.136231 14.077148,31.736816 "
+         id="polygon76809"
+         style="fill:white" />
+      <polygon
+         points="53.817871,71.10791 73.304199,61.252441 74.040527,25.139648 52.780762,30.843262 53.817871,71.10791 "
+         id="polygon76811"
+         style="fill:#06f" />
+      <polygon
+         points="53.817871,71.10791 53.083496,30.885254 15.444336,24.263672 16.897461,60.968262 53.817871,71.10791 "
+         id="polygon76813"
+         style="fill:#09f" />
+      <polygon
+         points="74.040527,25.139648 38.993164,20.189453 15.444336,24.263672 53.083496,30.885254 74.040527,25.139648 "
+         id="polygon76815"
+         style="fill:#0cf" />
+      <polygon
+         points="19.116211,28.543945 19.602539,52.943848 48.778809,60.572754 48.942871,34.204102 19.116211,28.543945 "
+         id="polygon76817"
+         style="fill:#070791" />
+      <polygon
+         points="29.621094,31.085938 19.97168,34.612305 28.161133,36.790039 29.621094,31.085938 "
+         id="polygon76819"
+         style="fill:#0046b7" />
+      <polyline
+         points="19.6669922,34.8325195 31.8251953,30.7675781 29.9619141,30.3671875       17.9521484,34.1640625 "
+         id="polyline76821"
+         style="fill:#b3ddff" />
+      <polygon
+         points="23.104492,38.689453 22.814453,20 46.210449,26.876953 45.011719,46.129394 43.783203,47.189941 23.104492,38.689453 "
+         id="polygon76823"
+         style="fill:white" />
+      <polygon
+         points="22.835938,20.076172 45.976074,26.93457 49.001465,26.404297 26.605469,20.072266 22.835938,20.076172 "
+         id="polygon76825"
+         style="fill:#ffc400" />
+      <polygon
+         points="45.976074,26.93457 43.477539,47.744629 46.04834,46.354004 49.001465,26.404297 45.976074,26.93457 "
+         id="polygon76827"
+         style="fill:#d98204" />
+      <path
+         d="M 43.552734,47.766113 L 22.87207,38.785156 C 21.706543,27.642578 18.78418,20.716309 18.78418,20.716309 C 23.080078,22.266113 42.229492,28.328613 42.229492,28.328613 C 45.289063,40.192383 43.37207,42.625 43.552734,47.766113 z "
+         id="path76829"
+         style="fill:#fc0" />
+      <linearGradient
+         gradientTransform="matrix(-0.105,-0.4005,0.3754,-9.84e-2,-314.9889,-11.936)"
+         gradientUnits="userSpaceOnUse"
+         id="XMLID_4_"
+         x1="-316.06201"
+         x2="-323.51028"
+         y1="809.96143"
+         y2="840.27692">
+        <stop
+           offset="0"
+           style="stop-color:#FFFFFF"
+           id="stop76832" />
+        <stop
+           offset="1"
+           style="stop-color:#FFCC00"
+           id="stop76834" />
+      </linearGradient>
+      <path
+         d="M 22.844727,22.126953 C 29.491211,24 42.229492,28.328613 42.229492,28.328613 C 45.283203,38.26123 43.242188,45.841309 43.552734,47.766113 L 22.800781,38.818359 L 22.844727,22.126953 z "
+         id="path76836"
+         style="fill:url(#linearGradient76936)" />
+      <polygon
+         points="41.004883,42.025391 40.986328,40.810059 48.065918,37.460449 48.069824,38.693359 41.004883,42.025391 "
+         id="polygon76838"
+         style="fill:#b3ddff" />
+      <polygon
+         points="8.1904297,32.516113 38.138672,39.671875 38.34668,62.253418 9.2324219,54.01416 8.1904297,32.516113 "
+         id="polygon76840"
+         style="fill:#0cf" />
+      <polygon
+         points="10.730469,32.03125 8.1904297,32.516113 38.138672,39.671875 40.969727,38.604004 10.730469,32.03125 "
+         id="polygon76842"
+         style="fill:#cfecff" />
+      <polygon
+         points="17.31543,46.994629 16.231445,47.297363 28.15918,50.725098 29.324219,50.242676 17.31543,46.994629 "
+         id="polygon76844"
+         style="fill:#cfecff" />
+      <polygon
+         points="18.113281,38.503906 18.243164,42.424316 28.248047,45.068359 28.248047,40.839844 18.113281,38.503906 "
+         id="polygon76846"
+         style="fill:#f9f9f9" />
+      <polygon
+         points="28.163086,50.70166 28.295898,52.703613 29.241211,52.10791 29.324219,50.242676 28.163086,50.70166 "
+         id="polygon76848"
+         style="fill:#06f" />
+      <linearGradient
+         gradientUnits="userSpaceOnUse"
+         id="XMLID_5_"
+         x1="11.963867"
+         x2="34.643429"
+         y1="53.834473"
+         y2="60.526596">
+        <stop
+           offset="0"
+           style="stop-color:#66F2EE"
+           id="stop76851" />
+        <stop
+           offset="1"
+           style="stop-color:#464646"
+           id="stop76853" />
+      </linearGradient>
+      <polygon
+         points="9.3466797,52.802246 38.393555,60.729981 38.337891,62.307129 9.2617188,53.941894 9.3466797,52.802246 "
+         id="polygon76855"
+         style="fill:url(#XMLID_5_)" />
+      <polygon
+         points="38.138672,39.671875 40.969727,38.604004 40.969727,42.076172 48.075684,38.633301 48.083496,56.816894 38.34668,62.253418 38.138672,39.671875 "
+         id="polygon76857"
+         style="fill:#0852bc" />
+      <linearGradient
+         gradientUnits="userSpaceOnUse"
+         id="XMLID_6_"
+         x1="53.26709"
+         x2="73.433105"
+         y1="48.185059"
+         y2="48.185059">
+        <stop
+           offset="0"
+           style="stop-color:#00FFFF"
+           id="stop76860" />
+        <stop
+           offset="0.0490068"
+           style="stop-color:#00E1FF"
+           id="stop76862" />
+        <stop
+           offset="0.1141682"
+           style="stop-color:#00C0FF"
+           id="stop76864" />
+        <stop
+           offset="0.1871896"
+           style="stop-color:#00A4FF"
+           id="stop76866" />
+        <stop
+           offset="0.2686932"
+           style="stop-color:#008DFF"
+           id="stop76868" />
+        <stop
+           offset="0.3624018"
+           style="stop-color:#007BFF"
+           id="stop76870" />
+        <stop
+           offset="0.4758376"
+           style="stop-color:#006FFF"
+           id="stop76872" />
+        <stop
+           offset="0.6294785"
+           style="stop-color:#0068FF"
+           id="stop76874" />
+        <stop
+           offset="1"
+           style="stop-color:#0066FF"
+           id="stop76876" />
+      </linearGradient>
+      <polygon
+         points="55.04834,70.125488 53.849121,71.018066 53.26709,30.977051 73.433105,25.351563 55.04834,70.125488 "
+         id="polygon76878"
+         style="fill:url(#XMLID_6_)" />
+    </g>
+  </g>
+  <g
+     id="g66764"
+     transform="matrix(0.580892,0,0,0.580892,30.46276,33.49717)">
+    <g
+       id="g66766">
+      <rect
+         height="88.000488"
+         width="87.998535"
+         id="rect66768"
+         x="0"
+         y="0"
+         style="fill:none" />
+      <path
+         d="M 12.445313,23.541992 C 12.450684,23.536621 12.459961,23.538574 12.46582,23.533203 C 12.399902,23.605469 12.33252,23.711426 12.217773,23.902832 L 11.669434,25.508789 C 11.420898,28.112793 8.7612305,29.766601 7.7451172,29.761719 C 7.7431641,29.761719 7.1030274,29.961914 7.1030274,29.961914 C 7.0551758,29.977051 7.0234376,29.996582 6.9838868,30.027832 L 2.6176759,33.564941 C 2.5869142,33.593262 2.2260743,34.223144 2.2260743,34.223144 C 2.1948243,34.276855 2.1816407,34.330566 2.1782227,34.393066 C 2.1782227,34.393066 2.0952149,35.925781 2.0952149,35.926269 C 2.0952149,41.897461 5.9643555,44.13623 8.7773438,44.98584 C 8.597168,45.19873 8.4672852,45.446777 8.4672852,45.736816 L 11.043945,64.936035 C 11.108399,65.408691 11.444824,65.79834 11.901367,65.929199 L 60.859863,80.074707 C 61.250488,80.188965 61.67041,80.096191 61.980957,79.82666 L 84.133301,60.395019 C 84.172363,60.359863 84.205566,60.315918 84.229004,60.270019 L 84.497559,59.734863 C 84.521973,59.687988 84.535645,59.637207 84.539551,59.585449 C 86.019043,40.415527 86.019043,40.415527 86.019043,40.373535 C 86.019043,39.777344 85.573731,39.266601 84.98291,39.185058 C 84.98291,39.185058 75.30127,37.846191 72.290527,37.430176 C 72.355957,37.376953 72.479004,37.276367 72.479004,37.276367 C 72.439942,37.308594 72.407715,37.306152 72.374512,37.311035 C 72.496582,37.270996 72.809082,37.124023 74.008301,36.560547 C 75.133301,36.081055 76.311035,35.579101 77.156738,34.694824 C 78.469238,33.407715 79.227051,31.364746 79.227051,29.098144 L 79.223145,28.824219 C 79.144043,25.855469 77.844238,23.051758 75.656738,21.126465 C 75.621582,21.094726 75.574707,21.067871 75.529785,21.051269 L 75.010254,20.853515 C 74.965332,20.836914 74.918457,20.827637 74.869629,20.827637 L 71.266113,20.810058 C 70.694824,20.810058 70.199707,21.215332 70.088379,21.773926 C 70.088379,21.773926 69.250488,25.944824 69.046387,26.961426 C 68.818848,26.751465 68.604004,26.479492 68.442871,26.118164 C 68.489746,25.844726 69.39502,20.551269 69.39502,20.551269 C 69.400879,20.512207 69.421387,20.455566 69.421387,20.412109 C 69.421387,20.404785 69.42041,20.399414 69.42041,20.393555 L 69.390137,20.219726 L 69.240723,19.757324 C 69.211426,19.66748 69.222168,19.646973 69.143066,19.597168 L 68.535644,19.21582 C 68.488769,19.186523 68.441894,19.17041 68.387207,19.162597 L 65.260254,18.697754 L 64.92041,18.696777 C 62.097168,19.086914 59.969238,20.297363 58.596191,22.293945 C 57.271973,24.219726 57.074707,26.316894 57.074707,27.395996 L 57.247559,29.104492 C 57.26709,29.184082 57.461426,30.003418 57.461426,30.003418 C 57.737793,31.127441 58.049316,32.395019 58.049316,33.294433 C 58.049316,33.294433 57.946777,33.943359 57.935059,34.017578 C 57.82959,34.20459 57.615723,34.613769 57.205566,35.407715 C 56.671387,35.333984 41.949219,33.300781 41.638672,33.257812 C 41.459961,33.027832 37.396484,27.795898 36.745117,26.957519 C 39.82373,26.290527 47.033691,26.475586 52.600098,27.415527 C 53.043457,27.487793 53.484863,27.312988 53.754395,26.958008 C 54.025879,26.602051 54.07666,26.128906 53.887207,25.723144 L 49.924316,17.249023 C 49.902832,17.205566 49.875488,17.166015 49.840332,17.132324 L 49.436035,16.737793 C 49.401855,16.704101 49.361816,16.676757 49.316895,16.657226 C 38.896973,12.099121 23.738281,11.51416 12.445313,23.541992 z M 16.739746,39.831055 C 16.741211,38.884277 18.64502,37.631348 19.720703,36.945801 C 19.999512,37.088867 21.273926,37.740234 22.068359,38.146484 C 21.14502,38.611816 18.191406,40.099121 16.487305,40.95752 C 16.497559,40.934082 16.739746,40.380859 16.739746,40.380859 C 16.756836,40.341309 16.763184,40.260254 16.763184,40.180664 C 16.763184,40.109375 16.758301,40.039551 16.750488,40.001465 L 16.758789,40.042481 L 16.739746,39.831055 z M 72.281738,37.328613 C 72.303223,37.328613 72.322754,37.327149 72.35498,37.317383 C 72.333496,37.318848 72.312988,37.328613 72.281738,37.328613 z "
+         id="path66770"
+         style="fill:#7c6800;fill-opacity:0.25;stroke-opacity:0.25" />
+      <path
+         d="M 69.965332,38.319824 L 84.818848,40.374023 L 83.342285,59.492676 L 61.191894,78.922363 L 12.233398,64.775879 L 9.6669922,45.736816 L 24.719727,38.153809 L 19.647461,35.561523 C 17.205567,37.086914 15.258789,38.483398 15.573242,40.220703 L 11.157227,44.286621 C 7.8017578,43.873047 2.5927735,41.928711 3.3735352,34.498047 L 7.7392579,30.961426 C 9.4326173,30.969727 12.573242,28.71875 12.807617,25.889649 L 13.319336,24.36377 C 23.454102,13.569824 37.645508,12.861817 48.836426,17.757324 L 52.799317,26.231445 C 46.812988,25.22168 36.821289,24.815918 34.748535,26.342774 L 40.991211,34.379883 L 57.881348,36.712891 L 59.064942,34.420899 C 59.588379,33.134766 58.85791,30.745117 58.424317,28.882813 C 57.906738,26.655762 58.391113,20.8125 65.084473,19.884766 L 68.211426,20.349121 L 67.191895,26.3125 C 67.713379,27.916992 69.350098,28.623047 69.350098,28.623047 L 70.010254,28.255859 L 71.26416,22.009766 L 74.86377,22.027344 C 78.686035,25.392578 78.896973,31.307617 76.289551,33.865234 C 75.240723,34.961426 73.248535,35.453125 71.885254,36.233398 C 70.322754,37.124023 69.965332,38.319824 69.965332,38.319824 z "
+         id="path66772"
+         style="fill:white" />
+      <polygon
+         points="82.98877,41.490234 34.850586,34.807617 10.897461,46.449707 59.643066,56.678223 82.98877,41.490234 "
+         id="polygon66774"
+         style="fill:#ff6" />
+      <polygon
+         points="34.645508,36.333008 77.516113,42.653809 59.053223,54.161621 34.930664,49.486816 34.645508,36.333008 "
+         id="polygon66776"
+         style="fill:#c15200" />
+      <polygon
+         points="34.645508,36.333008 15.549805,45.724121 34.930664,49.486816 34.645508,36.333008 "
+         id="polygon66778"
+         style="fill:#ff7300" />
+      <g
+         id="g66780">
+        <g
+           id="g66782">
+          <path
+             d="M 76.352051,31.694824 C 76.67041,30.902832 76.869629,29.890625 76.838379,28.59375 C 76.791504,27.172852 76.148926,24.931641 74.311035,22.837891 L 71.859863,22.851563 C 73.848144,25.124023 74.611816,27.337891 74.234863,30.358398 C 74.176269,30.860352 74.059082,31.303711 73.904785,31.695801 L 76.352051,31.694824 z "
+             id="path66784"
+             style="fill:url(#linearGradient76934)" />
+          <g
+             id="g66786">
+            <defs
+               id="defs66788">
+              <path
+                 d="M 55.395019,59.633301 L 52.963379,59.641113 C 53.992676,59.63916 54.779785,59.342285 54.828613,59.32666 L 57.260254,59.316895 C 57.213379,59.334473 56.424316,59.628418 55.395019,59.633301 z "
+                 id="XMLID_2_" />
+            </defs>
+            <use
+               xlink:actuate="onLoad"
+               xlink:href="#XMLID_2_"
+               xlink:show="embed"
+               xlink:type="simple"
+               id="use66791"
+               style="fill:#0046b7"
+               x="0"
+               y="0"
+               width="87.999512"
+               height="88.000488" />
+            <g
+               id="g66793">
+              <path
+                 d="M 54.828613,59.32666 L 57.260254,59.316895 C 57.213379,59.334473 56.424316,59.628418 55.39502,59.633301 L 52.963379,59.641113 C 53.992676,59.63916 54.779785,59.342285 54.828613,59.32666"
+                 id="path66795"
+                 style="fill:#0046b7" />
+            </g>
+          </g>
+          <g
+             id="g66797">
+            <polygon
+               points="65.090332,20.790527 67.375488,21.078125 66.404785,26.494141 63.975098,26.501953 65.090332,20.790527 "
+               id="polygon66799"
+               style="fill:#b7b9b9" />
+          </g>
+          <path
+             d="M 73.904785,31.695801 C 73.131348,33.666992 71.398926,34.34668 70.73877,34.55957 C 69.943848,34.8125 67.314942,35.589844 66.088379,37.922852 L 66.104004,37.922852 C 65.13916,39.753418 55.355957,58.328613 54.828613,59.32666 L 57.260254,59.316895 C 57.797363,58.299316 67.977051,38.970703 68.588379,37.811523 L 68.570801,37.811523 C 69.730957,35.546875 72.955566,34.633789 73.383301,34.485352 C 73.703613,34.375 75.479004,33.878418 76.352051,31.694824 L 73.904785,31.695801 z "
+             id="path66801"
+             style="fill:#6d6d6d" />
+          <path
+             d="M 63.971191,26.500977 L 66.393066,26.485352 C 66.766113,27.546875 67.797363,29.191406 69.502441,29.476563 C 66.766113,30.402832 64.658691,28.758789 63.971191,26.500977 z "
+             id="path66803"
+             style="fill:#c9c9c9" />
+          <path
+             d="M 72.650879,33.527832 L 75.080566,33.520019 C 74.645019,33.931641 74.137207,34.241211 73.572754,34.421875 C 71.439941,35.101563 70.23291,35.813477 69.477051,36.530762 L 67.047363,36.539063 C 67.80127,35.820801 69.008301,35.109375 71.141113,34.428711 C 71.70752,34.248047 72.215332,33.940918 72.650879,33.527832"
+             id="path66805"
+             style="fill:#333" />
+          <g
+             id="g66807">
+            <path
+               d="M 71.88916,22.849121 C 76.004395,27.4375 74.67627,33.291992 71.242676,34.388672 C 67.799316,35.486816 66.768066,36.667969 66.158691,37.819824 C 65.54541,38.979492 55.365723,58.307129 54.828613,59.32666 C 54.771973,59.346191 53.721191,59.737793 52.449707,59.615723 C 50.994629,59.477051 49.32666,58.63916 48.854004,55.686035 L 59.963379,34.609375 C 60.756348,32.59082 59.32666,29.636719 59.172363,27.599121 C 59.025879,25.561523 60.932129,21.179687 65.090332,20.790527 L 63.975098,26.501953 C 64.508301,28.180664 65.984863,29.490234 67.687988,29.652344 C 68.600098,29.742187 69.57666,29.5 70.510254,28.811523 L 71.88916,22.849121 z "
+               id="path66809"
+               style="fill:#919191" />
+          </g>
+          <circle
+             cx="52.789551"
+             cy="55.814941"
+             r="1.6933594"
+             id="circle66811"
+             sodipodi:cx="52.789551"
+             sodipodi:cy="55.814941"
+             sodipodi:rx="1.6933594"
+             sodipodi:ry="1.6933594"
+             style="fill:#36c" />
+          <defs
+             id="defs66813">
+            <linearGradient
+               gradientUnits="userSpaceOnUse"
+               id="linearGradient76911"
+               x1="74.182129"
+               x2="74.765144"
+               y1="24.07373"
+               y2="29.573807">
+              <stop
+                 offset="0"
+                 style="stop-color:#B7B9B9"
+                 id="stop66816" />
+              <stop
+                 offset="0.005618"
+                 style="stop-color:#B7B9B9"
+                 id="stop66818" />
+              <stop
+                 offset="1"
+                 style="stop-color:#6D6D6D"
+                 id="stop66820" />
+            </linearGradient>
+          </defs>
+        </g>
+        <g
+           id="g66822">
+          <g
+             id="g66824">
+            <path
+               d="M 50.832519,44.053711 C 43.444336,39.834961 37.477539,33.416992 34.688476,29.511719 L 33.342773,32.220703 C 33.342773,32.220703 46.459473,45.211426 50.13916,46.160645 L 50.832519,44.053711 z "
+               id="path66826"
+               style="fill:#333" />
+            <path
+               d="M 50.469238,45.766113 C 43.623535,42.766602 34.067383,31.725586 34.067383,31.725586 L 27.676758,36.816406 C 31.770508,39.287109 38.879883,43.388672 45.479004,49.699707 L 50.469238,45.766113 z "
+               id="path66828"
+               style="fill:#6d6d6d" />
+            <path
+               d="M 48.385254,20.231445 L 47.199707,19.206055 C 37.325195,15.119141 28.913086,16.099121 16.15918,23.868164 C 15.344727,24.647461 14.579102,24.813477 13.959961,27.211426 C 13.50293,28.967774 12.106445,31.232422 8.3349609,32.696777 L 7.915039,32.555664 L 5.305664,34.822754 C 4.2705077,36.157227 5.0185546,42.132813 11.46582,42.494141 L 13.651367,40.511719 L 13.651367,39.290527 C 14.12793,36.078125 18.623535,34.112793 20.125977,34.132813 L 26.737305,37.532227 C 28.920899,36.6875 34.623535,32.71875 34.852539,31.164063 C 35.080566,29.604492 34.55957,28.042969 34.55957,28.042969 L 32.520508,25.804687 C 32.520508,25.804687 36.00293,22.625 50.541504,24.591797 C 50.541504,24.591797 50.477051,24.333008 48.998535,22.310547 C 48.998535,22.310547 41.084961,19.855469 32.688477,18.334961 C 36.459961,17.017578 42.286133,17.490234 48.385254,20.231445 z "
+               id="path66830"
+               style="fill:#919191" />
+            <path
+               d="M 34.631836,31.655762 C 35.020508,31.074219 35.165039,30.155762 34.55957,28.042969 L 32.520508,25.804687 C 31.510742,26.799316 30.780273,27.730469 32.039551,28.901367 C 33.299805,30.068359 34.631836,31.655762 34.631836,31.655762 z "
+               id="path66832"
+               style="fill:#6d6d6d" />
+            <path
+               d="M 50.541504,24.591797 C 50.541504,24.591797 51.102051,24.30957 49.621582,22.289063 C 49.621582,22.289063 44.786133,18.80957 35.485352,18.399414 C 39.358398,18.367188 42.692383,18.016602 48.793457,20.757324 L 47.498535,18.779297 C 37.625977,14.6875 28.192383,14.202149 16.25293,23.478516 C 15.719727,23.984375 15.051758,24.650391 14.555664,25.546875 L 15.793945,29.016602 C 31.30957,16.411621 45.932129,22.136719 50.541504,24.591797"
+               id="path66834"
+               style="fill:#c9c9c9" />
+            <path
+               d="M 16.586914,32.304688 C 16.586914,32.304688 12.022461,35.138672 10.043945,38.625 L 7.2333984,41.441406 C 8.0732422,41.981445 12.514648,40.385742 13.717773,40.462891 L 13.854492,39.743164 C 13.963867,38.047852 17.163086,34.486816 20.125977,34.132812 L 16.586914,32.304688 z "
+               id="path66836"
+               style="fill:#333" />
+            <path
+               d="M 16.600586,32.283203 C 14.96582,33.356445 11.579101,35.924805 10.036133,38.587891 L 7.2509765,41.455078 C 6.2861327,40.680664 5.1923827,39.529297 4.8251952,38.158203 L 7.5341796,35.494141 C 8.9443359,34.972656 12.993164,32.606445 15.793945,29.016602 L 16.600586,32.283203 z "
+               id="path66838"
+               style="fill:#6d6d6d" />
+            <path
+               d="M 7.7998047,32.655762 L 7.5068359,35.485352 L 4.8154296,38.153808 C 4.5791015,37.099121 4.5419921,35.902344 4.9482421,35.053223 L 7.7998047,32.655762 z "
+               id="path66840"
+               style="fill:#c9c9c9" />
+            <path
+               d="M 7.5068359,35.485352 C 7.5068359,35.485352 9.3134765,37.180664 10.02832,38.601563 L 7.2666015,41.444824 C 6.6435546,41.074219 5.0283202,39.418945 4.8154296,38.153809 L 7.5068359,35.485352 z "
+               id="path66842"
+               style="fill:#b7b9b9" />
+            <path
+               d="M 7.2666016,41.444824 L 10.02832,38.601563 C 10.811524,38.779297 12.194336,39.764648 13.711914,40.511719 L 11.188477,42.78418 C 9.6630859,42.866211 8.0732422,42.018555 7.2666016,41.444824 z "
+               id="path66844"
+               style="fill:#6d6d6d" />
+            <path
+               d="M 44.65332,48.95166 C 47.324707,48.807129 48.992676,46.717285 49.498535,43.475586 L 50.787598,42.709961 L 73.391113,58.754395 C 74.699707,63.26416 70.836426,69.141113 65.439941,69.166504 L 44.274414,50.365723 L 44.65332,48.95166 z "
+               id="path66846"
+               style="fill:#8e8e8e" />
+            <path
+               d="M 44.274414,50.365723 L 44.65332,48.95166 C 47.070801,48.23291 48.980957,46.559082 49.45752,43.18457 L 50.787598,42.709961 C 51.586426,44.164063 49.070801,49.775879 44.274414,50.365723 z "
+               id="path66848"
+               style="fill:#c9c9c9" />
+          </g>
+          <path
+             d="M 50.787598,42.709961 C 50.805176,43.702148 50.92041,44.510742 50.230957,45.887207 L 67.062988,58.01416 L 70.17041,56.402832 L 50.787598,42.709961 z "
+             id="path66850"
+             style="fill:#464646" />
+        </g>
+      </g>
+      <polygon
+         points="24.135742,47.375488 23.672852,49.090332 59.643066,56.678223 80.211426,43.274414 76.771973,43.078125 59.053223,54.161621 24.135742,47.375488 "
+         id="polygon66852"
+         style="fill:#ff6" />
+      <polygon
+         points="60.791504,76.643066 13.458008,62.793457 11.22168,46.449707 59.973144,56.678223 60.791504,76.643066 "
+         id="polygon66854"
+         style="fill:#f90" />
+      <polygon
+         points="60.791504,76.643066 81.945801,58.510254 82.98877,41.490234 59.893066,56.594238 60.791504,76.643066 "
+         id="polygon66856"
+         style="fill:#ff7300" />
+    </g>
+  </g>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/inc/FB.hrh	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,271 @@
+/*
+* 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 FILEBROWSER_HRH
+#define FILEBROWSER_HRH
+
+enum TFileBrowserCommandIds
+    {
+    EFileBrowserCmdFile = 1,
+    EFileBrowserCmdFileBack,
+    EFileBrowserCmdFileOpen,
+    EFileBrowserCmdFileOpenApparc,
+    EFileBrowserCmdFileOpenDocHandlerEmbed,
+    EFileBrowserCmdFileOpenDocHandlerStandAlone,
+    EFileBrowserCmdFileOpenFileService,
+    EFileBrowserCmdFileOpenDrive,
+    EFileBrowserCmdFileOpenDirectory,
+    EFileBrowserCmdFileView,
+    EFileBrowserCmdFileViewText,
+    EFileBrowserCmdFileViewHex,
+    EFileBrowserCmdFileEdit,
+    EFileBrowserCmdFileEditText,
+    EFileBrowserCmdFileEditHex,
+    EFileBrowserCmdFileSearch,
+    EFileBrowserCmdFileSendTo,
+    EFileBrowserCmdFileNew,
+    EFileBrowserCmdFileNewFile,
+    EFileBrowserCmdFileNewDirectory,
+    EFileBrowserCmdFileDelete,
+    EFileBrowserCmdFileRename,
+    EFileBrowserCmdFileTouch,
+    EFileBrowserCmdFileProperties,
+    EFileBrowserCmdFileChecksums,
+    EFileBrowserCmdFileChecksumsMD5,
+    EFileBrowserCmdFileChecksumsMD2,
+    EFileBrowserCmdFileChecksumsSHA1,
+    EFileBrowserCmdFileSetAttributes,
+    EFileBrowserCmdFileCompress,
+    EFileBrowserCmdFileDecompress,
+    EFileBrowserCmdEdit,
+    EFileBrowserCmdSnapShot,
+    EFileBrowserCmdEditCut,
+    EFileBrowserCmdEditCopy,    
+    EFileBrowserCmdEditPaste,
+    EFileBrowserCmdEditCopyToFolder,    
+    EFileBrowserCmdEditMoveToFolder,
+    EFileBrowserCmdEditSelect,    
+    EFileBrowserCmdEditUnselect,
+    EFileBrowserCmdEditSelectAll,    
+    EFileBrowserCmdEditUnselectAll,
+    EFileBrowserCmdView,
+    EFileBrowserCmdViewSort,
+    EFileBrowserCmdViewSortByName,
+    EFileBrowserCmdViewSortByExtension,
+    EFileBrowserCmdViewSortByDate,
+    EFileBrowserCmdViewSortBySize,
+    EFileBrowserCmdViewOrder,
+    EFileBrowserCmdViewOrderAscending,
+    EFileBrowserCmdViewOrderDescending,
+    EFileBrowserCmdViewFilterEntries,
+    EFileBrowserCmdViewRefresh,
+    EFileBrowserCmdDiskAdmin,    
+    EFileBrowserCmdDiskAdminSetDrivePassword,    
+    EFileBrowserCmdDiskAdminUnlockDrive,    
+    EFileBrowserCmdDiskAdminClearDrivePassword,    
+    EFileBrowserCmdDiskAdminEraseDrivePassword,    
+    EFileBrowserCmdDiskAdminFormatDrive,    
+    EFileBrowserCmdDiskAdminQuickFormatDrive,    
+    EFileBrowserCmdDiskAdminCheckDisk,    
+    EFileBrowserCmdDiskAdminScanDrive,    
+    EFileBrowserCmdDiskAdminSetDriveName,    
+    EFileBrowserCmdDiskAdminSetDriveVolumeLabel,    
+    EFileBrowserCmdDiskAdminEraseMBR,
+    EFileBrowserCmdDiskAdminDrivePartition,    
+    EFileBrowserCmdDiskAdminEjectDrive,    
+    EFileBrowserCmdDiskAdminDismountFileSystem,    
+    EFileBrowserCmdTools,    
+    EFileBrowserCmdToolsAllFiles,
+    EFileBrowserCmdToolsAvkonIconCache,
+    EFileBrowserCmdToolsAvkonIconCacheEnable,
+    EFileBrowserCmdToolsAvkonIconCacheDisable,    
+    EFileBrowserCmdToolsDisableExtErrors,    
+    EFileBrowserCmdToolsEditDataTypes,
+    EFileBrowserCmdToolsEnableExtErrors,
+    EFileBrowserCmdToolsErrorSimulate,
+    EFileBrowserCmdToolsErrorSimulateLeave,
+    EFileBrowserCmdToolsErrorSimulatePanic,
+    EFileBrowserCmdToolsErrorSimulateException,    
+    EFileBrowserCmdToolsLocalConnectivity,    
+    EFileBrowserCmdToolsLocalConnectivityActivateInfrared,    
+    EFileBrowserCmdToolsLocalConnectivityLaunchBTUI,    
+    EFileBrowserCmdToolsLocalConnectivityLaunchUSBUI,    
+    EFileBrowserCmdToolsInstalledApps,    
+    EFileBrowserCmdToolsOpenFiles,    
+    EFileBrowserCmdToolsMsgAttachments,    
+    EFileBrowserCmdToolsMsgAttachmentsInbox,    
+    EFileBrowserCmdToolsMsgAttachmentsDrafts,    
+    EFileBrowserCmdToolsMsgAttachmentsSentItems,    
+    EFileBrowserCmdToolsMsgAttachmentsOutbox,    
+    EFileBrowserCmdToolsMsgStoreWalk,
+    EFileBrowserCmdToolsSecureBackup,    
+    EFileBrowserCmdToolsSecureBackupStartBackup,    
+    EFileBrowserCmdToolsSecureBackupStartRestore,    
+    EFileBrowserCmdToolsSecureBackupStop,    
+    EFileBrowserCmdToolsSetDebugMask,    
+    EFileBrowserCmdToolsMemoryInfo,    
+    EFileBrowserCmdSettings,
+    EFileBrowserCmdAbout,
+    EFileBrowserCmdSettingsChange,
+    EFileBrowserCmdSettingsExit,
+    EFileBrowserCmdSettingsBack,
+    EFileBrowserSettingItemList,
+    EFileBrowserCmdDataTypesChangeMapping,
+    EFileBrowserCmdDataTypesSetDefaultMapping,
+    EFileBrowserCmdDataTypesRefresh,
+    EFileBrowserCmdDataTypesExit,
+    EFileBrowserCmdDataTypesBack,
+    EFileBrowserDataTypesList,
+    EFileBrowserProgressNote,
+    EFileBrowserWaitNote,
+    EFileBrowserAttributeEditorSetArchive,
+    EFileBrowserAttributeEditorSetHidden,
+    EFileBrowserAttributeEditorSetReadOnly,
+    EFileBrowserAttributeEditorSetSystem,
+    EFileBrowserAttributeEditorSetRecurse,
+    EFileBrowserSearchQuerySearchDir,
+    EFileBrowserSearchQueryWildCards,
+    EFileBrowserSearchQueryTextInFile,
+    EFileBrowserSearchQueryMinSize,
+    EFileBrowserSearchQueryMaxSize,
+    EFileBrowserSearchQueryMinDate,
+    EFileBrowserSearchQueryMaxDate,
+    EFileBrowserSearchQueryRecurse,
+    EFileBrowserCmdFileEditorViewAsText,
+    EFileBrowserCmdFileEditorViewAsHex,
+    EFileBrowserCmdFileEditorSave,
+    EFileBrowserCmdFileEditorSaveAs,
+    EFileBrowserCmdFileEditorSaveFormat,
+    EFileBrowserCmdFileEditorSaveFormatANSIASCII,
+    EFileBrowserCmdFileEditorSaveFormatUTF8,
+    EFileBrowserCmdFileEditorSaveFormatUTF16LE,
+    EFileBrowserCmdFileEditorSaveFormatUTF16BE,
+    EFileBrowserCmdFileEditorEditAsText,
+    EFileBrowserCmdFileEditorEditAsHex,
+    EFileBrowserCmdFileEditorExit,
+    EFileBrowserFileOpCommandAttribs,
+    EFileBrowserFileOpCommandCopy,
+    EFileBrowserFileOpCommandMove,
+    EFileBrowserFileOpCommandRename,
+    EFileBrowserFileOpCommandDelete,
+    EFileBrowserFileOpCommandDriveSnapShot
+    };
+
+enum TFileBrowserFixedIconIds
+    {
+    EFixedIconMarking = 0,
+    EFixedIconEmpty,    
+    EFixedIconPhoneMemory,    
+    EFixedIconMemoryCard,    
+    EFixedIconMemoryCardDisabled,    
+    EFixedIconFolder,    
+    EFixedIconFolderSub,    
+    EFixedIconFolderCurrent,
+    EFixedIconListLength // this should be last   
+    };
+
+enum TFileBrowserEntryOverwriteActions
+    {
+    EFileActionOverwriteAll = 0,
+    EFileActionSkipAllExisting,    
+    EFileActionGenerateUniqueFilenames,
+    EFileActionQueryPostFix   
+    };
+
+enum TFileBrowserSecureBackupState
+    {
+    ESecureBackupStateFull = 0,
+    ESecureBackupStatePartial    
+    };
+
+enum TFileBrowserSecureBackupType
+    {
+    ESecureBackupTypeBase = 0,
+    ESecureBackupTypeIncremental    
+    };
+    
+enum TFileBrowserDataTypePriorities
+    {
+    EDataTypePriorityMaximum = 0,
+    EDataTypePriorityHigh,    
+    EDataTypePriorityNormal,
+    EDataTypePriorityLow,
+    EDataTypePriorityLastResort   
+    };
+
+enum TFileBrowserCommonFileActions
+    {
+    ECommonFileActionViewAsTextHex = 0,
+    ECommonFileActionOpenWithApparc,    
+    ECommonFileActionOpenWithDocHandlerEmbed   
+    };
+                     
+enum TFileBrowserSettingListTabs
+    {
+    ETabGeneral = 0,
+    ETabFileOps    
+    };
+    
+enum TFileBrowserSettingListIds
+    {
+    ESettingListDisplayModeSelection = 0,
+    ESettingListFileViewModeSelection,
+    ESettingListShowSubdirectoryInfoSelection,
+    ESettingListShowAssociatedIconsSelection,
+    ESettingListRememberLastPathSelection,
+    ESettingListRememberFolderSelection,
+    ESettingListEnableToolbar,
+
+    ESettingListSupportNetworkDrivesSelection,
+    ESettingListBypassPlatformSecuritySelection,
+    ESettingListRemoveFileLocksSelection,
+    ESettingListIgnoreProtectionsAttsSelection,
+    ESettingListRemoveROMWriteProtectionSelection
+    };
+
+enum TFileBrowserSettingDisplayModes
+    {
+    EDisplayModeFullScreen = 0,
+    EDisplayModeNormal
+    };
+
+enum TFileBrowserSettingFileViewModes
+    {
+    EFileViewModeSimple = 0,
+    EFileViewModeExtended
+    };
+
+enum TFileBrowserFileEditorModes
+    {
+    EFileEditorViewAsText = 0,
+    EFileEditorViewAsHex,
+    EFileEditorEditAsText,
+    EFileEditorEditAsHex
+    };
+
+enum
+    {
+    EFileViewerDialogControl = 0x5FEC
+    };
+
+enum
+    {
+    EFileEditorDialogId = 1
+    };
+
+#endif      // FILEBROWSER_HRH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/inc/FBApp.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,63 @@
+/*
+* 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 FILEBROWSERAPP_H
+#define FILEBROWSERAPP_H
+
+// INCLUDES
+#include <aknapp.h>
+
+// CONSTANTS
+// UID of the application
+const TUid KUidFileBrowser = { 0x102828D6 };
+
+// CLASS DECLARATION
+
+/**
+* CFileBrowserApp application class.
+* Provides factory to create concrete document object.
+* 
+*/
+class CFileBrowserApp : 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 CFileBrowserDocument document object.
+        * @return A pointer to the created document object.
+        */
+        CApaDocument* CreateDocumentL();
+        
+        /**
+        * From CApaApplication, returns application's UID (KUidFileBrowser).
+        * @return The value of KUidFileBrowser.
+        */
+        TUid AppDllUid() const;
+    };
+
+#endif
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/inc/FBAppUi.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,89 @@
+/*
+* 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 FILEBROWSERAPPUI_H
+#define FILEBROWSERAPPUI_H
+
+// INCLUDES
+#include <eikapp.h>
+#include <eikdoc.h>
+#include <e32std.h>
+#include <coeccntx.h>
+#include <aknViewAppUi.h>
+#include <akntabgrp.h>
+#include <aknnavide.h>
+#include "FBStd.h"
+
+// FORWARD DECLARATIONS
+class CFileBrowserFileListContainer;
+class CFileBrowserModel;
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+
+// CLASS DECLARATION
+
+
+class CFileBrowserAppUi : public CAknViewAppUi
+    {
+    public: // // Constructors and destructor
+
+        /**
+        * EPOC default constructor.
+        */      
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */      
+        ~CFileBrowserAppUi();
+        
+    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
+        CFileBrowserModel*    iModel;
+
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/inc/FBDocument.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,84 @@
+/*
+* 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 FILEBROWSERDOCUMENT_H
+#define FILEBROWSERDOCUMENT_H
+
+// INCLUDES
+#include <AknDoc.h>
+   
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class CEikAppUi;
+class CFileBrowserModel;
+
+
+// CLASS DECLARATION
+
+/**
+*  CFileBrowserDocument application class.
+*/
+class CFileBrowserDocument : public CAknDocument
+    {
+    public: // Constructors and destructor
+        /**
+        * Two-phased constructor.
+        */
+        static CFileBrowserDocument* NewL(CEikApplication& aApp);
+
+        /**
+        * Destructor.
+        */
+        virtual ~CFileBrowserDocument();
+
+    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.
+        */
+        CFileBrowserDocument(CEikApplication& aApp);
+        void ConstructL();
+
+    private:
+
+        /**
+        * From CEikDocument, create CFileBrowserAppUi "App UI" object.
+        */
+        CEikAppUi* CreateAppUiL();
+
+    public:
+        CFileBrowserModel* Model();
+
+    private:
+        CFileBrowserModel* iModel;
+
+    };
+
+#endif
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/inc/FBFileDlgs.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,164 @@
+/*
+* 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 FILEBROWSER_FILEDLGS_H
+#define FILEBROWSER_FILEDLGS_H
+
+
+//  INCLUDES
+#include "FBFileUtils.h"
+
+#include <e32std.h>
+#include <e32base.h>
+#include <f32file.h>
+#include <aknlistquerydialog.h>
+#include <apgcli.h>
+
+
+//  FORWARD DECLARATIONS
+class CAknIconArray;
+class CAknSingleGraphicStyleListBox;
+
+
+//  CLASS DEFINITIONS
+
+class CFileBrowserDestinationFolderSelectionDlg : public CAknListQueryDialog
+    {
+public:
+    static CFileBrowserDestinationFolderSelectionDlg* NewL(TDes& aReturnPath, CDriveEntryList* aDriveEntryList, CAknIconArray* aIconArray);
+    virtual ~CFileBrowserDestinationFolderSelectionDlg();
+
+private: // Constructors
+    CFileBrowserDestinationFolderSelectionDlg(TDes& aReturnPath, CAknIconArray* aIconArray);
+    void ConstructL(CDriveEntryList* aDriveEntryList);        
+
+protected:  // From CEikDialog
+    TKeyResponse OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType);
+    void PreLayoutDynInitL();
+    void PostLayoutDynInitL();
+    TBool OkToExitL(TInt aButtonId);    
+
+protected:  // From CCoeControl
+    //void HandlePointerEventL(const TPointerEvent &aPointerEvent); 
+
+private: // New methods
+    void MoveUpOneLevelL();
+    void MoveDownToDirectoryL();
+    void RefreshViewL();
+    inline TBool IsDriveListViewActive() { return iCurrentPath==KNullDesC; }
+    
+public:  // New methods
+    TBool RunCopyDlgLD();
+    TBool RunMoveDlgLD();
+
+private: // Data
+    TInt                            iSelectedIndex;
+    TBuf<16>                        iLSKActionText;
+    TDes&                           iReturnPath;
+    RFs                             iFs;
+    CDriveEntryList*                iDriveEntryList;
+    CFileEntryList*                 iFileEntryList;
+    CAknIconArray*                  iIconArray;
+    TFileName                       iCurrentPath;
+    //TPoint                          iDragStartPoint;
+    //TBool                           iIsDragging;
+    };
+
+
+class CFileBrowserAttributeEditorDlg : public CAknForm
+    {
+public:
+    static CFileBrowserAttributeEditorDlg* NewL(TUint& aSetAttMask, TUint& aClearAttMask, TBool& aRecurse);
+    virtual ~CFileBrowserAttributeEditorDlg();
+
+private: // Constructors
+    CFileBrowserAttributeEditorDlg(TUint& aSetAttMask, TUint& aClearAttMask, TBool& aRecurse);
+    void ConstructL();        
+
+protected:  // From CEikDialog
+    TBool OkToExitL(TInt aButtonId);    
+    void PreLayoutDynInitL();
+    
+public:  // New methods
+    TBool RunEditorLD();
+
+private: // Data
+    TUint&                          iSetAttMask;
+    TUint&                          iClearAttMask;
+    TBool&                          iRecurse;
+    };
+
+
+class CFileBrowserSearchQueryDlg : public CAknForm
+    {
+public:
+    static CFileBrowserSearchQueryDlg* NewL(TSearchAttributes& aSearchAttributes);
+    virtual ~CFileBrowserSearchQueryDlg();
+
+private: // Constructors
+    CFileBrowserSearchQueryDlg(TSearchAttributes& aSearchAttributes);
+    void ConstructL();        
+
+protected:  // From CEikDialog
+    TBool OkToExitL(TInt aButtonId);    
+    void PreLayoutDynInitL();
+    
+public:  // New methods
+    TBool RunQueryLD();
+
+private: // Data
+    TSearchAttributes&              iSearchAttributes;
+    };
+
+
+class CFileBrowserDataTypesDlg : public CAknDialog, public MEikListBoxObserver
+    {
+public:
+    static CFileBrowserDataTypesDlg* NewL();
+    virtual ~CFileBrowserDataTypesDlg();
+
+public: // From MEikListBoxObserver
+    void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
+
+public: // From CAknDialog
+    void ProcessCommandL(TInt aCommandId);
+        
+private: // Constructors
+    CFileBrowserDataTypesDlg();
+    void ConstructL();        
+
+protected: // From CEikDialog
+    void PreLayoutDynInitL();
+    TBool OkToExitL(TInt aButtonId); 
+    
+public:  // New methods
+    void GetDataTypesL();
+    void ChangeMappingL();
+    void SetDefaultMappingL();
+    TBool RunQueryLD();
+
+private: // Data
+    CAknSingleGraphicStyleListBox*          iListBox;
+    RApaLsSession                           iLs;
+    CDataTypeArray*                         iDTArray;  
+    };
+
+#endif
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/inc/FBFileEditor.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,137 @@
+/*
+* 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 FILEBROWSER_FILEVIEWERDLG_H
+#define FILEBROWSER_FILEVIEWERDLG_H
+
+//  INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <f32file.h>
+#include <AknDialog.h>
+#include <eiksbobs.h>
+
+//  FORWARD DECLARATIONS
+class CFileBrowserFileEditorViewControl;
+class CEikEdwin;
+class CParaFormat;
+class CEikScrollBarFrame;
+
+
+//  CLASS DEFINITIONS
+
+class CFileBrowserFileEditorDlg : public CAknDialog
+    {
+public:
+    static CFileBrowserFileEditorDlg* NewL(const TDesC& aFileName, TInt aMode);
+    virtual ~CFileBrowserFileEditorDlg();
+
+private: // Constructors
+    CFileBrowserFileEditorDlg(const TDesC& aFileName, TInt aMode);
+    void ConstructL();        
+
+protected: // From CAknDialog
+    void ProcessCommandL(TInt aCommandId);
+    void PreLayoutDynInitL();
+    void PostLayoutDynInitL();
+        
+protected: // From CEikDialog
+    void SetSizeAndPosition(const TSize& aSize);
+    SEikControlInfo CreateCustomControlL(TInt aControlType);
+
+protected: // From MEikMenuObserver
+    void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
+
+public:  // New methods
+    TBool RunDlgLD();
+
+private:  // New methods
+    void OpenFileLC(RFile& aFile, const TDesC& aFileName);
+    void LoadFileL();    
+    void GetTextFileMode(RFile& aFile, TInt& aFileSize);
+    HBufC16* ConvertBuf8ToBuf16L(HBufC8* aBuf8);
+    HBufC8* ConvertBuf16ToBuf8L(HBufC16* aBuf16);
+    void SaveEditorDataL(TBool aQueryNewName=EFalse);
+    TBool IsHexChar(TInt aCh);
+
+private: // Data
+    CFileBrowserFileEditorViewControl*  iViewer;
+    CEikEdwin*                          iTextEditor;
+    CParaFormat*                        iEditorPF;
+    TFileName			                iFileName;
+    TInt                                iActiveMode;
+    TInt                                iTextFormat;
+    };
+
+
+
+class CFileBrowserFileEditorViewControl : public CCoeControl, MEikScrollBarObserver
+    {
+public:
+    virtual ~CFileBrowserFileEditorViewControl();
+
+public: // Constructors
+    CFileBrowserFileEditorViewControl();
+    void ConstructL();        
+
+protected: // From CCoeControl
+    void Draw(const TRect& aRect) const; 
+    TKeyResponse OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType);
+    TSize MinimumSize();
+    CCoeControl* ComponentControl(TInt aIndex) const;
+    TInt CountComponentControls() const;    
+    void HandleResourceChange(TInt aType);
+    TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
+
+protected: // From MEikScrollBarObserver
+    void HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType);
+
+public: // New methods
+    void FormatAsTextL(HBufC16* aBuf=NULL);
+    void FormatAsHexL(HBufC8* aBuf=NULL);
+
+private: // New methods
+    void InitVariables();
+    void ResetVariables(TBool aResetData=ETrue);
+    void UpdateScrollBarL();
+    
+private: // Data
+    TInt			        iActiveMode;
+    TRect                   iViewerRect;
+    TInt                    iDrawingWidth;
+    TInt                    iLeftDrawingPosition;
+    TReal                   iX_factor;
+    TReal                   iY_factor;
+    TInt                    iNumberOfLinesFitsScreen;
+    CEikScrollBarFrame*     iScrollBarFrame;
+    CFont*                  iFont;
+    TInt                    iCurrentLine;
+    TInt                    iTotalNumberOfLines;
+    
+    HBufC8*                 iHexesBuffer;
+    TInt                    iHexGrougWidth;
+    TInt                    iAmountOfHexesFitsHorizontally;
+    
+    HBufC16*                iTextBuf;
+    CArrayFix<TPtrC>*       iWrappedTextArray;
+    };
+
+#endif
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/inc/FBFileListContainer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,123 @@
+/*
+* 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 FILEBROWSERMAINCONTAINER_H
+#define FILEBROWSERMAINCONTAINER_H
+
+// INCLUDES
+#include <coecntrl.h>
+#include <aknlists.h>
+#include <eiklbo.h>
+
+// FORWARD DECLARATIONS
+class CFileBrowserModel;
+class CEikTextListBox;
+class CAknSearchField;
+class CAknNavigationControlContainer;
+class CAknNavigationDecorator;
+class CAknIconArray;
+class CAknInfoPopupNoteController;
+class CFont;
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)
+    class CFileBrowserToolbar;
+#endif
+
+// CLASS DECLARATIONS
+
+class CFileBrowserFileListContainer : public CCoeControl, MCoeControlObserver, MEikListBoxObserver
+    {
+public:
+    void ConstructL(const TRect& aRect);
+    ~CFileBrowserFileListContainer();
+
+private:
+    void SizeChanged();
+    TInt CountComponentControls() const;
+    CCoeControl* ComponentControl(TInt aIndex) const;
+    void Draw(const TRect& aRect) const;
+    void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
+    void HandleResourceChange(TInt aType);
+    void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType); // From MEikListBoxObserver
+    void HandlePointerEventL(const TPointerEvent &aPointerEvent);
+
+public:
+	TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode /*aType*/);
+    void CreateEmptyNaviPaneLabelL();
+    void DeleteNaviPane();
+    void CreateListBoxL(TInt aFileViewMode);
+    TInt CurrentListBoxItemIndex();
+    const CArrayFix<TInt>* ListBoxSelectionIndexes();
+    TInt ListBoxSelectionIndexesCount();
+    TInt ListBoxNumberOfVisibleItems();
+    CAknIconArray* ListBoxIconArrayL();
+    void SetListBoxIconArrayL(CAknIconArray* aIconArray);
+    void SetListBoxTextArrayL(CDesCArray* aTextArray);
+    void EnableSearchFieldL();
+    TBool IsSearchFieldEnabled();
+    void DisableSearchFieldL();
+    void SetScreenLayoutL(TInt aLayoutMode);
+    void SetNaviPaneTextL(const TDesC& aText);
+    inline CEikTextListBox* ListBox() { return iListBox; }
+    inline CAknSearchField* SearchField() { return iSearchField; }
+    void HandleSettingsChangeL();
+    void HideToolbar();
+    void UpdateToolbar();
+
+private:
+    CFileBrowserModel*                  iModel;
+    CEikTextListBox*                    iListBox;
+    CAknSearchField*                    iSearchField;
+    CAknNavigationControlContainer*     iNaviContainer;
+    CAknNavigationDecorator*            iNaviDecorator;
+    CAknInfoPopupNoteController*        iInfoPopup;
+    TInt                                iFileViewMode;
+    TPoint                              iDragStartPoint;
+    TBool                               iIsDragging;
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)
+    CFileBrowserToolbar*                iToolbar;
+#endif
+    };
+
+
+class CSimpleFileViewListBox : public CAknSingleGraphicStyleListBox
+    {
+private:
+    ~CSimpleFileViewListBox();
+    void ReleaseFonts();
+    void SizeChanged();
+    void SizeChangedL();
+private:
+    CFont*     iFont;
+    };
+
+
+class CExtendedFileViewListBox : public CAknDoubleGraphicStyleListBox
+    {
+private:    
+    ~CExtendedFileViewListBox();
+    void ReleaseFonts();
+    void SizeChanged();
+    void SizeChangedL();
+private:
+    CFont*     iFont1;
+    CFont*     iFont2;
+    };
+    
+#endif
+
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/inc/FBFileListView.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,109 @@
+/*
+* 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 FILEBROWSERMAINVIEW_H
+#define FILEBROWSERMAINVIEW_H
+
+// INCLUDES
+#include <aknview.h>
+#include <remconcoreapitargetobserver.h>
+
+#include "FBStd.h"
+
+
+
+// CONSTANTS
+// UID of view
+const TUid KFileListViewUID = {1};
+
+
+// FORWARD DECLARATIONS
+class CFileBrowserFileListContainer;
+class CFileBrowserModel;
+class CRemConInterfaceSelector;
+class CRemConCoreApiTarget;
+
+
+// CLASS DECLARATION
+
+/**
+*  CFileBrowserFileListView view class.
+* 
+*/
+class CFileBrowserFileListView : public CAknView, public MRemConCoreApiTargetObserver
+    {
+    public: // Constructors and destructor
+
+        /**
+        * EPOC default constructor.
+        */
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */
+        ~CFileBrowserFileListView();
+
+    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 MEikMenuObserver
+        void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
+
+    private:
+        // From MRemConCoreApiTargetObserver
+        void MrccatoCommand(TRemConCoreApiOperationId aOperationId, TRemConCoreApiButtonAction aButtonAct);
+        
+    private:
+
+        /**
+        * From AknView, ?member_description
+        */
+        void DoActivateL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,
+            const TDesC8& aCustomMessage);
+
+        /**
+        * From AknView, ?member_description
+        */
+        void DoDeactivate();
+
+    private: // Data
+        CFileBrowserFileListContainer*  iContainer;
+        CFileBrowserModel*              iModel;
+        CRemConInterfaceSelector*       iRemConSelector;
+        CRemConCoreApiTarget*           iRemConTarget;        
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/inc/FBFileOps.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,134 @@
+/*
+* 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 FILEBROWSER_FILEOPS_H
+#define FILEBROWSER_FILEOPS_H
+
+// INCLUDES
+#include <e32base.h>
+#include <f32file.h>
+#include <connect/sbeclient.h>
+
+// FORWARD DECLARATIONS
+class TFileEntry;
+class CFBFileOpClient;
+class CFileMan;
+class CFileBrowserModel;
+class CSBEClient;
+
+
+class CFileBrowserFileOps : public CBase,
+                            public MFileManObserver 
+	{
+private:
+    enum TRecursiveOperation
+    	{
+    	EFileOpInvalid = -1,
+    	EFileOpCopy,
+    	EFileOpMove,
+    	EFileOpRename,
+    	EFileOpAttribs,
+    	EFileOpDelete,
+    	EFileOpMkDirAll,
+    	EFileOpCreateEmptyFile,
+    	EFileOpEraseMBR,
+    	EFileOpPartitionDrive
+    	};
+public:
+	static CFileBrowserFileOps* NewL(CFileBrowserModel* aModel);
+	~CFileBrowserFileOps();
+
+public: // From MFileManObserver
+    
+    TControl NotifyFileManStarted();
+    TControl NotifyFileManOperation();
+    TControl NotifyFileManEnded();
+    
+private:
+	CFileBrowserFileOps(CFileBrowserModel* aModel);
+	void ConstructL();
+
+public:
+    TInt ActivateSecureBackUpViaFileOp();
+    TInt DeActivateSecureBackUpViaFileOp();
+    TInt ActivateSecureBackUp(conn::TBURPartType aPartType=conn::EBURBackupFull, conn::TBackupIncType aBackupIncType=conn::EBackupBase);
+    TInt DeActivateSecureBackUp();
+    TInt Copy(const TFileEntry& aSourceEntry, const TDesC& aTargetFullName, TUint aSwitch=CFileMan::EOverWrite, TBool aDeleteSource=EFalse); 
+    TInt Rename(const TFileEntry& aSourceEntry, const TDesC& aNew, TUint aSwitch=CFileMan::EOverWrite); 
+    TInt Attribs(const TFileEntry& aSourceEntry, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch=0); 
+    TInt Delete(const TFileEntry& aSourceEntry, TUint aSwitch=0); 
+    TInt MkDirAll(const TDesC& aPath, TInt aSetAtts=0, TBool aQuickOperation=EFalse); 
+    TInt CreateEmptyFile(const TDesC& aName); 
+    TInt DriveSnapShot(TChar aSourceDriveLetter, TChar aTargetDriveLetter); 
+    TInt EraseMBR(TUint aDriveNumber); 
+    TInt PartitionDrive(TUint aDriveNumber, TUint aNumberOfPartitions);
+    void CancelOp();
+
+private:
+    TInt DoFindEntries(const TDesC& aFileName, const TDesC& aPath);
+    TInt DoFindEntriesRecursiveL(const TDesC& aFileName, const TDesC& aPath);    
+
+    TInt FileOpCopy(const TDesC& aSourceFullName, const TDesC& aTargetFullName, TUint aSwitch); 
+    TInt DoFileOpCopy(const TDesC& aSourceFullName, const TDesC& aTargetFullName, TUint aSwitch); 
+
+    TInt FileOpRename(const TDesC& aName, const TDesC& aNew, TUint aSwitch); 
+    TInt DoFileOpRename(const TDesC& aName, const TDesC& aNew, TUint aSwitch); 
+
+    TInt FileOpAttribs(const TDesC& aName, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch); 
+    TInt DoFileOpAttribs(const TDesC& aName, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch); 
+
+    TInt FileOpDeleteFile(const TDesC& aName, TUint aSwitch); 
+    TInt DoFileOpDeleteFile(const TDesC& aName, TUint aSwitch); 
+
+    TInt FileOpRmDir(const TDesC& aDirName, TUint aSwitch); 
+    TInt DoFileOpRmDir(const TDesC& aDirName, TUint aSwitch); 
+
+    TInt FileOpMkDirAll(const TDesC& aPath, TInt aSetAtts=0); 
+    TInt DoFileOpMkDirAll(const TDesC& aPath); 
+
+    TInt FileOpCreateEmptyFile(const TDesC& aName); 
+    TInt DoFileOpCreateEmptyFile(const TDesC& aName); 
+
+public:
+    inline TBool SecureBackUpActive() { return iSecureBackUpActive; }
+    inline TBool FileCommandActivatedSecureBackup() { return iFileCommandActivatedSecureBackup; }
+
+private:
+    TInt                            iRecursiveState;
+    CFileBrowserModel*              iModel;
+    CFBFileOpClient*                iFileOpClient;
+    CFileMan*                       iFileMan;
+    RFs                             iFs;
+    TInt                            iOperationError;
+    conn::CSBEClient*               iSBEClient;
+    TBool                           iSecureBackUpActive;
+    TBool                           iFileCommandActivatedSecureBackup;
+
+    TFileName   iBuf1;
+    TFileName   iBuf2;
+    TUint       iUint1;
+    TUint       iUint2;
+    TUint       iUint3;
+    TTime       iTime1;
+    MFileManObserver::TControl iFileManObserverResult;
+    };
+
+#endif
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/inc/FBFileUtils.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,380 @@
+/*
+* 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 FILEBROWSER_FILEUTILS_H
+#define FILEBROWSER_FILEUTILS_H
+
+// INCLUDES
+#include <e32base.h>
+#include <f32file.h>
+#include <w32std.h>
+#include <badesca.h>
+#include <coedef.h>
+#include <AknServerApp.h>
+#include <msvapi.h>
+#include <AknProgressDialog.h> 
+#include <tz.h>
+
+_LIT(KIRAppPath, "z:\\sys\\bin\\irapp.exe");
+_LIT(KBTAppPath, "z:\\sys\\bin\\btui.exe");
+_LIT(KUSBAppPath, "z:\\sys\\bin\\usbclasschangeui.exe");
+_LIT(KErrRdPath, "c:\\resource\\ErrRd");
+_LIT(KErrRdDir, "c:\\resource\\");
+
+
+// FORWARD DECLARATIONS
+class CFileBrowserModel;
+class CFileBrowserFileOps;
+class CAknIconArray;
+class TAknsItemID;
+class CDocumentHandler;
+class CAknWaitDialog;
+class CAknProgressDialog;
+class CEikProgressInfo;
+class CFBFileOpClient;
+class CAknProgressDialog;
+class CEikProgressInfo;
+class CAknOpenFileService;
+class CMessageDigest;
+
+// CLASS DECLARATIONS
+
+class TSearchAttributes
+	{
+public:
+    TFileName       iSearchDir;
+    TFileName       iWildCards;
+    TFileName       iTextInFile;
+    TUint           iMinSize;
+    TUint           iMaxSize;
+    TTime           iMinDate;
+    TTime           iMaxDate;
+    TBool           iRecurse;
+	};
+
+class TDriveEntry
+	{
+public:
+    TChar           iLetter;
+    TInt            iNumber;
+    TVolumeInfo     iVolumeInfo;
+    TBuf<64>        iMediaTypeDesc;
+    TBuf<128>       iAttributesDesc;
+    TInt            iIconId;
+	};
+
+class TFileEntry
+	{
+public:
+    TFileName       iPath;
+    TEntry          iEntry;
+    TInt            iDirEntries;
+    TInt            iIconId;
+	};
+
+class TAppIcon
+	{
+public:
+    TInt            iId;
+    TUid            iUid;
+	};
+
+typedef CArrayFixSeg<TDriveEntry> CDriveEntryList;
+typedef CArrayFixSeg<TFileEntry> CFileEntryList;
+typedef CArrayFixSeg<TAppIcon> CAppIconList;
+
+
+class CCommandParamsBase : public CBase
+    {
+    };
+
+class CCommandParamsAttribs : public CCommandParamsBase
+    {
+public:
+    TFileEntry iSourceEntry;
+    TUint iSetMask;
+    TUint iClearMask;
+    TTime iTime;
+    TUint iSwitch;
+public:
+    CCommandParamsAttribs(const TFileEntry& aSourceEntry, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch) : iSourceEntry(aSourceEntry), iSetMask(aSetMask), iClearMask(aClearMask), iTime(aTime), iSwitch(aSwitch) {}
+    };
+    
+class CCommandParamsCopyOrMove : public CCommandParamsBase
+    {
+public:
+    TFileEntry iSourceEntry;
+    TFileName iTargetPath;
+    TUint iSwitch;
+public:
+    CCommandParamsCopyOrMove(const TFileEntry& aSourceEntry, const TDesC& aTargetPath, TUint aSwitch) : iSourceEntry(aSourceEntry), iTargetPath(aTargetPath), iSwitch(aSwitch) {}
+    };
+        
+class CCommandParamsRename : public CCommandParamsBase
+    {
+public:
+    TFileEntry iSourceEntry;
+    TFileName iTargetPath;
+    TUint iSwitch;
+public:
+    CCommandParamsRename(const TFileEntry& aSourceEntry, const TDesC& aTargetPath, TUint aSwitch) : iSourceEntry(aSourceEntry), iTargetPath(aTargetPath), iSwitch(aSwitch) {}
+    };
+
+class CCommandParamsDelete : public CCommandParamsBase
+    {
+public:
+    TFileEntry iSourceEntry;
+    TUint iSwitch;
+public:
+    CCommandParamsDelete(const TFileEntry& aSourceEntry, TUint aSwitch) : iSourceEntry(aSourceEntry), iSwitch(aSwitch) {}
+    };
+
+class CCommandParamsDriveSnapShot : public CCommandParamsBase
+    {
+public:
+    TInt iSourceDriveLetter;
+    TInt iTargetDriveLetter;
+public:
+    CCommandParamsDriveSnapShot(TChar aSourceDriveLetter, TChar aTargetDriveLetter) : iSourceDriveLetter(aSourceDriveLetter), iTargetDriveLetter(aTargetDriveLetter) {}
+    };
+    
+class TCommand
+    {
+public:
+    TInt iCommandId;
+    CCommandParamsBase* iParameters;
+public:
+    TCommand(TInt aCommandId, CCommandParamsBase* aParameters) : iCommandId(aCommandId), iParameters(aParameters) {}
+    };
+
+typedef CArrayFixSeg<TCommand> CCommandArray;
+
+
+
+class CFileBrowserFileUtils : public CActive, public MAknServerAppExitObserver, public MMsvSessionObserver, public MProgressDialogCallback 
+	{
+private:
+    enum TState // active object states
+    	{
+    	EIdle = 0,              // do nothing
+    	};
+
+    enum TClipBoardMode
+    	{
+    	EClipBoardModeCut = 0,
+    	EClipBoardModeCopy
+    	};
+
+    enum TListingMode
+    	{
+    	ENormalEntries = 0,
+    	ESearchResults,
+    	EOpenFiles,
+    	EMsgAttachmentsInbox,
+    	EMsgAttachmentsDrafts,
+    	EMsgAttachmentsSentItems,
+    	EMsgAttachmentsOutbox
+    	};
+    	    	
+public:
+	static CFileBrowserFileUtils* NewL(CFileBrowserModel* aModel);
+	~CFileBrowserFileUtils();
+
+private:
+	CFileBrowserFileUtils(CFileBrowserModel* aModel);
+	void ConstructL();
+
+private: // from CActive
+	void RunL();
+    TInt RunError(TInt aError);
+	void DoCancel();
+
+private: // from MAknServerAppExitObserver
+    void HandleServerAppExit(TInt aReason);
+
+private: // from MMsvSessionObserver
+    void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3);
+
+private:  //from MProgressDialogCallback
+    void DialogDismissedL(TInt aButtonId);  
+    
+private: // command handling
+    void StartExecutingCommandsL(const TDesC& aLabel);
+    void ExecuteCommand();
+    void CheckForMoreCommandsL();
+    void AppendToCommandArrayL(TInt aCommand, CCommandParamsBase* aParameters);
+    TInt CommandArrayCount() const;
+    void ResetCommandArray();       
+
+private: // misc functionality
+    void GenerateDirectoryDataL();
+    void GetDriveListL();
+    void GetDirectoryListingL();
+    CAknIconArray* GenerateIconArrayL(TBool aGenerateNewBasicIconArray=EFalse);
+    void AppendGulIconToIconArrayL(CAknIconArray* aIconArray, const TDesC& aIconFile, TInt aIconId, TInt aMaskId, const TAknsItemID aAknsItemId);
+    TInt AppIconIdForUid(TUid aUid);
+    TUid GetAppUid(TFileEntry aFileEntry);
+    CDesCArray* GenerateItemTextArrayL();
+    TInt GetSelectedItemsOrCurrentItemL(CFileEntryList* aFileEntryList);
+    void DoCopyToFolderL(CFileEntryList* aEntryList, const TDesC& aTargetDir, TBool aDeleteSource);
+    TInt DoSearchFiles(const TDesC& aFileName, const TDesC& aPath);
+    TInt DoSearchFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath);
+    TInt DoFindFiles(const TDesC& aFileName, const TDesC& aPath);
+    TInt DoFindFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath);
+    void ReadAttachmentPathsRecursiveL(CMsvSession* aSession, CMsvEntry* aContext, CDesCArray* aAttPaths);
+    void WriteMessageEntryInfoRecursiveL(CMsvSession* aSession, CMsvEntry* aContext, RFile& aFile, TInt& aLevel);
+    void DoWriteMessageEntryInfoL(CMsvEntry* aContext, RFile& aFile, TInt aLevel);
+    void ConvertCharsToPwd(TDesC& aWord, TDes8& aConverted) const;
+    HBufC8* MessageDigestInHexLC(CMessageDigest* aMD, RFile& aFile);
+    void OpenCommonFileActionQueryL();
+    
+public: // public interfaces
+    TKeyResponse HandleOfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
+    void HandleSettingsChangeL();
+    void SetSortModeL(TInt aSortMode);
+    void SetOrderModeL(TInt aOrderMode);
+    void RefreshViewL();
+    TBool IsCurrentDriveReadOnly();
+    TBool IsCurrentItemDirectory();
+    void MoveUpOneLevelL();
+    void MoveDownToDirectoryL();
+    void ClipboardCutL();
+    void ClipboardCopyL();
+    void ClipboardPasteL();
+    void CopyToFolderL(TBool aMove=EFalse);
+    void DeleteL();
+    void TouchL();
+    void RenameL();
+    void SetAttributesL();
+    void SearchL();
+    void NewFileL();
+    void NewDirectoryL();
+    void SendToL();
+    void CompressL();
+    void DecompressL();
+    void PropertiesL();
+    void OpenWithApparcL();
+    void OpenWithDocHandlerL(TBool aEmbed);
+    void OpenWithFileServiceL();
+    TBool FileExists(const TDesC& aPath);
+    TInt LaunchProgramL(const TDesC& aPath);
+    void MemoryInfoPopupL();
+    void ShowFileCheckSumsL(TInt aType);
+    void SetErrRdL(TBool aEnable);
+    void EnableAvkonIconCacheL(TBool aEnable);
+    void SimulateLeaveL();
+    void SimulatePanicL();
+    void SimulateExceptionL();
+    void SetDebugMaskL();
+    void WriteAllAppsL();
+    void WriteAllFilesL();
+    void ListOpenFilesL();
+    void ListMessageAttachmentsL(TInt aType);
+    void WriteMsgStoreWalkL();
+    void FileEditorL(TInt aType);
+    void SetDrivePasswordL();
+    void UnlockDriveL();
+    void ClearDrivePasswordL();
+    void EraseDrivePasswordL();
+    void FormatDriveL(TBool aQuickFormat);
+    void CheckDiskL();
+    void ScanDriveL();
+    void SetDriveNameL();
+    void SetDriveVolumeLabelL();
+    void EjectDriveL();
+    void DismountFileSystemL();
+    void EraseMBRL();
+    void PartitionDriveL();
+    TBool DriveSnapShotPossible();
+    void DriveSnapShotL();
+    void EditDataTypesL();
+    void SecureBackupL(TInt aType);
+    
+public:    
+    inline TInt SortMode() { return iSortMode; }
+    inline TInt OrderMode() { return iOrderMode; }
+    inline CFileEntryList* ClipBoardList() { return iClipBoardList; }
+    inline TBool IsDriveListViewActive() { return iCurrentPath==KNullDesC && iListingMode==ENormalEntries; }
+    inline TBool IsNormalModeActive() { return iListingMode==ENormalEntries; }
+
+private:
+	TState                          iState;
+    CFileBrowserModel*              iModel;
+    CFileBrowserFileOps*            iFileOps;
+    CAknWaitDialog*                 iWaitDialog;
+    CAknProgressDialog*             iProgressDialog;
+    CEikProgressInfo*               iProgressInfo;
+    CCommandArray*                  iCommandArray;
+    TInt                            iCurrentEntry;
+    TInt                            iSucceededOperations;
+    TInt                            iFailedOperations;
+    TInt                            iLastError;
+    RTimer                          iTimer;
+	RFs                             iFs;
+	TListingMode                    iListingMode;
+	CFileMan*                       iFileMan;
+	TInt                            iViewMode;
+    TFileName                       iCurrentPath;
+    TInt                            iSortMode;
+    TInt                            iOrderMode;
+    TInt                            iClipboardMode;
+    CDesCArray*                     iClipboardPaths;
+    CDriveEntryList*                iDriveEntryList;
+    CFileEntryList*                 iFileEntryList;
+    CFileEntryList*                 iFindFileEntryList;
+    CAppIconList*                   iAppIconList;
+    TClipBoardMode                  iClipBoardMode;
+    CFileEntryList*                 iClipBoardList;
+    TSearchAttributes               iSearchAttributes;
+    CDocumentHandler*               iDocHandler;
+    CAknOpenFileService*		    iOpenFileService;
+    RFile                           iMsgStoreWalkFile;
+    TInt                            iPrevFolderIndex;
+    TFileName                       iPrevFolderName;
+    RTz                             iTz;
+    };
+
+
+// utility class for waiting for asychronous requests
+class CAsyncWaiter : public CActive
+	{
+public:
+	static CAsyncWaiter* NewL( TInt aPriority = EPriorityStandard );
+	static CAsyncWaiter* NewLC( TInt aPriority = EPriorityStandard );
+	~CAsyncWaiter();
+	
+	void StartAndWait();
+	TInt Result() const;
+	
+private:
+	CAsyncWaiter( TInt aPriority );
+	
+	// from CActive
+	void RunL();
+	void DoCancel();
+	
+private:
+    CActiveSchedulerWait iWait;
+	TInt iError;
+	};
+	
+	
+#endif
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/inc/FBModel.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,118 @@
+/*
+* 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 __FILEBROWSER_MODEL_H__
+#define __FILEBROWSER_MODEL_H__
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <apgcli.h>
+#include <CAknMemorySelectionSettingPage.h>
+
+
+// setting keys (do not change uids of existing keys to maintain compatibility to older versions!)
+const TUid KFBSettingDisplayMode                   = { 0x00 };
+const TUid KFBSettingFileViewMode                  = { 0x01 };
+const TUid KFBSettingShowSubDirectoryInfo          = { 0x02 };
+const TUid KFBSettingShowAssociatedIcons           = { 0x03 };
+const TUid KFBSettingRememberLastPath              = { 0x04 };
+const TUid KFBSettingLastPath                      = { 0x05 };
+
+const TUid KFBSettingSupportNetworkDrives          = { 0x06 };
+const TUid KFBSettingBypassPlatformSecurity        = { 0x07 };
+const TUid KFBSettingRemoveFileLocks               = { 0x08 };
+const TUid KFBSettingIgnoreProtectionsAtts         = { 0x09 };
+const TUid KFBSettingRemoveROMWriteProtection      = { 0x0A };
+
+const TUid KFBSettingFolderSelection               = { 0x0B };
+const TUid KFBSettingEnableToolbar                 = { 0x0C };
+
+
+// FORWARD DECLARATIONS
+class CFileBrowserFileListContainer;
+class CFileBrowserScreenCapture;
+class CFileBrowserFileUtils;
+class CEikonEnv;
+class CAknGlobalConfirmationQuery;
+class CDictionaryFileStore;
+
+// CLASS DECLARATIONS
+
+class TFileBrowserSettings
+    {
+public:
+    TInt                                        iDisplayMode;
+    TInt                                        iFileViewMode;
+    TBool                                       iShowSubDirectoryInfo;
+    TBool                                       iShowAssociatedIcons;
+    TBool                                       iRememberLastPath;
+    TFileName                                   iLastPath;
+    TBool                                       iRememberFolderSelection;
+    TBool                                       iEnableToolbar;
+
+    TBool                                       iSupportNetworkDrives;
+    TBool                                       iBypassPlatformSecurity;
+    TBool                                       iRemoveFileLocks;
+    TBool                                       iIgnoreProtectionsAtts;
+    TBool                                       iRemoveROMWriteProrection;
+    };
+
+
+class CFileBrowserModel : public CBase
+	{
+public:
+	static CFileBrowserModel* NewL();
+	~CFileBrowserModel();
+
+private:
+	CFileBrowserModel();
+	void ConstructL();
+    void LoadSettingsL();
+    void GetHashKeySelectionStatus();
+    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);
+
+public:
+    void ActivateModelL();
+    void DeActivateModelL();
+    void SaveSettingsL(TBool aNotifyModules=ETrue);
+    void SetFileListContainer(CFileBrowserFileListContainer* aFileListContainer);
+    TInt LaunchSettingsDialogL();
+    inline TFileBrowserSettings& Settings() { return iSettings; }
+    inline CEikonEnv* EikonEnv() { return iEnv; }
+    inline RApaLsSession& LsSession() { return iLs; }
+    inline CFileBrowserScreenCapture* ScreenCapture() { return iScreenCapture; }
+    inline CFileBrowserFileUtils* FileUtils() { return iFileUtils; }
+    inline CFileBrowserFileListContainer* FileListContainer() { return iFileListContainer; }
+    inline TBool IsHashKeySelectionInUse() { return iIsHashKeySelectionInUse; }
+
+private:
+    CFileBrowserFileListContainer*  iFileListContainer;
+    CFileBrowserScreenCapture*      iScreenCapture;
+    CFileBrowserFileUtils*          iFileUtils;
+    CEikonEnv*                      iEnv;
+    TFileBrowserSettings            iSettings;
+    RApaLsSession                   iLs;
+    TBool                           iIsHashKeySelectionInUse; 
+    };
+   
+
+#endif // __FILEBROWSER_MODEL_H__
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/inc/FBSettingViewDlg.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  
+*
+*/
+
+
+#ifndef FILEBROWSER_SETTINGVIEWDLG_H
+#define FILEBROWSER_SETTINGVIEWDLG_H
+
+//  INCLUDES
+#include <AknDialog.h>
+#include <eiklbo.h>
+#include <AknTabObserver.h> 
+#include <akntabgrp.h>
+
+//  FORWARD DECLARATIONS
+class CAknSettingItemArray;
+class CAknSettingStyleListBox;
+class CAknNavigationControlContainer;
+class CAknNavigationDecorator;
+class CAknTabGroup; 
+class TFileBrowserSettings;
+
+
+//  CLASS DEFINITIONS
+
+class CFileBrowserSettingViewDlg : public CAknDialog, public MEikListBoxObserver, public MAknTabObserver
+    {
+public:
+    static CFileBrowserSettingViewDlg* NewL(TFileBrowserSettings& aSettings);
+    virtual ~CFileBrowserSettingViewDlg();
+
+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
+    CFileBrowserSettingViewDlg(TFileBrowserSettings& aSettings);
+    void ConstructL();        
+
+private: // Data
+    CAknSettingItemArray*               iSettingItemArray;
+    CAknSettingStyleListBox*            iListBox;
+    CAknNavigationControlContainer*     iNaviContainer;
+    CAknNavigationDecorator*            iDecoratedTabGroup;
+    CAknTabGroup*                       iTabGroup;
+    TFileBrowserSettings&               iSettings;
+    };
+
+
+#endif
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/inc/FBStd.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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 FILEBROWSER_STD_H
+#define FILEBROWSER_STD_H
+
+#include <e32cmn.h>
+#include <e32std.h>
+#include <e32base.h>
+
+LOCAL_C inline TBool IsQHD(const TSize& aSize) { return ((aSize.iWidth==640 && aSize.iHeight==360) || (aSize.iWidth==360 && aSize.iHeight==640)); }
+
+#endif
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/inc/FBToolbar.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,127 @@
+/*
+* 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 FILEBROWSERTOOLBAR_H
+#define FILEBROWSERTOOLBAR_H
+
+
+#include <aknappui.h>
+#include <akntoolbarobserver.h>
+#include <coecobs.h>    // MCoeControlObserver
+
+#ifdef RD_CALEN_ENHANCED_MSK
+#include <BADESCA.H> // for CDesCArrayFlat 
+#endif
+
+//Forward declarations 
+class CAknToolbar;
+class CAknButton;
+class CCoeControl;
+class CAknView;
+class CFileBrowserModel;
+class CAknInfoPopupNoteController;
+
+class CFileBrowserToolbar : public CBase, 
+                            public MAknToolbarObserver,
+                            public MCoeControlObserver
+    {
+    public:
+        /**
+         * 1st phase constructor
+         */
+        static CFileBrowserToolbar* NewL();
+
+        /**
+         * 1st phase constructor
+         */
+        static CFileBrowserToolbar* NewLC();
+
+        /**
+         * Destructor
+         */
+        ~CFileBrowserToolbar();
+
+        /**
+         * 2nd phase constructor
+         */
+        void ConstructL();
+
+    public:
+        // from MAknToolbarObserver
+
+        /**
+         * From MAknToolbarObserver
+         */
+        void DynInitToolbarL( TInt aResourceId, CAknToolbar* aToolbar );
+
+        /**
+         * Handling toolbar key events
+         */
+        void OfferToolbarEventL( TInt aCommand );
+
+    public:
+        // from MCoeControlObserver
+
+        /**
+         * Handles toolbar event
+         */
+        void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType );
+    
+    public:
+        // New functions
+
+        /**
+         * Updates the toolbar state to default state
+         */
+        void ResetState();
+
+        /**
+         * Enables the display of toolbar
+         */
+        void ShowToolbarL();
+
+        /**
+         * Disables the display of toolbar
+         */
+        void HideToolbarL();
+
+        /**
+         * Returns whether the toolbar is shown or not
+         */
+        TBool IsShown();
+        
+        const TRect Rect() const;
+
+    private:
+        // New functions
+        CFileBrowserToolbar();
+        
+    // private:
+    public:
+        CFileBrowserModel* iModel;
+        CAknToolbar* iViewerToolbar;
+        TBool iShown;
+        TInt iFirstSelectionIndex;
+        TInt iLastSelectionIndex;
+        CAknInfoPopupNoteController* iInfoPopup;
+        CAknButton* iSelectbutton;
+    };
+
+#endif // FILEBROWSERTOOLBAR_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/inc/FBTraces.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,103 @@
+/*
+* 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 FILEBROWSER_TRACES_H
+#define FILEBROWSER_TRACES_H
+
+#include <e32def.h>
+
+
+// ---------------------------------------------------------------------------
+// You can change these logging method values below! Recompile the application to take changes effect.
+
+    // logging methods
+    // 0 = No logging
+    // 1 = Flogger
+    // 2 = RDebug
+    // 3 = Flogger and RDebug
+    
+    #ifndef _DEBUG
+        
+        // Logging method for UREL/release builds:
+        #define FILEBROWSER_LOGGING_METHOD  0
+
+    #else
+
+        // Logging method for UDEB/debug builds:
+        #define FILEBROWSER_LOGGING_METHOD  2
+
+    #endif    
+    
+
+
+// ---------------------------------------------------------------------------
+// Do not make any changes to lines below...
+
+    #if FILEBROWSER_LOGGING_METHOD == 1 || FILEBROWSER_LOGGING_METHOD == 3
+
+        #include <flogger.h>
+        _LIT(KLogFolder,"Launcher");
+        _LIT(KLogFile,"Launcher_Trace.txt");
+
+    #endif
+
+    #if FILEBROWSER_LOGGING_METHOD == 2 || FILEBROWSER_LOGGING_METHOD == 3
+
+        #include <e32debug.h>
+
+    #endif
+
+
+    #if FILEBROWSER_LOGGING_METHOD == 0
+    
+        #define LOGTEXT(AAA)
+        #define LOGSTRING(AAA)
+        #define LOGSTRING2(AAA,BBB)
+        #define LOGSTRING3(AAA,BBB,CCC)
+        #define LOGSTRING4(AAA,BBB,CCC,DDD)
+    
+    
+    #elif FILEBROWSER_LOGGING_METHOD == 1
+    
+        #define LOGTEXT(AAA)                RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend, AAA)
+        #define LOGSTRING(AAA)              do { _LIT(tempLogDes,AAA); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0)
+        #define LOGSTRING2(AAA,BBB)         do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB); } while (0)
+        #define LOGSTRING3(AAA,BBB,CCC)     do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB,CCC); } while (0)
+        #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB,CCC,DDD); } while (0)
+   
+    #elif FILEBROWSER_LOGGING_METHOD == 2
+    
+        #define LOGTEXT(AAA)                RDebug::Print(AAA)
+        #define LOGSTRING(AAA)              do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); } while (0)
+        #define LOGSTRING2(AAA,BBB)         do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); } while (0)
+        #define LOGSTRING3(AAA,BBB,CCC)     do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); } while (0)
+        #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); } while (0)
+    
+    #elif FILEBROWSER_LOGGING_METHOD == 3
+    
+        #define LOGTEXT(AAA)                RDebug::Print(AAA); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend, AAA)
+        #define LOGSTRING(AAA)              do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0)
+        #define LOGSTRING2(AAA,BBB)         do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB); } while (0)
+        #define LOGSTRING3(AAA,BBB,CCC)     do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB,CCC); } while (0)
+        #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB,CCC,DDD); } while (0)
+
+    #endif
+
+// ---------------------------------------------------------------------------
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/rom/filebrowser.iby	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,40 @@
+/*
+* 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 __FILEBROWSER_IBY__
+#define __FILEBROWSER_IBY__
+
+S60_APP_EXE(FileBrowser)
+S60_APP_AIF_ICONS(FileBrowser)
+S60_APP_RESOURCE(FileBrowser)
+SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,FileBrowser_ExtraIcons)
+#ifdef S60_UPGRADABLE_APP_REG_RSC
+  S60_UPGRADABLE_APP_REG_RSC(FileBrowser)
+#else
+  S60_APP_AIF_RSC(FileBrowser)
+#endif
+
+#ifndef FILEBROWSER_LITE
+file=ABI_DIR\BUILD_DIR\FileBrowserFileOpServer.exe      PROGRAMS_DIR\FileBrowserFileOpServer.exe
+file=ABI_DIR\BUILD_DIR\FileBrowserFileOpClient.dll      SHARED_LIB_DIR\FileBrowserFileOpClient.dll
+#endif
+
+data=ZPRIVATE\102828D6\backup_registration.xml        	private\102828D6\backup_registration.xml
+data=ZSYSTEM\Install\FileBrowser_stub.sis               \system\install\FileBrowser_stub.sis
+
+#endif // __FILEBROWSER_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/sis/FileBrowser_S60-30.pkg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,42 @@
+;
+; 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:
+
+
+; Language - standard language definitions
+&EN
+
+; Standard SIS file header
+#{"FileBrowser"},(0x102828D6),4,5,2,TYPE=SA
+
+; Supports S60 v 3.0
+[0x101F7961], 0, 0, 0, {"S60ProductID"}
+
+; Non-localised vendor name
+:"Nokia Corporation"
+
+; Localised vendor names
+%{"Nokia Corporation"}
+
+; normal stuff:
+"\epoc32\RELEASE\armv5\UREL\FileBrowser.exe"-"!:\sys\bin\FileBrowser.exe"
+"\epoc32\data\z\Resource\apps\FileBrowser_aif.mif"-"!:\Resource\Apps\FileBrowser_aif.mif"
+"\epoc32\data\z\Resource\apps\FileBrowser_ExtraIcons.mif"-"!:\Resource\Apps\FileBrowser_ExtraIcons.mif"
+"\epoc32\data\z\Resource\apps\FileBrowser.rsc"-"!:\Resource\Apps\FileBrowser.rsc"
+"\epoc32\data\z\PRIVATE\10003A3F\APPS\FileBrowser_reg.rsc"-"!:\private\10003a3f\import\apps\FileBrowser_reg.rsc"
+"..\group\backup_registration.xml"-"!:\private\102828D6\backup_registration.xml"
+
+; remove the following two entrys for lite version
+"\epoc32\RELEASE\armv5\UREL\FileBrowserFileOpServer.exe"-"!:\sys\bin\FileBrowserFileOpServer.exe"
+"\epoc32\RELEASE\armv5\UREL\FileBrowserFileOpClient.dll"-"!:\sys\bin\FileBrowserFileOpClient.dll"
Binary file filebrowser/sis/FileBrowser_S60-30.sis has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/sis/FileBrowser_S60-50.pkg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,42 @@
+;
+; 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:
+
+
+; Language - standard language definitions
+&EN
+
+; Standard SIS file header
+#{"FileBrowser"},(0x102828D6),4,5,2,TYPE=SA
+
+; Supports S60 v 5.0
+[0x1028315F], 0, 0, 0, {"S60ProductID"}
+
+; Non-localised vendor name
+:"Nokia Corporation"
+
+; Localised vendor names
+%{"Nokia Corporation"}
+
+; normal stuff:
+"\epoc32\RELEASE\armv5\UREL\FileBrowser.exe"-"!:\sys\bin\FileBrowser.exe"
+"\epoc32\data\z\Resource\apps\FileBrowser_aif.mif"-"!:\Resource\Apps\FileBrowser_aif.mif"
+"\epoc32\data\z\Resource\apps\FileBrowser_ExtraIcons.mif"-"!:\Resource\Apps\FileBrowser_ExtraIcons.mif"
+"\epoc32\data\z\Resource\apps\FileBrowser.rsc"-"!:\Resource\Apps\FileBrowser.rsc"
+"\epoc32\data\z\PRIVATE\10003A3F\APPS\FileBrowser_reg.rsc"-"!:\private\10003a3f\import\apps\FileBrowser_reg.rsc"
+"..\group\backup_registration.xml"-"!:\private\102828D6\backup_registration.xml"
+
+; remove the following two entrys for lite version
+"\epoc32\RELEASE\armv5\UREL\FileBrowserFileOpServer.exe"-"!:\sys\bin\FileBrowserFileOpServer.exe"
+"\epoc32\RELEASE\armv5\UREL\FileBrowserFileOpClient.dll"-"!:\sys\bin\FileBrowserFileOpClient.dll"
Binary file filebrowser/sis/FileBrowser_S60-50.sis has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/sis/FileBrowser_stub.pkg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,38 @@
+;
+; 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:
+;
+
+
+; Language - standard language definitions
+&EN
+
+; Standard SIS file header
+#{"FileBrowser"},(0x102828D6),1,0,0
+
+; Non-localised vendor name
+:"Nokia Corporation"
+
+; Localised vendor names
+%{"Nokia Corporation"}
+
+; normal stuff:
+""-"z:\sys\bin\FileBrowser.exe"
+""-"z:\Resource\Apps\FileBrowser_aif.mif"
+""-"z:\Resource\Apps\FileBrowser.rsc"
+""-"z:\private\10003a3f\import\apps\FileBrowser_reg.rsc"
+""-"z:\private\102828D6\backup_registration.xml"
+
+""-"z:\sys\bin\FileBrowserFileOpServer.exe"
+""-"z:\sys\bin\FileBrowserFileOpClient.dll"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/src/FBApp.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -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 "FBApp.h"
+#include "FBDocument.h"
+
+#include <eikstart.h>
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CFileBrowserApp::AppDllUid()
+// Returns application UID
+// ---------------------------------------------------------
+//
+TUid CFileBrowserApp::AppDllUid() const
+    {
+    return KUidFileBrowser;
+    }
+
+// ---------------------------------------------------------
+// CDictionaryStore* CFileBrowserApp::OpenIniFileLC(RFs& aFs) const
+// overrides CAknApplication::OpenIniFileLC to enable INI file support
+// ---------------------------------------------------------
+//
+CDictionaryStore* CFileBrowserApp::OpenIniFileLC(RFs& aFs) const
+{
+    return CEikApplication::OpenIniFileLC(aFs);
+}
+   
+// ---------------------------------------------------------
+// CFileBrowserApp::CreateDocumentL()
+// Creates CFileBrowserDocument object
+// ---------------------------------------------------------
+//
+CApaDocument* CFileBrowserApp::CreateDocumentL()
+    {
+    return CFileBrowserDocument::NewL( *this );
+    }
+
+// ================= OTHER EXPORTED FUNCTIONS ==============
+
+LOCAL_C CApaApplication* NewApplication()
+    {
+    return new CFileBrowserApp;
+    }
+
+
+GLDEF_C TInt E32Main()
+    {
+    return EikStart::RunApplication(NewApplication);
+    }
+   
+
+// End of File  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/src/FBAppUi.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  
+*
+*/
+
+
+// INCLUDE FILES
+#include "FBAppUi.h"
+#include "FBFileListView.h"
+#include "FB.hrh"
+#include "FBModel.h"
+#include "FBDocument.h"
+#include <filebrowser.rsg>
+
+#include <avkon.hrh>
+#include <AknQueryDialog.h>
+
+// ================= MEMBER FUNCTIONS =======================
+//
+// ----------------------------------------------------------
+// CFileBrowserAppUi::ConstructL()
+// ?implementation_description
+// ----------------------------------------------------------
+//
+void CFileBrowserAppUi::ConstructL()
+    {
+    BaseConstructL(EAknEnableSkin);
+
+    iModel = static_cast<CFileBrowserDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model();
+
+    CFileBrowserFileListView* fileListView = new (ELeave) CFileBrowserFileListView;
+    CleanupStack::PushL( fileListView );
+    fileListView->ConstructL();
+    AddViewL( fileListView );           // transfer ownership to CAknViewAppUi
+    CleanupStack::Pop();                // fileListView
+
+    SetDefaultViewL(*fileListView);
+
+    // notify the model that everything has been constructed
+    iModel->ActivateModelL();
+    }
+
+// ----------------------------------------------------
+// CFileBrowserAppUi::~CFileBrowserAppUi()
+// Destructor
+// Frees reserved resources
+// ----------------------------------------------------
+//
+CFileBrowserAppUi::~CFileBrowserAppUi()
+    {
+    // notify the model that app ui will be deconstructed
+    if (iModel)
+        TRAP_IGNORE(iModel->DeActivateModelL());
+    }
+
+// ------------------------------------------------------------------------------
+// CFileBrowserAppUi::::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 CFileBrowserAppUi::DynInitMenuPaneL(
+    TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
+    {
+    }
+
+// ----------------------------------------------------
+// CFileBrowserAppUi::HandleKeyEventL(
+//     const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
+// ?implementation_description
+// ----------------------------------------------------
+//
+TKeyResponse CFileBrowserAppUi::HandleKeyEventL(
+    const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
+    {
+    return EKeyWasNotConsumed;
+    }
+
+// ----------------------------------------------------
+// CFileBrowserAppUi::HandleCommandL(TInt aCommand)
+// ?implementation_description
+// ----------------------------------------------------
+//
+void CFileBrowserAppUi::HandleCommandL(TInt aCommand)
+    {
+    switch ( aCommand )
+        {
+        // a normal way to close an application
+        case EAknCmdExit:
+        case EEikCmdExit: 
+			{
+            Exit();
+			}
+            break;
+
+        default:
+            break;      
+        }
+    }
+
+// ----------------------------------------------------
+// CFileBrowserAppUi::HandleWsEventL(const TWsEvent& aEvent, CCoeControl* aDestination)
+// ?implementation_description
+// ----------------------------------------------------
+//
+void CFileBrowserAppUi::HandleWsEventL(const TWsEvent& aEvent, CCoeControl* aDestination)
+    {
+    //if (iModel->ScreenCapture()->HandleKeyCaptureEventsL(aEvent))
+      	CAknViewAppUi::HandleWsEventL(aEvent, aDestination);  //continue the event loop if needed
+    }
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/src/FBDocument.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,86 @@
+/*
+* 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 "FBDocument.h"
+#include "FBAppUi.h"
+#include "FBModel.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// constructor
+CFileBrowserDocument::CFileBrowserDocument(CEikApplication& aApp)
+: CAknDocument(aApp)    
+    {
+    }
+
+// destructor
+CFileBrowserDocument::~CFileBrowserDocument()
+    {
+    delete iModel;
+    }
+
+// EPOC default constructor can leave.
+void CFileBrowserDocument::ConstructL()
+    {
+    iModel = CFileBrowserModel::NewL();
+    }
+
+// Two-phased constructor.
+CFileBrowserDocument* CFileBrowserDocument::NewL(
+        CEikApplication& aApp)     // CFileBrowserApp reference
+    {
+    CFileBrowserDocument* self = new (ELeave) CFileBrowserDocument( aApp );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+    
+// ----------------------------------------------------
+// CFileBrowserDocument::CreateAppUiL()
+// constructs CFileBrowserAppUi
+// ----------------------------------------------------
+//
+CEikAppUi* CFileBrowserDocument::CreateAppUiL()
+    {
+    return new (ELeave) CFileBrowserAppUi;
+    }
+
+// ----------------------------------------------------
+// CFileBrowserDocument::OpenFileL
+// Overrides CAknDocument::OpenFileL to support document file
+// ----------------------------------------------------
+//
+CFileStore* CFileBrowserDocument::OpenFileL(TBool aDoOpen,const TDesC& aFilename,RFs& aFs)
+    {
+    return CEikDocument::OpenFileL(aDoOpen, aFilename, aFs);
+    }
+
+
+// ----------------------------------------------------
+
+CFileBrowserModel* CFileBrowserDocument::Model()
+    {
+    return iModel;
+    }
+
+// ----------------------------------------------------
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/src/FBFileDlgs.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,1115 @@
+/*
+* 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 "FBFileDlgs.h"
+#include "FBFileUtils.h"
+#include "FB.hrh"
+#include "FBStd.h"
+#include <filebrowser.rsg>
+
+#include <aknlistquerydialog.h>
+#include <AknIconArray.h>
+#include <aknlists.h>
+#include <eikbtgpc.h> 
+#include <akntitle.h>
+#include <AknPopupFieldText.h>
+#include <aknnotewrappers.h> 
+#include <eikfutil.h>
+#include <eikclbd.h> 
+
+const TInt KAttOn = 1;
+const TInt KAttOff = 2;
+const TInt KAttEnableRecursion = 0;
+const TInt KAttDisableRecursion = 1;
+const TInt64 KAlmostaDayInMicroSeconds = 86399999999;
+ 
+
+// ===================================== MEMBER FUNCTIONS =====================================
+
+CFileBrowserDestinationFolderSelectionDlg* CFileBrowserDestinationFolderSelectionDlg::NewL(
+    TDes& aReturnPath, CDriveEntryList* aDriveEntryList, CAknIconArray* aIconArray)
+    {
+    CFileBrowserDestinationFolderSelectionDlg* self = new(ELeave) CFileBrowserDestinationFolderSelectionDlg(aReturnPath, aIconArray);
+    CleanupStack::PushL(self);
+    self->ConstructL(aDriveEntryList);
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CFileBrowserDestinationFolderSelectionDlg::~CFileBrowserDestinationFolderSelectionDlg()
+    {
+    delete iFileEntryList;
+    delete iDriveEntryList;
+    
+    iFs.Close();
+
+    iEikonEnv->InfoMsgCancel();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CFileBrowserDestinationFolderSelectionDlg::CFileBrowserDestinationFolderSelectionDlg(
+    TDes& aReturnPath, CAknIconArray* aIconArray) : CAknListQueryDialog(&iSelectedIndex),
+    iReturnPath(aReturnPath), iIconArray(aIconArray)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserDestinationFolderSelectionDlg::ConstructL(CDriveEntryList* aDriveEntryList)
+    {
+    User::LeaveIfError( iFs.Connect() );
+    iDriveEntryList = new(ELeave) CDriveEntryList(8);
+    iFileEntryList = new(ELeave) CFileEntryList(32);
+    iCurrentPath = KNullDesC;
+    
+    //iIsDragging = EFalse;
+    //EnableDragEvents();
+    
+    // get only writeable drives
+    for (TInt i=0; i<aDriveEntryList->Count(); i++)
+        {
+        TDriveEntry driveEntry = aDriveEntryList->At(i);
+        
+        if (driveEntry.iVolumeInfo.iDrive.iMediaAtt != KMediaAttWriteProtected && driveEntry.iVolumeInfo.iDrive.iMediaAtt != KMediaAttLocked && driveEntry.iVolumeInfo.iDrive.iDriveAtt != KDriveAbsent)
+            {
+            iDriveEntryList->AppendL(driveEntry);
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+/*
+void CFileBrowserDestinationFolderSelectionDlg::HandlePointerEventL(const TPointerEvent &aPointerEvent)
+    {
+    // detect direction of dragging by comparing the start and finish points
+    
+    if (aPointerEvent.iType == TPointerEvent::EButton1Down)
+        {
+        iDragStartPoint = aPointerEvent.iPosition;
+        iIsDragging = EFalse;
+        }
+    else if (aPointerEvent.iType == TPointerEvent::EDrag)
+        {
+        iIsDragging = ETrue;
+        
+        return;
+        }
+    else if (aPointerEvent.iType == TPointerEvent::EButton1Up)
+        {
+        if (iIsDragging)
+            {
+            const TInt KDelta = iDragStartPoint.iX - aPointerEvent.iPosition.iX;
+            const TInt KThreshold = 30;
+            
+            if (KDelta < -KThreshold) // dragging to right
+                {
+                // "emulate" right key press
+                
+                TKeyEvent keyEvent;
+                keyEvent.iCode = EKeyRightArrow;
+                keyEvent.iModifiers = 0;
+                
+                TEventCode type = EEventKey;
+        
+                OfferKeyEventL(keyEvent, type);
+                
+                return;
+                }
+            else if (KDelta > KThreshold) // dragging to left
+                {
+                // "emulate" left key press
+                
+                TKeyEvent keyEvent;
+                keyEvent.iCode = EKeyLeftArrow;
+                keyEvent.iModifiers = 0;
+                
+                TEventCode type = EEventKey;
+        
+                OfferKeyEventL(keyEvent, type);
+                
+                return;
+                }            
+            }
+        iIsDragging = EFalse;
+        }
+    else
+        {
+        iIsDragging = EFalse;        
+        }
+
+    CAknListQueryDialog::HandlePointerEventL(aPointerEvent);    
+    }
+*/
+       
+// --------------------------------------------------------------------------------------------
+
+TKeyResponse CFileBrowserDestinationFolderSelectionDlg::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
+    {
+    if(aType != EEventKey)
+        return EKeyWasNotConsumed;
+    
+    if (aKeyEvent.iCode == EKeyLeftArrow && !IsDriveListViewActive())
+        {
+        MoveUpOneLevelL(); 
+        return EKeyWasConsumed;    
+        }
+    else if (aKeyEvent.iCode == EKeyRightArrow && ((ListBox()->CurrentItemIndex() > 0 && !IsDriveListViewActive()) || IsDriveListViewActive()))
+        {
+        MoveDownToDirectoryL();    
+        return EKeyWasConsumed;    
+        }
+    else if (aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter)    
+        {
+        if (IsDriveListViewActive())
+            {
+            MoveDownToDirectoryL();    
+            return EKeyWasConsumed;    
+            }            
+        else if (ListBox()->CurrentItemIndex() == 0)
+            {
+            TryExitL(EAknSoftkeyOk);    
+            return EKeyWasConsumed;    
+            }
+        else if (ListBox()->CurrentItemIndex() > 0)
+            {
+            MoveDownToDirectoryL();    
+            return EKeyWasConsumed;    
+            }            
+        }
+
+    TKeyResponse result = CAknDialog::OfferKeyEventL(aKeyEvent, aType);
+    
+    // update LSK label
+    if (!IsDriveListViewActive())
+        {
+        if (ListBox()->CurrentItemIndex() == 0)
+            {
+            ButtonGroupContainer().SetCommandL(0, EAknSoftkeyOk, iLSKActionText);
+            ButtonGroupContainer().DrawNow();                
+            }
+        else
+            {
+            ButtonGroupContainer().SetCommandL(0, EAknSoftkeyOk, _L("Open dir"));
+            ButtonGroupContainer().DrawNow();                
+            }
+        }
+
+    return result;    
+    }    
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserDestinationFolderSelectionDlg::PreLayoutDynInitL()
+    {
+    CAknListQueryDialog::PreLayoutDynInitL();
+
+    static_cast<CEikFormattedCellListBox*>(ListBox())->ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserDestinationFolderSelectionDlg::PostLayoutDynInitL()
+    {
+    CAknListQueryDialog::PostLayoutDynInitL();
+    
+    SetIconArrayL(static_cast<CArrayPtr<CGulIcon>*>(iIconArray)); 
+    
+    RefreshViewL();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TBool CFileBrowserDestinationFolderSelectionDlg::OkToExitL(TInt aButtonId)
+    {
+    if (aButtonId == GetLeftCBAShortKeyPress())
+        {
+        if (IsDriveListViewActive())
+            {
+            MoveDownToDirectoryL();    
+            return EFalse;    
+            }            
+        else if (ListBox()->CurrentItemIndex() == 0)
+            {
+            // close the dialog
+            iReturnPath = iCurrentPath;    
+            return ETrue;    
+            }
+        else if (ListBox()->CurrentItemIndex() > 0)
+            {
+            MoveDownToDirectoryL();    
+            return EFalse;    
+            } 
+        else
+            return EFalse;
+        }    
+    else if (aButtonId == GetRightCBAShortKeyPress())
+        {
+        return ETrue;
+        }
+    else
+        {
+        return EFalse;
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserDestinationFolderSelectionDlg::MoveUpOneLevelL()
+    {
+    if (iCurrentPath.Length() <= 3)
+        {
+        // move to drive list view is the current path is already short enough
+        iCurrentPath = KNullDesC;
+        }
+    else
+        {
+        // move one directory up
+        TInt marker(iCurrentPath.Length());
+        
+        // find second last dir marker
+        for (TInt i=iCurrentPath.Length()-2; i>=0; i--)
+            {
+            if (iCurrentPath[i] == '\\')
+                {
+                marker = i;
+                break;
+                }
+                
+            }
+        iCurrentPath = iCurrentPath.LeftTPtr(marker+1);
+        }    
+
+    // update view
+    RefreshViewL();        
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserDestinationFolderSelectionDlg::MoveDownToDirectoryL()
+    {
+    TInt index = ListBox()->CurrentItemIndex();
+    
+    if (index >= 0)
+        {
+        if (IsDriveListViewActive())
+            {
+            // currently in a drive list view, move to root of selected drive
+            if (iDriveEntryList->Count() > index)
+                {
+                TDriveEntry driveEntry = iDriveEntryList->At(index);
+                
+                iCurrentPath.Append(driveEntry.iLetter);    
+                iCurrentPath.Append(_L(":\\"));
+                }
+            }
+        else
+            {
+            // this needed because we have an extra item in the listbox
+            index--;
+
+            // append the new directory
+            if (iFileEntryList->Count() > index)
+                {
+                TFileEntry fileEntry = iFileEntryList->At(index);
+                
+                if (fileEntry.iEntry.IsDir())
+                    {
+                    iCurrentPath.Append(fileEntry.iEntry.iName);
+                    iCurrentPath.Append(_L("\\"));
+                    }
+                }
+            }
+                   
+        // update view
+        RefreshViewL();
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserDestinationFolderSelectionDlg::RefreshViewL()
+    {
+    CDesCArray* textArray = new(ELeave) CDesCArrayFlat(16);
+    
+    if (IsDriveListViewActive())
+        {
+        _LIT(KSimpleDriveEntry, "%d\t%c: <%S>\t\t");
+
+        for (TInt i=0; i<iDriveEntryList->Count(); i++)
+            {
+            TFileName textEntry;
+            TDriveEntry driveEntry = iDriveEntryList->At(i);
+            
+            textEntry.Format(KSimpleDriveEntry, driveEntry.iIconId, TUint(driveEntry.iLetter), &driveEntry.iMediaTypeDesc);
+            
+            textArray->AppendL(textEntry);
+            }
+
+        // set default LSK label
+        ButtonGroupContainer().SetCommandL(0, EAknSoftkeyOk, _L("Open drive"));
+        ButtonGroupContainer().DrawNow();
+        }
+    
+    else
+        {
+        // first get the directory list
+        iFileEntryList->Reset();
+            
+        CDir* dir = NULL;
+        if (iFs.GetDir(iCurrentPath, KEntryAttDir|KEntryAttMatchMask, ESortByName | EAscending | EDirsFirst, dir) == KErrNone)
+            {
+            CleanupStack::PushL(dir);
+            
+            for (TInt i=0; i<dir->Count(); i++)
+                {
+                TFileEntry fileEntry;
+                fileEntry.iPath = iCurrentPath;
+                fileEntry.iEntry = (*dir)[i];
+                fileEntry.iDirEntries = KErrNotFound;
+                fileEntry.iIconId = EFixedIconEmpty;
+                
+                // check for directory entries
+                if (fileEntry.iEntry.IsDir())
+                    {
+                    fileEntry.iIconId = EFixedIconFolder;
+                    
+                    TFileName subPath = fileEntry.iPath;
+                    subPath.Append(fileEntry.iEntry.iName);
+                    subPath.Append(_L("\\"));
+
+                    // check if any sub directories                
+                    CDir* subDir = NULL;
+                    if (iFs.GetDir(subPath, KEntryAttDir|KEntryAttMatchMask, ESortNone | EDirsFirst, subDir) == KErrNone)
+                        {
+                        fileEntry.iDirEntries = subDir->Count();
+
+                        for (TInt j=0; j<subDir->Count(); j++)
+                            {
+                            TEntry entry = (*subDir)[j];
+
+                            if (entry.IsDir())
+                                {
+                                fileEntry.iIconId = EFixedIconFolderSub;
+                                break;    
+                                }
+                            }
+
+                        delete subDir;    
+                        }
+                    }
+
+                iFileEntryList->AppendL(fileEntry);
+                }
+            
+            CleanupStack::PopAndDestroy(); //dir    
+            }        
+        
+         
+        _LIT(KSimpleFileEntry, "%d\t%S\t\t");
+
+        
+        // append current folder item
+        TParse nameParser;
+        TInt err = nameParser.SetNoWild(iCurrentPath.LeftTPtr(iCurrentPath.Length()-1), NULL, NULL);
+        TFileName currentFolderName = nameParser.Name();
+        if (currentFolderName == KNullDesC)
+            currentFolderName.Copy(_L("[root level]"));
+
+        TFileName currentDirTextEntry;
+        currentDirTextEntry.Format(KSimpleFileEntry, EFixedIconFolderCurrent, &currentFolderName);
+        textArray->AppendL(currentDirTextEntry);
+
+
+        for (TInt i=0; i<iFileEntryList->Count(); i++)
+            {
+            TFileName textEntry;
+            TFileEntry fileEntry = iFileEntryList->At(i);
+            
+            textEntry.Format(KSimpleFileEntry, fileEntry.iIconId, &fileEntry.iEntry.iName);
+            
+            textArray->AppendL(textEntry);
+            }
+
+         // set default LSK label
+        ButtonGroupContainer().SetCommandL(0, EAknSoftkeyOk, iLSKActionText);
+        ButtonGroupContainer().DrawNow();
+        }
+
+    if (iCurrentPath == KNullDesC)
+        iEikonEnv->InfoMsgWithDuration(_L("<- up dir  down dir ->"), TTimeIntervalMicroSeconds32(KMaxTInt));
+    else
+        iEikonEnv->InfoMsgWithDuration(iCurrentPath, TTimeIntervalMicroSeconds32(KMaxTInt));
+   
+    SetItemTextArray(textArray);
+    SetOwnershipType(ELbmOwnsItemArray);
+    ListBox()->HandleItemAdditionL();
+    Layout();
+    ListBox()->SetCurrentItemIndex(0);
+    DrawNow();
+    }
+
+// --------------------------------------------------------------------------------------------
+    
+TBool CFileBrowserDestinationFolderSelectionDlg::RunCopyDlgLD()
+    {
+    iLSKActionText.Copy(_L("Copy"));
+    return ExecuteLD(R_COPY_TO_FOLDER_SELECTION_QUERY); 
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TBool CFileBrowserDestinationFolderSelectionDlg::RunMoveDlgLD()
+    {
+    iLSKActionText.Copy(_L("Move"));
+    return ExecuteLD(R_MOVE_TO_FOLDER_SELECTION_QUERY); 
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CAknQueryDialog::GetLeftCBAShortKeyPress()
+    {
+    return TInt16(0xffff & TInt16(ButtonGroupContainer().ButtonGroup()->CommandId(0)));
+    }
+
+// --------------------------------------------------------------------------------------------
+  
+TInt CAknQueryDialog::GetRightCBAShortKeyPress()
+    {
+    return TInt16(0xffff & TInt16(ButtonGroupContainer().ButtonGroup()->CommandId(2)));
+    }
+       
+        
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+
+CFileBrowserAttributeEditorDlg* CFileBrowserAttributeEditorDlg::NewL(TUint& aSetAttMask, TUint& aClearAttMask, TBool& aRecurse)
+    {
+    CFileBrowserAttributeEditorDlg* self = new(ELeave) CFileBrowserAttributeEditorDlg(aSetAttMask, aClearAttMask, aRecurse);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CFileBrowserAttributeEditorDlg::~CFileBrowserAttributeEditorDlg()
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CFileBrowserAttributeEditorDlg::CFileBrowserAttributeEditorDlg(TUint& aSetAttMask, TUint& aClearAttMask, TBool& aRecurse) :
+    iSetAttMask(aSetAttMask), iClearAttMask(aClearAttMask), iRecurse(aRecurse)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserAttributeEditorDlg::ConstructL()
+    {
+    CAknForm::ConstructL();
+
+    // set title text
+    CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
+    CAknTitlePane* tp = static_cast<CAknTitlePane*>( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
+    tp->SetTextL( _L("Set attributes") );
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserAttributeEditorDlg::PreLayoutDynInitL()
+    {
+    CAknForm::PreLayoutDynInitL();
+    
+    // set default LSK label
+    ButtonGroupContainer().SetCommandL(0, EAknSoftkeyOk, _L("Save"));
+
+    // load values
+    CAknPopupFieldText* archivePopup = static_cast<CAknPopupFieldText*>(Control(EFileBrowserAttributeEditorSetArchive));
+    CAknPopupFieldText* hiddenPopup = static_cast<CAknPopupFieldText*>(Control(EFileBrowserAttributeEditorSetHidden));
+    CAknPopupFieldText* readOnlyPopup = static_cast<CAknPopupFieldText*>(Control(EFileBrowserAttributeEditorSetReadOnly));
+    CAknPopupFieldText* systemPopup = static_cast<CAknPopupFieldText*>(Control(EFileBrowserAttributeEditorSetSystem));
+    CAknPopupFieldText* recursePopup = static_cast<CAknPopupFieldText*>(Control(EFileBrowserAttributeEditorSetRecurse));
+    
+    if (iSetAttMask & KEntryAttArchive)
+        archivePopup->SetCurrentValueIndex(KAttOn);
+    else if (iClearAttMask & KEntryAttArchive)
+        archivePopup->SetCurrentValueIndex(KAttOff);
+    
+    if (iSetAttMask & KEntryAttHidden)
+        hiddenPopup->SetCurrentValueIndex(KAttOn);
+    else if (iClearAttMask & KEntryAttHidden)
+        hiddenPopup->SetCurrentValueIndex(KAttOff);
+    
+    if (iSetAttMask & KEntryAttReadOnly)
+        readOnlyPopup->SetCurrentValueIndex(KAttOn);
+    else if (iClearAttMask & KEntryAttReadOnly)
+        readOnlyPopup->SetCurrentValueIndex(KAttOff);
+    
+    if (iSetAttMask & KEntryAttSystem)
+        systemPopup->SetCurrentValueIndex(KAttOn);
+    else if (iClearAttMask & KEntryAttSystem)
+        systemPopup->SetCurrentValueIndex(KAttOff);
+    
+    if (iRecurse)
+        recursePopup->SetCurrentValueIndex(KAttEnableRecursion);
+    else
+        recursePopup->SetCurrentValueIndex(KAttDisableRecursion);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TBool CFileBrowserAttributeEditorDlg::OkToExitL(TInt aButtonId)
+    {
+    if (aButtonId == EAknSoftkeyOk)
+        {
+        // save changes
+        CAknPopupFieldText* archivePopup = static_cast<CAknPopupFieldText*>(Control(EFileBrowserAttributeEditorSetArchive));
+        CAknPopupFieldText* hiddenPopup = static_cast<CAknPopupFieldText*>(Control(EFileBrowserAttributeEditorSetHidden));
+        CAknPopupFieldText* readOnlyPopup = static_cast<CAknPopupFieldText*>(Control(EFileBrowserAttributeEditorSetReadOnly));
+        CAknPopupFieldText* systemPopup = static_cast<CAknPopupFieldText*>(Control(EFileBrowserAttributeEditorSetSystem));
+        CAknPopupFieldText* recursePopup = static_cast<CAknPopupFieldText*>(Control(EFileBrowserAttributeEditorSetRecurse));
+
+        iSetAttMask = 0;
+        iClearAttMask = 0;
+        
+        if (archivePopup->CurrentValueIndex() == KAttOn)
+            iSetAttMask |= KEntryAttArchive;
+        else if (archivePopup->CurrentValueIndex() == KAttOff)
+            iClearAttMask |= KEntryAttArchive;
+        
+        if (hiddenPopup->CurrentValueIndex() == KAttOn)
+            iSetAttMask |= KEntryAttHidden;
+        else if (hiddenPopup->CurrentValueIndex() == KAttOff)
+            iClearAttMask |= KEntryAttHidden;
+        
+        if (readOnlyPopup->CurrentValueIndex() == KAttOn)
+            iSetAttMask |= KEntryAttReadOnly;
+        else if (readOnlyPopup->CurrentValueIndex() == KAttOff)
+            iClearAttMask |= KEntryAttReadOnly;
+                
+        if (systemPopup->CurrentValueIndex() == KAttOn)
+            iSetAttMask |= KEntryAttSystem;
+        else if (systemPopup->CurrentValueIndex() == KAttOff)
+            iClearAttMask |= KEntryAttSystem;
+
+        if (recursePopup->CurrentValueIndex() == KAttEnableRecursion)
+            iRecurse = ETrue;
+        else if (recursePopup->CurrentValueIndex() == KAttDisableRecursion)
+            iRecurse = EFalse;
+        }
+    
+    return ETrue;
+    }       
+// --------------------------------------------------------------------------------------------
+
+TBool CFileBrowserAttributeEditorDlg::RunEditorLD()
+    {
+    return ExecuteLD(R_ATTRIBUTE_EDITOR_FORM_DIALOG);
+    }
+      
+       
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+
+CFileBrowserSearchQueryDlg* CFileBrowserSearchQueryDlg::NewL(TSearchAttributes& aSearchAttributes)
+    {
+    CFileBrowserSearchQueryDlg* self = new(ELeave) CFileBrowserSearchQueryDlg(aSearchAttributes);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CFileBrowserSearchQueryDlg::~CFileBrowserSearchQueryDlg()
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CFileBrowserSearchQueryDlg::CFileBrowserSearchQueryDlg(TSearchAttributes& aSearchAttributes) :
+    iSearchAttributes(aSearchAttributes)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserSearchQueryDlg::ConstructL()
+    {
+    CAknForm::ConstructL();
+
+    // set title text
+    CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
+    CAknTitlePane* tp = static_cast<CAknTitlePane*>( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
+    tp->SetTextL( _L("Search") );
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserSearchQueryDlg::PreLayoutDynInitL()
+    {
+    CAknForm::PreLayoutDynInitL();
+    
+    // set default LSK label
+    ButtonGroupContainer().SetCommandL(0, EAknSoftkeyOk, _L("Search"));
+
+    // load values
+    CEikEdwin* searchDir = static_cast<CEikEdwin*>(Control(EFileBrowserSearchQuerySearchDir));
+    CEikEdwin* wildCards = static_cast<CEikEdwin*>(Control(EFileBrowserSearchQueryWildCards));
+    CEikEdwin* textInFile = static_cast<CEikEdwin*>(Control(EFileBrowserSearchQueryTextInFile));
+    CEikNumberEditor* minSize = static_cast<CEikNumberEditor*>(Control(EFileBrowserSearchQueryMinSize));
+    CEikNumberEditor* maxSize = static_cast<CEikNumberEditor*>(Control(EFileBrowserSearchQueryMaxSize));
+    CEikDateEditor* minDate = static_cast<CEikDateEditor*>(Control(EFileBrowserSearchQueryMinDate));
+    CEikDateEditor* maxDate = static_cast<CEikDateEditor*>(Control(EFileBrowserSearchQueryMaxDate));
+    CAknPopupFieldText* recurse = static_cast<CAknPopupFieldText*>(Control(EFileBrowserSearchQueryRecurse));
+
+    searchDir->SetTextL(&iSearchAttributes.iSearchDir);
+    wildCards->SetTextL(&iSearchAttributes.iWildCards);
+    textInFile->SetTextL(&iSearchAttributes.iTextInFile);
+    minSize->SetNumber(iSearchAttributes.iMinSize);
+    maxSize->SetNumber(iSearchAttributes.iMaxSize);
+    minDate->SetDate(iSearchAttributes.iMinDate);
+    maxDate->SetDate(iSearchAttributes.iMaxDate);
+    recurse->SetCurrentValueIndex(iSearchAttributes.iRecurse);
+    }
+// --------------------------------------------------------------------------------------------
+
+TBool CFileBrowserSearchQueryDlg::OkToExitL(TInt aButtonId)
+    {
+    if (aButtonId == EAknSoftkeyOk)
+        {
+        // save changes
+        CEikEdwin* searchDir = static_cast<CEikEdwin*>(Control(EFileBrowserSearchQuerySearchDir));
+        CEikEdwin* wildCards = static_cast<CEikEdwin*>(Control(EFileBrowserSearchQueryWildCards));
+        CEikEdwin* textInFile = static_cast<CEikEdwin*>(Control(EFileBrowserSearchQueryTextInFile));
+        CEikNumberEditor* minSize = static_cast<CEikNumberEditor*>(Control(EFileBrowserSearchQueryMinSize));
+        CEikNumberEditor* maxSize = static_cast<CEikNumberEditor*>(Control(EFileBrowserSearchQueryMaxSize));
+        CEikDateEditor* minDate = static_cast<CEikDateEditor*>(Control(EFileBrowserSearchQueryMinDate));
+        CEikDateEditor* maxDate = static_cast<CEikDateEditor*>(Control(EFileBrowserSearchQueryMaxDate));
+        CAknPopupFieldText* recurse = static_cast<CAknPopupFieldText*>(Control(EFileBrowserSearchQueryRecurse));
+
+        // get the current value of search dir and make sure it has a trailing backslash
+        TFileName searchDirBuf;
+        searchDir->GetText(searchDirBuf);
+        if (searchDirBuf.Length() && searchDirBuf[searchDirBuf.Length()-1] != '\\')
+            searchDirBuf.Append('\\');
+
+        // check that the path is valid
+        if (searchDirBuf.Length() && !EikFileUtils::PathExists(searchDirBuf))
+            {
+            CAknInformationNote* note = new(ELeave) CAknInformationNote;
+            note->ExecuteLD(_L("Given search directory does not exists"));
+            
+            return EFalse;
+            }
+
+        iSearchAttributes.iSearchDir = searchDirBuf; 
+        wildCards->GetText(iSearchAttributes.iWildCards);
+        textInFile->GetText(iSearchAttributes.iTextInFile);
+        iSearchAttributes.iMinSize = minSize->Number();
+        iSearchAttributes.iMaxSize = maxSize->Number();
+        iSearchAttributes.iMinDate = minDate->Date();
+        iSearchAttributes.iMaxDate = maxDate->Date();
+        // Adjust the MaxDate to the end of the day:
+        iSearchAttributes.iMaxDate += TTimeIntervalMicroSeconds( KAlmostaDayInMicroSeconds );
+        iSearchAttributes.iRecurse = recurse->CurrentValueIndex();
+        }
+    
+    return ETrue;
+    }       
+// --------------------------------------------------------------------------------------------
+
+TBool CFileBrowserSearchQueryDlg::RunQueryLD()
+    {
+    return ExecuteLD(R_SEARCH_QUERY_FORM_DIALOG);
+    }
+  
+       
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+
+CFileBrowserDataTypesDlg* CFileBrowserDataTypesDlg::NewL()
+    {
+    CFileBrowserDataTypesDlg* self = new(ELeave) CFileBrowserDataTypesDlg();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CFileBrowserDataTypesDlg::~CFileBrowserDataTypesDlg()
+    {
+    delete iDTArray;
+    
+    iLs.Close();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CFileBrowserDataTypesDlg::CFileBrowserDataTypesDlg()
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserDataTypesDlg::ConstructL()
+    {
+    // construct a menu bar
+    CAknDialog::ConstructL(R_FILEBROWSER_DATA_TYPES_MENUBAR);
+
+    // set title text
+    CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
+    CAknTitlePane* tp = static_cast<CAknTitlePane*>( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
+    tp->SetTextL( _L("Data types") );
+    
+    User::LeaveIfError(iLs.Connect());
+    
+    iDTArray = new(ELeave) CDataTypeArray(32);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserDataTypesDlg::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
+    {
+    switch (aEventType)
+        {
+        case EEventEnterKeyPressed:
+        case EEventItemDoubleClicked:
+            // reserved for future extensions;
+            break;
+        default:
+            break;
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserDataTypesDlg::ProcessCommandL(TInt aCommandId)
+    {
+    CAknDialog::ProcessCommandL(aCommandId);
+
+    switch (aCommandId)
+        {
+        case EFileBrowserCmdDataTypesChangeMapping:
+            ChangeMappingL();
+            break;
+        case EFileBrowserCmdDataTypesSetDefaultMapping:
+            SetDefaultMappingL();
+            break;
+        case EFileBrowserCmdDataTypesRefresh:
+            GetDataTypesL();
+            break;
+        case EFileBrowserCmdDataTypesExit:
+            TryExitL(EAknCmdExit);
+            break;
+        default:
+            break;
+        }
+    } 
+    
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserDataTypesDlg::PreLayoutDynInitL()
+    {
+    CAknDialog::PreLayoutDynInitL();
+
+    iListBox = static_cast<CAknSingleGraphicStyleListBox*>( Control(EFileBrowserDataTypesList) );
+    iListBox->SetContainerWindowL(*this);
+    iListBox->View()->SetListEmptyTextL(_L("No data types"));
+
+    iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue);
+        
+    iListBox->CreateScrollBarFrameL(ETrue);
+    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
+    iListBox->SetListBoxObserver(this);
+    
+    iListBox->Model()->SetOwnershipType(ELbmOwnsItemArray);
+
+    GetDataTypesL(); 
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserDataTypesDlg::GetDataTypesL()
+    {
+    // get an instance of the listbox's item array
+	MDesCArray* tempArray = iListBox->Model()->ItemTextArray();
+	CDesCArray* listBoxArray = (CDesCArray*)tempArray;
+	listBoxArray->Reset();
+	
+	// create an icon array
+	CAknIconArray* iconArray = new(ELeave) CAknIconArray(32);
+    CleanupStack::PushL(iconArray);
+
+    // get data types
+    iDTArray->Reset();
+    User::LeaveIfError(iLs.GetSupportedDataTypesL(*iDTArray));
+    
+    // sort the array
+    TKeyArrayFix key(0, ECmpFolded8);  // iDataType is located in offset 0 and contain 8-bit descriptor
+    iDTArray->Sort(key);
+
+    
+    // loop each data type
+    for (TInt i=0; i<iDTArray->Count(); i++)
+        {
+        TDataType& dt = iDTArray->At(i);
+        
+        // get app uid which handles this data type
+        TUid appUid;
+        TInt err = iLs.AppForDataType(dt, appUid);
+        
+        // generate icon which is the app icon which handles this mime type
+        CFbsBitmap* bitmap = NULL;
+        CFbsBitmap* mask = NULL;
+        CGulIcon* appIcon = NULL;
+        
+        TRAPD(err2, 
+            AknsUtils::CreateAppIconLC(AknsUtils::SkinInstance(), appUid, EAknsAppIconTypeList, bitmap, mask);
+            appIcon = CGulIcon::NewL(bitmap, mask);
+            CleanupStack::Pop(2); //bitmap, mask
+            );
+                         
+        // append to the icon array    
+        appIcon->SetBitmapsOwnedExternally(EFalse);
+        iconArray->AppendL(appIcon);
+        
+        TFileName entry;
+        entry.AppendNum(i);
+        entry.Append(_L("\t"));
+        entry.Append(dt.Des());
+        entry.Append(_L("  <<"));
+        
+
+        // get caption of the handling app
+        TFileName appCaption;
+        
+        if (err || err2 || appUid == KNullUid)
+            entry.Append(_L("none"));
+        else
+            {
+            TApaAppInfo appInfo;
+            
+            if (iLs.GetAppInfo(appInfo, appUid) == KErrNone)
+                entry.Append(appInfo.iCaption);
+            else
+                entry.Append(_L("none"));
+            }
+        
+        entry.Append(_L(">>"));
+
+        listBoxArray->AppendL( entry );
+        }
+
+
+    // clear any previous icon array
+    CAknIconArray* oldIconArray = static_cast<CAknIconArray*>(iListBox->ItemDrawer()->ColumnData()->IconArray());
+    if (oldIconArray)
+        delete oldIconArray;
+
+    
+    CleanupStack::Pop(); //iconArray
+
+    // updates the listbox
+    iListBox->ItemDrawer()->ColumnData()->SetIconArray(iconArray);
+    iListBox->HandleItemAdditionL();    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserDataTypesDlg::ChangeMappingL()
+    {
+    TInt currentItemIndex = iListBox->CurrentItemIndex();
+    
+    if (iDTArray->Count() > currentItemIndex && currentItemIndex >= 0)
+        {
+        // create list of TApaAppInfo
+        CArrayFixFlat<TApaAppInfo>* appInfoArray = new(ELeave) CArrayFixFlat<TApaAppInfo>(64);
+        CleanupStack::PushL(appInfoArray);
+
+        // get list of applications
+        TApaAppInfo appInfo;
+        User::LeaveIfError(iLs.GetAllApps());
+
+        while (iLs.GetNextApp(appInfo) == KErrNone)
+            {
+            appInfoArray->AppendL(appInfo);
+            }
+
+        // sort the array
+        TKeyArrayFix key(_FOFF(TApaAppInfo,iCaption), ECmpFolded16);
+        appInfoArray->Sort(key);
+
+        // create a popup with listbox
+        CAknSingleGraphicPopupMenuStyleListBox* listBox = new(ELeave) CAknSingleGraphicPopupMenuStyleListBox();
+        CleanupStack::PushL(listBox);
+        CAknPopupList* popupList = CAknPopupList::NewL(listBox, R_AVKON_SOFTKEYS_SELECT_CANCEL, AknPopupLayouts::EMenuGraphicWindow );
+        CleanupStack::PushL(popupList);
+        listBox->ConstructL( popupList, 0 );
+        listBox->CreateScrollBarFrameL(ETrue);
+        listBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
+        listBox->View()->SetListEmptyTextL(_L("No apps"));
+        listBox->ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue);        
+        listBox->Model()->SetOwnershipType(ELbmOwnsItemArray);
+        popupList->SetTitleL(_L("Select app"));
+        popupList->EnableFind();
+
+
+        // get an instance of the listbox's item array
+    	MDesCArray* tempArray = listBox->Model()->ItemTextArray();
+    	CDesCArray* listBoxArray = (CDesCArray*)tempArray;
+
+    	// create an icon array
+    	CAknIconArray* iconArray = new(ELeave) CAknIconArray(32);
+        CleanupStack::PushL(iconArray);
+        
+        // loop each app info
+        for (TInt i=0; i<appInfoArray->Count(); i++)
+            {
+                   
+            // get icon of this app
+            CFbsBitmap* bitmap = NULL;
+            CFbsBitmap* mask = NULL;
+            CGulIcon* appIcon = NULL;
+            
+            TRAP_IGNORE( 
+                AknsUtils::CreateAppIconLC(AknsUtils::SkinInstance(), appInfoArray->At(i).iUid, EAknsAppIconTypeList, bitmap, mask);
+                appIcon = CGulIcon::NewL(bitmap, mask);
+                CleanupStack::Pop(2); //bitmap, mask
+                );
+                             
+            // append to the icon array    
+            appIcon->SetBitmapsOwnedExternally(EFalse);
+            iconArray->AppendL(appIcon);            
+            
+            TFileName entry;
+            entry.AppendNum(i);
+            entry.Append(_L("\t"));
+            entry.Append(appInfoArray->At(i).iCaption);
+            
+            listBoxArray->AppendL(entry);
+            }
+
+
+        CleanupStack::Pop(); //iconArray
+
+        // updates the listbox
+        listBox->ItemDrawer()->ColumnData()->SetIconArray(iconArray);
+        listBox->HandleItemAdditionL(); 
+
+    
+        // execute the popup to query the application
+        if (popupList->ExecuteLD())
+            {
+
+            // query priority
+            TInt queryIndex(0);
+            CAknListQueryDialog* listQueryDlg = new(ELeave) CAknListQueryDialog(&queryIndex);
+
+            if (listQueryDlg->ExecuteLD(R_DATA_TYPE_PRIORITY_QUERY))
+                {
+                TInt32 selectedPriority(0);
+                
+                if (queryIndex == EDataTypePriorityMaximum)
+                    selectedPriority = KDataTypeUnTrustedPriorityThreshold;
+                else if (queryIndex == EDataTypePriorityHigh)
+                    selectedPriority = KDataTypePriorityHigh;
+                else if (queryIndex == EDataTypePriorityNormal)
+                    selectedPriority = KDataTypePriorityNormal;
+                else if (queryIndex == EDataTypePriorityLow)
+                    selectedPriority = KDataTypePriorityLow;
+                else
+                    selectedPriority = KDataTypePriorityLastResort;
+                
+                
+                TApaAppInfo& selectedAppInfo = appInfoArray->At(listBox->CurrentItemIndex());
+
+                if (iLs.InsertDataMapping(iDTArray->At(currentItemIndex), selectedPriority, selectedAppInfo.iUid) == KErrNone)
+                    {
+                    GetDataTypesL();
+
+                    CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+                    note->ExecuteLD(_L("Mapping changed"));
+                    }
+                else
+                    {
+                    CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                    note->ExecuteLD(_L("Unable to change mapping"));
+                    }  
+                }
+            }
+
+        CleanupStack::Pop(); // popupList
+        CleanupStack::PopAndDestroy(2); // listBox, appInfoArray
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserDataTypesDlg::SetDefaultMappingL()
+    {
+    TInt currentItemIndex = iListBox->CurrentItemIndex();
+    
+    if (iDTArray->Count() > currentItemIndex && currentItemIndex >= 0)
+        {
+        if (iLs.DeleteDataMapping(iDTArray->At(currentItemIndex)) == KErrNone)
+            {
+            GetDataTypesL();
+            
+            CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+            note->ExecuteLD(_L("Restored default"));
+            }
+        else
+            {
+            CAknInformationNote* note = new(ELeave) CAknInformationNote;
+            note->ExecuteLD(_L("Nothing to restore"));
+            }
+        }
+    }
+        
+// --------------------------------------------------------------------------------------------
+
+TBool CFileBrowserDataTypesDlg::OkToExitL(TInt aButtonId)
+    {
+    return CAknDialog::OkToExitL(aButtonId);
+    }
+           
+// --------------------------------------------------------------------------------------------
+
+TBool CFileBrowserDataTypesDlg::RunQueryLD()
+    {
+    return ExecuteLD(R_DATA_TYPES_DIALOG);
+    }
+       
+// --------------------------------------------------------------------------------------------
+      
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/src/FBFileEditor.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,1300 @@
+/*
+* 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 "FBFileEditor.h"
+#include "FBStd.h"
+#include "FB.hrh"
+#include <filebrowser.rsg>
+
+#include <utf.h>
+#include <eikedwin.h>
+#include <eikrted.h>
+#include <txtrich.h>
+#include <eikspane.h>
+#include <avkon.hrh> 
+#include <akntitle.h>
+#include <AknUtils.h> 
+#include <AknBidiTextUtils.h>
+#include <aknnotewrappers.h>
+#include <eiksbfrm.h>
+#include <AknDef.h>
+#include <layoutmetadata.cdl.h>
+
+const TUint KLeftMargin = 2;
+const TUint KRightMargin = 2;
+const TUint KHexSeparatorMargin = 4;
+
+const TInt KEditorFontHeight = 117;
+const TInt KViewerFontHeight = 117;
+const TInt KEditorFontHeightQHD = 100;
+const TInt KViewerFontHeightQHD = 100;
+
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+CFileBrowserFileEditorDlg* CFileBrowserFileEditorDlg::NewL(const TDesC& aFileName, TInt aMode)
+    {
+    CFileBrowserFileEditorDlg* self = new(ELeave) CFileBrowserFileEditorDlg(aFileName, aMode);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CFileBrowserFileEditorDlg::~CFileBrowserFileEditorDlg()
+    {
+    if (iEditorPF)
+        delete iEditorPF;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CFileBrowserFileEditorDlg::CFileBrowserFileEditorDlg(const TDesC& aFileName, TInt aMode) :
+    iFileName(aFileName), iActiveMode(aMode)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileEditorDlg::ConstructL()
+    {
+    // construct a menu bar
+    if (iActiveMode == EFileEditorEditAsText || iActiveMode == EFileEditorEditAsHex)
+        CAknDialog::ConstructL(R_FILEBROWSER_FILEEDITOR_MENUBAR);
+    else
+        CAknDialog::ConstructL(R_FILEBROWSER_FILEVIEWER_MENUBAR);
+    
+    iTextFormat = EFileBrowserCmdFileEditorSaveFormatANSIASCII;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileEditorDlg::PreLayoutDynInitL()
+    {
+    CAknDialog::PreLayoutDynInitL();
+    
+    // set title text
+    CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
+    CAknTitlePane* tp = static_cast<CAknTitlePane*>( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
+    tp->SetTextL( _L("File editor") );
+    
+    
+    // init edwin editor component
+    if (iActiveMode == EFileEditorEditAsText || iActiveMode == EFileEditorEditAsHex)
+        {
+        CCoeControl* control = CreateLineByTypeL(KNullDesC, EFileEditorDialogId, EEikCtEdwin, NULL);
+        iTextEditor = static_cast<CEikEdwin*>(control);
+        iTextEditor->SetMopParent(this);
+        iTextEditor->ConstructL(EEikEdwinOwnsWindow|EEikEdwinNoHorizScrolling|EEikEdwinInclusiveSizeFixed|EEikEdwinNoAutoSelection, 0, 0, 0 );
+        iTextEditor->CreateTextViewL();
+        iTextEditor->SetAknEditorFlags(EAknEditorFlagEnableScrollBars);
+        iTextEditor->CreateScrollBarFrameL();
+        iTextEditor->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
+        iTextEditor->ForceScrollBarUpdateL(); 
+        iTextEditor->SetBackgroundColorL(KRgbWhite);
+        iTextEditor->SetFocus(ETrue);
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileEditorDlg::PostLayoutDynInitL()
+    {
+    CAknDialog::PostLayoutDynInitL();
+    
+    // modify layout of the texteditor
+    if (iActiveMode == EFileEditorEditAsText || iActiveMode == EFileEditorEditAsHex)
+        {
+        CGraphicsDevice* dev = iCoeEnv->ScreenDevice();
+        const TSize screenSize = dev->SizeInPixels();
+        
+        // Set the font of the editor
+        TFontSpec fontSpec = AknLayoutUtils::FontFromId(EAknLogicalFontSecondaryFont)->FontSpecInTwips();
+        fontSpec.iHeight = IsQHD(screenSize) ? KEditorFontHeightQHD : KEditorFontHeight; // set height
+        
+        TCharFormat cf(fontSpec.iTypeface.iName, fontSpec.iHeight);
+        cf.iFontPresentation.iTextColor = KRgbBlack; 
+
+        TCharFormatMask cfm;
+        cfm.SetAll();
+
+        CCharFormatLayer *charFL = CCharFormatLayer::NewL(cf, cfm);
+        iTextEditor->SetCharFormatLayer(charFL);
+
+        if (iEditorPF)
+            {
+            delete iEditorPF;
+            iEditorPF = NULL;
+            }
+
+        iEditorPF = CParaFormat::NewL();
+        iEditorPF->iLineSpacingInTwips = IsQHD(screenSize) ? KEditorFontHeightQHD : KEditorFontHeight;
+        iEditorPF->iFillColor = KRgbWhite;
+
+        TParaFormatMask pfm;
+        pfm.SetAll();
+
+        CParaFormatLayer *paraFL = CParaFormatLayer::NewL(iEditorPF, pfm);
+        iTextEditor->SetParaFormatLayer(paraFL);
+        
+
+        // set size of the editor
+        TRect rect = Rect();
+        iTextEditor->SetRect(rect);
+        //iTextEditor->Size().iWidth - (CEikScrollBar::DefaultScrollBarBreadth());
+        }
+
+    // load the file to editor or viewer
+    LoadFileL();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileEditorDlg::OpenFileLC(RFile& aFile, const TDesC& aFileName)
+    {
+    TInt err = aFile.Open(CEikonEnv::Static()->FsSession(), aFileName, EFileRead|EFileShareReadersOnly);
+    
+    if (err == KErrInUse)
+        {
+        CAknErrorNote* note = new(ELeave) CAknErrorNote;
+        note->ExecuteLD(_L("The file is in use, cannot open"));
+        User::Leave(KErrNone);
+        }
+    else if (err != KErrNone)
+        {
+        CAknErrorNote* note = new(ELeave) CAknErrorNote;
+        note->ExecuteLD(_L("Cannot open the file"));
+        User::Leave(KErrNone);
+        }
+    else
+        {
+        // opened succesfully, add to cleanup stack
+        CleanupClosePushL(aFile);
+        }     
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileEditorDlg::GetTextFileMode(RFile& aFile, TInt& aFileSize)
+    {
+    iTextFormat = EFileBrowserCmdFileEditorSaveFormatANSIASCII;
+
+    // if we are working with text files, check the type first   
+    if (iActiveMode == EFileEditorEditAsText || iActiveMode == EFileEditorViewAsText)
+        {
+        TBuf8<4> BOM;
+
+        // first check for UTF-16
+        if (aFileSize >= 2 && aFile.Read(0, BOM, 2) == KErrNone)
+            {
+            if (BOM.Length()==2 && BOM[0]==0xFF && BOM[1]==0xFE)
+                {
+                iTextFormat = EFileBrowserCmdFileEditorSaveFormatUTF16LE;
+                aFileSize -= 2;
+                return;
+                }
+            else if (BOM.Length()==2 && BOM[0]==0xFE && BOM[1]==0xFF)
+                {
+                iTextFormat = EFileBrowserCmdFileEditorSaveFormatUTF16BE;
+                aFileSize -= 2;
+                return;
+                }
+            }       
+
+        // then check for UTF-8
+        if (aFileSize >= 3 && aFile.Read(0, BOM, 3) == KErrNone)
+            {
+            if (BOM.Length()==3 && BOM[0]==0xEF && BOM[1]==0xBB && BOM[2]==0xBF)
+                {
+                iTextFormat = EFileBrowserCmdFileEditorSaveFormatUTF8;
+                aFileSize -= 3;
+                return;
+                }
+            }
+            
+        
+        // none of those, seek back to beginning
+        TInt pos(0);
+        aFile.Seek(ESeekStart, pos);
+        }    
+    }
+
+
+// --------------------------------------------------------------------------------------------
+
+HBufC16* CFileBrowserFileEditorDlg::ConvertBuf8ToBuf16L(HBufC8* aBuf8)
+    {
+    __ASSERT_ALWAYS(aBuf8 != NULL, User::Panic(_L("Emp.Buf."),942));
+
+    HBufC16* buf16 = NULL;
+    TPtr8 buf8Ptr(aBuf8->Des()); 
+
+    if (iTextFormat == EFileBrowserCmdFileEditorSaveFormatANSIASCII)
+        {
+        // simple conversion
+        buf16 = HBufC16::NewMaxL(aBuf8->Length());
+        buf16->Des().Copy(aBuf8->Des());
+        }
+    
+    else if (iTextFormat == EFileBrowserCmdFileEditorSaveFormatUTF8)
+        {
+        // use the conversion service
+        buf16 = CnvUtfConverter::ConvertToUnicodeFromUtf8L(aBuf8->Des());
+        }            
+
+    else if (iTextFormat == EFileBrowserCmdFileEditorSaveFormatUTF16LE || iTextFormat == EFileBrowserCmdFileEditorSaveFormatUTF16BE)
+        {
+        buf16 = HBufC16::NewL(aBuf8->Length());
+        buf16->Des().Copy(KNullDesC);
+        
+        HBufC16* oneUniCodeChar = HBufC16::NewMaxLC(1);
+        TUint16* oneUniCodeCharPtr = &oneUniCodeChar->Des()[0];
+       
+        for (TInt i=0; i<buf8Ptr.Length(); i+=2)
+            {
+            // get two 8-bit values and pack them to one 16-bit character depending of endianess
+
+            if (iTextFormat == EFileBrowserCmdFileEditorSaveFormatUTF16LE)
+                {
+                oneUniCodeCharPtr[0] = TUint16((buf8Ptr[i+1] << 8) + buf8Ptr[i]);
+                }
+            else if (iTextFormat == EFileBrowserCmdFileEditorSaveFormatUTF16BE)
+                {
+                oneUniCodeCharPtr[0] = TUint16((buf8Ptr[i] << 8) + buf8Ptr[i+1]);
+                }
+            
+            // append to buffer
+            buf16->Des().Append( oneUniCodeChar->Des() );
+            }
+        
+        CleanupStack::PopAndDestroy(); // oneUniCodeChar
+        } 
+    
+    return buf16; //ownership of buf16 will transferred to the caller           
+    }
+
+// --------------------------------------------------------------------------------------------
+
+HBufC8* CFileBrowserFileEditorDlg::ConvertBuf16ToBuf8L(HBufC16* aBuf16)
+    {
+    __ASSERT_ALWAYS(aBuf16 != NULL, User::Panic(_L("Emp.Buf."),943));
+
+    HBufC8* buf8 = NULL;
+    TPtr16 buf16Ptr(aBuf16->Des()); 
+
+    if (iTextFormat == EFileBrowserCmdFileEditorSaveFormatANSIASCII)
+        {
+        // simple conversion
+        buf8 = HBufC8::NewMaxL(aBuf16->Length());
+        buf8->Des().Copy(aBuf16->Des());
+        }
+    
+    else if (iTextFormat == EFileBrowserCmdFileEditorSaveFormatUTF8)
+        {
+        // use the conversion service
+        buf8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(aBuf16->Des());
+        }            
+
+    else if (iTextFormat == EFileBrowserCmdFileEditorSaveFormatUTF16LE || iTextFormat == EFileBrowserCmdFileEditorSaveFormatUTF16BE)
+        {
+        buf8 = HBufC8::NewL(aBuf16->Length()*2);
+        buf8->Des().Copy(KNullDesC);
+
+        TUint16* charPtr = NULL;
+        TBuf8<2> twoChars;
+        twoChars.Copy(_L8("XX"));        
+       
+        for (TInt i=0; i<aBuf16->Length(); i++)
+            {
+            charPtr = &aBuf16->Des()[i];
+            
+            // get 16-bit character to two variables
+            if (iTextFormat == EFileBrowserCmdFileEditorSaveFormatUTF16LE)
+                {
+                twoChars[0] = TUint8(charPtr[0]);
+                twoChars[1] = TUint8(charPtr[0] << 8);
+                }
+            else if (iTextFormat == EFileBrowserCmdFileEditorSaveFormatUTF16BE)
+                {
+                twoChars[0] = TUint8(charPtr[0] << 8);
+                twoChars[1] = TUint8(charPtr[0]);
+                }
+
+            // append to the buffer
+            buf8->Des().Append(twoChars);
+
+            } // for
+            
+        } // else if
+    
+    return buf8; //ownership of buf8 will transferred to the caller           
+    }                
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileEditorDlg::LoadFileL()
+    {
+    // open the file for reading
+    RFile fileP;
+    OpenFileLC(fileP, iFileName);
+    
+    // get file size
+    TInt fileSize(0);
+    User::LeaveIfError(fileP.Size(fileSize));
+
+    // read BOM from file
+    GetTextFileMode(fileP, fileSize);
+
+    
+    // editor related file loading
+    if (iActiveMode == EFileEditorEditAsText || iActiveMode == EFileEditorEditAsHex)
+        {
+        // make sure that there is currently no text in the editor 
+        iTextEditor->Text()->Reset();
+
+        // set character handling related cases for the editor
+        if (iActiveMode == EFileEditorEditAsText)
+            {
+            iTextEditor->SetOnlyASCIIChars(EFalse);
+            iTextEditor->SetAknEditorCase(EAknEditorTextCase);
+            }
+        else if (iActiveMode == EFileEditorEditAsHex)
+            {
+            iTextEditor->SetOnlyASCIIChars(ETrue);
+            iTextEditor->SetAknEditorCase(EAknEditorUpperCase);
+            }  
+            
+        const TInt KBufSize(1024);
+        TInt fileOffset(0);
+        TInt printOffset(0);
+
+        HBufC8* buf = HBufC8::NewLC(KBufSize);
+        TPtr8 bufPtr(buf->Des());
+        TChar ch;
+        _LIT(KHex, "%02x");
+        TBuf<3> hexBuf;
+
+        // read to buffer and supply the editor
+        while (fileOffset < fileSize)
+            {
+            // read to buffer
+            User::LeaveIfError( fileP.Read(bufPtr, KBufSize) );
+            
+            // handle in text format
+            if (iActiveMode == EFileEditorEditAsText)
+                {
+                HBufC16* buf16 = ConvertBuf8ToBuf16L(buf);
+                CleanupStack::PushL(buf16);
+                TPtr16 buf16Ptr(buf16->Des());
+
+                // replace any line breaks and append to the editor
+                for (TInt i=0; i<buf16Ptr.Length(); i++)
+                    {
+                    ch = buf16Ptr[i] != '\n' ? (TChar)buf16Ptr[i] : (TChar)CEditableText::ELineBreak;
+                    iTextEditor->Text()->InsertL(printOffset, ch);
+                    printOffset++;
+                    }
+                
+                CleanupStack::PopAndDestroy(); // buf16
+                }
+            
+            // or handle in hex format
+            else if (iActiveMode == EFileEditorEditAsHex)
+                {
+                for (TInt i=0; i<bufPtr.Length(); i++)
+                    {
+                    hexBuf.Format(KHex, bufPtr[i]);
+                    hexBuf.UpperCase();
+                    hexBuf.Append(_L(" "));                    
+                    iTextEditor->Text()->InsertL(printOffset, hexBuf);
+                    printOffset += 3;
+                    }
+                }
+            
+            fileOffset += bufPtr.Length();
+            }
+                
+        CleanupStack::PopAndDestroy(); // buf
+
+        // make sure that the cursor position is in the beginning 
+        iTextEditor->SetCursorPosL(0, EFalse);
+        iTextEditor->NotifyNewDocumentL();
+        iTextEditor->UpdateScrollBarsL();
+        }
+
+
+    // viewer related file loading
+    else if (iActiveMode == EFileEditorViewAsText || iActiveMode == EFileEditorViewAsHex)
+        {
+        // load the entire file to buffer
+        HBufC8* buf = HBufC8::NewLC(fileSize);
+        TPtr8 bufPtr(buf->Des());
+        
+        User::LeaveIfError( fileP.Read(bufPtr, fileSize) );
+        
+        // send the buffer to viewer
+        if (iActiveMode == EFileEditorViewAsText)
+            {
+            HBufC16* buf16 = ConvertBuf8ToBuf16L(buf);
+            CleanupStack::PopAndDestroy(); // buf
+            iViewer->FormatAsTextL(buf16);
+            }
+
+        else if (iActiveMode == EFileEditorViewAsHex)
+            {
+            iViewer->FormatAsHexL(buf);
+            CleanupStack::Pop(); // buf
+            }
+        }
+
+    CleanupStack::PopAndDestroy(); // fileP
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileEditorDlg::SaveEditorDataL(TBool aQueryNewName)
+    {
+    TBool doSave(ETrue);
+    CPlainText* docText = iTextEditor->Text();
+    TInt docLength = docText->DocumentLength();
+    
+    TFileName fileName;
+    fileName.Copy(iFileName);
+    
+    // check that format of the file is valid
+    if (iActiveMode == EFileEditorEditAsHex)
+        {
+        // check every 3rd char is a space
+        for (TInt i=2; i<docLength; i+=3)
+            {
+            TPtrC docPtr = docText->Read(i, 1);
+            if (docPtr.Length() < 1 || docPtr[0] != ' ')
+                {
+                CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                note->ExecuteLD(_L("Separate hex blocks with space!"));
+                return;                
+                }
+            }
+        
+        // check for valid chars
+        for (TInt i=0; i<docLength; i+=3)
+            {
+            TPtrC docPtr = docText->Read(i, 2);
+            if (docPtr.Length() < 2 || !IsHexChar(docPtr[0]) || !IsHexChar(docPtr[1]))
+                {
+                CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                note->ExecuteLD(_L("Use only hex characters!"));
+                return;                
+                }
+            }
+        }
+    
+    
+    // query new file name
+    if (aQueryNewName)
+        {
+        CAknTextQueryDialog* textQuery = CAknTextQueryDialog::NewL(fileName);
+        textQuery->SetPromptL(_L("Full path:"));
+        
+        if (textQuery->ExecuteLD(R_GENERAL_TEXT_QUERY))
+            {
+            doSave = ETrue;
+            }
+        else
+            {
+            doSave = EFalse;
+            }
+        }
+
+
+    // continue with writing
+    if (doSave)        
+        {
+        RFile fileP;
+        TInt err = fileP.Replace(CEikonEnv::Static()->FsSession(), fileName, EFileWrite);
+            
+        if (err == KErrNone)    
+            {
+            CleanupClosePushL(fileP);
+            
+            const TInt KBufSize(1002);
+            TInt fileOffset(0);        
+            TInt docOffset(0);
+            TLex converter;
+            TUint hexValue(0);
+            
+            // write BOM for text files
+            if (iActiveMode == EFileEditorEditAsText)
+                {
+                if (iTextFormat == EFileBrowserCmdFileEditorSaveFormatUTF16LE)
+                    {
+                    TBuf8<2> BOM;
+                    BOM.Append(0xFF);
+                    BOM.Append(0xFE);
+                    
+                    if (fileP.Write(0, BOM, 2) == KErrNone)
+                        fileOffset += 2;
+                    }
+                
+                else if (iTextFormat == EFileBrowserCmdFileEditorSaveFormatUTF16BE)
+                    {
+                    TBuf8<2> BOM;
+                    BOM.Append(0xFE);
+                    BOM.Append(0xFF);
+                    
+                    if (fileP.Write(0, BOM, 2) == KErrNone)
+                        fileOffset += 2;
+                    }
+                                  
+                else if (iTextFormat == EFileBrowserCmdFileEditorSaveFormatUTF8)
+                    {
+                    TBuf8<3> BOM;
+                    BOM.Append(0xEF);
+                    BOM.Append(0xBB);
+                    BOM.Append(0xBF);
+                    
+                    if (fileP.Write(0, BOM, 3) == KErrNone)
+                        fileOffset += 3;
+                    }                
+                }
+            
+            
+            HBufC8* buf = HBufC8::NewLC(KBufSize * 2);
+            TPtr8 bufPtr(buf->Des());      
+          
+            while (docOffset < docLength)
+                {
+                // get text from storage
+                TPtrC docPtr = docText->Read(docOffset, KBufSize);
+                bufPtr.Copy(KNullDesC);
+
+                if (iActiveMode == EFileEditorEditAsText)
+                    {
+                    HBufC16* convBuf = HBufC16::NewLC(docPtr.Length());
+                    convBuf->Des().Copy(KNullDesC);
+                    
+                     // convert to line breaks first
+                    for (TInt i=0; i<docPtr.Length(); i++)
+                        {
+                        if (docPtr[i] == CEditableText::EParagraphDelimiter) // skip extra char from the editor
+                            continue;    
+                        else if (docPtr[i] == CEditableText::ELineBreak)
+                            convBuf->Des().Append('\n');
+                        else
+                            convBuf->Des().Append(docPtr[i]);
+                        }
+ 
+                    HBufC8* buf8 = ConvertBuf16ToBuf8L(convBuf);
+                    
+                    // make sure the sizes are correct
+                    if (iTextFormat == EFileBrowserCmdFileEditorSaveFormatANSIASCII || iTextFormat == EFileBrowserCmdFileEditorSaveFormatUTF8)
+                        {
+                        bufPtr.Copy(buf8->Des().Left(convBuf->Length())); 
+                        }
+                    else if (iTextFormat == EFileBrowserCmdFileEditorSaveFormatUTF16LE || iTextFormat == EFileBrowserCmdFileEditorSaveFormatUTF16BE)
+                        {
+                        bufPtr.Copy(buf8->Des().Left(convBuf->Length()*2)); 
+                        }
+                    
+                    delete buf8;
+                    buf8 = NULL;
+
+                    CleanupStack::PopAndDestroy(); // convBuf
+                    }
+                    
+                else if (iActiveMode == EFileEditorEditAsHex)
+                    {
+                    for (TInt i=0; i<docPtr.Length(); i+=3)
+                        {
+                        if (i+1 >= docPtr.Length() - 1)
+                            break;
+                        
+                        TBuf<3> buf2;
+                        buf2.Append(docPtr[i]);
+                        buf2.Append(docPtr[i+1]);
+
+                        // convert from hex to decimal
+                        converter.Assign(buf2);
+                        if (converter.Val(hexValue, EHex) == KErrNone)
+                            {
+                            bufPtr.Append(hexValue);
+                            }
+                        }                    
+                    }
+                
+                // write to a file
+                err = fileP.Write(fileOffset, bufPtr, bufPtr.Length());
+                if (err != KErrNone)
+                    break;
+                
+                docOffset += docPtr.Length();
+                fileOffset += bufPtr.Length();
+                }
+            
+           CleanupStack::PopAndDestroy(2); // buf, fileP
+            }
+        
+        if (err == KErrNone)
+            {
+            // remember the new file name if save was succesfull
+            iFileName.Copy(fileName);
+            
+            CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+            note->ExecuteLD(_L("Saved succesfully"));
+            } 
+        else if (err == KErrInUse)
+            {
+            CAknErrorNote* note = new(ELeave) CAknErrorNote;
+            note->ExecuteLD(_L("The file is in use, cannot write"));
+            User::Leave(KErrNone);
+            }
+        else
+            {
+            CAknErrorNote* note = new(ELeave) CAknErrorNote;
+            note->ExecuteLD(_L("Cannot write to the file"));
+            User::Leave(KErrNone);
+            }
+        }
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TBool CFileBrowserFileEditorDlg::IsHexChar(TInt aCh)
+    {
+    if (aCh >= '0' && aCh <= '9')
+        return ETrue;
+    else if (aCh >= 'a' && aCh <= 'f')
+        return ETrue;
+    else if (aCh >= 'A' && aCh <= 'F')
+        return ETrue;
+    else
+        return EFalse;
+    }
+      
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileEditorDlg::ProcessCommandL(TInt aCommandId)
+    {
+    CAknDialog::ProcessCommandL(aCommandId);
+
+    switch (aCommandId)
+        {
+        case EFileBrowserCmdFileEditorViewAsText:
+            {
+            iActiveMode = EFileEditorViewAsText;
+            LoadFileL();
+            }
+            break;
+
+        case EFileBrowserCmdFileEditorViewAsHex:
+            {
+            iActiveMode = EFileEditorViewAsHex;
+            LoadFileL();
+            }
+            break;
+
+//
+        case EFileBrowserCmdFileEditorSave:
+            {
+            SaveEditorDataL();
+            }
+            break;
+            
+        case EFileBrowserCmdFileEditorSaveAs:
+            {
+            SaveEditorDataL(ETrue);
+            }
+            break;
+
+        case EFileBrowserCmdFileEditorSaveFormatANSIASCII:
+        case EFileBrowserCmdFileEditorSaveFormatUTF8:
+        case EFileBrowserCmdFileEditorSaveFormatUTF16LE:
+        case EFileBrowserCmdFileEditorSaveFormatUTF16BE:
+            {
+            iTextFormat = aCommandId;
+            }
+            break;
+            
+        case EFileBrowserCmdFileEditorEditAsText:
+            {
+            iActiveMode = EFileEditorEditAsText;
+            LoadFileL();
+            }
+            break;
+
+        case EFileBrowserCmdFileEditorEditAsHex:
+            {
+            iActiveMode = EFileEditorEditAsHex;
+            LoadFileL();
+            }
+            break;
+
+//                        
+        case EFileBrowserCmdFileEditorExit:
+            TryExitL(EAknCmdExit);
+            break;
+
+        default:
+            break;
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileEditorDlg::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
+    {
+    if (aResourceId == R_FILEBROWSER_FILEVIEWER_MENUPANE)
+        {
+        aMenuPane->SetItemDimmed(EFileBrowserCmdFileEditorViewAsText, iActiveMode == EFileEditorViewAsText);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdFileEditorViewAsHex, iActiveMode == EFileEditorViewAsHex);
+        }
+    else if (aResourceId == R_FILEBROWSER_FILEEDITOR_MENUPANE)
+        {
+        aMenuPane->SetItemDimmed(EFileBrowserCmdFileEditorEditAsText, iActiveMode == EFileEditorEditAsText);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdFileEditorEditAsHex, iActiveMode == EFileEditorEditAsHex);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdFileEditorSaveFormat, iActiveMode == EFileEditorEditAsHex);
+        }
+	else if (aResourceId == R_FILEBROWSER_FILEEDITOR_SAVEFORMAT_SUBMENU)
+	    {
+        aMenuPane->SetItemButtonState(iTextFormat, EEikMenuItemSymbolOn);
+	    }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+SEikControlInfo CFileBrowserFileEditorDlg::CreateCustomControlL(TInt aControlType)
+    {
+    SEikControlInfo controlInfo;
+    controlInfo.iControl = NULL;
+    controlInfo.iTrailerTextId = 0;
+    controlInfo.iFlags = 0;
+
+    if (aControlType == EFileViewerDialogControl)
+        {
+        // create a control
+        iViewer = new(ELeave) CFileBrowserFileEditorViewControl();
+        iViewer->SetMopParent(this);
+        iViewer->ConstructL();
+
+        controlInfo.iControl = iViewer;
+        }
+        
+    return controlInfo;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileEditorDlg::SetSizeAndPosition(const TSize& /*aSize*/)
+    {
+    // fill whole window
+    TRect mainPaneRect;
+    TRect naviPaneRect;
+
+    if (Layout_Meta_Data::IsLandscapeOrientation() ||
+        iEikonEnv->AppUiFactory()->StatusPane()->CurrentLayoutResId() != R_AVKON_STATUS_PANE_LAYOUT_SMALL)
+        {
+        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+        }
+    else
+        {
+        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::ENaviPane, naviPaneRect);
+        mainPaneRect.iTl.iY = naviPaneRect.Height();   
+        }
+            
+    SetRect(mainPaneRect);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TBool CFileBrowserFileEditorDlg::RunDlgLD()
+    {
+    if (iActiveMode == EFileEditorViewAsText || iActiveMode == EFileEditorViewAsHex)
+        return ExecuteLD(R_FILEBROWSER_FILEVIEWER_DIALOG);
+    else
+        return ExecuteLD(R_FILEBROWSER_FILEEDITOR_DIALOG);
+    }
+       
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+CFileBrowserFileEditorViewControl::~CFileBrowserFileEditorViewControl()
+    {
+    ResetVariables();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CFileBrowserFileEditorViewControl::CFileBrowserFileEditorViewControl()
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileEditorViewControl::ConstructL()
+    {
+    CreateWindowL();
+    SetBlank();
+    SetRect(Rect());
+    ActivateL();
+    
+    iTotalNumberOfLines = 0;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TSize CFileBrowserFileEditorViewControl::MinimumSize()
+    {
+    TRect mainPaneRect;
+    TRect naviPaneRect;
+    
+    if (Layout_Meta_Data::IsLandscapeOrientation() ||
+        iEikonEnv->AppUiFactory()->StatusPane()->CurrentLayoutResId() != R_AVKON_STATUS_PANE_LAYOUT_SMALL)
+        {
+        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+        }
+    else
+        {
+        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::ENaviPane, naviPaneRect);
+        mainPaneRect.iTl.iY = naviPaneRect.Height();   
+        }
+
+    return mainPaneRect.Size();
+    }
+        
+// --------------------------------------------------------------------------------------------
+
+TKeyResponse CFileBrowserFileEditorViewControl::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
+    {
+    if(aType != EEventKey)
+        return EKeyWasNotConsumed;
+    
+    // normally scroll only one line
+    TInt scrollLines(1); 
+    
+    // with special keys scroll iNumberOfLinesFitsScreen-1 lines instead
+    if (aKeyEvent.iCode == EKeyIncVolume || aKeyEvent.iCode=='#' || aKeyEvent.iCode == EKeyDecVolume || aKeyEvent.iCode=='*')
+        scrollLines = iNumberOfLinesFitsScreen-1;
+    
+    
+    if (aKeyEvent.iCode == EKeyUpArrow || aKeyEvent.iCode == EKeyIncVolume || aKeyEvent.iCode=='#')
+        {
+        if (iCurrentLine > 0)
+            {
+            iCurrentLine -= scrollLines;
+            
+            if (iCurrentLine < 0)
+                iCurrentLine = 0;
+            
+            UpdateScrollBarL();
+            DrawNow();
+            }
+
+        return EKeyWasConsumed;
+        }
+    
+    else if (aKeyEvent.iCode == EKeyDownArrow || aKeyEvent.iCode == EKeyDecVolume || aKeyEvent.iCode=='*')
+        {
+        if (iActiveMode == EFileEditorViewAsText)
+            {
+            // no need to scroll text if it fits to the screen
+            if (iTotalNumberOfLines <= iNumberOfLinesFitsScreen)
+                return EKeyWasConsumed;
+
+            iCurrentLine += scrollLines;
+
+            // adjust the last line to end of the screen            
+            if (iCurrentLine > iTotalNumberOfLines - iNumberOfLinesFitsScreen)
+                iCurrentLine = iTotalNumberOfLines - iNumberOfLinesFitsScreen;            
+            }
+        else if (iActiveMode == EFileEditorViewAsHex)
+            {
+            iCurrentLine += scrollLines;
+
+            // last line can be first line on the screen            
+            if (iCurrentLine > iTotalNumberOfLines - 1)
+                iCurrentLine = iTotalNumberOfLines - 1;              
+            }
+            
+        UpdateScrollBarL();
+        DrawNow();
+        
+        return EKeyWasConsumed;
+        }
+    
+    return EKeyWasNotConsumed;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileEditorViewControl::FormatAsTextL(HBufC16* aBuf)
+    {
+    if (aBuf == NULL)    
+        ResetVariables(EFalse);
+    else
+        ResetVariables();
+    
+    InitVariables();
+    iActiveMode = EFileEditorViewAsText;
+    
+    // store the bugger
+    if (aBuf != NULL)
+        iTextBuf = aBuf;
+    
+    iWrappedTextArray = new(ELeave) CArrayFixFlat<TPtrC>(32);
+    
+    // wrap to array
+    AknTextUtils::WrapToArrayL(iTextBuf->Des(), iDrawingWidth, *iFont, *iWrappedTextArray);
+    iTotalNumberOfLines = iWrappedTextArray->Count();
+
+    // count amount of lines fits to screen
+    iNumberOfLinesFitsScreen = TInt(iViewerRect.Height() / (iFont->HeightInPixels()));
+
+    // update scroll bars
+    UpdateScrollBarL();
+
+    // update the screen
+    DrawNow();    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileEditorViewControl::FormatAsHexL(HBufC8* aBuf)
+    {
+    if (aBuf == NULL)    
+        ResetVariables(EFalse);
+    else
+        ResetVariables();
+    
+    InitVariables();
+    iActiveMode = EFileEditorViewAsHex;
+    
+    // store the buffer
+    if (aBuf != NULL)
+        iHexesBuffer = aBuf;
+    
+    // calculate amount of hex values fits to the screen
+    TUint charWidth = iFont->CharWidthInPixels('X');
+    iHexGrougWidth = charWidth*2 + TInt (KHexSeparatorMargin*iX_factor);
+    iAmountOfHexesFitsHorizontally = TUint( iDrawingWidth / iHexGrougWidth );
+
+    // calculate total number of files
+    iTotalNumberOfLines = iHexesBuffer->Length() / iAmountOfHexesFitsHorizontally + 1;
+
+    // count amount of lines fits to screen
+    iNumberOfLinesFitsScreen = TInt(iViewerRect.Height() / iFont->HeightInPixels()) - 1;
+
+    // update scroll bars
+    UpdateScrollBarL();
+
+    // update the screen
+    DrawNow();      
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileEditorViewControl::InitVariables()
+    {
+    iCurrentLine = 0;
+
+    // calculate layout data
+    TRect mainPaneRect;
+    TRect naviPaneRect;
+    
+    if (Layout_Meta_Data::IsLandscapeOrientation() ||
+        iEikonEnv->AppUiFactory()->StatusPane()->CurrentLayoutResId() != R_AVKON_STATUS_PANE_LAYOUT_SMALL)
+        {
+        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+        }
+    else
+        {
+        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::ENaviPane, naviPaneRect);
+        mainPaneRect.iTl.iY = naviPaneRect.Height();   
+        }
+
+    iViewerRect = TRect(mainPaneRect.Size());
+
+    iX_factor = TReal(iViewerRect.Width()) / 176;
+    iY_factor = TReal(iViewerRect.Height()) / 144;
+
+
+    // define drawing width, some extra space needed for double span scrolling bar
+    if (AknLayoutUtils::LayoutMirrored())  // scroll bar on 'left'
+        {
+        iLeftDrawingPosition = KLeftMargin + 12;
+        iDrawingWidth = TUint( iViewerRect.Width() - iLeftDrawingPosition*iX_factor - (KRightMargin*iX_factor)); 
+        }
+    else // scroll bar on 'right'
+        {
+        iLeftDrawingPosition = KLeftMargin;  
+        iDrawingWidth = TUint( iViewerRect.Width() - iLeftDrawingPosition*iX_factor - (KRightMargin*iX_factor + 7*iX_factor)); 
+        } 
+
+
+    // set font
+    CGraphicsDevice* dev = iCoeEnv->ScreenDevice();
+    const TSize screenSize = dev->SizeInPixels();
+    
+    TFontSpec fontSpec = AknLayoutUtils::FontFromId(EAknLogicalFontSecondaryFont)->FontSpecInTwips();
+    fontSpec.iHeight = IsQHD(screenSize) ? KViewerFontHeightQHD : KViewerFontHeight; // set height
+    dev->GetNearestFontInTwips(iFont, fontSpec);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileEditorViewControl::ResetVariables(TBool aResetData)
+    {
+    if (iScrollBarFrame)
+        {
+        delete iScrollBarFrame;
+        iScrollBarFrame = NULL;
+        }
+        
+    if (iHexesBuffer && aResetData)
+        {
+        delete iHexesBuffer;
+        iHexesBuffer = NULL;
+        }    
+
+    if (iWrappedTextArray)
+        {
+        delete iWrappedTextArray;
+        iWrappedTextArray = NULL;
+        }
+
+    if (iTextBuf && aResetData)
+        {
+        delete iTextBuf;
+        iTextBuf = NULL;
+        }
+
+    if (iFont)
+        {
+        CGraphicsDevice* dev = iCoeEnv->ScreenDevice();
+        dev->ReleaseFont(iFont);
+        iFont = NULL;
+        }
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileEditorViewControl::UpdateScrollBarL()
+    {
+    TRect rect(iViewerRect);
+    
+    // init the scroll bar    
+    if (!iScrollBarFrame)
+        {
+        iScrollBarFrame = new(ELeave) CEikScrollBarFrame(this, this, ETrue);
+        iScrollBarFrame->CreateDoubleSpanScrollBarsL(ETrue, EFalse);            
+        iScrollBarFrame->SetTypeOfVScrollBar(CEikScrollBarFrame::EDoubleSpan);
+        iScrollBarFrame->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
+        }       
+
+
+    // update values
+	TEikScrollBarModel horizontalBar;
+    TEikScrollBarModel verticalBar;
+
+    if (iActiveMode == EFileEditorViewAsText)
+        {    
+        verticalBar.iThumbPosition = iCurrentLine;
+        verticalBar.iScrollSpan = iTotalNumberOfLines - iNumberOfLinesFitsScreen + 1;
+        verticalBar.iThumbSpan = 1;
+        }
+    
+    else if (iActiveMode == EFileEditorViewAsHex)
+        {    
+        verticalBar.iThumbPosition = iCurrentLine;
+        verticalBar.iScrollSpan = iTotalNumberOfLines;
+        verticalBar.iThumbSpan = 1;
+        }
+        
+    TEikScrollBarFrameLayout layout;
+	layout.iTilingMode = TEikScrollBarFrameLayout::EInclusiveRectConstant;
+
+    // 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());
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileEditorViewControl::Draw(const TRect& aRect) const
+    {
+    CWindowGc& gc = SystemGc();
+    gc.Clear(aRect);
+    gc.SetPenColor(KRgbBlack);
+    gc.UseFont(iFont);
+    
+    TInt fontHeight = iFont->HeightInPixels();
+
+    if (iActiveMode == EFileEditorViewAsText)
+        {
+        // draw the text
+        for (TInt i=0; i<iNumberOfLinesFitsScreen; i++)
+            {
+            // check for bounds and draw
+            if (iCurrentLine >= 0 && iTotalNumberOfLines > i+iCurrentLine)
+                gc.DrawText(iWrappedTextArray->At(i+iCurrentLine), TPoint(TInt(iLeftDrawingPosition*iX_factor), TInt(fontHeight*(i+1))));
+            }        
+        }
+
+    else if (iActiveMode == EFileEditorViewAsHex)
+        {
+        TInt hexesOffSet = iCurrentLine * iAmountOfHexesFitsHorizontally; 
+        TInt topLineHeight = 2*iY_factor + fontHeight;
+        
+        // draw the top line
+        gc.SetPenColor(KRgbWhite);
+        
+        gc.SetBrushColor(KRgbBlue);
+        gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
+        if (AknLayoutUtils::LayoutMirrored())  // scroll bar on 'left'
+            {
+            gc.DrawRect(TRect((KLeftMargin + 12)*iX_factor, 0, aRect.iBr.iX, topLineHeight));
+            }
+        else // scroll bar on 'right'
+            {
+            gc.DrawRect(TRect(0, 0, aRect.iBr.iX-(KRightMargin*iX_factor + 7*iX_factor), topLineHeight));
+            } 
+
+        TBuf<128> topLineBuf;
+        topLineBuf.AppendNum(hexesOffSet);
+        topLineBuf.Append(_L(": "));
+        
+        for (TInt i=0; i<iAmountOfHexesFitsHorizontally; i++)
+            {
+            TInt pos = hexesOffSet + i;
+            
+            if (pos < iHexesBuffer->Des().Length())
+                {
+                topLineBuf.Append(iHexesBuffer->Des()[pos]);
+                }
+            }
+ 
+        gc.DrawText(topLineBuf, TPoint(TInt(iLeftDrawingPosition*iX_factor), TInt(fontHeight)));
+
+ 
+        // draw hex values
+        gc.SetPenColor(KRgbBlack);
+        for (TInt i=0; i<iNumberOfLinesFitsScreen; i++)
+            {
+            for (TInt j=0; j<iAmountOfHexesFitsHorizontally; j++)
+                {
+                TInt pos = hexesOffSet + i*iAmountOfHexesFitsHorizontally + j;
+                
+                if (pos >= iHexesBuffer->Des().Length())
+                    return;
+                
+                TUint8* ptr = &iHexesBuffer->Des()[pos];
+                
+                _LIT(KHex, "%02x");
+                TBuf<5> hexBuf;
+                hexBuf.Format(KHex, ptr[0]);
+                hexBuf.UpperCase();
+
+                gc.DrawText(hexBuf, TPoint(TInt(iLeftDrawingPosition*iX_factor + j*iHexGrougWidth), TInt(topLineHeight + fontHeight*(i+1))));
+                }
+            }         
+        }
+
+    gc.DiscardFont();
+    }
+  
+// --------------------------------------------------------------------------------------------
+
+CCoeControl* CFileBrowserFileEditorViewControl::ComponentControl(TInt aIndex) const
+	{
+	if (aIndex == 0 && iScrollBarFrame)
+	    return iScrollBarFrame->VerticalScrollBar();
+	else
+	    return NULL;
+	}
+
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileEditorViewControl::CountComponentControls() const
+	{
+	if (iScrollBarFrame)
+	    return 1;
+	else
+	    return 0;
+	}
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileEditorViewControl::HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType)
+    {
+    if ((aEventType == EEikScrollPageDown) || (aEventType == EEikScrollPageUp) || 
+       (aEventType == EEikScrollThumbDragVert) || (aEventType == EEikScrollUp) ||
+       (aEventType == EEikScrollDown))
+        {
+        iCurrentLine = aScrollBar->ThumbPosition();
+        UpdateScrollBarL();
+        DrawNow();
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+ 
+TTypeUid::Ptr CFileBrowserFileEditorViewControl::MopSupplyObject(TTypeUid aId)
+    {
+    return CCoeControl::MopSupplyObject(aId);
+    }
+	   
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileEditorViewControl::HandleResourceChange(TInt aType)
+    {
+    if (aType == KEikDynamicLayoutVariantSwitch)
+        {
+        SetRect(Rect());
+        ActivateL();
+        
+        // reformat the text
+        if (iActiveMode == EFileEditorViewAsText)
+            {
+            FormatAsTextL();
+            }
+        else if (iActiveMode == EFileEditorViewAsHex)
+            {
+            FormatAsHexL();
+            }
+        }
+    else
+        {
+        CCoeControl::HandleResourceChange(aType);
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/src/FBFileListContainer.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,1133 @@
+/*
+* 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 "FBFileListContainer.h"
+#include "FB.hrh"
+#include "FBDocument.h"
+#include "FBAppUi.h"
+#include "FBModel.h"
+#include "FBFileUtils.h"
+#include "FBStd.h"
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)
+    #include "FBToolbar.h"
+#endif
+
+#include <w32std.h>
+#include <AknDef.h>
+#include <AknUtils.h> 
+#include <eikspane.h>
+#include <akntitle.h>
+#include <aknnavilabel.h>
+#include <aknlists.h>
+#include <aknsfld.h>
+#include <eikclbd.h>
+#include <eiktxlbm.h>
+#include <AknsListBoxBackgroundControlContext.h>
+#include <AknInfoPopupNoteController.h>
+#include <AknIconArray.h>
+#include <layoutmetadata.cdl.h>
+
+_LIT(KEmptyDirectory, "No entries");
+_LIT(KNoMatches, "No matches");
+
+const TInt KSimpleViewFontHeight = 127;
+const TInt KExtendedViewFontHeight1 = 127;
+const TInt KExtendedViewFontHeight2 = 105;
+
+const TInt KSimpleViewFontHeightQHD = 120;
+const TInt KExtendedViewFontHeight1QHD = 115;
+const TInt KExtendedViewFontHeight2QHD = 90;
+
+// ===================================== MEMBER FUNCTIONS =====================================
+
+void CFileBrowserFileListContainer::ConstructL(const TRect& /*aRect*/)
+    {
+    iModel = static_cast<CFileBrowserDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model();
+    iModel->SetFileListContainer(this);
+    
+    iFileViewMode = -1;
+    iIsDragging = EFalse;
+    
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __SERIES60_32__)
+    iToolbar = CFileBrowserToolbar::NewL();
+    if ( iModel->Settings().iEnableToolbar && 
+         AknLayoutUtils::PenEnabled() )
+        {
+        iToolbar->ShowToolbarL();        
+        }
+    else
+        {
+        iToolbar->HideToolbarL();
+        }
+#endif
+    
+    CreateWindowL();
+    Window().SetShadowDisabled(EFalse);
+    SetBlank();
+
+    SetScreenLayoutL(iModel->Settings().iDisplayMode);
+    
+    CreateEmptyNaviPaneLabelL();
+    
+    iModel->FileUtils()->RefreshViewL();
+
+    EnableDragEvents();
+    
+    ActivateL();
+    
+    iInfoPopup = CAknInfoPopupNoteController::NewL();
+    iInfoPopup->SetTimePopupInView(5000);
+    iInfoPopup->SetTimeDelayBeforeShow(500);
+    iInfoPopup->SetTextL(_L("TIP: Use left arrow key or touch drag to left to move up in the directory structure."));
+    iInfoPopup->ShowInfoPopupNote();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CFileBrowserFileListContainer::~CFileBrowserFileListContainer()
+    {
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)
+    delete iToolbar;
+#endif
+    delete iInfoPopup;
+    
+    DeleteNaviPane();
+
+    if (iSearchField)
+        delete iSearchField;
+    
+    if (iListBox)
+        delete iListBox;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileListContainer::CreateEmptyNaviPaneLabelL()
+    {
+    CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
+
+    iNaviContainer = static_cast<CAknNavigationControlContainer*>(sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi)));
+    iNaviDecorator = iNaviContainer->CreateNavigationLabelL();
+    iNaviContainer->PushL(*iNaviDecorator);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileListContainer::DeleteNaviPane()
+    {
+    if (iNaviContainer)
+        {
+        iNaviContainer->Pop(iNaviDecorator);
+        }
+    
+    if (iNaviDecorator)
+        {
+        delete iNaviDecorator;
+        iNaviDecorator = NULL;
+        }
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileListContainer::Draw(const TRect& aRect) const
+    {
+    CWindowGc& gc = SystemGc();
+    gc.Clear(aRect);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileListContainer::HandleControlEventL(
+    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TKeyResponse CFileBrowserFileListContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
+    {
+    // open search field with alpha digit numbers
+    if (aType == EEventKeyDown && !iSearchField && aKeyEvent.iScanCode < EStdKeyF1 && TChar(aKeyEvent.iScanCode).IsAlphaDigit())
+        {
+        EnableSearchFieldL();
+        
+        if (iSearchField)
+            {
+            //static_cast<CAknFilteredTextListBoxModel*>(iListBox->Model())->Filter()->DeferredSendKeyEventToFepL(aKeyEvent.iCode);
+            return EKeyWasConsumed;
+            }
+        }
+    
+    // close search field with clear-button if it's empty
+    if (iSearchField && aKeyEvent.iCode == EKeyBackspace)
+        {
+           TFileName searchText;
+           iSearchField->GetSearchText(searchText);
+           
+           if (searchText == KNullDesC)
+               {
+               DisableSearchFieldL();
+               return EKeyWasConsumed; 
+               }
+        }
+
+    // check file/directory handling related cases
+    if (iModel->FileUtils()->HandleOfferKeyEventL(aKeyEvent, aType) == EKeyWasConsumed)
+        return EKeyWasConsumed;
+    
+    TKeyResponse result = EKeyWasNotConsumed;
+
+    if (iSearchField && iListBox)
+        {
+        // find items with all event codes (that's the reason why there is EEventKey instead of aType)
+        TBool needsRefresh(EFalse);
+        result = AknFind::HandleFindOfferKeyEventL(aKeyEvent, EEventKey, this, iListBox, iSearchField, EFalse, needsRefresh);
+        
+        if (needsRefresh)
+            DrawNow();
+        }
+
+    // scroll one page up/down with volume keys
+    if (result == EKeyWasNotConsumed && iListBox && iListBox->Model()->NumberOfItems() > 0 && (aKeyEvent.iCode == EKeyIncVolume || (aKeyEvent.iCode=='#' && !iModel->IsHashKeySelectionInUse())))
+        {
+        CListBoxView::TSelectionMode selectionMode = CListBoxView::ENoSelection;
+        CListBoxView::TCursorMovement moveto = CListBoxView::ECursorPrevScreen;
+        
+        iListBox->View()->MoveCursorL(moveto, selectionMode);
+      
+        iListBox->SetCurrentItemIndex(iListBox->CurrentItemIndex()); 
+        iListBox->DrawDeferred();
+
+        return EKeyWasConsumed;
+        
+        }
+    else if (result == EKeyWasNotConsumed && iListBox && iListBox->Model()->NumberOfItems() > 0 && (aKeyEvent.iCode == EKeyDecVolume || aKeyEvent.iCode=='*'))
+        {
+        CListBoxView::TSelectionMode selectionMode = CListBoxView::ENoSelection;
+        CListBoxView::TCursorMovement moveto = CListBoxView::ECursorNextScreen;
+        
+        if (iListBox->CurrentItemIndex() >= iListBox->Model()->NumberOfItems() - iListBox->View()->NumberOfItemsThatFitInRect(iListBox->View()->ViewRect()))
+            moveto = CListBoxView::ECursorLastItem;
+        
+        iListBox->View()->MoveCursorL(moveto, selectionMode);
+
+        iListBox->SetCurrentItemIndex(iListBox->CurrentItemIndex()); 
+        iListBox->DrawDeferred();
+
+        return EKeyWasConsumed;
+        }
+
+    // offer key event to the listbox if not already consumed
+    else if (result == EKeyWasNotConsumed && iListBox)
+        return iListBox->OfferKeyEventL(aKeyEvent, aType);
+    else
+        return result;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileListContainer::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
+    {
+    switch (aEventType)
+        {
+        case EEventEnterKeyPressed:
+        case EEventItemDoubleClicked:
+            {
+            // "emulate" enter key press and send it to file utils for prosessing
+            
+            TKeyEvent keyEvent;
+            keyEvent.iCode = EKeyEnter;
+            keyEvent.iModifiers = 0;
+            
+            TEventCode type = EEventKey;
+    
+            iModel->FileUtils()->HandleOfferKeyEventL(keyEvent, type);          
+            }
+            break;
+        default:
+            break;
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileListContainer::HandlePointerEventL(const TPointerEvent &aPointerEvent)
+    {
+    // detect direction of dragging by comparing the start and finish points
+    
+    if (aPointerEvent.iType == TPointerEvent::EButton1Down)
+        {
+        iDragStartPoint = aPointerEvent.iPosition;
+        iIsDragging = EFalse;
+        }
+    else if (aPointerEvent.iType == TPointerEvent::EDrag)
+        {
+        iIsDragging = ETrue;
+        
+        return;
+        }
+    else if (aPointerEvent.iType == TPointerEvent::EButton1Up)
+        {
+        if (iIsDragging)
+            {
+            const TInt KDelta = iDragStartPoint.iX - aPointerEvent.iPosition.iX;
+            const TInt KThreshold = 30;
+            
+            if (KDelta < -KThreshold) // dragging to right
+                {
+                // "emulate" right key press and send it to file utils for prosessing
+                
+                TKeyEvent keyEvent;
+                keyEvent.iCode = EKeyRightArrow;
+                keyEvent.iModifiers = 0;
+                
+                TEventCode type = EEventKey;
+        
+                iModel->FileUtils()->HandleOfferKeyEventL(keyEvent, type);
+                
+                return;
+                }
+            else if (KDelta > KThreshold) // dragging to left
+                {
+                // "emulate" left key press and send it to file utils for prosessing
+                
+                TKeyEvent keyEvent;
+                keyEvent.iCode = EKeyLeftArrow;
+                keyEvent.iModifiers = 0;
+                
+                TEventCode type = EEventKey;
+        
+                iModel->FileUtils()->HandleOfferKeyEventL(keyEvent, type);
+                
+                return;
+                }            
+            }
+        iIsDragging = EFalse;
+        }
+    else
+        {
+        iIsDragging = EFalse;        
+        }
+
+    CCoeControl::HandlePointerEventL(aPointerEvent);
+    }
+            
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileListContainer::CreateListBoxL(TInt aFileViewMode)
+    {
+    iFileViewMode = aFileViewMode;
+    
+    if (iSearchField)
+        DisableSearchFieldL();
+    
+    if (iListBox)
+        {
+        delete iListBox;
+        iListBox = NULL;    
+        }
+    
+    if (iFileViewMode == EFileViewModeSimple)
+        {
+        iListBox = new(ELeave) CSimpleFileViewListBox;
+        }
+    else     
+        {
+        iListBox = new(ELeave) CExtendedFileViewListBox;
+        }
+        
+                
+    iListBox->SetContainerWindowL(*this);
+    iListBox->ConstructL(this, EAknListBoxMarkableList);
+    
+    iListBox->View()->SetListEmptyTextL(KEmptyDirectory);
+        
+    iListBox->CreateScrollBarFrameL(ETrue);
+    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
+    iListBox->SetListBoxObserver(this);
+
+    // make sure listbox has correct size
+    SizeChanged();
+
+    iListBox->ActivateL();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileListContainer::CurrentListBoxItemIndex()
+    {
+    if (iListBox && iSearchField)
+        {
+        TInt currentItemIndex = iListBox->CurrentItemIndex();
+        
+        if (currentItemIndex >= 0)
+            return static_cast<CAknFilteredTextListBoxModel*>(iListBox->Model())->Filter()->FilteredItemIndex(currentItemIndex);
+        else
+            return KErrNotFound;
+        }
+    else if (iListBox)
+        {
+        return iListBox->CurrentItemIndex();
+        }
+    else
+        return KErrNotFound;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+const CArrayFix<TInt>* CFileBrowserFileListContainer::ListBoxSelectionIndexes()
+    {
+    if (iListBox && iSearchField)
+        {
+        TRAP_IGNORE( static_cast<CAknFilteredTextListBoxModel*>(iListBox->Model())->Filter()->UpdateSelectionIndexesL() ); // !!!
+        return static_cast<CAknFilteredTextListBoxModel*>(iListBox->Model())->Filter()->SelectionIndexes();
+        }
+    else if (iListBox)
+        {
+        const CListBoxView::CSelectionIndexArray* indices = iListBox->SelectionIndexes();
+        return static_cast<const CArrayFix<TInt>*>(indices);
+        }
+    else
+        return NULL;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileListContainer::ListBoxSelectionIndexesCount()
+    {
+    if (iListBox && iSearchField)
+        {
+        TRAP_IGNORE( static_cast<CAknFilteredTextListBoxModel*>(iListBox->Model())->Filter()->UpdateSelectionIndexesL() ); // !!!
+        return static_cast<CAknFilteredTextListBoxModel*>(iListBox->Model())->Filter()->SelectionIndexes()->Count();
+        }
+    else if (iListBox)
+        {
+        return iListBox->SelectionIndexes()->Count();
+        }
+    else
+        return KErrNotFound;
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileListContainer::ListBoxNumberOfVisibleItems()
+    {
+    if (iListBox && iSearchField)
+        {
+        return static_cast<CAknFilteredTextListBoxModel*>(iListBox->Model())->Filter()->FilteredNumberOfItems();
+        }
+    else if (iListBox)
+        {
+        return iListBox->Model()->NumberOfItems();
+        }
+    else
+        return KErrNotFound;
+    }
+        
+// --------------------------------------------------------------------------------------------
+
+CAknIconArray* CFileBrowserFileListContainer::ListBoxIconArrayL()
+    {
+    if (iListBox)
+        { 
+        if (iFileViewMode == EFileViewModeSimple)
+            {
+            return static_cast<CAknIconArray*>(static_cast<CEikColumnListBox*>(iListBox)->ItemDrawer()->ColumnData()->IconArray());
+            }
+        else if (iFileViewMode == EFileViewModeExtended)
+            {
+            return static_cast<CAknIconArray*>(static_cast<CEikFormattedCellListBox*>(iListBox)->ItemDrawer()->ColumnData()->IconArray());
+            }
+        }
+
+    return NULL;
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileListContainer::SetListBoxIconArrayL(CAknIconArray* aIconArray)
+    {
+    if (iListBox)
+        { 
+        if (iFileViewMode == EFileViewModeSimple)
+            {
+            //CArrayPtr<CGulIcon>* currentIconArray = static_cast<CEikColumnListBox*>(iListBox)->ItemDrawer()->ColumnData()->IconArray();
+            //delete currentIconArray;
+            //currentIconArray = NULL;       
+            static_cast<CEikColumnListBox*>(iListBox)->ItemDrawer()->ColumnData()->SetIconArray(aIconArray);
+            }
+        else if (iFileViewMode == EFileViewModeExtended)
+            {
+            //CArrayPtr<CGulIcon>* currentIconArray = static_cast<CEikFormattedCellListBox*>(iListBox)->ItemDrawer()->ColumnData()->IconArray();
+            //delete currentIconArray;
+            //currentIconArray = NULL;       
+            static_cast<CEikFormattedCellListBox*>(iListBox)->ItemDrawer()->ColumnData()->SetIconArray(aIconArray);
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileListContainer::SetListBoxTextArrayL(CDesCArray* aTextArray)
+    {
+    if (iListBox)
+        {    
+        iListBox->Model()->SetItemTextArray(aTextArray);
+        iListBox->Model()->SetOwnershipType(ELbmOwnsItemArray);
+        iListBox->HandleItemAdditionL();
+        iListBox->UpdateScrollBarsL();
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileListContainer::EnableSearchFieldL()
+    {
+    if (iListBox && !iSearchField && iListBox->Model()->NumberOfItems() > 0)
+        {
+        iSearchField = CAknSearchField::NewL(*this, CAknSearchField::ESearch, NULL, KMaxFileName);
+        
+        iSearchField->SetObserver(this);
+        iSearchField->SetFocus(ETrue);
+        iSearchField->MakeVisible(ETrue);
+        iSearchField->ResetL();
+        
+        iListBox->View()->SetListEmptyTextL(KNoMatches);
+        
+        // enable filtering
+        ((CAknFilteredTextListBoxModel*)iListBox->Model())->CreateFilterL(iListBox, iSearchField);
+        
+        SizeChanged();   
+
+        // update cba
+        CEikButtonGroupContainer* cbaGroup = CEikButtonGroupContainer::Current();
+        cbaGroup->SetCommandSetL(R_AVKON_SOFTKEYS_OPTIONS_CANCEL);
+        cbaGroup->DrawNow();
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TBool CFileBrowserFileListContainer::IsSearchFieldEnabled()
+    {
+    return iSearchField != NULL;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileListContainer::DisableSearchFieldL()
+    {
+    if (iSearchField)
+        {
+        iSearchField->MakeVisible( EFalse );
+        iSearchField->SetFocusing( EFalse );
+        
+        delete iSearchField;
+        iSearchField = NULL;  
+
+        iListBox->View()->SetListEmptyTextL(KEmptyDirectory);
+
+        // disable filtering
+        ((CAknFilteredTextListBoxModel*)iListBox->Model())->RemoveFilter();
+
+        SizeChanged();
+        DrawNow();
+
+        // update cba
+        CEikButtonGroupContainer* cbaGroup = CEikButtonGroupContainer::Current();
+        cbaGroup->SetCommandSetL(R_AVKON_SOFTKEYS_OPTIONS_EXIT);
+        cbaGroup->DrawNow();
+        
+        // Clear selections because using filter causes selections to go out of sync
+        UpdateToolbar();
+        AknSelectionService::HandleMarkableListProcessCommandL( EAknUnmarkAll, iListBox );
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileListContainer::CountComponentControls() const
+    {
+    TInt controls(0);
+
+    if (iListBox)
+        controls++;
+    
+    if (iSearchField)
+        controls++;
+    
+    return controls;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CCoeControl* CFileBrowserFileListContainer::ComponentControl(TInt aIndex) const
+    {
+    switch (aIndex)
+        {
+        case 0:
+            {
+            return iListBox;
+            }
+        case 1:
+            {
+            return iSearchField;
+            }
+        default:
+            {
+            return NULL;
+            }
+        }
+    }    
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileListContainer::SetScreenLayoutL(TInt aLayoutMode)
+    {
+    // make sure that the search field has been disabled
+    DisableSearchFieldL();
+
+    // make sure that the title of the application is correct
+    CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
+    CAknTitlePane* tp = static_cast<CAknTitlePane*>( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
+    tp->SetTextL( _L("FileBrowser") );
+    
+    // change the layout mode
+    if (aLayoutMode == EDisplayModeFullScreen)
+        sp->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_SMALL);
+    else
+        sp->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_USUAL);
+    
+    // update layout
+    HandleResourceChange(KEikDynamicLayoutVariantSwitch);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileListContainer::SetNaviPaneTextL(const TDesC& aText)
+    {
+    if (iNaviDecorator)
+        {
+        delete iNaviDecorator;
+        iNaviDecorator = NULL;
+        }
+    
+    CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
+    iNaviDecorator = iNaviContainer->CreateMessageLabelL(aText);
+    iNaviContainer->PushL(*iNaviDecorator);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileListContainer::SizeChanged()
+    {
+    if (iListBox && iSearchField)
+        {
+        TSize findPaneSize;
+        AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EFindPane, findPaneSize);
+
+        TRect mainPaneRect;
+        TRect naviPaneRect;
+
+        if (Layout_Meta_Data::IsLandscapeOrientation() ||
+            iEikonEnv->AppUiFactory()->StatusPane()->CurrentLayoutResId() != R_AVKON_STATUS_PANE_LAYOUT_SMALL)
+            {
+            AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)
+            if ( iToolbar && iModel->Settings().iEnableToolbar )
+                {
+                iToolbar->ShowToolbarL();
+                // Get location of softkeys 
+                AknLayoutUtils::TAknCbaLocation cbaLocation = AknLayoutUtils::CbaLocation(); 
+                if ( cbaLocation == AknLayoutUtils::EAknCbaLocationBottom ) 
+                    { 
+                    // here there is the BSK mode
+                    mainPaneRect.iBr.iX -= iToolbar->Rect().Width();
+                    findPaneSize.iWidth -= iToolbar->Rect().Width();
+                    }
+                }
+#endif
+            }
+        else
+            {
+            AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+            AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::ENaviPane, naviPaneRect);
+            mainPaneRect.iTl.iY = naviPaneRect.Height();
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)
+            if ( iToolbar && iModel->Settings().iEnableToolbar )
+                {
+                iToolbar->ShowToolbarL();
+                mainPaneRect.iBr.iY -= iToolbar->Rect().Height();
+                }
+#endif
+            }
+        
+        mainPaneRect.iBr.iY -= findPaneSize.iHeight;  
+
+        TRect listBoxRect(mainPaneRect.Size());
+        iListBox->SetRect(listBoxRect);
+
+        if (iFileViewMode == EFileViewModeSimple)
+            {        
+            CAknsListBoxBackgroundControlContext* listBoxContext = static_cast<CAknsListBoxBackgroundControlContext*>(static_cast<CEikColumnListBox*>(iListBox)->ItemDrawer()->ColumnData()->SkinBackgroundContext());
+            listBoxContext->SetRect(listBoxRect);
+            }
+        else if (iFileViewMode == EFileViewModeExtended)
+            {        
+            CAknsListBoxBackgroundControlContext* listBoxContext = static_cast<CAknsListBoxBackgroundControlContext*>(static_cast<CEikFormattedCellListBox*>(iListBox)->ItemDrawer()->ColumnData()->SkinBackgroundContext());
+            listBoxContext->SetRect(listBoxRect);
+            }        
+
+        iSearchField->SetRect(TRect(TPoint(0,mainPaneRect.Height()), findPaneSize));
+        
+        if (iSearchField->IsVisible() && iListBox->IsVisible())
+            iSearchField->SetLinePos(2);
+
+        }
+        
+    else if (iListBox)
+        {
+        TRect mainPaneRect;
+        TRect naviPaneRect;
+
+        if (Layout_Meta_Data::IsLandscapeOrientation() ||
+            iEikonEnv->AppUiFactory()->StatusPane()->CurrentLayoutResId() != R_AVKON_STATUS_PANE_LAYOUT_SMALL)
+            {
+            AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)
+            if ( iToolbar && iModel->Settings().iEnableToolbar )
+                {
+                iToolbar->ShowToolbarL();
+                // Get location of softkeys 
+                AknLayoutUtils::TAknCbaLocation cbaLocation = AknLayoutUtils::CbaLocation(); 
+                if ( cbaLocation == AknLayoutUtils::EAknCbaLocationBottom ) 
+                    { 
+                    // here there is the BSK mode
+                    mainPaneRect.iBr.iX -= iToolbar->Rect().Width();
+                    }
+                }
+#endif
+            }
+        else
+            {
+            AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+            AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::ENaviPane, naviPaneRect);
+            mainPaneRect.iTl.iY = naviPaneRect.Height();
+            
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)
+            if ( iToolbar && iModel->Settings().iEnableToolbar )
+                {
+                iToolbar->ShowToolbarL();
+                mainPaneRect.iBr.iY -= iToolbar->Rect().Height();
+                }
+#endif
+            }
+        
+        TRect listBoxRect(mainPaneRect.Size());
+        iListBox->SetRect(listBoxRect);
+
+        if (iFileViewMode == EFileViewModeSimple)
+            {        
+            CAknsListBoxBackgroundControlContext* listBoxContext = static_cast<CAknsListBoxBackgroundControlContext*>(static_cast<CEikColumnListBox*>(iListBox)->ItemDrawer()->ColumnData()->SkinBackgroundContext());
+            listBoxContext->SetRect(listBoxRect);
+            }
+        else if (iFileViewMode == EFileViewModeExtended)
+            {        
+            CAknsListBoxBackgroundControlContext* listBoxContext = static_cast<CAknsListBoxBackgroundControlContext*>(static_cast<CEikFormattedCellListBox*>(iListBox)->ItemDrawer()->ColumnData()->SkinBackgroundContext());
+            listBoxContext->SetRect(listBoxRect);
+            }
+        }
+    }
+        
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileListContainer::HandleResourceChange(TInt aType)
+    {
+    CCoeControl::HandleResourceChange(aType);
+
+    if (aType == KEikDynamicLayoutVariantSwitch)
+        {
+        TRect mainPaneRect;
+        TRect naviPaneRect;
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __SERIES60_32__)
+        TBool needToCutSearchFieldLength( EFalse );
+#endif
+        
+        if (Layout_Meta_Data::IsLandscapeOrientation() ||
+            iEikonEnv->AppUiFactory()->StatusPane()->CurrentLayoutResId() != R_AVKON_STATUS_PANE_LAYOUT_SMALL)
+            {
+            AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __SERIES60_32__)
+            if ( iToolbar && iModel->Settings().iEnableToolbar )
+                {
+                iToolbar->ShowToolbarL();
+                // Get location of softkeys 
+                AknLayoutUtils::TAknCbaLocation cbaLocation = AknLayoutUtils::CbaLocation(); 
+                if ( cbaLocation == AknLayoutUtils::EAknCbaLocationBottom ) 
+                    { 
+                    // here there is the BSK mode
+                    mainPaneRect.iBr.iX -= iToolbar->Rect().Width();
+                    needToCutSearchFieldLength = ETrue;
+                    }
+                }
+#endif
+            }
+        else
+            {
+            AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+            AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::ENaviPane, naviPaneRect);
+            mainPaneRect.iTl.iY = naviPaneRect.Height();
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __SERIES60_32__)
+            if ( iToolbar && iModel->Settings().iEnableToolbar )
+                {
+                iToolbar->ShowToolbarL();
+                mainPaneRect.iBr.iY -= iToolbar->Rect().Height();
+                }
+#endif
+            }
+
+        SetRect(mainPaneRect);
+
+        if (iListBox && iSearchField)
+            {
+            TSize findPaneSize;
+            AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EFindPane, findPaneSize);
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __SERIES60_32__)
+            if ( needToCutSearchFieldLength )
+                {
+                findPaneSize.iWidth -= iToolbar->Rect().Width();
+                }
+#endif
+            mainPaneRect.iBr.iY -= findPaneSize.iHeight;
+            
+            TRect listBoxRect(mainPaneRect.Size());
+            iListBox->SetRect(listBoxRect);
+            
+            if (iFileViewMode == EFileViewModeSimple)
+                {        
+                CAknsListBoxBackgroundControlContext* listBoxContext = static_cast<CAknsListBoxBackgroundControlContext*>(static_cast<CEikColumnListBox*>(iListBox)->ItemDrawer()->ColumnData()->SkinBackgroundContext());
+                listBoxContext->SetRect(listBoxRect);
+                }
+            else if (iFileViewMode == EFileViewModeExtended)
+                {        
+                CAknsListBoxBackgroundControlContext* listBoxContext = static_cast<CAknsListBoxBackgroundControlContext*>(static_cast<CEikFormattedCellListBox*>(iListBox)->ItemDrawer()->ColumnData()->SkinBackgroundContext());
+                listBoxContext->SetRect(listBoxRect);
+                }    
+            
+            iSearchField->SetRect(TRect(TPoint(0,mainPaneRect.Height()), findPaneSize));
+            
+            if (iSearchField->IsVisible() && iListBox->IsVisible())
+                iSearchField->SetLinePos(2);
+        
+            TRAP_IGNORE(iListBox->UpdateScrollBarsL());
+            }        
+        else if (iListBox)
+            {
+            TRect listBoxRect(mainPaneRect.Size());
+            iListBox->SetRect(listBoxRect);
+            
+            if (iFileViewMode == EFileViewModeSimple)
+                {        
+                CAknsListBoxBackgroundControlContext* listBoxContext = static_cast<CAknsListBoxBackgroundControlContext*>(static_cast<CEikColumnListBox*>(iListBox)->ItemDrawer()->ColumnData()->SkinBackgroundContext());
+                listBoxContext->SetRect(listBoxRect);
+                }
+            else if (iFileViewMode == EFileViewModeExtended)
+                {        
+                CAknsListBoxBackgroundControlContext* listBoxContext = static_cast<CAknsListBoxBackgroundControlContext*>(static_cast<CEikFormattedCellListBox*>(iListBox)->ItemDrawer()->ColumnData()->SkinBackgroundContext());
+                listBoxContext->SetRect(listBoxRect);
+                }    
+            
+            TRAP_IGNORE(iListBox->UpdateScrollBarsL());
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileListContainer::HandleSettingsChangeL()
+    {
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)
+    if ( iModel->Settings().iEnableToolbar )
+        {
+        if ( AknLayoutUtils::PenEnabled() )
+            {
+            if ( !iToolbar )
+                {
+                iToolbar = CFileBrowserToolbar::NewL();
+                }
+            iToolbar->ShowToolbarL();
+            }
+        }
+    else
+        {
+        HideToolbar();
+        }
+    SizeChanged();
+#endif
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileListContainer::HideToolbar()
+    {
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)
+    if ( iToolbar && iToolbar->IsShown() )
+        {
+        iToolbar->HideToolbarL();
+        }
+#endif
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileListContainer::UpdateToolbar()
+    {
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)
+    if ( iToolbar && iToolbar->IsShown() )
+        {
+        iToolbar->ResetState();
+        }
+#endif    
+    }
+
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+CSimpleFileViewListBox::~CSimpleFileViewListBox()
+    {
+    ReleaseFonts();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CSimpleFileViewListBox::ReleaseFonts()
+    {
+    if (iFont)
+        {
+        CGraphicsDevice* dev = iCoeEnv->ScreenDevice();
+        dev->ReleaseFont(iFont);
+        iFont = NULL;   
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+    
+void CSimpleFileViewListBox::SizeChanged()
+    {
+    // call the base class function first
+    CAknSingleGraphicStyleListBox::SizeChanged();
+
+    // customize the list box
+    TRAP_IGNORE(SizeChangedL());
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CSimpleFileViewListBox::SizeChangedL()
+    {
+    // disable separator line
+    ItemDrawer()->ColumnData()->SetSeparatorLinePosition(ENoLine);
+
+    // enable marquee
+    ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue);
+
+    // get font
+    ReleaseFonts();
+    CGraphicsDevice* dev = iCoeEnv->ScreenDevice();
+    const TSize screenSize = dev->SizeInPixels();
+
+    TFontSpec fontSpec = AknLayoutUtils::FontFromId(EAknLogicalFontPrimarySmallFont)->FontSpecInTwips();
+    fontSpec.iHeight = IsQHD(screenSize) ? KSimpleViewFontHeightQHD : KSimpleViewFontHeight;
+    dev->GetNearestFontInTwips(iFont, fontSpec);
+    
+    // set fonts
+    ItemDrawer()->ColumnData()->SetColumnFontL(0, iFont);
+    ItemDrawer()->ColumnData()->SetColumnFontL(1, iFont);
+    ItemDrawer()->ColumnData()->SetColumnFontL(2, iFont);
+    ItemDrawer()->ColumnData()->SetColumnFontL(3, iFont);
+
+    // set row height
+    TInt rowHeight = iFont->HeightInPixels()+4;    
+    TSize itemCellSize = View()->ItemDrawer()->ItemCellSize();
+    itemCellSize.iHeight = rowHeight; 
+    SetItemHeightL(rowHeight);
+    View()->ItemDrawer()->SetItemCellSize(itemCellSize);
+    
+    // set icon sizes
+    TInt normalIconSize = rowHeight * 0.9;
+    TInt markingIconSize = rowHeight * 0.8;
+    ItemDrawer()->ColumnData()->SetSubCellIconSize(0, TSize(normalIconSize,normalIconSize));
+    ItemDrawer()->ColumnData()->SetSubCellIconSize(2, TSize(markingIconSize,markingIconSize));
+    ItemDrawer()->ColumnData()->SetSubCellIconSize(3, TSize(markingIconSize,markingIconSize));
+
+    // set column widths
+    ItemDrawer()->ColumnData()->SetColumnWidthPixelL(0, normalIconSize);
+    ItemDrawer()->ColumnData()->SetColumnWidthPixelL(1, itemCellSize.iWidth-normalIconSize-markingIconSize);
+    ItemDrawer()->ColumnData()->SetColumnWidthPixelL(2, markingIconSize);
+    ItemDrawer()->ColumnData()->SetColumnWidthPixelL(3, markingIconSize);
+
+    // set baseline for the text
+    ItemDrawer()->ColumnData()->SetColumnBaselinePosL(1, iFont->HeightInPixels()-iFont->BaselineOffsetInPixels()-1);
+
+    // set margins
+    TMargins iconMargins;
+    iconMargins.iBottom = 0;
+    iconMargins.iLeft = 0;
+    iconMargins.iRight = 0;
+    iconMargins.iTop = 0;
+
+    TMargins textMargins;
+    textMargins.iBottom = 0;
+    textMargins.iLeft = markingIconSize * 0.15;
+    textMargins.iRight = markingIconSize * 0.15;
+    textMargins.iTop = 0;
+
+    ItemDrawer()->ColumnData()->SetColumnMarginsL(0, iconMargins);
+    ItemDrawer()->ColumnData()->SetColumnMarginsL(1, textMargins);
+    ItemDrawer()->ColumnData()->SetColumnMarginsL(2, iconMargins);
+    ItemDrawer()->ColumnData()->SetColumnMarginsL(3, iconMargins);
+    }
+
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+CExtendedFileViewListBox::~CExtendedFileViewListBox()
+    {
+    ReleaseFonts();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CExtendedFileViewListBox::ReleaseFonts()
+    {
+    if (iFont1)
+        {
+        CGraphicsDevice* dev = iCoeEnv->ScreenDevice();
+        dev->ReleaseFont(iFont1);
+        iFont1 = NULL;     
+        }
+
+    if (iFont2)
+        {
+        CGraphicsDevice* dev = iCoeEnv->ScreenDevice();
+        dev->ReleaseFont(iFont2);
+        iFont2 = NULL;      
+        }        
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CExtendedFileViewListBox::SizeChanged()
+    {
+    // call the base class function first
+    CAknDoubleGraphicStyleListBox::SizeChanged();
+
+    // customize the list box
+    TRAP_IGNORE(SizeChangedL());
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CExtendedFileViewListBox::SizeChangedL()
+    {
+    // disable separator line
+    ItemDrawer()->ColumnData()->SetSeparatorLinePosition(ENoLine);
+
+    // enable marquee
+    ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue);
+    
+    // get fonts
+    ReleaseFonts();
+    CGraphicsDevice* dev = iCoeEnv->ScreenDevice();
+    const TSize screenSize = dev->SizeInPixels();
+    
+    TFontSpec fontSpec1 = AknLayoutUtils::FontFromId(EAknLogicalFontPrimarySmallFont)->FontSpecInTwips();
+    fontSpec1.iHeight = IsQHD(screenSize) ? KExtendedViewFontHeight1QHD : KExtendedViewFontHeight1;
+    dev->GetNearestFontInTwips(iFont1, fontSpec1);
+
+    TFontSpec fontSpec2 = AknLayoutUtils::FontFromId(EAknLogicalFontSecondaryFont)->FontSpecInTwips();
+    fontSpec2.iHeight = IsQHD(screenSize) ? KExtendedViewFontHeight2QHD : KExtendedViewFontHeight2;
+    dev->GetNearestFontInTwips(iFont2, fontSpec2);    
+
+        
+    // set fonts
+    ItemDrawer()->ColumnData()->SetSubCellFontL(0, iFont1);
+    ItemDrawer()->ColumnData()->SetSubCellFontL(1, iFont1);
+    ItemDrawer()->ColumnData()->SetSubCellFontL(2, iFont2);
+    ItemDrawer()->ColumnData()->SetSubCellFontL(3, iFont1);
+    ItemDrawer()->ColumnData()->SetSubCellFontL(4, iFont1);
+
+    // set row height
+    TInt rowHeight1 = iFont1->HeightInPixels()+3;    
+    TInt rowHeight2 = iFont2->HeightInPixels()+3;    
+    TSize itemCellSize = View()->ItemDrawer()->ItemCellSize();
+    itemCellSize.iHeight = rowHeight1+rowHeight2; 
+    SetItemHeightL(rowHeight1+rowHeight2);
+    View()->ItemDrawer()->SetItemCellSize(itemCellSize);
+
+    
+    // set icon sizes
+    TInt normalIconSize = rowHeight1 * 0.9;
+    TInt markingIconSize = rowHeight1 * 0.8;
+    ItemDrawer()->ColumnData()->SetSubCellIconSize(0, TSize(normalIconSize,normalIconSize));
+    ItemDrawer()->ColumnData()->SetSubCellIconSize(3, TSize(markingIconSize,markingIconSize));
+    ItemDrawer()->ColumnData()->SetSubCellIconSize(4, TSize(markingIconSize,markingIconSize));
+
+    // set sub cell sizes
+    ItemDrawer()->ColumnData()->SetSubCellSizeL(0, TSize(normalIconSize,rowHeight1+rowHeight2));
+    ItemDrawer()->ColumnData()->SetSubCellSizeL(1, TSize(itemCellSize.iWidth-normalIconSize-markingIconSize,rowHeight1));
+    ItemDrawer()->ColumnData()->SetSubCellSizeL(2, TSize(itemCellSize.iWidth-normalIconSize-markingIconSize,rowHeight2));
+    ItemDrawer()->ColumnData()->SetSubCellSizeL(3, TSize(markingIconSize,rowHeight1+rowHeight2));
+    ItemDrawer()->ColumnData()->SetSubCellSizeL(4, TSize(markingIconSize,rowHeight1+rowHeight2));
+
+    // set sub cell positions
+    ItemDrawer()->ColumnData()->SetSubCellPositionL(0, TPoint(0,0));
+    ItemDrawer()->ColumnData()->SetSubCellPositionL(1, TPoint(normalIconSize,0));
+    ItemDrawer()->ColumnData()->SetSubCellPositionL(2, TPoint(normalIconSize,rowHeight1));
+    ItemDrawer()->ColumnData()->SetSubCellPositionL(3, TPoint(itemCellSize.iWidth-normalIconSize-markingIconSize,0));
+    ItemDrawer()->ColumnData()->SetSubCellPositionL(4, TPoint(itemCellSize.iWidth-normalIconSize-markingIconSize,0));
+    
+    // set baselines for the texts
+    ItemDrawer()->ColumnData()->SetSubCellBaselinePosL(1, iFont1->HeightInPixels()-iFont1->BaselineOffsetInPixels()-1);
+    ItemDrawer()->ColumnData()->SetSubCellBaselinePosL(2, rowHeight1+iFont2->HeightInPixels()-iFont2->BaselineOffsetInPixels()-1);
+    
+    // set margins
+    TMargins iconMargins;
+    iconMargins.iBottom = rowHeight2;
+    iconMargins.iLeft = 0;
+    iconMargins.iRight = 0;
+    iconMargins.iTop = 0;
+
+    TMargins textMargins;
+    textMargins.iBottom = 0;
+    textMargins.iLeft = markingIconSize * 0.15;
+    textMargins.iRight = markingIconSize * 0.15;
+    textMargins.iTop = 0;
+
+    ItemDrawer()->ColumnData()->SetSubCellMarginsL(0, iconMargins);
+    ItemDrawer()->ColumnData()->SetSubCellMarginsL(1, textMargins);
+    ItemDrawer()->ColumnData()->SetSubCellMarginsL(2, textMargins);
+    ItemDrawer()->ColumnData()->SetSubCellMarginsL(3, iconMargins);
+    ItemDrawer()->ColumnData()->SetSubCellMarginsL(4, iconMargins);
+    }
+    
+// --------------------------------------------------------------------------------------------
+        
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/src/FBFileListView.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,763 @@
+/*
+* 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 <remconinterfaceselector.h>
+#include <remconcoreapitarget.h>
+
+#include <filebrowser.rsg>
+#include "FB.hrh"
+#include "FBFileListView.h"
+#include "FBFileListContainer.h"
+#include "FBDocument.h" 
+#include "FBModel.h"
+#include "FBFileUtils.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CFileBrowserFileListView::ConstructL(const TRect& aRect)
+// EPOC two-phased constructor
+// ---------------------------------------------------------
+//
+void CFileBrowserFileListView::ConstructL()
+    {
+    BaseConstructL( R_FILEBROWSER_VIEW_FILELIST );
+    iModel = static_cast<CFileBrowserDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model();
+    
+    iRemConSelector = CRemConInterfaceSelector::NewL();
+    iRemConTarget = CRemConCoreApiTarget::NewL(*iRemConSelector, *this);
+    iRemConSelector->OpenTargetL();
+    }
+
+// ---------------------------------------------------------
+// CFileBrowserFileListView::~CFileBrowserFileListView()
+// ?implementation_description
+// ---------------------------------------------------------
+//
+CFileBrowserFileListView::~CFileBrowserFileListView()
+    {
+    delete iRemConSelector;
+
+    if ( iContainer )
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        }
+
+    delete iContainer;
+    }
+
+// ---------------------------------------------------------
+// TUid CFileBrowserFileListView::Id()
+// ?implementation_description
+// ---------------------------------------------------------
+//
+TUid CFileBrowserFileListView::Id() const
+    {
+    return KFileListViewUID;
+    }
+
+// ---------------------------------------------------------
+// TUid CFileBrowserFileListView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
+// ?implementation_description
+// ---------------------------------------------------------
+//
+
+void CFileBrowserFileListView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
+    {
+    TBool emptyListBox = iContainer->ListBoxNumberOfVisibleItems() == 0;
+    TBool driveListActive = iModel->FileUtils()->IsDriveListViewActive();
+    TBool normalModeActive = iModel->FileUtils()->IsNormalModeActive();
+    TBool currentDriveReadOnly = iModel->FileUtils()->IsCurrentDriveReadOnly();
+    TBool currentItemDirectory = iModel->FileUtils()->IsCurrentItemDirectory();
+    TBool listBoxSelections = iContainer->ListBoxSelectionIndexesCount() == 0;
+    TBool emptyClipBoard = iModel->FileUtils()->ClipBoardList()->Count() == 0;
+    TBool showSnapShot = iModel->FileUtils()->DriveSnapShotPossible();
+    
+    TBool hideEditMenu(EFalse);
+    if (driveListActive)
+        {
+        if (!showSnapShot || emptyListBox && emptyClipBoard)
+            hideEditMenu = ETrue;    
+        else
+            hideEditMenu = EFalse;
+        }
+    else
+        {
+        if (emptyListBox && emptyClipBoard)
+            hideEditMenu = ETrue;    
+        else
+            hideEditMenu = EFalse;
+        }
+    
+
+    if (aResourceId == R_FILEBROWSER_VIEW_FILELIST_MENU)
+	    {
+        aMenuPane->SetItemDimmed(EFileBrowserCmdEdit, hideEditMenu);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdDiskAdmin, !driveListActive);
+	    }    
+
+    else if (aResourceId == R_FILEBROWSER_FILE_SUBMENU)
+	    {
+        aMenuPane->SetItemDimmed(EFileBrowserCmdFileBack, driveListActive);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdFileOpen, emptyListBox || driveListActive || currentItemDirectory);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdFileOpenDrive, emptyListBox || !driveListActive);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdFileOpenDirectory, emptyListBox || driveListActive || !currentItemDirectory);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdFileView, emptyListBox || !listBoxSelections || currentItemDirectory || driveListActive);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdFileEdit, emptyListBox || !listBoxSelections || currentItemDirectory || driveListActive);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdFileSendTo, emptyListBox || driveListActive || currentItemDirectory);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdFileNew, driveListActive || currentDriveReadOnly);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdFileDelete, emptyListBox || driveListActive || currentDriveReadOnly);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdFileRename, emptyListBox || driveListActive || currentDriveReadOnly || !listBoxSelections);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdFileTouch, emptyListBox || driveListActive || currentDriveReadOnly);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdFileProperties, emptyListBox || !listBoxSelections);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdFileChecksums, emptyListBox || !listBoxSelections || currentItemDirectory || driveListActive);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdFileSetAttributes, emptyListBox || driveListActive || currentDriveReadOnly);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdFileCompress, currentDriveReadOnly || emptyListBox || !listBoxSelections || currentItemDirectory || driveListActive);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdFileDecompress, currentDriveReadOnly || emptyListBox || !listBoxSelections || currentItemDirectory || driveListActive);
+	    }
+    
+    else if (aResourceId == R_FILEBROWSER_EDIT_SUBMENU)
+	    {
+        TBool currentSelected = iContainer->ListBox()->View()->ItemIsSelected(iContainer->ListBox()->View()->CurrentItemIndex());
+        TBool allSelected = iContainer->ListBox()->SelectionIndexes()->Count() == iContainer->ListBox()->Model()->NumberOfItems();
+        TBool noneSelected = iContainer->ListBox()->SelectionIndexes()->Count() == 0;
+        
+        aMenuPane->SetItemDimmed(EFileBrowserCmdSnapShot, !driveListActive);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdEditCut, driveListActive || currentDriveReadOnly || emptyListBox);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdEditCopy, driveListActive || emptyListBox);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdEditPaste, driveListActive || emptyClipBoard || currentDriveReadOnly);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdEditCopyToFolder, driveListActive || emptyListBox);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdEditMoveToFolder, driveListActive || currentDriveReadOnly || emptyListBox);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdEditSelect, driveListActive || currentSelected || emptyListBox);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdEditUnselect, driveListActive || !currentSelected || emptyListBox);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdEditSelectAll, driveListActive || allSelected || emptyListBox);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdEditUnselectAll, driveListActive || noneSelected || emptyListBox);
+	    }
+
+	else if (aResourceId == R_FILEBROWSER_VIEW_SUBMENU)
+	    {
+        aMenuPane->SetItemDimmed(EFileBrowserCmdViewSort, !normalModeActive || driveListActive || emptyListBox);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdViewOrder, !normalModeActive || driveListActive || emptyListBox);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdViewRefresh, !normalModeActive);
+        aMenuPane->SetItemDimmed(EFileBrowserCmdViewFilterEntries, emptyListBox);
+	    }
+
+	else if (aResourceId == R_FILEBROWSER_VIEW_SORT_SUBMENU)
+	    {
+        aMenuPane->SetItemButtonState(iModel->FileUtils()->SortMode(), EEikMenuItemSymbolOn);
+	    }
+
+	else if (aResourceId == R_FILEBROWSER_VIEW_ORDER_SUBMENU)
+	    {
+        aMenuPane->SetItemButtonState(iModel->FileUtils()->OrderMode(), EEikMenuItemSymbolOn);
+	    }
+
+	else if (aResourceId == R_FILEBROWSER_TOOLS_SUBMENU)
+	    {
+	    TBool noLocalCon = !iModel->FileUtils()->FileExists(KIRAppPath) && !iModel->FileUtils()->FileExists(KBTAppPath) && !iModel->FileUtils()->FileExists(KUSBAppPath);
+	    
+        aMenuPane->SetItemDimmed(EFileBrowserCmdToolsDisableExtErrors, !iModel->FileUtils()->FileExists(KErrRdPath));
+        aMenuPane->SetItemDimmed(EFileBrowserCmdToolsEnableExtErrors, iModel->FileUtils()->FileExists(KErrRdPath));
+        aMenuPane->SetItemDimmed(EFileBrowserCmdToolsLocalConnectivity, noLocalCon);
+	    }
+
+	else if (aResourceId == R_FILEBROWSER_TOOLS_LOCALCONNECTIVITY_SUBMENU)
+	    {
+        aMenuPane->SetItemDimmed(EFileBrowserCmdToolsLocalConnectivityActivateInfrared, !iModel->FileUtils()->FileExists(KIRAppPath));
+        aMenuPane->SetItemDimmed(EFileBrowserCmdToolsLocalConnectivityLaunchBTUI, !iModel->FileUtils()->FileExists(KBTAppPath));
+        aMenuPane->SetItemDimmed(EFileBrowserCmdToolsLocalConnectivityLaunchUSBUI, !iModel->FileUtils()->FileExists(KUSBAppPath));
+	    }	    
+    else
+        {
+        AppUi()->DynInitMenuPaneL(aResourceId, aMenuPane);
+        }
+    }
+
+// ---------------------------------------------------------
+// CFileBrowserFileListView::MrccatoCommand(TRemConCoreApiOperationId aOperationId, TRemConCoreApiButtonAction aButtonAct)
+// Used to handle multimedia keys
+// ---------------------------------------------------------
+//
+
+void CFileBrowserFileListView::MrccatoCommand(TRemConCoreApiOperationId aOperationId, TRemConCoreApiButtonAction /*aButtonAct*/)
+    {
+    switch(aOperationId)
+        {
+        case ERemConCoreApiVolumeUp:
+            {
+            // simulate a keyevent, so that it can be handled as all other key events
+            TKeyEvent keyEvent;
+            keyEvent.iCode = EKeyIncVolume;
+            keyEvent.iScanCode = 0;
+            keyEvent.iModifiers = 0;
+            keyEvent.iRepeats = 0;
+            
+            //TRAP_IGNORE( iContainer->OfferKeyEventL(keyEvent, EEventKey) );
+            
+            //RWsSession& wsSession=iCoeEnv->WsSession();
+            //wsSession.SimulateKeyEvent(keyEvent);
+            //wsSession.Flush();
+
+            iCoeEnv->SimulateKeyEventL(keyEvent,EEventKeyDown);
+            iCoeEnv->SimulateKeyEventL(keyEvent,EEventKey);
+            iCoeEnv->SimulateKeyEventL(keyEvent,EEventKeyUp);
+            
+            break;
+            }
+        case ERemConCoreApiVolumeDown:
+            {
+            // simulate a keyevent, so that it can be handled as all other key events
+            TKeyEvent keyEvent;
+            keyEvent.iCode = EKeyDecVolume;
+            keyEvent.iScanCode = 0;
+            keyEvent.iModifiers = 0;
+            keyEvent.iRepeats = 0;
+                        
+            //TRAP_IGNORE( iContainer->OfferKeyEventL(keyEvent, EEventKey) );
+            
+            //RWsSession& wsSession=iCoeEnv->WsSession();
+            //wsSession.SimulateKeyEvent(keyEvent);
+            //wsSession.Flush();
+            
+            iCoeEnv->SimulateKeyEventL(keyEvent,EEventKeyDown);
+            iCoeEnv->SimulateKeyEventL(keyEvent,EEventKey);
+            iCoeEnv->SimulateKeyEventL(keyEvent,EEventKeyUp);
+            
+            break;
+            }
+        }
+    }
+
+  
+// ---------------------------------------------------------
+// CFileBrowserFileListView::HandleCommandL(TInt aCommand)
+// ?implementation_description
+// ---------------------------------------------------------
+//
+void CFileBrowserFileListView::HandleCommandL(TInt aCommand)
+    {   
+    switch ( aCommand )
+        {
+
+        case EFileBrowserCmdFileBack:
+            {
+            iModel->FileUtils()->MoveUpOneLevelL();
+            break;
+            }
+                    
+        case EFileBrowserCmdFileOpenApparc:
+            {
+            iModel->FileUtils()->OpenWithApparcL();
+            break;
+            }
+
+        case EFileBrowserCmdFileOpenDocHandlerEmbed:
+            {
+            iModel->FileUtils()->OpenWithDocHandlerL(ETrue);
+            break;
+            }
+
+        case EFileBrowserCmdFileOpenDocHandlerStandAlone:
+            {
+            iModel->FileUtils()->OpenWithDocHandlerL(EFalse);
+            break;
+            }
+
+        case EFileBrowserCmdFileOpenFileService:
+            {
+            iModel->FileUtils()->OpenWithFileServiceL();
+            break;
+            }
+            
+        case EFileBrowserCmdFileOpenDrive:
+        case EFileBrowserCmdFileOpenDirectory:
+            {
+            iModel->FileUtils()->MoveDownToDirectoryL();
+            break;
+            }
+
+        case EFileBrowserCmdFileViewText:
+        case EFileBrowserCmdFileViewHex:
+        case EFileBrowserCmdFileEditText:
+        case EFileBrowserCmdFileEditHex:
+            {
+            iModel->FileUtils()->FileEditorL(aCommand);
+            break;
+            }
+
+        case EFileBrowserCmdFileSearch:
+            {
+            iModel->FileListContainer()->HideToolbar();
+            iModel->FileUtils()->SearchL();
+            break;
+            }
+
+        case EFileBrowserCmdFileSendTo:
+            {
+            iModel->FileUtils()->SendToL();
+            break;
+            }
+
+        case EFileBrowserCmdFileNewFile:
+            {
+            iModel->FileUtils()->NewFileL();
+            break;
+            }
+
+        case EFileBrowserCmdFileNewDirectory:
+            {
+            iModel->FileUtils()->NewDirectoryL();
+            break;
+            }
+
+        case EFileBrowserCmdFileDelete:
+            {
+            iModel->FileUtils()->DeleteL();
+            break;
+            }
+
+        case EFileBrowserCmdFileRename:
+            {
+            iModel->FileUtils()->RenameL();
+            break;
+            }
+
+        case EFileBrowserCmdFileTouch:
+            {
+            iModel->FileUtils()->TouchL();
+            break;
+            }
+
+        case EFileBrowserCmdFileProperties:
+            {
+            iModel->FileUtils()->PropertiesL();
+            break;
+            }
+
+        case EFileBrowserCmdFileChecksumsMD5:
+        case EFileBrowserCmdFileChecksumsMD2:
+        case EFileBrowserCmdFileChecksumsSHA1:
+            {
+            iModel->FileUtils()->ShowFileCheckSumsL(aCommand);
+            break;
+            }
+            
+        case EFileBrowserCmdFileSetAttributes:
+            {
+            iModel->FileListContainer()->HideToolbar();
+            iModel->FileUtils()->SetAttributesL();
+            break;
+            }
+
+        case EFileBrowserCmdFileCompress:
+            {
+            iModel->FileUtils()->CompressL();
+            break;
+            }
+
+        case EFileBrowserCmdFileDecompress:
+            {
+            iModel->FileUtils()->DecompressL();
+            break;
+            }
+///        
+        case EFileBrowserCmdSnapShot:
+            {
+            iModel->FileUtils()->DriveSnapShotL();
+            break;
+            }
+            
+        case EFileBrowserCmdEditCut:
+            {
+            iModel->FileUtils()->ClipboardCutL();
+            break;
+            }
+
+        case EFileBrowserCmdEditCopy:
+            {
+            iModel->FileUtils()->ClipboardCopyL();
+            break;
+            }
+
+        case EFileBrowserCmdEditPaste:
+            {
+            iModel->FileUtils()->ClipboardPasteL();
+            break;
+            }
+
+        case EFileBrowserCmdEditCopyToFolder:
+            {
+            iModel->FileUtils()->CopyToFolderL();
+            break;
+            }
+
+        case EFileBrowserCmdEditMoveToFolder:
+            {
+            iModel->FileUtils()->CopyToFolderL(ETrue);
+            break;
+            }            
+
+        case EFileBrowserCmdEditSelect:
+            {
+            iModel->FileListContainer()->UpdateToolbar();
+            AknSelectionService::HandleMarkableListProcessCommandL( EAknCmdMark, iContainer->ListBox() );
+            break;
+            }
+
+        case EFileBrowserCmdEditUnselect:
+            {
+            iModel->FileListContainer()->UpdateToolbar();
+            AknSelectionService::HandleMarkableListProcessCommandL( EAknCmdUnmark, iContainer->ListBox() );
+            break;
+            }
+
+        case EFileBrowserCmdEditSelectAll:
+            {
+            iModel->FileListContainer()->UpdateToolbar();
+            AknSelectionService::HandleMarkableListProcessCommandL( EAknMarkAll, iContainer->ListBox() );
+            break;
+            }
+            
+        case EFileBrowserCmdEditUnselectAll:
+            {
+            iModel->FileListContainer()->UpdateToolbar();
+            AknSelectionService::HandleMarkableListProcessCommandL( EAknUnmarkAll, iContainer->ListBox() );
+            break;
+            }
+///
+        case EFileBrowserCmdViewSortByName:
+        case EFileBrowserCmdViewSortByExtension:
+        case EFileBrowserCmdViewSortByDate:
+        case EFileBrowserCmdViewSortBySize:
+            {
+            iModel->FileUtils()->SetSortModeL(aCommand);
+            break;
+            }
+
+        case EFileBrowserCmdViewOrderAscending:
+        case EFileBrowserCmdViewOrderDescending:
+            {
+            iModel->FileUtils()->SetOrderModeL(aCommand);
+            break;
+            }
+	
+        case EFileBrowserCmdViewFilterEntries:
+            {
+            iContainer->EnableSearchFieldL();
+            break;
+            }
+
+        case EFileBrowserCmdViewRefresh:
+            {
+            iModel->FileUtils()->RefreshViewL();
+            break;
+            }
+///
+        case EFileBrowserCmdDiskAdminSetDrivePassword:
+            {
+            iModel->FileUtils()->SetDrivePasswordL();
+            break;
+            }
+
+        case EFileBrowserCmdDiskAdminUnlockDrive:
+            {
+            iModel->FileUtils()->UnlockDriveL();
+            break;
+            }
+
+        case EFileBrowserCmdDiskAdminClearDrivePassword:
+            {
+            iModel->FileUtils()->ClearDrivePasswordL();
+            break;
+            }
+
+        case EFileBrowserCmdDiskAdminEraseDrivePassword:
+            {
+            iModel->FileUtils()->EraseDrivePasswordL();
+            break;
+            }
+
+        case EFileBrowserCmdDiskAdminFormatDrive:
+            {
+            iModel->FileUtils()->FormatDriveL(EFalse);
+            break;
+            }
+
+        case EFileBrowserCmdDiskAdminQuickFormatDrive:
+            {
+            iModel->FileUtils()->FormatDriveL(ETrue);
+            break;
+            }
+
+        case EFileBrowserCmdDiskAdminCheckDisk:
+            {
+            iModel->FileUtils()->CheckDiskL();
+            break;
+            }
+
+        case EFileBrowserCmdDiskAdminScanDrive:
+            {
+            iModel->FileUtils()->ScanDriveL();
+            break;
+            }
+
+        case EFileBrowserCmdDiskAdminSetDriveName:
+            {
+            iModel->FileUtils()->SetDriveNameL();
+            break;
+            }
+
+        case EFileBrowserCmdDiskAdminSetDriveVolumeLabel:
+            {
+            iModel->FileUtils()->SetDriveVolumeLabelL();
+            break;
+            }
+
+        case EFileBrowserCmdDiskAdminEjectDrive:
+            {
+            iModel->FileUtils()->EjectDriveL();
+            break;
+            }
+            
+        case EFileBrowserCmdDiskAdminDismountFileSystem:
+            {
+            iModel->FileUtils()->DismountFileSystemL();
+            break;
+            }
+            
+        case EFileBrowserCmdDiskAdminEraseMBR:
+            {
+            iModel->FileUtils()->EraseMBRL();
+            break;
+            }
+            
+        case EFileBrowserCmdDiskAdminDrivePartition:
+            {
+            iModel->FileUtils()->PartitionDriveL();
+            break;
+            }
+
+///
+        case EFileBrowserCmdToolsAllFiles:
+            {
+            iModel->FileUtils()->WriteAllFilesL();
+            break;
+            }
+
+        case EFileBrowserCmdToolsAvkonIconCacheEnable:
+            {
+            iModel->FileUtils()->EnableAvkonIconCacheL(ETrue);
+            break;
+            }
+
+        case EFileBrowserCmdToolsAvkonIconCacheDisable:
+            {
+            iModel->FileUtils()->EnableAvkonIconCacheL(EFalse);
+            break;
+            }
+
+        case EFileBrowserCmdToolsEditDataTypes:
+            {
+            iModel->FileUtils()->EditDataTypesL();
+            break;
+            }
+                        
+        case EFileBrowserCmdToolsDisableExtErrors:
+            {
+            iModel->FileUtils()->SetErrRdL(EFalse);
+            break;
+            }
+
+        case EFileBrowserCmdToolsEnableExtErrors:
+            {
+            iModel->FileUtils()->SetErrRdL(ETrue);
+            break;
+            }
+
+        case EFileBrowserCmdToolsErrorSimulateLeave:
+            {
+            iModel->FileUtils()->SimulateLeaveL();
+            break;
+            }
+
+        case EFileBrowserCmdToolsErrorSimulatePanic:
+            {
+            iModel->FileUtils()->SimulatePanicL();
+            break;
+            }
+        
+       case EFileBrowserCmdToolsErrorSimulateException:
+            {
+            iModel->FileUtils()->SimulateExceptionL();
+            break;
+            }
+                            
+        case EFileBrowserCmdToolsLocalConnectivityActivateInfrared:
+            {
+            iModel->FileUtils()->LaunchProgramL(KIRAppPath);
+            break;
+            }
+
+        case EFileBrowserCmdToolsLocalConnectivityLaunchBTUI:
+            {
+            iModel->FileUtils()->LaunchProgramL(KBTAppPath);
+            break;
+            }
+
+        case EFileBrowserCmdToolsLocalConnectivityLaunchUSBUI:
+            {
+            iModel->FileUtils()->LaunchProgramL(KUSBAppPath);
+            break;
+            }
+
+        case EFileBrowserCmdToolsInstalledApps:
+            {
+            iModel->FileUtils()->WriteAllAppsL();
+            break;
+            }
+
+        case EFileBrowserCmdToolsOpenFiles:
+            {
+            iModel->FileUtils()->ListOpenFilesL();
+            break;
+            }
+
+        case EFileBrowserCmdToolsSetDebugMask:
+            {
+            iModel->FileUtils()->SetDebugMaskL();
+            break;
+            }
+            
+        case EFileBrowserCmdToolsMsgAttachmentsInbox:
+        case EFileBrowserCmdToolsMsgAttachmentsDrafts:
+        case EFileBrowserCmdToolsMsgAttachmentsSentItems:
+        case EFileBrowserCmdToolsMsgAttachmentsOutbox:
+            {
+            iModel->FileUtils()->ListMessageAttachmentsL(aCommand);
+            break;
+            }
+
+        case EFileBrowserCmdToolsMsgStoreWalk:
+            {
+            iModel->FileUtils()->WriteMsgStoreWalkL();
+            break;
+            }
+
+        case EFileBrowserCmdToolsMemoryInfo:
+            {
+            iModel->FileUtils()->MemoryInfoPopupL();
+            break;
+            }
+
+        case EFileBrowserCmdToolsSecureBackupStartBackup:
+        case EFileBrowserCmdToolsSecureBackupStartRestore:
+        case EFileBrowserCmdToolsSecureBackupStop:
+            {
+            iModel->FileUtils()->SecureBackupL(aCommand);
+            break;
+            }
+
+///
+        case EFileBrowserCmdSettings:
+            {
+            if (iModel->LaunchSettingsDialogL() == EAknCmdExit)
+                AppUi()->HandleCommandL( EEikCmdExit );
+            break;
+            }
+
+        case EFileBrowserCmdAbout:
+            {
+	        CAknMessageQueryDialog* dialog = new(ELeave) CAknMessageQueryDialog;
+            dialog->ExecuteLD(R_FILEBROWSER_ABOUT_DIALOG);
+            }
+            break;
+ 
+         case EAknSoftkeyCancel:
+            {
+            iContainer->DisableSearchFieldL();
+            break;
+            }
+                   
+        case EAknSoftkeyExit:
+            {
+            AppUi()->HandleCommandL( EEikCmdExit );
+            break;
+            }
+
+        default:
+            {
+            AppUi()->HandleCommandL( aCommand );
+            break;
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CFileBrowserFileListView::HandleClientRectChange()
+// ---------------------------------------------------------
+//
+void CFileBrowserFileListView::HandleClientRectChange()
+    {
+    if ( iContainer )
+        {
+        iContainer->SetRect( ClientRect() );
+        }
+    }
+
+// ---------------------------------------------------------
+// CFileBrowserFileListView::DoActivateL(...)
+// ?implementation_description
+// ---------------------------------------------------------
+//
+void CFileBrowserFileListView::DoActivateL(
+   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
+   const TDesC8& /*aCustomMessage*/)
+    {
+    if (!iContainer)
+        {
+        iContainer = new (ELeave) CFileBrowserFileListContainer;
+        iContainer->SetMopParent(this);
+        iContainer->ConstructL( ClientRect() );
+        AppUi()->AddToStackL( *this, iContainer );
+        } 
+   }
+
+// ---------------------------------------------------------
+// CFileBrowserFileListView::HandleCommandL(TInt aCommand)
+// ?implementation_description
+// ---------------------------------------------------------
+//
+void CFileBrowserFileListView::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/filebrowser/src/FBFileOps.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,1158 @@
+/*
+* 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 "FBFileOps.h"
+#include "FBFileUtils.h"
+#include "FBModel.h"
+#include "FBTraces.h"
+
+#ifndef FILEBROWSER_LITE
+  #include "FBFileOpClient.h"
+#endif  
+
+#include <f32file.h>
+#include <bautils.h>
+#include <eikenv.h>
+#include <babackup.h>
+
+const TInt KSecureBackupStartDelay = 750000;
+const TInt KSecureBackupLoopDelay = 100000;
+const TInt KSecureBackupEndDelay = 200000;
+const TInt KMaxFileLockAttempts = 3;
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+CFileBrowserFileOps* CFileBrowserFileOps::NewL(CFileBrowserModel* aModel)
+	{
+	CFileBrowserFileOps* self = new(ELeave) CFileBrowserFileOps(aModel);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop();
+	return self;
+	}
+
+// --------------------------------------------------------------------------------------------
+
+CFileBrowserFileOps::CFileBrowserFileOps(CFileBrowserModel* aModel) : iModel(aModel)
+	{
+	}
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileOps::ConstructL()
+	{
+	iRecursiveState = EFileOpInvalid;
+	iSecureBackUpActive = EFalse;
+	iFileCommandActivatedSecureBackup = EFalse;
+	
+    User::LeaveIfError(iFs.Connect());
+    iFileMan = CFileMan::NewL( iFs, this );
+	}
+
+// --------------------------------------------------------------------------------------------
+
+CFileBrowserFileOps::~CFileBrowserFileOps()
+	{
+	if (iSBEClient)
+	    delete iSBEClient;
+	
+    #ifndef FILEBROWSER_LITE	
+        if (iFileOpClient)
+            delete iFileOpClient;
+    #endif	
+
+    delete iFileMan;
+    iFs.Close();    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileOps::ActivateSecureBackUpViaFileOp()
+    {
+    iFileManObserverResult = MFileManObserver::EContinue;
+    // if already activate by a file command, return ok
+    if (iFileCommandActivatedSecureBackup)
+        return KErrNone;
+    else
+        {
+        // if secure backup is already active, disable it first, because it may in wrong state
+        if (iSecureBackUpActive)
+            DeActivateSecureBackUp();
+        }
+    
+    // try to activate full secure backup
+    TInt err = ActivateSecureBackUp(conn::EBURBackupFull, conn::EBackupBase);
+    
+    if (err == KErrNone)
+        iFileCommandActivatedSecureBackup = ETrue;
+    
+    return err;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileOps::DeActivateSecureBackUpViaFileOp()
+    {
+    TInt err(KErrGeneral);
+    iFileManObserverResult = MFileManObserver::EContinue;
+    
+    // if activate by a file command, try to reactivate it
+    if (iFileCommandActivatedSecureBackup)
+        {
+        err = DeActivateSecureBackUp();
+        
+        // even if it fails, forget the state
+        iFileCommandActivatedSecureBackup = EFalse;
+        }
+
+    return err;
+    }    
+    
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileOps::ActivateSecureBackUp(conn::TBURPartType aPartType, conn::TBackupIncType aBackupIncType)
+    {
+    iFileManObserverResult = MFileManObserver::EContinue;
+    // check for invalid parameters
+    if (aPartType == conn::EBURNormal || aBackupIncType == conn::ENoBackup)
+        User::Panic(_L("Inv.Usage.SE"), 532);
+    
+    TInt err(KErrNone);
+    
+    if (!iSBEClient)
+        {
+        TRAP(err, iSBEClient = conn::CSBEClient::NewL());
+        if (err != KErrNone)
+            return err;
+        }
+    
+    TDriveList driveList;
+    err = iFs.DriveList(driveList);
+    
+    if (err == KErrNone)
+        {
+        // make sure that the application has a system status to prevent getting shut down events
+        iModel->EikonEnv()->SetSystem(ETrue);
+    
+        // activating secure back up removes locks from files which respect this fuctionality                
+        TRAP(err, iSBEClient->SetBURModeL(driveList, aPartType, aBackupIncType));
+        
+        if (err == KErrNone)
+            {
+            iSecureBackUpActive = ETrue;
+            User::After(KSecureBackupStartDelay); // a short delay to wait to activate
+            }
+        }
+
+    return err;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileOps::DeActivateSecureBackUp()
+    {
+    TInt err(KErrNone);
+    
+    if (!iSBEClient)
+        {
+        TRAP(err, iSBEClient = conn::CSBEClient::NewL());
+        if (err != KErrNone)
+            return err;
+        
+        // make sure that the application has a system status
+        iModel->EikonEnv()->SetSystem(ETrue);
+        }
+        
+    TDriveList driveList;
+    err = iFs.DriveList(driveList);
+    
+    if (err == KErrNone)
+        {
+        // deactivate secure backup
+        TRAP(err, iSBEClient->SetBURModeL(driveList, conn::EBURNormal, conn::ENoBackup));
+        
+        User::After(KSecureBackupEndDelay); // a short delay to wait to deactivate
+
+        // system status not needed anymore
+        iModel->EikonEnv()->SetSystem(EFalse);
+        }
+    
+    iSecureBackUpActive = EFalse;
+
+    return err;
+    }
+        
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileOps::DoFindEntries(const TDesC& aFileName, const TDesC& aPath)
+    {
+    TFindFile fileFinder(iFs);
+    CDir* dir;
+    TInt err = fileFinder.FindWildByPath(aFileName, &aPath, dir);
+
+    while (err == KErrNone && iFileManObserverResult != MFileManObserver::ECancel)
+        {
+        for (TInt i=0; i<dir->Count(); i++)
+            {
+            TEntry entry = (*dir)[i];
+
+            if (entry.iName.Length() && aPath.Length())
+                {
+                // parse the entry
+                TParse parsedName;
+                parsedName.Set(entry.iName, &fileFinder.File(), NULL);
+                
+                if (parsedName.Drive().Length() && aPath.Length() && parsedName.Drive()[0] == aPath[0])
+                    {
+                    // get full source path
+                    TFileName fullSourcePath = parsedName.FullName();
+                    if (entry.IsDir())
+                        fullSourcePath.Append(_L("\\"));
+                    
+                    // call the file operation command
+                    switch(iRecursiveState)
+                        {
+                        case EFileOpAttribs:
+                            {
+                            // the same attribs command can be given for both directories and files
+                            FileOpAttribs(fullSourcePath, iUint1, iUint2, iTime1, iUint3);
+                            }
+                            break;
+
+                        case EFileOpCopy:
+                            {
+                            // calculate length of new entries added to the original source path
+                            TUint newEntriesLength = fullSourcePath.Length() - iBuf1.Length();
+                            
+                            // get pointer description to the rightmost data
+                            TPtr16 newEntriesPtr = fullSourcePath.RightTPtr(newEntriesLength);
+                            
+                            // generate target path
+                            TFileName fullTargetPath = iBuf2;
+                            fullTargetPath.Append(newEntriesPtr);
+                            
+                            if (entry.IsDir())
+                                {
+                                // if it is a directory entry, just create it based on the entry's attributes
+                                FileOpMkDirAll(fullTargetPath, entry.iAtt);
+                                }
+                            else
+                                {
+                                // otherwise copy the file
+                                FileOpCopy(fullSourcePath, fullTargetPath, iUint1);
+                                }
+                            }
+                            break;
+
+                        case EFileOpDelete:
+                            {
+                            if (entry.IsDir())
+                                {
+                                // for directories call rmdir    
+                                FileOpRmDir(fullSourcePath, iUint1);
+                                }
+                            else
+                                {
+                                // for files call the normal file deletion operation    
+                                FileOpDeleteFile(fullSourcePath, iUint1);
+                                }
+                            }
+                            break;
+                                                    
+                        default:
+                            User::Panic (_L("FileOpRecurs"), 775);
+                            break;
+                        }                        
+                    }
+                }
+                if ( iFileManObserverResult == MFileManObserver::ECancel ) break;
+            }
+
+        delete dir;
+        dir = NULL;
+        if ( iFileManObserverResult != MFileManObserver::ECancel )
+            {
+            err = fileFinder.FindWild(dir);
+            }
+        }
+
+    return err;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileOps::DoFindEntriesRecursiveL(const TDesC& aFileName, const TDesC& aPath)
+	{
+    TInt err(KErrNone);
+
+    // it is logical to scan upwards when deleting and changing attributes
+    CDirScan::TScanDirection scanDirection = CDirScan::EScanUpTree;
+    
+    // when copying files, it is more logical to move downwards
+    if (iRecursiveState == EFileOpCopy)
+        scanDirection = CDirScan::EScanDownTree;
+    
+    
+    CDirScan* scan = CDirScan::NewLC(iFs);
+    scan->SetScanDataL(aPath, KEntryAttDir|KEntryAttMatchMask, ESortByName | EAscending | EDirsFirst, scanDirection);
+    CDir* dir = NULL;
+
+    for(;;)
+        {
+        TRAP(err, scan->NextL(dir));
+        if (!dir  || (err != KErrNone))
+            break;
+
+        for (TInt i=0; i<dir->Count(); i++)
+            {
+            TEntry entry = (*dir)[i];
+            
+            if (entry.IsDir())
+                {
+                TFileName path(scan->FullPath());
+                
+                if (path.Length())
+                    {
+                    path.Append(entry.iName);
+                    path.Append(_L("\\"));
+                    DoFindEntries(aFileName, path);
+                    }
+                }
+            if ( iFileManObserverResult == MFileManObserver::ECancel )
+                {
+                break;
+                }
+            }
+        delete(dir);
+        if ( iFileManObserverResult == MFileManObserver::ECancel )
+            {
+            break;
+            }
+        }
+
+    CleanupStack::PopAndDestroy(scan);
+    return err;
+    }
+    
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileOps::Copy(const TFileEntry& aSourceEntry, const TDesC& aTargetFullName, TUint aSwitch, TBool aDeleteSource) 
+    {
+    iOperationError = KErrNone;
+    iFileManObserverResult = MFileManObserver::EContinue;
+    
+    TFileName sourcePath = aSourceEntry.iPath;
+    sourcePath.Append(aSourceEntry.iEntry.iName);
+    
+    TInt err(KErrNone);
+
+    if (aSourceEntry.iEntry.IsDir() && (aSwitch & CFileMan::ERecurse))
+        {
+        // find all files recursively and run the operation for them
+        iRecursiveState = EFileOpCopy;
+        sourcePath.Append(_L("\\"));
+        
+        TFileName targetPath = aTargetFullName;
+        targetPath.Append(_L("\\"));
+        
+        // remove the recursion flag because we will implement our own recursion
+        TUint newSwitch(aSwitch);
+        newSwitch &= ~CFileMan::ERecurse;
+    
+        iBuf1.Copy(sourcePath);
+        iBuf2.Copy(targetPath);
+        iUint1 = newSwitch;
+        
+        // create initial directory - if it does not succeed, do not even try to continue
+        err = FileOpMkDirAll(targetPath, aSourceEntry.iEntry.iAtt);
+        
+        if (iOperationError == KErrNone)
+            {
+            TRAP(err, DoFindEntries(_L("*"), sourcePath));              // entries under current directory entry
+            if ( iFileManObserverResult != MFileManObserver::ECancel )
+                {
+                TRAP(err, DoFindEntriesRecursiveL(_L("*"), sourcePath));    // recursively under directories of current directory entry
+                }
+            }
+        }
+
+    else if (aSourceEntry.iEntry.IsDir())
+        {
+        TFileName targetPath = aTargetFullName;
+        targetPath.Append(_L("\\"));
+        
+        // just create a directory based on the file attributes of the source directory
+        err = FileOpMkDirAll(targetPath, aSourceEntry.iEntry.iAtt);
+        }
+        
+    else
+        {
+        // remove a recursion flag if present (this should never happen, but some extra error checking)
+        if (aSwitch & CFileMan::ERecurse)
+            aSwitch &= ~CFileMan::ERecurse;    
+            
+        // do the operation for a file entry
+        err = FileOpCopy(sourcePath, aTargetFullName, aSwitch);
+        }
+    
+        
+    // delete source if needed and copy succeeded without any errors (== move operation)
+    if ( aDeleteSource && iOperationError == KErrNone &&
+         iFileManObserverResult != MFileManObserver::ECancel )
+        {
+        err = Delete(aSourceEntry, aSwitch);    
+        }
+    
+    if ( !iOperationError && iFileManObserverResult == MFileManObserver::ECancel )
+        {
+        iOperationError = KErrCancel;
+        }
+        
+    return iOperationError; 
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileOps::FileOpCopy(const TDesC& aSourceFullName, const TDesC& aTargetFullName, TUint aSwitch) 
+    {
+    TInt err = DoFileOpCopy(aSourceFullName, aTargetFullName, aSwitch);
+
+    // if locked, unlock the file and retry
+    if (iModel->Settings().iRemoveFileLocks && err == KErrInUse)
+        {
+        // try to remove the file lock by activating secure backup mode
+        if (ActivateSecureBackUpViaFileOp() == KErrNone)
+            {
+            // try the operation several times
+            for (TInt i=0; i<KMaxFileLockAttempts; i++)
+                {
+                err = DoFileOpCopy(aSourceFullName, aTargetFullName, aSwitch);
+                
+                if (err != KErrInUse)
+                    break;
+                else
+                    User::After(KSecureBackupLoopDelay);
+                }
+            }
+        }
+
+    // if access denied, then try to remove the target path and try again
+    if (iModel->Settings().iIgnoreProtectionsAtts && err == KErrAccessDenied && BaflUtils::FileExists(iFs, aTargetFullName))
+        {
+        if (FileOpDeleteFile(aTargetFullName, 0) == KErrNone)
+            {
+            err = DoFileOpCopy(aSourceFullName, aTargetFullName, aSwitch);
+            }
+        }
+
+    // if the file already exists, it is not an error    
+    if (err == KErrAlreadyExists)
+        err = KErrNone;
+    
+    
+    // if copying from a ROM drive, remove the writing protection flag
+    if (iModel->Settings().iRemoveROMWriteProrection && err == KErrNone && aSourceFullName.Length() > 3 && (aSourceFullName[0]=='z' || aSourceFullName[0]=='Z'))
+        {
+        FileOpAttribs(aTargetFullName, 0, KEntryAttReadOnly, 0, 0);
+        }
+    
+    
+    // remember the "lowest" error
+    if (err < iOperationError)
+        iOperationError = err;
+
+    LOGSTRING4("FileBrowser: FileOpCopy %S -> %S, err=%d", &aSourceFullName, &aTargetFullName, err);
+        
+    return err; 
+    }
+            
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileOps::DoFileOpCopy(const TDesC& aSourceFullName, const TDesC& aTargetFullName, TUint aSwitch) 
+    {
+    #ifndef FILEBROWSER_LITE
+    if (iModel->Settings().iBypassPlatformSecurity)
+        {
+        if (!iFileOpClient)
+            iFileOpClient = CFBFileOpClient::NewL();   
+            
+        return iFileOpClient->Copy(aSourceFullName, aTargetFullName, aSwitch);
+        }
+    else
+        {
+    #endif
+        CAsyncWaiter* waiter = CAsyncWaiter::NewLC();
+        TInt result = iFileMan->Copy( aSourceFullName, aTargetFullName, aSwitch, waiter->iStatus );
+        waiter->StartAndWait();
+        if ( !result ) result = waiter->Result();
+        CleanupStack::PopAndDestroy( waiter );
+        return result;
+    #ifndef FILEBROWSER_LITE
+        }    
+    #endif
+    }
+
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileOps::Rename(const TFileEntry& aSourceEntry, const TDesC& aNew, TUint aSwitch)
+    {
+    iOperationError = KErrNone;
+    iFileManObserverResult = MFileManObserver::EContinue;
+    
+    TFileName sourcePath = aSourceEntry.iPath;
+    sourcePath.Append(aSourceEntry.iEntry.iName);
+    
+    if (aSourceEntry.iEntry.IsDir())
+        {
+        // do the operation for a directory entry
+        FileOpRename(sourcePath, aNew, aSwitch);
+        }
+    else
+        {
+        // do the operation for a file
+        FileOpRename(sourcePath, aNew, aSwitch);
+        }
+
+    return iOperationError; 
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileOps::FileOpRename(const TDesC& aName, const TDesC& aNew, TUint aSwitch)
+    {
+    TBool setBackROFlag(EFalse);
+
+    TInt err = DoFileOpRename(aName, aNew, aSwitch);
+
+    // if locked, unlock the file and retry
+    if (iModel->Settings().iRemoveFileLocks && err == KErrInUse)
+        {
+        // try to remove the file lock by activating secure backup mode
+        if (ActivateSecureBackUpViaFileOp() == KErrNone)
+            {
+            // try the operation several times
+            for (TInt i=0; i<KMaxFileLockAttempts; i++)
+                {
+                err = DoFileOpRename(aName, aNew, aSwitch);
+                
+                if (err != KErrInUse)
+                    break;
+                else
+                    User::After(KSecureBackupLoopDelay);
+                }
+            }
+        }
+
+    // if write protected, remove protection and retry
+    else if (iModel->Settings().iIgnoreProtectionsAtts && err == KErrAccessDenied)
+        {
+        // remove write protection and try again
+        if (FileOpAttribs(aName, 0, KEntryAttReadOnly, 0, 0) == KErrNone)
+            {
+            err = DoFileOpRename(aName, aNew, aSwitch);
+            
+            setBackROFlag = ETrue;
+            }
+        }
+
+    // if still access denied, then try to remove the target path and try again
+    if (iModel->Settings().iIgnoreProtectionsAtts && err == KErrAccessDenied && BaflUtils::FileExists(iFs, aNew))
+        {
+        if (FileOpDeleteFile(aNew, 0) == KErrNone)
+            {
+            err = DoFileOpRename(aName, aNew, aSwitch);
+            }
+        }
+
+    // set back the read only flag
+    if (setBackROFlag)
+        FileOpAttribs(aName, KEntryAttReadOnly, 0, 0, 0);
+            
+
+    // remember the "lowest" error
+    if (err < iOperationError)
+        iOperationError = err;
+
+    LOGSTRING3("FileBrowser: FileOpRename %S, err=%d", &aName, err);
+        
+    return err; 
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileOps::DoFileOpRename(const TDesC& aName, const TDesC& aNew, TUint aSwitch)
+    {
+    #ifndef FILEBROWSER_LITE
+    if (iModel->Settings().iBypassPlatformSecurity)
+        {
+        if (!iFileOpClient)
+            iFileOpClient = CFBFileOpClient::NewL();   
+
+        return iFileOpClient->Rename(aName, aNew, aSwitch);
+        }
+    else
+        {
+    #endif
+        return iFileMan->Rename(aName, aNew, aSwitch);
+    #ifndef FILEBROWSER_LITE
+        }    
+    #endif
+    }
+
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileOps::Attribs(const TFileEntry& aSourceEntry, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch) 
+    {
+    iOperationError = KErrNone;
+    iFileManObserverResult = MFileManObserver::EContinue;
+    
+    TFileName sourcePath = aSourceEntry.iPath;
+    sourcePath.Append(aSourceEntry.iEntry.iName);
+    
+    TInt err(KErrNone);
+
+    if (aSourceEntry.iEntry.IsDir() && (aSwitch & CFileMan::ERecurse))
+        {
+        // do the operation for a current directory entry
+        err = FileOpAttribs(sourcePath, aSetMask, aClearMask, aTime, 0);
+
+        // find all files recursively and run the operation for them
+        iRecursiveState = EFileOpAttribs;
+        sourcePath.Append(_L("\\"));
+    
+        iBuf1.Copy(sourcePath);
+        iUint1 = aSetMask;
+        iUint2 = aClearMask;
+        iTime1 = aTime;
+        iUint3 = 0;
+        
+        TRAP(err, DoFindEntriesRecursiveL(_L("*"), sourcePath));    // recursively under directories of current directory entry
+        TRAP(err, DoFindEntries(_L("*"), sourcePath));              // entries under current directory entry
+        }
+
+    else if (aSourceEntry.iEntry.IsDir())
+        {
+        //sourcePath.Append(_L("\\"));   // <-- do not apply!
+    
+        // do the operation for a directory entry
+        err = FileOpAttribs(sourcePath, aSetMask, aClearMask, aTime, 0);
+        }
+            
+    else
+        {
+        // do the operation for a file entry
+        err = FileOpAttribs(sourcePath, aSetMask, aClearMask, aTime, 0);
+        }
+
+    return iOperationError;     
+    }
+
+// --------------------------------------------------------------------------------------------
+    
+TInt CFileBrowserFileOps::FileOpAttribs(const TDesC& aName, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch) 
+    {
+    TInt err = DoFileOpAttribs(aName, aSetMask, aClearMask, aTime, aSwitch);
+
+    // if locked, unlock the file and retry
+    if (iModel->Settings().iRemoveFileLocks && err == KErrInUse)
+        {
+        // try to remove the file lock by activating secure backup mode
+        if (ActivateSecureBackUpViaFileOp() == KErrNone)
+            {
+            // try the operation several times
+            for (TInt i=0; i<KMaxFileLockAttempts; i++)
+                {
+                err = DoFileOpAttribs(aName, aSetMask, aClearMask, aTime, aSwitch);
+                
+                if (err != KErrInUse)
+                    break;
+                else
+                    User::After(KSecureBackupLoopDelay);
+                }
+            }
+        }
+
+    // remember the "lowest" error
+    if (err < iOperationError)
+        iOperationError = err;
+
+    LOGSTRING3("FileBrowser: FileOpAttribs %S, err=%d", &aName, err);
+        
+    return err;    
+    }
+    
+// --------------------------------------------------------------------------------------------
+    
+TInt CFileBrowserFileOps::DoFileOpAttribs(const TDesC& aName, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch) 
+    {
+    #ifndef FILEBROWSER_LITE
+    if (iModel->Settings().iBypassPlatformSecurity)
+        {
+        if (!iFileOpClient)
+            iFileOpClient = CFBFileOpClient::NewL();   
+
+        return iFileOpClient->Attribs(aName, aSetMask, aClearMask, aTime, aSwitch);
+        }
+    else
+        {
+    #endif
+        return iFileMan->Attribs(aName, aSetMask, aClearMask, aTime, aSwitch);
+    #ifndef FILEBROWSER_LITE
+        }    
+    #endif
+    }
+
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileOps::Delete(const TFileEntry& aSourceEntry, TUint aSwitch) 
+    {
+    iOperationError = KErrNone;
+    iFileManObserverResult = MFileManObserver::EContinue;
+    
+    TFileName sourcePath = aSourceEntry.iPath;
+    sourcePath.Append(aSourceEntry.iEntry.iName);
+    
+    TInt err(KErrNone);
+
+    if (aSourceEntry.iEntry.IsDir() && (aSwitch & CFileMan::ERecurse))
+        {
+        // find all files recursively and run the operation for them
+        iRecursiveState = EFileOpDelete;
+        sourcePath.Append(_L("\\"));
+    
+        iBuf1.Copy(sourcePath);
+        iUint1 = 0;
+        
+        TRAP(err, DoFindEntriesRecursiveL(_L("*"), sourcePath));    // recursively under directories of current directory entry
+        if ( iFileManObserverResult != MFileManObserver::ECancel )
+            {
+            TRAP(err, DoFindEntries(_L("*"), sourcePath));              // entries under current directory entry
+            }
+        
+        if ( iFileManObserverResult != MFileManObserver::ECancel )
+            {
+            // do the operation for a current directory entry as well
+            err = FileOpRmDir(sourcePath, 0);
+            }
+        }
+
+    else if (aSourceEntry.iEntry.IsDir())
+        {
+        sourcePath.Append(_L("\\"));
+    
+        // do the operation for a directory entry
+        err = FileOpRmDir(sourcePath, 0);
+        }
+
+    else
+        {
+        // do the operation for a file entry
+        err = FileOpDeleteFile(sourcePath, 0);
+        }
+    if ( !iOperationError && iFileManObserverResult == MFileManObserver::ECancel )
+        {
+        iOperationError = KErrCancel;
+        }
+    return iOperationError; 
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileOps::FileOpDeleteFile(const TDesC& aName, TUint aSwitch) 
+    {
+    TInt err = DoFileOpDeleteFile(aName, aSwitch);
+
+    // if locked, unlock the file and retry
+    if (iModel->Settings().iRemoveFileLocks && err == KErrInUse)
+        {
+        // try to remove the file lock by activating secure backup mode
+        if (ActivateSecureBackUpViaFileOp() == KErrNone)
+            {
+            // try the operation several times
+            for (TInt i=0; i<KMaxFileLockAttempts; i++)
+                {
+                err = DoFileOpDeleteFile(aName, aSwitch);
+                
+                if (err != KErrInUse)
+                    break;
+                else
+                    User::After(KSecureBackupLoopDelay);
+                }
+            }
+        }
+
+    // if write protected or system file, remove protections and retry
+    else if (iModel->Settings().iIgnoreProtectionsAtts && (err == KErrAccessDenied || err == KErrNotFound))
+        {
+        // remove protections  and try again
+        if (FileOpAttribs(aName, 0, KEntryAttReadOnly|KEntryAttSystem|KEntryAttHidden, 0, 0) == KErrNone)
+            {
+            err = DoFileOpDeleteFile(aName, aSwitch);
+            }
+        }
+
+    // remember the "lowest" error
+    if (err < iOperationError)
+        iOperationError = err;
+
+    LOGSTRING3("FileBrowser: FileOpDeleteFile %S, err=%d", &aName, err);
+        
+    return err; 
+    }
+        
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileOps::DoFileOpDeleteFile(const TDesC& aName, TUint aSwitch) 
+    {
+    #ifndef FILEBROWSER_LITE
+    if (iModel->Settings().iBypassPlatformSecurity)
+        {
+        if (!iFileOpClient)
+            iFileOpClient = CFBFileOpClient::NewL();   
+
+        return iFileOpClient->Delete(aName, aSwitch);
+        }
+    else
+        {
+    #endif
+        CAsyncWaiter* waiter = CAsyncWaiter::NewLC();
+        TInt result = iFileMan->Delete( aName, aSwitch, waiter->iStatus );
+        waiter->StartAndWait();
+        if ( iFileManObserverResult == MFileManObserver::ECancel ) result = KErrCancel;
+        if ( !result ) result = waiter->Result();
+        CleanupStack::PopAndDestroy( waiter );
+        return result;
+    #ifndef FILEBROWSER_LITE
+        }    
+    #endif
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileOps::FileOpRmDir(const TDesC& aName, TUint aSwitch) 
+    {
+    TInt err = DoFileOpRmDir(aName, aSwitch);
+
+    // if write protected or system directory, remove protections and retry
+    if (iModel->Settings().iIgnoreProtectionsAtts && (err == KErrAccessDenied || err == KErrInUse))
+        {
+        // remove protections and try again
+        if (FileOpAttribs(aName.Left(aName.Length()-1), 0, KEntryAttReadOnly|KEntryAttSystem|KEntryAttHidden, 0, 0) == KErrNone)
+            {
+            err = DoFileOpRmDir(aName, aSwitch);
+            }
+        }
+
+    // remember the "lowest" error
+    if (err < iOperationError)
+        iOperationError = err;
+
+    LOGSTRING3("FileBrowser: FileOpRmDir %S, err=%d", &aName, err);
+        
+    return err; 
+    }
+        
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileOps::DoFileOpRmDir(const TDesC& aDirName, TUint aSwitch)
+    {
+    #ifndef FILEBROWSER_LITE
+    if (iModel->Settings().iBypassPlatformSecurity)
+        {
+        if (!iFileOpClient)
+            iFileOpClient = CFBFileOpClient::NewL();   
+
+        return iFileOpClient->RmDir(aDirName, aSwitch);
+        }
+    else
+        {
+    #endif
+        if ( aSwitch & CFileMan::ERecurse )
+            {
+            CAsyncWaiter* waiter = CAsyncWaiter::NewLC();
+            TInt result = iFileMan->RmDir( aDirName, waiter->iStatus );
+            waiter->StartAndWait();
+            if ( iFileManObserverResult == MFileManObserver::ECancel ) result = KErrCancel;
+            if ( !result ) result = waiter->Result();
+            CleanupStack::PopAndDestroy( waiter);
+            return result;
+            }
+        else
+            return iFs.RmDir(aDirName);    
+    #ifndef FILEBROWSER_LITE
+        }    
+    #endif
+   }
+
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileOps::MkDirAll(const TDesC& aPath, TInt aSetAtts, TBool aQuickOperation) 
+    {
+    iFileManObserverResult = MFileManObserver::EContinue;
+    if (aQuickOperation)
+        return DoFileOpMkDirAll(aPath);
+    else
+        return FileOpMkDirAll(aPath, aSetAtts);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileOps::FileOpMkDirAll(const TDesC& aPath, TInt aSetAtts) 
+    {
+    TInt err = DoFileOpMkDirAll(aPath);
+
+    // if the directory already exists, it is not an error    
+    if (err == KErrAlreadyExists)
+        err = KErrNone;
+    
+    
+    // set attributes for directory just created
+    if (aSetAtts > 0 && err == KErrNone && aPath.Length() > 3)
+        {
+        // a path has a trailing backslash so it needs to be removed before the call
+        err = FileOpAttribs(aPath.Left(aPath.Length()-1), aSetAtts, 0, 0, 0);
+        }
+    
+
+    // remember the "lowest" error
+    if (err < iOperationError)
+        iOperationError = err;
+    
+    LOGSTRING3("FileBrowser: FileOpMkDirAll %S, err=%d", &aPath, err);
+    
+    return err;
+    }
+        
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileOps::DoFileOpMkDirAll(const TDesC& aPath) 
+    {
+    #ifndef FILEBROWSER_LITE
+    if (iModel->Settings().iBypassPlatformSecurity)
+        {
+        if (!iFileOpClient)
+            iFileOpClient = CFBFileOpClient::NewL();   
+
+        return iFileOpClient->MkDirAll(aPath);
+        }
+    else
+        {
+    #endif
+        return iFs.MkDirAll(aPath);
+    #ifndef FILEBROWSER_LITE
+        }    
+    #endif
+    }
+
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileOps::CreateEmptyFile(const TDesC& aName) 
+    {
+    return DoFileOpCreateEmptyFile(aName);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileOps::FileOpCreateEmptyFile(const TDesC& aName) 
+    {
+    TInt err = DoFileOpCreateEmptyFile(aName);
+
+    // remember the "lowest" error
+    if (err < iOperationError)
+        iOperationError = err;
+    
+    LOGSTRING3("FileBrowser: FileOpCreateEmptyFile %S, err=%d", &aName, err);
+    
+    return err;
+    }
+
+// --------------------------------------------------------------------------------------------
+    
+TInt CFileBrowserFileOps::DoFileOpCreateEmptyFile(const TDesC& aName) 
+    {
+    #ifndef FILEBROWSER_LITE
+    if (iModel->Settings().iBypassPlatformSecurity)
+        {
+        if (!iFileOpClient)
+            iFileOpClient = CFBFileOpClient::NewL();   
+
+        return iFileOpClient->CreateEmptyFile(aName);
+        }
+    else
+        {
+    #endif
+        TInt err(KErrNone);
+            
+        RFile newFile;
+        err = newFile.Create(iFs, aName, EFileShareExclusive);
+        if (err == KErrNone)
+            err = newFile.Flush(); 
+        newFile.Close();
+        
+        return err; 
+    #ifndef FILEBROWSER_LITE
+        }    
+    #endif
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileOps::DriveSnapShot(TChar aSourceDriveLetter, TChar aTargetDriveLetter)
+    {
+    TInt err(KErrNone);
+    iFileManObserverResult = MFileManObserver::EContinue;
+    
+    // remember old settings and force them to be true for this operation
+    TBool currentRemoveFileLocksValue = iModel->Settings().iRemoveFileLocks;
+    TBool currentIgnoreProtectionAttsValue = iModel->Settings().iIgnoreProtectionsAtts;
+    TBool currentRemoveROMWriteProrection = iModel->Settings().iRemoveROMWriteProrection;
+    iModel->Settings().iRemoveFileLocks = ETrue;
+    iModel->Settings().iIgnoreProtectionsAtts = ETrue;
+    iModel->Settings().iRemoveROMWriteProrection = ETrue;
+
+    
+    TFileName sourceDir;
+    sourceDir.Append(aSourceDriveLetter);
+    sourceDir.Append(_L(":"));
+
+    _LIT(KTargetDir, "%c:\\SnapShot_%c_drive");
+    TFileName targetDir;
+    targetDir.Format(KTargetDir, TUint(aTargetDriveLetter), TUint(aSourceDriveLetter));            
+
+    // remove any existing content, first get TEntry
+    TEntry entry;
+    err = iFs.Entry(targetDir, entry);
+
+    // entry directory exists, delete it
+    if (err == KErrNone && entry.IsDir())
+        {
+        TFileName targetRoot;
+        targetRoot.Append(aTargetDriveLetter);
+        targetRoot.Append(_L(":\\"));
+
+        TFileEntry targetEntry;
+        targetEntry.iPath = targetRoot;
+        targetEntry.iEntry = entry;
+
+        err = Delete(targetEntry, CFileMan::ERecurse);                
+        }
+        
+    // do not care if removing succeeded or not, just continue with copying    
+    TEntry fakeEntry;
+    fakeEntry.iAtt |= KEntryAttDir;
+
+    TFileEntry sourceEntry;
+    sourceEntry.iPath = sourceDir;
+    sourceEntry.iEntry = fakeEntry;
+
+    err = Copy(sourceEntry, targetDir, CFileMan::ERecurse|CFileMan::EOverWrite);                
+
+
+    // restore back settings
+    iModel->Settings().iRemoveFileLocks = currentRemoveFileLocksValue;
+    iModel->Settings().iIgnoreProtectionsAtts = currentIgnoreProtectionAttsValue;    
+    iModel->Settings().iRemoveROMWriteProrection = currentRemoveROMWriteProrection;    
+
+
+    return iOperationError;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileOps::EraseMBR(TUint aDriveNumber) 
+    {
+    #ifndef FILEBROWSER_LITE
+
+        if (!iFileOpClient)
+            iFileOpClient = CFBFileOpClient::NewL();
+        
+        return iFileOpClient->EraseMBR(aDriveNumber);
+
+    #else
+        return KErrNotSupported;
+    #endif
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileOps::PartitionDrive(TUint aDriveNumber, TUint aNumberOfPartitions) 
+    {
+    #ifndef FILEBROWSER_LITE
+
+        if (!iFileOpClient)
+            iFileOpClient = CFBFileOpClient::NewL();
+        
+        return iFileOpClient->PartitionDrive(aDriveNumber, aNumberOfPartitions);
+
+    #else
+        return KErrNotSupported
+    #endif
+    }
+
+// --------------------------------------------------------------------------------------------
+
+MFileManObserver::TControl CFileBrowserFileOps::NotifyFileManStarted()
+    {
+    return iFileManObserverResult;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+MFileManObserver::TControl CFileBrowserFileOps::NotifyFileManOperation()
+    {
+    return iFileManObserverResult;
+    }
+// --------------------------------------------------------------------------------------------
+
+MFileManObserver::TControl CFileBrowserFileOps::NotifyFileManEnded()
+    {
+    return iFileManObserverResult;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileOps::CancelOp()
+    {
+#ifndef FILEBROWSER_LITE
+
+    if ( iModel->Settings().iBypassPlatformSecurity )
+        {
+        if ( !iFileOpClient )
+            iFileOpClient = CFBFileOpClient::NewL();
+        
+        iFileOpClient->CancelOp();
+        }
+
+    // we need this information even when using iFileOpClient
+    // to be able to not execute aggregate operations 
+    iFileManObserverResult = MFileManObserver::ECancel;
+    
+#else
+    iFileManObserverResult = MFileManObserver::ECancel;
+#endif
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/src/FBFileUtils.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,5147 @@
+/*
+* 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 "FBFileUtils.h"
+#include "FBFileOps.h"
+#include "FBModel.h"
+#include "FBFileDlgs.h"
+#include "FBFileEditor.h"
+#include "FBFileListContainer.h"
+#include "FB.hrh"
+#include <filebrowser.rsg>
+
+#include <textresolver.h> 
+#include <AknWaitDialog.h>
+#include <AknProgressDialog.h>
+#include <eikprogi.h>
+#include <f32file.h>
+#include <eikfutil.h>
+#include <apparc.h>
+#include <eikenv.h>
+#include <bautils.h>
+#include <AknIconArray.h>
+#include <gulicon.h>
+#include <AknsUtils.h>
+#include <AknsItemID.h>
+#include <aknconsts.h>
+#include <aknnotewrappers.h>
+#include <AknProgressDialog.h> 
+#include <aknPopup.h>
+#include <aknmessagequerydialog.h>
+#include <AknGlobalNote.h>
+#include <babackup.h> 
+#include <avkon.mbg>
+#include <aknmemorycardui.mbg>
+#include <sendui.h>
+#include <CMessageData.h>
+#include <ezgzip.h>
+#include <e32hal.h>
+#include <pathinfo.h>
+#include <apgcli.h>
+#include <apmstd.h>
+#include <apgtask.h>
+#include <apacmdln.h>
+#include <DocumentHandler.h>
+#include <AknOpenFileService.h>
+#include <msvapi.h>
+#include <msvids.h>
+#include <msvstd.h>
+#include <msvstore.h>
+#include <mmsvattachmentmanager.h>
+#include <cmsvattachment.h>
+#include <hash.h>
+#include <connect/sbeclient.h>
+#include <e32property.h>
+#if (!defined __SERIES60_30__ && !defined __SERIES60_31__) 
+#include <driveinfo.h>
+#endif // !defined __SERIES60_30__ && !defined __SERIES60_31__
+
+#ifndef __SERIES60_30__
+  #include <akniconconfig.h>
+#endif
+
+_LIT(KGZipExt, ".gz");
+_LIT8(KFileNewLine, "\r\n");
+const TInt KForcedFormatTimeout = 1000000;
+
+// copied from coreapplicationuisdomainpskeys.h
+const TUid KPSUidCoreApplicationUIs = { 0x101F8767 };
+const TUint32 KCoreAppUIsMmcRemovedWithoutEject = 0x00000109;
+enum TCoreAppUIsMmcRemovedWithoutEject
+    {
+    ECoreAppUIsEjectCommandUsedUninitialized = 0,
+    ECoreAppUIsEjectCommandNotUsed,
+    ECoreAppUIsEjectCommandUsed,
+    ECoreAppUIsEjectCommandUsedToDrive // Low 16-bits contain this value and high 16-bits TDriveNumber to eject
+    };
+const TInt KDriveLetterStringLength = 3; // e.g. C:\
+
+// ================= MEMBER FUNCTIONS =======================
+
+CFileBrowserFileUtils* CFileBrowserFileUtils::NewL(CFileBrowserModel* aModel)
+	{
+	CFileBrowserFileUtils* self = new(ELeave) CFileBrowserFileUtils(aModel);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop();
+	return self;
+	}
+
+// --------------------------------------------------------------------------------------------
+
+CFileBrowserFileUtils::CFileBrowserFileUtils(CFileBrowserModel* aModel) : CActive(EPriorityStandard), iModel(aModel)
+	{
+	}
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::ConstructL()
+	{
+    User::LeaveIfError(iTimer.CreateLocal());
+    User::LeaveIfError(iFs.Connect());
+    User::LeaveIfError(iTz.Connect());
+    
+    iState = EIdle;
+    iListingMode = ENormalEntries;
+
+    iSortMode = EFileBrowserCmdViewSortByName;
+    iOrderMode = EFileBrowserCmdViewOrderAscending;
+    iCurrentPath = KNullDesC;
+    
+    iFileOps = CFileBrowserFileOps::NewL(iModel);
+    
+    iDriveEntryList = new(ELeave) CDriveEntryList(8);
+    iFileEntryList = new(ELeave) CFileEntryList(64);
+    iFindFileEntryList = new(ELeave) CFileEntryList(64);
+    iAppIconList = new(ELeave) CAppIconList(16);
+    iClipBoardList = new(ELeave) CFileEntryList(64);
+
+    iDocHandler = CDocumentHandler::NewL();
+    iDocHandler->SetExitObserver(this);
+    
+    // set defaults to the search settings
+    iSearchAttributes.iSearchDir = KNullDesC;
+    iSearchAttributes.iWildCards = _L("*.jpg");
+    iSearchAttributes.iTextInFile = KNullDesC;
+    iSearchAttributes.iMinSize = 0;
+    iSearchAttributes.iMaxSize = 999999999;
+    iSearchAttributes.iMinDate = TDateTime(1980, EJanuary,   0,0,0,0,0);
+    iSearchAttributes.iMaxDate = TDateTime(2060, EDecember, 30,0,0,0,0);
+    iSearchAttributes.iRecurse = ETrue;
+    
+    // init the command array
+    iCommandArray = new(ELeave) CCommandArray(64);
+        
+    // get current path from settings
+    if (iModel->Settings().iRememberLastPath)
+        {
+        TFileName settingPath = iModel->Settings().iLastPath;
+        if (BaflUtils::PathExists(iFs, settingPath))
+            iCurrentPath = settingPath;
+        
+        if (iCurrentPath != KNullDesC)
+            GetDriveListL();
+        }
+
+	CActiveScheduler::Add(this);
+	}
+
+// --------------------------------------------------------------------------------------------
+
+CFileBrowserFileUtils::~CFileBrowserFileUtils()
+	{
+	Cancel();
+	
+	// save current path from settings
+    if (iModel->Settings().iRememberLastPath)
+        {
+        iModel->Settings().iLastPath = iCurrentPath;
+        TRAP_IGNORE(iModel->SaveSettingsL(EFalse));
+        }
+
+    if (iWaitDialog)
+        TRAP_IGNORE(iWaitDialog->ProcessFinishedL()); 
+     
+    if (iProgressDialog)
+        TRAP_IGNORE(iProgressDialog->ProcessFinishedL());
+    
+    delete iFileOps;    
+   
+	delete iDocHandler;
+	
+	if (iOpenFileService)
+	    delete iOpenFileService;
+	
+	delete iClipBoardList;
+	delete iAppIconList;
+	delete iFindFileEntryList;
+    delete iFileEntryList;
+    delete iDriveEntryList;
+    
+    delete iFileMan;
+    
+    if (iCommandArray)
+        {
+        ResetCommandArray();
+        delete iCommandArray;
+        }
+        
+    iTz.Close();
+	iFs.Close();
+	iTimer.Close();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::DoCancel()
+	{
+    iTimer.Cancel();
+	}
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::StartExecutingCommandsL(const TDesC& aLabel)
+    {
+    if (iCommandArray->Count() >= 2)
+        {
+        // init progress bar
+        iProgressDialog = new(ELeave) CAknProgressDialog((reinterpret_cast<CEikDialog**>(&iProgressDialog)), ETrue);
+        iProgressDialog->SetCallback(this);
+        iProgressDialog->PrepareLC(R_GENERAL_PROGRESS_NOTE);
+        iProgressDialog->SetCurrentLabelL( EAknCtNote, aLabel );
+        iProgressInfo = iProgressDialog->GetProgressInfoL();
+        iProgressInfo->SetFinalValue( CommandArrayCount() );
+        iProgressDialog->RunLD();
+        iProgressDialog->MakeVisible( ETrue );        
+        }
+    else if (iCommandArray->Count() >= 1)
+        {
+        // init wait dialog
+        iWaitDialog = new(ELeave) CAknWaitDialog((reinterpret_cast<CEikDialog**>(&iWaitDialog)), ETrue);
+        iWaitDialog->SetCallback(this);
+        iWaitDialog->PrepareLC(R_GENERAL_WAIT_NOTE);
+        iWaitDialog->SetTextL( aLabel );
+        iWaitDialog->RunLD();
+        }
+    else
+        {
+        // no commands, just do nothing
+        return;
+        }
+
+
+    // start with the first operation
+    iCurrentEntry = 0;
+    iSucceededOperations = 0;
+    iFailedOperations = 0;
+
+    // starts executing commands
+    ExecuteCommand();
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::ExecuteCommand()
+    {
+    // make sure the engine isn't active, should never happen
+    __ASSERT_ALWAYS(!IsActive(), User::Panic(_L("FileUtils:IsActive"), 333));
+
+    // execute a command after a very short delay (25ms)
+    iTimer.After(iStatus, 25);
+    SetActive();
+    }
+
+// --------------------------------------------------------------------------------------------
+    
+void CFileBrowserFileUtils::RunL()
+    {
+    TInt err(KErrNone);
+    TInt currentCommand = iCommandArray->At(iCurrentEntry).iCommandId;
+
+    // execute a command from the queue
+    switch(currentCommand)
+        {
+        case EFileBrowserFileOpCommandAttribs:
+            {
+            CCommandParamsAttribs* params = static_cast<CCommandParamsAttribs*>(iCommandArray->At(iCurrentEntry).iParameters);
+            err = iFileOps->Attribs(params->iSourceEntry, params->iSetMask, params->iClearMask, params->iTime, params->iSwitch);
+            }
+            break;
+            
+        case EFileBrowserFileOpCommandCopy:
+            {
+            CCommandParamsCopyOrMove* params = static_cast<CCommandParamsCopyOrMove*>(iCommandArray->At(iCurrentEntry).iParameters);
+            err = iFileOps->Copy(params->iSourceEntry, params->iTargetPath, params->iSwitch);
+            }
+            break;
+            
+        case EFileBrowserFileOpCommandMove:
+            {
+            CCommandParamsCopyOrMove* params = static_cast<CCommandParamsCopyOrMove*>(iCommandArray->At(iCurrentEntry).iParameters);
+            err = iFileOps->Copy(params->iSourceEntry, params->iTargetPath, params->iSwitch, ETrue);
+            }
+            break;
+                
+        case EFileBrowserFileOpCommandRename:
+            {
+            CCommandParamsRename* params = static_cast<CCommandParamsRename*>(iCommandArray->At(iCurrentEntry).iParameters);
+            err = iFileOps->Rename(params->iSourceEntry, params->iTargetPath, params->iSwitch);
+            }
+            break;
+
+        case EFileBrowserFileOpCommandDelete:
+            {
+            CCommandParamsDelete* params = static_cast<CCommandParamsDelete*>(iCommandArray->At(iCurrentEntry).iParameters);
+            err = iFileOps->Delete(params->iSourceEntry, params->iSwitch);
+            }
+            break;
+
+        case EFileBrowserFileOpCommandDriveSnapShot:
+            {
+            CCommandParamsDriveSnapShot* params = static_cast<CCommandParamsDriveSnapShot*>(iCommandArray->At(iCurrentEntry).iParameters);
+            err = iFileOps->DriveSnapShot(params->iSourceDriveLetter, params->iTargetDriveLetter);
+            }
+            break;
+                                                
+        default:
+            User::Panic (_L("Unknown command"), 400);
+            break;
+        }
+
+    
+    if (err == KErrNone)
+        {
+        iSucceededOperations++;
+        }
+    else if ( err != KErrCancel )
+        {
+        iFailedOperations++;
+        }
+        
+    iLastError = err;            
+
+    // check for more commands in queue
+    TRAP_IGNORE( CheckForMoreCommandsL() );
+    }
+
+// ---------------------------------------------------------------------------
+
+TInt CFileBrowserFileUtils::RunError(TInt aError)
+    {
+    _LIT(KMessage, "Command error %d");
+    TBuf<128> noteMsg;
+    noteMsg.Format(KMessage, aError);
+            
+    iModel->EikonEnv()->InfoMsg(noteMsg);
+    
+    TRAP_IGNORE( CheckForMoreCommandsL() );
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::CheckForMoreCommandsL()
+    {
+    //LOGSTRING("Creator: CCreatorEngine::CheckForMoreCommandsL");
+    
+    // update the progress bar
+    if (iProgressInfo)
+        iProgressInfo->IncrementAndDraw(1);
+
+	// check if we have more commands to be executed
+	if (iCurrentEntry >= CommandArrayCount() - 1)
+		{
+        //LOGSTRING("Creator: CCreatorEngine::CheckForMoreCommandsL all done");
+
+        // all done, free resources
+        ResetCommandArray();
+        
+        // deactive secure backup if it was activated by a file command
+        iFileOps->DeActivateSecureBackUpViaFileOp();
+
+        // dismiss any wait/progress dialogs        
+        if (iWaitDialog)
+            {
+            TRAP_IGNORE(iWaitDialog->ProcessFinishedL()); 
+            iWaitDialog = NULL;
+            }
+        if (iProgressDialog)
+            {
+            TRAP_IGNORE(iProgressDialog->ProcessFinishedL());
+            iProgressDialog = NULL;
+            }
+
+
+        // show result note
+        if ( iSucceededOperations == 0 && iFailedOperations == 0 )
+            {
+            // single operation cancelled -> show nothing
+            }
+        else if (iSucceededOperations == 1 && iFailedOperations == 0)    
+            {
+            _LIT(KMessage, "Operation succeeded");
+    		CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+    		note->ExecuteLD(KMessage);
+            }
+        else if (iSucceededOperations > 0 && iFailedOperations == 0)    
+            {
+            _LIT(KMessage, "%d operations succeeded");
+            TBuf<128> noteMsg;
+            noteMsg.Format(KMessage, iSucceededOperations);
+            
+    		CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+    		note->ExecuteLD(noteMsg);
+            }
+        else if (iSucceededOperations == 0 && iFailedOperations > 1)    
+            {
+            _LIT(KMessage, "%d operations failed");
+            TBuf<128> noteMsg;
+            noteMsg.Format(KMessage, iFailedOperations);
+            
+    		CAknErrorNote* note = new(ELeave) CAknErrorNote;
+    		note->ExecuteLD(noteMsg);
+            }
+        else if (iSucceededOperations > 0 && iFailedOperations > 0)    
+            {
+            _LIT(KMessage, "%d operations succeeded, %d failed");
+            TBuf<128> noteMsg;
+            noteMsg.Format(KMessage, iSucceededOperations, iFailedOperations);
+            
+    		CAknInformationNote* note = new(ELeave) CAknInformationNote;
+    		note->ExecuteLD(noteMsg);
+            }
+        else    
+            {
+            CTextResolver* textResolver = CTextResolver::NewLC(*iModel->EikonEnv());     
+                
+            CAknErrorNote* note = new(ELeave) CAknErrorNote;
+            note->ExecuteLD( textResolver->ResolveErrorString(iLastError, CTextResolver::ECtxNoCtxNoSeparator) );    
+
+            CleanupStack::PopAndDestroy();  //textResolver    
+            }
+
+        RefreshViewL();
+
+		}
+	else
+		{
+		// maintain requests
+		iCurrentEntry++;
+
+        //LOGSTRING2("Creator: CCreatorEngine::CheckForMoreCommandsL iCurrentEntry=%d", iCurrentEntry);
+
+        ExecuteCommand();
+		}
+    }    
+// --------------------------------------------------------------------------------------------
+
+// This callback function is called when cancel button of the progress bar was pressed
+void CFileBrowserFileUtils::DialogDismissedL(TInt aButtonId)
+    {
+    iProgressDialog = NULL;
+    iProgressInfo = NULL;
+    iWaitDialog = NULL;
+    
+    // check if cancel button was pressed
+    if (aButtonId == EAknSoftkeyCancel)
+        {
+        // cancel the active object, command executer 
+        Cancel();
+        
+        iFileOps->CancelOp();
+        
+        ResetCommandArray();
+
+	    CAknInformationNote* note = new (ELeave) CAknInformationNote;
+	    note->ExecuteLD(_L("Cancelled"));
+        }
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::AppendToCommandArrayL(TInt aCommand, CCommandParamsBase* aParameters)
+    {
+    if (iCommandArray)
+        iCommandArray->AppendL( TCommand(aCommand, aParameters) );
+    else
+        User::Leave(KErrNotReady);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileUtils::CommandArrayCount() const
+    {
+    TInt count(0);
+    
+    if (iCommandArray)
+        count = iCommandArray->Count();
+    
+    return count;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::ResetCommandArray()
+    {
+    // delete params first
+    for (TInt i=0; i<CommandArrayCount(); i++)
+        {
+        if ( iCommandArray->At(i).iParameters )
+            {
+            delete iCommandArray->At(i).iParameters;
+            iCommandArray->At(i).iParameters = NULL;
+            }
+        }
+
+    // reset the entries
+    iCommandArray->Reset();
+    }
+                    
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::HandleSettingsChangeL()
+    {
+    if (iModel->FileListContainer())
+        {
+        iModel->FileListContainer()->SetScreenLayoutL(iModel->Settings().iDisplayMode); 
+        iModel->FileListContainer()->CreateListBoxL(iModel->Settings().iFileViewMode);
+        //iModel->FileListContainer()->SetNaviPaneTextL(iCurrentPath);
+        RefreshViewL();
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::SetSortModeL(TInt aSortMode)
+    {
+    iSortMode = aSortMode;
+    RefreshViewL();
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::SetOrderModeL(TInt aOrderMode)
+    {
+    iOrderMode = aOrderMode;
+    RefreshViewL();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TKeyResponse CFileBrowserFileUtils::HandleOfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
+    {
+    if(aType != EEventKey)
+        return EKeyWasNotConsumed;
+    
+    TBool shiftKeyPressed = (aKeyEvent.iModifiers & EModifierShift) ||
+                            (aKeyEvent.iModifiers & EModifierLeftShift) ||
+                            (aKeyEvent.iModifiers & EModifierRightShift);
+    TBool controlKeyPressed = (aKeyEvent.iModifiers & EModifierCtrl) || 
+                              (aKeyEvent.iModifiers & EModifierRightCtrl); 
+    
+    // handle left arrow key press
+    if (aKeyEvent.iCode == EKeyLeftArrow)
+        {
+        MoveUpOneLevelL();
+        return EKeyWasConsumed;
+        }
+    
+    // handle right arrow key press
+    else if (aKeyEvent.iCode == EKeyRightArrow)
+        {
+        if (IsDriveListViewActive() && iDriveEntryList->Count() > 0)
+            {
+            MoveDownToDirectoryL();
+            return EKeyWasConsumed;
+            }
+        else if (iFileEntryList->Count() > 0)
+            {
+            MoveDownToDirectoryL();
+            return EKeyWasConsumed;
+            }        
+        }    
+
+    // skip OK/Enter keys when shift or ctrl is pressed because those are needed by the listbox
+    else if ((aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter) && (shiftKeyPressed || controlKeyPressed))
+        {
+        return EKeyWasNotConsumed;
+        }
+    
+    // handle OK/Enter keys
+    else if (aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter)
+        {
+        if (IsDriveListViewActive() && iDriveEntryList->Count() > 0)
+            {
+            MoveDownToDirectoryL();
+            return EKeyWasConsumed;
+            }
+        else if (iFileEntryList->Count() > 0)
+            {
+            TFileEntry fileEntry = iFileEntryList->At(iModel->FileListContainer()->CurrentListBoxItemIndex());
+            
+            if (fileEntry.iEntry.IsDir())
+                MoveDownToDirectoryL();
+            else
+                OpenCommonFileActionQueryL();
+            
+            return EKeyWasConsumed;
+            } 
+        }
+    
+    // handle Delete/Backspace keys
+    else if (!iModel->FileListContainer()->SearchField() && (aKeyEvent.iCode == EKeyBackspace || aKeyEvent.iCode == EKeyDelete) &&
+             !iModel->FileUtils()->IsCurrentDriveReadOnly() && !iModel->FileUtils()->IsDriveListViewActive())
+        {
+        DeleteL();
+        return EKeyWasConsumed;
+        }
+                          
+    return EKeyWasNotConsumed;
+    }        
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::RefreshViewL()
+    {
+    if (iModel->FileListContainer())
+        {
+        // update navi pane text        
+        if (iListingMode == ENormalEntries)
+            iModel->FileListContainer()->SetNaviPaneTextL(iCurrentPath);
+        else if (iListingMode == ESearchResults)
+            iModel->FileListContainer()->SetNaviPaneTextL(_L("Search results"));
+        else if (iListingMode == EOpenFiles)
+            iModel->FileListContainer()->SetNaviPaneTextL(_L("Open files"));
+        else if (iListingMode == EMsgAttachmentsInbox)
+            iModel->FileListContainer()->SetNaviPaneTextL(_L("Attachments in Inbox"));
+        else if (iListingMode == EMsgAttachmentsDrafts)
+            iModel->FileListContainer()->SetNaviPaneTextL(_L("Attachments in Drafts"));
+        else if (iListingMode == EMsgAttachmentsSentItems)
+            iModel->FileListContainer()->SetNaviPaneTextL(_L("Attachments in Sent Items"));
+        else if (iListingMode == EMsgAttachmentsOutbox)
+            iModel->FileListContainer()->SetNaviPaneTextL(_L("Attachments in Outbox"));
+
+        // create a list box if it doesn't already exist
+        if (!iModel->FileListContainer()->ListBox())
+            iModel->FileListContainer()->CreateListBoxL(iModel->Settings().iFileViewMode);
+        
+        // clear selections if any
+        iModel->FileListContainer()->ListBox()->ClearSelection();
+
+        // make sure that the search field is disabled
+        iModel->FileListContainer()->DisableSearchFieldL();
+        
+        // read directory listing
+        GenerateDirectoryDataL();
+        
+        // set an icon array
+        iModel->FileListContainer()->SetListBoxIconArrayL(GenerateIconArrayL());
+
+        // set text items
+        iModel->FileListContainer()->SetListBoxTextArrayL(GenerateItemTextArrayL());
+
+        // make sure that the current item index is not out of array
+        if (iModel->FileListContainer()->CurrentListBoxItemIndex() == -1 && // -1 is a hardcoded value meaning that no current item index
+                iModel->FileListContainer()->ListBox()->Model()->NumberOfItems() > 0)  
+            iModel->FileListContainer()->ListBox()->SetCurrentItemIndex( iModel->FileListContainer()->ListBox()->Model()->NumberOfItems() - 1 );    
+
+        }
+    
+        iModel->FileListContainer()->UpdateToolbar();
+    }   
+    
+// --------------------------------------------------------------------------------------------
+
+CAknIconArray* CFileBrowserFileUtils::GenerateIconArrayL(TBool aGenerateNewBasicIconArray)
+    {
+    CAknIconArray* iconArray = NULL;
+    
+    if (aGenerateNewBasicIconArray)
+        {
+        iconArray = new(ELeave) CAknIconArray(16);    
+        }
+    else
+        {
+        if (iModel->FileListContainer())
+            iconArray = iModel->FileListContainer()->ListBoxIconArrayL();
+        
+        if (!iconArray)    
+            iconArray = new(ELeave) CAknIconArray(16);
+        }
+
+        
+    CleanupStack::PushL(iconArray);
+    
+    // generate basic items if not already existing
+    if (iconArray->Count() < EFixedIconListLength)
+        {
+        // reset arrays
+        iconArray->Reset();
+        iAppIconList->Reset();
+        
+        // get default control color
+        TRgb defaultColor;
+        defaultColor = iModel->EikonEnv()->Color(EColorControlText);
+        
+        // create a color icon of the marking indicator
+        CFbsBitmap* markBitmap = NULL;
+        CFbsBitmap* markBitmapMask = NULL;
+
+        AknsUtils::CreateColorIconL(AknsUtils::SkinInstance(),
+                KAknsIIDQgnIndiMarkedAdd,
+                KAknsIIDQsnIconColors,
+                EAknsCIQsnIconColorsCG13,
+                markBitmap,
+                markBitmapMask,
+                AknIconUtils::AvkonIconFileName(),
+                EMbmAvkonQgn_indi_marked_add,
+                EMbmAvkonQgn_indi_marked_add_mask,
+                defaultColor
+                );
+         
+        // 0 marking indicator
+        CGulIcon* markIcon = CGulIcon::NewL(markBitmap, markBitmapMask);
+        iconArray->AppendL(markIcon);                       
+
+        // 1 empty
+        AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(),
+                                  EMbmAvkonQgn_prop_empty, EMbmAvkonQgn_prop_empty_mask, KAknsIIDQgnPropEmpty);
+        // 2 phone memory
+        AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(),
+                                  EMbmAvkonQgn_prop_phone_memc, EMbmAvkonQgn_prop_phone_memc_mask, KAknsIIDQgnPropPhoneMemc);
+        // 3 memory card
+        AppendGulIconToIconArrayL(iconArray, KMemoryCardUiBitmapFile,
+                                  EMbmAknmemorycarduiQgn_prop_mmc_memc, EMbmAknmemorycarduiQgn_prop_mmc_memc_mask, KAknsIIDQgnPropMmcMemc);
+        // 4 memory card disabled
+        AppendGulIconToIconArrayL(iconArray, KMemoryCardUiBitmapFile,
+                                  EMbmAknmemorycarduiQgn_prop_mmc_non, EMbmAknmemorycarduiQgn_prop_mmc_non_mask, KAknsIIDQgnPropMmcNon);
+        // 5 folder
+        AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(),
+                                  EMbmAvkonQgn_prop_folder_small, EMbmAvkonQgn_prop_folder_small_mask, KAknsIIDQgnPropFolderSmall);
+        // 6 folder with subfolders
+        AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(),
+                                  EMbmAvkonQgn_prop_folder_sub_small, EMbmAvkonQgn_prop_folder_sub_small_mask, KAknsIIDQgnPropFolderSubSmall);
+        // 7 current folder
+        AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(),
+                                  EMbmAvkonQgn_prop_folder_current, EMbmAvkonQgn_prop_folder_current_mask, KAknsIIDQgnPropFolderCurrent);
+        }
+
+    // append custom icons if not in drive list view and setting is enabled
+    if (!aGenerateNewBasicIconArray && !IsDriveListViewActive() && iModel->Settings().iShowAssociatedIcons)
+        {
+        // init id counter
+        TInt idCounter(EFixedIconListLength + iAppIconList->Count());
+        
+        // loop all items in the file list
+        for (TInt i=0; i<iFileEntryList->Count(); i++)
+            {
+            TFileEntry& fileEntry = iFileEntryList->At(i);
+
+            // just check for normal files            
+            if (!fileEntry.iEntry.IsDir())     
+                {
+                TUid appUid = GetAppUid(fileEntry);
+                TInt iconId = AppIconIdForUid(appUid);
+                
+                if (appUid != KNullUid && iconId == KErrNotFound)
+                    {
+                    // icon not found from the icon array, generate it
+                    CFbsBitmap* bitmap = NULL;
+                    CFbsBitmap* mask = NULL;
+                    CGulIcon* appIcon = NULL;
+        
+                    TRAPD(err, 
+                        AknsUtils::CreateAppIconLC(AknsUtils::SkinInstance(), appUid, EAknsAppIconTypeList, bitmap, mask);
+                        appIcon = CGulIcon::NewL(bitmap, mask);
+                        CleanupStack::Pop(2); //bitmap, mask
+                        );
+                         
+                    if (err == KErrNone)
+                        {
+                        TAppIcon appIconEntry;
+                        appIconEntry.iId = idCounter;
+                        appIconEntry.iUid = appUid;
+                        
+                        appIcon->SetBitmapsOwnedExternally(EFalse);
+                        iconArray->AppendL(appIcon);
+                        iAppIconList->AppendL(appIconEntry);
+
+                        fileEntry.iIconId = idCounter;
+                                                
+                        idCounter++;      
+                        }
+                    else
+                        {
+                        delete bitmap;
+                        delete mask;
+		
+                        TAppIcon appIconEntry;
+                        appIconEntry.iId = EFixedIconEmpty;
+                        appIconEntry.iUid = appUid;
+                        
+                        iAppIconList->AppendL(appIconEntry);
+                        }
+                    }
+
+                else if (appUid != KNullUid && iconId >= 0)
+                    {
+                    // we already have already generated an icon for this uid, use it
+                    fileEntry.iIconId = iconId;
+                    }
+                }
+            }
+        }
+
+    CleanupStack::Pop(); //iconArray
+    return iconArray;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::AppendGulIconToIconArrayL(CAknIconArray* aIconArray, const TDesC& aIconFile, TInt aIconId, TInt aMaskId, const TAknsItemID aAknsItemId)
+    {
+    CGulIcon* icon = AknsUtils::CreateGulIconL(
+            AknsUtils::SkinInstance(),
+            aAknsItemId,
+            aIconFile,
+            aIconId,
+            aMaskId);
+    CleanupStack::PushL(icon);
+	
+	icon->SetBitmapsOwnedExternally(EFalse);
+	aIconArray->AppendL(icon);
+	
+	CleanupStack::Pop(); //icon          
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileUtils::AppIconIdForUid(TUid aUid)
+    {
+    TInt result(KErrNotFound);
+    
+    for (TInt i=0; i<iAppIconList->Count(); i++)
+        {
+        if (iAppIconList->At(i).iUid == aUid)
+            {
+            result = iAppIconList->At(i).iId;
+            break;
+            }
+        }
+    
+    return result;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TUid CFileBrowserFileUtils::GetAppUid(TFileEntry aFileEntry)
+    {
+    TFileName fullPath;
+    fullPath.Copy(aFileEntry.iPath);
+    fullPath.Append(aFileEntry.iEntry.iName);
+    
+    TParse parsedName;
+    parsedName.Set(fullPath, NULL, NULL);
+
+    // this will boost performance in \sys\bin folder    
+    if (parsedName.Ext().CompareF(_L(".dll")) == 0 || parsedName.Ext().CompareF(_L(".rsc")) == 0)
+        return KNullUid;
+    
+    TInt err1(KErrNone), err2(KErrNone);
+    TUid appUid;
+    TDataType dataType;
+    TBool isProgram;
+    
+    err1 = iModel->LsSession().AppForDocument(fullPath, appUid, dataType);
+    err2 = iModel->LsSession().IsProgram(fullPath, isProgram);
+        
+    if (err1 == KErrNone && err2 == KErrNone)
+        {
+        if (isProgram)
+            {
+            // get the real app Uid from the app list
+            TApaAppInfo appInfo;
+            iModel->LsSession().GetAllApps();
+
+            while (iModel->LsSession().GetNextApp(appInfo) == KErrNone)
+                {
+                if (fullPath.CompareF(appInfo.iFullName) == 0)
+                    return appInfo.iUid;
+                }
+            }
+        else
+            {
+            // return the app Uid associated for it
+            return appUid;
+            }            
+        }
+
+    return KNullUid;
+    }
+// --------------------------------------------------------------------------------------------
+
+CDesCArray* CFileBrowserFileUtils::GenerateItemTextArrayL()
+    {
+    CDesCArray* textArray = new(ELeave) CDesCArrayFlat(64);
+    CleanupStack::PushL(textArray);
+
+    if (IsDriveListViewActive())
+        {
+        _LIT(KSimpleDriveEntry, "%d\t%c: <%S>\t\t");
+        _LIT(KExtendedDriveEntry, "%d\t%c: <%S>\t%LD / %LD kB\t");
+
+        for (TInt i=0; i<iDriveEntryList->Count(); i++)
+            {
+            TFileName textEntry;
+            TDriveEntry driveEntry = iDriveEntryList->At(i);
+            
+            if (iModel->Settings().iFileViewMode == EFileViewModeSimple)
+                {
+                textEntry.Format(KSimpleDriveEntry, driveEntry.iIconId, TUint(driveEntry.iLetter), &driveEntry.iMediaTypeDesc);
+                }
+            else if (iModel->Settings().iFileViewMode == EFileViewModeExtended)
+                {
+                textEntry.Format(KExtendedDriveEntry, driveEntry.iIconId, TUint(driveEntry.iLetter), &driveEntry.iMediaTypeDesc, driveEntry.iVolumeInfo.iFree/1024, driveEntry.iVolumeInfo.iSize/1024);
+                }
+            
+            textArray->AppendL(textEntry);
+            }
+        }
+    
+    else
+        {
+        _LIT(KSimpleFileEntry, "%d\t%S\t\t");
+        _LIT(KExtendedFileEntry, "%d\t%S\t%S\t");
+
+        for (TInt i=0; i<iFileEntryList->Count(); i++)
+            {
+            TBuf<KMaxPath+KMaxFileName> textEntry;
+            TFileEntry fileEntry = iFileEntryList->At(i);
+            
+            // format text line entries            
+            if (iModel->Settings().iFileViewMode == EFileViewModeSimple)
+                {
+                textEntry.Format(KSimpleFileEntry, fileEntry.iIconId, &fileEntry.iEntry.iName);
+                }
+            else if (iModel->Settings().iFileViewMode == EFileViewModeExtended)
+                {
+                TBuf<128> extraData;
+                
+                // append entry date
+                TTime entryModified = fileEntry.iEntry.iModified;
+                if ( iTz.ConvertToLocalTime( entryModified ) == KErrNone )
+                    {
+                    entryModified = fileEntry.iEntry.iModified;
+                    }
+                
+                _LIT(KCurrentDate,"%D%M%*Y%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B");
+                entryModified.FormatL(extraData, KCurrentDate);
+
+                // for a directory append number of entries and for a file the file size
+                if (fileEntry.iEntry.IsDir() && fileEntry.iDirEntries >= 0)
+                    {
+                    extraData.Append(_L(" - "));
+                    extraData.AppendNum(fileEntry.iDirEntries);
+                    
+                    if (fileEntry.iDirEntries == 1)
+                        extraData.Append(_L(" entry"));
+                    else
+                        extraData.Append(_L(" entries"));
+                    }
+                
+                // normal file entry
+                else if (!fileEntry.iEntry.IsDir())
+                    {
+                    extraData.Append(_L(" - "));
+
+                    if (fileEntry.iEntry.iSize < 1024)
+                        {
+                        extraData.AppendNum(fileEntry.iEntry.iSize);
+                        extraData.Append(_L(" B"));
+                        }
+                    else if (fileEntry.iEntry.iSize < 1024*1024)
+                        {
+                        TReal sizeKB = (TReal)fileEntry.iEntry.iSize / 1024;
+                        extraData.AppendNum(sizeKB, TRealFormat(KDefaultRealWidth, 1));
+                        extraData.Append(_L(" kB"));
+                        }
+                    else
+                        {
+                        TReal sizeMB = (TReal)fileEntry.iEntry.iSize / (1024*1024);
+                        extraData.AppendNum(sizeMB, TRealFormat(KDefaultRealWidth, 1));
+                        extraData.Append(_L(" MB"));
+                        }
+                    }
+
+                // append attribute flags if any
+                TBuf<4> atts;
+                if (fileEntry.iEntry.IsArchive())
+                    atts.Append(_L("A"));
+                if (fileEntry.iEntry.IsHidden())
+                    atts.Append(_L("H"));
+                if (fileEntry.iEntry.IsReadOnly())
+                    atts.Append(_L("R"));
+                if (fileEntry.iEntry.IsSystem())
+                    atts.Append(_L("S"));
+                
+                if (atts.Length() > 0)
+                    {
+                    extraData.Append(_L(" - ["));    
+                    extraData.Append(atts);    
+                    extraData.Append(_L("]"));    
+                    }
+                
+                // format                
+                textEntry.Format(KExtendedFileEntry, fileEntry.iIconId, &fileEntry.iEntry.iName, &extraData);
+                }
+            
+            if( fileEntry.iEntry.iName.Length() + fileEntry.iPath.Length() <= KMaxFileName )
+                {
+                textArray->AppendL(textEntry);
+                }
+            else
+                {
+                // Too long filenames are deleted from the list
+                iFileEntryList->Delete(i--);                
+                }
+            }
+        }
+    
+    CleanupStack::Pop(); //textArray
+    return textArray;
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::GenerateDirectoryDataL()
+    {
+    if (iListingMode == ENormalEntries)
+        {
+        if (IsDriveListViewActive())
+            GetDriveListL();    
+        else
+            GetDirectoryListingL();        
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::GetDriveListL()
+    {
+    TDriveList driveList;
+    
+    // get drive listing depending of the support for network drives
+    if (iModel->Settings().iSupportNetworkDrives)
+        {
+        #ifndef __SERIES60_30__
+            #ifndef __SERIES60_31__
+                User::LeaveIfError(iFs.DriveList(driveList, KDriveAttAll));
+            #endif
+        #else    
+            User::LeaveIfError(iFs.DriveList(driveList));
+        #endif        
+        }
+    else
+        {
+        User::LeaveIfError(iFs.DriveList(driveList));
+        }
+    
+    iDriveEntryList->Reset();        
+    
+    for (TInt i=0; i<KMaxDrives; i++)
+        {
+        if (driveList[i])
+            {
+            TDriveEntry driveEntry;
+            
+            // set default icon
+            driveEntry.iIconId = EFixedIconPhoneMemory;
+
+            // get drive letter and number 
+            driveEntry.iLetter = 'A' + i;
+            iFs.CharToDrive(driveEntry.iLetter, driveEntry.iNumber);
+            
+            // get volume info and check errors
+            if (iFs.Volume(driveEntry.iVolumeInfo, driveEntry.iNumber) == KErrNone)
+                {
+                // set media type descriptor
+                TInt mediaType = driveEntry.iVolumeInfo.iDrive.iType;
+                TBool extMountable( EFalse );
+                
+                if (mediaType == EMediaNotPresent)
+                    driveEntry.iMediaTypeDesc = _L("Not present");
+                else if (mediaType ==EMediaUnknown )
+                    driveEntry.iMediaTypeDesc = _L("Unknown");
+                else if (mediaType ==EMediaFloppy )
+                    driveEntry.iMediaTypeDesc = _L("Floppy");
+                else if (mediaType == EMediaHardDisk)
+                    driveEntry.iMediaTypeDesc = _L("Mass storage");
+                else if (mediaType == EMediaCdRom)
+                    driveEntry.iMediaTypeDesc = _L("CD-ROM");
+                else if (mediaType == EMediaRam)
+                    driveEntry.iMediaTypeDesc = _L("RAM");
+                else if (mediaType == EMediaFlash)
+                    driveEntry.iMediaTypeDesc = _L("Flash");
+                else if (mediaType == EMediaRom)
+                    driveEntry.iMediaTypeDesc = _L("ROM");
+                else if (mediaType == EMediaRemote)
+                    driveEntry.iMediaTypeDesc = _L("Remote");
+                else if (mediaType == EMediaNANDFlash)
+                    driveEntry.iMediaTypeDesc = _L("NAND flash");
+                
+                // get real size of the ROM drive
+                if (mediaType == EMediaRom)
+                    {
+                    TMemoryInfoV1Buf ramMemory;
+                    UserHal::MemoryInfo(ramMemory);
+                    driveEntry.iVolumeInfo.iSize = ramMemory().iTotalRomInBytes;
+                    }
+                
+                // set attribute descripitions
+                if (driveEntry.iVolumeInfo.iDrive.iBattery == EBatNotSupported)
+                    driveEntry.iAttributesDesc.Append(_L("Battery not supported"));
+                else if (driveEntry.iVolumeInfo.iDrive.iBattery == EBatGood)
+                    driveEntry.iAttributesDesc.Append(_L("Battery good"));
+                else if (driveEntry.iVolumeInfo.iDrive.iBattery == EBatLow)
+                    driveEntry.iAttributesDesc.Append(_L("Battery low"));
+                else
+                    driveEntry.iAttributesDesc.Append(_L("Battery state unknown"));
+                
+                if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttLocal)
+                    driveEntry.iAttributesDesc.Append(_L(" + Local"));
+                if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttRom)
+                    driveEntry.iAttributesDesc.Append(_L(" + ROM"));
+                if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttRedirected)
+                    driveEntry.iAttributesDesc.Append(_L("+ Redirected"));
+                if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttSubsted)
+                    driveEntry.iAttributesDesc.Append(_L(" + Substed"));
+                if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttInternal)
+                    driveEntry.iAttributesDesc.Append(_L(" + Internal"));
+                if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttRemovable)
+                    {
+                    driveEntry.iAttributesDesc.Append(_L(" + Removable"));
+#if (!defined __SERIES60_30__ && !defined __SERIES60_31__)
+                    TUint drvStatus( 0 );
+                    if ( !DriveInfo::GetDriveStatus( iFs, driveEntry.iNumber, drvStatus ) &&
+                         drvStatus & DriveInfo::EDriveExternallyMountable &&
+                         drvStatus & DriveInfo::EDriveInternal )
+                        {
+                        extMountable = ETrue;
+                        // iMediaTypeDesc already set as "Mass storage" 
+                        }
+                    else
+                        {
+                        driveEntry.iMediaTypeDesc = _L("Memory card");
+                        }
+#else
+                    driveEntry.iMediaTypeDesc = _L("Memory card");
+#endif
+                    }
+                if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttRemote)
+                    driveEntry.iAttributesDesc.Append(_L(" + Remote"));
+                if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttTransaction)
+                    driveEntry.iAttributesDesc.Append(_L(" + Transaction"));
+                                
+                if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttVariableSize)
+                    driveEntry.iAttributesDesc.Append(_L(" + Variable size"));
+                if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttDualDensity)
+                    driveEntry.iAttributesDesc.Append(_L(" + Dual density"));
+                if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttFormattable)
+                    driveEntry.iAttributesDesc.Append(_L(" + Formattable"));
+                if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttWriteProtected)
+                    driveEntry.iAttributesDesc.Append(_L(" + Write protected"));
+                if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttLockable)
+                    driveEntry.iAttributesDesc.Append(_L(" + Lockable"));
+                if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttLocked)
+                    driveEntry.iAttributesDesc.Append(_L(" + Locked"));
+                if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttHasPassword)
+                    driveEntry.iAttributesDesc.Append(_L(" + Has password"));
+                if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttReadWhileWrite)
+                    driveEntry.iAttributesDesc.Append(_L(" + Read while write"));
+                if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttDeleteNotify)
+                    driveEntry.iAttributesDesc.Append(_L(" + Supports DeleteNotify"));
+                
+                
+                // mark a removable media with memory card icon
+                if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttRemovable && !extMountable)
+                    {
+                    if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttLocked || driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAbsent)
+                        {                
+                        driveEntry.iIconId = EFixedIconMemoryCardDisabled;
+                        }                 
+                    else
+                        {                
+                        driveEntry.iIconId = EFixedIconMemoryCard;
+                        } 
+                    }
+                }   
+            
+            // if this fails, likely it's a memory card which is not present
+            else
+                {
+                TVolumeInfo volumeInfo;
+                volumeInfo.iSize = 0;
+                volumeInfo.iFree = 0;
+                volumeInfo.iDrive.iDriveAtt = KDriveAttRemovable;
+                volumeInfo.iDrive.iMediaAtt = KMediaAttWriteProtected;
+                driveEntry.iVolumeInfo = volumeInfo;
+
+                driveEntry.iMediaTypeDesc = _L("Not ready");
+                driveEntry.iIconId = EFixedIconMemoryCardDisabled;
+                }
+            
+            if ( iPrevFolderName != KNullDesC && iPrevFolderName[0] == driveEntry.iLetter )
+                {
+                iPrevFolderIndex = iDriveEntryList->Count();
+                }
+            
+            iDriveEntryList->AppendL(driveEntry);
+            }
+        }
+    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::GetDirectoryListingL()
+    {
+    iFileEntryList->Reset();
+
+    TInt sortMode(ESortByName);
+    if (iSortMode == EFileBrowserCmdViewSortByExtension)    
+        sortMode = ESortByExt; 
+    else if (iSortMode == EFileBrowserCmdViewSortBySize)    
+        sortMode = ESortBySize; 
+    else if (iSortMode == EFileBrowserCmdViewSortByDate)    
+        sortMode = ESortByDate; 
+    
+    TInt orderMode(EAscending);
+    if (iOrderMode == EFileBrowserCmdViewOrderDescending)    
+        orderMode = EDescending; 
+    
+    CDir* dir = NULL;
+    if (iFs.GetDir(iCurrentPath, KEntryAttMatchMask, sortMode | orderMode | EDirsFirst, dir) == KErrNone)
+        {
+        CleanupStack::PushL(dir);
+        
+        for (TInt i=0; i<dir->Count(); i++)
+            {
+            TFileEntry fileEntry;
+            fileEntry.iPath = iCurrentPath;
+            fileEntry.iEntry = (*dir)[i];
+            fileEntry.iDirEntries = KErrNotFound;
+            fileEntry.iIconId = EFixedIconEmpty;
+            
+            if ( iPrevFolderName != KNullDesC && iPrevFolderName == fileEntry.iEntry.iName )
+                {
+                iPrevFolderIndex = i;
+                }
+            
+            // check for directory entries
+            if (fileEntry.iEntry.IsDir())
+                {
+                fileEntry.iIconId = EFixedIconFolder;
+
+                TFileName subPath = fileEntry.iPath;
+                subPath.Append(fileEntry.iEntry.iName);
+                subPath.Append(_L("\\"));
+                                
+                // get number of entries in this directory if extended info about sub directories enabled
+                if (iModel->Settings().iShowSubDirectoryInfo && iModel->Settings().iFileViewMode == EFileViewModeExtended)
+                    {
+                    CDir* subDir = NULL;
+                    if (iFs.GetDir(subPath, KEntryAttMatchMask, ESortNone | EDirsFirst, subDir) == KErrNone)
+                        {
+                        fileEntry.iDirEntries = subDir->Count();
+                        delete subDir;    
+                        }
+                    }
+                
+                // apply subfolder icon for known directories (speed improvement)
+                if (subPath[0]=='Z' && (subPath.CompareF(_L("Z:\\data\\"))==0 || subPath.CompareF(_L("Z:\\Nokia\\"))==0
+                    || subPath.Compare(_L("Z:\\private\\"))==0 || subPath.Compare(_L("Z:\\resource\\"))==0
+                    || subPath.Compare(_L("Z:\\sys\\"))==0 || subPath.Compare(_L("Z:\\system\\"))==0))
+                    {
+                    fileEntry.iIconId = EFixedIconFolderSub;
+                    }
+                else if (subPath[0]=='Z' && (subPath.CompareF(_L("Z:\\sys\\bin\\"))==0))
+                    {
+                    // normal folder icon for these ones
+                    fileEntry.iIconId = EFixedIconFolder;
+                    }
+                else
+                    {
+                    // check if this folder has subdirectories
+                    CDir* subDir = NULL;
+                    if (iFs.GetDir(subPath, KEntryAttDir|KEntryAttMatchMask, ESortNone | EDirsFirst, subDir) == KErrNone)
+                        {
+                        for (TInt j=0; j<subDir->Count(); j++)
+                            {
+                            TEntry entry = (*subDir)[j];
+
+                            if (entry.IsDir())
+                                {
+                                fileEntry.iIconId = EFixedIconFolderSub;
+                                break;    
+                                }
+                            }
+
+                        delete subDir;    
+                        }                    
+                    }
+                }
+
+            iFileEntryList->AppendL(fileEntry);
+            }
+        
+        CleanupStack::PopAndDestroy(); //dir    
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::MoveUpOneLevelL()
+    {
+    iPrevFolderIndex = KErrNotFound;
+    iPrevFolderName.Zero();
+    
+    // change back to normal mode or move up
+    if (iListingMode != ENormalEntries)
+        {
+        iListingMode = ENormalEntries;
+        }
+    else
+        {
+        // do nothing if displaying drive list view
+        if (IsDriveListViewActive())
+            return;
+        
+        if (iCurrentPath.Length() <= KDriveLetterStringLength)
+            {
+            if ( iCurrentPath.Length() > 0 )
+                {
+                iPrevFolderName.Append( iCurrentPath[0] );
+                }
+            // move to drive list view if the current path is already short enough
+            iCurrentPath = KNullDesC;
+            }
+        else
+            {
+            // move one directory up
+            TInt marker(iCurrentPath.Length());
+            
+            // find second last dir marker
+            for (TInt i=iCurrentPath.Length()-2; i>=0; i--)
+                {
+                if (iCurrentPath[i] == '\\')
+                    {
+                    marker = i;
+                    break;
+                    }
+                    
+                }
+            
+            // update iPrevDir with the directory name that we just left 
+            iPrevFolderName.Copy( iCurrentPath.RightTPtr( iCurrentPath.Length() -  marker - 1 ) );
+            iPrevFolderName.Delete( iPrevFolderName.Length() -1, 2 ); // remove extra '\\'
+            
+            iCurrentPath = iCurrentPath.LeftTPtr(marker+1);
+            }    
+        }
+
+    if (iModel->FileListContainer())
+        {
+        //iModel->FileListContainer()->DisableSearchFieldL();
+        //iModel->FileListContainer()->ListBox()->ClearSelection();
+        iModel->FileListContainer()->ListBox()->SetCurrentItemIndex(0);
+        //iModel->FileListContainer()->SetNaviPaneTextL(iCurrentPath);
+        }
+    
+    // update view
+    RefreshViewL();
+    
+    if ( iModel->Settings().iRememberFolderSelection &&
+         iModel->FileListContainer() && iPrevFolderIndex > KErrNotFound )
+        {
+        
+        TInt visibleItems = iModel->FileListContainer()->ListBox()->Rect().Height() /
+                            iModel->FileListContainer()->ListBox()->ItemHeight() 
+                            - 1; // for the title row
+
+        // By default, the selected item would be the last visible item on the listbox.
+        // We want the selected item be displayed at the middle of the listbox, so we
+        // select one of the successor items first to scroll down a bit
+        iModel->FileListContainer()->ListBox()->SetCurrentItemIndex( 
+            Min( iModel->FileListContainer()->ListBox()->Model()->ItemTextArray()->MdcaCount() -1,
+                 iPrevFolderIndex + visibleItems / 2 ) );
+        
+        // ...and after that we select the the correct item.
+        iModel->FileListContainer()->ListBox()->SetCurrentItemIndex( iPrevFolderIndex );
+        
+        // update view
+        RefreshViewL();
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::MoveDownToDirectoryL()
+    {
+    // change back to normal mode
+    if (iListingMode != ENormalEntries)
+        {
+        iListingMode = ENormalEntries;
+        }
+    
+    TInt index = iModel->FileListContainer()->CurrentListBoxItemIndex();
+    
+    if (index >= 0)
+        {
+        TBool needsRefresh(EFalse);
+
+        if (IsDriveListViewActive())
+            {
+            // currently in a drive list view, move to root of selected drive
+            if (iDriveEntryList->Count() > index)
+                {
+                TDriveEntry driveEntry = iDriveEntryList->At(index);
+                
+                iCurrentPath.Append(driveEntry.iLetter);    
+                iCurrentPath.Append(_L(":\\"));
+                
+                needsRefresh = ETrue;    
+                }
+            }
+        else
+            {
+            // otherwise just append the new directory
+            if (iFileEntryList->Count() > index)
+                {
+                TFileEntry fileEntry = iFileEntryList->At(index);
+                
+                if (fileEntry.iEntry.IsDir())
+                    {
+                    iCurrentPath.Copy(fileEntry.iPath);
+                    iCurrentPath.Append(fileEntry.iEntry.iName);
+                    iCurrentPath.Append(_L("\\"));
+
+                    needsRefresh = ETrue;    
+                    }
+                }
+            }
+
+        if (needsRefresh && iModel->FileListContainer())
+            {
+            //iModel->FileListContainer()->DisableSearchFieldL();
+            //iModel->FileListContainer()->ListBox()->ClearSelection();
+            iModel->FileListContainer()->ListBox()->SetCurrentItemIndex(0);
+            //iModel->FileListContainer()->SetNaviPaneTextL(iCurrentPath);
+
+            // update view
+            RefreshViewL();
+            }
+        }
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TBool CFileBrowserFileUtils::IsCurrentDriveReadOnly()
+    {
+    if (iListingMode !=ENormalEntries || iCurrentPath.Length() < 2)
+        return EFalse;
+    else
+        {
+        for (TInt i=0; i<iDriveEntryList->Count(); i++)
+            {
+            TDriveEntry driveEntry = iDriveEntryList->At(i);
+            
+            if (driveEntry.iLetter == iCurrentPath[0])
+                {
+                if (driveEntry.iVolumeInfo.iDrive.iMediaAtt == KMediaAttWriteProtected || driveEntry.iVolumeInfo.iDrive.iMediaAtt == KMediaAttLocked || driveEntry.iVolumeInfo.iDrive.iDriveAtt == KDriveAbsent)
+                    return ETrue;    
+                else
+                    return EFalse;
+                }
+            }
+        }
+
+    return EFalse;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TBool CFileBrowserFileUtils::IsCurrentItemDirectory()
+    {
+    TInt currentItemIndex = iModel->FileListContainer()->CurrentListBoxItemIndex();
+    
+    if (currentItemIndex < 0)
+        return EFalse;
+    else
+        {
+        if (iFileEntryList->Count() > currentItemIndex)
+            {
+            TFileEntry fileEntry = iFileEntryList->At(currentItemIndex) ;   
+            return fileEntry.iEntry.IsDir();
+            }
+        else
+            return EFalse;
+        }
+    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileUtils::GetSelectedItemsOrCurrentItemL(CFileEntryList* aFileEntryList)
+    {
+    aFileEntryList->Reset();
+    
+    const CArrayFix<TInt>* selectionIndexes = iModel->FileListContainer()->ListBoxSelectionIndexes();
+
+    // by default use selected items
+    if (selectionIndexes && selectionIndexes->Count() > 0)
+        {
+        TInt ref(0);
+        TKeyArrayFix key(0, ECmpTUint16);
+        TInt index(0);
+
+        for (TInt i=0; i<iFileEntryList->Count(); i++)
+            {
+            ref = i;
+
+            if (selectionIndexes->Find(ref, key, index) == 0)  
+                {
+                aFileEntryList->AppendL(iFileEntryList->At(i));
+                }
+            }
+        }
+    
+    // or if none selected, use the current item index
+    else
+        {
+        TInt currentItemIndex = iModel->FileListContainer()->CurrentListBoxItemIndex();
+        
+        if (iFileEntryList->Count() > currentItemIndex && currentItemIndex >= 0)
+            {
+            aFileEntryList->AppendL(iFileEntryList->At(currentItemIndex));
+            }
+        }  
+
+    return aFileEntryList->Count();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::ClipboardCutL()
+    {
+    iClipBoardMode = EClipBoardModeCut;
+    TInt operations = GetSelectedItemsOrCurrentItemL(iClipBoardList);
+
+    _LIT(KMessage, "%d entries cut to clipboard");
+    TFileName noteMsg;
+    noteMsg.Format(KMessage, operations);
+    
+    CAknInformationNote* note = new(ELeave) CAknInformationNote;
+    note->ExecuteLD(noteMsg);
+
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::ClipboardCopyL()
+    {
+    iClipBoardMode = EClipBoardModeCopy;
+    TInt operations = GetSelectedItemsOrCurrentItemL(iClipBoardList);
+
+    _LIT(KMessage, "%d entries copied to clipboard");
+    TFileName noteMsg;
+    noteMsg.Format(KMessage, operations);
+    
+    CAknInformationNote* note = new(ELeave) CAknInformationNote;
+    note->ExecuteLD(noteMsg);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::ClipboardPasteL()
+    {
+    if (iClipBoardMode == EClipBoardModeCut)
+        {
+        DoCopyToFolderL(iClipBoardList, iCurrentPath, ETrue);
+        iClipBoardList->Reset();
+        }
+    else if (iClipBoardMode == EClipBoardModeCopy)
+        {
+        DoCopyToFolderL(iClipBoardList, iCurrentPath, EFalse);
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::CopyToFolderL(TBool aMove)
+    {
+    TFileName destinationFolder;
+    
+    // generate an icon array
+    CAknIconArray* iconArray = GenerateIconArrayL(ETrue);
+    CleanupStack::PushL(iconArray);
+
+    // run folder selection dialog
+    CFileBrowserDestinationFolderSelectionDlg* dlg = CFileBrowserDestinationFolderSelectionDlg::NewL(destinationFolder, iDriveEntryList, iconArray);
+
+    TBool dialogOK(EFalse);
+    
+    if (aMove)
+        dialogOK = dlg->RunMoveDlgLD();
+    else
+        dialogOK = dlg->RunCopyDlgLD();
+    
+    if (dialogOK)
+        {
+        // get entry list
+        CFileEntryList* entryList = new(ELeave) CFileEntryList(32);
+        GetSelectedItemsOrCurrentItemL(entryList);
+        CleanupStack::PushL(entryList);
+
+        // do the file operations
+        if (aMove)
+            DoCopyToFolderL(entryList, destinationFolder, ETrue);
+        else
+            DoCopyToFolderL(entryList, destinationFolder, EFalse);
+
+        CleanupStack::PopAndDestroy(); // entryList   
+        }
+
+    CleanupStack::Pop(); //iconArray
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::DoCopyToFolderL(CFileEntryList* aEntryList, const TDesC& aTargetDir, TBool aDeleteSource)
+    {
+    if (aEntryList && aEntryList->Count() > 0)
+        {
+        TBool someEntryExists(EFalse);
+        TBool doFileOperations(ETrue);
+        TInt queryIndex(0);
+        TFileName postFix;
+        TInt overWriteFlags = CFileMan::EOverWrite;
+
+        // check if some destination entries also exists
+        for (TInt i=0; i<aEntryList->Count(); i++)
+            {
+            TFileEntry fileEntry = aEntryList->At(i);
+            
+            TFileName targetEntry = aTargetDir;
+            targetEntry.Append(fileEntry.iEntry.iName);
+
+            if (fileEntry.iEntry.IsDir())
+                {
+                targetEntry.Append(_L("\\"));
+                
+                if (BaflUtils::PathExists(iFs, targetEntry))
+                    {
+                    someEntryExists = ETrue;
+                    break;
+                    }
+                }
+            else
+                {
+                if (BaflUtils::FileExists(iFs, targetEntry))
+                    {
+                    someEntryExists = ETrue;
+                    break;
+                    }
+                }
+            }        
+        
+        // show a query if existing entries
+        if (someEntryExists)
+            {
+            CAknListQueryDialog* listQueryDlg = new(ELeave) CAknListQueryDialog(&queryIndex);
+            
+            if (listQueryDlg->ExecuteLD(R_ENTRY_OVERWRITE_TYPE_QUERY))
+                {
+                if (queryIndex == EFileActionQueryPostFix)
+                    {
+                    CAknTextQueryDialog* textQuery = CAknTextQueryDialog::NewL(postFix);
+                    textQuery->SetPromptL(_L("Postfix:"));
+                    
+                    if (textQuery->ExecuteLD(R_GENERAL_TEXT_QUERY))
+                        {
+                            
+                        }
+                    else
+                        {
+                        doFileOperations = EFalse;    
+                        }
+                    }
+                else if (queryIndex == EFileActionSkipAllExisting)
+                    {
+                    overWriteFlags = 0;
+                    }
+                }
+            else
+                {
+                doFileOperations = EFalse;    
+                }
+            }
+        
+
+        if (doFileOperations)
+            {
+            // set correct command id depending if we are copying or moving
+            TInt commandId(EFileBrowserFileOpCommandCopy);
+            if (aDeleteSource)
+                commandId = EFileBrowserFileOpCommandMove;
+            
+            // do the file operations for each entry
+            for (TInt i=0; i<aEntryList->Count(); i++)
+                {
+                TFileEntry fileEntry = aEntryList->At(i);
+                
+                TFileName targetEntry = aTargetDir;
+                targetEntry.Append(fileEntry.iEntry.iName);
+                
+                if (queryIndex == EFileActionGenerateUniqueFilenames)
+                    {
+                    CApaApplication::GenerateFileName(iFs, targetEntry);
+                    }
+                else if (queryIndex == EFileActionQueryPostFix)
+                    {
+                    targetEntry.Append(postFix);
+                    }
+
+                
+                // append the new command to the command array
+                if (fileEntry.iEntry.IsDir())
+                    {
+                    AppendToCommandArrayL(commandId,
+                                          new(ELeave)CCommandParamsCopyOrMove(fileEntry, targetEntry, overWriteFlags|CFileMan::ERecurse)
+                                         );
+                    }
+                else
+                    {
+                    AppendToCommandArrayL(commandId,
+                                          new(ELeave)CCommandParamsCopyOrMove(fileEntry, targetEntry, overWriteFlags)
+                                         );
+                    }
+
+                }
+
+            // execute all operations
+            if (aDeleteSource)
+                StartExecutingCommandsL(_L("Moving"));
+            else
+                StartExecutingCommandsL(_L("Copying"));
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::DeleteL()
+    {
+    CFileEntryList* entries = new(ELeave) CFileEntryList(32);
+    TInt operations = GetSelectedItemsOrCurrentItemL(entries);
+    CleanupStack::PushL(entries);
+
+    CAknQueryDialog* query = CAknQueryDialog::NewL();
+    _LIT(KQueryMessage, "Delete %d entries?");
+    TFileName queryMsg;
+    queryMsg.Format(KQueryMessage, operations);
+        
+    if (query->ExecuteLD(R_GENERAL_CONFIRMATION_QUERY, queryMsg))
+        {
+        // do the file operations for each entry
+        for (TInt i=0; i<entries->Count(); i++)
+            {
+            TFileEntry fileEntry = entries->At(i);
+            
+            // append the new command to the command array
+            if (fileEntry.iEntry.IsDir())
+                {
+                AppendToCommandArrayL(EFileBrowserFileOpCommandDelete,
+                                      new(ELeave)CCommandParamsDelete(fileEntry, CFileMan::ERecurse)
+                                     );
+                }
+            else
+                {
+                AppendToCommandArrayL(EFileBrowserFileOpCommandDelete,
+                                      new(ELeave)CCommandParamsDelete(fileEntry, 0)
+                                     );
+                }
+
+            }
+
+        // execute all operations
+        StartExecutingCommandsL(_L("Deleting"));
+        }
+
+    CleanupStack::PopAndDestroy(); //entries
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::TouchL()
+    {
+    CFileEntryList* entries = new(ELeave) CFileEntryList(32);
+    GetSelectedItemsOrCurrentItemL(entries);
+    CleanupStack::PushL(entries);
+    
+    TBool recurse(EFalse);
+
+    // check if any directories and ask recursion
+    for (TInt i=0; i<entries->Count(); i++)
+        {
+        TFileEntry fileEntry = entries->At(i);
+        
+        if (fileEntry.iEntry.IsDir())
+            {
+            CAknQueryDialog* query = CAknQueryDialog::NewL();
+            if (query->ExecuteLD(R_GENERAL_CONFIRMATION_QUERY, _L("Recurse touch for all selected dirs?")))
+                {
+                recurse = ETrue;
+                }
+            break;
+            }
+        }
+    
+    // now go through all entries    
+    for (TInt i=0; i<entries->Count(); i++)
+        {
+        TFileEntry fileEntry = entries->At(i);
+
+        // touch to current time
+        TTime now;
+        now.UniversalTime();
+
+        
+        // append the new command to the command array
+        if (fileEntry.iEntry.IsDir() && recurse)
+            {
+            AppendToCommandArrayL(EFileBrowserFileOpCommandAttribs,
+                                  new(ELeave)CCommandParamsAttribs(fileEntry, NULL, NULL, now, CFileMan::ERecurse)
+                                 );
+            }
+        else
+            {
+            AppendToCommandArrayL(EFileBrowserFileOpCommandAttribs,
+                                  new(ELeave)CCommandParamsAttribs(fileEntry, NULL, NULL, now, 0)
+                                 );
+            }
+        }
+       
+    // execute all operations
+    StartExecutingCommandsL(_L("Touching"));
+
+    CleanupStack::PopAndDestroy(); //entries
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::RenameL()
+    {
+    CFileEntryList* entries = new(ELeave) CFileEntryList(16);
+    GetSelectedItemsOrCurrentItemL(entries);
+    CleanupStack::PushL(entries);
+    
+    for (TInt i=0; i<entries->Count(); i++)
+        {
+        TFileEntry fileEntry = entries->At(i);
+        
+        TFileName newName = fileEntry.iEntry.iName;
+        
+        CAknTextQueryDialog* textQuery = CAknTextQueryDialog::NewL(newName);
+        textQuery->SetPromptL(_L("Enter new name:"));
+        
+        if (textQuery->ExecuteLD(R_GENERAL_TEXT_QUERY))
+            {
+            TFileName targetEntry = fileEntry.iPath;
+            targetEntry.Append(newName);
+            
+            TBool alreadyExists(EFalse);
+            TBool doRenameOperation(ETrue);
+            
+            if (fileEntry.iEntry.IsDir())
+                {
+                //targetEntry.Append(_L("\\"));
+                alreadyExists = BaflUtils::PathExists(iFs, targetEntry);
+                }
+            else    
+                {
+                alreadyExists = BaflUtils::FileExists(iFs, targetEntry);
+                }                
+ 
+            if (alreadyExists)
+                {
+                CAknQueryDialog* query = CAknQueryDialog::NewL();
+                _LIT(KQueryMessage, "%S already exists, overwrite?");
+                TFileName queryMsg;
+                queryMsg.Format(KQueryMessage, &newName);
+                
+                if (!query->ExecuteLD(R_GENERAL_CONFIRMATION_QUERY, queryMsg))
+                    {
+                    doRenameOperation = EFalse;                                    
+                    }
+                }
+
+            if (doRenameOperation)
+                {
+                // append the new command to the command array
+                AppendToCommandArrayL(EFileBrowserFileOpCommandRename,
+                                      new(ELeave)CCommandParamsRename(fileEntry, targetEntry, CFileMan::EOverWrite)
+                                     );
+                }
+            }
+        }
+
+    // execute all operations
+    StartExecutingCommandsL(_L("Renaming"));
+
+    CleanupStack::PopAndDestroy(); //entries
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::SetAttributesL()
+    {
+    CFileEntryList* entries = new(ELeave) CFileEntryList(16);
+    GetSelectedItemsOrCurrentItemL(entries);
+    CleanupStack::PushL(entries);
+    
+    if (entries->Count() > 0)
+        {
+        TFileName naviText = _L("Multiple entries");
+        
+        TUint setAttMask(0);
+        TUint clearAttMask(0);
+        TBool recurse(EFalse);
+        
+        // set default masks if only one file selected
+        if (entries->Count() == 1)
+            {
+            TFileEntry fileEntry = entries->At(0);
+            
+            naviText.Copy(fileEntry.iEntry.iName);
+            
+            if (fileEntry.iEntry.IsArchive())
+                setAttMask |= KEntryAttArchive;
+            else
+                clearAttMask |= KEntryAttArchive;
+            
+            if (fileEntry.iEntry.IsHidden())
+                setAttMask |= KEntryAttHidden;
+            else
+                clearAttMask |= KEntryAttHidden;
+ 
+            if (fileEntry.iEntry.IsReadOnly())
+                setAttMask |= KEntryAttReadOnly;
+            else
+                clearAttMask |= KEntryAttReadOnly;
+
+            if (fileEntry.iEntry.IsSystem())
+                setAttMask |= KEntryAttSystem;
+            else
+                clearAttMask |= KEntryAttSystem;
+            }
+        
+        iModel->FileListContainer()->SetScreenLayoutL(EDisplayModeNormal);
+        iModel->FileListContainer()->SetNaviPaneTextL(naviText);
+
+        CFileBrowserAttributeEditorDlg* dlg = CFileBrowserAttributeEditorDlg::NewL(setAttMask, clearAttMask, recurse);
+        TBool dlgResult = dlg->RunEditorLD();
+
+        iModel->FileListContainer()->SetScreenLayoutL(iModel->Settings().iDisplayMode);
+        iModel->FileListContainer()->SetNaviPaneTextL(iCurrentPath);        
+        
+        if (dlgResult && (setAttMask > 0 || clearAttMask > 0))
+            {
+            for (TInt i=0; i<entries->Count(); i++)
+                {
+                TFileEntry fileEntry = entries->At(i);
+ 
+                // append the new command to the command array
+                if (fileEntry.iEntry.IsDir() && recurse)
+                    {
+                    AppendToCommandArrayL(EFileBrowserFileOpCommandAttribs,
+                                          new(ELeave)CCommandParamsAttribs(fileEntry, setAttMask, clearAttMask, fileEntry.iEntry.iModified, CFileMan::ERecurse)
+                                         );
+                    }
+                else
+                    {
+                    AppendToCommandArrayL(EFileBrowserFileOpCommandAttribs,
+                                          new(ELeave)CCommandParamsAttribs(fileEntry, setAttMask, clearAttMask, fileEntry.iEntry.iModified, 0)
+                                         );
+                    }
+                }
+
+            // execute all operations
+            StartExecutingCommandsL(_L("Changing attributes"));          
+            }
+        }
+    
+    CleanupStack::PopAndDestroy(); //entries
+    }
+       
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::SearchL()
+    {
+    iModel->FileListContainer()->SetScreenLayoutL(EDisplayModeNormal);
+    iModel->FileListContainer()->SetNaviPaneTextL(KNullDesC);
+    
+    iSearchAttributes.iSearchDir = iCurrentPath;
+    
+    CFileBrowserSearchQueryDlg* dlg = CFileBrowserSearchQueryDlg::NewL(iSearchAttributes);
+    TBool dlgResult = dlg->RunQueryLD();
+
+    iModel->FileListContainer()->SetScreenLayoutL(iModel->Settings().iDisplayMode);
+    iModel->FileListContainer()->SetNaviPaneTextL(iCurrentPath);        
+    
+    if (dlgResult)
+        {
+        iModel->EikonEnv()->BusyMsgL(_L("** Searching **"), TGulAlignment(EHCenterVTop));
+
+        iFileEntryList->Reset();
+        
+        // if search dir is empty, find from all drives
+        if (iSearchAttributes.iSearchDir == KNullDesC)
+            {
+            for (TInt i=0; i<iDriveEntryList->Count(); i++)
+                {
+                TDriveEntry driveEntry = iDriveEntryList->At(i);
+
+                TBuf<10> driveRoot;
+                driveRoot.Append(driveEntry.iLetter);
+                driveRoot.Append(_L(":\\"));
+                
+                DoSearchFiles(iSearchAttributes.iWildCards, driveRoot);
+                
+                if (iSearchAttributes.iRecurse)
+                    DoSearchFilesRecursiveL(iSearchAttributes.iWildCards, driveRoot);
+                
+                }
+            
+            }
+        
+        // otherwise just search from the selected directory
+        else
+            {
+            DoSearchFiles(iSearchAttributes.iWildCards, iSearchAttributes.iSearchDir);
+            
+            if (iSearchAttributes.iRecurse)
+                DoSearchFilesRecursiveL(iSearchAttributes.iWildCards, iSearchAttributes.iSearchDir);
+            }
+        
+        iModel->EikonEnv()->BusyMsgCancel();
+        
+        TInt operations = iFileEntryList->Count();
+        
+        iListingMode = ESearchResults;
+        iModel->FileListContainer()->ListBox()->SetCurrentItemIndex(0);
+        RefreshViewL();            
+
+        _LIT(KMessage, "%d entries found");
+        TFileName noteMsg;
+        noteMsg.Format(KMessage, operations);
+        
+        CAknInformationNote* note = new(ELeave) CAknInformationNote;
+        note->ExecuteLD(noteMsg);
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileUtils::DoSearchFiles(const TDesC& aFileName, const TDesC& aPath)
+    {
+    TFindFile fileFinder(iFs);
+    CDir* dir;
+    TInt err = fileFinder.FindWildByPath(aFileName, &aPath, dir);
+
+    while (err == KErrNone)
+        {
+        for (TInt i=0; i<dir->Count(); i++)
+            {
+            TEntry entry = (*dir)[i];
+            
+            TTime entryModified = entry.iModified;
+            // convert from universal time
+            if ( iTz.ConvertToLocalTime( entryModified ) == KErrNone )
+                {
+                entryModified = entry.iModified;
+                }
+            if ((entry.IsDir() && entryModified >= iSearchAttributes.iMinDate && entryModified <= iSearchAttributes.iMaxDate) ||
+                (!entry.IsDir() &&entry.iSize >= iSearchAttributes.iMinSize && entry.iSize <= iSearchAttributes.iMaxSize &&
+                 entryModified >= iSearchAttributes.iMinDate && entryModified <= iSearchAttributes.iMaxDate))
+                {
+                TParse parsedName;
+                parsedName.Set(entry.iName, &fileFinder.File(), NULL);
+                
+                if (parsedName.Drive().Length() && aPath.Length() && parsedName.Drive()[0] == aPath[0])
+                    {
+                    TFileEntry fileEntry;
+                    fileEntry.iPath = parsedName.DriveAndPath();
+                    fileEntry.iEntry = entry;
+                    fileEntry.iDirEntries = KErrNotFound;
+                    
+                    TBool appendToArray(EFalse);
+                    
+                    // append directories always
+                    if (entry.IsDir() && !iSearchAttributes.iTextInFile.Length())
+                        {
+                        fileEntry.iIconId = EFixedIconFolder;
+                        appendToArray = ETrue;    
+                        }
+                    
+                    // normal file
+                    else
+                        {
+                        fileEntry.iIconId = EFixedIconEmpty;
+                        
+                        // check if a string needs to be found inside the file
+                        if (iSearchAttributes.iTextInFile.Length())
+                            {
+                            // currently only 8-bit searching, so convert from 16-bit
+                            TBuf8<256> searchText;
+                            searchText.Copy(iSearchAttributes.iTextInFile);
+                            
+                            // specify buffer size and create a buffer
+                            const TInt KReadBufSize = 1024*1024;
+                            HBufC8* buffer = HBufC8::NewLC(KReadBufSize);
+                            TPtr8 bufferPtr = buffer->Des();
+
+                            // open the file for reading
+                            RFile file;
+                            if (file.Open(iFs, parsedName.FullName(), EFileRead) == KErrNone)
+                                {
+                                TInt currentPos(0);
+                                
+                                for (;;)
+                                    {
+                                    // read from the file
+                                    file.Read(currentPos, bufferPtr, KReadBufSize);
+
+                                    // stop looping if the read buffer isn't long enough
+                                    if (bufferPtr.Length() < searchText.Length())
+                                        {
+                                        break;
+                                        }
+                                        
+                                    // try to find the text
+                                    if (bufferPtr.FindF(searchText) >= 0)
+                                        {
+                                        // match found!
+                                        appendToArray = ETrue;
+                                        break;
+                                        }
+                                        
+                                    // calculate the next position
+                                    currentPos += KReadBufSize - searchText.Length();    
+                                    }
+                                
+                                file.Close();
+                                }
+                            
+                            CleanupStack::PopAndDestroy(); //buffer
+                            }
+                        else
+                            {
+                            appendToArray = ETrue;
+                            }
+                        }
+
+                    if (appendToArray)
+                        TRAP(err, iFileEntryList->AppendL(fileEntry));    
+                    }
+                }
+            }
+
+        delete dir;
+        err = fileFinder.FindWild(dir);
+        }
+
+    return err;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileUtils::DoSearchFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath)
+	{
+    TInt err(KErrNone);
+    CDirScan* scan = CDirScan::NewLC(iFs);
+    scan->SetScanDataL(aPath, KEntryAttDir|KEntryAttMatchMask, ESortByName | EAscending | EDirsFirst);
+    CDir* dir = NULL;
+
+    for(;;)
+        {
+        TRAP(err, scan->NextL(dir));
+        if (!dir  || (err != KErrNone))
+            break;
+
+        for (TInt i=0; i<dir->Count(); i++)
+            {
+            TEntry entry = (*dir)[i];
+            
+            if (entry.IsDir())
+                {
+                TFileName path(scan->FullPath());
+                
+                if (path.Length())
+                    {
+                    path.Append(entry.iName);
+                    path.Append(_L("\\"));
+                    DoSearchFiles(aFileName, path);
+                    }
+                }
+            }
+        delete(dir);
+        }
+
+    CleanupStack::PopAndDestroy(scan);
+    return err;
+    }
+         
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::NewFileL()
+    {
+    TFileName newName;
+    
+    CAknTextQueryDialog* textQuery = CAknTextQueryDialog::NewL(newName);
+    textQuery->SetPromptL(_L("Enter filename:"));
+    
+    if (textQuery->ExecuteLD(R_GENERAL_TEXT_QUERY))
+        {
+        TFileName fullPath = iCurrentPath;
+        fullPath.Append(newName);
+        
+        TParse nameParser;
+        TInt err = nameParser.SetNoWild(fullPath, NULL, NULL);
+        
+        if (err == KErrNone)
+            {
+            // do not try to recreate the file if it already exists
+            if (BaflUtils::PathExists(iFs, nameParser.DriveAndPath()))
+                {
+                err = iFileOps->CreateEmptyFile(fullPath);
+                }
+            else
+                err = KErrAlreadyExists;
+            }
+
+        if (err == KErrNone)    
+            {
+            CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+            note->ExecuteLD(_L("New file created"));    
+            }
+        
+        else if (err == KErrAlreadyExists)    
+            {
+            CAknInformationNote* note = new(ELeave) CAknInformationNote;
+            note->ExecuteLD(_L("File already exists"));    
+            }            
+
+        else    
+            {
+            CTextResolver* textResolver = CTextResolver::NewLC(*iModel->EikonEnv());     
+                
+            CAknErrorNote* note = new(ELeave) CAknErrorNote;
+            note->ExecuteLD( textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) );    
+
+            CleanupStack::PopAndDestroy();  //textResolver     
+            }
+
+        RefreshViewL();
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::NewDirectoryL()
+    {    
+    TFileName newDirectory;
+    
+    CAknTextQueryDialog* textQuery = CAknTextQueryDialog::NewL(newDirectory);
+    textQuery->SetPromptL(_L("Enter directory name:"));
+    
+    if (textQuery->ExecuteLD(R_GENERAL_TEXT_QUERY))
+        {
+        TFileName fullPath = iCurrentPath;
+        fullPath.Append(newDirectory);
+        fullPath.Append(_L("\\"));
+        
+        TInt err = iFileOps->MkDirAll(fullPath, 0, ETrue);
+
+        if (err == KErrNone)    
+            {
+            CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+            note->ExecuteLD(_L("New directory created"));    
+            }
+        
+        else if (err == KErrAlreadyExists)    
+            {
+            CAknInformationNote* note = new(ELeave) CAknInformationNote;
+            note->ExecuteLD(_L("Directory already exists"));    
+            }            
+
+        else    
+            {
+            CTextResolver* textResolver = CTextResolver::NewLC(*iModel->EikonEnv());     
+                
+            CAknErrorNote* note = new(ELeave) CAknErrorNote;
+            note->ExecuteLD( textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) );    
+
+            CleanupStack::PopAndDestroy();  //textResolver     
+            }
+
+        RefreshViewL();
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::SendToL()
+    {
+    CFileEntryList* entries = new(ELeave) CFileEntryList(32);
+    GetSelectedItemsOrCurrentItemL(entries);
+    CleanupStack::PushL(entries);
+
+    TInt operations(0);
+
+    CSendUi* sendUi = CSendUi::NewL();
+    CleanupStack::PushL(sendUi);
+    CMessageData* messageData = CMessageData::NewL();
+    CleanupStack::PushL(messageData);            
+        
+    for (TInt i=0; i<entries->Count(); i++)
+        {
+        TFileEntry fileEntry = entries->At(i);
+
+        // only supported for normal file entries
+        if (!fileEntry.iEntry.IsDir())
+            {
+            TFileName fullPath = fileEntry.iPath;
+            fullPath.Append(fileEntry.iEntry.iName);
+            
+            messageData->AppendAttachmentL(fullPath);
+            operations++;
+            
+            }
+        }
+    
+    if (operations > 0)
+        {
+        sendUi->ShowQueryAndSendL(messageData, TSendingCapabilities(0, 0, TSendingCapabilities::ESupportsAttachments));
+
+        // I guess this note is not needed..
+        /* 
+        _LIT(KMessage, "%d entries sent");
+        TFileName noteMsg;
+        noteMsg.Format(KMessage, operations);
+        
+        CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+        note->ExecuteLD(noteMsg);    
+        */
+        }
+    else
+        {
+        _LIT(KMessage, "Nothing to send");
+        CAknInformationNote* note = new(ELeave) CAknInformationNote;
+        note->ExecuteLD(KMessage);    
+        }        
+        
+    CleanupStack::PopAndDestroy(3); // entries, sendUi, messageData    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::CompressL()
+    {
+    CFileEntryList* entries = new(ELeave) CFileEntryList(16);
+    GetSelectedItemsOrCurrentItemL(entries);
+    CleanupStack::PushL(entries);
+    
+    for (TInt i=0; i<entries->Count(); i++)
+        {
+        TFileEntry fileEntry = entries->At(i);
+        
+        TFileName sourceEntry = fileEntry.iPath;
+        sourceEntry.Append(fileEntry.iEntry.iName);
+        
+        TFileName targetEntry = sourceEntry;
+        targetEntry.Append(KGZipExt);
+        
+        TFileName targetEntryShort;
+        targetEntryShort.Copy(fileEntry.iEntry.iName);
+        targetEntryShort.Append(KGZipExt);
+        
+        if (BaflUtils::FileExists(iFs, targetEntry))
+            {
+            _LIT(KMessage, "%S already exists");
+            TFileName noteMsg;
+            noteMsg.Format(KMessage, &targetEntryShort);
+            
+            CAknInformationNote* note = new(ELeave) CAknInformationNote;
+            note->ExecuteLD(noteMsg);           
+            }
+        else
+            {
+            TRAPD(err,
+                RFile inputFile;
+                User::LeaveIfError(inputFile.Open(iFs, sourceEntry, EFileStream | EFileRead | EFileShareAny));
+                CleanupClosePushL(inputFile);
+                
+                CEZFileToGZip* gZip = CEZFileToGZip::NewLC(iFs, targetEntry, inputFile);
+
+                while (gZip->DeflateL())
+                    ;
+
+                CleanupStack::PopAndDestroy(2); //inputFile, gZip
+                );
+             
+             if (err == KErrNone)
+                {
+                _LIT(KMessage, "%S created succesfully");
+                TFileName noteMsg;
+                noteMsg.Format(KMessage, &targetEntryShort);
+                
+                CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+                note->ExecuteLD(noteMsg);
+                }
+             else
+                {
+                _LIT(KMessage, "Unable to create %S");
+                TFileName noteMsg;
+                noteMsg.Format(KMessage, &targetEntryShort);
+                
+                CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                note->ExecuteLD(noteMsg);
+                }
+                
+            RefreshViewL();
+            }
+        }
+
+    CleanupStack::PopAndDestroy(); //entries
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::DecompressL()
+    {
+    CFileEntryList* entries = new(ELeave) CFileEntryList(16);
+    GetSelectedItemsOrCurrentItemL(entries);
+    CleanupStack::PushL(entries);
+    
+    for (TInt i=0; i<entries->Count(); i++)
+        {
+        TFileEntry fileEntry = entries->At(i);
+        
+        TFileName sourceEntry = fileEntry.iPath;
+        sourceEntry.Append(fileEntry.iEntry.iName);
+        
+        TFileName targetEntry;
+        TFileName targetEntryShort;
+
+        TInt sourceNameLen = fileEntry.iEntry.iName.Length();
+        TInt gZipExtLen = KGZipExt().Length();
+
+        if (sourceNameLen > gZipExtLen && sourceEntry.Right(gZipExtLen).CompareF(KGZipExt) == 0)
+            {
+            targetEntry = sourceEntry.Left(sourceEntry.Length() - gZipExtLen);
+            targetEntryShort = fileEntry.iEntry.iName.Left(sourceNameLen - gZipExtLen);
+            
+            if (BaflUtils::FileExists(iFs, targetEntry))
+                {
+                _LIT(KMessage, "%S already exists");
+                TFileName noteMsg;
+                noteMsg.Format(KMessage, &targetEntryShort);
+                
+                CAknInformationNote* note = new(ELeave) CAknInformationNote;
+                note->ExecuteLD(noteMsg);           
+                }
+            else
+                {
+                TRAPD(err,
+                    RFile outputFile;
+                    User::LeaveIfError(outputFile.Create(iFs, targetEntry, EFileStream | EFileWrite | EFileShareExclusive));
+                    CleanupClosePushL(outputFile);
+                    
+                    CEZGZipToFile* gZip = CEZGZipToFile::NewLC(iFs, sourceEntry, outputFile);
+
+                    while (gZip->InflateL())
+                        ;            
+
+                    CleanupStack::PopAndDestroy(2); //outputFile, gZip
+                    );
+                 
+                 if (err == KErrNone)
+                    {
+                    _LIT(KMessage, "%S decompressed succesfully");
+                    TFileName noteMsg;
+                    noteMsg.Format(KMessage, &fileEntry.iEntry.iName);
+                    
+                    CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+                    note->ExecuteLD(noteMsg);
+                    }
+                 else
+                    {
+                    _LIT(KMessage, "Unable to decompress %S");
+                    TFileName noteMsg;
+                    noteMsg.Format(KMessage, &fileEntry.iEntry.iName);
+                    
+                    CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                    note->ExecuteLD(noteMsg);
+                    }
+                    
+                RefreshViewL();
+                }
+            }
+        else
+            {
+            _LIT(KMessage, "%S does not have %S extension");
+            TFileName noteMsg;
+            noteMsg.Format(KMessage, &fileEntry.iEntry.iName, &KGZipExt);
+            
+            CAknInformationNote* note = new(ELeave) CAknInformationNote;
+            note->ExecuteLD(noteMsg);              
+            }
+        }
+
+    CleanupStack::PopAndDestroy(); //entries
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::PropertiesL()
+    {
+    TBool showDialog(EFalse);
+    
+    _LIT(KPropertiesEntryStr,       "%S\t%S");
+    _LIT(KPropertiesEntryInt,       "%S\t%d");
+    _LIT(KPropertiesEntryUintHex,   "%S\t0x%x");
+    
+    _LIT(KDateFormat,               "%D%M%Y%/0%1%/1%2%/2%3%/3");
+    _LIT(KTimeFormat,               "%-B%:0%J%:1%T%:2%S%:3%+B");
+    
+    _LIT(KMediaType,                "Media");
+    _LIT(KAttributes,               "Atts");
+    _LIT(KVolumeName,               "Name");
+    _LIT(KUniqueID,                 "ID");
+    _LIT(KNumberOfEntries,          "Entries");
+    _LIT(KNumberOfFiles,            "Files");
+    _LIT(KUsed,                     "Used (B)");
+    _LIT(KFree,                     "Free (B)");
+    _LIT(KSize,                     "Size (B)");
+    _LIT(KPath,                     "Path");
+    _LIT(KDate,                     "Date");
+    _LIT(KTime,                     "Time");
+    _LIT(KMimeType,                 "Mime");
+    _LIT(KOpensWith,                "Opens");
+ 
+
+    // create an array for the items
+	CDesCArray* entryLines = new(ELeave) CDesCArrayFlat(16);
+	CleanupStack::PushL(entryLines);
+    TFileName titleText;
+    
+    // just get current item
+    TInt currentItemIndex = iModel->FileListContainer()->CurrentListBoxItemIndex();
+    
+    if (IsDriveListViewActive() && iDriveEntryList->Count() > currentItemIndex && currentItemIndex >= 0)
+        {
+        // it is a drive entry
+        TDriveEntry driveEntry = iDriveEntryList->At(currentItemIndex);
+        TFileName textEntry;
+        
+        // set title
+        titleText.Append(driveEntry.iLetter);
+        titleText.Append(_L(":"));
+        
+        // media type
+        textEntry.Format(KPropertiesEntryStr, &KMediaType, &driveEntry.iMediaTypeDesc);
+        entryLines->AppendL(textEntry);
+
+        // attributes
+        textEntry.Format(KPropertiesEntryStr, &KAttributes, &driveEntry.iAttributesDesc);
+        entryLines->AppendL(textEntry);
+
+        // volume name
+        if (driveEntry.iVolumeInfo.iName.Length())
+            {
+            textEntry.Format(KPropertiesEntryStr, &KVolumeName, &driveEntry.iVolumeInfo.iName);
+            entryLines->AppendL(textEntry);
+            }
+
+        // unique id
+        textEntry.Format(KPropertiesEntryUintHex, &KUniqueID, driveEntry.iVolumeInfo.iUniqueID);
+        entryLines->AppendL(textEntry);
+        
+        // number of files
+        if (iModel->Settings().iShowSubDirectoryInfo)
+            {
+            iFindFileEntryList->Reset();
+            
+            TBuf<10> driveRoot;
+            driveRoot.Append(driveEntry.iLetter);
+            driveRoot.Append(_L(":\\"));
+
+            DoFindFiles(_L("*"), driveRoot);
+            DoFindFilesRecursiveL(_L("*"), driveRoot);
+            
+            textEntry.Format(KPropertiesEntryInt, &KNumberOfFiles, iFindFileEntryList->Count());
+            entryLines->AppendL(textEntry);
+            
+            iFindFileEntryList->Reset();
+            }
+      
+        // used
+        TBuf<32> usedBuf;
+        usedBuf.AppendNum(driveEntry.iVolumeInfo.iSize-driveEntry.iVolumeInfo.iFree, TRealFormat(KDefaultRealWidth, 0));
+        textEntry.Format(KPropertiesEntryStr, &KUsed, &usedBuf);
+        entryLines->AppendL(textEntry);        
+
+        // free
+        TBuf<32> freeBuf;
+        freeBuf.AppendNum(driveEntry.iVolumeInfo.iFree, TRealFormat(KDefaultRealWidth, 0));
+        textEntry.Format(KPropertiesEntryStr, &KFree, &freeBuf);
+        entryLines->AppendL(textEntry);
+                
+        // size
+        TBuf<32> sizeBuf;
+        sizeBuf.AppendNum(driveEntry.iVolumeInfo.iSize, TRealFormat(KDefaultRealWidth, 0));
+        textEntry.Format(KPropertiesEntryStr, &KSize, &sizeBuf);
+        entryLines->AppendL(textEntry);   
+
+        showDialog = ETrue;
+        }
+    
+    else if (iFileEntryList->Count() > currentItemIndex && currentItemIndex >= 0)
+        {
+        // it is a file or a directory entry
+        TFileEntry fileEntry = iFileEntryList->At(currentItemIndex);
+        TFileName textEntry;
+        
+        // set title
+        titleText.Append(fileEntry.iEntry.iName);
+        
+        // path
+        textEntry.Format(KPropertiesEntryStr, &KPath, &fileEntry.iPath);
+        entryLines->AppendL(textEntry);
+
+        // date
+        TTime entryModified = fileEntry.iEntry.iModified;
+        
+        // convert from universal time
+        if ( iTz.ConvertToLocalTime( entryModified ) == KErrNone )
+            {
+            entryModified = fileEntry.iEntry.iModified; // use universal time
+            }
+        
+        TBuf<32> dateBuf;
+        entryModified.FormatL(dateBuf, KDateFormat);
+        textEntry.Format(KPropertiesEntryStr, &KDate, &dateBuf);
+        entryLines->AppendL(textEntry);
+
+        // time
+        TBuf<32> timeBuf;
+        entryModified.FormatL(timeBuf, KTimeFormat);
+        textEntry.Format(KPropertiesEntryStr, &KTime, &timeBuf);
+        entryLines->AppendL(textEntry);
+
+        if (!fileEntry.iEntry.IsDir())
+            {
+            // size
+            TBuf<32> sizeBuf;
+            sizeBuf.AppendNum(fileEntry.iEntry.iSize, TRealFormat(KDefaultRealWidth, 0));
+            textEntry.Format(KPropertiesEntryStr, &KSize, &sizeBuf);
+            entryLines->AppendL(textEntry);            
+            }
+        else if (fileEntry.iEntry.IsDir() && iModel->Settings().iShowSubDirectoryInfo)
+            {
+            iFindFileEntryList->Reset();
+            
+            TFileName fullPath;
+            fullPath.Append(fileEntry.iPath);
+            fullPath.Append(fileEntry.iEntry.iName);
+            fullPath.Append(_L("\\"));
+            
+            // number of entries
+            CDir* subDir = NULL;
+            if (iFs.GetDir(fullPath, KEntryAttMatchMask, ESortNone | EDirsFirst, subDir) == KErrNone)
+                {
+                CleanupStack::PushL(subDir);
+                textEntry.Format(KPropertiesEntryInt, &KNumberOfEntries, subDir->Count());
+                entryLines->AppendL(textEntry);
+                CleanupStack::PopAndDestroy(); //subDir 
+                }
+            
+            // number of files
+            DoFindFiles(_L("*"), fullPath);
+            DoFindFilesRecursiveL(_L("*"), fullPath);
+            textEntry.Format(KPropertiesEntryInt, &KNumberOfFiles, iFindFileEntryList->Count());
+            entryLines->AppendL(textEntry);
+            
+            // size
+            TInt64 size(0);
+            for (TInt i=0; i<iFindFileEntryList->Count(); i++)
+                {
+                TFileEntry fileEntry = iFindFileEntryList->At(i);
+                size += fileEntry.iEntry.iSize;
+                }
+            
+            TBuf<32> sizeBuf;
+            sizeBuf.AppendNum(size, TRealFormat(KDefaultRealWidth, 0));
+            textEntry.Format(KPropertiesEntryStr, &KSize, &sizeBuf);
+            entryLines->AppendL(textEntry); 
+            
+            iFindFileEntryList->Reset();            
+            }
+        
+        // attributes
+        TBuf<32> attBuf;
+        if (fileEntry.iEntry.IsArchive())
+            attBuf.Append(_L("Arc "));
+        if (fileEntry.iEntry.IsHidden())
+            attBuf.Append(_L("Hid "));
+        if (fileEntry.iEntry.IsReadOnly())
+            attBuf.Append(_L("R/O "));
+        if (fileEntry.iEntry.IsSystem())
+            attBuf.Append(_L("Sys"));
+        textEntry.Format(KPropertiesEntryStr, &KAttributes, &attBuf);
+        entryLines->AppendL(textEntry);            
+
+        if (!fileEntry.iEntry.IsDir())
+            {
+            // mime type
+            TFileName fullPath = fileEntry.iPath;
+            fullPath.Append(fileEntry.iEntry.iName);
+            TDataType dataType;
+            TUid appUid;
+            if (iModel->LsSession().AppForDocument(fullPath, appUid, dataType) == KErrNone)
+                {
+                TBuf<128> mimeTypeBuf;
+                mimeTypeBuf.Copy(dataType.Des8());
+                if (mimeTypeBuf == KNullDesC)
+                    mimeTypeBuf.Copy(_L("N/A"));
+                textEntry.Format(KPropertiesEntryStr, &KMimeType, &mimeTypeBuf);
+                entryLines->AppendL(textEntry); 
+                }
+
+            // opens with
+            TApaAppInfo appInfo;
+            if (iModel->LsSession().GetAppInfo(appInfo, appUid) == KErrNone)
+                {
+                TFileName opensWithBuf;
+                _LIT(KOpensWithFormat, "%S (0x%08X)");
+                opensWithBuf.Format(KOpensWithFormat, &appInfo.iCaption, appInfo.iUid);
+                textEntry.Format(KPropertiesEntryStr, &KOpensWith, &opensWithBuf);
+                entryLines->AppendL(textEntry); 
+                }
+            }
+        
+        showDialog = ETrue;
+        }   
+
+
+    if (showDialog)
+        {
+        CAknSingleHeadingPopupMenuStyleListBox* listBox = new(ELeave) CAknSingleHeadingPopupMenuStyleListBox;
+        CleanupStack::PushL(listBox);
+        
+        CAknPopupList* popupList = CAknPopupList::NewL(listBox, R_AVKON_SOFTKEYS_OK_EMPTY, AknPopupLayouts::EMenuDoubleWindow);
+        CleanupStack::PushL(popupList);
+
+        listBox->ConstructL(popupList, CEikListBox::ELeftDownInViewRect);
+        listBox->ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue);
+        listBox->CreateScrollBarFrameL(ETrue);
+        listBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
+        listBox->Model()->SetItemTextArray(entryLines);
+        listBox->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray);
+        listBox->HandleItemAdditionL();
+        
+        popupList->SetTitleL(titleText);
+        popupList->ExecuteLD();
+        
+        CleanupStack::Pop(); // popupList
+        CleanupStack::PopAndDestroy(); // listBox
+        }
+
+    CleanupStack::PopAndDestroy(); //entryLines
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::OpenWithApparcL()
+    {
+    // just get current item
+    TInt currentItemIndex = iModel->FileListContainer()->CurrentListBoxItemIndex();
+    
+    if (iFileEntryList->Count() > currentItemIndex && currentItemIndex >= 0)
+        {
+        TFileEntry fileEntry = iFileEntryList->At(currentItemIndex);
+        
+        TFileName fullPath = fileEntry.iPath;
+        fullPath.Append(fileEntry.iEntry.iName);
+        
+        TInt err1(KErrNone), err2(KErrNone);
+        TUid appUid;
+        TDataType dataType;
+        TBool isProgram;
+        
+        err1 = iModel->LsSession().AppForDocument(fullPath, appUid, dataType);
+        err2 = iModel->LsSession().IsProgram(fullPath, isProgram);
+        
+        if (err1 == KErrNone && err2 == KErrNone)
+            {
+            if (appUid != KNullUid)
+                {
+                // found an app, run using it
+                TApaTaskList taskList(iModel->EikonEnv()->WsSession());
+                TApaTask task = (taskList.FindApp(appUid));
+                if (task.Exists())
+                    {
+                    User::LeaveIfError(task.SwitchOpenFile(fullPath));
+                    task.BringToForeground();
+                    }
+                else
+                    {
+                    TThreadId id;
+                    iModel->LsSession().StartDocument(fullPath, appUid, id, RApaLsSession::ESwitchFiles);
+                    }
+                }
+            else if (isProgram)
+                {
+                LaunchProgramL(fullPath);
+                }            
+            }
+        }   
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::HandleServerAppExit(TInt aReason)
+	{
+	if (iOpenFileService)
+		{
+		delete iOpenFileService;
+		iOpenFileService = NULL;
+		}
+	MAknServerAppExitObserver::HandleServerAppExit(aReason);
+	}
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::OpenWithDocHandlerL(TBool aEmbed)
+    {
+    // just get current item 
+    TInt currentItemIndex = iModel->FileListContainer()->CurrentListBoxItemIndex();
+    
+    if (iFileEntryList->Count() > currentItemIndex && currentItemIndex >= 0)
+        {
+        TFileEntry fileEntry = iFileEntryList->At(currentItemIndex);
+        
+        TFileName fullPath = fileEntry.iPath;
+        fullPath.Append(fileEntry.iEntry.iName);
+
+        RFile sharableFile;
+        iDocHandler->OpenTempFileL(fullPath, sharableFile);
+        CleanupClosePushL(sharableFile);
+        TDataType dataType;
+        if (aEmbed)
+    	    iDocHandler->OpenFileEmbeddedL(sharableFile, dataType);
+        else
+    	    iDocHandler->OpenFileL(sharableFile, dataType);
+        CleanupStack::PopAndDestroy();  //sharableFile
+        }   
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::OpenWithFileServiceL()
+    {
+    // just get current item 
+    TInt currentItemIndex = iModel->FileListContainer()->CurrentListBoxItemIndex();
+    
+    if (iFileEntryList->Count() > currentItemIndex && currentItemIndex >= 0)
+        {
+        TFileEntry fileEntry = iFileEntryList->At(currentItemIndex);
+        
+        TFileName fullPath = fileEntry.iPath;
+        fullPath.Append(fileEntry.iEntry.iName);
+
+    	TBool itemSelected(EFalse);
+        RFile sharableFile;
+        TUid appUidExtracted;
+        
+        TRAPD(err,
+           
+        	// use doc handler to get a sharable file handle
+            iDocHandler->OpenTempFileL(fullPath, sharableFile);
+            CleanupClosePushL(sharableFile);
+            
+            // find the data type
+            TDataRecognitionResult dataType;
+        	User::LeaveIfError(iModel->LsSession().RecognizeData(sharableFile, dataType));
+
+        	// get all apps that support OpenFileService for this datatype
+        	CApaAppServiceInfoArray* apps = iModel->LsSession().GetServiceImplementationsLC(KOpenServiceUid, dataType.iDataType);
+        	TArray<TApaAppServiceInfo> appServiceInfos = apps->Array();
+    	
+        	if (appServiceInfos.Count() > 0)
+        		{
+        		// build an array of the app names
+        		CDesCArray* names = new (ELeave) CDesCArrayFlat(16);
+        		CleanupStack::PushL(names);
+        		for (TInt ii=0; ii<appServiceInfos.Count(); ii++)
+        			{
+        			TUid appUid = appServiceInfos[ii].Uid();
+        			TApaAppInfo appInfo;
+        			if (iModel->LsSession().GetAppInfo(appInfo, appUid) == KErrNone)
+        				{
+        				names->AppendL(appInfo.iCaption);
+        				}
+        			else
+        				{
+        				TBuf<10> buf;
+        				buf.Format(_L("0x%08x"), appUid);
+        				names->AppendL(buf);
+        				}
+        			}
+    		
+        		// use a list query to select the app
+        		TInt index(0);
+        		CAknListQueryDialog* dlg = new(ELeave) CAknListQueryDialog(&index);
+        		dlg->PrepareLC(R_APP_SELECTION_QUERY);
+        		dlg->SetItemTextArray(names);
+        		dlg->SetOwnershipType(ELbmDoesNotOwnItemArray);
+
+        		if(dlg->RunLD())
+        			{
+        			// extract the chosen UID
+        			appUidExtracted = appServiceInfos[index].Uid();
+        			itemSelected = ETrue;
+        			}
+    		
+        		CleanupStack::PopAndDestroy(); // names
+        		}
+
+            if (itemSelected)
+                {
+                // start OpenFileService for the selected app
+                CAiwGenericParamList& paramList = iDocHandler->InParamListL();
+                
+                if (iOpenFileService)
+                    {
+                    delete iOpenFileService;
+                    iOpenFileService = NULL;
+                    }
+
+                iOpenFileService = CAknOpenFileService::NewL(appUidExtracted, sharableFile, this, &paramList);
+                }
+
+            CleanupStack::PopAndDestroy(2); // sharableFile, apps
+
+            ); // TRAPD
+
+        if (err != KErrNone)
+            {
+            _LIT(KMessage, "No file service available for %S");
+            TFileName noteMsg;
+            noteMsg.Format(KMessage, &fileEntry.iEntry.iName);
+            
+            CAknInformationNote* note = new(ELeave) CAknInformationNote;
+            note->ExecuteLD(noteMsg);            
+            }
+        }   
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TBool CFileBrowserFileUtils::FileExists(const TDesC& aPath)
+    {
+    return BaflUtils::FileExists(iFs, aPath);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileUtils::LaunchProgramL(const TDesC& aPath)
+    {
+    CApaCommandLine* commandLine = CApaCommandLine::NewLC();
+    commandLine->SetExecutableNameL(aPath);
+    commandLine->SetCommandL(EApaCommandRun);
+    TInt err = iModel->LsSession().StartApp(*commandLine);
+    CleanupStack::PopAndDestroy(); //commandLine
+    return err;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::MemoryInfoPopupL()
+    {
+    _LIT(KUsedBytesEntry, "Used: %S bytes\n");
+    _LIT(KFreeBytesEntry, "Free: %S bytes\n");
+    _LIT(KSizeBytesEntry, "Size: %S bytes\n");
+        
+    HBufC* messageBuf = HBufC::NewLC(2048);
+    TPtr messagePtr = messageBuf->Des();
+    TBuf<128> entryLine;
+
+    // RAM
+    TMemoryInfoV1Buf ramMemory;
+    UserHal::MemoryInfo(ramMemory);
+    messagePtr.Append(_L("RAM\n"));
+
+    // used
+    TBuf<32> usedBuf;
+    usedBuf.AppendNum(ramMemory().iMaxFreeRamInBytes-ramMemory().iFreeRamInBytes, TRealFormat(KDefaultRealWidth, 0));
+    entryLine.Format(KUsedBytesEntry, &usedBuf);
+    messagePtr.Append(entryLine);        
+
+    // free
+    TBuf<32> freeBuf;
+    freeBuf.AppendNum(ramMemory().iFreeRamInBytes, TRealFormat(KDefaultRealWidth, 0));
+    entryLine.Format(KFreeBytesEntry, &freeBuf);
+    messagePtr.Append(entryLine);
+            
+    // size
+    TBuf<32> sizeBuf;
+    sizeBuf.AppendNum(ramMemory().iMaxFreeRamInBytes, TRealFormat(KDefaultRealWidth, 0));
+    entryLine.Format(KSizeBytesEntry, &sizeBuf);
+    messagePtr.Append(entryLine); 
+    
+    // All drives
+    for (TInt i=0; i<iDriveEntryList->Count(); i++)
+        {
+        TDriveEntry driveEntry = iDriveEntryList->At(i);
+
+        messagePtr.Append(_L("\n"));
+        messagePtr.Append(driveEntry.iLetter);
+        messagePtr.Append(_L(":\n"));
+
+        // used
+        TBuf<32> usedBuf;
+        usedBuf.AppendNum(driveEntry.iVolumeInfo.iSize-driveEntry.iVolumeInfo.iFree, TRealFormat(KDefaultRealWidth, 0));
+        entryLine.Format(KUsedBytesEntry, &usedBuf);
+        messagePtr.Append(entryLine);        
+
+        // free
+        TBuf<32> freeBuf;
+        freeBuf.AppendNum(driveEntry.iVolumeInfo.iFree, TRealFormat(KDefaultRealWidth, 0));
+        entryLine.Format(KFreeBytesEntry, &freeBuf);
+        messagePtr.Append(entryLine);
+                
+        // size
+        TBuf<32> sizeBuf;
+        sizeBuf.AppendNum(driveEntry.iVolumeInfo.iSize, TRealFormat(KDefaultRealWidth, 0));
+        entryLine.Format(KSizeBytesEntry, &sizeBuf);
+        messagePtr.Append(entryLine); 
+        }
+
+    CAknMessageQueryDialog* dialog = new(ELeave) CAknMessageQueryDialog;
+    dialog->PrepareLC(R_MEMORYINFO_DIALOG);
+    dialog->SetMessageTextL(messagePtr);
+    dialog->RunLD();
+    
+    CleanupStack::PopAndDestroy(); //messageBuf
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::ShowFileCheckSumsL(TInt aType)
+    {
+     // get current item
+    TInt currentItemIndex = iModel->FileListContainer()->CurrentListBoxItemIndex();
+    
+    if (iFileEntryList->Count() > currentItemIndex && currentItemIndex >= 0)
+        {
+        TFileEntry fileEntry = iFileEntryList->At(currentItemIndex);
+        TFileName fullPath = fileEntry.iPath;
+        fullPath.Append(fileEntry.iEntry.iName);
+        
+        // try to open the file for reading
+        RFile fileP;
+        TInt err = fileP.Open(iModel->EikonEnv()->FsSession(), fullPath, EFileRead|EFileShareReadersOnly);
+        
+        if (err == KErrNone)
+            {
+            CleanupClosePushL(fileP);
+
+            TBuf<128> checkSum;
+            HBufC* messageBuf = HBufC::NewLC(2048);
+            TPtr messagePtr = messageBuf->Des();
+            
+            // get MD5 checksum
+            if (aType == EFileBrowserCmdFileChecksumsMD5)
+                {
+                CMD5* md5 = CMD5::NewL();
+                CleanupStack::PushL(md5);
+                HBufC8* md5Buf = MessageDigestInHexLC(md5, fileP);
+                checkSum.Copy(*md5Buf);
+                messagePtr.Append(_L("MD5\n"));
+                messagePtr.Append(checkSum);
+                CleanupStack::PopAndDestroy(2); // md5, md5Buf
+                }
+
+            // get MD2 checksum
+            else if (aType == EFileBrowserCmdFileChecksumsMD2)
+                {                
+                CMD2* md2 = CMD2::NewL();
+                CleanupStack::PushL(md2);
+                HBufC8* md2Buf = MessageDigestInHexLC(md2, fileP);
+                checkSum.Copy(*md2Buf);
+                messagePtr.Append(_L("MD2\n"));
+                messagePtr.Append(checkSum);
+                CleanupStack::PopAndDestroy(2); // md2, md2Buf
+                }
+
+            // get SHA-1 checksum
+            else if (aType == EFileBrowserCmdFileChecksumsSHA1)
+                {
+                CSHA1* sha1 = CSHA1::NewL();
+                CleanupStack::PushL(sha1);
+                HBufC8* sha1Buf = MessageDigestInHexLC(sha1, fileP);
+                checkSum.Copy(*sha1Buf);
+                messagePtr.Append(_L("SHA-1\n"));
+                messagePtr.Append(checkSum);
+                CleanupStack::PopAndDestroy(2); // sha1, sha1Buf
+                }
+            
+            else
+                {
+                User::Panic(_L("Inv.CS.Type"), 723);
+                }
+                            
+            // show dialog
+            CAknMessageQueryDialog* dialog = new(ELeave) CAknMessageQueryDialog;
+            dialog->PrepareLC(R_CHECKSUMS_DIALOG);
+            dialog->SetMessageTextL(messagePtr);
+            dialog->SetHeaderTextL(fileEntry.iEntry.iName);
+            dialog->RunLD();
+    
+            CleanupStack::PopAndDestroy(2); // messageBuf, fileP
+            }
+        else
+            {
+            // open failed, show an error note
+            CTextResolver* textResolver = CTextResolver::NewLC(*iModel->EikonEnv());     
+                
+            CAknErrorNote* note = new(ELeave) CAknErrorNote;
+            note->ExecuteLD( textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) );    
+
+            CleanupStack::PopAndDestroy();  //textResolver               
+            }
+            
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+HBufC8* CFileBrowserFileUtils::MessageDigestInHexLC(CMessageDigest* aMD, RFile& aFile)
+    {
+    // seek to file start
+    TInt startPos(0);
+    aFile.Seek(ESeekStart, startPos);
+
+    // create result buffer
+    HBufC8* result = HBufC8::NewLC(128);
+
+    const TInt KBufSize(1024);
+    TInt fileSize(0);
+    TInt fileOffset(0);
+
+    // get file size
+    aFile.Size(fileSize);
+
+    HBufC8* buf = HBufC8::NewMaxLC(KBufSize);
+    TPtr8 bufPtr(buf->Des());
+
+    // read to buffer
+    while (fileOffset < fileSize - KBufSize)
+        {
+        aFile.Read(bufPtr, KBufSize);
+        aMD->Hash(bufPtr);
+        fileOffset += bufPtr.Length();
+        }
+
+    aFile.Read(bufPtr, fileSize - fileOffset);
+    bufPtr.SetLength(fileSize - fileOffset);
+    
+    // get final message digest
+    TPtrC8 hashedSig(aMD->Final(bufPtr));
+    
+    // change size of the result buffer
+    result->ReAllocL(hashedSig.Length() * 2);
+    TPtr8 resultPtr = result->Des();
+
+    // convert to hex format
+    for (TInt i=0; i<hashedSig.Length(); i++)
+        {
+        resultPtr.AppendFormat(_L8("%+02x"), hashedSig[i]);
+        }
+                    
+    CleanupStack::PopAndDestroy(); // buf
+    
+    return result;
+    }
+        
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::SetErrRdL(TBool aEnable)
+    {
+    #ifndef FILEBROWSER_LITE
+    if (iModel->Settings().iBypassPlatformSecurity)
+        {
+        TInt err(KErrNone);
+        
+        if (aEnable)
+            {
+            // make sure that the directory exists
+            iFileOps->MkDirAll(KErrRdPath);        
+
+            // create the file
+            err = iFileOps->CreateEmptyFile(KErrRdPath);
+            }
+        else    
+            {
+            // get TEntry of ErrRd
+            TEntry entry;
+            err = iFs.Entry(KErrRdPath, entry);
+            
+            if (err == KErrNone)
+                {
+                TFileEntry fileEntry;
+                fileEntry.iPath = KErrRdDir;
+                fileEntry.iEntry = entry;
+                
+                err = iFileOps->Delete(fileEntry);                
+                }
+            }        
+
+        // update view
+        RefreshViewL(); 
+    
+        if (err == KErrNone)    
+            {
+            CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+            note->ExecuteLD(_L("State changed"));    
+            }
+        else    
+            {
+            CAknErrorNote* note = new(ELeave) CAknErrorNote;
+            note->ExecuteLD(_L("Cannot change the state"));    
+            }        
+        }
+    else
+        {
+        CAknInformationNote* note = new(ELeave) CAknInformationNote;
+        note->ExecuteLD(_L("Enable \"bypass platform security\" from the settings first"));          
+        }
+    #else
+        aEnable = aEnable;
+        CAknInformationNote* note = new(ELeave) CAknInformationNote;
+        note->ExecuteLD(_L("Not supported in lite version"));          
+    #endif
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::EnableAvkonIconCacheL(TBool aEnable)
+    {
+#ifndef __SERIES60_30__
+    if (AknIconConfig::EnableAknIconSrvCache(aEnable) == KErrNone)
+        {
+        CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+        note->ExecuteLD(_L("State changed"));        
+        }
+    else
+        {
+        CAknErrorNote* note = new(ELeave) CAknErrorNote;
+        note->ExecuteLD(_L("Unknown error occured"));        
+        }
+ #else
+    aEnable = aEnable;
+    CAknInformationNote* note = new(ELeave) CAknInformationNote;
+    note->ExecuteLD(_L("Not supported in S60 3.0"));  
+ #endif
+ 
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::SimulateLeaveL()
+    {
+    TInt leaveCode(-6);
+
+    CAknNumberQueryDialog* numberQuery = CAknNumberQueryDialog::NewL(leaveCode);
+    numberQuery->SetPromptL(_L("Leave code"));
+
+    if (numberQuery->ExecuteLD(R_GENERAL_NUMERIC_QUERY))    
+        {
+        User::Leave(leaveCode);
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::SimulatePanicL()
+    {
+    TInt panicCode(555);
+    TBuf<128> panicCategory;
+    panicCategory.Copy(_L("Test Category"));
+    
+    CAknTextQueryDialog* textQuery = CAknTextQueryDialog::NewL(panicCategory);
+    textQuery->SetPromptL(_L("Panic category"));
+    
+    if (textQuery->ExecuteLD(R_GENERAL_TEXT_QUERY))
+        {
+        CAknNumberQueryDialog* numberQuery = CAknNumberQueryDialog::NewL(panicCode);
+        numberQuery->SetPromptL(_L("Panic code"));
+
+        if (numberQuery->ExecuteLD(R_GENERAL_NUMERIC_QUERY))    
+            {
+            User::Panic(panicCategory, panicCode);
+            }        
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::SimulateExceptionL()
+    {
+    TInt exceptionCode(0);
+
+    CAknNumberQueryDialog* numberQuery = CAknNumberQueryDialog::NewL(exceptionCode);
+    numberQuery->SetPromptL(_L("Exception code"));
+
+    if (numberQuery->ExecuteLD(R_GENERAL_NUMERIC_QUERY))    
+        {
+        User::RaiseException((TExcType)exceptionCode);
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::SetDebugMaskL()
+    {
+    // get current debug mask
+    TUint32 dbgMask = UserSvr::DebugMask();
+    
+    // convert the value in hex format
+    TBuf<64> hexBuf;
+    hexBuf.Copy(_L("0x"));
+    hexBuf.AppendNum(dbgMask, EHex);
+    
+    // do the query
+    CAknTextQueryDialog* textQuery = CAknTextQueryDialog::NewL(hexBuf);
+    textQuery->SetPromptL(_L("Kernel debug mask in hex format"));
+
+    if (textQuery->ExecuteLD(R_GENERAL_TEXT_QUERY))
+        {
+        // check value
+        if (hexBuf.Length() > 2 && hexBuf[0]=='0' && hexBuf[1]=='x')
+            {
+            // remove 0x from the beginning
+            hexBuf.Copy(hexBuf.Right(hexBuf.Length()-2));
+            
+            // convert the string back to decimal
+            TLex converter;
+            converter.Assign(hexBuf);
+            
+            if (converter.Val(dbgMask, EHex) == KErrNone)
+                {
+                User::SetDebugMask(dbgMask);
+                
+                CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+                note->ExecuteLD(_L("Changed"));            
+                }
+            else
+                {
+                CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                note->ExecuteLD(_L("Cannot convert value"));            
+                }        
+            }            
+        else        
+            {
+            CAknErrorNote* note = new(ELeave) CAknErrorNote;
+            note->ExecuteLD(_L("Not in hex format"));            
+            }
+        }
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::WriteAllAppsL()
+    {
+    _LIT(KAllAppsFileName, "AllApps.txt");
+    TFileName allAppsPath = PathInfo::PhoneMemoryRootPath();
+    allAppsPath.Append(KAllAppsFileName);
+
+    RFile file;
+    if (file.Replace(iFs, allAppsPath, EFileWrite) == KErrNone)
+        {
+        CleanupClosePushL(file);
+        
+        CDesC8Array* appsArray = new(ELeave) CDesC8ArrayFlat(192);
+        CleanupStack::PushL(appsArray);
+        
+        TBuf8<KMaxFileName> fileEntry;
+        TBuf8<KMaxFileName> appFullPath;
+        _LIT8(KAppEntryFormat, "%S (0x%08X)%S");
+        TApaAppInfo appInfo;
+
+        iModel->LsSession().GetAllApps();        
+
+        while (iModel->LsSession().GetNextApp(appInfo) == KErrNone)
+            {
+            appFullPath.Copy(appInfo.iFullName);
+            fileEntry.Format(KAppEntryFormat, &appFullPath, appInfo.iUid, &KFileNewLine);
+            appsArray->AppendL(fileEntry);    
+            }
+        
+        appsArray->Sort();
+        
+        for (TInt i=0; i<appsArray->Count(); i++)
+            {
+            file.Write(appsArray->MdcaPoint(i));
+            }
+        
+        CleanupStack::PopAndDestroy(2); //appsArray, file
+        
+        _LIT(KMessage, "App list written to %S");
+        TFileName noteMsg;
+        noteMsg.Format(KMessage, &allAppsPath);
+        
+        CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote();
+        note->SetTimeout(CAknNoteDialog::ENoTimeout);
+        note->ExecuteLD(noteMsg);
+        }
+    else
+        {
+        _LIT(KMessage, "Failed writing to %S");
+        TFileName noteMsg;
+        noteMsg.Format(KMessage, &allAppsPath);
+        
+        CAknErrorNote* note = new(ELeave) CAknErrorNote();
+        note->SetTimeout(CAknNoteDialog::ENoTimeout);
+        note->ExecuteLD(noteMsg);
+        }    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::WriteAllFilesL()
+    {
+    _LIT(KAllFilesFileName, "AllFiles.txt");
+    TFileName allFilesPath = PathInfo::PhoneMemoryRootPath();
+    allFilesPath.Append(KAllFilesFileName);
+
+    RFile file;
+    if (file.Replace(iFs, allFilesPath, EFileWrite) == KErrNone)
+        {
+        CleanupClosePushL(file);
+        iFindFileEntryList->Reset();
+        
+        iModel->EikonEnv()->BusyMsgL(_L("** Generating **"), TGulAlignment(EHCenterVTop));
+        
+        for (TInt i=0; i<iDriveEntryList->Count(); i++)
+            {
+            TDriveEntry driveEntry = iDriveEntryList->At(i);
+
+            TBuf<10> driveRoot;
+            driveRoot.Append(driveEntry.iLetter);
+            driveRoot.Append(_L(":\\"));
+
+            // current dir
+            DoFindFiles(_L("*"), driveRoot);
+            
+            // recurse into sub directories
+            DoFindFilesRecursiveL(_L("*"), driveRoot);
+            }
+        
+        // write entries
+        TBuf8<KMaxFileName> writeBuf;
+        for (TInt i=0; i<iFindFileEntryList->Count(); i++)
+            {
+            TFileEntry fileEntry = iFindFileEntryList->At(i);
+            
+            writeBuf.Copy(fileEntry.iPath);
+            writeBuf.Append(fileEntry.iEntry.iName);
+            writeBuf.Append(KFileNewLine);
+            
+            file.Write(writeBuf);
+            }
+        
+        iModel->EikonEnv()->BusyMsgCancel();
+        
+        CleanupStack::PopAndDestroy(); //file
+        iFindFileEntryList->Reset();
+        
+        _LIT(KMessage, "File list written to %S");
+        TFileName noteMsg;
+        noteMsg.Format(KMessage, &allFilesPath);
+        
+        CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote();
+        note->SetTimeout(CAknNoteDialog::ENoTimeout);
+        note->ExecuteLD(noteMsg);
+        }
+    else
+        {
+        _LIT(KMessage, "Failed writing to %S");
+        TFileName noteMsg;
+        noteMsg.Format(KMessage, &allFilesPath);
+        
+        CAknErrorNote* note = new(ELeave) CAknErrorNote();
+        note->SetTimeout(CAknNoteDialog::ENoTimeout);
+        note->ExecuteLD(noteMsg);
+        }    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileUtils::DoFindFiles(const TDesC& aFileName, const TDesC& aPath)
+    {
+    TFindFile fileFinder(iFs);
+    CDir* dir;
+    TInt err = fileFinder.FindWildByPath(aFileName, &aPath, dir);
+
+    while (err == KErrNone)
+        {
+        for (TInt i=0; i<dir->Count(); i++)
+            {
+            TEntry entry = (*dir)[i];
+
+            // ignore any directory entries
+            if (!entry.IsDir() && entry.iName.Length() && aPath.Length())
+                {
+                TParse parsedName;
+                parsedName.Set(entry.iName, &fileFinder.File(), NULL);
+                
+                if (parsedName.Drive().Length() && aPath.Length() && parsedName.Drive()[0] == aPath[0])
+                    {
+                    TFileEntry fileEntry;
+                    fileEntry.iPath = parsedName.DriveAndPath();
+                    fileEntry.iEntry = entry;
+                    fileEntry.iDirEntries = KErrNotFound;
+                    fileEntry.iIconId = EFixedIconEmpty;
+                    
+                    TRAP(err, iFindFileEntryList->AppendL(fileEntry));             
+                    }
+                }
+            }
+
+        delete dir;
+        dir = NULL;
+        err = fileFinder.FindWild(dir);
+        }
+
+    return err;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserFileUtils::DoFindFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath)
+	{
+    TInt err(KErrNone);
+    CDirScan* scan = CDirScan::NewLC(iFs);
+    scan->SetScanDataL(aPath, KEntryAttDir|KEntryAttMatchMask, ESortByName | EAscending | EDirsFirst);
+    CDir* dir = NULL;
+
+    for(;;)
+        {
+        TRAP(err, scan->NextL(dir));
+        if (!dir  || (err != KErrNone))
+            break;
+
+        for (TInt i=0; i<dir->Count(); i++)
+            {
+            TEntry entry = (*dir)[i];
+            
+            if (entry.IsDir())
+                {
+                TFileName path(scan->FullPath());
+                
+                if (path.Length())
+                    {
+                    path.Append(entry.iName);
+                    path.Append(_L("\\"));
+                    DoFindFiles(aFileName, path);
+                    }
+                }
+            }
+        delete(dir);
+        }
+
+    CleanupStack::PopAndDestroy(scan);
+    return err;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::ListOpenFilesL()
+    {
+    iFileEntryList->Reset();
+
+    CFileList* dir = NULL;
+    TOpenFileScan fileScan(iFs);
+    fileScan.NextL(dir);
+    
+    while (dir)
+        {
+        for (TInt i=0; i<dir->Count(); i++)
+            {
+            TEntry entry = (*dir)[i];
+            TFileName fullPath;
+
+            // TOpenFileScan does not return drive letters for the entries, so try to guess it
+            if (entry.iName.Length() > 2 && entry.iName[1] != ':')
+                {
+                for (TInt i=0; i<iDriveEntryList->Count(); i++)
+                    {
+                    TDriveEntry driveEntry = iDriveEntryList->At(i);
+                    
+                    TFileName guessPath;
+                    guessPath.Append(driveEntry.iLetter);
+                    guessPath.Append(_L(":"));
+                    guessPath.Append(entry.iName);
+                    
+                    // check if the file exists
+                    if (BaflUtils::FileExists(iFs, guessPath))
+                        {
+                        // if it's on read only drive, then take it or check if it's really in use
+                        TBool readOnlyDrive(ETrue);
+                        BaflUtils::DiskIsReadOnly(iFs, guessPath, readOnlyDrive);
+                        
+                        if (readOnlyDrive || iFs.SetEntry(guessPath, entry.iModified, NULL, NULL) == KErrInUse)
+                            {
+                            fullPath = guessPath;
+                            break;
+                            }
+                        }
+                    }
+                }
+            else
+                {
+                fullPath = entry.iName;   
+                }
+
+            TParse nameParser;
+            if (fullPath.Length() && nameParser.SetNoWild(fullPath, NULL, NULL) == KErrNone)
+                {
+                entry.iName = nameParser.NameAndExt();
+                
+                TFileEntry fileEntry;
+                fileEntry.iPath = nameParser.DriveAndPath();
+                fileEntry.iEntry = entry;
+                fileEntry.iDirEntries = KErrNotFound;
+                fileEntry.iIconId = EFixedIconEmpty;
+                
+                iFileEntryList->AppendL(fileEntry);                
+                }
+            }
+            
+        delete dir;
+        dir = NULL;
+        fileScan.NextL(dir);
+        }
+
+    TInt operations = iFileEntryList->Count();
+    
+    iListingMode = EOpenFiles;
+    iModel->FileListContainer()->ListBox()->SetCurrentItemIndex(0);
+    RefreshViewL();            
+
+    _LIT(KMessage, "%d open files found");
+    TFileName noteMsg;
+    noteMsg.Format(KMessage, operations);
+    
+    CAknInformationNote* note = new(ELeave) CAknInformationNote;
+    note->ExecuteLD(noteMsg);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::ListMessageAttachmentsL(TInt aType)
+    {
+    iFileEntryList->Reset();
+
+    CMsvSession* session = CMsvSession::OpenSyncL(*this);
+    CleanupStack::PushL(session);
+    
+    CMsvEntry* context = NULL;
+    
+    if (aType == EFileBrowserCmdToolsMsgAttachmentsInbox)
+        context = session->GetEntryL(KMsvGlobalInBoxIndexEntryId);
+    else if (aType == EFileBrowserCmdToolsMsgAttachmentsDrafts)
+        context = session->GetEntryL(KMsvDraftEntryId);
+    else if (aType == EFileBrowserCmdToolsMsgAttachmentsSentItems)
+        context = session->GetEntryL(KMsvSentEntryId);
+    else if (aType == EFileBrowserCmdToolsMsgAttachmentsOutbox)
+        context = session->GetEntryL(KMsvGlobalOutBoxIndexEntryId);
+    else
+        User::Panic(_L("MsgAtt.Mode"), 100);
+    
+    CleanupStack::PushL(context);
+    
+    CDesCArray* attPaths = new(ELeave) CDesCArrayFlat(128);
+    CleanupStack::PushL(attPaths);
+    
+    // read attachment paths
+    ReadAttachmentPathsRecursiveL(session, context, attPaths);
+    
+    // create file entries of the paths
+    for (TInt i=0; i<attPaths->MdcaCount(); i++)
+        {
+        TFileEntry fileEntry;
+        TEntry entry;
+        TParse nameParser;
+        
+        if (attPaths->MdcaPoint(i).Length() &&
+            nameParser.SetNoWild(attPaths->MdcaPoint(i), NULL, NULL) == KErrNone &&
+            iFs.Entry(attPaths->MdcaPoint(i), entry) == KErrNone)
+            {
+            TFileEntry fileEntry;
+            fileEntry.iPath = nameParser.DriveAndPath();
+            fileEntry.iEntry = entry;
+            fileEntry.iDirEntries = KErrNotFound;
+            fileEntry.iIconId = EFixedIconEmpty;
+
+            iFileEntryList->AppendL(fileEntry);                
+            }
+        }
+    
+    CleanupStack::PopAndDestroy(3); //session, context, attPaths
+            
+    TInt operations = iFileEntryList->Count();
+    
+    if (aType == EFileBrowserCmdToolsMsgAttachmentsInbox)
+        iListingMode = EMsgAttachmentsInbox;
+    else if (aType == EFileBrowserCmdToolsMsgAttachmentsDrafts)
+        iListingMode = EMsgAttachmentsDrafts;
+    else if (aType == EFileBrowserCmdToolsMsgAttachmentsSentItems)
+        iListingMode = EMsgAttachmentsSentItems;
+    else if (aType == EFileBrowserCmdToolsMsgAttachmentsOutbox)
+        iListingMode = EMsgAttachmentsOutbox;
+
+    iModel->FileListContainer()->ListBox()->SetCurrentItemIndex(0);
+    RefreshViewL();            
+
+    _LIT(KMessage, "%d files found");
+    TFileName noteMsg;
+    noteMsg.Format(KMessage, operations);
+    
+    CAknInformationNote* note = new(ELeave) CAknInformationNote;
+    note->ExecuteLD(noteMsg);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::ReadAttachmentPathsRecursiveL(CMsvSession* aSession, CMsvEntry* aContext, CDesCArray* aAttPaths)
+    {
+    CMsvEntrySelection* entrySelection = aContext->ChildrenL(); 
+    CleanupStack::PushL(entrySelection);
+    
+    for (TInt i=0; i<entrySelection->Count(); i++)
+        {
+        CMsvEntry* entry = aSession->GetEntryL((*entrySelection)[i]);
+        CleanupStack::PushL(entry);
+        
+        CMsvStore* store = NULL;
+        TRAPD(err, store = entry->ReadStoreL());
+        
+        if (err == KErrNone)
+            {
+            CleanupStack::PushL(store);
+
+            for (TInt j=0; j<store->AttachmentManagerL().AttachmentCount(); j++)
+                {
+                CMsvAttachment* attachment = store->AttachmentManagerL().GetAttachmentInfoL(j);
+                CleanupStack::PushL(attachment);
+                
+                aAttPaths->AppendL(attachment->FilePath());
+                
+                CleanupStack::PopAndDestroy(); //attachment
+                }
+            CleanupStack::PopAndDestroy(); // store
+            }
+
+        // recurse into children
+        if (entry->Count() > 0)
+            {
+            ReadAttachmentPathsRecursiveL(aSession, entry, aAttPaths);
+            }
+
+        CleanupStack::PopAndDestroy(); // entry
+        }      
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::WriteMsgStoreWalkL()
+    {
+    _LIT(KAllAppsFileName, "MsgStoreWalk.txt");
+    TFileName allAppsPath = PathInfo::PhoneMemoryRootPath();
+    allAppsPath.Append(KAllAppsFileName);
+
+    if (iMsgStoreWalkFile.Replace(iFs, allAppsPath, EFileWrite) == KErrNone)
+        {
+        CMsvSession* session = CMsvSession::OpenSyncL(*this);
+        CleanupStack::PushL(session);
+        
+        CMsvEntry* context = session->GetEntryL(KMsvRootIndexEntryId);
+        CleanupStack::PushL(context);
+        
+        iMsgStoreWalkFile.Write(_L8("id  service_id  related_id  type  mtm  date  size  error  biotype  mtmdata1  mtmdata2  mtmdata3  description  details\r\n\r\n"));
+        
+        // write details about the root entry
+        DoWriteMessageEntryInfoL(context, iMsgStoreWalkFile, 0);
+        
+        // get and write info recursively
+        TInt level(1);        
+        WriteMessageEntryInfoRecursiveL(session, context, iMsgStoreWalkFile, level);
+
+        CleanupStack::PopAndDestroy(2); //session, context
+        
+        iMsgStoreWalkFile.Flush();
+        iMsgStoreWalkFile.Close();
+        
+        _LIT(KMessage, "Msg. store walk written to %S");
+        TFileName noteMsg;
+        noteMsg.Format(KMessage, &allAppsPath);
+        
+        CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote();
+        note->SetTimeout(CAknNoteDialog::ENoTimeout);
+        note->ExecuteLD(noteMsg);
+        }
+    else
+        {
+        _LIT(KMessage, "Failed writing to %S");
+        TFileName noteMsg;
+        noteMsg.Format(KMessage, &allAppsPath);
+        
+        CAknErrorNote* note = new(ELeave) CAknErrorNote();
+        note->SetTimeout(CAknNoteDialog::ENoTimeout);
+        note->ExecuteLD(noteMsg);
+        }    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::WriteMessageEntryInfoRecursiveL(CMsvSession* aSession, CMsvEntry* aContext, RFile& aFile, TInt& aLevel)
+    {
+    CMsvEntrySelection* entrySelection = aContext->ChildrenL(); 
+    CleanupStack::PushL(entrySelection);
+    
+    for (TInt i=0; i<entrySelection->Count(); i++)
+        {
+        CMsvEntry* entry = aSession->GetEntryL((*entrySelection)[i]);
+        CleanupStack::PushL(entry);
+        
+        DoWriteMessageEntryInfoL(entry, aFile, aLevel);
+
+        // recurse into children
+        if (entry->Count() > 0)
+            {
+            aLevel++;
+            WriteMessageEntryInfoRecursiveL(aSession, entry, aFile, aLevel);
+            aLevel--;
+            }
+
+        CleanupStack::PopAndDestroy(); // entry
+        }      
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::DoWriteMessageEntryInfoL(CMsvEntry* aContext, RFile& aFile, TInt aLevel)
+    {
+    TMsvEntry messageEntry = aContext->Entry();
+    
+    for (TInt j=0; j<aLevel; j++)
+        {
+        aFile.Write(_L8("     "));
+        }
+
+    TBuf8<256> desc;
+    desc.Copy(messageEntry.iDescription);
+
+    TBuf8<256> details;
+    details.Copy(messageEntry.iDetails);
+
+    _LIT8(KLine, "-> %d  %d  %d  %d  %d  %Ld  %d  %d  %d  %d  %d  %d  %S  %S\r\n");
+    TBuf8<1024> buf;
+    buf.Format(KLine, messageEntry.Id(), messageEntry.iServiceId, messageEntry.iRelatedId, messageEntry.iType.iUid,
+        messageEntry.iMtm.iUid, messageEntry.iDate.Int64(), messageEntry.iSize, messageEntry.iError, messageEntry.iBioType,
+        messageEntry.iMtmData1, messageEntry.iMtmData2, messageEntry.iMtmData3, &desc, &details);
+
+    aFile.Write(buf);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::FileEditorL(TInt aType)
+    {
+    // just get current item 
+    TInt currentItemIndex = iModel->FileListContainer()->CurrentListBoxItemIndex();
+    
+    if (iFileEntryList->Count() > currentItemIndex && currentItemIndex >= 0)
+        {
+        TFileEntry fileEntry = iFileEntryList->At(currentItemIndex);
+        
+        // only valid for files
+        if (!fileEntry.iEntry.IsDir())
+            {
+            TFileName fullPath = fileEntry.iPath;
+            fullPath.Append(fileEntry.iEntry.iName);
+
+            iModel->FileListContainer()->SetNaviPaneTextL(fileEntry.iEntry.iName);
+    
+            TInt editorMode(0);
+            
+            if (aType == EFileBrowserCmdFileViewText)
+                editorMode = EFileEditorViewAsText;
+            else if (aType == EFileBrowserCmdFileViewHex)
+                editorMode = EFileEditorViewAsHex;
+            else if (aType == EFileBrowserCmdFileEditText)
+                editorMode = EFileEditorEditAsText;
+            else if (aType == EFileBrowserCmdFileEditHex)
+                editorMode = EFileEditorEditAsHex;
+            else
+                User::Panic(_L("Inv.Ed.Mode"), 843);
+            
+            // launch dialog
+            CFileBrowserFileEditorDlg* dlg = CFileBrowserFileEditorDlg::NewL(fullPath, editorMode);
+            dlg->RunDlgLD();
+
+            iModel->FileListContainer()->SetNaviPaneTextL(iCurrentPath);
+            
+            if (aType == EFileBrowserCmdFileEditText || aType == EFileBrowserCmdFileEditHex)
+                RefreshViewL();        
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TBool CFileBrowserFileUtils::DriveSnapShotPossible()
+    {
+    // check that E-drive is available
+    TBool EDriveIsOK(EFalse);
+    
+    for (TInt i=0; i<iDriveEntryList->Count(); i++)
+        {
+        TDriveEntry driveEntry = iDriveEntryList->At(i);
+        
+        if (driveEntry.iNumber == EDriveE)
+            {
+            if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttLocked || driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAbsent)
+                EDriveIsOK = EFalse;
+            else
+                EDriveIsOK = ETrue;
+            }
+        }
+    
+    if (!EDriveIsOK)
+        return EFalse;
+    
+    // get current item 
+    TInt currentItemIndex = iModel->FileListContainer()->CurrentListBoxItemIndex();
+    
+    if (iDriveEntryList->Count() > currentItemIndex && currentItemIndex >= 0)
+        {
+        TDriveEntry driveEntry = iDriveEntryList->At(currentItemIndex);
+ 
+        // drive snapshot not possible when E-drive is highlighted, since that's where we are copying
+        if (driveEntry.iNumber == EDriveE)
+            return EFalse;
+        else
+            return ETrue;
+        }
+    
+    return EFalse;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::DriveSnapShotL()
+    {
+    if (iModel->Settings().iBypassPlatformSecurity)
+        {
+        // get current item 
+        TInt currentItemIndex = iModel->FileListContainer()->CurrentListBoxItemIndex();
+
+        if (iDriveEntryList->Count() > currentItemIndex && currentItemIndex >= 0)
+            {
+            TDriveEntry driveEntry = iDriveEntryList->At(currentItemIndex);
+            
+            TChar sourceDriveLetter = driveEntry.iLetter;
+            TChar targetDriveLetter = 'E';  // hardcoded drive letter, could be better if would be queried from the user
+            
+            // append to the command array
+            AppendToCommandArrayL(EFileBrowserFileOpCommandDriveSnapShot,
+                                  new(ELeave)CCommandParamsDriveSnapShot(sourceDriveLetter, targetDriveLetter)
+                                 );
+                                 
+            // execute the operation
+            StartExecutingCommandsL(_L("Copying"));
+            }
+        }
+    else
+        {
+        CAknInformationNote* note = new(ELeave) CAknInformationNote;
+        note->ExecuteLD(_L("Enable \"bypass platform security\" from the settings first"));          
+        }
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::SetDrivePasswordL()
+    {
+    // get current item 
+    TInt currentItemIndex = iModel->FileListContainer()->CurrentListBoxItemIndex();
+    
+    if (iDriveEntryList->Count() > currentItemIndex && currentItemIndex >= 0)
+        {
+        TMediaPassword oldPassword;
+        TMediaPassword newPassword;
+        TFileName oldPassword16;
+        TFileName newPassword16;
+        
+        TDriveEntry driveEntry = iDriveEntryList->At(currentItemIndex);
+        
+        // query existing password if it already exists
+        if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttHasPassword)
+            {
+            CAknTextQueryDialog* textQuery = CAknTextQueryDialog::NewL(oldPassword16);
+            textQuery->SetPromptL(_L("Existing password:"));
+            
+            if (textQuery->ExecuteLD(R_GENERAL_TEXT_QUERY))
+                {
+                ConvertCharsToPwd(oldPassword16, oldPassword);    
+                }
+            else
+                {
+                return;    
+                }            
+            }
+        
+        // query new password    
+        newPassword16.Copy(oldPassword16);
+        
+        CAknTextQueryDialog* textQuery = CAknTextQueryDialog::NewL(newPassword16);
+        textQuery->SetPromptL(_L("New password:"));
+        
+        if (textQuery->ExecuteLD(R_GENERAL_TEXT_QUERY))
+            {
+            ConvertCharsToPwd(newPassword16, newPassword);
+            
+            // set the password, does not actually lock the drive
+            TInt err = iFs.LockDrive(driveEntry.iNumber, oldPassword, newPassword, ETrue);
+            
+            if (err == KErrNone)
+                {
+                CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+                note->ExecuteLD(_L("Password set"));                     
+                }
+            else if (err == KErrNotSupported)
+                {
+                CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                note->ExecuteLD(_L("Not supported for this drive"));                     
+                }
+            else
+                {
+                CTextResolver* textResolver = CTextResolver::NewLC(*iModel->EikonEnv());     
+                    
+                CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                note->ExecuteLD( textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) );    
+
+                CleanupStack::PopAndDestroy();  //textResolver                       
+                }
+            
+            RefreshViewL();
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::UnlockDriveL()
+    {
+    // get current item 
+    TInt currentItemIndex = iModel->FileListContainer()->CurrentListBoxItemIndex();
+    
+    if (iDriveEntryList->Count() > currentItemIndex && currentItemIndex >= 0)
+        {
+        TDriveEntry driveEntry = iDriveEntryList->At(currentItemIndex);
+
+        // check if the drive is locked
+        if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttLocked)
+            {
+            TMediaPassword oldPassword;
+            TFileName oldPassword16;
+
+            CAknTextQueryDialog* textQuery = CAknTextQueryDialog::NewL(oldPassword16);
+            textQuery->SetPromptL(_L("Existing password:"));
+
+            if (textQuery->ExecuteLD(R_GENERAL_TEXT_QUERY))
+                {
+                ConvertCharsToPwd(oldPassword16, oldPassword);
+                
+                // unlock the drive
+                TInt err = iFs.UnlockDrive(driveEntry.iNumber, oldPassword, ETrue) == KErrNone;
+                
+                if (err == KErrNone)
+                    {
+                    CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+                    note->ExecuteLD(_L("Drive unlocked"));                     
+                    }
+                else if (err == KErrNotSupported)
+                    {
+                    CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                    note->ExecuteLD(_L("Not supported for this drive"));                     
+                    }
+                else
+                    {
+                    CTextResolver* textResolver = CTextResolver::NewLC(*iModel->EikonEnv());     
+                        
+                    CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                    note->ExecuteLD( textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) );    
+
+                    CleanupStack::PopAndDestroy();  //textResolver                       
+                    }
+                
+                RefreshViewL();
+                }
+            }
+        else
+            {
+            CAknInformationNote* note = new(ELeave) CAknInformationNote;
+            note->ExecuteLD(_L("This drive is not locked"));             
+            }
+
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::ClearDrivePasswordL()
+    {
+    // get current item 
+    TInt currentItemIndex = iModel->FileListContainer()->CurrentListBoxItemIndex();
+    
+    if (iDriveEntryList->Count() > currentItemIndex && currentItemIndex >= 0)
+        {
+        TDriveEntry driveEntry = iDriveEntryList->At(currentItemIndex);
+        
+        // check if the drive has a password
+        if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttHasPassword)
+            {
+            TMediaPassword oldPassword;
+            TFileName oldPassword16;
+
+            CAknTextQueryDialog* textQuery = CAknTextQueryDialog::NewL(oldPassword16);
+            textQuery->SetPromptL(_L("Existing password:"));
+
+            if (textQuery->ExecuteLD(R_GENERAL_TEXT_QUERY))
+                {
+                ConvertCharsToPwd(oldPassword16, oldPassword);
+                
+                // clear the password from the drive
+                TInt err = iFs.ClearPassword(driveEntry.iNumber, oldPassword);
+                
+                if (err == KErrNone)
+                    {
+                    CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+                    note->ExecuteLD(_L("Password cleared"));                     
+                    }
+                else if (err == KErrNotSupported)
+                    {
+                    CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                    note->ExecuteLD(_L("Not supported for this drive"));                     
+                    }
+                else
+                    {
+                    CTextResolver* textResolver = CTextResolver::NewLC(*iModel->EikonEnv());     
+                        
+                    CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                    note->ExecuteLD( textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) );    
+
+                    CleanupStack::PopAndDestroy();  //textResolver                       
+                    }
+                
+                RefreshViewL();
+                }
+            }
+        else
+            {
+            CAknInformationNote* note = new(ELeave) CAknInformationNote;
+            note->ExecuteLD(_L("This drive has no password"));                     
+            }    
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::EraseDrivePasswordL()
+    {
+    // get current item 
+    TInt currentItemIndex = iModel->FileListContainer()->CurrentListBoxItemIndex();
+    
+    if (iDriveEntryList->Count() > currentItemIndex && currentItemIndex >= 0)
+        {
+        TDriveEntry driveEntry = iDriveEntryList->At(currentItemIndex);
+        
+        // check if the drive has a password
+        if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttHasPassword)
+            {
+            CAknQueryDialog* query = CAknQueryDialog::NewL();
+            
+            if (query->ExecuteLD(R_GENERAL_CONFIRMATION_QUERY, _L("Are you sure? All data can be lost!")))
+                {
+                // erase the password from the drive
+                TInt err(KErrNone);
+                err = iFs.ErasePassword(driveEntry.iNumber);
+                
+                if (err == KErrNone)
+                    {
+                    CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+                    note->ExecuteLD(_L("Password erased"));                     
+                    }
+                else if (err == KErrNotSupported)
+                    {
+                    CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                    note->ExecuteLD(_L("Not supported for this drive"));                     
+                    }
+                else
+                    {
+                    CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                    note->ExecuteLD(_L("Cannot erase, you may have to format the drive first"));                     
+                    }
+
+                RefreshViewL();
+                }
+            }
+        else
+            {
+            CAknInformationNote* note = new(ELeave) CAknInformationNote;
+            note->ExecuteLD(_L("This drive has no password"));                     
+            }         
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::FormatDriveL(TBool aQuickFormat)
+    {
+    // get current item 
+    TInt currentItemIndex = iModel->FileListContainer()->CurrentListBoxItemIndex();
+    
+    if (iDriveEntryList->Count() > currentItemIndex && currentItemIndex >= 0)
+        {
+        TDriveEntry driveEntry = iDriveEntryList->At(currentItemIndex);
+        
+        CAknQueryDialog* query = CAknQueryDialog::NewL();
+        
+        if (query->ExecuteLD(R_GENERAL_CONFIRMATION_QUERY, _L("Are you sure? All data will be lost!")))
+            {
+            TInt err(KErrNone);
+            TInt formatCount(0);
+            
+            TBuf<10> driveRoot;
+            driveRoot.Append(driveEntry.iLetter);
+            driveRoot.Append(_L(":"));
+            
+            TUint formatMode(0);
+            if (aQuickFormat)
+                formatMode = ESpecialFormat|EQuickFormat;
+            else
+                formatMode = ESpecialFormat|EFullFormat;
+            
+            // set as system application to prevent getting shut down events
+            iModel->EikonEnv()->SetSystem(ETrue);
+            
+            // first close any open applications            
+            CBaBackupSessionWrapper* BSWrapper = CBaBackupSessionWrapper::NewL();
+            CleanupStack::PushL(BSWrapper);
+
+            TBackupOperationAttributes atts(MBackupObserver::EReleaseLockNoAccess, MBackupOperationObserver::EStart);
+            BSWrapper->NotifyBackupOperationL(atts);
+            
+            CAsyncWaiter* waiter = CAsyncWaiter::NewLC();
+            BSWrapper->CloseAll( MBackupObserver::EReleaseLockNoAccess, waiter->iStatus );
+            waiter->StartAndWait();
+            CleanupStack::PopAndDestroy(); //waiter
+
+            // some delay to make sure all applications have been closed
+            User::After(1000000);
+
+            // format the drive
+            RFormat format;
+            err = format.Open(iFs, driveRoot, formatMode, formatCount);
+            
+            // Forced format for locked card
+            if ( err == KErrLocked )
+                {
+                // Erase password and try again
+                err = iFs.ErasePassword( driveEntry.iNumber );
+                if ( !err )
+                    {
+                    err = format.Open(iFs, driveRoot, formatMode, formatCount);
+                    }
+                }
+
+            if( err != KErrNone &&  err != KErrLocked )
+                {
+                CAknQueryDialog* lockQuery = CAknQueryDialog::NewL();
+                if ( lockQuery->ExecuteLD(R_GENERAL_CONFIRMATION_QUERY, _L("Memory card in use by other application. Proceed anyway?")))
+                    {
+                    // If format could not be started, someone is still keeping
+                    // files open on media. Let's try to dismount file system, then 
+                    // remount with own extension embedded and try again.
+
+                    TFullName fsName;
+                    err = iFs.FileSystemName( fsName, driveEntry.iNumber );
+
+                    if ( err == KErrNone && fsName.Length() > 0 )
+                        {
+                        // Prevent SysAp shutting down applications
+                        RProperty::Set(
+                            KPSUidCoreApplicationUIs,
+                            KCoreAppUIsMmcRemovedWithoutEject,
+                            ECoreAppUIsEjectCommandUsed );
+
+                        TRequestStatus stat;
+                        iFs.NotifyDismount( driveEntry.iNumber, stat, EFsDismountForceDismount );
+                        User::WaitForRequest( stat );
+
+                        // Unfortunately, at the moment we have to wait until clients have received 
+                        // notification about card dismount. Otherwise at least causes problems with 
+                        // theme selected from card. In future clients should use new notify-API.
+                        User::After( KForcedFormatTimeout );
+
+                        // Let's set priority higher than normally. This is done to decrease the chance 
+                        // that someone reopens files on memory card after mandatory file system 
+                        // remounting hence preventing formatting again.
+                        TThreadPriority priority( RThread().Priority() );
+                        RThread().SetPriority( EPriorityAbsoluteHigh );
+
+                        // Mount file system back...
+                        err = iFs.MountFileSystem( fsName, driveEntry.iNumber );
+                        err = format.Open(iFs, driveRoot, formatMode, formatCount);
+                        RThread().SetPriority( priority );
+                        }
+                    }
+                }
+            
+            
+            if (err == KErrNone)
+                {
+                // needs to be implemented with active objects
+                // CAknProgressDialog* dlg = new(ELeave) CAknProgressDialog(formatCount, 1, 1, NULL);
+                // dlg->SetTone(CAknNoteDialog::ENoTone);
+                // dlg->ExecuteLD(R_FORMAT_PROGRESS_NOTE);
+                
+                while (formatCount && err == KErrNone)
+                    {
+                    err = format.Next(formatCount);
+                    }
+                }
+
+            format.Close();
+
+            // restart closed applications
+            TBackupOperationAttributes atts2(MBackupObserver::ETakeLock, MBackupOperationObserver::EEnd);
+            BSWrapper->NotifyBackupOperationL(atts2);
+            BSWrapper->RestartAll();
+            CleanupStack::PopAndDestroy(); //BSWrapper
+
+            // system status not needed anymore
+            iModel->EikonEnv()->SetSystem(EFalse);
+                                    
+                                    
+            if (err == KErrNone)
+                {
+                CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+                note->ExecuteLD(_L("Format succeeded"));                     
+                }
+            else if (err == KErrNotSupported)
+                {
+                CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                note->ExecuteLD(_L("Not supported for this drive"));                     
+                }
+            else
+                {
+                CTextResolver* textResolver = CTextResolver::NewLC(*iModel->EikonEnv());     
+                    
+                CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                note->ExecuteLD( textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) );    
+
+                CleanupStack::PopAndDestroy();  //textResolver                       
+                }
+
+            RefreshViewL();
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::EraseMBRL()
+    {
+    #ifndef FILEBROWSER_LITE
+    if (iModel->Settings().iBypassPlatformSecurity)
+        {
+        // get current item 
+        TInt currentItemIndex = iModel->FileListContainer()->CurrentListBoxItemIndex();
+        
+        if (iDriveEntryList->Count() > currentItemIndex && currentItemIndex >= 0)
+            {
+            TDriveEntry driveEntry = iDriveEntryList->At(currentItemIndex);
+            
+            CAknQueryDialog* query = CAknQueryDialog::NewL();
+            if (query->ExecuteLD(R_GENERAL_CONFIRMATION_QUERY, _L("Are you sure? Your media driver must support this!")))
+                {
+
+                CAknQueryDialog* query2 = CAknQueryDialog::NewL();
+                if (query2->ExecuteLD(R_GENERAL_CONFIRMATION_QUERY, _L("Are you really sure you know what are you doing ?!?")))
+                    {
+                    // warn if the selected drive is not detected as removable
+                    TBool proceed(EFalse);                    
+
+                    if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttRemovable)
+                        {
+                        proceed = ETrue;
+                        }
+                    else
+                        {
+                        CAknQueryDialog* query3 = CAknQueryDialog::NewL();
+                        if (query3->ExecuteLD(R_GENERAL_CONFIRMATION_QUERY, _L("Selected drive is not removable, really continue?")))
+                            proceed = ETrue;
+                        else
+                            proceed = EFalse;                        
+                        }
+                                    
+                    if (proceed)
+                        {
+                        TInt err(KErrNone);
+                        
+                        CAknInformationNote* note = new(ELeave) CAknInformationNote;
+                        note->ExecuteLD(_L("Please wait, this may take 30 seconds"));
+                        
+                        // set as system application to prevent getting shut down events
+                        iModel->EikonEnv()->SetSystem(ETrue);
+                        
+                        // first close any open applications            
+                        CBaBackupSessionWrapper* BSWrapper = CBaBackupSessionWrapper::NewL();
+                        CleanupStack::PushL(BSWrapper);
+            
+                        TBackupOperationAttributes atts(MBackupObserver::EReleaseLockNoAccess, MBackupOperationObserver::EStart);
+                        BSWrapper->NotifyBackupOperationL(atts);
+                        
+                        CAsyncWaiter* waiter = CAsyncWaiter::NewLC();
+                        BSWrapper->CloseAll( MBackupObserver::EReleaseLockNoAccess, waiter->iStatus );
+                        waiter->StartAndWait();
+                        CleanupStack::PopAndDestroy(); //waiter
+            
+                        // some delay to make sure all applications have been closed
+                        User::After(1000000);
+                        
+                        
+                        // do the erase MBR operation
+                        err = iFileOps->EraseMBR(driveEntry.iNumber);
+                        
+                        
+                        // restart closed applications
+                        TBackupOperationAttributes atts2(MBackupObserver::ETakeLock, MBackupOperationObserver::EEnd);
+                        BSWrapper->NotifyBackupOperationL(atts2);
+                        BSWrapper->RestartAll();
+                        CleanupStack::PopAndDestroy(); //BSWrapper
+            
+                        // system status not needed anymore
+                        iModel->EikonEnv()->SetSystem(EFalse);
+                                                
+                                                
+                        if (err == KErrNone)
+                            {
+                            CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+                            note->ExecuteLD(_L("Erase MBR succeeded"));                     
+                            }
+                        else if (err == KErrNotSupported)
+                            {
+                            CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                            note->ExecuteLD(_L("Not supported for this drive"));                     
+                            }
+                        else
+                            {
+                            CTextResolver* textResolver = CTextResolver::NewLC(*iModel->EikonEnv());     
+                                
+                            CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                            note->ExecuteLD( textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) );    
+
+                            CleanupStack::PopAndDestroy();  //textResolver                       
+                            }
+            
+                        RefreshViewL();
+                        }
+                    }
+                }
+            }
+        }
+    else
+        {
+        CAknInformationNote* note = new(ELeave) CAknInformationNote;
+        note->ExecuteLD(_L("Enable \"bypass platform security\" from the settings first"));          
+        }
+    #else
+        CAknInformationNote* note = new(ELeave) CAknInformationNote;
+        note->ExecuteLD(_L("Not supported in lite version"));          
+    #endif
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::PartitionDriveL()
+    {
+    #ifndef FILEBROWSER_LITE
+    if (iModel->Settings().iBypassPlatformSecurity)
+        {
+        // get current item 
+        TInt currentItemIndex = iModel->FileListContainer()->CurrentListBoxItemIndex();
+        
+        if (iDriveEntryList->Count() > currentItemIndex && currentItemIndex >= 0)
+            {
+            TDriveEntry driveEntry = iDriveEntryList->At(currentItemIndex);
+            
+            CAknQueryDialog* query = CAknQueryDialog::NewL();
+            if (query->ExecuteLD(R_GENERAL_CONFIRMATION_QUERY, _L("Are you sure? Your media driver must support this!")))
+                {
+
+                CAknQueryDialog* query2 = CAknQueryDialog::NewL();
+                if (query2->ExecuteLD(R_GENERAL_CONFIRMATION_QUERY, _L("Are you really sure you know what are you doing ?!?")))
+                    {
+                    // warn if the selected drive is not detected as removable
+                    TBool proceed(EFalse);                    
+
+                    if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttRemovable)
+                        {
+                        proceed = ETrue;
+                        }
+                    else
+                        {
+                        CAknQueryDialog* query3 = CAknQueryDialog::NewL();
+                        if (query3->ExecuteLD(R_GENERAL_CONFIRMATION_QUERY, _L("Selected drive is not removable, really continue?")))
+                            proceed = ETrue;
+                        else
+                            proceed = EFalse;                        
+                        }
+                                    
+                    if (proceed)
+                        {
+                        // query if erase mbr
+                        TBool eraseMBR(EFalse);
+                        
+                        CAknQueryDialog* query4 = CAknQueryDialog::NewL();
+                        if (query4->ExecuteLD(R_GENERAL_CONFIRMATION_QUERY, _L("Erase MBR first (normally needed)?")))
+                            {
+                            eraseMBR = ETrue;
+                            }
+                        
+                        
+                        // query amount of partitions from user
+                        TInt queryIndex(0);
+                        CAknListQueryDialog* listQueryDlg = new(ELeave) CAknListQueryDialog(&queryIndex);
+
+                        if (listQueryDlg->ExecuteLD(R_PARTITION_AMOUNT_QUERY))
+                            {
+                            TInt amountOfPartitions = queryIndex + 1;  // selections are 1..4
+               
+                            TInt err(KErrNone);
+                            
+                            CAknInformationNote* note = new(ELeave) CAknInformationNote;
+                            note->ExecuteLD(_L("Please wait, this may take 30 seconds"));
+
+                            // set as system application to prevent getting shut down events
+                            iModel->EikonEnv()->SetSystem(ETrue);
+                            
+                            // first close any open applications            
+                            CBaBackupSessionWrapper* BSWrapper = CBaBackupSessionWrapper::NewL();
+                            CleanupStack::PushL(BSWrapper);
+                
+                            TBackupOperationAttributes atts(MBackupObserver::EReleaseLockNoAccess, MBackupOperationObserver::EStart);
+                            BSWrapper->NotifyBackupOperationL(atts);
+                            
+                            CAsyncWaiter* waiter = CAsyncWaiter::NewLC();
+                            BSWrapper->CloseAll( MBackupObserver::EReleaseLockNoAccess, waiter->iStatus );
+                            waiter->StartAndWait();
+                            CleanupStack::PopAndDestroy(); //waiter
+                
+                            // some delay to make sure all applications have been closed
+                            User::After(1000000);
+                            
+                            // do the erase operation
+                            if (eraseMBR)
+                                {
+                                err = iFileOps->EraseMBR(driveEntry.iNumber);
+                                
+                                if (err != KErrNone)
+                                    {
+                                    CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                                    note->ExecuteLD(_L("Erase MBR failed"));                     
+                                    }
+
+                                User::After(500000);
+                                }
+                            
+                            
+                            // do the partition operation
+                            err = iFileOps->PartitionDrive(driveEntry.iNumber, amountOfPartitions);
+                            
+                            
+                            // restart closed applications
+                            TBackupOperationAttributes atts2(MBackupObserver::ETakeLock, MBackupOperationObserver::EEnd);
+                            BSWrapper->NotifyBackupOperationL(atts2);
+                            BSWrapper->RestartAll();
+                            CleanupStack::PopAndDestroy(); //BSWrapper
+                
+                            // system status not needed anymore
+                            iModel->EikonEnv()->SetSystem(EFalse);
+                                                    
+                                                    
+                            if (err == KErrNone)
+                                {
+                                CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+                                note->ExecuteLD(_L("Partition succeeded"));                     
+                                }
+                            else if (err == KErrNotSupported)
+                                {
+                                CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                                note->ExecuteLD(_L("Not supported for this drive"));                     
+                                }
+                            else
+                                {
+                                CTextResolver* textResolver = CTextResolver::NewLC(*iModel->EikonEnv());     
+                                    
+                                CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                                note->ExecuteLD( textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) );    
+
+                                CleanupStack::PopAndDestroy();  //textResolver                       
+                                }
+                
+                            RefreshViewL();
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    else
+        {
+        CAknInformationNote* note = new(ELeave) CAknInformationNote;
+        note->ExecuteLD(_L("Enable \"bypass platform security\" from the settings first"));          
+        }
+    #else
+        CAknInformationNote* note = new(ELeave) CAknInformationNote;
+        note->ExecuteLD(_L("Not supported in lite version"));          
+    #endif
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::CheckDiskL()
+    {
+    // get current item 
+    TInt currentItemIndex = iModel->FileListContainer()->CurrentListBoxItemIndex();
+    
+    if (iDriveEntryList->Count() > currentItemIndex && currentItemIndex >= 0)
+        {
+        TDriveEntry driveEntry = iDriveEntryList->At(currentItemIndex);
+        
+        TBuf<10> driveRoot;
+        driveRoot.Append(driveEntry.iLetter);
+        driveRoot.Append(_L(":"));
+        
+        // check disk
+        TInt err = iFs.CheckDisk(driveRoot);
+
+        if (err == KErrNone)
+            {
+            CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+            note->ExecuteLD(_L("Integrity of the disk is ok"));                     
+            }
+        else if (err == KErrNotReady)
+            {
+            CAknInformationNote* note = new(ELeave) CAknInformationNote;
+            note->ExecuteLD(_L("Disk is empty"));                     
+            }
+        else if (err == KErrNotSupported)
+            {
+            CAknErrorNote* note = new(ELeave) CAknErrorNote;
+            note->ExecuteLD(_L("Not supported for this drive"));                     
+            }
+        else
+            {
+            CAknErrorNote* note = new(ELeave) CAknErrorNote;
+            note->ExecuteLD(_L("Disk is corrupted"));                     
+            }        
+
+        RefreshViewL();
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::ScanDriveL()
+    {
+    // get current item 
+    TInt currentItemIndex = iModel->FileListContainer()->CurrentListBoxItemIndex();
+    
+    if (iDriveEntryList->Count() > currentItemIndex && currentItemIndex >= 0)
+        {
+        CAknQueryDialog* query = CAknQueryDialog::NewL();
+        
+        if (query->ExecuteLD(R_GENERAL_CONFIRMATION_QUERY, _L("This finds errors on disk and corrects them. Proceed?")))
+            {
+            TDriveEntry driveEntry = iDriveEntryList->At(currentItemIndex);
+            
+            TBuf<10> driveRoot;
+            driveRoot.Append(driveEntry.iLetter);
+            driveRoot.Append(_L(":"));
+            
+            // scan disk
+            TInt err = iFs.ScanDrive(driveRoot);
+
+            if (err == KErrNone)
+                {
+                CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+                note->ExecuteLD(_L("Run succesfully"));                     
+                }
+            else if (err == KErrNotSupported)
+                {
+                CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                note->ExecuteLD(_L("Not supported for this drive"));                     
+                }
+            else
+                {
+                CTextResolver* textResolver = CTextResolver::NewLC(*iModel->EikonEnv());     
+                    
+                CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                note->ExecuteLD( textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) );    
+
+                CleanupStack::PopAndDestroy();  //textResolver                       
+                }        
+
+            RefreshViewL();
+            }
+        }
+    }
+
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::SetDriveNameL()
+    {
+    // get current item 
+    TInt currentItemIndex = iModel->FileListContainer()->CurrentListBoxItemIndex();
+    
+    if (iDriveEntryList->Count() > currentItemIndex && currentItemIndex >= 0)
+        {
+        TDriveEntry driveEntry = iDriveEntryList->At(currentItemIndex);
+
+        TFileName driveName;
+        
+        // get existing drive name
+        iFs.GetDriveName(driveEntry.iNumber, driveName);
+        
+        CAknTextQueryDialog* textQuery = CAknTextQueryDialog::NewL(driveName);
+        textQuery->SetPromptL(_L("New name:"));
+
+        if (textQuery->ExecuteLD(R_GENERAL_TEXT_QUERY))
+            {
+            // set drive name
+            TInt err = iFs.SetDriveName(driveEntry.iNumber, driveName);
+
+            if (err == KErrNone)
+                {
+                CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+                note->ExecuteLD(_L("Name changed"));                     
+                }
+            else if (err == KErrNotSupported)
+                {
+                CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                note->ExecuteLD(_L("Not supported for this drive"));                     
+                }
+            else
+                {
+                CTextResolver* textResolver = CTextResolver::NewLC(*iModel->EikonEnv());     
+                    
+                CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                note->ExecuteLD( textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) );    
+
+                CleanupStack::PopAndDestroy();  //textResolver                       
+                }              
+
+            RefreshViewL();
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::SetDriveVolumeLabelL()
+    {
+    // get current item 
+    TInt currentItemIndex = iModel->FileListContainer()->CurrentListBoxItemIndex();
+    
+    if (iDriveEntryList->Count() > currentItemIndex && currentItemIndex >= 0)
+        {
+        TDriveEntry driveEntry = iDriveEntryList->At(currentItemIndex);
+
+        // get existing volume label
+        TFileName volumeLabel;
+        volumeLabel.Copy(driveEntry.iVolumeInfo.iName);
+        
+        CAknTextQueryDialog* textQuery = CAknTextQueryDialog::NewL(volumeLabel);
+        textQuery->SetPromptL(_L("New volume label:"));
+
+        if (textQuery->ExecuteLD(R_GENERAL_TEXT_QUERY))
+            {
+            // set volume label
+            TInt err = iFs.SetVolumeLabel(volumeLabel, driveEntry.iNumber);
+
+            if (err == KErrNone)
+                {
+                CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+                note->ExecuteLD(_L("Volume label changed"));                     
+                }
+            else if (err == KErrNotSupported)
+                {
+                CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                note->ExecuteLD(_L("Not supported for this drive"));                     
+                }
+            else
+                {
+                CTextResolver* textResolver = CTextResolver::NewLC(*iModel->EikonEnv());     
+                    
+                CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                note->ExecuteLD( textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) );    
+
+                CleanupStack::PopAndDestroy();  //textResolver                       
+                }              
+
+            RefreshViewL();
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::EjectDriveL()
+    {
+    // get current item 
+    TInt currentItemIndex = iModel->FileListContainer()->CurrentListBoxItemIndex();
+    
+    if (iDriveEntryList->Count() > currentItemIndex && currentItemIndex >= 0)
+        {
+        TDriveEntry driveEntry = iDriveEntryList->At(currentItemIndex);
+        
+        TInt err(KErrNone);
+        
+        // get current filesystem name
+        TFileName fileSystemName;
+        err = iFs.FileSystemName(fileSystemName, driveEntry.iNumber);
+        
+        if (err == KErrNone)
+            {
+            // Prevent SysAp shutting down applications
+            RProperty::Set(
+                KPSUidCoreApplicationUIs,
+                KCoreAppUIsMmcRemovedWithoutEject,
+                ECoreAppUIsEjectCommandUsed );
+            
+            // dismount the file system
+            err = iFs.DismountFileSystem(fileSystemName, driveEntry.iNumber);
+            
+            if (err == KErrNone)
+                {
+                // remount the file system
+                err = iFs.MountFileSystem(fileSystemName, driveEntry.iNumber);
+                
+                if (err == KErrInUse)
+                    {
+                    // try to remount after a while if locked
+                    User::After(1000000);
+                    err = iFs.MountFileSystem(fileSystemName, driveEntry.iNumber);
+                    }                
+                }
+            }
+
+        if (err == KErrNone)
+            {
+            CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+            note->ExecuteLD(_L("Ejected succesfully"));                     
+            }
+        else if (err == KErrNotSupported)
+            {
+            CAknErrorNote* note = new(ELeave) CAknErrorNote;
+            note->ExecuteLD(_L("Not supported for this drive"));                     
+            }
+        else
+            {
+            CTextResolver* textResolver = CTextResolver::NewLC(*iModel->EikonEnv());     
+                
+            CAknErrorNote* note = new(ELeave) CAknErrorNote;
+            note->ExecuteLD( textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) );    
+
+            CleanupStack::PopAndDestroy();  //textResolver                       
+            }              
+
+        RefreshViewL();
+        }
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::DismountFileSystemL()
+    {
+    // get current item 
+    TInt currentItemIndex = iModel->FileListContainer()->CurrentListBoxItemIndex();
+    
+    if (iDriveEntryList->Count() > currentItemIndex && currentItemIndex >= 0)
+        {
+        CAknQueryDialog* query = CAknQueryDialog::NewL();
+        
+        if (query->ExecuteLD(R_GENERAL_CONFIRMATION_QUERY, _L("Are you sure you know what are you doing?")))
+            {
+            TDriveEntry driveEntry = iDriveEntryList->At(currentItemIndex);
+            
+            TInt err(KErrNone);
+            
+            // get current filesystem name
+            TFileName fileSystemName;
+            err = iFs.FileSystemName(fileSystemName, driveEntry.iNumber);
+            
+            if (err == KErrNone)
+                {
+                // Prevent SysAp shutting down applications
+                RProperty::Set(
+                    KPSUidCoreApplicationUIs,
+                    KCoreAppUIsMmcRemovedWithoutEject,
+                    ECoreAppUIsEjectCommandUsed );
+                
+                // dismount the file system
+                err = iFs.DismountFileSystem(fileSystemName, driveEntry.iNumber);
+                }
+
+            if (err == KErrNone)
+                {
+                CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+                note->ExecuteLD(_L("Dismounted succesfully"));                     
+                }
+            else if (err == KErrNotSupported)
+                {
+                CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                note->ExecuteLD(_L("Not supported for this drive"));                     
+                }
+            else
+                {
+                CTextResolver* textResolver = CTextResolver::NewLC(*iModel->EikonEnv());     
+                    
+                CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                note->ExecuteLD( textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) );    
+
+                CleanupStack::PopAndDestroy();  //textResolver                       
+                }              
+
+            RefreshViewL();
+            }
+        }
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::ConvertCharsToPwd(TDesC& aWord, TDes8& aConverted) const
+    {
+    aConverted.FillZ(aConverted.MaxLength());
+    aConverted.Zero();
+    
+    if (aWord.Length())
+        {
+        aConverted.Copy( (TUint8*)(&aWord[0]), aWord.Size() );
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::EditDataTypesL()
+    {
+    iModel->FileListContainer()->SetScreenLayoutL(EDisplayModeNormal);
+    iModel->FileListContainer()->SetNaviPaneTextL(KNullDesC);
+    
+    CFileBrowserDataTypesDlg* dlg = CFileBrowserDataTypesDlg::NewL();
+    dlg->RunQueryLD();
+
+    iModel->FileListContainer()->SetScreenLayoutL(iModel->Settings().iDisplayMode);
+    iModel->FileListContainer()->SetNaviPaneTextL(iCurrentPath);     
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::SecureBackupL(TInt aType)
+    {
+    TInt err(KErrNone);
+    TInt showStatus(EFalse);
+    
+    if (aType == EFileBrowserCmdToolsSecureBackupStartBackup || aType == EFileBrowserCmdToolsSecureBackupStartRestore)
+        {
+        TInt queryIndexState(0);
+        TInt queryIndexType(0);
+        
+        CAknListQueryDialog* listQueryDlgState = new(ELeave) CAknListQueryDialog(&queryIndexState);
+        if (listQueryDlgState->ExecuteLD(R_SECUREBACKUP_STATE_QUERY))
+            {
+
+            CAknListQueryDialog* listQueryDlgType = new(ELeave) CAknListQueryDialog(&queryIndexType);
+            if (listQueryDlgType->ExecuteLD(R_SECUREBACKUP_TYPE_QUERY))
+                {
+                conn::TBURPartType partType = conn::EBURNormal;
+                conn::TBackupIncType backupIncType = conn::ENoBackup;
+                
+                if (aType == EFileBrowserCmdToolsSecureBackupStartBackup)
+                    {
+                    if (queryIndexState == ESecureBackupStateFull)
+                        partType = conn::EBURBackupFull;
+                    else if (queryIndexState == ESecureBackupStatePartial)
+                        partType = conn::EBURBackupPartial;
+                    }
+                else if (aType == EFileBrowserCmdToolsSecureBackupStartRestore)
+                    {
+                    if (queryIndexState == ESecureBackupStateFull)
+                        partType = conn::EBURRestoreFull;
+                    else if (queryIndexState == ESecureBackupStatePartial)
+                        partType = conn::EBURRestorePartial;
+                    }
+                    
+                if (queryIndexType == ESecureBackupTypeBase)
+                    backupIncType = conn::EBackupBase;
+                else if (queryIndexType == ESecureBackupTypeIncremental)    
+                    backupIncType = conn::EBackupIncrement;    
+
+                // start secure backup
+                err = iFileOps->ActivateSecureBackUp(partType, backupIncType);
+                showStatus = ETrue;
+                }
+            }
+        }
+
+    else if (aType == EFileBrowserCmdToolsSecureBackupStop)
+        {
+        err = iFileOps->DeActivateSecureBackUp();
+        showStatus = ETrue;
+        }
+
+    else
+        User::Panic(_L("Sec.br.mode"), 101);
+    
+    
+    if (showStatus)
+        {
+        if (err == KErrNone)
+            {
+            CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+            note->ExecuteLD(_L("Succeeded"));                     
+            }
+        else
+            {
+            CTextResolver* textResolver = CTextResolver::NewLC(*iModel->EikonEnv());     
+                
+            CAknErrorNote* note = new(ELeave) CAknErrorNote;
+            note->ExecuteLD( textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) );    
+
+            CleanupStack::PopAndDestroy();  //textResolver                       
+            }  
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserFileUtils::OpenCommonFileActionQueryL()
+    {
+    // just get current item
+    TInt currentItemIndex = iModel->FileListContainer()->CurrentListBoxItemIndex();
+    
+    if (iFileEntryList->Count() > currentItemIndex && currentItemIndex >= 0)
+        {
+        TInt queryIndex(0);
+        
+        CAknListQueryDialog* listQueryDlg = new(ELeave) CAknListQueryDialog(&queryIndex);
+        
+        if (listQueryDlg->ExecuteLD(R_COMMON_FILE_ACTION_QUERY))
+            {
+            if (queryIndex == ECommonFileActionViewAsTextHex)
+                {
+                TFileEntry fileEntry = iFileEntryList->At(currentItemIndex);
+                
+                TFileName fullPath = fileEntry.iPath;
+                fullPath.Append(fileEntry.iEntry.iName);
+                
+                TInt viewerType(EFileBrowserCmdFileViewHex);
+                
+                // check from mime type if it's text
+                TDataType dataType;
+                TUid appUid;
+                if (iModel->LsSession().AppForDocument(fullPath, appUid, dataType) == KErrNone)
+                    {
+                    TBuf<128> mimeTypeBuf;
+                    mimeTypeBuf.Copy(dataType.Des8());
+                    if (mimeTypeBuf == KNullDesC)
+                        mimeTypeBuf.Copy(_L("N/A"));
+                    
+                    if (mimeTypeBuf.CompareF(_L("text/plain")) == 0)
+                        viewerType = EFileBrowserCmdFileViewText;
+                    }
+                    
+                FileEditorL(viewerType);   
+                }
+
+            else if (queryIndex == ECommonFileActionOpenWithApparc)
+                {
+                OpenWithApparcL();
+                }
+
+            else if (queryIndex == ECommonFileActionOpenWithDocHandlerEmbed)
+                {
+                OpenWithDocHandlerL(ETrue);
+                }
+
+            else
+                User::Panic(_L("Unk.Com.Act"), 221);    
+                            
+            }
+        }
+    }
+    
+// --------------------------------------------------------------------------------------------
+	            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/src/FBModel.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,376 @@
+/*
+* 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 "FBModel.h"
+#include "FBApp.h"
+#include "FB.hrh"
+#include "FBSettingViewDlg.h"
+#include "FBFileUtils.h"
+#include "FBFileListContainer.h"
+#include "FBStd.h"
+#include <filebrowser.rsg>
+
+#include <coeutils.h>
+#include <bautils.h>
+#include <apaid.h>
+#include <AknGlobalConfirmationQuery.h>
+#include <s32file.h>
+
+// hash key selection related includes
+#ifndef __SERIES60_30__
+  #include <centralrepository.h>
+  #include <AknFepInternalCRKeys.h>
+  #include <AvkonInternalCRKeys.h>
+  #include <e32property.h> 
+#endif
+
+const TInt KSettingsDrive = EDriveC;
+_LIT(KSettingsFileName, "filebrowser_settings.ini");
+
+// ===================================== MEMBER FUNCTIONS =====================================
+
+CFileBrowserModel* CFileBrowserModel::NewL()
+	{
+	CFileBrowserModel* self = new(ELeave) CFileBrowserModel;
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop();
+	return self;
+	}
+
+// --------------------------------------------------------------------------------------------
+
+CFileBrowserModel::CFileBrowserModel()
+	{
+	}
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserModel::ConstructL()
+	{
+    iEnv = CEikonEnv::Static();
+    User::LeaveIfError(iLs.Connect());
+	}
+
+// --------------------------------------------------------------------------------------------
+
+CFileBrowserModel::~CFileBrowserModel()
+	{
+	if (iFileUtils)
+	    delete iFileUtils;
+
+	iLs.Close();
+    }
+
+// ---------------------------------------------------------------------------
+
+void CFileBrowserModel::ActivateModelL()
+	{
+    TRAP_IGNORE( LoadSettingsL() );
+
+    iFileUtils = CFileBrowserFileUtils::NewL(this);
+    
+    // get hash key selection value
+    GetHashKeySelectionStatus();
+	}
+
+// ---------------------------------------------------------------------------
+
+void CFileBrowserModel::DeActivateModelL()
+	{
+	}
+	
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserModel::SetFileListContainer(CFileBrowserFileListContainer* aFileListContainer)
+    {
+    iFileListContainer = aFileListContainer;
+    }
+
+// ---------------------------------------------------------------------------
+
+void CFileBrowserModel::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 CFileBrowserModel::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 CFileBrowserModel::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 CFileBrowserModel::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 CFileBrowserModel::LoadSettingsL()
+    {
+    const TSize screenSize = iEnv->ScreenDevice()->SizeInPixels();
+
+    // set defaults
+    iSettings.iDisplayMode = EDisplayModeFullScreen;
+    iSettings.iFileViewMode = IsQHD(screenSize) ? EFileViewModeExtended : EFileViewModeSimple;
+    iSettings.iShowSubDirectoryInfo = EFalse;
+    iSettings.iShowAssociatedIcons = EFalse;
+    iSettings.iRememberLastPath = EFalse;
+    iSettings.iLastPath = KNullDesC;
+    iSettings.iRememberFolderSelection = ETrue;
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)
+    if ( AknLayoutUtils::PenEnabled() )
+        {
+        iSettings.iEnableToolbar = ETrue;
+        }
+    else
+        {
+        iSettings.iEnableToolbar = EFalse;
+        }
+#else
+    iSettings.iEnableToolbar = EFalse;
+#endif
+
+    iSettings.iSupportNetworkDrives = EFalse;
+    iSettings.iBypassPlatformSecurity = EFalse;
+    iSettings.iRemoveFileLocks = ETrue;
+    iSettings.iIgnoreProtectionsAtts = ETrue;
+    iSettings.iRemoveROMWriteProrection = ETrue;
+
+    // build specific defaults
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
+    iSettings.iSupportNetworkDrives = ETrue;
+#endif 
+
+
+    // make sure that the private path of this app in c-drive exists
+    iEnv->FsSession().CreatePrivatePath( KSettingsDrive ); // c:\\private\\102828d6\\
+    
+    // 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, KUidFileBrowser);
+
+        LoadDFSValueL(settingsStore, KFBSettingDisplayMode,                 iSettings.iDisplayMode);
+        LoadDFSValueL(settingsStore, KFBSettingFileViewMode,                iSettings.iFileViewMode);
+        LoadDFSValueL(settingsStore, KFBSettingShowSubDirectoryInfo,        iSettings.iShowSubDirectoryInfo);
+        LoadDFSValueL(settingsStore, KFBSettingShowAssociatedIcons,         iSettings.iShowAssociatedIcons);
+        LoadDFSValueL(settingsStore, KFBSettingRememberLastPath,            iSettings.iRememberLastPath);
+        LoadDFSValueL(settingsStore, KFBSettingLastPath,                    iSettings.iLastPath);
+        LoadDFSValueL(settingsStore, KFBSettingFolderSelection,             iSettings.iRememberFolderSelection);
+        LoadDFSValueL(settingsStore, KFBSettingEnableToolbar,               iSettings.iEnableToolbar);
+
+        LoadDFSValueL(settingsStore, KFBSettingSupportNetworkDrives,        iSettings.iSupportNetworkDrives);
+        LoadDFSValueL(settingsStore, KFBSettingBypassPlatformSecurity,      iSettings.iBypassPlatformSecurity);
+        LoadDFSValueL(settingsStore, KFBSettingRemoveFileLocks,             iSettings.iRemoveFileLocks);
+        LoadDFSValueL(settingsStore, KFBSettingIgnoreProtectionsAtts,       iSettings.iIgnoreProtectionsAtts);
+        LoadDFSValueL(settingsStore, KFBSettingRemoveROMWriteProtection,    iSettings.iRemoveROMWriteProrection);
+
+        CleanupStack::PopAndDestroy(); // settingsStore         
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserModel::SaveSettingsL(TBool aNotifyModules)
+    {
+    // handle settings always in c:\\private\\102828d6\\
+    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, KUidFileBrowser);
+
+        SaveDFSValueL(settingsStore, KFBSettingDisplayMode,                 iSettings.iDisplayMode);
+        SaveDFSValueL(settingsStore, KFBSettingFileViewMode,                iSettings.iFileViewMode);
+        SaveDFSValueL(settingsStore, KFBSettingShowSubDirectoryInfo,        iSettings.iShowSubDirectoryInfo);
+        SaveDFSValueL(settingsStore, KFBSettingShowAssociatedIcons,         iSettings.iShowAssociatedIcons);
+        SaveDFSValueL(settingsStore, KFBSettingRememberLastPath,            iSettings.iRememberLastPath);
+        SaveDFSValueL(settingsStore, KFBSettingLastPath,                    iSettings.iLastPath);
+        SaveDFSValueL(settingsStore, KFBSettingFolderSelection,             iSettings.iRememberFolderSelection);
+        SaveDFSValueL(settingsStore, KFBSettingEnableToolbar,               iSettings.iEnableToolbar);
+
+        SaveDFSValueL(settingsStore, KFBSettingSupportNetworkDrives,        iSettings.iSupportNetworkDrives);
+        SaveDFSValueL(settingsStore, KFBSettingBypassPlatformSecurity,      iSettings.iBypassPlatformSecurity);
+        SaveDFSValueL(settingsStore, KFBSettingRemoveFileLocks,             iSettings.iRemoveFileLocks);
+        SaveDFSValueL(settingsStore, KFBSettingIgnoreProtectionsAtts,       iSettings.iIgnoreProtectionsAtts);
+        SaveDFSValueL(settingsStore, KFBSettingRemoveROMWriteProtection,    iSettings.iRemoveROMWriteProrection);
+        
+        settingsStore->CommitL();
+        CleanupStack::PopAndDestroy(); // settingsStore             
+        }
+
+    // update changes to modules
+    if (aNotifyModules)
+        {
+        //iScreenCapture->HandleSettingsChangeL();
+        iFileUtils->HandleSettingsChangeL();
+        iFileListContainer->HandleSettingsChangeL();
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserModel::GetHashKeySelectionStatus()
+    {
+    TBool hashKeySelectionInUse(EFalse);
+    
+#ifndef __SERIES60_30__
+    
+    // get hash key selection value
+    TRAP_IGNORE(
+        CRepository* repository = CRepository::NewLC(KCRUidAknFep);
+        repository->Get(KAknFepHashKeySelection, hashKeySelectionInUse);
+        CleanupStack::PopAndDestroy();
+    );
+    
+    // even if hash key selection is in use, ignore the value in qwerty mode
+    if (hashKeySelectionInUse)
+        {
+        TBool qwertyMode(EFalse);
+        RProperty qwertyModeStatusProperty;
+        qwertyModeStatusProperty.Attach(KCRUidAvkon, KAknQwertyInputModeActive);
+        qwertyModeStatusProperty.Get(qwertyMode);
+        qwertyModeStatusProperty.Close();
+        
+        if (qwertyMode)
+            hashKeySelectionInUse = EFalse;        
+        }
+
+#endif
+
+    iIsHashKeySelectionInUse = hashKeySelectionInUse;
+    }
+    	
+// --------------------------------------------------------------------------------------------
+
+TInt CFileBrowserModel::LaunchSettingsDialogL()
+    {
+    // set to normal mode
+    iFileListContainer->SetScreenLayoutL(EDisplayModeNormal);
+    iFileListContainer->DeleteNaviPane();
+    iFileListContainer->HideToolbar();
+    
+    // launch the dialog and save settings
+    CFileBrowserSettingViewDlg* dlg = CFileBrowserSettingViewDlg::NewL(iSettings);
+    TInt retValue = dlg->ExecuteLD(R_FILEBROWSER_SETTINGS_DIALOG);        
+    FileListContainer()->CreateEmptyNaviPaneLabelL();
+    TRAP_IGNORE(SaveSettingsL());
+    return retValue;
+    }
+	
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+CAsyncWaiter* CAsyncWaiter::NewL(TInt aPriority)
+	{
+	CAsyncWaiter* self = new(ELeave) CAsyncWaiter(aPriority);
+	return self;
+	}
+
+CAsyncWaiter* CAsyncWaiter::NewLC(TInt aPriority)
+	{
+	CAsyncWaiter* self = new(ELeave) CAsyncWaiter(aPriority);
+	CleanupStack::PushL(self);
+	return self;
+	}
+	
+CAsyncWaiter::CAsyncWaiter(TInt aPriority) : CActive(aPriority)
+	{
+	CActiveScheduler::Add(this);
+	}	
+
+CAsyncWaiter::~CAsyncWaiter()
+	{
+	Cancel();
+	}
+	
+void CAsyncWaiter::StartAndWait()
+	{
+    iStatus = KRequestPending;
+    SetActive();
+    iWait.Start();
+	}
+	
+TInt CAsyncWaiter::Result() const
+	{
+	return iError;
+	}
+	
+void CAsyncWaiter::RunL()
+	{
+	iError = iStatus.Int();
+	CAknEnv::StopSchedulerWaitWithBusyMessage( iWait );
+	}
+	
+void CAsyncWaiter::DoCancel()
+	{
+	iError = KErrCancel;
+    if( iStatus == KRequestPending )
+        {
+        TRequestStatus* s=&iStatus;
+        User::RequestComplete( s, KErrCancel );
+        }
+
+    CAknEnv::StopSchedulerWaitWithBusyMessage( iWait );
+	}
+
+// --------------------------------------------------------------------------------------------
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/src/FBSettingViewDlg.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,463 @@
+/*
+* 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 "FBSettingViewDlg.h"
+#include "FBModel.h"
+#include "FB.hrh"
+#include "FBStd.h"
+#include <filebrowser.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 =====================================
+
+CFileBrowserSettingViewDlg* CFileBrowserSettingViewDlg::NewL(TFileBrowserSettings& aSettings)
+    {
+    CFileBrowserSettingViewDlg* self = new(ELeave) CFileBrowserSettingViewDlg(aSettings);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CFileBrowserSettingViewDlg::~CFileBrowserSettingViewDlg()
+    {
+    // restore default navi pane
+    if (iNaviContainer)
+        iNaviContainer->Pop();
+    
+    if (iSettingItemArray)
+        {
+        iSettingItemArray->ResetAndDestroy();
+        delete iSettingItemArray; 
+        }
+    
+    if (iDecoratedTabGroup)
+        delete iDecoratedTabGroup;   
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CFileBrowserSettingViewDlg::CFileBrowserSettingViewDlg(TFileBrowserSettings& aSettings) : iSettings(aSettings)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserSettingViewDlg::ConstructL()
+    {
+    // construct a menu bar
+    CAknDialog::ConstructL(R_FILEBROWSER_SETTINGS_MENUBAR);
+   
+    CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
+    
+    // set empty navi pane label
+    iNaviContainer = static_cast<CAknNavigationControlContainer*>(sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi)));
+    iNaviContainer->PushDefaultL();
+    
+    // set title text
+    CAknTitlePane* tp = static_cast<CAknTitlePane*>( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
+    tp->SetTextL( _L("Settings") );
+    
+    // create a tab group
+    iDecoratedTabGroup = iNaviContainer->CreateTabGroupL(this);
+    iTabGroup = static_cast<CAknTabGroup*>(iDecoratedTabGroup->DecoratedControl());
+    iTabGroup->SetTabFixedWidthL(KTabWidthWithTwoLongTabs); 
+    
+    // add tabs
+    iTabGroup->AddTabL(ETabGeneral, _L("General"));
+    iTabGroup->AddTabL(ETabFileOps, _L("Operations"));
+    iTabGroup->SetActiveTabByIndex(ETabGeneral);
+    
+    iNaviContainer->PushL( *iDecoratedTabGroup );
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserSettingViewDlg::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
+    {
+    switch (aEventType)
+        {
+        case EEventEnterKeyPressed:
+        case EEventItemDoubleClicked:
+            ShowSettingPageL(EFalse);
+            break;
+        default:
+            break;
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserSettingViewDlg::TabChangedL(TInt /*aIndex*/)
+    {
+    iListBox->SetCurrentItemIndex(0);
+
+    SetVisibilitiesOfSettingItemsL();   
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserSettingViewDlg::ProcessCommandL(TInt aCommandId)
+    {
+    CAknDialog::ProcessCommandL(aCommandId);
+
+    switch (aCommandId)
+        {
+        case EFileBrowserCmdSettingsChange:
+            ShowSettingPageL(ETrue);
+            break;
+        case EFileBrowserCmdSettingsExit:
+            TryExitL(EAknCmdExit);
+            break;
+        default:
+            break;
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TKeyResponse CFileBrowserSettingViewDlg::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 CFileBrowserSettingViewDlg::PreLayoutDynInitL()
+    {
+    iListBox = static_cast<CAknSettingStyleListBox*>( Control(EFileBrowserSettingItemList) );
+    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 CFileBrowserSettingViewDlg::OkToExitL(TInt aButtonId)
+    {
+    return CAknDialog::OkToExitL(aButtonId);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserSettingViewDlg::ShowSettingPageL(TInt aCalledFromMenu)
+    {
+    TInt listIndex = iListBox->CurrentItemIndex();
+    TInt realIndex = iSettingItemArray->ItemIndexFromVisibleIndex(listIndex);
+    CAknSettingItem* item = iSettingItemArray->At(realIndex);
+    item->EditItemL(aCalledFromMenu);
+    item->StoreL();
+    SetVisibilitiesOfSettingItemsL();
+    DrawNow();
+    
+    if (realIndex == ESettingListBypassPlatformSecuritySelection && iSettings.iBypassPlatformSecurity)
+        {
+        _LIT(KMessage, "Gives TCB rights to file operations, use at your own risk");
+        CAknInformationNote* note = new(ELeave) CAknInformationNote;
+        note->ExecuteLD(KMessage);    
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserSettingViewDlg::SetVisibilitiesOfSettingItemsL()
+    {
+    if (iSettingItemArray->Count() > 0)
+        {
+        switch (iTabGroup->ActiveTabIndex())
+            {
+            case ETabGeneral:
+                {
+                ((*iSettingItemArray)[ESettingListDisplayModeSelection])->SetHidden(EFalse);
+                ((*iSettingItemArray)[ESettingListFileViewModeSelection])->SetHidden(EFalse);
+                ((*iSettingItemArray)[ESettingListShowSubdirectoryInfoSelection])->SetHidden(EFalse);
+                ((*iSettingItemArray)[ESettingListShowAssociatedIconsSelection])->SetHidden(EFalse);
+                ((*iSettingItemArray)[ESettingListRememberLastPathSelection])->SetHidden(EFalse);
+                ((*iSettingItemArray)[ESettingListRememberFolderSelection])->SetHidden(EFalse);
+                ((*iSettingItemArray)[ESettingListEnableToolbar])->SetHidden(EFalse);
+                
+                ((*iSettingItemArray)[ESettingListSupportNetworkDrivesSelection])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListBypassPlatformSecuritySelection])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListRemoveFileLocksSelection])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListIgnoreProtectionsAttsSelection])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListRemoveROMWriteProtectionSelection])->SetHidden(ETrue);
+                }
+                break;
+            
+            case ETabFileOps:
+                {
+                ((*iSettingItemArray)[ESettingListDisplayModeSelection])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListFileViewModeSelection])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListShowSubdirectoryInfoSelection])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListShowAssociatedIconsSelection])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListRememberLastPathSelection])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListRememberFolderSelection])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListEnableToolbar])->SetHidden(ETrue);
+
+                ((*iSettingItemArray)[ESettingListSupportNetworkDrivesSelection])->SetHidden(EFalse);
+                ((*iSettingItemArray)[ESettingListBypassPlatformSecuritySelection])->SetHidden(EFalse);
+                ((*iSettingItemArray)[ESettingListRemoveFileLocksSelection])->SetHidden(EFalse);
+                ((*iSettingItemArray)[ESettingListIgnoreProtectionsAttsSelection])->SetHidden(EFalse);
+                ((*iSettingItemArray)[ESettingListRemoveROMWriteProtectionSelection])->SetHidden(EFalse);
+                }
+                break;            
+
+            default:
+                User::Panic(_L("TabIOOB"), 50);
+                break;
+            }
+            
+        #ifdef FILEBROWSER_LITE
+          ((*iSettingItemArray)[ESettingListBypassPlatformSecuritySelection])->SetHidden(ETrue);
+        #endif
+          
+        #if(defined __SERIES60_30__ || defined __SERIES60_31__ || defined __S60_32__)
+          ((*iSettingItemArray)[ESettingListEnableToolbar])->SetHidden(ETrue);
+        #else
+        if ( !AknLayoutUtils::PenEnabled() )
+            {
+            ((*iSettingItemArray)[ESettingListEnableToolbar])->SetHidden(ETrue);
+            }
+        #endif
+        
+        iSettingItemArray->RecalculateVisibleIndicesL();
+        iListBox->HandleItemAdditionL();
+        iListBox->UpdateScrollBarsL();
+        }
+    }   
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserSettingViewDlg::UpdateListBoxL()
+    {
+    iSettingItemArray->ResetAndDestroy();
+    
+    // create items
+    TInt ordinal(0);
+ 
+    AddSettingItemL(ESettingListDisplayModeSelection,
+                    R_DISPLAYMODESELECTION_SETTING_TITLE,
+                    R_DISPLAYMODESELECTION_SETTING_PAGE,
+                    R_DISPLAYMODESELECTION_SETTING_TEXTS,
+                    ordinal++);
+                    
+    AddSettingItemL(ESettingListFileViewModeSelection,
+                    R_FILEVIEWMODESELECTION_SETTING_TITLE,
+                    R_FILEVIEWMODESELECTION_SETTING_PAGE,
+                    R_FILEVIEWMODESELECTION_SETTING_TEXTS,
+                    ordinal++); 
+
+    AddSettingItemL(ESettingListShowSubdirectoryInfoSelection,
+                    R_SHOWSUBDIRECTORYINFOSELECTION_SETTING_TITLE,
+                    R_BINARY_SETTING_PAGE,
+                    R_YESNO_BINARYSELECTION_TEXTS,
+                    ordinal++); 
+
+    AddSettingItemL(ESettingListShowAssociatedIconsSelection,
+                    R_SHOWASSOCIATEDICONSSELECTION_SETTING_TITLE,
+                    R_BINARY_SETTING_PAGE,
+                    R_YESNO_BINARYSELECTION_TEXTS,
+                    ordinal++); 
+ 
+    AddSettingItemL(ESettingListRememberLastPathSelection,
+                    R_REMEMBERLASTPATHSELECTION_SETTING_TITLE,
+                    R_BINARY_SETTING_PAGE,
+                    R_YESNO_BINARYSELECTION_TEXTS,
+                    ordinal++); 
+
+    AddSettingItemL(ESettingListRememberFolderSelection,
+                    R_REMEMBERFOLDERSELECTION_SETTING_TITLE,
+                    R_BINARY_SETTING_PAGE,
+                    R_YESNO_BINARYSELECTION_TEXTS,
+                    ordinal++);
+
+    AddSettingItemL(ESettingListEnableToolbar,
+                    R_ENABLETOOLBAR_SETTING_TITLE,
+                    R_BINARY_SETTING_PAGE,
+                    R_YESNO_BINARYSELECTION_TEXTS,
+                    ordinal++);
+    
+    AddSettingItemL(ESettingListSupportNetworkDrivesSelection,
+                    R_SUPPORTNETWORKDRIVESSELECTION_SETTING_TITLE,
+                    R_BINARY_SETTING_PAGE,
+                    R_YESNO_BINARYSELECTION_TEXTS,
+                    ordinal++); 
+                     
+    AddSettingItemL(ESettingListBypassPlatformSecuritySelection,
+                    R_BYPASSPLATFORMSECURITYSELECTION_SETTING_TITLE,
+                    R_BINARY_SETTING_PAGE,
+                    R_YESNO_BINARYSELECTION_TEXTS,
+                    ordinal++); 
+ 
+    AddSettingItemL(ESettingListRemoveFileLocksSelection,
+                    R_REMOVEFILELOCKSSELECTION_SETTING_TITLE,
+                    R_BINARY_SETTING_PAGE,
+                    R_YESNO_BINARYSELECTION_TEXTS,
+                    ordinal++);
+
+    AddSettingItemL(ESettingListIgnoreProtectionsAttsSelection,
+                    R_IGNOREPROTECTIONATTSSELECTION_SETTING_TITLE,
+                    R_BINARY_SETTING_PAGE,
+                    R_YESNO_BINARYSELECTION_TEXTS,
+                    ordinal++);   
+
+    AddSettingItemL(ESettingListRemoveROMWriteProtectionSelection,
+                    R_REMOVEROMWRITEPROTECTIONSELECTION_SETTING_TITLE,
+                    R_BINARY_SETTING_PAGE,
+                    R_YESNO_BINARYSELECTION_TEXTS,
+                    ordinal++);
+                                                              
+    SetVisibilitiesOfSettingItemsL(); 
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CFileBrowserSettingViewDlg::AddSettingItemL(TInt aId,
+                                                 TInt aTitleResource,
+                                                 TInt aSettingPageResource,
+                                                 TInt aAssociatedResource,
+                                                 TInt aOrdinal)
+    {
+    // create a setting item
+    CAknSettingItem* settingItem = NULL;
+    
+    switch (aId)
+        {
+        case ESettingListDisplayModeSelection:
+            settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iDisplayMode);
+            break;
+            
+        case ESettingListFileViewModeSelection:
+            settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iFileViewMode);
+            break;
+
+        case ESettingListShowSubdirectoryInfoSelection:
+            settingItem = new(ELeave) CAknBinaryPopupSettingItem(aId, iSettings.iShowSubDirectoryInfo);
+            break;  
+
+        case ESettingListShowAssociatedIconsSelection:
+            settingItem = new(ELeave) CAknBinaryPopupSettingItem(aId, iSettings.iShowAssociatedIcons);
+            break;  
+            
+        case ESettingListRememberLastPathSelection:
+            settingItem = new(ELeave) CAknBinaryPopupSettingItem(aId, iSettings.iRememberLastPath);
+            break;
+            
+        case ESettingListRememberFolderSelection:
+            settingItem = new(ELeave) CAknBinaryPopupSettingItem(aId, iSettings.iRememberFolderSelection);
+            break;
+
+        case ESettingListEnableToolbar:
+            settingItem = new(ELeave) CAknBinaryPopupSettingItem(aId, iSettings.iEnableToolbar);
+            break;
+
+        case ESettingListSupportNetworkDrivesSelection:
+            settingItem = new(ELeave) CAknBinaryPopupSettingItem(aId, iSettings.iSupportNetworkDrives);
+            break; 
+            
+        case ESettingListBypassPlatformSecuritySelection:
+            settingItem = new(ELeave) CAknBinaryPopupSettingItem(aId, iSettings.iBypassPlatformSecurity);
+            break;  
+
+        case ESettingListRemoveFileLocksSelection:
+            settingItem = new(ELeave) CAknBinaryPopupSettingItem(aId, iSettings.iRemoveFileLocks);
+            break;  
+
+        case ESettingListIgnoreProtectionsAttsSelection:
+            settingItem = new(ELeave) CAknBinaryPopupSettingItem(aId, iSettings.iIgnoreProtectionsAtts);
+            break;
+            
+        case ESettingListRemoveROMWriteProtectionSelection:
+            settingItem = new(ELeave) CAknBinaryPopupSettingItem(aId, iSettings.iRemoveROMWriteProrection);
+            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
+    }
+
+// --------------------------------------------------------------------------------------------
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filebrowser/src/FBToolbar.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,369 @@
+/*
+* 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 "FBToolbar.h"
+
+#include <aknappui.h>
+#include <akntoolbar.h>
+#include <AknsUtils.h>
+#include <aknbutton.h>
+#include <akntouchpane.h>
+#include <gulicon.h>
+#include <eikapp.h>
+#include <StringLoader.h>
+#include <data_caging_path_literals.hrh>
+#include <layoutmetadata.cdl.h>
+#include <aknlayoutscalable_avkon.cdl.h>
+#include <aknlayoutscalable_apps.cdl.h>
+#include <filebrowser.rsg>
+#include <AknInfoPopupNoteController.h>
+
+#include "FB.hrh"
+#include "FBDocument.h"
+#include "FBModel.h"
+#include "FBFileUtils.h"
+#include "FBFileListContainer.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CFileBrowserToolbar::NewL(const TRect& aRect)
+// EPOC two-phased constructor
+// ---------------------------------------------------------
+//
+CFileBrowserToolbar* CFileBrowserToolbar::NewL(/* CAknView& aView*/ )
+    {
+    CFileBrowserToolbar* self = CFileBrowserToolbar::NewLC();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CFileBrowserToolbar::NewLC()
+// Creates and leaves on failure. 
+// -----------------------------------------------------------------------------
+//
+CFileBrowserToolbar* CFileBrowserToolbar::NewLC()
+    {
+    CFileBrowserToolbar* self = new ( ELeave )CFileBrowserToolbar();
+    CleanupStack::PushL( self );
+    self->ConstructL();               
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CFileBrowserToolbar::~CFileBrowserToolbar()
+// removes the toolbar items when it leaves Editor/viewer plugin.
+// -----------------------------------------------------------------------------
+//
+CFileBrowserToolbar::~CFileBrowserToolbar()
+    {
+    delete iInfoPopup;
+    if ( AknLayoutUtils::PenEnabled() )
+        {
+        if ( iViewerToolbar )
+            {
+            iViewerToolbar->SetToolbarVisibility( EFalse );
+            TRAP_IGNORE( iViewerToolbar->DisableToolbarL(ETrue) );
+            }
+        }
+
+    if ( iViewerToolbar )
+        {
+        iViewerToolbar->HideItem( EFileBrowserCmdFileBack, ETrue, EFalse );
+        iViewerToolbar->HideItem( EFileBrowserCmdFileSearch, ETrue, EFalse );
+        iViewerToolbar->HideItem( EFileBrowserCmdEditSelect, ETrue, EFalse );
+        }
+    }
+// -----------------------------------------------------------------------------
+// CFileBrowserToolbar::CFileBrowserToolbar()
+// C++ construct function add items the toolbar.
+// -----------------------------------------------------------------------------
+//
+CFileBrowserToolbar::CFileBrowserToolbar() :
+    iFirstSelectionIndex( KErrNotFound ),
+    iLastSelectionIndex( KErrNotFound )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CFileBrowserToolbar::ConstructL()
+// C++ construct function add items the toolbar.
+// -----------------------------------------------------------------------------
+//
+void CFileBrowserToolbar::ConstructL()
+    {
+    CAknAppUi* appUi = (CAknAppUi*)CEikonEnv::Static()->EikAppUi();
+    iModel = static_cast<CFileBrowserDocument*>(appUi->Document())->Model();
+
+    iViewerToolbar = appUi->CurrentFixedToolbar();
+    iSelectbutton = static_cast<CAknButton*>( iViewerToolbar->ControlOrNull( EFileBrowserCmdEditSelect ) );
+
+    if ( iViewerToolbar )
+        {
+        iShown = ETrue;
+        iViewerToolbar->SetObserver( this );
+        iViewerToolbar->SetToolbarObserver( this );
+        iViewerToolbar->SetWithSliding( ETrue );
+        iViewerToolbar->SetCloseOnAllCommands( EFalse );
+        iViewerToolbar->SetFocusing( EFalse );
+        }
+    iInfoPopup = CAknInfoPopupNoteController::NewL();
+    iInfoPopup->SetTimePopupInView(5000);
+    iInfoPopup->SetTimeDelayBeforeShow(500);
+    }
+
+// ---------------------------------------------------------------------------
+// CFileBrowserToolbar::ResetState
+// Updates the toolbar 
+// ---------------------------------------------------------------------------
+//
+void CFileBrowserToolbar::ResetState()
+    {
+    if ( AknLayoutUtils::PenEnabled() )
+        {
+        iSelectbutton->SetCurrentState( 0, ETrue );
+        iFirstSelectionIndex = KErrNotFound;
+        iLastSelectionIndex = KErrNotFound;
+        }
+    if ( iInfoPopup )
+        {
+        iInfoPopup->HideInfoPopupNote();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CFileBrowserToolbar::DynInitToolbarL
+// Initialise before the display of the toolbar
+// ---------------------------------------------------------------------------
+//
+void CFileBrowserToolbar::DynInitToolbarL( TInt /*aResourceId*/, CAknToolbar* /*aToolbar*/ )
+    {
+    ResetState();
+    iViewerToolbar->SetFocusing(EFalse);
+    }
+
+// ---------------------------------------------------------------------------
+// CFileBrowserToolbar::ShowToolbar
+// Shows the toolbar
+// ---------------------------------------------------------------------------
+//
+void CFileBrowserToolbar::ShowToolbarL()
+    {
+    if(AknLayoutUtils::PenEnabled() )
+        {
+        TRAP_IGNORE( iViewerToolbar->DisableToolbarL(EFalse) );
+        iViewerToolbar->SetToolbarVisibility(ETrue);
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CFileBrowserToolbar::ShowToolbar
+// Hides the Toolbar
+// ---------------------------------------------------------------------------
+//
+void  CFileBrowserToolbar::HideToolbarL()
+    {
+    // Undim the toolbar if dimmed
+    if(AknLayoutUtils::PenEnabled() )
+        {
+        TRAP_IGNORE( iViewerToolbar->DisableToolbarL(ETrue) );
+        iViewerToolbar->SetToolbarVisibility(EFalse);
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CFileBrowserToolbar::OfferToolbarEventL
+// Handling toolbar key events
+// ---------------------------------------------------------------------------
+//
+void CFileBrowserToolbar::OfferToolbarEventL( TInt aCommand )
+    {
+    switch ( aCommand )
+        {
+        case EFileBrowserCmdFileBack:
+            {
+            iModel->FileUtils()->MoveUpOneLevelL();
+            break;
+            }
+        case EFileBrowserCmdFileSearch:
+            {
+            TBool emptyListBox = iModel->FileListContainer()->ListBoxNumberOfVisibleItems() == 0;
+            TBool searchFieldEnabled = iModel->FileListContainer()->IsSearchFieldEnabled();
+            if ( !emptyListBox && !searchFieldEnabled )
+                {
+                iModel->FileListContainer()->EnableSearchFieldL();
+                }
+            else if ( searchFieldEnabled )
+                {
+                iModel->FileListContainer()->DisableSearchFieldL();
+                }
+            break;
+            }
+        case EFileBrowserCmdEditSelect:
+            {
+            TBool emptyListBox = iModel->FileListContainer()->ListBoxNumberOfVisibleItems() == 0;
+            TBool driveListActive = iModel->FileUtils()->IsDriveListViewActive();
+            TBool allSelected = iModel->FileListContainer()->ListBox()->SelectionIndexes()->Count() == iModel->FileListContainer()->ListBox()->Model()->NumberOfItems();
+            TBool noneSelected = iModel->FileListContainer()->ListBox()->SelectionIndexes()->Count() == 0;
+            
+            if ( iViewerToolbar->EventModifiers() == CAknToolbar::ELongPressEnded )
+                {                
+                // handle long tap event 
+                iFirstSelectionIndex = KErrNotFound;
+                iLastSelectionIndex = KErrNotFound;
+                iSelectbutton->SetCurrentState( 0, ETrue );
+
+                if ( !( driveListActive || allSelected || emptyListBox ) )
+                    {
+                    AknSelectionService::HandleMarkableListProcessCommandL( EAknMarkAll, iModel->FileListContainer()->ListBox() );
+                    }
+                else if ( !( driveListActive || noneSelected || emptyListBox ) )
+                    {
+                    AknSelectionService::HandleMarkableListProcessCommandL( EAknUnmarkAll, iModel->FileListContainer()->ListBox() );
+                    }
+                }
+            else if ( iViewerToolbar->EventModifiers() != CAknToolbar::ELongPress )
+                {
+                // handle single tap event
+                TBool currentSelected = iModel->FileListContainer()->ListBox()->View()->ItemIsSelected(iModel->FileListContainer()->ListBox()->View()->CurrentItemIndex());                
+                
+                if ( !( driveListActive || emptyListBox ) )
+                    {
+                    if ( noneSelected && iFirstSelectionIndex == KErrNotFound )
+                        {
+                        iLastSelectionIndex = KErrNotFound;
+                        }
+                    
+                    if ( iFirstSelectionIndex == KErrNotFound )
+                        {
+                        // first item selected
+                        iFirstSelectionIndex = iModel->FileListContainer()->ListBox()->CurrentItemIndex();
+                        if ( currentSelected )
+                            {
+                            AknSelectionService::HandleMarkableListProcessCommandL( EAknCmdUnmark, iModel->FileListContainer()->ListBox() );
+                            }
+                        else
+                            {
+                            AknSelectionService::HandleMarkableListProcessCommandL( EAknCmdMark, iModel->FileListContainer()->ListBox() );
+                            }
+                        // Toolbar button updates its state (icon)
+                        iInfoPopup->SetTextL( _L("Select the last item.") );
+                        iInfoPopup->ShowInfoPopupNote();
+                        }
+                    else
+                        {
+                        iInfoPopup->HideInfoPopupNote();
+                        iLastSelectionIndex = iModel->FileListContainer()->ListBox()->CurrentItemIndex();
+                        if ( iLastSelectionIndex == iFirstSelectionIndex )
+                            {
+                            // the same item selected second time
+                            iFirstSelectionIndex = KErrNotFound;
+                            iLastSelectionIndex = KErrNotFound;
+                            if ( currentSelected )
+                                {
+                                AknSelectionService::HandleMarkableListProcessCommandL( EAknCmdUnmark, iModel->FileListContainer()->ListBox() );
+                                }
+                            else
+                                {
+                                AknSelectionService::HandleMarkableListProcessCommandL( EAknCmdMark, iModel->FileListContainer()->ListBox() );
+                                }
+                            // Toolbar button updates its state (icon)
+                            }
+                        else
+                            {
+                            // the last item selected, toggle the item selection between first and last 
+                            TInt skipFirstToggle(1);
+                            TInt skipLastToggle(0);
+                            TInt finalFocus = iLastSelectionIndex;
+                            if ( iFirstSelectionIndex > iLastSelectionIndex )
+                                {
+                                TInt tmp = iFirstSelectionIndex;
+                                iFirstSelectionIndex = iLastSelectionIndex;
+                                iLastSelectionIndex = tmp;
+                                skipFirstToggle = 0;
+                                skipLastToggle = 1;
+                                }
+                            for ( TInt i = iFirstSelectionIndex+skipFirstToggle; i <= iLastSelectionIndex-skipLastToggle ; i++ )
+                                {
+                                iModel->FileListContainer()->ListBox()->SetCurrentItemIndexAndDraw( i );
+                                TBool itemSelected = iModel->FileListContainer()->ListBox()->View()->ItemIsSelected(iModel->FileListContainer()->ListBox()->View()->CurrentItemIndex());
+                                if ( itemSelected )
+                                    {
+                                    TRAP_IGNORE( AknSelectionService::HandleMarkableListProcessCommandL( EAknCmdUnmark, iModel->FileListContainer()->ListBox() ) );
+                                    }
+                                else
+                                    {
+                                    TRAP_IGNORE( AknSelectionService::HandleMarkableListProcessCommandL( EAknCmdMark, iModel->FileListContainer()->ListBox() ) );
+                                    }
+                                }
+                            iFirstSelectionIndex = KErrNotFound;
+                            iLastSelectionIndex = KErrNotFound;
+                            iModel->FileListContainer()->ListBox()->SetCurrentItemIndexAndDraw( finalFocus );
+                            // Toolbar button updates its state (icon)
+                            }
+                        }
+                    }
+                else
+                    {
+                    iSelectbutton->SetCurrentState( 0, ETrue );
+                    }
+                }
+            break;
+            }
+        default:
+            {
+            break;
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CFileBrowserToolbar::HandleControlEventL
+// Handles toolbar event cannot contain any code
+// ---------------------------------------------------------------------------
+//
+void CFileBrowserToolbar::HandleControlEventL( CCoeControl* /*aControl*/,
+                                               TCoeEvent /*aEventType*/ )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CFileBrowserToolbar::IsShown
+// Returns whether the toolbar is shown or not
+// ---------------------------------------------------------------------------
+//
+TBool CFileBrowserToolbar::IsShown()
+    {
+    return iShown;
+    }   
+
+// ---------------------------------------------------------------------------
+// CFileBrowserToolbar::Rect
+// 
+// ---------------------------------------------------------------------------
+//
+const TRect CFileBrowserToolbar::Rect() const
+    {
+    return iViewerToolbar->Rect();
+    }
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -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"
+#include "../perfmon/group/bld.inf"
+#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/htiui/HtiAdmin/data/1020DEB6.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  A startup control file to add HtiFramework.exe to startup list.
+*
+*/
+
+#include <StartupItem.rh>
+
+RESOURCE STARTUP_ITEM_INFO hti_framework
+    {
+    executable_name = "!:\\sys\\bin\\HtiFramework.exe";
+    recovery = EStartupItemExPolicyNone;
+    }
+
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiAdmin/data/HtiAdmin.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,317 @@
+/*
+* 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:  Resource definitions for HtiAdmin
+*
+*/
+
+NAME HTIA
+
+// INCLUDES
+#include <eikon.rh>
+#include <eikon.rsg>
+#include <avkon.rh>
+#include <avkon.rsg>
+#include <appinfo.rh>
+#include <data_caging_paths_strings.hrh>
+#include "HtiAdmin.hrh"
+
+
+// RESOURCE DEFINITIONS
+
+// ---------------------------------------------------------
+//
+//    Define the resource file signature
+//    This resource should be empty.
+//
+// ---------------------------------------------------------
+//
+RESOURCE RSS_SIGNATURE { }
+
+// ---------------------------------------------------------
+//
+//    Default Document Name
+//
+// ---------------------------------------------------------
+//
+RESOURCE TBUF r_default_document_name { buf=""; }
+
+// ---------------------------------------------------------
+//
+//    Define default menu and CBA key.
+//
+// ---------------------------------------------------------
+//
+RESOURCE EIK_APP_INFO
+    {
+    menubar = r_htiadmin_menubar;
+    cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
+    }
+
+
+// ---------------------------------------------------------
+//
+//   r_htiadmin_menubar
+//   Menubar for HtiAdmin example
+//
+// ---------------------------------------------------------
+//
+RESOURCE MENU_BAR r_htiadmin_menubar
+    {
+    titles =
+        {
+        MENU_TITLE {menu_pane = r_htiadmin_menu;}
+        };
+    }
+
+
+// ---------------------------------------------------------
+//
+//   Options menu items
+//
+//
+// ---------------------------------------------------------
+
+RESOURCE MENU_PANE r_htiadmin_submenu_logs
+    {
+    items =
+        {
+        MENU_ITEM {command = EHtiAdminCreateLogFolder; txt = "Create c:\\logs\\hti";},
+        MENU_ITEM {command = EHtiAdminRemoveLogFolder; txt = "Remove c:\\logs\\hti";},
+        MENU_ITEM {command = EHtiAdminClearLogs;       txt = "Clear";}
+        };
+    }
+
+RESOURCE MENU_PANE r_htiadmin_submenu_priority
+    {
+    items =
+        {
+        MENU_ITEM {command = EHtiAdminPriorityBackground;   flags = EEikMenuItemCheckBox; txt="Background"; },
+        MENU_ITEM {command = EHtiAdminPriorityForeground;   flags = EEikMenuItemCheckBox; txt="Foreground"; },
+        MENU_ITEM {command = EHtiAdminPriorityHigh;         flags = EEikMenuItemCheckBox; txt="High"; },
+        MENU_ITEM {command = EHtiAdminPriorityAbsoluteHigh; flags = EEikMenuItemCheckBox; txt="AbsoluteHigh"; }
+        };
+    }
+
+RESOURCE MENU_PANE r_htiadmin_submenu_watchdog
+    {
+    items =
+        {
+        MENU_ITEM {command = EHtiAdminWatchDogEnable;  flags = EEikMenuItemCheckBox; txt="Enable"; },
+        MENU_ITEM {command = EHtiAdminWatchDogDisable; flags = EEikMenuItemCheckBox; txt="Disable"; }
+        };
+    }
+
+RESOURCE MENU_PANE r_htiadmin_submenu_console
+    {
+    items =
+        {
+        MENU_ITEM {command = EHtiAdminConsoleEnable;  flags = EEikMenuItemCheckBox; txt="Enable"; },
+        MENU_ITEM {command = EHtiAdminConsoleDisable; flags = EEikMenuItemCheckBox; txt="Disable"; }
+        };
+    }
+
+RESOURCE MENU_PANE r_htiadmin_submenu_error_dialogs
+    {
+    items =
+        {
+        MENU_ITEM {command = EHtiAdminErrorDialogsEnable;  flags = EEikMenuItemCheckBox; txt="Enable"; },
+        MENU_ITEM {command = EHtiAdminErrorDialogsDisable; flags = EEikMenuItemCheckBox; txt="Disable"; }
+        };
+    }
+
+RESOURCE MENU_PANE r_htiadmin_submenu_autostart
+    {
+    items =
+        {
+        MENU_ITEM {command = EHtiAdminAutoStartEnable;  flags = EEikMenuItemCheckBox; txt="Enable"; },
+        MENU_ITEM {command = EHtiAdminAutoStartDisable; flags = EEikMenuItemCheckBox; txt="Disable"; }
+        };
+    }
+
+RESOURCE MENU_PANE r_htiadmin_submenu_set_param
+    {
+    items =
+        {
+        MENU_ITEM {command = EHtiAdminHtiCfg;           txt = "Hti.cfg";},
+        MENU_ITEM {command = EHtiAdminHtiBtCommCfg;     txt = "HtiBtComm.cfg";},
+        MENU_ITEM {command = EHtiAdminHtiSerialCommCfg; txt = "HtiSerialComm.cfg";},
+        MENU_ITEM {command = EHtiAdminHtiIPCommCfg;     txt = "HtiIPComm.cfg";}
+        };
+    }
+
+RESOURCE MENU_PANE r_htiadmin_submenu_options
+    {
+    items =
+        {
+        MENU_ITEM {command = EHtiAdminSubComms;        txt = "Comms";},
+        MENU_ITEM {command = EHtiAdminSubAutoStart;    cascade = r_htiadmin_submenu_autostart;     txt = "AutoStart";},
+        MENU_ITEM {command = EHtiAdminSubLogs;         cascade = r_htiadmin_submenu_logs;          txt = "Logs";},
+        MENU_ITEM {command = EHtiAdminSubPriority;     cascade = r_htiadmin_submenu_priority;      txt = "Priority";},
+        MENU_ITEM {command = EHtiAdminSubWatchDog;     cascade = r_htiadmin_submenu_watchdog;      txt = "Watchdog";},
+        MENU_ITEM {command = EHtiAdminSubConsole;      cascade = r_htiadmin_submenu_console;       txt = "Console";},
+        MENU_ITEM {command = EHtiAdminSubErrorDialogs; cascade = r_htiadmin_submenu_error_dialogs; txt = "Error dialogs";},
+        MENU_ITEM {command = EHtiAdminSubSetParam;     cascade = r_htiadmin_submenu_set_param;     txt = "Set parameter";}
+        };
+    }
+
+// ---------------------------------------------------------
+//
+//   r_htiadmin_menu
+//   Menu for "Options"
+//
+// ---------------------------------------------------------
+//
+RESOURCE MENU_PANE r_htiadmin_menu
+    {
+    items =
+        {
+        MENU_ITEM {command = EHtiAdminStart;   txt = "Start";},
+        MENU_ITEM {command = EHtiAdminStop;    txt = "Stop";},
+        MENU_ITEM {command = EHtiAdminSubOptions; cascade = r_htiadmin_submenu_options;   txt = "Options";},
+        MENU_ITEM {command = EHtiAdminAbout;   txt = "About";},
+        MENU_ITEM {command = EAknSoftkeyExit;  txt = "Exit";}
+        };
+    }
+
+
+RESOURCE DIALOG r_numeric_query
+  {
+  flags = EGeneralQueryFlags;
+  buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+  items =
+    {
+    DLG_LINE
+      {
+      type = EAknCtQuery;
+      id = EGeneralQuery;
+      control = AVKON_DATA_QUERY
+        {
+        layout = EDataLayout;
+        control = EDWIN
+          {
+          flags = EEikEdwinNoHorizScrolling | EEikEdwinResizable;
+          default_input_mode = EAknEditorNumericInputMode;
+          };
+        };
+      }
+    };
+  }
+
+RESOURCE DIALOG r_text_query
+  {
+  flags = EGeneralQueryFlags;
+  buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+  items =
+    {
+    DLG_LINE
+      {
+      type = EAknCtQuery;
+      id = EGeneralQuery;
+      control = AVKON_DATA_QUERY
+        {
+        layout = EDataLayout;
+        control = EDWIN
+          {
+          flags = EEikEdwinNoHorizScrolling | EEikEdwinResizable;
+          default_input_mode = EAknEditorTextInputMode;
+          };
+        };
+      }
+    };
+  }
+
+RESOURCE AVKON_LIST_QUERY r_query_dialog
+{
+   flags = EGeneralQueryFlags;
+   softkeys = R_AVKON_SOFTKEYS_OK_CANCEL;
+   items =
+   {
+      AVKON_LIST_QUERY_DLG_LINE
+      {
+         control = AVKON_LIST_QUERY_CONTROL
+         {
+            listtype = EAknCtSinglePopupMenuListBox;
+            listbox = AVKON_LIST_QUERY_LIST
+            {
+            };
+            heading = "Select Option";
+         };
+      }
+   };
+}
+
+RESOURCE AVKON_LIST_QUERY r_select_iap_dialog
+{
+   flags = EGeneralQueryFlags;
+   softkeys = R_AVKON_SOFTKEYS_OK_CANCEL;
+   items =
+   {
+      AVKON_LIST_QUERY_DLG_LINE
+      {
+         control = AVKON_LIST_QUERY_CONTROL
+         {
+            listtype = EAknCtSinglePopupMenuListBox;
+            listbox = AVKON_LIST_QUERY_LIST
+            {
+            };
+            heading = "Select IAP";
+         };
+      }
+   };
+}
+
+// ---------------------------------------------------------
+//
+//   r_htiadmin_about_dialog
+//   About dialog
+//
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_htiadmin_about_dialog
+   {
+   flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow;
+   buttons = R_AVKON_SOFTKEYS_OK_EMPTY;
+   items=
+       {
+       DLG_LINE
+           {
+           type = EAknCtPopupHeadingPane;
+           id = EAknMessageQueryHeaderId;
+           control = AVKON_HEADING
+               {
+               label = "About HTI Admin";
+               headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE;
+               };
+           },
+       DLG_LINE
+           {
+           type = EAknCtMessageQuery;
+           id = EAknMessageQueryContentId;
+           control = AVKON_MESSAGE_QUERY
+               {             
+               };
+           }
+       };
+   }
+
+// ---------------------------------------------------------
+//
+//   r_htiadmin_about_text
+//   Text for the About dialog
+//
+// ---------------------------------------------------------
+//
+RESOURCE TBUF r_htiadmin_about_text { buf="Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved."; }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiAdmin/data/HtiAdmin_reg.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,34 @@
+/*
+* 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:  App registration resource definitions for HtiAdmin
+*
+*/
+
+
+// INCLUDES
+#include <appinfo.rh>
+#include <data_caging_paths_strings.hrh>
+
+// RESOURCE DEFINITIONS
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0x1020DEB5 // application UID
+
+RESOURCE APP_REGISTRATION_INFO
+    {
+    app_file = "HtiAdmin";
+    group_name = "RnD Tools";
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiAdmin/group/HtiAdmin.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,81 @@
+/*
+* 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:  Project file for HtiAdmin
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET          HtiAdmin.exe
+TARGETTYPE      EXE
+
+UID             0x100039CE 0x1020DEB5
+
+VENDORID        0x101FB657
+
+CAPABILITY      ALL -TCB
+
+EPOCSTACKSIZE   0x5000
+
+TARGETPATH      PROGRAMS_DIR
+
+LANG            SC
+
+USERINCLUDE     ../inc
+APP_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH      ../src
+SOURCE          HtiAdmin.cpp
+SOURCE          HtiAdminApplication.cpp
+SOURCE          HtiAdminAppView.cpp
+SOURCE          HtiAdminAppUi.cpp
+SOURCE          HtiAdminDocument.cpp
+
+SOURCEPATH      ../data
+
+START RESOURCE  HtiAdmin.rss
+HEADER
+TARGETPATH      APP_RESOURCE_DIR
+LANG            SC
+END
+
+START RESOURCE  HtiAdmin_reg.rss
+HEADER
+TARGETPATH      /private/10003a3f/apps
+END
+
+START RESOURCE  1020DEB6.rss
+HEADER
+TARGETPATH      /private/101f875a/import
+END
+
+LIBRARY         apparc.lib
+LIBRARY         avkon.lib
+LIBRARY         cone.lib
+LIBRARY         ecom.lib
+LIBRARY         eikcoctl.lib
+LIBRARY         eikcore.lib
+LIBRARY         euser.lib
+LIBRARY         gdi.lib
+LIBRARY         hticfg.lib
+LIBRARY         ws32.lib
+LIBRARY         flogger.lib
+LIBRARY         bafl.lib
+LIBRARY         commdb.lib
+
+SMPSAFE
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiAdmin/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,23 @@
+/*
+* 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:  UI application to start/stop HtiFramework.exe
+*
+*/
+
+
+PRJ_MMPFILES
+
+HtiAdmin.mmp
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiAdmin/inc/HtiAdmin.hrh	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,66 @@
+/*
+* 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:  Command ids
+*
+*/
+
+#ifndef __HTIADMIN_HRH__
+#define __HTIADMIN_HRH__
+
+/* HtiAdmin enumerate command codes */
+enum THtiAdminIds
+    {
+    EHtiAdminStart = 1,
+    EHtiAdminStop,
+    EHtiAdminAbout,
+    EHtiAdminSubOptions,
+
+        EHtiAdminSubComms,
+                
+        EHtiAdminSubAutoStart,
+            EHtiAdminAutoStartEnable,
+            EHtiAdminAutoStartDisable,
+
+        EHtiAdminSubLogs,
+            EHtiAdminCreateLogFolder,
+            EHtiAdminRemoveLogFolder,
+            EHtiAdminClearLogs,
+
+        EHtiAdminSubPriority,
+            EHtiAdminPriorityBackground,
+            EHtiAdminPriorityForeground,
+            EHtiAdminPriorityHigh,
+            EHtiAdminPriorityAbsoluteHigh,
+
+        EHtiAdminSubWatchDog,
+            EHtiAdminWatchDogEnable,
+            EHtiAdminWatchDogDisable,
+
+        EHtiAdminSubConsole,
+            EHtiAdminConsoleEnable,
+            EHtiAdminConsoleDisable,
+
+        EHtiAdminSubErrorDialogs,
+            EHtiAdminErrorDialogsEnable,
+            EHtiAdminErrorDialogsDisable,
+
+        EHtiAdminSubSetParam,
+            EHtiAdminHtiCfg,
+            EHtiAdminHtiBtCommCfg,
+            EHtiAdminHtiSerialCommCfg,
+            EHtiAdminHtiIPCommCfg
+    };
+
+
+#endif // __HTIADMIN_HRH__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiAdmin/inc/HtiAdmin.pan	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,35 @@
+/*
+* 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:  Panics definitions for HtiAdmin
+*
+*/
+
+
+#ifndef __HTIADMIN_PAN__
+#define __HTIADMIN_PAN__
+
+/** HtiAdmin application panic codes */
+enum THtiAdminPanics
+    {
+    EHtiAdminBasicUi = 1
+    // add further panics here
+    };
+
+inline void Panic(THtiAdminPanics aReason)
+    {
+    _LIT(applicationName,"HtiAdmin");
+    User::Panic(applicationName, aReason);
+    }
+
+#endif // __HTIADMIN_PAN__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiAdmin/inc/HtiAdminAppUi.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,153 @@
+/*
+* 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:  AppUi class
+*
+*/
+
+
+#ifndef __HTIADMIN_APPUI_H__
+#define __HTIADMIN_APPUI_H__
+
+// INCLUDES
+#include <aknappui.h>
+
+// FORWARD DECLARATIONS
+class CHtiAdminAppView;
+class CHtiCfg;
+
+// CLASS DECLARATION
+
+/**
+* An instance of class CHtiAdminAppUi is the UserInterface part of the AVKON
+* application framework for the HtiAdmin application
+*/
+class CHtiAdminAppUi : public CAknAppUi
+    {
+    public:
+        /**
+        * Perform the second phase construction of a CHtiAdminAppUi object.
+        * This needs to be public due to the way the framework constructs the AppUi
+        */
+        void ConstructL();
+
+        /**
+        * Perform the first phase of two phase construction.
+        * This needs to be public due to the way the framework constructs the AppUi
+        */
+        CHtiAdminAppUi();
+
+
+        /**
+        * Destroy the object and release all memory objects.
+        */
+        ~CHtiAdminAppUi();
+
+        /**
+        * Tries to find the HTIFramework.exe process and open a handle to it.
+        * @param aPrs on return contains an open handle to the HTIFramework.exe
+        * process if process found and opened successfully
+        * @return ETrue if process found and opened successfully,
+        * otherwise EFalse
+        */
+        TBool OpenHtiProcess( RProcess& aPrs );
+
+        /**
+        * Updates the version text in the display.
+        */
+        void UpdateVersion();
+
+        /**
+        * Updates the HTI Framework process status in the display.
+        */
+        void UpdateStatusL();
+
+        /**
+        * Updates the HTI auto start status in the display.
+        */
+        void UpdateAutoStartStatus();
+
+        /**
+        * Updates the selected communication in the display.
+        */
+        void UpdateSelectedComm();
+
+        /**
+        * Kills the HtiWatchDog process if it is running.
+        */
+        void KillHtiWatchDogL();
+
+        /**
+        * Stops the timer issuing the periodical HTI Framework process
+        * status checks.
+        */
+        void KillTimer();
+
+        /**
+        * The method called by the periodic timer.
+        * @param aPtr pointer to this CHtiAdminAppUi instance
+        * @return zero if the callback function should not be called again,
+        * otherwise non-zero. Current implementation returns always ETrue.
+        */
+        static TInt TimerCallBackL( TAny* aPtr );
+
+    public: // from CAknAppUi
+        /**
+        * Handle user menu selections
+        * @param aCommand the enumerated code for the option selected
+        */
+        void HandleCommandL( TInt aCommand );
+
+        /**
+        * Updates the HTI Framework status information and starts the
+        * periodical status polling when application comes to foreground -
+        * stops the polling when going to background.
+        * @param aForeground ETrue if the application is in the foreground,
+        * otherwise EFalse
+        */
+        void HandleForegroundEventL( TBool aForeground );
+
+    public: // from MEikMenuObserver
+        /**
+        * Used to initialize user menu content dynamically
+        * @param aResourceId the resource id of the menu pane being initialised
+        * @param aMenuPane the in-memory representation of the menu pane
+        */
+        void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane *aMenuPane );
+    
+    private:
+    	void ShowBTListQueryL();
+    	void ShowIPListQueryL();
+    	void ShowCommsListQueryL();
+    	void ShowCommsDBListQueryL();
+    	void HandleBtByAddress();
+    	void HandleBtByName();
+    	void HandleBtSearch();
+    	void HandleIPConnect();
+    	void HandleIPListen();
+
+    private:
+
+        // The application view
+        CHtiAdminAppView* iAppView;
+
+        // Timer triggering periodic checking of HTIFramework process status
+        CPeriodic*        iPeriodic;
+
+        // For reading and writing HTI configuration files
+        CHtiCfg*          iHtiCfg;
+    };
+
+#endif // __HTIADMIN_APPUI_H__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiAdmin/inc/HtiAdminAppView.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,110 @@
+/*
+* 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:  App view displays 2 labels.
+*
+*/
+
+
+#ifndef __HTIADMIN_APPVIEW_H__
+#define __HTIADMIN_APPVIEW_H__
+
+// INCLUDES
+#include <coecntrl.h>
+
+// CONSTANTS
+const static TInt KMaxDisplayText = 64;
+
+// CLASS DECLARATION
+/**
+    An instance of the Application View object for the HtiAdmin
+  example application
+  */
+class CHtiAdminAppView : public CCoeControl
+    {
+public:
+
+/**
+    Create a CHtiAdminAppView object, which will draw itself to aRect
+  @param aRect the rectangle this view will be drawn to
+  @return a pointer to the created instance of CHtiAdminAppView
+  */
+    static CHtiAdminAppView* NewL(const TRect& aRect);
+
+/**
+    Create a CHtiAdminAppView object, which will draw itself to aRect
+  @param aRect the rectangle this view will be drawn to
+  @return a pointer to the created instance of CHtiAdminAppView
+  */
+    static CHtiAdminAppView* NewLC(const TRect& aRect);
+
+
+/**
+    Destroy the object and release all memory objects
+  */
+     ~CHtiAdminAppView();
+
+    /**
+    Set text for the labels in the view.
+    */
+    void SetCaption( const TDesC& aText );
+    void SetStatus( const TDesC& aText );
+    void SetVersionCaption( const TDesC& aText );
+    void SetVersion( const TDesC& aText );
+    void SetAutoStartCaption( const TDesC& aText );
+    void SetAutoStartStatus( const TDesC& aText );
+    void SetSelectedCommCaption( const TDesC& aText );
+    void SetSelectedComm( const TDesC& aText );
+    void SetCommDetails( const TDesC& aText );
+
+public:  // from CCoeControl
+/**
+    Draw this CHtiAdminAppView to the screen
+  @param aRect the rectangle of this view that needs updating
+  */
+    void Draw( const TRect& aRect ) const;
+
+
+private:
+
+/**
+    Perform the second phase construction of a CHtiAdminAppView object
+  @param aRect the rectangle this view will be drawn to
+  */
+    void ConstructL( const TRect& aRect );
+
+/**
+    Perform the first phase of two phase construction
+  */
+    CHtiAdminAppView();
+
+private:
+    /**
+    text to show in the view
+    */
+    HBufC* iHtiCaption;
+    HBufC* iHtiStatus;
+    HBufC* iHtiVersionCaption;
+    HBufC* iHtiVersion;
+    HBufC* iHtiAutoStartCaption;
+    HBufC* iHtiAutoStartStatus;
+    HBufC* iHtiSelectedCommCaption;
+    HBufC* iHtiSelectedComm;
+    HBufC* iHtiCommDetails;
+    };
+
+
+#endif // __HTIADMIN_APPVIEW_H__
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiAdmin/inc/HtiAdminApplication.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,52 @@
+/*
+* 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:  Application class
+*
+*/
+
+
+#ifndef __HTIADMIN_APPLICATION_H__
+#define __HTIADMIN_APPLICATION_H__
+
+// INCLUDES
+
+#include <aknapp.h>
+
+// CLASS DECLARATION
+/**
+    An instance of CHtiAdminApplication is the application part of the AVKON
+  application framework for the HtiAdmin example application
+  */
+class CHtiAdminApplication : public CAknApplication
+    {
+public:  // from CAknApplication
+
+/**
+    Returns the application DLL UID value
+  @return the UID of this Application/Dll
+  */
+    TUid AppDllUid() const;
+
+protected: // from CAknApplication
+/**
+    Create a CApaDocument object and return a pointer to it
+  @return a pointer to the created document
+  */
+    CApaDocument* CreateDocumentL();
+    };
+
+#endif // __HTIADMIN_APPLICATION_H__
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiAdmin/inc/HtiAdminDocument.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,87 @@
+/*
+* 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:  Document class
+*
+*/
+
+
+#ifndef __HTIADMIN_DOCUMENT_H__
+#define __HTIADMIN_DOCUMENT_H__
+
+// INCLUDES
+#include <akndoc.h>
+
+// FORWARD DECLARATIONS
+class CHtiAdminAppUi;
+class CEikApplication;
+
+// CLASS DECLARATION
+/**
+  An instance of class CHtiAdminDocument is the Document part of the AVKON
+  application framework for the HtiAdmin example application
+  */
+class CHtiAdminDocument : public CAknDocument
+    {
+public:
+
+/**
+    Construct a CHtiAdminDocument for the AVKON application aApp
+  using two phase construction, and return a pointer to the created object
+
+  @param aApp application creating this document
+  @return a pointer to the created instance of CHtiAdminDocument
+  */
+    static CHtiAdminDocument* NewL(CEikApplication& aApp);
+
+/**
+    Construct a CHtiAdminDocument for the AVKON application aApp
+  using two phase construction, and return a pointer to the created object
+  @param aApp application creating this document
+
+  @return a pointer to the created instance of CHtiAdminDocument
+  */
+    static CHtiAdminDocument* NewLC(CEikApplication& aApp);
+
+/**
+Destroy the object and release all memory objects
+  */
+    ~CHtiAdminDocument();
+
+public: // from CAknDocument
+/**
+    Create a CHtiAdminAppUi object and return a pointer to it
+  @return a pointer to the created instance of the AppUi created
+  */
+    CEikAppUi* CreateAppUiL();
+
+private:
+
+/**
+    Perform the second phase construction of a CHtiAdminDocument object
+  */
+    void ConstructL();
+
+/**
+    Perform the first phase of two phase construction
+  @param aApp application creating this document
+  */
+    CHtiAdminDocument(CEikApplication& aApp);
+
+    };
+
+
+#endif // __HTIADMIN_DOCUMENT_H__
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiAdmin/src/HtiAdmin.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,33 @@
+/*
+* 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:  Implementation of HtiAdmin main.
+*
+*/
+
+
+#include "HtiAdminApplication.h"
+#include <eikstart.h>
+
+
+LOCAL_C CApaApplication* NewApplication()
+    {
+    //HTI_LOG_TEXT("NewApplication");
+    return new CHtiAdminApplication;
+    }
+
+GLDEF_C TInt E32Main()
+    {
+    //HTI_LOG_TEXT("E32Main");
+    return EikStart::RunApplication(NewApplication);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiAdmin/src/HtiAdminAppUi.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,1144 @@
+/*
+* 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:  AppUi implementation, all functions here
+*
+*/
+
+// INCLUDE FILES
+#include <avkon.hrh>
+#include <aknnotewrappers.h>
+#include <aknquerydialog.h>
+#include <aknmessagequerydialog.h>
+#include <w32std.h>
+#include <eikmenup.h>
+#include <commdb.h>
+
+#include <HtiAdmin.rsg>
+#include <HtiCommPluginInterface.h> // for KHTICommInterfaceUid
+#include <HtiCfg.h>
+#include <HtiVersion.h>
+
+#include "HtiAdmin.pan"
+#include "HtiAdminAppUi.h"
+#include "HtiAdminAppView.h"
+#include "HtiAdmin.hrh"
+
+
+#ifdef __ENABLE_LOGGING__
+
+#include <flogger.h>
+
+_LIT(KLogFolder, "hti");
+_LIT(KLogFile, "htiadmin.txt");
+#define HTI_LOG_TEXT(a1) {_LIT(temp, a1); RFileLogger::Write(KLogFolder, KLogFile, EFileLoggingModeAppend, temp);}
+#define HTI_LOG_FORMAT(a1,a2) {_LIT(temp, a1); RFileLogger::WriteFormat(KLogFolder, KLogFile, EFileLoggingModeAppend, temp, (a2));}
+#define HTI_LOG_DES(a1) {RFileLogger::Write(KLogFolder, KLogFile, EFileLoggingModeAppend, (a1));}
+
+#else // __ENABLE_LOGGING__
+
+#define HTI_LOG_TEXT(a1)
+#define HTI_LOG_FORMAT(a1,a2)
+#define HTI_LOG_DES(a1)
+
+#endif // __ENABLE_LOGGING__
+
+// CONSTANTS
+_LIT( KHtiWatchDogMatchPattern, "HtiWatchDog*" );
+_LIT( KHtiFrameworkExe, "HtiFramework.exe" );
+_LIT( KHtiMatchPattern, "HtiFramework*" );
+_LIT( KHtiFrameworkCaption, "HTI status: " );
+_LIT( KHtiAutoStartCaption, "AutoStart: " );
+_LIT( KHtiVersionCaption, "Version: " );
+_LIT( KHtiSelectedCommCaption, "Communication: " );
+_LIT( KHtiAdminStartParameter, "admin" );
+_LIT( KHtiAdminVersionFormat, "%u.%u.%u (%uwk%02u)" );
+_LIT( KHtiAdminAboutVersionFormat, "Version %u.%u.%u - " );
+const static TInt KTerminateReason = 1;
+
+
+const TInt32 KHTIImplUidSerial    = {0x10210CCA};
+const TInt32 KHTIImplUidBluetooth = {0x200212CC};
+const TInt32 KHTIImplUidIPComm    = {0x200212CE};
+
+// configuration file constants
+_LIT( KCfgFilePath,         "\\");
+_LIT( KHtiCfg,              "hti.cfg" );
+_LIT( KHtiBtCommCfg,        "HTIBtComm.cfg" );
+_LIT( KHtiSerialCommCfg ,   "HTISerialComm.cfg" );
+_LIT( KHtiIPCommCfg,        "HTIIPComm.cfg" );
+// hti.cfg
+_LIT8( KCommPlugin,         "CommPlugin" );
+_LIT8( KPriority,           "Priority" );
+_LIT8( KShowConsole,        "ShowConsole" );
+_LIT8( KEnableHtiWatchDog,  "EnableHtiWatchDog" );
+_LIT8( KEnableHtiAutoStart, "EnableHtiAutoStart" );
+_LIT8( KShowErrorDialogs,   "ShowErrorDialogs" );
+// HtiBtComm.cfg
+_LIT8( KBtDeviceAddress,    "BtDeviceAddress" );
+_LIT8( KBtDeviceName,       "BtDeviceName" );
+// HtiSerialComm.cfg
+_LIT8( KCommPortNumber,     "CommPort" );
+// HTIIPComm.cfg
+_LIT8( KLocalPort,          "LocalPort" );
+_LIT8( KRemoteHost,         "RemoteHost" );
+_LIT8( KRemotePort,         "RemotePort" );
+_LIT8( KIAPName,            "IAPName" );
+
+
+// ConstructL is called by the application framework
+void CHtiAdminAppUi::ConstructL()
+    {
+    BaseConstructL( EAknEnableSkin );
+    iAppView = CHtiAdminAppView::NewL( ClientRect() );
+    AddToStackL( iAppView );
+
+    iAppView->SetCaption( KHtiFrameworkCaption );
+    iAppView->SetVersionCaption( KHtiVersionCaption );
+    iAppView->SetAutoStartCaption( KHtiAutoStartCaption );
+    iAppView->SetSelectedCommCaption( KHtiSelectedCommCaption );
+    UpdateVersion();
+    UpdateStatusL();
+    iHtiCfg = CHtiCfg::NewL();
+    UpdateAutoStartStatus(); // uses iHtiCfg
+    UpdateSelectedComm(); // uses iHtiCfg
+    }
+
+CHtiAdminAppUi::CHtiAdminAppUi()
+    {
+    iHtiCfg = NULL;
+    }
+
+CHtiAdminAppUi::~CHtiAdminAppUi()
+    {
+    KillTimer();
+    if ( iAppView )
+        {
+        RemoveFromStack( iAppView );
+        delete iAppView;
+        iAppView = NULL;
+        }
+
+    if ( iHtiCfg )
+        delete iHtiCfg;
+    }
+
+void CHtiAdminAppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane *aMenuPane)
+    {
+    HTI_LOG_FORMAT( "DynInitMenuPaneL 0x%x", aResourceId );
+
+    if ( aResourceId == R_HTIADMIN_MENU )
+        {
+        RProcess prs;
+        if ( OpenHtiProcess( prs ) )
+            {
+            if ( prs.ExitType() == EExitPending )
+                {
+                aMenuPane->SetItemDimmed( EHtiAdminStart, ETrue );
+                aMenuPane->SetItemDimmed( EHtiAdminSubOptions, ETrue );
+                prs.Close();
+                return;
+                }
+            }
+        aMenuPane->SetItemDimmed( EHtiAdminStop, ETrue );
+        prs.Close();
+        }
+
+    else if ( aResourceId == R_HTIADMIN_SUBMENU_OPTIONS )
+        {
+#if !defined(__ENABLE_LOGGING__)
+        aMenuPane->SetItemDimmed( EHtiAdminSubLogs, ETrue );
+#endif
+        }
+    else if ( aResourceId == R_HTIADMIN_SUBMENU_PRIORITY )
+        {
+        TInt priority = 3; // default value
+        TRAPD( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) );
+        if ( !err )
+            {
+            TRAP( err, priority = iHtiCfg->GetParameterIntL( KPriority ) );
+            }
+
+        switch ( priority )
+            {
+            case 1:
+                aMenuPane->SetItemButtonState( EHtiAdminPriorityBackground, EEikMenuItemSymbolOn );
+                break;
+            case 2:
+                aMenuPane->SetItemButtonState( EHtiAdminPriorityForeground, EEikMenuItemSymbolOn );
+                break;
+            case 4:
+                aMenuPane->SetItemButtonState( EHtiAdminPriorityAbsoluteHigh, EEikMenuItemSymbolOn );
+                break;
+            default:
+                aMenuPane->SetItemButtonState( EHtiAdminPriorityHigh, EEikMenuItemSymbolOn );
+                break;
+            }
+        }
+
+    else if ( aResourceId == R_HTIADMIN_SUBMENU_AUTOSTART )
+        {
+#ifdef __WINS__
+        TInt value = 0; // default value for emulator
+#else
+        TInt value = 1; // default value for hardware
+#endif
+        TRAPD( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) );
+        if ( !err )
+            {
+            TRAP( err, value = iHtiCfg->GetParameterIntL( KEnableHtiAutoStart ) );
+            }
+
+        if ( value )
+            aMenuPane->SetItemButtonState( EHtiAdminAutoStartEnable, EEikMenuItemSymbolOn );
+        else
+            aMenuPane->SetItemButtonState( EHtiAdminAutoStartDisable, EEikMenuItemSymbolOn );
+        }
+
+    else if ( aResourceId == R_HTIADMIN_SUBMENU_WATCHDOG )
+        {
+        TInt value = 0; // default value
+        TRAPD( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) );
+        if ( !err )
+            {
+            TRAP( err, value = iHtiCfg->GetParameterIntL( KEnableHtiWatchDog ) );
+            }
+
+        if ( value )
+            aMenuPane->SetItemButtonState( EHtiAdminWatchDogEnable, EEikMenuItemSymbolOn );
+        else
+            aMenuPane->SetItemButtonState( EHtiAdminWatchDogDisable, EEikMenuItemSymbolOn );
+        }
+
+    else if ( aResourceId == R_HTIADMIN_SUBMENU_CONSOLE )
+        {
+        TInt value = 0; // default value
+        TRAPD( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) );
+        if ( !err )
+            {
+            TRAP( err, value = iHtiCfg->GetParameterIntL( KShowConsole ) );
+            }
+
+        if ( value )
+            aMenuPane->SetItemButtonState( EHtiAdminConsoleEnable, EEikMenuItemSymbolOn );
+        else
+            aMenuPane->SetItemButtonState( EHtiAdminConsoleDisable, EEikMenuItemSymbolOn );
+        }
+
+    else if ( aResourceId == R_HTIADMIN_SUBMENU_ERROR_DIALOGS )
+        {
+        TInt value = 1; // default value
+        TRAPD( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) );
+        if ( !err )
+            {
+            TRAP( err, value = iHtiCfg->GetParameterIntL( KShowErrorDialogs ) );
+            }
+
+        if ( value )
+            aMenuPane->SetItemButtonState( EHtiAdminErrorDialogsEnable, EEikMenuItemSymbolOn );
+        else
+            aMenuPane->SetItemButtonState( EHtiAdminErrorDialogsDisable, EEikMenuItemSymbolOn );
+        }
+    }
+
+
+// Helper function to get data from a dialog
+TInt ShowDialog(TInt aResourceId, const TDesC &aText, TDes8 &aValue)
+    {
+    TBuf<KMaxParameterValueLength> data;
+
+    CAknTextQueryDialog* dlg;
+    dlg = new (ELeave) CAknTextQueryDialog(data);
+    CleanupStack::PushL(dlg);
+    dlg->SetPromptL(aText);
+    dlg->SetMaxLength(KMaxParameterValueLength);
+    CleanupStack::Pop(); // dlg
+
+    if ( dlg->ExecuteLD( aResourceId ) )
+        {
+        aValue.Copy(data);
+        return KErrNone;
+        }
+
+    return KErrCancel;
+    }
+
+void CHtiAdminAppUi::ShowBTListQueryL()
+	{
+	TInt selectedOption( KErrNotFound );
+	        	 
+	CDesCArrayFlat* array = new (ELeave) CDesCArrayFlat(20);
+	CleanupStack::PushL(array);
+	
+	array->AppendL(_L("By BT address"));
+	array->AppendL(_L("By BT Name"));
+	array->AppendL(_L("Search when starting"));
+				 
+	CAknListQueryDialog* dlg = new(ELeave) CAknListQueryDialog( &selectedOption );
+	dlg->PrepareLC(R_QUERY_DIALOG);
+	dlg->SetItemTextArray(array);
+	dlg->SetOwnershipType(ELbmDoesNotOwnItemArray);
+	dlg->RunLD();
+	
+	CleanupStack::PopAndDestroy(array); 
+	
+	if(selectedOption == 0)
+		{
+		HandleBtByAddress();
+		}
+	else if(selectedOption == 1)
+		{
+		HandleBtByName();
+		}
+	else if (selectedOption == 2)
+		{
+		HandleBtSearch();
+		}
+	}
+
+void CHtiAdminAppUi::ShowIPListQueryL()
+	{
+	TInt selectedOption( KErrNotFound );
+	        	 
+	CDesCArrayFlat* array = new (ELeave) CDesCArrayFlat(10);
+	CleanupStack::PushL(array);
+	
+	array->AppendL(_L("Listen"));
+	array->AppendL(_L("Connect"));
+	
+	CAknListQueryDialog* dlg = new(ELeave) CAknListQueryDialog( &selectedOption );
+	dlg->PrepareLC(R_QUERY_DIALOG);
+	dlg->SetItemTextArray(array);
+	dlg->SetOwnershipType(ELbmDoesNotOwnItemArray);
+	dlg->RunLD();
+	
+	CleanupStack::PopAndDestroy(array); 
+	
+	if(selectedOption == 0)
+		{
+		HandleIPListen();
+		}
+	else if(selectedOption == 1)
+		{
+		HandleIPConnect();
+		}
+	}
+
+void CleanupRArray( TAny* object )
+    {
+    ( ( RImplInfoPtrArray* ) object )->ResetAndDestroy();
+    }
+
+void CHtiAdminAppUi::ShowCommsListQueryL()
+	{
+	TInt selectedOption( KErrNotFound );
+	        	 
+	const TInt pluginNameArrayGranularity (15);
+	CDesCArrayFlat* pluginNameArray = new (ELeave) CDesCArrayFlat(pluginNameArrayGranularity);
+	CleanupStack::PushL(pluginNameArray);
+		
+	RImplInfoPtrArray implInfoArray;
+	CleanupStack::PushL( TCleanupItem( CleanupRArray, &implInfoArray ) );
+	
+	REComSession::ListImplementationsL( KHTICommInterfaceUid, implInfoArray );
+
+	for ( TInt i = 0; i < implInfoArray.Count(); ++i )
+		{
+		pluginNameArray->AppendL(implInfoArray[i]->DisplayName());
+		}
+	
+	CAknListQueryDialog* dlg = new(ELeave) CAknListQueryDialog( &selectedOption );
+	
+	dlg->PrepareLC(R_QUERY_DIALOG);
+	dlg->SetHeaderTextL(_L("Select communication"));
+	dlg->SetItemTextArray(pluginNameArray);
+	dlg->SetOwnershipType(ELbmDoesNotOwnItemArray);
+	
+	if(dlg->RunLD())
+		{
+		TInt32 uid = implInfoArray[selectedOption]->ImplementationUid().iUid;
+		switch(uid)
+			{
+			case KHTIImplUidSerial:  
+				{
+				TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) );
+				iHtiCfg->SetParameterL( KCommPlugin, _L8( "SERIAL" ) );
+				iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg );
+
+				TBuf8<KMaxParameterValueLength> portNum;
+				if ( !ShowDialog( R_NUMERIC_QUERY, _L("Com port number:"), portNum ) )
+					{
+					TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiSerialCommCfg ) );
+					iHtiCfg->SetParameterL( KCommPortNumber, portNum );
+					iHtiCfg->SaveCfgL( KCfgFilePath, KHtiSerialCommCfg );
+					}
+				UpdateSelectedComm();
+				}
+				break;
+				
+			case KHTIImplUidBluetooth:  
+				{
+				ShowBTListQueryL();				
+				}
+				break;
+				
+			case KHTIImplUidIPComm:  
+				{
+				ShowIPListQueryL();
+				}
+				break;
+			default:
+				{
+				//Just save the conf info for other plugins
+				TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) );
+				iHtiCfg->SetParameterL( KCommPlugin, implInfoArray[selectedOption]->DataType() );
+				iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg );
+				UpdateSelectedComm();
+				}
+			}
+		}
+	CleanupStack::PopAndDestroy(2, pluginNameArray);  
+	}
+
+void CHtiAdminAppUi::HandleBtByAddress()
+	{
+	TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath,  KHtiCfg ) );
+	iHtiCfg->SetParameterL( KCommPlugin, _L8( "BTSERIAL" ) );
+	iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg );
+
+	TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiBtCommCfg ) );
+	iHtiCfg->RemoveParameterL( KBtDeviceName );
+	iHtiCfg->RemoveParameterL( KBtDeviceAddress );
+
+	TBuf8<KMaxParameterValueLength> address;
+	if ( !ShowDialog( R_TEXT_QUERY, _L("BT address:"), address) )
+		{
+		iHtiCfg->SetParameterL( KBtDeviceAddress, address);
+		}
+
+	iHtiCfg->SaveCfgL( KCfgFilePath, KHtiBtCommCfg);
+	UpdateSelectedComm();
+	}
+
+void CHtiAdminAppUi::HandleBtByName()
+	{
+	TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) );
+	iHtiCfg->SetParameterL( KCommPlugin, _L8( "BTSERIAL" ) );
+	iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg );
+
+	TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiBtCommCfg ) );
+	iHtiCfg->RemoveParameterL( KBtDeviceName );
+	iHtiCfg->RemoveParameterL( KBtDeviceAddress );
+
+	TBuf8<KMaxParameterValueLength> name;
+	if ( !ShowDialog( R_TEXT_QUERY, _L( "BT name:" ), name ) )
+		{
+		iHtiCfg->SetParameterL( KBtDeviceName, name );
+		}
+
+	iHtiCfg->SaveCfgL( KCfgFilePath, KHtiBtCommCfg );
+	UpdateSelectedComm();
+	}
+
+void CHtiAdminAppUi::HandleBtSearch()
+	{
+	TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) );
+	iHtiCfg->SetParameterL( KCommPlugin, _L8( "BTSERIAL" ) );
+	iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg );
+
+	TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiBtCommCfg ) );
+	iHtiCfg->RemoveParameterL( KBtDeviceName );
+	iHtiCfg->RemoveParameterL( KBtDeviceAddress );
+	iHtiCfg->SaveCfgL( KCfgFilePath, KHtiBtCommCfg );
+	UpdateSelectedComm();
+	}
+
+void CHtiAdminAppUi::HandleIPListen()
+	{
+	TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) );
+	iHtiCfg->SetParameterL( KCommPlugin, _L8("IPCOMM"));
+	iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg );
+
+	TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiIPCommCfg ) );
+	iHtiCfg->RemoveParameterL( KRemotePort );
+	iHtiCfg->RemoveParameterL( KRemoteHost );
+	
+	TBuf8<KMaxParameterValueLength> localPort;
+	if ( !ShowDialog( R_TEXT_QUERY, _L( "Local port:" ), localPort ) )
+		{
+		iHtiCfg->SetParameterL( KLocalPort, localPort );
+		ShowCommsDBListQueryL();
+		}
+	iHtiCfg->SaveCfgL( KCfgFilePath, KHtiIPCommCfg );
+	UpdateSelectedComm();
+	}
+	
+void CHtiAdminAppUi::HandleIPConnect()
+	{
+	TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) );
+	iHtiCfg->SetParameterL( KCommPlugin, _L8( "IPCOMM" ) );
+	iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg );
+
+	TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiIPCommCfg ) );
+	iHtiCfg->RemoveParameterL( KLocalPort );
+	TBuf8<KMaxParameterValueLength> remoteHost;
+	TBuf8<KMaxParameterValueLength> remotePort;
+	if ( !ShowDialog( R_TEXT_QUERY, _L("Remote host:"), remoteHost ) )
+		{
+		iHtiCfg->SetParameterL( KRemoteHost, remoteHost );
+		if ( !ShowDialog( R_TEXT_QUERY, _L( "Remote port:" ), remotePort ) )
+			{
+			iHtiCfg->SetParameterL( KRemotePort, remotePort );
+			ShowCommsDBListQueryL();
+			}
+		}
+	iHtiCfg->SaveCfgL( KCfgFilePath, KHtiIPCommCfg );
+	UpdateSelectedComm();
+	}
+	
+
+// handle any menu commands
+void CHtiAdminAppUi::HandleCommandL(TInt aCommand)
+    {
+    TFileName cfgFile;
+
+    switch ( aCommand )
+        {
+        case EEikCmdExit:
+        case EAknSoftkeyExit:
+            Exit();
+            break;
+
+        case EHtiAdminStart:
+            {
+            HTI_LOG_TEXT( "Start" );
+            RProcess prs;
+            TInt err;
+            TBool isRunning = EFalse;
+            if ( OpenHtiProcess( prs ) )
+                {
+                if ( prs.ExitType() == EExitPending )
+                    {
+                    isRunning = ETrue;
+                    _LIT(KText, "Already running");
+                    iAppView->SetStatus( KText );
+                    }
+                prs.Close();
+                }
+
+            if ( !isRunning )
+                {
+                HTI_LOG_TEXT( "create process" );
+                err = prs.Create( KHtiFrameworkExe, KHtiAdminStartParameter );
+                if ( err == KErrNone )
+                    {
+                    prs.Resume();
+                    prs.Close();
+                    UpdateStatusL();
+                    HTI_LOG_TEXT("create done");
+                    }
+                else
+                    {
+                    TBuf<64> msg;
+                    msg.Format( _L("Error in starting: %d"), err );
+                    iAppView->SetStatus( msg );
+                    HTI_LOG_TEXT("create error");
+                    }
+                }
+            }
+            break;
+
+        case EHtiAdminStop:
+            {
+            HTI_LOG_TEXT("Stop");
+
+            // kill the watchdog to prevent it from restarting HTI again
+            KillHtiWatchDogL();
+
+            RProcess prs;
+            if ( OpenHtiProcess( prs ) )
+                {
+                if ( prs.ExitType() == EExitPending )
+                    {
+                    HTI_LOG_TEXT("try to kill");
+                    prs.Kill( KTerminateReason );
+                    UpdateStatusL();
+                    }
+                else
+                    {
+                    _LIT(KText, "Already stopped");
+                    iAppView->SetStatus( KText );
+                    }
+                prs.Close();
+                }
+            }
+            break;
+
+        case EHtiAdminAbout:
+            {
+            HTI_LOG_TEXT("About");
+            TDateSuffix suffix( KHtiVersionDay - 1 );
+            TMonthName month( ( TMonth ) ( KHtiVersionMonth - 1 ) );
+            TBuf<64> msgPart1;
+            msgPart1.Format( KHtiAdminAboutVersionFormat,
+                    KHtiVersionMajor, KHtiVersionMinor, KHtiVersionBuild );
+            msgPart1.AppendNum( KHtiVersionDay );
+            msgPart1.Append( suffix );
+            msgPart1.Append( ' ' );
+            msgPart1.Append( month );
+            msgPart1.Append( ' ' );
+            msgPart1.AppendNum( KHtiVersionYear );
+            msgPart1.Append( '.' );
+            msgPart1.Append( ' ' );
+            HBufC* msgPart2 = iEikonEnv->AllocReadResourceLC( R_HTIADMIN_ABOUT_TEXT );
+            HBufC* fullMsg = HBufC::NewLC( msgPart1.Length() + msgPart2->Length() );
+            fullMsg->Des().Append( msgPart1 );
+            fullMsg->Des().Append( *msgPart2 );
+            CAknMessageQueryDialog* dialog = new ( ELeave ) CAknMessageQueryDialog;
+            dialog->PrepareLC( R_HTIADMIN_ABOUT_DIALOG );
+            dialog->SetMessageTextL( *fullMsg );
+            dialog->RunLD();
+            CleanupStack::PopAndDestroy( 2 ); // fullMsg, msgPart2
+            }
+            break;
+
+        case EHtiAdminSubOptions:
+            break;
+
+        case EHtiAdminSubLogs:
+            break;
+
+        case EHtiAdminCreateLogFolder:
+#ifdef __ENABLE_LOGGING__
+            {
+            TInt err = KErrNone;
+            RFs fs;
+            err = fs.Connect();
+            if ( err == KErrNone )
+                {
+                err = fs.MkDirAll(_L("c:\\logs\\hti\\"));
+                }
+            fs.Close();
+            }
+#endif
+            break;
+
+        case EHtiAdminRemoveLogFolder:
+#ifdef __ENABLE_LOGGING__
+            {
+            TInt err = KErrNone;
+            RFs fs;
+            err = fs.Connect();
+            if ( err == KErrNone )
+                {
+                CFileMan *fileman = CFileMan::NewL( fs );
+                fileman->RmDir( _L( "c:\\logs\\hti\\" ) );
+                delete fileman;
+                }
+            fs.Close();
+            }
+#endif
+            break;
+
+        case EHtiAdminClearLogs:
+#ifdef __ENABLE_LOGGING__
+            {
+            TInt err = KErrNone;
+            RFs fs;
+            err = fs.Connect();
+            if ( err == KErrNone )
+                {
+                CFileMan *fileman = CFileMan::NewL( fs );
+                fileman->Delete( _L( "c:\\logs\\hti\\*" ) );
+                fileman->Delete( _L( "c:\\HTI_*.log" ) );
+                delete fileman;
+                }
+            fs.Close();
+            }
+#endif
+            break;
+
+        case EHtiAdminSubComms:
+        	{
+        	ShowCommsListQueryL();
+        	}
+            break;
+
+        case EHtiAdminSubPriority:
+            break;
+
+        case EHtiAdminPriorityBackground:
+            TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) );
+            iHtiCfg->SetParameterL( KPriority, _L8("1"));
+            iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg );
+            break;
+
+        case EHtiAdminPriorityForeground:
+            TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) );
+            iHtiCfg->SetParameterL( KPriority, _L8("2"));
+            iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg );
+            break;
+
+        case EHtiAdminPriorityHigh:
+            TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) );
+            iHtiCfg->SetParameterL( KPriority, _L8("3"));
+            iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg );
+            break;
+
+        case EHtiAdminPriorityAbsoluteHigh:
+            TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) );
+            iHtiCfg->SetParameterL( KPriority, _L8("4"));
+            iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg );
+            break;
+
+        case EHtiAdminSubAutoStart:
+            break;
+
+        case EHtiAdminAutoStartEnable:
+            TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) );
+            iHtiCfg->SetParameterL( KEnableHtiAutoStart, _L8("1"));
+            iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg );
+            UpdateAutoStartStatus();
+            break;
+
+        case EHtiAdminAutoStartDisable:
+            TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) );
+            iHtiCfg->SetParameterL( KEnableHtiAutoStart, _L8("0"));
+            iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg );
+            UpdateAutoStartStatus();
+            break;
+
+        case EHtiAdminSubWatchDog:
+            break;
+
+        case EHtiAdminWatchDogEnable:
+            TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) );
+            iHtiCfg->SetParameterL( KEnableHtiWatchDog, _L8("1"));
+            iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg );
+            break;
+
+        case EHtiAdminWatchDogDisable:
+            TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) );
+            iHtiCfg->SetParameterL( KEnableHtiWatchDog, _L8("0"));
+            iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg );
+            break;
+
+        case EHtiAdminSubConsole:
+            break;
+
+        case EHtiAdminConsoleEnable:
+            TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) );
+            iHtiCfg->SetParameterL( KShowConsole, _L8("1"));
+            iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg );
+            break;
+
+        case EHtiAdminConsoleDisable:
+            TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) );
+            iHtiCfg->SetParameterL( KShowConsole, _L8("0"));
+            iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg );
+            break;
+
+        case EHtiAdminErrorDialogsEnable:
+            TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) );
+            iHtiCfg->SetParameterL( KShowErrorDialogs, _L8("1"));
+            iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg );
+            break;
+
+        case EHtiAdminErrorDialogsDisable:
+            TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) );
+            iHtiCfg->SetParameterL( KShowErrorDialogs, _L8("0"));
+            iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg );
+            break;
+
+        case EHtiAdminSubSetParam:
+            break;
+
+        case EHtiAdminHtiCfg:
+            cfgFile = KHtiCfg;
+
+        case EHtiAdminHtiBtCommCfg:
+            if ( !cfgFile.Length() )
+                cfgFile = KHtiBtCommCfg;
+
+        case EHtiAdminHtiIPCommCfg:
+            if ( !cfgFile.Length() )
+                cfgFile = KHtiIPCommCfg;
+
+        case EHtiAdminHtiSerialCommCfg:
+            {
+            if ( !cfgFile.Length() )
+                cfgFile = KHtiSerialCommCfg;
+
+            TBuf8<KMaxParameterNameLength> parameterName;
+            if ( !ShowDialog( R_TEXT_QUERY, _L("Parameter name:"), parameterName) )
+                {
+                TBuf8<KMaxParameterValueLength> parameterValue;
+                if ( !ShowDialog( R_TEXT_QUERY, _L("Parameter value:"), parameterValue ) )
+                    {
+                    TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, cfgFile ) );
+                    iHtiCfg->SetParameterL( parameterName, parameterValue );
+                    iHtiCfg->SaveCfgL( KCfgFilePath, cfgFile);
+                    }
+                }
+            }
+            break;
+
+        default:
+        	{
+			CAknErrorNote* dialog = new(ELeave)CAknErrorNote(ETrue);			 
+			dialog->ExecuteLD(_L("Unknown Command Recieved"));
+			}
+        	break;
+        }
+    }
+
+void CHtiAdminAppUi::HandleForegroundEventL( TBool aForeground )
+    {
+    CAknAppUi::HandleForegroundEventL( aForeground );
+
+    if ( aForeground )
+        {
+        UpdateStatusL();
+        UpdateAutoStartStatus();
+        }
+    else
+        {
+        KillTimer();
+        }
+    }
+
+TBool CHtiAdminAppUi::OpenHtiProcess( RProcess& aPrs )
+    {
+    HTI_LOG_TEXT( "OpenHtiProcess" );
+
+    TFullName processName;
+    TInt err;
+
+    TFindProcess finder( KHtiMatchPattern );
+    err = finder.Next( processName );
+    if ( err == KErrNone )
+        {
+        HTI_LOG_TEXT( "try to open..." );
+        err = aPrs.Open( finder );
+        HTI_LOG_TEXT( "opened" );
+
+        if ( err == KErrNone )
+            {
+            HTI_LOG_TEXT( "OpenHtiProcess OK" );
+            return ETrue;
+            }
+        else
+            {
+            HTI_LOG_TEXT( "Failed to open process" );
+            TBuf<64> msg;
+            msg.Format( _L( "Error: %d" ), err );
+            iAppView->SetStatus( msg );
+            }
+        }
+    else if ( err == KErrNotFound )
+        {
+        HTI_LOG_TEXT( "Not found" );
+        _LIT( KNotFound, "Stopped" );
+        iAppView->SetStatus( KNotFound );
+        }
+    else
+        {
+        TBuf<64> msg;
+        msg.Format( _L( "Error: %d" ), err );
+        iAppView->SetStatus( msg );
+        }
+
+    HTI_LOG_TEXT( "OpenHtiProcess NOK" );
+
+    return EFalse;
+    }
+
+
+void CHtiAdminAppUi::UpdateVersion()
+    {
+    HTI_LOG_TEXT( "UpdateVersion" );
+    TBuf<128> tmp;
+    tmp.Format( KHtiAdminVersionFormat, KHtiVersionMajor, KHtiVersionMinor,
+        KHtiVersionBuild, KHtiVersionYear, KHtiVersionWeek );
+     iAppView->SetVersion( tmp );
+    }
+
+
+void CHtiAdminAppUi::UpdateStatusL()
+    {
+    HTI_LOG_TEXT( "UpdateStatusL" );
+    RProcess prs;
+    if ( OpenHtiProcess( prs ) )
+        {
+        HTI_LOG_TEXT( "Update display" );
+        TExitType exT = prs.ExitType();
+
+        switch ( exT )
+            {
+            case EExitPending:
+                {
+                _LIT( KTxt, "Running" );
+                iAppView->SetStatus( KTxt );
+
+                // start timer to watch the status
+                if ( !iPeriodic )
+                    {
+                    iPeriodic = CPeriodic::NewL( CActive::EPriorityStandard );
+                    iPeriodic->Start( 5 * 1000 * 1000,
+                                      5 * 1000 * 1000,
+                                      TCallBack( TimerCallBackL, this ) );
+                    }
+                }
+                break;
+
+            case EExitKill:
+            case EExitTerminate:
+                {
+                _LIT( KTxt, "Stopped" );
+                iAppView->SetStatus( KTxt );
+                KillTimer();
+                }
+                break;
+
+            case EExitPanic:
+                {
+                _LIT( KTxt, "Panic" );
+                iAppView->SetStatus( KTxt );
+                KillTimer();
+                }
+                break;
+            };
+        prs.Close();
+        }
+    else
+        {
+        KillTimer();
+        }
+    }
+
+void CHtiAdminAppUi::UpdateAutoStartStatus()
+    {
+    HTI_LOG_TEXT( "UpdateAutoStartStatus" );
+    TInt value = KErrNotFound;
+    TRAPD( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) );
+    if ( !err )
+        {
+        TRAP( err, value = iHtiCfg->GetParameterIntL(KEnableHtiAutoStart) );
+        }
+
+    if ( value == KErrNotFound )
+        {
+        // Use default values if not found from config.
+#ifdef __WINS__
+        value = 0;
+#else
+        value = 1;
+#endif
+        }
+
+    if ( value == 0 )
+        {
+        _LIT( KTxt, "Disabled" );
+        iAppView->SetAutoStartStatus( KTxt );
+        }
+    else if ( value == 1 )
+        {
+        _LIT( KTxt, "Enabled" );
+        iAppView->SetAutoStartStatus( KTxt );
+        }
+    else
+        {
+        _LIT( KTxt, "Unknown" );
+        iAppView->SetAutoStartStatus( KTxt );
+        }
+    }
+
+void CHtiAdminAppUi::UpdateSelectedComm()
+    {
+    HTI_LOG_TEXT( "UpdateSelectedComm" );
+    TBuf<64> commPlugin;
+    TRAPD( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) );
+    if ( !err )
+        {
+        TBuf8<KMaxParameterValueLength> commValue;
+        TRAP( err, commValue = iHtiCfg->GetParameterL( KCommPlugin ) );
+        if ( err == KErrNone )
+            {
+            commPlugin.Copy( commValue );
+            }
+        }
+    // Use default if not found from config
+    if ( commPlugin.Length() == 0 )
+        {
+        commPlugin.Copy(KCommDefaultImplementation  );        
+        }
+    iAppView->SetSelectedComm( commPlugin );
+
+    if ( commPlugin.Compare( _L( "SERIAL" ) ) == 0 )
+        {
+        TInt portNum = 0;
+        TRAP( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiSerialCommCfg ) );
+        if ( err == KErrNone )
+            {
+            TRAP( err, portNum = iHtiCfg->GetParameterIntL( KCommPortNumber ) );
+            }
+        TBuf<16> portBuf;
+        portBuf.Copy( _L( "Port: " ) );
+        portBuf.AppendNum( portNum );
+        iAppView->SetCommDetails( portBuf );
+        }
+
+    else if ( commPlugin.Compare( _L( "BTSERIAL" ) ) == 0 )
+        {
+        TBuf<64> hostBuf;
+        TRAP( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiBtCommCfg ) );
+        if ( err == KErrNone )
+            {
+            TBuf8<KMaxParameterValueLength> hostValue;
+            TRAP( err, hostValue = iHtiCfg->GetParameterL( KBtDeviceAddress ) );
+            if ( err != KErrNone )
+                {
+                TRAP( err, hostValue = iHtiCfg->GetParameterL( KBtDeviceName ) );
+                }
+            if ( err == KErrNone )
+                {
+                hostBuf.Copy( hostValue );
+                }
+            }
+        if ( hostBuf.Length() > 0 )
+            {
+            hostBuf.Insert( 0, _L( "Host: " ) );
+            }
+        iAppView->SetCommDetails( hostBuf );
+        }
+
+    else if ( commPlugin.Compare( _L( "IPCOMM" ) ) == 0 )
+        {
+        TBuf<128> hostBuf;
+        TRAP( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiIPCommCfg ) );
+        if ( err == KErrNone )
+            {
+            TInt localPort = 0;
+            TRAP( err, localPort = iHtiCfg->GetParameterIntL( KLocalPort ) );
+            if ( err == KErrNone && localPort > 0 )
+                {
+                hostBuf.Copy( _L( "Listen: " ) );
+                hostBuf.AppendNum( localPort );
+                }
+            else
+                {
+                TBuf8<KMaxParameterValueLength> remoteHost;
+                TInt remotePort = 0;
+                TRAP( err, remoteHost = iHtiCfg->GetParameterL( KRemoteHost ) );
+                if ( err == KErrNone )
+                    {
+                    TRAP( err, remotePort = iHtiCfg->GetParameterIntL(
+                            KRemotePort ) );
+                    }
+                if ( err == KErrNone )
+                    {
+                    hostBuf.Copy( remoteHost );
+                    hostBuf.Insert( 0, _L("Connect: " ) );
+                    hostBuf.Append( ':' );
+                    hostBuf.AppendNum( remotePort );
+                    }
+                else
+                    {
+                    hostBuf.Copy( _L( "Invalid config!" ) );
+                    }
+                }
+            }
+        iAppView->SetCommDetails( hostBuf );
+        }
+
+    else
+        {
+        iAppView->SetCommDetails( KNullDesC );
+        }
+    }
+
+void CHtiAdminAppUi::KillHtiWatchDogL()
+    {
+    TFullName processName;
+    TFindProcess finder( KHtiWatchDogMatchPattern );
+    TInt err = finder.Next( processName );
+    if ( err == KErrNone )
+        {
+        HTI_LOG_TEXT( "HTI watchdog process found. Trying to open and kill it..." );
+        RProcess prs;
+        User::LeaveIfError( prs.Open( finder ) );
+        prs.Kill( KTerminateReason );
+        prs.Close();
+        HTI_LOG_TEXT( "HTI watchdog killed" );
+        }
+    }
+
+void CHtiAdminAppUi::KillTimer()
+    {
+    if ( iPeriodic )
+        {
+        iPeriodic->Cancel();
+        delete iPeriodic;
+        iPeriodic = NULL;
+        }
+    }
+
+TInt CHtiAdminAppUi::TimerCallBackL( TAny* aPtr )
+    {
+    ( (CHtiAdminAppUi*)aPtr )->UpdateStatusL();
+    return ETrue;
+    }
+
+void CHtiAdminAppUi::ShowCommsDBListQueryL()
+    {
+    TInt selectedOption( KErrNotFound );
+    TBuf<KMaxParameterValueLength> name;
+                 
+    CDesCArrayFlat* array = new (ELeave) CDesCArrayFlat(16);
+    CleanupStack::PushL(array);
+
+    // Get IAP names from the database
+    CCommsDatabase* db = CCommsDatabase::NewL(EDatabaseTypeIAP);;
+    CleanupStack::PushL(db);
+    db->ShowHiddenRecords();
+    CCommsDbTableView* view = db->OpenTableLC(TPtrC(IAP));
+    TInt res = view->GotoFirstRecord();
+
+    while(res == KErrNone)
+        {
+        view->ReadTextL(TPtrC(COMMDB_NAME), name);
+        array->InsertL(0, name);
+        res = view->GotoNextRecord();
+        }
+
+    CleanupStack::PopAndDestroy(view); //view
+    CleanupStack::PopAndDestroy(db); //db    
+
+    // Show IAP selection dialog
+    CAknListQueryDialog* dlg = new(ELeave) CAknListQueryDialog(&selectedOption);
+    dlg->PrepareLC(R_SELECT_IAP_DIALOG);
+    dlg->SetItemTextArray(array);
+    dlg->SetOwnershipType(ELbmDoesNotOwnItemArray);
+    dlg->RunLD();
+
+    if(selectedOption != KErrNotFound)
+        {
+        // Write selected IAP name to config file
+        name = array->MdcaPoint(selectedOption); 
+        TBuf8<KMaxParameterValueLength> iapName;
+        iapName.Copy(name);
+        iHtiCfg->SetParameterL(KIAPName, iapName);
+        }
+    CleanupStack::PopAndDestroy(array); 
+    }
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiAdmin/src/HtiAdminAppView.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,184 @@
+/*
+* 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:  AppView implementation, only displays two labels changed
+*                from CHtiAdminAppUi class
+*
+*/
+
+
+#include <coemain.h>
+#include <AknUtils.h>
+#include <HtiAdmin.rsg>
+
+#include "HtiAdminAppView.h"
+#include "HtiAdminApplication.h" //logging
+
+// Standard construction sequence
+CHtiAdminAppView* CHtiAdminAppView::NewL(const TRect& aRect)
+    {
+    CHtiAdminAppView* self = CHtiAdminAppView::NewLC(aRect);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CHtiAdminAppView* CHtiAdminAppView::NewLC(const TRect& aRect)
+    {
+    CHtiAdminAppView* self = new (ELeave) CHtiAdminAppView;
+    CleanupStack::PushL(self);
+    self->ConstructL(aRect);
+    return self;
+    }
+
+CHtiAdminAppView::CHtiAdminAppView()
+    {
+    // no implementation required
+    }
+
+CHtiAdminAppView::~CHtiAdminAppView()
+    {
+    delete iHtiCaption;
+    delete iHtiStatus;
+    delete iHtiVersionCaption;
+    delete iHtiVersion;
+    delete iHtiAutoStartCaption;
+    delete iHtiAutoStartStatus;
+    delete iHtiSelectedCommCaption;
+    delete iHtiSelectedComm;
+    delete iHtiCommDetails;
+    }
+
+void CHtiAdminAppView::ConstructL(const TRect& aRect)
+    {
+    //HTI_LOG_TEXT("CHtiAdminAppView::ConstructL");
+
+    iHtiCaption = HBufC::NewL( KMaxDisplayText );
+    iHtiStatus = HBufC::NewL( KMaxDisplayText );
+    iHtiVersionCaption = HBufC::NewL( KMaxDisplayText );
+    iHtiVersion = HBufC::NewL( KMaxDisplayText );
+    iHtiAutoStartCaption = HBufC::NewL( KMaxDisplayText );
+    iHtiAutoStartStatus = HBufC::NewL( KMaxDisplayText );
+    iHtiSelectedCommCaption = HBufC::NewL( KMaxDisplayText );
+    iHtiSelectedComm = HBufC::NewL( KMaxDisplayText );
+    iHtiCommDetails = HBufC::NewL( KMaxDisplayText );
+
+    // Create a window for this application view
+    CreateWindowL();
+
+    // Set the windows size
+    SetRect(aRect);
+
+    // Activate the window, which makes it ready to be drawn
+    ActivateL();
+    }
+
+// Draw this application's view to the screen
+void CHtiAdminAppView::Draw(const TRect& /*aRect*/) const
+    {
+    // Get the standard graphics context
+    CWindowGc& gc = SystemGc();
+
+    // Gets the control's extent
+    TRect rect = Rect();
+
+    // Clears the screen
+    gc.Clear(rect);
+
+    //draw text
+    const CFont* f = AknLayoutUtils::FontFromId( EAknLogicalFontSecondaryFont );
+    gc.UseFont( f );
+
+    TInt leftMargin = f->MaxNormalCharWidthInPixels() / 4;
+
+    TPoint dP( leftMargin, f->FontLineGap() );
+    gc.DrawText( *iHtiCaption, dP );
+    dP.iX += f->TextWidthInPixels( *iHtiCaption );
+    gc.DrawText( *iHtiStatus, dP );
+
+    dP.iX = leftMargin;
+    dP.iY += f->FontLineGap() * 1.5;
+    gc.DrawText( *iHtiVersionCaption, dP );
+    dP.iX += f->TextWidthInPixels( *iHtiVersionCaption );
+    gc.DrawText( *iHtiVersion, dP );
+
+    dP.iX = leftMargin;
+    dP.iY += f->FontLineGap() * 1.5;
+    gc.DrawText( *iHtiAutoStartCaption, dP );
+    dP.iX += f->TextWidthInPixels( *iHtiAutoStartCaption );
+    gc.DrawText( *iHtiAutoStartStatus, dP );
+
+    dP.iX = leftMargin;
+    dP.iY += f->FontLineGap() * 1.5;
+    gc.DrawText( *iHtiSelectedCommCaption, dP );
+    dP.iX += f->TextWidthInPixels( *iHtiSelectedCommCaption );
+    gc.DrawText( *iHtiSelectedComm, dP );
+    dP.iX = leftMargin;
+    dP.iY += f->FontLineGap();
+    gc.DrawText( *iHtiCommDetails, dP );
+    }
+
+void CHtiAdminAppView::SetCaption( const TDesC& aText )
+    {
+    iHtiCaption->Des().Copy( aText );
+    DrawDeferred();
+    }
+
+void CHtiAdminAppView::SetStatus( const TDesC& aText )
+    {
+    iHtiStatus->Des().Copy( aText );
+    DrawDeferred();
+    }
+
+void CHtiAdminAppView::SetVersionCaption( const TDesC& aText )
+    {
+    iHtiVersionCaption->Des().Copy( aText );
+    DrawDeferred();
+    }
+
+void CHtiAdminAppView::SetVersion( const TDesC& aText )
+    {
+    iHtiVersion->Des().Copy( aText );
+    DrawDeferred();
+    }
+
+void CHtiAdminAppView::SetAutoStartCaption( const TDesC& aText )
+    {
+    iHtiAutoStartCaption->Des().Copy( aText );
+    DrawDeferred();
+    }
+
+void CHtiAdminAppView::SetAutoStartStatus( const TDesC& aText )
+    {
+    iHtiAutoStartStatus->Des().Copy( aText );
+    DrawDeferred();
+    }
+
+void CHtiAdminAppView::SetSelectedCommCaption( const TDesC& aText )
+    {
+    iHtiSelectedCommCaption->Des().Copy( aText );
+    DrawDeferred();
+    }
+
+void CHtiAdminAppView::SetSelectedComm( const TDesC& aText )
+    {
+    iHtiSelectedComm->Des().Copy( aText );
+    DrawDeferred();
+    }
+
+void CHtiAdminAppView::SetCommDetails( const TDesC& aText )
+    {
+    iHtiCommDetails->Des().Copy( aText );
+    DrawDeferred();
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiAdmin/src/HtiAdminApplication.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,38 @@
+/*
+* 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:  Application implemetation
+*
+*/
+
+
+#include "HtiAdminDocument.h"
+#include "HtiAdminApplication.h"
+
+// UID for the application, this should correspond to the uid defined in the mmp file
+static const TUid KUidHtiAdminApp = {0x1020DEB5};
+
+CApaDocument* CHtiAdminApplication::CreateDocumentL()
+    {
+    //HTI_LOG_TEXT("CreateDocumentL");
+    // Create an HtiAdmin document, and return a pointer to it
+    CApaDocument* document = CHtiAdminDocument::NewL(*this);
+    return document;
+    }
+
+TUid CHtiAdminApplication::AppDllUid() const
+    {
+    // Return the UID for the HtiAdmin application
+    return KUidHtiAdminApp;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiAdmin/src/HtiAdminDocument.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  AppDoc implemetation
+*
+*/
+
+
+#include "HtiAdminAppUi.h"
+#include "HtiAdminDocument.h"
+
+// Standard Symbian OS construction sequence
+CHtiAdminDocument* CHtiAdminDocument::NewL(CEikApplication& aApp)
+    {
+    CHtiAdminDocument* self = NewLC(aApp);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CHtiAdminDocument* CHtiAdminDocument::NewLC(CEikApplication& aApp)
+    {
+    CHtiAdminDocument* self = new (ELeave) CHtiAdminDocument(aApp);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+void CHtiAdminDocument::ConstructL()
+    {
+    // no implementation required
+    }
+
+CHtiAdminDocument::CHtiAdminDocument(CEikApplication& aApp) : CAknDocument(aApp)
+    {
+    // no implementation required
+    }
+
+CHtiAdminDocument::~CHtiAdminDocument()
+    {
+    // no implementation required
+    }
+
+CEikAppUi* CHtiAdminDocument::CreateAppUiL()
+    {
+    // Create the application user interface, and return a pointer to it,
+    // the framework takes ownership of this object
+    CEikAppUi* appUi = new (ELeave) CHtiAdminAppUi;
+    return appUi;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BWINS/HtiBtCommInterfaceu.def	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,13 @@
+EXPORTS
+	??0RHtiBtCommInterface@@QAE@XZ @ 1 NONAME ; RHtiBtCommInterface::RHtiBtCommInterface(void)
+	?CancelReceive@RHtiBtCommInterface@@QAEXXZ @ 2 NONAME ; void RHtiBtCommInterface::CancelReceive(void)
+	?CancelSend@RHtiBtCommInterface@@QAEXXZ @ 3 NONAME ; void RHtiBtCommInterface::CancelSend(void)
+	?Close@RHtiBtCommInterface@@QAEXXZ @ 4 NONAME ; void RHtiBtCommInterface::Close(void)
+	?Connect@RHtiBtCommInterface@@QAEHAAVTDesC8@@H@Z @ 5 NONAME ; int RHtiBtCommInterface::Connect(class TDesC8 &, int)
+	?GetPortNumber@RHtiBtCommInterface@@QBEHXZ @ 6 NONAME ; int RHtiBtCommInterface::GetPortNumber(void) const
+	?GetReceiveBufferSize@RHtiBtCommInterface@@QBEHXZ @ 7 NONAME ; int RHtiBtCommInterface::GetReceiveBufferSize(void) const
+	?GetSendBufferSize@RHtiBtCommInterface@@QBEHXZ @ 8 NONAME ; int RHtiBtCommInterface::GetSendBufferSize(void) const
+	?Receive@RHtiBtCommInterface@@QAEXAAVTDes8@@AAVTRequestStatus@@@Z @ 9 NONAME ; void RHtiBtCommInterface::Receive(class TDes8 &, class TRequestStatus &)
+	?Send@RHtiBtCommInterface@@QAEXABVTDesC8@@AAVTRequestStatus@@@Z @ 10 NONAME ; void RHtiBtCommInterface::Send(class TDesC8 const &, class TRequestStatus &)
+	?Version@RHtiBtCommInterface@@QBE?AVTVersion@@XZ @ 11 NONAME ; class TVersion RHtiBtCommInterface::Version(void) const
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BWINS/HtiBtCommServeru.def	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?StartThread@@YAHXZ @ 1 NONAME ; int StartThread(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BWINS/HtiBtSerialComHelperu.def	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,16 @@
+EXPORTS
+	??1CBtSerialClient@@UAE@XZ @ 1 NONAME ; CBtSerialClient::~CBtSerialClient(void)
+	?ConnectL@CBtSerialClient@@QAEXABVTDesC16@@H@Z @ 2 NONAME ; void CBtSerialClient::ConnectL(class TDesC16 const &, int)
+	?ConnectL@CBtSerialClient@@QAEXVTBTDevAddr@@H@Z @ 3 NONAME ; void CBtSerialClient::ConnectL(class TBTDevAddr, int)
+	?ConnectL@CBtSerialClient@@QAEXXZ @ 4 NONAME ; void CBtSerialClient::ConnectL(void)
+	?Connected@CBtSerialClient@@QAEHXZ @ 5 NONAME ; int CBtSerialClient::Connected(void)
+	?Connecting@CBtSerialClient@@QAEHXZ @ 6 NONAME ; int CBtSerialClient::Connecting(void)
+	?Disconnect@CBtSerialClient@@QAEXXZ @ 7 NONAME ; void CBtSerialClient::Disconnect(void)
+	?FreeSpaceInSendBuffer@CBtSerialClient@@QAEHXZ @ 8 NONAME ; int CBtSerialClient::FreeSpaceInSendBuffer(void)
+	?NewL@CBtSerialClient@@SAPAV1@AAVMBtSerialClientObserver@@@Z @ 9 NONAME ; class CBtSerialClient * CBtSerialClient::NewL(class MBtSerialClientObserver &)
+	?ReadAsyncL@CBtSerialClient@@QAEXXZ @ 10 NONAME ; void CBtSerialClient::ReadAsyncL(void)
+	?SendBufferMaxSize@CBtSerialClient@@QAEHXZ @ 11 NONAME ; int CBtSerialClient::SendBufferMaxSize(void)
+	?SendL@CBtSerialClient@@QAEXABVTDesC8@@@Z @ 12 NONAME ; void CBtSerialClient::SendL(class TDesC8 const &)
+	?ServerAddressL@CBtSerialClient@@QAE?AVTBTDevAddr@@XZ @ 13 NONAME ; class TBTDevAddr CBtSerialClient::ServerAddressL(void)
+	?ServicePort@CBtSerialClient@@QAEHXZ @ 14 NONAME ; int CBtSerialClient::ServicePort(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/BtSerialClient.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,255 @@
+/*
+* 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:  Bluetooth serial client.
+*
+*/
+
+
+#ifndef __BTSERIALCLIENT_H__
+#define __BTSERIALCLIENT_H__
+
+// INCLUDES
+#include <e32base.h>
+#include <es_sock.h>
+#include <bt_sock.h>
+#include <BTextNotifiers.h>
+#include <BtSdp.h>
+
+#include "SocketObserver.h"
+
+// FORWARD DECLARATIONS
+class CMessageServiceSearcher;
+class CSocketsReader;
+class CSocketsWriter;
+
+
+class MBtSerialClientObserver
+    {
+public:
+    virtual void ConnectedToServer(TInt aError) = 0;
+    virtual void DisconnectedFromServer() = 0;
+    virtual void DataFromServer(const TDesC8& aData) = 0;
+    virtual void AllBufferedDataSent() = 0;
+    };
+
+/**
+* CBtSerialClient
+* Connects and sends messages to a remote machine using bluetooth
+*/
+class CBtSerialClient : public CActive, public MSocketObserver
+    {
+    public: // Constructors and destructor
+
+        /**
+        * NewL()
+        * Construct a CBtSerialClient
+        * @param aObserver the observer for this BT serial client
+        * @return a pointer to the created instance of CBtSerialClient
+        */
+        IMPORT_C static CBtSerialClient* NewL( MBtSerialClientObserver& aObserver );
+
+        /**
+        * ~CBtSerialClient()
+        * Destroy the object and release all memory objects.
+        * Close any open sockets.
+        */
+        IMPORT_C virtual ~CBtSerialClient();
+
+    public:     // New functions
+
+        /**
+        * ConnectL()
+        * Connect to remote device. Query user for a device.
+        */
+        IMPORT_C void ConnectL();
+
+        /**
+        * ConnectL()
+        * Connect to remote device.
+        */
+        IMPORT_C void ConnectL(const TBTDevAddr aBTServerDevice, const TInt aPort );
+
+        /**
+        * ConnectL()
+        * Connect to remote device by device name.
+        */
+        IMPORT_C void ConnectL( const TDesC& aBTServerDeviceName, const TInt aPort );
+
+        /**
+        * DisconnectL()
+        * Disconnect from remote machine
+        */
+        IMPORT_C void Disconnect();
+
+        /**
+        * IsConnecting()
+        * @return ETrue if the client is establishing a
+        * connection to the server.
+        */
+        IMPORT_C TBool Connecting();
+
+        /**
+        * Connected()
+        * @return ETrue if the client is fully connected to the server.
+        */
+        IMPORT_C TBool Connected();
+
+        /**
+        * ServerAddressL()
+        * @return address of connected server. Leaves with KErrNotReady, if
+        * not connected.
+        */
+        TBTDevAddr ServerAddressL();
+
+        /**
+        * Add data to outgoing buffer and start sending it to client.
+        *
+        * Leaves with KErrOverflow, if the outgoing buffer cannot
+        * be added all of the aData.
+        * Leaves with KErrNotReady, if client is not connected.
+        * When all data in internal buffer has been sent, observer
+        * is notified (AllBufferedDataSent)
+        */
+        IMPORT_C void SendL(const TDesC8& aData);
+
+        /**
+        * Issue read operation. Will complete asyncronously.
+        *
+        * Leaves with KErrNotReady, if client is not connected.
+        * Notifies observer, when some data has been read. Caller
+        * is responsible for calling this method again to receive
+        * more data.
+        */
+        IMPORT_C void ReadAsyncL();
+
+        /**
+        * Query free size of outgoing buffer.
+        */
+        IMPORT_C TInt FreeSpaceInSendBuffer();
+
+        /**
+        * Query max size of outgoing buffer.
+        */
+        IMPORT_C TInt SendBufferMaxSize();
+
+        /**
+        * Query the port of the service we are connected with
+        * @return Port number or KErrDisconnected if not connected to a service
+        */
+        IMPORT_C TInt ServicePort();
+
+    protected:    // from CActive
+
+        /**
+        * DoCancel()
+        * Cancel any outstanding requests
+        */
+        void DoCancel();
+
+        /**
+        * RunL()
+        * Respond to an event
+        */
+        void RunL();
+
+    protected: // from MSocketObserver
+
+        void ReportError( TErrorType aErrorType, TInt aErrorCode );
+        void NewData( const TDesC8& aData );
+        void AllBufferedDataSent();
+
+    private:
+
+        /**
+        * ConnectToServerL
+        * Connects to the service
+        */
+        void ConnectToServerL();
+
+        /**
+        * DisconnectFromServer()
+        * Disconnects from the service
+        */
+        void DisconnectFromServer();
+
+        /**
+        * CBtSerialClient()
+        * Constructs this object
+        */
+        CBtSerialClient( MBtSerialClientObserver& aObserver );
+
+        /**
+        * ConstructL()
+        * Performs second phase construction of this object
+        */
+        void ConstructL();
+
+    private:    // data
+
+        /**
+        * TState
+        * The state of the active object, determines behaviour within
+        * the RunL method.
+        * EWaitingToGetDevice waiting for the user to select a device
+        * EGettingDevice searching for a device
+        * EGettingService searching for a service
+        * EGettingConnection connecting to a service on a remote machine
+        * EConnected connected to a service on a remote machine
+        */
+        enum TState
+            {
+            EWaitingToGetDevice,      // phase 1 of Connect
+            EGettingDevice,           // phase 2 of Connect
+            EGettingService,          // phase 3 of Connect
+            EGettingConnection,       // phase 4 of Connect
+            EConnected, // sending and receiving data
+            EDisconnecting
+            };
+
+        MBtSerialClientObserver& iObserver;
+
+        /** iState the current state of the client */
+        TState iState;
+
+        /**
+        * iServiceSearcher searches for service this
+        * client can connect to.
+        * Owned by CBtSerialClient
+        */
+        CMessageServiceSearcher* iServiceSearcher;
+
+        /**
+        * iCurrentServiceIndex the index number of the service we are
+        * currently connecting/connected to
+        */
+        TInt iCurrentServiceIndex;
+
+        /** iSocketServer a connection to the socket server */
+        RSocketServ iSocketServer;
+
+        /** iSocket a socket to connect with */
+        RSocket iSocket;
+
+        /** iServiceClass the service class UUID to search for */
+        TUUID iServiceClass;
+
+        TBTDevAddr iBTServerDevice;
+
+        CSocketsReader* iSocketReader;
+        CSocketsWriter* iSocketWriter;
+    };
+
+#endif // __BTSERIALCLIENT_H__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/BtSerialEngine.pan	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  Bluetooth serial engine panic codes.
+*
+*/
+
+
+#ifndef __BTSERIALENGINE_PAN__
+#define __BTSERIALENGINE_PAN__
+
+#include <e32def.h>
+#include <e32std.h>
+
+/** Panic Categories */
+_LIT( KPanicSerialEngine, "BTSerialEngine" ); // All engine classes
+_LIT( KPanicBTServiceAdvertiser, "BTServiceAdvertiser" ); // only service advertiser
+
+
+enum TBTSerialEnginePanics
+    {
+    EBTPointToPointReceiverInvalidState = 1,
+    EBTPointToPointSenderExists = 2,
+    EBTPointToPointReceiverExists = 3,
+    EBTPointToPointSenderInvalidState = 4,
+    EBTPointToPointNoSender = 5,
+    EBTPointToPointAddMessage = 6,
+    EBTPointToPointNextRecordRequestComplete = 7,
+    EBTPointToPointAttributeRequestResult = 8,
+    EBTPointToPointAttributeRequestComplete = 9,
+    EBTPointToPointProtocolRead = 10,
+    EBTPointToPointAttributeRequest = 11,
+    EBTPointToPointSdpRecordDelete = 12,
+    EBTPointToPointServerStop = 13,
+    EBTPointToPointInvalidLogicState = 14,
+    EBTPointToPointUnableToDisconnect = 15,
+
+    EBTSerialEngineReadSocketBadState = 16,
+    EBTSerialEngineWriteSocketBadState = 17
+    };
+
+inline void Panic( TBTSerialEnginePanics aReason )
+    {
+    User::Panic( KPanicSerialEngine, aReason );
+    }
+
+
+#endif // __BTSERIALENGINE_PAN__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/HtiBtEngineLogging.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,92 @@
+/*
+* 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:  Logging for Bluetooth engine.
+*
+*/
+
+
+#ifndef __HTIBTENGINELOGGING_H__
+#define __HTIBTENGINELOGGING_H__
+
+// INCLUDES
+#include <flogger.h>
+
+/******************************************************/
+/**     LOG SETUP                                    **/
+/******************************************************/
+_LIT(KLogFolder, "Hti");
+_LIT(KLogFile, "BtSerialEngine.log");
+
+#ifdef __ENABLE_LOGGING__
+// Comment out the levels which are marked supported in the build
+// (and which are used runtime).
+//
+#define LOG_LEVEL_ERROR_SUPPORTED
+#define LOG_LEVEL_WARN_SUPPORTED
+#define LOG_LEVEL_INFO_SUPPORTED
+//#define LOG_LEVEL_DEBUG_SUPPORTED
+#endif
+
+/******************************************************/
+/**     MACRO DEFINITIONS                            **/
+/******************************************************/
+
+// Macros:                            Example:                                 Result:
+// LOGFMT_E(formatstring, parameter)  LOGFMT_E("Leave in RunL: %d", -6)        <TIME> ERROR: Leave in RunL: -6
+// LOG_E(string)                      LOG_E("There was an error")              <TIME> ERROR: There was an error
+// LOGFMT_W(formatstring, parameter)  LOGFMT_W("Buffer too small: %d", 12)     <TIME> WARNING: Buffer too small: 12
+// LOG_W(string)                      LOG_W("warmingtext")                     <TIME> WARNING: warningtext
+// LOGFMT_I(formatstring, parameter)  LOGFMT_I("plugin loaded: %S", &myDescr8) <TIME> INFO: plugin loaded: myplugin
+// LOG_I(string)                      LOG_I("abc")                             <TIME> INFO: abc
+// LOGFMT_D(formatstring, parameter)  LOGFMT_D("buffer length: %d", 56)        <TIME> DEBUG: buffer length: 56
+// LOG_D(string)                      LOG_D("abc")                             <TIME> DEBUG: abc
+
+#define ERRORSTR "ERROR: "
+#define WARNSTR  "WARNING: "
+#define INFOSTR  "INFO: "
+#define DEBUGSTR "DEBUG: "
+
+#ifdef LOG_LEVEL_ERROR_SUPPORTED
+    #define LOGFMT_E(a1, a2) {_LIT8(temp, ERRORSTR##a1); RFileLogger::WriteFormat(KLogFolder, KLogFile, EFileLoggingModeAppend, temp, a2);}
+    #define LOG_E(a1) {_LIT8(temp, ERRORSTR##a1); RFileLogger::Write(KLogFolder, KLogFile, EFileLoggingModeAppend, temp);}
+#else
+    #define LOGFMT_E(a1, a2) {}
+    #define LOG_E(a1) {}
+#endif
+
+#ifdef LOG_LEVEL_WARN_SUPPORTED
+    #define LOGFMT_W(a1, a2) {_LIT8(temp, WARNSTR##a1); RFileLogger::WriteFormat(KLogFolder, KLogFile, EFileLoggingModeAppend, temp, a2);}
+    #define LOG_W(a1) {_LIT8(temp, WARNSTR##a1); RFileLogger::Write(KLogFolder, KLogFile, EFileLoggingModeAppend, temp);}
+#else
+    #define LOGFMT_W(a1, a2) {}
+    #define LOG_W(a1) {}
+#endif
+
+#ifdef LOG_LEVEL_INFO_SUPPORTED
+    #define LOGFMT_I(a1, a2) {_LIT8(temp, INFOSTR##a1); RFileLogger::WriteFormat(KLogFolder, KLogFile, EFileLoggingModeAppend, temp, a2);}
+    #define LOG_I(a1) {_LIT8(temp, INFOSTR##a1); RFileLogger::Write(KLogFolder, KLogFile, EFileLoggingModeAppend, temp);}
+#else
+    #define LOGFMT_I(a1, a2) {}
+    #define LOG_I(a1) {}
+#endif
+
+#ifdef LOG_LEVEL_DEBUG_SUPPORTED
+    #define LOGFMT_D(a1, a2) {_LIT8(temp, DEBUGSTR##a1); RFileLogger::WriteFormat(KLogFolder, KLogFile, EFileLoggingModeAppend, temp, a2);}
+    #define LOG_D(a1) {_LIT8(temp, DEBUGSTR##a1); RFileLogger::Write(KLogFolder, KLogFile, EFileLoggingModeAppend, temp);}
+#else
+    #define LOGFMT_D(a1, a2) {}
+    #define LOG_D(a1) {}
+#endif
+
+#endif // __HTIBTENGINELOGGING_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/SocketObserver.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  The error notification interface.
+*
+*/
+
+
+#ifndef __SOCKETOBSERVER_H__
+#define __SOCKETOBSERVER_H__
+
+// CLASS DECLARATION
+
+/**
+* MEngineNotifier.
+* This class specifies the error notification interface.
+*/
+class MSocketObserver
+    {
+    public: // Enumerations
+
+        /**
+        * TErrorType.
+        * Error types encountered when reading/writing to a sockets.
+        *  - EDisconnected.      A disconnected error has been encountered.
+        *  - ETimeOutOnWrite.    A write operation has failed to complete
+        *                        within a predetermined period.
+        *  - EGeneralReadError.  A general error has been encountered
+        *                        during a read.
+        *  - EGeneralWriteError. A general error has been encountered
+        *                        during a write
+        */
+        enum TErrorType
+            {
+            EDisconnected,
+            ETimeOutOnWrite,
+            EGeneralReadError,
+            EGeneralWriteError
+            };
+
+    public: // New functions
+
+        /**
+        * ReportError.
+        * Reports a communication error.
+        * @param aErrorType Error type.
+        * @param aErrorCode Associated error code.
+        */
+        virtual void ReportError( TErrorType aErrorType, TInt aErrorCode ) = 0;
+
+        /**
+        * NewData.
+        * Data has been received on the socket and read into a buffer.
+        * @param aData The data buffer.
+        */
+        virtual void NewData(const TDesC8& aData) = 0;
+
+        virtual void AllBufferedDataSent() = 0;
+    };
+
+#endif // __SOCKETOBSERVER_H__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/btservicesearcher.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,264 @@
+/*
+* 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:  Bluetooth service searcher.
+*
+*/
+
+
+#ifndef __BTSERVICESEARCHER_H__
+#define __BTSERVICESEARCHER_H__
+
+// INCLUDES
+#include <e32base.h>
+#include <bttypes.h>
+#include <btextnotifiers.h>
+
+#include "SdpAttributeParser.h"
+#include "SdpAttributeNotifier.h"
+
+// CONSTANTS
+#include "MessageProtocolConstants.h"
+
+// CLASS DECLARATIONS
+/**
+* CBTServiceSearcher
+* Searches for a service on a remote machine
+*/
+
+class CBTServiceSearcher : public CBase,
+                           public MSdpAgentNotifier,
+                           public MSdpAttributeNotifier
+    {
+    public: // Destructor
+
+        /**
+        * ~CBTServiceSearcher()
+        * Destroy the object and release all memory objects
+        */
+        virtual ~CBTServiceSearcher();
+
+    public: // New functions
+
+        /**
+        * SelectDeviceByDiscoveryL()
+        * Select a device
+        * @param aObserverRequestStatus the observer that is to
+        * be notified when the device selection is complete.
+        */
+        void SelectDeviceByDiscoveryL( TRequestStatus&
+                                       aObserverRequestStatus );
+
+       /**
+        * SelectDeviceByNameL()
+        * Select a device by BT device name.
+        * @param aDeviceName the name of the device to search and select.
+        * @param aObserverRequestStatus the observer that is to
+        * be notified when the device selection is complete.
+        */
+        void SelectDeviceByNameL( const TDesC& aDeviceName,
+                                  TRequestStatus& aObserverRequestStatus );
+
+        /**
+        * FindServiceL()
+        * Find a service on the specified device
+        * @param aDeviceAddress the BT address of the device to search for
+        * the service
+        * @param aObserverRequestStatus the observer that is to be notified
+        * when the service search is complete
+        */
+        void FindServiceL( const TBTDevAddr& aDeviceAddress,
+            TRequestStatus& aObserverRequestStatus );
+
+        /**
+        * BTDevAddr()
+        * @return the bluetooth device address
+        */
+        const TBTDevAddr& BTDevAddr();
+
+        /**
+        * ResponseParams()
+        * @return Information about the device selected by the user
+        */
+        const TBTDeviceResponseParams& ResponseParams();
+
+    protected:  // New functions
+
+        /**
+        * CBTServiceSearcher()
+        * Constructs this object
+        */
+        CBTServiceSearcher();
+
+        /**
+        * Finished()
+        * The search has finished. Notify the observer
+        * that the process is complete.
+        */
+        virtual void Finished( TInt aError = KErrNone );
+
+        /**
+        * HasFinishedSearching()
+        * Is the instance still wanting to search.
+        * @return EFalse if the instance wants searching to continue.
+        */
+        virtual TBool HasFinishedSearching() const;
+
+        /**
+        * HasFoundService()
+        * @return ETrue if a service has been found
+        */
+        TBool HasFoundService() const;
+
+    protected: // abstract methods
+
+        /**
+        * ProtocolList()
+        * The list of Protocols required by the service.
+        */
+        virtual const TSdpAttributeParser::TSdpAttributeList&
+                                           ProtocolList() const = 0;
+
+        /**
+        * ServiceClass()
+        * The service class to search for
+        * @return the service class UUID
+        */
+        virtual const TUUID& ServiceClass() const = 0;
+
+        /**
+        * FoundElementL()
+        * Read the data element
+        * @param aKey a key that identifies the element
+        * @param aValue the data element
+        */
+        virtual void FoundElementL( TInt aKey, CSdpAttrValue& aValue ) = 0;
+
+    public: // from MSdpAgentNotifier
+
+        /**
+        * NextRecordRequestComplete()
+        * Process the result of the next record request
+        * @param aError the error code
+        * @param aHandle the handle of the service record
+        * @param aTotalRecordsCount the total number of matching
+        * service records
+        */
+        void NextRecordRequestComplete( TInt aError,
+                                        TSdpServRecordHandle aHandle,
+                                        TInt aTotalRecordsCount );
+
+        /**
+        * AttributeRequestResult()
+        * Process the next attribute requested
+        * @param aHandle the handle of the service record
+        * @param aAttrID the id of the attribute
+        * @param aAttrValue the value of the attribute
+        */
+        void AttributeRequestResult( TSdpServRecordHandle aHandle,
+                                     TSdpAttributeID aAttrID,
+                                     CSdpAttrValue* aAttrValue );
+
+        /**
+        * AttributeRequestComplete()
+        * Process the arrtibute request completion
+        * @param aHandle the handle of the service record
+        * @param aError the error code
+        */
+        void AttributeRequestComplete( TSdpServRecordHandle aHandle,
+                                       TInt aError );
+
+    private:    // Functions from base classes
+
+        /**
+        * NextRecordRequestCompleteL()
+        * Process the result of the next record request
+        * @param aError the error code
+        * @param aHandle the handle of the service record
+        * @param aTotalRecordsCount the total number of
+        * matching service records
+        */
+        void NextRecordRequestCompleteL( TInt aError,
+                                         TSdpServRecordHandle aHandle,
+                                         TInt aTotalRecordsCount );
+
+        /**
+        * AttributeRequestResultL()
+        * Process the next attribute requested
+        * @param aHandle the handle of the service record
+        * @param aAttrID the id of the attribute
+        * @param aAttrValue the value of the attribute
+        */
+        void AttributeRequestResultL( TSdpServRecordHandle aHandle,
+                                      TSdpAttributeID aAttrID,
+                                      CSdpAttrValue* aAttrValue );
+
+        /**
+        * AttributeRequestCompleteL()
+        * Process the arrtibute request completion
+        * @param aHandle the handle of the service record
+        * @param aError the error code
+        */
+        void AttributeRequestCompleteL( TSdpServRecordHandle,
+                                        TInt aError );
+
+    private:    // data
+
+        /**
+        * iStatusObserver pointer to the request status observer
+        * Not owned by CBTServiceSearcher
+        */
+        TRequestStatus* iStatusObserver;
+
+        /**
+        * iIsDeviceSelectorConnected is the device
+        * selector connected?
+        */
+        TBool iIsDeviceSelectorConnected;
+
+        /**
+        * iDeviceSelector
+        * a handle to the bluetooth device selector notifier
+        */
+        RNotifier iDeviceSelector;
+
+        /**
+        * iResponse
+        * the response of the device selection.
+        */
+        TBTDeviceResponseParamsPckg iResponse;
+
+        /**
+        * iSelectionFilter
+        * Request a device selection
+        */
+        TBTDeviceSelectionParamsPckg iSelectionFilter;
+        /**
+        * iAgent a connetction to the SDP client
+        * Owned by CBTServiceSearcher
+        */
+        CSdpAgent* iAgent;
+
+        /**
+        * iSdpSearchPattern a search pattern
+        * Owned by CBTServiceSearcher
+        */
+        CSdpSearchPattern* iSdpSearchPattern;
+
+        /** iHasFoundService has the service been found ? */
+        TBool iHasFoundService;
+    };
+
+#endif // __BTSERVICESEARCHER_H__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/btservicesearcher.pan	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,48 @@
+/*
+* 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:  Bluetooth service searcher panic codes.
+*
+*/
+
+
+#ifndef __BTSERVICE_SEARCHER_PAN__
+#define __BTSERVICE_SEARCHER_PAN__
+
+#include <e32std.h>
+
+/** BTServiceSearcher application panic codes */
+enum TBTServiceSearcherPanics
+    {
+    EBTServiceSearcherNextRecordRequestComplete = 1,
+    EBTServiceSearcherAttributeRequestResult,
+    EBTServiceSearcherAttributeRequestComplete,
+    EBTServiceSearcherInvalidControlIndex,
+    EBTServiceSearcherProtocolRead,
+    EBTServiceSearcherAttributeRequest,
+    EBTServiceSearcherSdpRecordDelete
+    };
+
+
+/** Panic Category */
+_LIT( KPanicServiceSearcher, "ServiceSearcher" );
+
+
+inline void Panic( TBTServiceSearcherPanics aReason )
+    {
+    User::Panic( KPanicServiceSearcher, aReason );
+    }
+
+#endif // __BTSERVICE_SEARCHER_PAN__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/messageprotocolconstants.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,37 @@
+/*
+* 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:  Constants for Bluetooth.
+*
+*/
+
+
+#ifndef __CMESSAGE_PROTOCOL_CONSTANTS__
+#define __CMESSAGE_PROTOCOL_CONSTANTS__
+
+// INCLUDES
+#include <bt_sock.h>
+
+const TInt KRfcommChannel = 1;
+const TInt KServiceClass = 0x1101;    //  SerialPort
+
+const TUid KUidBTPointToPointApp = { 0x10005B8B };
+
+_LIT( KStrRFCOMM,             "RFCOMM" );
+
+const TInt KListeningQueSize = 1;
+
+
+#endif //__CMESSAGE_PROTOCOL_CONSTANTS__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/messageservicesearcher.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,134 @@
+/*
+* 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:  Message service searcher.
+*
+*/
+
+
+#ifndef __MESSAGESERVICESEARCHER_H__
+#define __MESSAGESERVICESEARCHER_H__
+
+// INCLUDES
+#include <e32base.h>
+#include "BTServiceSearcher.h"
+
+// CLASS DECLARATIONS
+/**
+* CMessageServiceSearcher
+* Searches for a message service.
+*/
+class CMessageServiceSearcher : public CBTServiceSearcher
+    {
+    public:     // Constructors and destructor
+
+        /*
+        * NewL()
+        * Create a CMessageServiceSearcher object
+        * @return a pointer to the created instance of
+        * CMessageServiceSearcher
+        */
+        static CMessageServiceSearcher* NewL();
+
+        /**
+        * NewLC()
+        * Create a CMessageServiceSearcher object
+        * @return a pointer to the created instance of
+        * CMessageServiceSearcher
+        */
+        static CMessageServiceSearcher* NewLC();
+
+        /**
+        * ~CMessageServiceSearcher()
+        * Destroy the object and release all memory objects.
+        */
+        virtual ~CMessageServiceSearcher();
+
+    public: // New functions
+
+        /**
+        * Port()
+        * Retrieve the port on which the service is installed
+        * @param aIndex index number of the service whose port number to get
+        * @return the port number or KErrNotFound if aIndex negative or greater
+        * than returned by ServiceCount()
+        */
+        TInt Port( TInt aIndex = 0 );
+
+        /**
+        * AppendPort()
+        * Adds a new port number to the port number array. If the port number
+        * already exists in the array a duplicate is not added.
+        * @param aPort the port number to add
+        * */
+        void AppendPort( TInt aPort );
+
+        /**
+         * ServiceCount()
+         * Get the amount of requested services found from the remote machine
+         * @return the count of services (= ports)
+         */
+         TInt ServiceCount();
+
+    protected:  // New functions
+
+        /**
+        * ServiceClass()
+        * @return the service class uid.
+        */
+        const TUUID& ServiceClass() const;
+
+        /**
+        * ProtocolList()
+        * @return the attribute list.
+        */
+        const TSdpAttributeParser::TSdpAttributeList& ProtocolList() const;
+
+        /**
+        * FoundElementL()
+        * Read the data element
+        * @param aKey a key that identifies the element
+        * @param aValue the data element
+        */
+        virtual void FoundElementL( TInt aKey, CSdpAttrValue& aValue );
+
+    private:    // Constructors
+
+        /**
+        * CMessageServiceSearcher()
+        * Constructs this object
+        * @param aLog the log to send output to
+        */
+        CMessageServiceSearcher();
+
+        /**
+        * ConstructL()
+        * Performs second phase construction of this object
+        */
+        void ConstructL();
+
+    private:    // data
+
+        /** iServiceClass the service class UUID to search for */
+        TUUID iServiceClass;
+
+        /**
+        * iPortNumbers array of port numbers that has the remote
+        * service installed
+        */
+        RArray<TInt> iPortNumbers;
+    };
+
+#endif // __MESSAGESERVICESEARCHER_H__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/sdpattributenotifier.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,46 @@
+/*
+* 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:  Reads SDP Attribute elements.
+*
+*/
+
+
+#ifndef __SDP_ATTRIBUTE_NOTIFIER_H__
+#define __SDP_ATTRIBUTE_NOTIFIER_H__
+
+// FORWARD DECLARATIONS
+class CSdpAttrValue;
+
+// CLASS DECLARATIONS
+/**
+* MSdpAttributeNotifier
+* An instance of MSdpAttributeNotifier is used to read selected SDP Attribute
+* elements from an attribute value.
+*/
+class MSdpAttributeNotifier
+    {
+    public: // New functions
+
+        /**
+        * FoundElementL
+        * Read the data element
+        * @param aKey a key that identifies the element
+        * @param aValue the data element
+        */
+        virtual void FoundElementL( TInt aKey, CSdpAttrValue& aValue ) = 0;
+    };
+
+#endif // __SDP_ATTRIBUTE_NOTIFIER_H__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/sdpattributeparser.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,174 @@
+/*
+* 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:  Reads selected parts of SDP attribute values.
+*
+*/
+
+
+#ifndef __SDP_ATTRIBUTE_PARSER_H__
+#define __SDP_ATTRIBUTE_PARSER_H__
+
+// INCLUDES
+#include <btsdp.h>
+#include "StaticArrayC.h"
+
+// FORWARD DECLARATIONS
+class MSdpAttributeNotifier;
+
+// CLASS DECLARATIONS
+/**
+* TSdpAttributeParser
+* An instance of TSdpAttributeParser is used to check an SDP
+* attribute value, and read selected parts
+*/
+class TSdpAttributeParser : public MSdpAttributeValueVisitor
+    {
+    public:     // Enumerations
+
+        /**
+        * TNodeCommand
+        * The command to be carried out at a node
+        * ECheckType. Check the type of the value
+        * ECheckValue. Check the type and the value
+        * ECheckEnd. Check that a list ends at this point
+        * ESkip. Do not check this value - can not match a list end
+        * EReadValue. Pass the value onto the observer
+        * EFinished. Marks the end of the node list
+        */
+        enum TNodeCommand
+            {
+                ECheckType,
+                ECheckValue,
+                ECheckEnd,
+                ESkip,
+                EReadValue,
+                EFinished
+            };
+
+        /**
+        * SSdpAttributeNode
+        * An instance of SSdpAttributeNode is used to determine how
+        * to parse an SDP attribute value data element
+        */
+        struct SSdpAttributeNode
+        {
+            /** iCommand the command for the node */
+            TNodeCommand iCommand;
+
+            /** iType the expected type */
+            TSdpElementType iType;
+
+            /** iValue the expected value for ECheckValue,the value of aKey
+            * passed to the observer for EReadValue
+            */
+            TInt iValue;
+        };
+
+        typedef const TStaticArrayC< SSdpAttributeNode > TSdpAttributeList;
+
+        /**
+        * TSdpAttributeParser
+        * Construct a TSdpAttributeParser
+        * @param aNodeList the list of expected nodes
+        * @param aObserver an observer to read specified node values
+        */
+        TSdpAttributeParser( TSdpAttributeList& aNodeList,
+                             MSdpAttributeNotifier& aObserver );
+
+        /**
+        * HasFinished
+        * Check if parsing processed the whole list
+        * @return true is the index refers to the EFinished node
+        */
+        TBool HasFinished() const;
+
+    public: // from MSdpAttributeValueVisitor
+
+        /**
+        * VisitAttributeValueL
+        * Process a data element
+        * @param aValue the data element
+        * @param aType the type of the data element
+        */
+        void VisitAttributeValueL( CSdpAttrValue& aValue,
+                                   TSdpElementType aType );
+
+        /**
+        * StartListL
+        * Process the start of a data element list
+        * @param aList the data element list
+        */
+        void StartListL( CSdpAttrValueList& aList );
+
+        /**
+        * EndListL
+        * Process the end of a data element list
+        */
+        void EndListL();
+
+    private:    // Functions from base classes
+
+        /**
+        * CheckTypeL
+        * Check the type of the current node is the same as
+        * the specified type.
+        * @param aElementType the type of the current data element
+        */
+        void CheckTypeL( TSdpElementType aElementType ) const;
+
+        /**
+        * CheckValueL
+        * Check the value of the current node is the same as the specified value
+        * @param aValue the value of the current data element.
+        */
+        void CheckValueL( CSdpAttrValue& aValue ) const;
+
+        /**
+        * ReadValueL
+        * Pass the data element value to the observer
+        * @param aValue the value of the current data element.
+        */
+        void ReadValueL( CSdpAttrValue& aValue ) const;
+
+        /**
+        * CurrentNode
+        * Get the current node
+        * @return the current node
+        */
+        const SSdpAttributeNode& CurrentNode() const;
+
+        /**
+        * AdvanceL
+        * Advance to the next node. Leaves with KErrEof
+        * if at the finished node.
+        */
+        void AdvanceL();
+
+    private:    // data
+
+        /** iObserver the observer to read values */
+        MSdpAttributeNotifier& iObserver;
+
+        /** iNodeList a list defining the expected
+        * structure of the value
+        */
+        TSdpAttributeList& iNodeList;
+
+        /** iCurrentNodeIndex the index of the current node in iNodeList */
+        TInt iCurrentNodeIndex;
+    };
+
+#endif // __SDP_ATTRIBUTE_PARSER_H__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/sdpattributeparser.pan	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,42 @@
+/*
+* 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:  Bluetooth SDP attribute parser panic codes.
+*
+*/
+
+
+#ifndef __SDP_ATTRIBUTE_PARSER_PAN__
+#define __SDP_ATTRIBUTE_PARSER_PAN__
+
+/** Panic Category */
+_LIT( KPanicSAP, "SAP" );
+
+/** BTPointToPoint application panic codes */
+enum TSdpAttributeParserPanics
+    {
+    ESdpAttributeParserInvalidCommand = 1,
+    ESdpAttributeParserNoValue,
+    ESdpAttributeParserValueIsList,
+    ESdpAttributeParserValueTypeUnsupported
+    };
+
+inline void Panic( TSdpAttributeParserPanics aReason )
+    {
+    User::Panic( KPanicSAP, aReason );
+    }
+
+
+#endif // __SDP_ATTRIBUTE_PARSER_PAN__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/socketsreader.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,68 @@
+/*
+* 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:  Reads from socket.
+*
+*/
+
+
+#ifndef __SOCKETSREADER_H__
+#define __SOCKETSREADER_H__
+
+// INCLUDES
+#include <in_sock.h>
+
+// FORWARD DECLARATIONS
+class MSocketObserver;
+
+// CLASS DECLARATION
+
+const TInt KReadBufferMaxSize = 2 * 1024;
+
+class CSocketsReader : public CActive
+    {
+    public: // Constructors and destructors
+
+        static CSocketsReader* NewL( MSocketObserver& aObserver,
+                                     RSocket& aSocket );
+        virtual ~CSocketsReader();
+
+    public: // New functions
+
+        void ReadAsync(); // Use Cancel() to cancel
+
+    protected: // from CActive
+
+        void DoCancel();
+        void RunL();
+
+    private: // Constructors and destructors
+
+        CSocketsReader( MSocketObserver& aObserver, RSocket& aSocket );
+        void ConstructL();
+
+    private: // New functions
+
+        void IssueRead();
+
+    private: // Data
+
+        RSocket& iSocket;
+        MSocketObserver& iObserver;
+        TBuf8<KReadBufferMaxSize> iBuffer;
+        TSockXfrLength iLen;
+    };
+
+#endif // __SOCKETSREADER_H__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/socketswriter.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,97 @@
+/*
+* 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:  Writes to socket.
+*
+*/
+
+
+#ifndef __SOCKETSWRITER_H__
+#define __SOCKETSWRITER_H__
+
+// INCLUDES
+#include <in_sock.h>
+#include "TimeOutNotifier.h"
+
+// FORWARD DECLARATIONS
+class CTimeOutTimer;
+class MSocketObserver;
+
+const TInt KSocketWriteBufferSize = 1024;
+const TInt KTransferBufferSize = 8 * 1024;
+
+// CLASS DECLARATION
+class CSocketsWriter : public CActive, public MTimeOutNotifier
+    {
+    public:
+
+        static CSocketsWriter* NewL( MSocketObserver& aEngineNotifier,
+                                     RSocket& aSocket );
+        virtual ~CSocketsWriter();
+
+        /**
+         * Add data to iTransferBuffer and start sending if not already sending
+         * Leaves with KErrOverflow, if there is not enough free space.
+         * This can be called as long as there is space in buffer.
+         */
+        void SendL(const TDesC8& aData);
+
+        void CancelSending();
+
+        /**
+        * Return number of bytes that can be added to iTransferBuffer.
+        */
+        TInt FreeSpaceInSendBuffer();
+
+        TInt SendBufferMaxSize();
+
+    protected: // from CActive
+
+        void DoCancel();
+        void RunL();
+
+    protected: // from MTimeOutNotifier
+
+        void TimerExpired();
+
+    private: // Constructors and destructors
+
+        CSocketsWriter( MSocketObserver& aEngineNotifier, RSocket& aSocket );
+        void ConstructL();
+
+    private: // New functions
+
+        void SendNextPacket();
+
+    private: // Enumerations
+
+        enum TWriteState
+            {
+            ESending,
+            EIdle // nothing to be sent
+            };
+
+    private: // Data
+
+        RSocket& iSocket;
+        MSocketObserver& iObserver;
+        TBuf8<KTransferBufferSize> iTransferBuffer;
+        TBuf8<KSocketWriteBufferSize> iWriteBuffer;
+        CTimeOutTimer* iTimer;
+        TInt iTimeOut; // microseconds
+        TWriteState iWriteStatus;
+    };
+
+#endif // __SOCKETSWRITER_H__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/staticarrayc.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,86 @@
+/*
+* 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:  Templated class for using static arrays.
+*
+*/
+
+
+#ifndef __STATIC_ARRAY_C_H__
+#define __STATIC_ARRAY_C_H__
+
+
+// CLASS DECLARATIONS
+
+/**
+* TStaticArrayC
+* This templated class provides a type, and size, safe method of
+* using static arrays.
+*/
+template <class T>
+class TStaticArrayC
+    {
+    public:     // enumerations
+
+        /**
+        * operator[]
+        * Return an element from the array.
+        * @param aIndex the index of the element to return
+        * @return a reference to the object
+        */
+        inline const T& operator[]( TInt aIndex ) const;
+
+        /**
+        * TPanicCode
+        * Panic code
+        * EIndexOutOfBounds index is out of bounds
+        */
+        enum TPanicCode
+            {
+                EIndexOutOfBounds = 1
+            };
+
+        /**
+        * Panic
+        * Generate a panic.
+        * @param aPanicCode the reason code for the panic
+        */
+        inline void Panic( TPanicCode aPanicCode ) const;
+
+    public:     // data
+
+        /** iArray the arrat of elements */
+        const T* iArray;
+
+        /** iCount the number of elements */
+        TInt iCount;
+
+    };
+
+// INCLUDES
+#include "StaticArrayC.inl"
+
+/**
+* CONSTRUCT_STATIC_ARRAY_C
+* Initalise a global constant of type TStaticArrayC<>.
+* @param aValue the underlying const array of T
+*/
+#define CONSTRUCT_STATIC_ARRAY_C( aValue ) \
+        {   \
+        aValue,    \
+        sizeof( aValue ) / sizeof( *aValue )  \
+        }  \
+
+#endif //   __STATIC_ARRAY_C_H__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/staticarrayc.inl	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Inline method implementations of TStaticArrayC.
+*
+*/
+
+
+// CONSTANTS
+_LIT( KStaticArrayPanic,"StaticArray" );
+
+template <class T>
+inline const T& TStaticArrayC<T>::operator[]( TInt aIndex ) const
+    {
+    if ( ( aIndex >= iCount ) || ( aIndex < 0 ) )
+        {
+        Panic( EIndexOutOfBounds );
+        }
+
+    return  iArray[aIndex];
+    }
+
+template <class T>
+inline void TStaticArrayC<T>::Panic( TPanicCode aPanicCode ) const
+    {
+    User::Panic( KStaticArrayPanic, aPanicCode );
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/timeoutnotifier.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,36 @@
+/*
+* 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:  Interface for timeout notification.
+*
+*/
+
+
+#ifndef __TIMEOUTNOTIFIER_H__
+#define __TIMEOUTNOTIFIER_H__
+
+// CLASS DECLARATION
+
+class MTimeOutNotifier
+    {
+    public: // New functions
+
+        /**
+        * The function to be called when a timeout occurs.
+        */
+        virtual void TimerExpired() = 0;
+    };
+
+#endif // __TIMEOUTNOTIFIER_H__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/timeouttimer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,54 @@
+/*
+* 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:  Timer.
+*
+*/
+
+
+#ifndef __TIMEOUTTIMER_H__
+#define __TIMEOUTTIMER_H__
+
+// INCLUDES
+#include <e32base.h>
+
+// FORWARD DECLARATIONS
+class MTimeOutNotifier;
+
+// CLASS DECLARATION
+class CTimeOutTimer : public CTimer
+    {
+    public: // Constructors and destructors
+
+        static CTimeOutTimer* NewL( const TInt aPriority,
+                                    MTimeOutNotifier& aObserver);
+        virtual ~CTimeOutTimer();
+
+    protected: // Functions from base classes
+
+        void RunL();
+
+    private: // Constructors and destructors
+
+        CTimeOutTimer( const TInt aPriority,
+                       MTimeOutNotifier& aTimeOutNotify );
+        void ConstructL();
+
+    private: // Data
+
+        MTimeOutNotifier& iObserver;
+    };
+
+#endif // __TIMEOUTTIMER_H__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/src/BtSerialClient.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,440 @@
+/*
+* 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:  Bluetooth serial client.
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <btengsettings.h>  // CBTEngSettings
+
+#include "BtSerialClient.h"
+#include "MessageServiceSearcher.h"
+#include "BtSerialEngine.pan"
+#include "HtiBtEngineLogging.h"
+#include "socketswriter.h"
+#include "socketsreader.h"
+
+const TInt KMaxBtStartWaitLoop   = 5;
+const TInt KBtStateQueryInterval = 1000000; // microseconds
+
+
+// ----------------------------------------------------------------------------
+EXPORT_C CBtSerialClient* CBtSerialClient::NewL(MBtSerialClientObserver& aObserver)
+    {
+    CBtSerialClient* self = new (ELeave) CBtSerialClient(aObserver);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+CBtSerialClient::CBtSerialClient(MBtSerialClientObserver& aObserver)
+: CActive( CActive::EPriorityStandard ), iObserver(aObserver),
+  iState( EWaitingToGetDevice ), iCurrentServiceIndex( 0 )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// ----------------------------------------------------------------------------
+EXPORT_C CBtSerialClient::~CBtSerialClient()
+    {
+    delete iSocketReader;
+    delete iSocketWriter;
+
+    Cancel();
+
+    iSocket.Close();
+    iSocketServer.Close();
+
+    delete iServiceSearcher;
+    }
+
+// ----------------------------------------------------------------------------
+void CBtSerialClient::ConstructL()
+    {
+    LOG_D( "CBtSerialClient::ConstructL()" );
+
+   // Check Bluetooth power state
+    TBTPowerStateValue powerState = EBTPowerOff;
+    CBTEngSettings* btSettings = CBTEngSettings::NewLC();
+    TInt err = btSettings->GetPowerState( powerState );
+    if ( err )
+        {
+        LOGFMT_W( "CBtSerialClient::ConstructL(): GetPowerState error %d", err );
+        powerState = EBTPowerOff;
+        }
+
+    // If BT not on - try to set it on
+    if ( powerState == EBTPowerOff )
+        {
+        LOG_I( "CBtSerialClient::ConstructL(): BT not on - setting power on" );
+        err = btSettings->SetPowerState( EBTPowerOn );
+        if ( err )
+            {
+            LOGFMT_E( "CBtSerialClient::ConstructL(): SetPowerState error %d", err );
+            User::Leave( err );
+            }
+
+        // Wait until BT is reported to be on (or waiting time exceeds)
+        TInt loopCounter = 0;
+        while ( powerState == EBTPowerOff && loopCounter < KMaxBtStartWaitLoop )
+            {
+            btSettings->GetPowerState( powerState );
+            LOGFMT_D( "CBtSerialClient::ConstructL(): BT power state %d", powerState );
+            User::After( KBtStateQueryInterval );
+            loopCounter++;
+            }
+
+        if ( powerState == EBTPowerOff )
+            {
+            LOG_E( "CBtSerialClient::ConstructL(): Could not turn BT on" );
+            User::Leave( KErrCouldNotConnect );
+            }
+        LOG_I( "CBtSerialClient::ConstructL(): Continuing BT connect" );
+        }
+    CleanupStack::PopAndDestroy(); // btSettings
+
+    iServiceSearcher = CMessageServiceSearcher::NewL();
+    User::LeaveIfError( iSocketServer.Connect() );
+    iSocketReader = CSocketsReader::NewL( *this, iSocket );
+    iSocketWriter = CSocketsWriter::NewL( *this, iSocket );
+    }
+
+// ----------------------------------------------------------------------------
+void CBtSerialClient::DoCancel()
+    {
+    LOG_W("CBtSerialClient::DoCancel(): Doing nothing");
+    }
+
+// ----------------------------------------------------------------------------
+void CBtSerialClient::RunL()
+    {
+    if ( iStatus != KErrNone )
+        {
+        switch ( iState )
+            {
+            case EGettingDevice:
+                if ( iStatus == KErrCancel )
+                    {
+                    LOG_W( "CBtSerialClient: No device selected" );
+                    }
+                iState = EWaitingToGetDevice;
+                iObserver.ConnectedToServer( iStatus.Int() );
+                break;
+            case EGettingService:
+                LOGFMT_W( "CBtSerialClient: Failed to fetch remote service: %d", iStatus.Int() );
+                iObserver.ConnectedToServer( iStatus.Int() );
+                iState = EWaitingToGetDevice;
+                break;
+            case EGettingConnection:
+                LOGFMT_W( "CBtSerialClient: Failed to connect to remote service: %d", iStatus.Int() );
+                if ( iCurrentServiceIndex < iServiceSearcher->ServiceCount() )
+                    {
+                    // Try another service
+                    iCurrentServiceIndex++;
+                    ConnectToServerL(); // establish RFComm connection
+                    }
+                else
+                    {
+                    iState = EWaitingToGetDevice;
+                    iObserver.ConnectedToServer( iStatus.Int() );
+                    }
+                break;
+            case EConnected:
+                LOGFMT_I( "CBtSerialClient: Lost connection: %d", iStatus.Int() )
+                DisconnectFromServer();
+                iState = EDisconnecting;
+                break;
+            case EDisconnecting:
+                LOGFMT_I("CBtSerialClient: Disconnected from server: %d", iStatus.Int() );
+                iSocket.Close();
+                iState = EWaitingToGetDevice;
+                iObserver.DisconnectedFromServer();
+                break;
+            default:
+                Panic( EBTPointToPointInvalidLogicState );
+                break;
+            }
+        }
+    else // iStatus = KErrNone
+        {
+        switch ( iState )
+            {
+            case EGettingDevice:
+                // found a device now search for a suitable service
+                LOGFMT_I("CBtSerialClient: Found device: %S. Finding correct service.", &(iServiceSearcher->ResponseParams().DeviceName()) );
+                iState = EGettingService;
+                iStatus = KRequestPending;  // this means that the RunL can not
+                                            // be called until this program
+                                            // does something to iStatus
+                iBTServerDevice = iServiceSearcher->BTDevAddr();
+                iServiceSearcher->FindServiceL( iBTServerDevice, iStatus );
+                SetActive();
+                break;
+            case EGettingService:
+                LOGFMT_I("CBtSerialClient: Found %d remote services", iServiceSearcher->ServiceCount());
+                iState = EGettingConnection;
+                ConnectToServerL(); // establish RFComm connection
+                break;
+            case EGettingConnection:
+                LOG_I( "CBtSerialClient: Connected to remote service" );
+                iState = EConnected;
+                iObserver.ConnectedToServer( KErrNone );
+                break;
+            case EDisconnecting:
+                LOG_I( "CBtSerialClient: Disconnecting" );
+                iSocket.Close();
+                iState = EWaitingToGetDevice;
+                iObserver.DisconnectedFromServer();
+                break;
+            default:
+                LOGFMT_E( "CBtSerialClient: Invalid logic state in RunL: %d. Will panic", iState );
+                Panic( EBTPointToPointInvalidLogicState );
+                break;
+            };
+        }
+    }
+
+// ----------------------------------------------------------------------------
+EXPORT_C void CBtSerialClient::ConnectL()
+    {
+    if ( iState == EWaitingToGetDevice && !IsActive() )
+        {
+        LOG_D( "CBtSerialClient: Connecting by user selection" );
+        iState = EGettingDevice;
+        iServiceSearcher->SelectDeviceByDiscoveryL( iStatus );
+        SetActive();
+        }
+    else
+        {
+        LOG_W( "CBtSerialClient: Already connecting or connected" );
+        User::Leave( KErrInUse );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+EXPORT_C void CBtSerialClient::ConnectL( const TBTDevAddr aBTServerDevice,
+                                         const TInt aPort )
+    {
+    if ( iState == EWaitingToGetDevice && !IsActive() )
+        {
+        if ( aPort >= 0 )
+            {
+            // If there was a valid port given, add it as the first port to try
+            iServiceSearcher->AppendPort( aPort );
+            }
+        LOG_D( "CBtSerialClient: Connecting by address" );
+        iBTServerDevice = aBTServerDevice;
+        iServiceSearcher->FindServiceL( iBTServerDevice, iStatus );
+        iState = EGettingService;
+        iStatus = KRequestPending;  // this means that the RunL can not
+                                    // be called until this program
+                                    // does something to iStatus
+        SetActive();
+        }
+    else
+        {
+        LOG_W("CBtSerialClient: Already connecting or connected");
+        User::Leave( KErrInUse );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+EXPORT_C void CBtSerialClient::ConnectL( const TDesC& aBTServerDeviceName,
+                                         const TInt aPort )
+    {
+    if ( iState == EWaitingToGetDevice && !IsActive() )
+        {
+        if ( aPort >= 0 )
+            {
+            // If there was a valid port given, add it as the first port to try
+            iServiceSearcher->AppendPort( aPort );
+            }
+        LOG_D( "CBtSerialClient: Connecting by name" );
+        iState = EGettingDevice;
+        iServiceSearcher->SelectDeviceByNameL( aBTServerDeviceName, iStatus );
+        SetActive();
+        }
+    else
+        {
+        LOG_W( "CBtSerialClient: Already connecting or connected" );
+        User::Leave( KErrInUse );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+EXPORT_C TBTDevAddr CBtSerialClient::ServerAddressL()
+    {
+    if ( !Connected() )
+        {
+        User::Leave( KErrNotReady );
+        }
+    return iBTServerDevice;
+    }
+
+// ----------------------------------------------------------------------------
+EXPORT_C void CBtSerialClient::Disconnect()
+    {
+    if ( iState == EConnected )
+        {
+        DisconnectFromServer();
+        iState = EDisconnecting;
+        }
+    else
+        {
+        LOG_W( "CBtSerialClient: Disconnect: Not connected" );
+        User::Leave( KErrDisconnected );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+void CBtSerialClient::DisconnectFromServer()
+    {
+    // Terminate all operations
+    iSocket.CancelAll();
+    Cancel();
+    iSocketReader->Cancel();
+    iSocketWriter->CancelSending();
+
+    LOG_I( "CBtSerialClient: Disconnecting from server" );
+    iSocket.Shutdown( RSocket::ENormal, iStatus );
+    SetActive();
+    }
+
+// ----------------------------------------------------------------------------
+void CBtSerialClient::ConnectToServerL()
+    {
+    LOG_I("CBtSerialClient: ConnectToServerL")
+    User::LeaveIfError( iSocket.Open( iSocketServer, KStrRFCOMM ) );
+
+    TBTSockAddr address;
+    address.SetBTAddr( iServiceSearcher->BTDevAddr() );
+    address.SetPort( iServiceSearcher->Port( iCurrentServiceIndex ) );
+
+    LOGFMT_I("CBtSerialClient: ConnectToServerL: Port = %d", address.Port() );
+    iSocket.Connect( address, iStatus );
+
+#ifdef __WINS__
+    User::After( 1 ); // Needed to allow emulator client to connect to server
+#endif
+
+    SetActive();
+    }
+
+// ----------------------------------------------------------------------------
+EXPORT_C void CBtSerialClient::SendL(const TDesC8& aData)
+    {
+    if ( !Connected() )
+        {
+        User::Leave( KErrNotReady );
+        }
+
+    LOGFMT_D("CBtSerialClient::SendL: Sending data (max first 32 bytes): \"%S\"", &(aData.Left(32)));
+    iSocketWriter->SendL( aData ); // Add to data queue and start sending
+    LOG_D("CBtSerialClient::SendL: Sent to socket");
+    }
+
+EXPORT_C void CBtSerialClient::ReadAsyncL()
+    {
+    if ( !Connected() )
+        {
+        User::Leave( KErrNotReady );
+        }
+    iSocketReader->ReadAsync();
+    }
+
+// ----------------------------------------------------------------------------
+EXPORT_C TInt CBtSerialClient::FreeSpaceInSendBuffer()
+    {
+    return iSocketWriter->FreeSpaceInSendBuffer();
+    }
+
+// ----------------------------------------------------------------------------
+EXPORT_C TInt CBtSerialClient::SendBufferMaxSize()
+    {
+    return iSocketWriter->SendBufferMaxSize();
+    }
+
+// ----------------------------------------------------------------------------
+EXPORT_C TBool CBtSerialClient::Connected()
+    {
+    return (iState == EConnected);
+    }
+
+// ----------------------------------------------------------------------------
+EXPORT_C TBool CBtSerialClient::Connecting()
+    {
+    return ( ( iState == EGettingDevice ) ||
+             ( iState == EGettingService ) ||
+             ( iState == EGettingConnection ) );
+    }
+
+// ----------------------------------------------------------------------------
+EXPORT_C TInt CBtSerialClient::ServicePort()
+    {
+    if ( !Connected() )
+        {
+        return KErrDisconnected;
+        }
+    return iServiceSearcher->Port( iCurrentServiceIndex );
+    }
+
+// ----------------------------------------------------------------------------
+void CBtSerialClient::ReportError( TErrorType aErrorType, TInt aErrorCode )
+    {
+    LOGFMT_W( "CBtSerialClient::ReportError: %d", aErrorCode );
+    // From socket reader or writer
+    switch ( aErrorType )
+        {
+        case EDisconnected:
+            {
+            LOG_I( "CBtSerialClient: disconnected" );
+            }
+            break;
+        case ETimeOutOnWrite:
+            {
+            LOG_I( "CBtSerialClient: timout writing data. Disconnecting from server" );
+            }
+            break;
+        case EGeneralReadError:
+            {
+            LOG_I( "CBtSerialClient: general read error. Disconnecting from server" );
+            }
+            break;
+        case EGeneralWriteError:
+            {
+            LOG_I( "CBtSerialClient: general write error. Disconnecting from server" );
+            }
+            break;
+        }
+    Disconnect();
+    aErrorCode = aErrorCode;
+    }
+
+// ----------------------------------------------------------------------------
+ void CBtSerialClient::NewData( const TDesC8& aData )
+    {
+    iObserver.DataFromServer( aData );
+    }
+
+// ----------------------------------------------------------------------------
+void CBtSerialClient::AllBufferedDataSent()
+    {
+    iObserver.AllBufferedDataSent();
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/src/btservicesearcher.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,382 @@
+/*
+* 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:  Bluetooth service searcher.
+*
+*/
+
+
+// INCLUDE FILES
+#include "BTServiceSearcher.h"
+#include "BTServiceSearcher.pan"
+
+#include "HtiBtEngineLogging.h"
+
+// ============================ MEMBER FUNCTIONS ==============================
+
+// ----------------------------------------------------------------------------
+// CBTServiceSearcher::CBTServiceSearcher()
+// Constructor.
+// ----------------------------------------------------------------------------
+//
+CBTServiceSearcher::CBTServiceSearcher()
+:  iIsDeviceSelectorConnected( EFalse )
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CBTServiceSearcher::~CBTServiceSearcher()
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CBTServiceSearcher::~CBTServiceSearcher()
+    {
+    if ( iIsDeviceSelectorConnected )
+        {
+        iDeviceSelector.CancelNotifier( KDeviceSelectionNotifierUid );
+        iDeviceSelector.Close();
+        }
+    delete iSdpSearchPattern;
+    iSdpSearchPattern = NULL;
+
+    delete iAgent;
+    iAgent = NULL;
+    }
+
+// ----------------------------------------------------------------------------
+// CBTServiceSearcher::SelectDeviceByDiscoveryL()
+// Select a device.
+// ----------------------------------------------------------------------------
+//
+void CBTServiceSearcher::SelectDeviceByDiscoveryL(
+        TRequestStatus& aObserverRequestStatus )
+    {
+    if ( ! iIsDeviceSelectorConnected )
+        {
+        User::LeaveIfError( iDeviceSelector.Connect() );
+        iIsDeviceSelectorConnected = ETrue;
+        }
+
+    iSelectionFilter().SetUUID( ServiceClass() );
+
+    iDeviceSelector.StartNotifierAndGetResponse(
+        aObserverRequestStatus,
+        KDeviceSelectionNotifierUid,
+        iSelectionFilter,
+        iResponse );
+    }
+
+// ----------------------------------------------------------------------------
+// CBTServiceSearcher::SelectDeviceByNameL()
+// Select a device by BT device name.
+// ----------------------------------------------------------------------------
+//
+void CBTServiceSearcher::SelectDeviceByNameL( const TDesC& aDeviceName,
+        TRequestStatus& aObserverRequestStatus )
+    {
+    LOG_D( "CBTServiceSearcher::SelectDeviceByNameL" );
+
+    RSocketServ socketServ;
+    User::LeaveIfError( socketServ.Connect() );
+    CleanupClosePushL( socketServ );
+
+    TProtocolDesc pInfo;
+    _LIT( KL2Cap, "BTLinkManager" );
+    User::LeaveIfError(
+        socketServ.FindProtocol( TProtocolName( KL2Cap ), pInfo ) );
+
+    LOG_D( "CBTServiceSearcher: Found protocol" );
+
+    RHostResolver hr;
+    User::LeaveIfError( hr.Open( socketServ,
+                            pInfo.iAddrFamily, pInfo.iProtocol ) );
+    CleanupClosePushL( hr );
+
+    LOG_D( "CBTServiceSearcher: HostResolver open" );
+
+    TInquirySockAddr addr;
+    TNameEntry entry;
+    addr.SetIAC( KGIAC );
+    addr.SetAction( KHostResName | KHostResInquiry );
+
+    User::LeaveIfError( hr.GetByAddress( addr, entry ) );
+    LOG_D( "CBTServiceSearcher: GetByAddress ok" );
+    TBool isFound = EFalse;
+    TInt err = KErrNone;
+    while ( !isFound && !err )
+        {
+        if ( !aDeviceName.CompareF( entry().iName ) )
+            {
+            LOG_D( "CBTServiceSearcher: Name match" );
+            isFound = ETrue;
+            }
+        else
+            {
+            LOG_D( "CBTServiceSearcher: Not match - getting next" );
+            err = hr.Next( entry );
+            }
+        }
+    CleanupStack::PopAndDestroy( 2 ); // hr, socketServ
+
+    iStatusObserver = &aObserverRequestStatus;
+
+    if ( isFound )
+        {
+        TInquirySockAddr& sa = TInquirySockAddr::Cast( entry().iAddr );
+        iResponse().SetDeviceAddress( sa.BTAddr() );
+        iResponse().SetDeviceName( entry().iName );
+        TBTDeviceClass deviceClass( sa.MajorServiceClass(),
+                                    sa.MajorClassOfDevice(),
+                                    sa.MinorClassOfDevice() );
+        iResponse().SetDeviceClass( deviceClass );
+        User::RequestComplete( iStatusObserver, KErrNone );
+        }
+
+    else
+        {
+        LOG_E( "CBTServiceSearcher: Device not found! Can't connect!" );
+        User::RequestComplete( iStatusObserver, err );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CBTServiceSearcher::FindServiceL()
+// Find a service on the specified device.
+// ----------------------------------------------------------------------------
+//
+void CBTServiceSearcher::FindServiceL( const TBTDevAddr& aDeviceAddress,
+    TRequestStatus& aObserverRequestStatus )
+    {
+    iResponse().SetDeviceAddress( aDeviceAddress );
+    if ( !iResponse().IsValidBDAddr() )
+        {
+        User::Leave( KErrArgument );
+        }
+    iHasFoundService = EFalse;
+
+    // delete any existing agent and search pattern
+    delete iSdpSearchPattern;
+    iSdpSearchPattern = NULL;
+
+    delete iAgent;
+    iAgent = NULL;
+
+    iAgent = CSdpAgent::NewL(*this, BTDevAddr());
+
+    iSdpSearchPattern = CSdpSearchPattern::NewL();
+
+    iSdpSearchPattern->AddL( ServiceClass() );
+    // return code is the position in the list that the UUID is inserted at
+    // and is intentionally ignored
+
+    iAgent->SetRecordFilterL( *iSdpSearchPattern );
+
+    iStatusObserver = &aObserverRequestStatus;
+
+    iAgent->NextRecordRequestL();
+    }
+
+// ----------------------------------------------------------------------------
+// CBTServiceSearcher::NextRecordRequestComplete()
+// Process the result of the next record request.
+// ----------------------------------------------------------------------------
+//
+void CBTServiceSearcher::NextRecordRequestComplete(
+    TInt aError,
+    TSdpServRecordHandle aHandle,
+    TInt aTotalRecordsCount)
+    {
+    TRAPD( error,
+           NextRecordRequestCompleteL( aError, aHandle, aTotalRecordsCount );
+    );
+
+    if ( error != KErrNone )
+        {
+        Panic( EBTServiceSearcherNextRecordRequestComplete );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CBTServiceSearcher::NextRecordRequestCompleteL()
+// Process the result of the next record request.
+// ----------------------------------------------------------------------------
+//
+void CBTServiceSearcher::NextRecordRequestCompleteL(
+    TInt aError,
+    TSdpServRecordHandle aHandle,
+    TInt aTotalRecordsCount )
+    {
+    if ( aError == KErrEof )
+        {
+        Finished();
+        return;
+        }
+
+    if ( aError != KErrNone )
+        {
+        LOGFMT_E("CBTServiceSearcher: NextRecordRequestCompleteL: %d", aError );
+        Finished( aError );
+        return;
+        }
+
+    if ( aTotalRecordsCount == 0 )
+        {
+        LOG_I("CBTServiceSearcher: NextRecordRequestCompleteL: No records found");
+        Finished( KErrNotFound );
+        return;
+        }
+
+    //  Request its attributes
+    iAgent->AttributeRequestL( aHandle, KSdpAttrIdProtocolDescriptorList );
+    }
+
+// ----------------------------------------------------------------------------
+// CBTServiceSearcher::AttributeRequestResult()
+// Process the next attribute requested.
+// ----------------------------------------------------------------------------
+//
+void CBTServiceSearcher::AttributeRequestResult(
+    TSdpServRecordHandle aHandle,
+    TSdpAttributeID aAttrID,
+    CSdpAttrValue* aAttrValue )
+    {
+    TRAPD( error,
+         AttributeRequestResultL( aHandle, aAttrID, aAttrValue );
+         );
+    if ( error != KErrNone )
+        {
+        Panic( EBTServiceSearcherAttributeRequestResult );
+        }
+
+    // Delete obsolete local atribute pointer.
+    delete aAttrValue;
+    }
+
+// ----------------------------------------------------------------------------
+// CBTServiceSearcher::AttributeRequestResultL()
+// Process the next attribute requested.
+// ----------------------------------------------------------------------------
+//
+void CBTServiceSearcher::AttributeRequestResultL(
+    TSdpServRecordHandle /*aHandle*/,
+    TSdpAttributeID aAttrID,
+    CSdpAttrValue* aAttrValue )
+    {
+    __ASSERT_ALWAYS( aAttrID == KSdpAttrIdProtocolDescriptorList,
+                     User::Leave( KErrNotFound ) );
+
+    TSdpAttributeParser parser( ProtocolList(), *this );
+
+    // Validate the attribute value, and extract the RFCOMM channel
+    aAttrValue->AcceptVisitorL( parser );
+
+    if ( parser.HasFinished() )
+        {
+        // Found a suitable record so change state
+        iHasFoundService = ETrue;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CBTServiceSearcher::AttributeRequestComplete()
+// Process the attribute request completion.
+// -----------------------------------------------------------------------------
+//
+void CBTServiceSearcher::AttributeRequestComplete( TSdpServRecordHandle aHandle,
+                                                   TInt aError )
+    {
+    TRAPD( error,
+        AttributeRequestCompleteL( aHandle, aError );
+    );
+    if ( error != KErrNone )
+        {
+        Panic( EBTServiceSearcherAttributeRequestComplete );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CBTServiceSearcher::AttributeRequestCompleteL()
+// Process the attribute request completion.
+// ----------------------------------------------------------------------------
+//
+void CBTServiceSearcher::AttributeRequestCompleteL( TSdpServRecordHandle
+                                                    /*aHandle*/,
+                                                    TInt aError )
+    {
+    if ( aError != KErrNone )
+        {
+        LOGFMT_W("CBTServiceSearcher::AttributeRequestCompleteL: %d", aError);
+        }
+    else
+        {
+        // done with attributes of this service record, request next
+        iAgent->NextRecordRequestL();
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CBTServiceSearcher::Finished()
+// The search has finished and notify the observer
+// that the process is complete.
+// ----------------------------------------------------------------------------
+//
+void CBTServiceSearcher::Finished( TInt aError /* default = KErrNone */ )
+    {
+    if ( aError == KErrNone && !HasFoundService() )
+        {
+        aError = KErrNotFound;
+        }
+    User::RequestComplete( iStatusObserver, aError );
+    }
+
+// ----------------------------------------------------------------------------
+// CBTServiceSearcher::HasFinishedSearching()
+// Is the instance still wanting to search.
+// ----------------------------------------------------------------------------
+//
+TBool CBTServiceSearcher::HasFinishedSearching() const
+    {
+    return EFalse;
+    }
+
+// ----------------------------------------------------------------------------
+// CBTServiceSearcher::BTDevAddr()
+// Returns the bluetooth device address.
+// ----------------------------------------------------------------------------
+//
+const TBTDevAddr& CBTServiceSearcher::BTDevAddr()
+    {
+    return iResponse().BDAddr();
+    }
+
+// ----------------------------------------------------------------------------
+// CBTServiceSearcher::ResponseParams()
+// Returns information about the device selected by the user.
+// ----------------------------------------------------------------------------
+//
+const TBTDeviceResponseParams& CBTServiceSearcher::ResponseParams()
+    {
+    return iResponse();
+    }
+
+// ----------------------------------------------------------------------------
+// CBTServiceSearcher::HasFoundService()
+// True if a service has been found.
+// ----------------------------------------------------------------------------
+//
+TBool CBTServiceSearcher::HasFoundService() const
+    {
+    return iHasFoundService;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/src/messageservicesearcher.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,183 @@
+/*
+* 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:  Message service searcher.
+*
+*/
+
+
+// INCLUDE FILES
+#include <bt_sock.h>
+
+#include "MessageServiceSearcher.h"
+#include "BTServiceSearcher.pan"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// TSdpAttributeParser::SSdpAttributeNode[]
+// Construct a TSdpAttributeParser.
+// -----------------------------------------------------------------------------
+//
+static const TSdpAttributeParser::SSdpAttributeNode gSerialPortProtocolArray[] =
+    {
+        { TSdpAttributeParser::ECheckType, ETypeDES },
+        { TSdpAttributeParser::ECheckType, ETypeDES },
+        { TSdpAttributeParser::ECheckValue, ETypeUUID, KL2CAP },
+        { TSdpAttributeParser::ECheckEnd },
+        { TSdpAttributeParser::ECheckType, ETypeDES },
+        { TSdpAttributeParser::ECheckValue, ETypeUUID, KRFCOMM }, // KRFCOMM defined in bt_sock.h
+        { TSdpAttributeParser::EReadValue, ETypeUint, KRfcommChannel }, // KRfcommChannel is custom key value used in FoundElementL. If there were more than one value to be read, the key value would be usefull
+        { TSdpAttributeParser::ECheckEnd },
+        { TSdpAttributeParser::ECheckEnd },
+        { TSdpAttributeParser::EFinished }
+    };
+
+// ----------------------------------------------------------------------------
+// TStaticArrayC
+// Provides a type and size, safe method of using static arrays.
+// ----------------------------------------------------------------------------
+//
+static const TStaticArrayC<TSdpAttributeParser
+::SSdpAttributeNode> gSerialPortProtocolList = CONSTRUCT_STATIC_ARRAY_C(
+                                               gSerialPortProtocolArray );
+
+// ----------------------------------------------------------------------------
+// CMessageServiceSearcher::NewL()
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMessageServiceSearcher* CMessageServiceSearcher::NewL()
+    {
+    CMessageServiceSearcher* self = CMessageServiceSearcher::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CMessageServiceSearcher::NewLC()
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CMessageServiceSearcher* CMessageServiceSearcher::NewLC()
+    {
+    CMessageServiceSearcher* self = new (ELeave) CMessageServiceSearcher();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CMessageServiceSearcher::CMessageServiceSearcher()
+// Construcor.
+// ----------------------------------------------------------------------------
+//
+CMessageServiceSearcher::CMessageServiceSearcher()
+: CBTServiceSearcher(),
+  iServiceClass( KServiceClass )
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CMessageServiceSearcher::~CMessageServiceSearcher()
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CMessageServiceSearcher::~CMessageServiceSearcher()
+    {
+    iPortNumbers.Close();
+    }
+
+// ----------------------------------------------------------------------------
+// CMessageServiceSearcher::ConstructL()
+// Symbian 2nd phase constructor can leave.
+// ----------------------------------------------------------------------------
+//
+void CMessageServiceSearcher::ConstructL()
+    {
+    // no implementation required
+    }
+
+// ----------------------------------------------------------------------------
+// CMessageServiceSearcher::ServiceClass()
+// The service class to search.
+// ----------------------------------------------------------------------------
+//
+const TUUID& CMessageServiceSearcher::ServiceClass() const
+    {
+    return iServiceClass;
+    }
+
+// ----------------------------------------------------------------------------
+// CMessageServiceSearcher::ProtocolList()
+// The list of Protocols required by the service.
+// ----------------------------------------------------------------------------
+//
+const TSdpAttributeParser::TSdpAttributeList& CMessageServiceSearcher
+::ProtocolList() const
+    {
+    return gSerialPortProtocolList;
+    }
+
+// ----------------------------------------------------------------------------
+// CMessageServiceSearcher::FoundElementL()
+// Read the data element.
+// ----------------------------------------------------------------------------
+//
+void CMessageServiceSearcher::FoundElementL( TInt aKey, CSdpAttrValue& aValue )
+    {
+    __ASSERT_ALWAYS( aKey == static_cast<TInt>( KRfcommChannel ),
+        Panic( EBTServiceSearcherProtocolRead ) );
+    AppendPort( aValue.Uint() );
+    }
+
+// ----------------------------------------------------------------------------
+// CMessageServiceSearcher::Port()
+// Port connection on the remote machine.
+// ----------------------------------------------------------------------------
+//
+TInt CMessageServiceSearcher::Port( TInt aIndex )
+    {
+    if ( aIndex < 0 || aIndex >= iPortNumbers.Count() )
+        {
+        return KErrNotFound;
+        }
+    return iPortNumbers[aIndex];
+    }
+
+// ----------------------------------------------------------------------------
+// CMessageServiceSearcher::AppendPort()
+// Adds a new port number to the port number array. If the port number
+// already exists in the array a duplicate is not added.
+// ----------------------------------------------------------------------------
+//
+void CMessageServiceSearcher::AppendPort( TInt aPort )
+    {
+    if ( iPortNumbers.Find( aPort ) == KErrNotFound )
+        {
+        iPortNumbers.Append( aPort );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CMessageServiceSearcher::ServiceCount()
+// The amount of requested services found from the remote machine.
+// ----------------------------------------------------------------------------
+//
+TInt CMessageServiceSearcher::ServiceCount()
+    {
+    return iPortNumbers.Count();
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/src/sdpattributeparser.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,231 @@
+/*
+* 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:  Reads selected parts of SDP attribute values.
+*
+*/
+
+
+// INCLUDE FILES
+#include <bt_sock.h>
+
+#include "SdpAttributeParser.h"
+#include "SdpAttributeParser.pan"
+#include "SdpAttributeNotifier.h"
+
+// ============================ MEMBER FUNCTIONS ==============================
+
+// ----------------------------------------------------------------------------
+// TSdpAttributeParser::TSdpAttributeParser()
+// Construct a TSdpAttributeParser.
+// ----------------------------------------------------------------------------
+//
+
+TSdpAttributeParser::TSdpAttributeParser(
+    TSdpAttributeList& aNodeList,
+    MSdpAttributeNotifier& aObserver
+)
+:   iObserver( aObserver ),
+    iNodeList( aNodeList ),
+    iCurrentNodeIndex( 0 )
+    {
+    // no implementation required
+    }
+
+// ----------------------------------------------------------------------------
+// TSdpAttributeParser::HasFinished()
+// Check if parsing processed the whole list.
+// ----------------------------------------------------------------------------
+//
+TBool TSdpAttributeParser::HasFinished() const
+    {
+    return CurrentNode().iCommand == EFinished;
+    }
+
+// ----------------------------------------------------------------------------
+// TSdpAttributeParser::VisitAttributeValueL()
+// Process a data element.
+// ----------------------------------------------------------------------------
+//
+void TSdpAttributeParser::VisitAttributeValueL( CSdpAttrValue& aValue,
+                                                TSdpElementType aType )
+    {
+    switch ( CurrentNode().iCommand )
+        {
+        case ECheckType:
+            CheckTypeL( aType );
+            break;
+
+        case ECheckValue:
+            CheckTypeL( aType );
+            CheckValueL( aValue );
+            break;
+
+        case ECheckEnd:
+            User::Leave( KErrGeneral ); //list element contains too many items
+            break;
+
+        case ESkip:
+            break;  // no checking required
+
+        case EReadValue:
+            CheckTypeL( aType );
+            ReadValueL( aValue );
+            break;
+
+        case EFinished:
+            User::Leave( KErrGeneral ); // element is after
+            return;                     // value should have ended
+
+        default:
+            Panic( ESdpAttributeParserInvalidCommand );
+        }
+
+    AdvanceL();
+    }
+
+// ----------------------------------------------------------------------------
+// TSdpAttributeParser::StartListL()
+// Process the start of a data element list.
+// ----------------------------------------------------------------------------
+//
+void TSdpAttributeParser::StartListL( CSdpAttrValueList& /*aList*/ )
+    {
+    // no checks done here
+    }
+
+// ----------------------------------------------------------------------------
+// TSdpAttributeParser::EndListL()
+// Process the end of a data element list.
+// ----------------------------------------------------------------------------
+//
+void TSdpAttributeParser::EndListL()
+    {
+    // check we are at the end of a list
+    if ( CurrentNode().iCommand != ECheckEnd )
+        {
+        User::Leave( KErrGeneral );
+        }
+
+    AdvanceL();
+    }
+
+// ----------------------------------------------------------------------------
+// TSdpAttributeParser::CheckTypeL()
+// Check the type of the current node is the same as the specified type.
+// ----------------------------------------------------------------------------
+//
+void TSdpAttributeParser::CheckTypeL( TSdpElementType aElementType ) const
+    {
+    if ( CurrentNode().iType != aElementType )
+        {
+        User::Leave( KErrGeneral );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// TSdpAttributeParser::CheckValueL()
+// Check the value of the current node is the same as the specified type.
+// ----------------------------------------------------------------------------
+//
+void TSdpAttributeParser::CheckValueL( CSdpAttrValue& aValue ) const
+    {
+    switch ( aValue.Type() )
+        {
+        case ETypeNil:
+            Panic( ESdpAttributeParserNoValue );
+            break;
+
+        case ETypeUint:
+            if ( aValue.Uint() != ( TUint )CurrentNode().iValue )
+                {
+                User::Leave( KErrArgument );
+                }
+            break;
+
+        case ETypeInt:
+            if ( aValue.Int() != CurrentNode().iValue )
+                {
+                User::Leave( KErrArgument );
+                }
+            break;
+
+        case ETypeBoolean:
+            if ( aValue.Bool() != CurrentNode().iValue )
+                {
+                User::Leave( KErrArgument );
+                }
+            break;
+
+        case ETypeUUID:
+            if ( aValue.UUID() != TUUID( CurrentNode().iValue ) )
+                {
+                User::Leave( KErrArgument );
+                }
+            break;
+
+        // these are lists, so have to check contents
+        case ETypeDES:
+        case ETypeDEA:
+            Panic( ESdpAttributeParserValueIsList );
+            break;
+
+        // these aren't supported - use EReadValue and leave on error
+        //case ETypeString:
+        //case ETypeURL:
+        //case ETypeEncoded:
+        default:
+            Panic( ESdpAttributeParserValueTypeUnsupported );
+            break;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// TSdpAttributeParser::ReadValueL()
+// Pass the data element value to the observer.
+// ----------------------------------------------------------------------------
+//
+void TSdpAttributeParser::ReadValueL( CSdpAttrValue& aValue ) const
+    {
+    iObserver.FoundElementL( CurrentNode().iValue, aValue );
+    }
+
+// ----------------------------------------------------------------------------
+// TSdpAttributeParser::CurrentNode()
+// Get the current node.
+// ----------------------------------------------------------------------------
+//
+const TSdpAttributeParser::SSdpAttributeNode& TSdpAttributeParser
+::CurrentNode() const
+    {
+    return  iNodeList[iCurrentNodeIndex];
+    }
+
+// ----------------------------------------------------------------------------
+// TSdpAttributeParser::AdvanceL()
+// Advance to the next node.
+// ----------------------------------------------------------------------------
+//
+void TSdpAttributeParser::AdvanceL()
+    {
+    // check not at end
+    if ( CurrentNode().iCommand == EFinished )
+        {
+        User::Leave( KErrEof );
+        }
+
+    // move to the next item
+    ++iCurrentNodeIndex;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/src/socketsreader.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,104 @@
+/*
+* 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:  Reads from socket.
+*
+*/
+
+
+// INCLUDE FILES
+#include "BtSerialEngine.pan"
+#include "SocketsReader.h"
+#include "SocketObserver.h"
+
+// -----------------------------------------------------------------------------
+CSocketsReader* CSocketsReader::NewL( MSocketObserver& aEngineNotifier,
+                                      RSocket& aSocket )
+    {
+    CSocketsReader* self = new ( ELeave ) CSocketsReader( aEngineNotifier,
+                                                          aSocket );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+CSocketsReader::CSocketsReader( MSocketObserver& aObserver,
+                                RSocket& aSocket )
+: CActive( EPriorityStandard ),
+  iSocket( aSocket ),
+  iObserver( aObserver )
+    {
+    // No implementation required
+    }
+
+// -----------------------------------------------------------------------------
+void CSocketsReader::ConstructL()
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// -----------------------------------------------------------------------------
+CSocketsReader::~CSocketsReader()
+    {
+    Cancel();
+    }
+
+// -----------------------------------------------------------------------------
+void CSocketsReader::DoCancel()
+    {
+    // Cancel asychronous read request
+    iSocket.CancelRead();
+    }
+
+// -----------------------------------------------------------------------------
+void CSocketsReader::RunL()
+    {
+    switch ( iStatus.Int() )
+        {
+        case KErrNone:
+            iObserver.NewData(iBuffer);
+//            IssueRead(); // Immediately start another read
+            break;
+        case KErrDisconnected:
+            iObserver.ReportError( MSocketObserver::EDisconnected,
+                                   iStatus.Int() );
+            break;
+        default:
+            iObserver.ReportError( MSocketObserver::EGeneralReadError,
+                                   iStatus.Int() );
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+void CSocketsReader::IssueRead()
+    {
+    // Initiate a new read from socket into iBuffer
+    __ASSERT_ALWAYS( !IsActive(), Panic(EBTSerialEngineReadSocketBadState) );
+    iSocket.RecvOneOrMore( iBuffer, 0, iStatus, iLen );
+    SetActive();
+    }
+
+// -----------------------------------------------------------------------------
+void CSocketsReader::ReadAsync()
+    {
+    // Initiate a new read from socket into iBuffer
+    if (!IsActive())
+        {
+        IssueRead();
+        }
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/src/socketswriter.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,171 @@
+/*
+* 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:  Writes to socket.
+*
+*/
+
+
+// INCLUDE FILES
+#include "SocketsWriter.h"
+#include "TimeOutTimer.h"
+#include "BtSerialEngine.pan"
+#include "SocketObserver.h"
+#include "HtiBtEngineLogging.h"
+
+// STATIC MEMBER INITIALISATIONS
+const TInt KTimeOut = 10 * 1000 * 1000; // 10 seconds time-out
+
+// ========================= MEMBER FUNCTIONS ==================================
+
+// -----------------------------------------------------------------------------
+CSocketsWriter* CSocketsWriter::NewL( MSocketObserver& aEngineNotifier,
+                                      RSocket& aSocket )
+    {
+    CSocketsWriter* self = new ( ELeave ) CSocketsWriter( aEngineNotifier,
+                                                          aSocket );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+CSocketsWriter::CSocketsWriter( MSocketObserver& aEngineNotifier,
+                                RSocket& aSocket )
+: CActive( EPriorityStandard ),
+  iSocket( aSocket ),
+  iObserver( aEngineNotifier )
+    {
+    // No implementation required
+    }
+
+// -----------------------------------------------------------------------------
+void CSocketsWriter::ConstructL()
+    {
+    CActiveScheduler::Add( this );
+    iTimeOut = KTimeOut;
+    iTimer = CTimeOutTimer::NewL( CActive::EPriorityUserInput, *this );
+    iWriteStatus = EIdle;
+    }
+
+// -----------------------------------------------------------------------------
+CSocketsWriter::~CSocketsWriter()
+    {
+    CancelSending();
+    delete iTimer;
+    }
+
+// -----------------------------------------------------------------------------
+void CSocketsWriter::DoCancel()
+    {
+    // Cancel asychronous write request
+    iSocket.CancelWrite();
+    iTimer->Cancel();
+    iWriteStatus = EIdle;
+    }
+
+// -----------------------------------------------------------------------------
+void CSocketsWriter::RunL()
+    {
+    iTimer->Cancel();
+
+    // Active object request complete handler
+    if ( iStatus == KErrNone )
+        {
+        switch ( iWriteStatus )
+            {
+            // Character has been written to socket
+            case ESending:
+                SendNextPacket();
+                break;
+            default:
+                LOGFMT_E( "CSocketsWriter: Bad write status: %d", iWriteStatus )
+                Panic( EBTSerialEngineWriteSocketBadState );
+                break;
+            };
+        }
+    else
+        {
+        iWriteStatus = EIdle;
+        iWriteBuffer.Zero();
+        iTransferBuffer.Zero();
+        iObserver.ReportError( MSocketObserver::EGeneralWriteError,
+                                     iStatus.Int() );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+void CSocketsWriter::TimerExpired()
+    {
+    Cancel();
+    iWriteStatus = EIdle;
+    iObserver.ReportError( MSocketObserver::ETimeOutOnWrite,
+                                 KErrTimedOut );
+    }
+
+// -----------------------------------------------------------------------------
+void CSocketsWriter::SendL(const TDesC8& aData)
+    {
+    if ( aData.Length() > FreeSpaceInSendBuffer() )
+        User::Leave( KErrOverflow );
+
+    iTransferBuffer.Append( aData );
+    SendNextPacket();
+    }
+
+// -----------------------------------------------------------------------------
+TInt CSocketsWriter::FreeSpaceInSendBuffer()
+    {
+    return iTransferBuffer.MaxSize() - iTransferBuffer.Size();
+    }
+
+// -----------------------------------------------------------------------------
+TInt CSocketsWriter::SendBufferMaxSize()
+    {
+    return iTransferBuffer.MaxLength();
+    }
+
+// -----------------------------------------------------------------------------
+void CSocketsWriter::SendNextPacket()
+    {
+    if ( IsActive() )
+        {
+        return; // already sending
+        }
+    if ( iTransferBuffer.Length() > 0 )
+        {
+        // Move data from transfer buffer to actual write buffer
+        iWriteBuffer.Copy(iTransferBuffer.Left(iWriteBuffer.MaxLength()));
+        iTransferBuffer.Delete(0, iWriteBuffer.MaxLength());
+        iSocket.Write( iWriteBuffer, iStatus ); // Initiate actual write
+
+        iWriteStatus = ESending;
+        iTimer->After( iTimeOut );
+        SetActive();
+        }
+    else
+        {
+        iWriteStatus = EIdle;
+        iObserver.AllBufferedDataSent();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+void CSocketsWriter::CancelSending()
+    {
+    Cancel();
+    iWriteBuffer.Zero();
+    iTransferBuffer.Zero();
+    }
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/src/timeouttimer.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,71 @@
+/*
+* 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:  Timer.
+*
+*/
+
+
+// INCLUDE FILES
+#include "TimeOutTimer.h"
+#include "TimeOutNotifier.h"
+#include "HtiBtEngineLogging.h"
+
+// -----------------------------------------------------------------------------
+CTimeOutTimer* CTimeOutTimer::NewL( const TInt aPriority,
+                                    MTimeOutNotifier& aTimeOutNotify )
+    {
+    CTimeOutTimer* self = new ( ELeave ) CTimeOutTimer( aPriority,
+                                                        aTimeOutNotify );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+CTimeOutTimer::CTimeOutTimer( const TInt aPriority,
+                              MTimeOutNotifier& aObserver )
+: CTimer( aPriority ), iObserver( aObserver )
+    {
+    // No implementation required
+    }
+
+// -----------------------------------------------------------------------------
+void CTimeOutTimer::ConstructL()
+    {
+    CTimer::ConstructL();
+    CActiveScheduler::Add( this );
+    }
+
+// -----------------------------------------------------------------------------
+CTimeOutTimer::~CTimeOutTimer()
+    {
+    // No implementation required
+    }
+
+// -----------------------------------------------------------------------------
+void CTimeOutTimer::RunL()
+    {
+    // Timer request has completed, so notify the timer's owner
+    if ( iStatus == KErrNone )
+        {
+        iObserver.TimerExpired();
+        }
+    else
+        {
+        LOGFMT_E("CTimeOutTimer: bad completion code: %d", iStatus.Int())
+        }
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommEcomPlugin/data/200212CB.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  Resource definitions for HtiBtComm ECOM plugin.
+*
+*/
+
+
+// INCLUDES
+#include <ecom/registryinfo.rh>
+
+
+//  RESOURCE DEFINITIONS
+RESOURCE REGISTRY_INFO theInfo
+    {
+    // UID for the DLL
+    dll_uid = 0x200212CB;
+    // Declare array of interface info
+    interfaces =
+        {
+        INTERFACE_INFO
+            {
+            // UID of interface that is implemented
+            interface_uid = 0x1020DEB8;
+            implementations =
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = 0x200212CC;
+                    version_no         = 1;
+                    display_name       = "Bt serial comm";
+                    default_data       = "BTSERIAL";
+                    opaque_data        = "";
+                    }
+                };
+            }
+        };
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommEcomPlugin/inc/HtiBtCommEcomPlugin.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,137 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ECOM plugin to communicate over BT serial port
+*
+*/
+
+
+#ifndef CHTIBTCOMMECOMPLUGIN_H
+#define CHTIBTCOMMECOMPLUGIN_H
+
+class CBtSerialClient;
+
+// INCLUDES
+#include <c32comm.h>
+#include <HTICommPluginInterface.h> // defined in HtiFramework project
+
+#include "HtiBtCommInterface.h" // RHtiBtCommInterface
+
+// FORWARD DECLARATIONS
+class CHtiCfg;
+
+// CLASS DECLARATION
+/**
+* ECOM plugin module for communicating with PC using serial port.
+*
+*/
+class CHtiBtCommEcomPlugin :
+    public CHTICommPluginInterface
+    {
+public:
+
+    /**
+    * Create instance of plugin.
+    * @return Connected plugin instance.
+    */
+    static CHtiBtCommEcomPlugin* NewL();
+
+    /**
+    * Destructor
+    */
+    ~CHtiBtCommEcomPlugin();
+
+public: // CHTICommPluginInterface interface implementation
+
+    /**
+    * Receive data from Bluetooth.
+    * The size of supplied buffer must equal to size given by GetBufferSize.
+    * The number of received bytes may be anything between 1 and GetBufferSize.
+    *
+    * @param aRawdataBuf Buffer where the result is written
+    * @param aStatus Request status
+    */
+    void Receive( TDes8& aRawdataBuf, TRequestStatus& aStatus );
+
+    /**
+    * Send data to Bluetooth. The size of data must not exceed GetBufferSize.
+    * @param aRawdataBuf Buffer where the data is read from.
+    * @param aStatus Request status
+    */
+    void Send( const TDesC8& aRawdataBuf, TRequestStatus& aStatus );
+
+    /**
+    * Cancel read operation
+    */
+    void CancelReceive();
+
+    /**
+    * Cancel send operation
+    */
+    void CancelSend();
+
+    /**
+     *  Return required buffer size for Send operation.
+     */
+    TInt GetSendBufferSize();
+
+    /**
+     *  Return required buffer size for Receive operation.
+     */
+    TInt GetReceiveBufferSize();
+
+private:
+
+    /**
+    * Constructor of this plugin.
+    */
+    CHtiBtCommEcomPlugin();
+
+    /**
+    * Second phase construction. Connects the Bluetooth.
+    */
+    void ConstructL();
+
+    /**
+    * Load configuration file.
+    */
+    void LoadConfigL();
+
+    /**
+    * Read and parse the configuration values.
+    */
+    void ReadConfig();
+
+    /**
+     * Parse the possible port (channel) number value from name or address param
+     */
+     TInt ParsePortNumber();
+
+     /**
+     * StorePortNumberL()
+     * Store the given port number to configuration file
+     * @param aPortNumber the port number to store
+     */
+     void StorePortNumberL( TInt aPortNumber );
+
+private: // Data
+
+    RHtiBtCommInterface iBtCommInterface;
+
+    CHtiCfg* iCfg;
+    HBufC8*  iBtDeviceNameOrAddress;
+    TInt     iPort;
+
+    };
+
+#endif // CHTIBTCOMMECOMPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommEcomPlugin/src/HtiBtCommEcomPlugin.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,277 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ECOM plugin for communication over serial port
+*
+*/
+
+
+// INCLUDE FILES
+#include <badesca.h>
+#include <f32file.h>
+
+#include "HtiBtCommEcomPlugin.h"
+#include "BtSerialClient.h"
+#include <hticfg.h>
+#include <htilogging.h>
+
+// CONSTANTS
+_LIT( KHtiCfgPath,       "\\" ); // root of drive
+_LIT( KHtiBtCommCfg,     "HTIBtComm.cfg" );
+_LIT8( KBtDeviceAddress, "BtDeviceAddress" );
+_LIT8( KBtDeviceName,    "BtDeviceName" );
+
+
+const TInt KBtAddressHexStringLength = 12; // 6 bytes
+const TUint KPortSeparatorChar = 30; // ASCII control char "record separator"
+
+// ----------------------------------------------------------------------------
+CHtiBtCommEcomPlugin* CHtiBtCommEcomPlugin::NewL()
+    {
+    HTI_LOG_FUNC_IN( "CHtiBtCommEcomPlugin::NewL" );
+    CHtiBtCommEcomPlugin* plugin = new (ELeave) CHtiBtCommEcomPlugin();
+    CleanupStack::PushL( plugin );
+    plugin->ConstructL();
+    CleanupStack::Pop( plugin );
+    HTI_LOG_FUNC_OUT( "CHtiBtCommEcomPlugin::NewL" );
+    return plugin;
+    }
+
+// ----------------------------------------------------------------------------
+CHtiBtCommEcomPlugin::~CHtiBtCommEcomPlugin()
+    {
+    HTI_LOG_FUNC_IN( "CHtiBtCommEcomPlugin::~CHtiBtCommEcomPlugin" );
+    iBtCommInterface.CancelReceive();
+    iBtCommInterface.CancelSend();
+    iBtCommInterface.Close();
+    delete iBtDeviceNameOrAddress;
+    delete iCfg;
+    HTI_LOG_FUNC_OUT( "CHtiBtCommEcomPlugin::~CHtiBtCommEcomPlugin" );
+    }
+
+// ----------------------------------------------------------------------------
+CHtiBtCommEcomPlugin::CHtiBtCommEcomPlugin():iPort( -1 )
+    {
+    }
+
+// ----------------------------------------------------------------------------
+void CHtiBtCommEcomPlugin::ConstructL()
+    {
+    TRAPD( err, LoadConfigL() );
+    if ( err == KErrNone )
+        {
+        ReadConfig();
+        }
+    else
+        {
+        TBufC8<1> emptyBuf( KNullDesC8 );
+        iBtDeviceNameOrAddress = emptyBuf.AllocL();
+        iPort = KErrNotFound;
+        }
+     // May take long!
+    User::LeaveIfError( iBtCommInterface.Connect(
+            *iBtDeviceNameOrAddress, iPort ) );
+
+    // Get the connected service port number (channel) and store it if needed
+    TInt connectedPort = iBtCommInterface.GetPortNumber();
+    HTI_LOG_FORMAT( "Connected port number = %d", connectedPort );
+    if ( connectedPort != iPort && connectedPort >= 0 )
+        {
+        TRAP( err, StorePortNumberL( connectedPort ) ); // ignore error
+        }
+    }
+
+// ----------------------------------------------------------------------------
+void CHtiBtCommEcomPlugin::Receive( TDes8& aRawdataBuf,
+                                    TRequestStatus& aStatus )
+    {
+    iBtCommInterface.Receive( aRawdataBuf, aStatus );
+    }
+
+// ----------------------------------------------------------------------------
+void CHtiBtCommEcomPlugin::Send( const TDesC8& aRawdataBuf,
+                                       TRequestStatus& aStatus )
+    {
+    iBtCommInterface.Send( aRawdataBuf, aStatus );
+    }
+
+// ----------------------------------------------------------------------------
+void CHtiBtCommEcomPlugin::CancelReceive()
+    {
+    iBtCommInterface.CancelReceive();
+    }
+
+// ----------------------------------------------------------------------------
+void CHtiBtCommEcomPlugin::CancelSend()
+    {
+    iBtCommInterface.CancelSend();
+    }
+
+// ----------------------------------------------------------------------------
+TInt CHtiBtCommEcomPlugin::GetSendBufferSize()
+    {
+    return iBtCommInterface.GetSendBufferSize();
+    }
+
+// ----------------------------------------------------------------------------
+TInt CHtiBtCommEcomPlugin::GetReceiveBufferSize()
+    {
+    return iBtCommInterface.GetReceiveBufferSize();
+    }
+
+// ----------------------------------------------------------------------------
+void CHtiBtCommEcomPlugin::LoadConfigL()
+    {
+    HTI_LOG_FUNC_IN( "CHtiBtCommEcomPlugin::LoadConfigL" );
+    iCfg = CHtiCfg::NewL();
+    iCfg->LoadCfgL( KHtiCfgPath, KHtiBtCommCfg );
+    HTI_LOG_TEXT( "cfg file loaded" );
+    HTI_LOG_FUNC_OUT( "CHtiBtCommEcomPlugin::LoadConfigL" );
+    }
+
+// ----------------------------------------------------------------------------
+void CHtiBtCommEcomPlugin::ReadConfig()
+    {
+    HTI_LOG_FUNC_IN( "CHtiBtCommEcomPlugin::ReadConfig" );
+    // First try to get address - if found and length is correct it is used
+    TRAPD( paramErr, iBtDeviceNameOrAddress = iCfg->GetParameterL(
+                                                KBtDeviceAddress ).AllocL() );
+
+    if ( paramErr == KErrNone )
+        {
+        TInt port = ParsePortNumber();
+        if ( port >= 0 ) iPort = port;
+        else iPort = KErrNotFound;
+        }
+
+    if ( paramErr ||
+         iBtDeviceNameOrAddress->Length() != KBtAddressHexStringLength )
+        {
+        HTI_LOG_TEXT( "BT address not defined or not valid - getting name" );
+        delete iBtDeviceNameOrAddress;
+        iBtDeviceNameOrAddress = NULL;
+        // Address was not found - try to get name.
+        TRAP( paramErr, iBtDeviceNameOrAddress = iCfg->GetParameterL(
+                                                 KBtDeviceName ).AllocL() );
+        if ( paramErr )
+            {
+            HTI_LOG_TEXT( "BT name not defined either" );
+            TBufC8<1> emptyBuf( KNullDesC8 );
+            iBtDeviceNameOrAddress = emptyBuf.AllocL();
+            iPort = KErrNotFound;
+            }
+        else
+            {
+            TInt port = ParsePortNumber();
+            if ( port >= 0 ) iPort = port;
+            else iPort = KErrNotFound;
+            }
+        }
+    HTI_LOG_TEXT( "BT device name or address:" );
+    HTI_LOG_DES( *iBtDeviceNameOrAddress );
+    HTI_LOG_FORMAT( "Port number: %d", iPort );
+    HTI_LOG_FUNC_OUT( "CHtiBtCommEcomPlugin::ReadConfig" );
+    }
+
+// ----------------------------------------------------------------------------
+TInt CHtiBtCommEcomPlugin::ParsePortNumber()
+    {
+    HTI_LOG_FUNC_IN( "CHtiBtCommEcomPlugin::ParsePortNumber" );
+    TInt port = KErrNotFound;
+    TInt separatorIndex = iBtDeviceNameOrAddress->LocateReverse(
+            TChar( KPortSeparatorChar ) );
+    if ( separatorIndex != KErrNotFound )
+        {
+        TPtrC8 value = iBtDeviceNameOrAddress->Right(
+                iBtDeviceNameOrAddress->Length() - ( separatorIndex + 1 ) );
+        TLex8 lex( value );
+        lex.Val( port );
+        // Strip away the port number
+        iBtDeviceNameOrAddress->Des().SetLength( separatorIndex );
+        }
+    HTI_LOG_FORMAT( "ParsePortNumber returning %d", port );
+    HTI_LOG_FUNC_OUT( "CHtiBtCommEcomPlugin::ParsePortNumber" );
+    return port;
+    }
+
+// ----------------------------------------------------------------------------
+void CHtiBtCommEcomPlugin::StorePortNumberL( TInt aPortNumber )
+    {
+    HTI_LOG_FUNC_IN( "CHtiBtCommEcomPlugin::StorePortNumberL" );
+    if ( !iCfg )
+        {
+        iCfg = CHtiCfg::NewL();
+        }
+    iCfg->LoadCfgL( KHtiCfgPath, KHtiBtCommCfg );
+
+    TBool changesMade = EFalse;
+
+    // Add or replace port number to address parameter if it exists
+    HBufC8* value = NULL;
+    TRAPD( err, value = iCfg->GetParameterL( KBtDeviceAddress ).AllocL() );
+    if ( !err )
+        {
+        HTI_LOG_FORMAT( "Found address param (length = %d)", value->Length() );
+        CleanupStack::PushL( value );
+        TInt separatorIndex = value->Locate( TChar( KPortSeparatorChar ) );
+        if ( separatorIndex != KErrNotFound )
+            {
+            HTI_LOG_FORMAT( "Separator char found from index %d", separatorIndex );
+            value->Des().SetLength( separatorIndex );
+            }
+        value = value->ReAllocL( value->Length() + 5 );
+        // The old value has been deleted by ReAllocL and new allocated,
+        // so update cleanup stack.
+        CleanupStack::Pop();
+        CleanupStack::PushL( value );
+        TPtr8 ptr = value->Des();
+        ptr.Append( TChar( KPortSeparatorChar ) );
+        ptr.AppendNum( aPortNumber );
+        TRAP( err, iCfg->SetParameterL( KBtDeviceAddress, *value ) );
+        if ( !err ) changesMade = ETrue;
+        CleanupStack::PopAndDestroy(); // value
+        }
+
+    // Add or replace port number to name parameter if it exists
+    TRAP( err, value = iCfg->GetParameterL( KBtDeviceName ).AllocL() );
+    if ( !err )
+        {
+        HTI_LOG_FORMAT( "Found name param (length = %d)", value->Length() );
+        CleanupStack::PushL( value );
+        TInt separatorIndex = value->Locate( TChar( KPortSeparatorChar ) );
+        if ( separatorIndex != KErrNotFound )
+            {
+            HTI_LOG_FORMAT( "Separator char found from index %d", separatorIndex );
+            value->Des().SetLength( separatorIndex );
+            }
+        value = value->ReAllocL( value->Length() + 5 );
+        // The old value has been deleted by ReAllocL and new allocated,
+        // so update cleanup stack.
+        CleanupStack::Pop();
+        CleanupStack::PushL( value );
+        TPtr8 ptr = value->Des();
+        ptr.Append( TChar( KPortSeparatorChar ) );
+        ptr.AppendNum( aPortNumber );
+        TRAP( err, iCfg->SetParameterL( KBtDeviceName, *value ) );
+        if ( !err ) changesMade = ETrue;
+        CleanupStack::PopAndDestroy(); // value
+        }
+
+    if ( changesMade )
+        {
+        iCfg->SaveCfgL( KHtiCfgPath, KHtiBtCommCfg );
+        }
+    HTI_LOG_FUNC_OUT( "CHtiBtCommEcomPlugin::StorePortNumberL" );
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommEcomPlugin/src/proxy.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ECOM implementations in this dll
+*
+*/
+
+
+// INCLUDE FILES
+#include "HtiBtCommEcomPlugin.h"
+
+#include <e32std.h>
+#include <ecom/implementationproxy.h>
+
+
+/*---------------------------------------------------------------------------*/
+// Provides a key value pair table, this is used to identify
+// the correct construction function for the requested interface.
+const TImplementationProxy ImplementationTable[] =
+    {
+        IMPLEMENTATION_PROXY_ENTRY( 0x200212CC,  CHtiBtCommEcomPlugin::NewL )
+    };
+
+/*---------------------------------------------------------------------------*/
+// Function used to return an instance of the proxy table.
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    return ImplementationTable;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommServer/inc/HtiBtClientServerCommon.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,62 @@
+/*
+* 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:  Global definitions for BtCommServer and client side interface.
+*
+*/
+
+
+#ifndef __HTIBTCLIENTSERVERCOMMON_H__
+#define __HTIBTCLIENTSERVERCOMMON_H__
+
+//  INCLUDES
+#include <e32base.h>
+
+// CONSTANTS
+
+// The server name (and server thread name)
+_LIT( KBtCommServerName,"HtiBtCommServer" );
+
+// The version of the server
+const TUint KBtCommServerMajorVersionNumber = 1;
+const TUint KBtCommServerMinorVersionNumber = 0;
+const TUint KBtCommServerBuildVersionNumber = 0;
+
+const TInt KClientReceiveBufferMaxSize = 0x1000; // 4096 bytes
+const TInt KClientSendBufferMaxSize = 0x1000; // 4096 bytes
+
+
+// DATA TYPES
+
+// The message ID's of BtCommServer
+// from Symbian side
+enum TBtCommServerRqst
+    {
+    EBtCommServerConnect = 0,
+    EBtCommServerRecv,
+    EBtCommServerSend,
+    ECancelBtCommServerRecv,
+    ECancelBtCommServerSend,
+    EGetServicePortNumber
+    };
+
+
+// FUNCTION PROTOTYPES
+/**
+* Start HtiBtCommServer thread. This is called by client interface.
+*/
+IMPORT_C TInt StartThread();
+
+#endif // __HTIBTCLIENTSERVERCOMMON_H__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommServer/inc/HtiBtCommInterface.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,149 @@
+/*
+* 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:  Client side interface to HtiBtCommServer
+*
+*/
+
+
+#ifndef __HTIBTCOMMINTERFACE_H__
+#define __HTIBTCOMMINTERFACE_H__
+
+//  INCLUDES
+#include <e32test.h>
+#include <e32base.h>
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+ * Remote interface to HtiBtCommServer.
+ * HtiBtCommServer runs in separate thread, but always within the
+ * client process.
+ *
+ * The thread is started and session to server created, when the
+ * Connect is called for the first time.
+ *
+ * Server allows only one connection (session) at a time.
+ *
+ * Library: htibtcomminterface.lib
+ */
+class RHtiBtCommInterface : public RSessionBase
+    {
+    public: // Constructor and destructor
+
+        /**
+        * C++ default constructor.
+        */
+        IMPORT_C RHtiBtCommInterface();
+
+    public:
+        /**
+        * Connects and creates session to BtCommServer. Additionally,
+        * connects to remote BT device. This may take a while
+        * and may require user interaction (device selection).
+        *
+        * If the server is not running within this process, it is
+        * started in a new thread. Note that server allows only one
+        * connection (session).
+        * @return Error code
+        */
+        IMPORT_C TInt Connect( TDesC8& aDeviceNameOrAddress, TInt aPort );
+
+        /**
+        * Close the session to server and wait for servers death.
+        * Will disconnect the server from remote BT host, if connected.
+        */
+        IMPORT_C void Close();
+
+        /**
+        * Returns server version
+        * @return Version
+        */
+        IMPORT_C TVersion Version() const;
+
+        /**
+         *  Return required buffer max size for Send operation.
+         */
+        IMPORT_C TInt GetSendBufferSize() const;
+
+        /**
+         *  Return required buffer max size for Receive operation.
+         */
+        IMPORT_C TInt GetReceiveBufferSize() const;
+
+        /**
+        * Receives data from BtCommServer.
+        * Note: The aData buffer size must equal to GetReceiveBufferSize().
+        * (server will write 1 to GetReceiveBufferSize bytes to the buffer).
+        * @param aData Descriptor where data is received
+        * @param aStatus Asynchronous request status
+        */
+        IMPORT_C void Receive( TDes8& aData,
+                           TRequestStatus& aStatus );
+
+        /**
+        * Sends data to BtCommServer.
+        * Note: The aData buffer size must equal to GetSendBufferSize().
+        * (server will read as much as there is data in aData. There must
+        * never be more data than GetSendBufferSize. This is important to notice,
+        * if HBufC is used, because its actual max size can be greater than
+        * initially suggested in its construction)
+        *
+        * @param aData Data to be sent
+        * @param aStatus Asynchronous request status
+        */
+        IMPORT_C void Send( const TDesC8& aData,
+                           TRequestStatus& aStatus );
+
+
+        /**
+        * Cancels pending Receive request on server.
+        */
+        IMPORT_C void CancelReceive();
+
+        /**
+        * Cancels pending Send request on server.
+        */
+        IMPORT_C void CancelSend();
+
+        /**
+        * Gets the port number of the remote service where the server is
+        * connected.
+        * @return Port number or KErrDisconnected if server is not connected
+        */
+         IMPORT_C TInt GetPortNumber() const;
+
+    private:
+
+        /**
+        * During Connect(), connect the server
+        * to remote BT host service.
+        */
+        TInt RHtiBtCommInterface::ConnectBt( TDesC8& aDeviceNameOrAddress,
+                                             TInt aPort );
+
+};
+
+#endif // __HTIBTCOMMINTERFACE_H__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommServer/inc/HtiBtCommServer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,136 @@
+/*
+* 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:  CHtiBtCommServer declaration
+*
+*/
+
+
+#ifndef __HTIBTCOMMSERVER_H__
+#define __HTIBTCOMMSERVER_H__
+
+//  INCLUDES
+
+#include <e32def.h>
+#include <e32base.h>
+
+//  CONSTANTS
+
+// Reasons for BtCommServer panic
+enum TBtCommServerPanic
+    {
+    EBadRequest,
+    EBadDescriptor,
+    EMainSchedulerError,
+    ESvrCreateServer,
+    ESvrStartServer,
+    ECreateTrapCleanup,
+    ENotImplementedYet,
+    EFailedToInitMessageBox,
+    EFailedToOpenBTconnection,
+    EFailedToOpenPhonetChannel,
+    EFailedToRecPhonetMsg,
+    EFailedToSendPhonetMsg,
+    ETooManyAsyncRequests
+    };
+
+//  FUNCTION PROTOTYPES
+
+// Function to panic the server
+GLREF_C void PanicServer( TBtCommServerPanic aPanic );
+
+// Thread function for server
+GLREF_C TInt BtCommServerThread( TAny * );
+
+//  FORWARD DECLARATIONS
+class CHtiBtCommServerSession;
+class CHtiBtReaderWriter;
+
+// CLASS DECLARATION
+
+/**
+* Server class for BT communication.
+*/
+class CHtiBtCommServer : public CServer2
+    {
+
+    private: // Constructors and destructor
+       /**
+        * C++ default constructor.
+        */
+        CHtiBtCommServer( TInt aPriority );
+
+       /**
+        * Second Phase constructor
+        */
+        void ConstructL();
+
+    public:
+       /**
+        * Symbian Two-phased constructor.
+        */
+        static CHtiBtCommServer* NewL();
+
+       /**
+        * Destructor.
+        */
+        ~CHtiBtCommServer();
+
+    public: // callbacks from session
+
+        /**
+        * Session was deleted notification.
+        * Session notifies server, when client is disconnecting
+        * and session is being deleted. Server will start shutdown.
+        */
+        void SessionFreed();
+
+        /**
+        * Session was created notification.
+        * @param aSession Session, which is notifying server of its creation.
+        */
+        void SessionCreated( CHtiBtCommServerSession* aSession );
+
+    public:
+       /**
+        * Creates a new client session
+        * @param aVersion Version of the server
+        * @param aMessage Client message
+        * @return Pointer to the client session
+        */
+        virtual CSession2* NewSessionL( const TVersion& aVersion,
+            const RMessage2& aMessage ) const;
+
+       /**
+        * Creates server thread
+        * @param aStarted semaphore
+        * @return Error code
+        */
+        static TInt ThreadFunction( TAny* aStarted );
+
+public: // Data
+    // Priority of the server
+    enum TBtServPriority
+        {
+        EBtCommServerPriority = 100
+        };
+
+private:
+
+    CHtiBtCommServerSession* iSession; // Not owned. Only one session allowed!
+
+    };
+
+#endif // __HTIBTCOMMSERVER_H__
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommServer/inc/HtiBtCommServerSession.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,154 @@
+/*
+* 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:  Server side session in HtiBtCommServer.
+*
+*/
+
+
+#ifndef CHTIBTCOMMSERVERSESSION_H
+#define CHTIBTCOMMSERVERSESSION_H
+
+//  INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+
+#include "BtSerialClient.h" // MBtSerialClientObserver
+
+// FORWARD DECLARATIONS
+
+class CHtiBtCommServer;
+
+// CLASS DECLARATION
+
+/**
+* This class represents a client session in the server.
+*
+* Server owns one instance of session (meaning only one client session
+* is allowed for this server).
+* Session allows only one outstanding read request and write request at a time.
+* Read request and write request may be outstanding simultaneously.
+*/
+class CHtiBtCommServerSession :
+    public CSession2,
+    public MBtSerialClientObserver
+    {
+public:
+
+   /**
+    * Two phase constructor.
+    *
+    * @param aServer Pointer to the server instance
+    */
+    static CHtiBtCommServerSession* NewL( CHtiBtCommServer* aServer );
+
+private: // Construction
+
+   /**
+    * C++ default constructor.
+    *
+    * @param aClient
+    * @param aServer
+    */
+    CHtiBtCommServerSession( CHtiBtCommServer* aServer );
+
+    /**
+     * Second phase construction.
+     */
+    void ConstructL();
+
+   /**
+    * Destructor.
+    */
+    ~CHtiBtCommServerSession();
+
+private: // From MBtSerialClientObserver
+
+    void ConnectedToServer(TInt aError);
+    void DisconnectedFromServer();
+    void DataFromServer(const TDesC8& aData);
+    void AllBufferedDataSent();
+
+private:
+
+    /**
+    * Handle client request. This is invoced by client server framework.
+    * @param aMessage Message object describing client request
+    */
+    virtual void ServiceL(const RMessage2 &aMessage);
+
+    /**
+    * Determine client request type and delegate handling accordingly.
+    * @param aMessage Message object describing client request
+    */
+    void DispatchMessageL(const RMessage2 &aMessage);
+
+    void HandleConnectRequestL(const RMessage2& aMessage);
+
+    /**
+    * Handle client's send request.
+    * Copies data from client address space to internal send buffer and starts
+    * sending it.
+    * @param aMessage Message object describing client request
+    */
+    void HandleSendRequestL(const RMessage2& aMessage);
+
+    /**
+    * Handle client's read request.
+    * Wait for incoming data. Once received, copy its data to client's
+    * address space and complete client's request.
+    * @param aMessage Message object describing client request
+    */
+    void HandleReadRequestL(const RMessage2& aMessage);
+
+    /**
+    * Handle client's cancel requests.
+    * Cancel either read or write operation depending on client request.
+    * @param aMessage Message object describing client request
+    */
+    void HandleCancelRequestL(const RMessage2& aMessage);
+
+    /**
+     * Handle port number request
+     * Write the port number of the currently connected service. If not
+     * connected writes KErrDisconnected.
+     */
+    void HandlePortNumberRequestL(const RMessage2& aMessage);
+
+private: // Helpers
+
+    void PanicClient(TInt aPanic) const;
+    void ResetAll(TInt aCompletionCode);
+    void TryCompleteReadRequest();
+
+private: // Data
+
+    CHtiBtCommServer *iBtCommServer; // referenced
+
+    RMessage2 iReadRequest;
+    RMessage2 iWriteRequest;
+    RMessage2 iConnectRequest;
+    TBool iWriteRequestComplete; // ETrue: no previous pending write request
+    TBool iReadRequestComplete; // ETrue: no previous pending read request
+    TBool iConnectRequestComplete;
+
+    CBtSerialClient* iBtClient;
+
+    HBufC8* iIncomingDataBuf; // Coming from remote host
+    HBufC8* iSendBuffer;      // Sent to remote host
+
+    };
+
+#endif // CHTIBTCOMMSERVERSESSION_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommServer/inc/Logger.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  Logger library
+*
+*/
+
+
+#ifndef __LOGGER_H_____
+#define __LOGGER_H_____
+
+//  INCLUDES
+#include <e32std.h>
+
+// CONSTANTS
+const TInt KLogLevelDebug   = 0;
+const TInt KLogLevelInfo    = 10;
+const TInt KLogLevelWarning = 20;
+const TInt KLogLevelError   = 30;
+
+const TInt KMinimumLogLevel = KLogLevelInfo;
+
+
+// When __ENABLE_LOGGING__ macro is defined, logging functions are
+// compiled to final build.
+//
+// Example usage: LOGFW(DebugLog(_L("Got an error %d"), 5))
+//
+#ifdef __ENABLE_LOGGING__
+
+    #define LOGFW(a) a;
+
+    _LIT(KLogFileName, "c:\\HTI_BtComm.log");
+
+    // panics
+    _LIT(KLogPanicCategory, "CustNotifyLog");
+    static const TInt KPanicFsConnectFailed = 1;
+    static const TInt KPanicFileCreateFailed = 2;
+    static const TInt KPanicFileWriteFailed = 3;
+
+    const TInt KLogEntryMaxLength = 156;
+
+    // Usage example: DOLOG(_L("Logstring"));
+    void DebugLog(TRefByValue<const TDesC> aFmt,...);
+    void InfoLog(TRefByValue<const TDesC> aFmt,...);
+    void WarnLog(TRefByValue<const TDesC> aFmt,...);
+    void ErrLog(TRefByValue<const TDesC> aFmt,...);
+
+    void Log(TInt aLevel, TRefByValue<const TDesC> aFmt, VA_LIST list);
+
+    void LogBytes(const TDesC8& aData, TInt aMaxBytesToLog );
+
+#else  //__ENABLE_LOGGING__
+
+    #define LOGFW(a)
+
+#endif //__ENABLE_LOGGING__
+
+#endif //__LOGGER_H_____
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommServer/src/HtiBtCommInterface.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,188 @@
+/*
+* 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: Implementation of RHtiBtCommInterface class.
+*              Symbian side component uses this interface to receive and
+*              send HTI data to HtiBtCommServer.
+*              HtiBtCommServer acts as proxy to send and receive data
+*              to and from PC.
+*
+*/
+
+
+// INCLUDE FILES
+#include "HtiBtClientServerCommon.h"
+#include "HtiBtCommInterface.h"
+
+#include <e32uid.h>
+#include <HTILogging.h>
+
+// CONSTANTS
+const TUint KBtCommServerDefaultMessageSlots = 4; // Read, write, readCancel, writeCancel
+
+// Constants
+
+/*---------------------------------------------------------------------------*/
+EXPORT_C RHtiBtCommInterface::RHtiBtCommInterface()
+    {
+    HTI_LOG_TEXT( "RHtiBtCommInterface::RHtiBtCommInterface()" );
+    }
+
+/*---------------------------------------------------------------------------*/
+EXPORT_C TInt RHtiBtCommInterface::Connect( TDesC8& aDeviceNameOrAddress,
+                                            TInt aPort )
+    {
+    HTI_LOG_TEXT( "RHtiBtCommInterface::Connect()" );
+
+    TInt error = StartThread(); // see HtiBtClientServerCommon.h
+    if (error == KErrNone)
+        {
+        error = CreateSession( KBtCommServerName,
+                               Version(),
+                               KBtCommServerDefaultMessageSlots );
+        }
+    if ( error )
+        return error;
+
+    return ConnectBt( aDeviceNameOrAddress, aPort );
+    }
+
+/*---------------------------------------------------------------------------*/
+EXPORT_C void RHtiBtCommInterface::Close()
+    {
+    HTI_LOG_FUNC_IN( "RHtiBtCommInterface::Close" );
+
+    // Use thread finder to find the server thread
+    TFullName threadName;
+    TFullName matchPattern;
+    matchPattern.Append( _L( "*" ) );
+    matchPattern.Append( KBtCommServerName );
+    matchPattern.Append( _L( "*" ) );
+
+    TFindThread threadFinder;
+    threadFinder.Find( matchPattern );
+    TInt err = threadFinder.Next( threadName );
+    if ( err )
+        {
+        HTI_LOG_FORMAT( "RHtiBtCommInterface::Close: Failed to find server thread: %d", err );
+        User::Panic( _L( "BtIf Close, server thread not found" ), err );
+        }
+
+    HTI_LOG_TEXT( "RHtiBtCommInterface::Close: Found server thread:" );
+    HTI_LOG_DES( threadName );
+
+    RThread thread;
+    err = thread.Open( threadName );
+    if ( err )
+        {
+        HTI_LOG_FORMAT( "RHtiBtCommInterface::Close: Failed to open server thread: %d", err );
+        User::Panic( _L( "BtIf Close, error opening server thread" ), err );
+        }
+    else
+        {
+        // initiate server shutdown
+        RSessionBase::Close();
+
+        // For clean server stop, wait for its death
+        HTI_LOG_TEXT( "RHtiBtCommInterface::Close: Waiting for server thread to die..." );
+        TRequestStatus status;
+        thread.Logon( status );
+        User::WaitForRequest( status );
+        HTI_LOG_TEXT( "RHtiBtCommInterface::Close: Server thread dead." );
+        }
+
+    thread.Close();
+    HTI_LOG_FUNC_OUT( "RHtiBtCommInterface::Close" );
+    }
+
+/*---------------------------------------------------------------------------*/
+EXPORT_C TVersion RHtiBtCommInterface::Version(void) const
+    {
+    HTI_LOG_TEXT( "RHtiBtCommInterface::Connect()" );
+    return ( TVersion( KBtCommServerMajorVersionNumber,
+                       KBtCommServerMinorVersionNumber,
+                       KBtCommServerBuildVersionNumber ) );
+
+    }
+
+/*---------------------------------------------------------------------------*/
+EXPORT_C TInt RHtiBtCommInterface::GetSendBufferSize() const
+    {
+    return KClientSendBufferMaxSize;
+    }
+
+/*---------------------------------------------------------------------------*/
+EXPORT_C TInt RHtiBtCommInterface::GetReceiveBufferSize() const
+    {
+    return KClientReceiveBufferMaxSize;
+    }
+
+/*---------------------------------------------------------------------------*/
+EXPORT_C void RHtiBtCommInterface::Receive(TDes8& aData,
+                                        TRequestStatus& aStatus)
+    {
+    HTI_LOG_TEXT( "RHtiBtCommInterface::Receive()" );
+    SendReceive( EBtCommServerRecv, TIpcArgs( &aData ), aStatus );
+    }
+
+/*---------------------------------------------------------------------------*/
+EXPORT_C void RHtiBtCommInterface::Send(const TDesC8& aData,
+                                        TRequestStatus& aStatus)
+    {
+    HTI_LOG_TEXT( "RHtiBtCommInterface::Send()" );
+    SendReceive( EBtCommServerSend, TIpcArgs( &aData ), aStatus );
+    }
+
+/*---------------------------------------------------------------------------*/
+EXPORT_C void RHtiBtCommInterface::CancelReceive()
+    {
+    HTI_LOG_TEXT( "RHtiBtCommInterface::CancelReceive()" );
+    SendReceive( ECancelBtCommServerRecv, TIpcArgs( NULL ) );
+    }
+
+/*---------------------------------------------------------------------------*/
+EXPORT_C void RHtiBtCommInterface::CancelSend()
+    {
+    HTI_LOG_TEXT( "RHtiBtCommInterface::CancelSend()" );
+    SendReceive( ECancelBtCommServerSend, TIpcArgs( NULL ) );
+    }
+
+/*---------------------------------------------------------------------------*/
+EXPORT_C TInt RHtiBtCommInterface::GetPortNumber() const
+    {
+    HTI_LOG_TEXT( "RHtiBtCommInterface::GetPortNumber()" );
+    TPckgBuf<TInt> pckg;
+    TInt ret = SendReceive( EGetServicePortNumber, TIpcArgs( &pckg ) );
+    if ( ret == KErrNone )
+        {
+        ret = pckg();
+        }
+    return ret;
+    }
+
+/*---------------------------------------------------------------------------*/
+TInt RHtiBtCommInterface::ConnectBt( TDesC8& aDeviceNameOrAddress, TInt aPort )
+    {
+    HTI_LOG_TEXT( "RHtiBtCommInterface::ConnectBt()" );
+    return SendReceive( EBtCommServerConnect,
+                            TIpcArgs( &aDeviceNameOrAddress, aPort ) );
+    }
+
+/*---------------------------------------------------------------------------*/
+GLDEF_C TInt E32Main()
+    {
+    HTI_LOG_TEXT( "RHtiBtCommInterface::E32Main()" );
+    return KErrNone;
+    }
+
+// End of the file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommServer/src/HtiBtCommServer.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,244 @@
+/*
+* 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: This file contains the implementation of the
+*              CHtiBtCommServer class.
+*              CHtiBtCommServer handles Symbian server side operations
+*              such as server starting and client session creation.
+*
+*/
+
+
+// INCLUDE FILES
+#include "HtiBtClientServerCommon.h"
+#include "HtiBtCommServer.h"
+#include "HtiBtCommServerSession.h"
+#include "Logger.h"
+
+#include <e32base.h>
+#include <e32std.h>
+#include <e32svr.h>
+#include <e32uid.h>
+
+// CONSTANTS
+// For memory allocations
+const TUint KBtCommServerHeapSizeMin       = 0x6000;
+const TUint KBtCommServerHeapSizeMax       = 0x20000;
+const TUint KBtCommServerStackSize         = 0x8000;
+
+
+//*****************************************************************************
+//
+// Class CHtiBtCommServer
+//
+//*****************************************************************************
+
+/*---------------------------------------------------------------------------*/
+CHtiBtCommServer::CHtiBtCommServer( TInt aPriority )
+    : CServer2( aPriority, ESharableSessions )
+    {
+    LOGFW(DebugLog(_L("CHtiBtCommServer: CHtiBtCommServer()")))
+    __DECLARE_NAME(_S( "CHtiBtCommServer" ));
+    }
+
+/*---------------------------------------------------------------------------*/
+void CHtiBtCommServer::ConstructL()
+    {
+    LOGFW(DebugLog(_L("CHtiBtCommServer: ConstructL()")))
+    }
+
+/*---------------------------------------------------------------------------*/
+CHtiBtCommServer* CHtiBtCommServer::NewL()
+    {
+    LOGFW(DebugLog(_L("CHtiBtCommServer: NewL()"));)
+
+    CHtiBtCommServer *pS =
+        new (ELeave) CHtiBtCommServer( EBtCommServerPriority );
+    CleanupStack::PushL( pS );
+    __ASSERT_ALWAYS( pS != NULL, PanicServer( ESvrCreateServer ) );
+
+    pS->ConstructL();
+    CleanupStack::Pop( pS );
+    User::SetProcessCritical( User::ENotCritical );
+    User::SetCritical( User::ENotCritical );
+    LOGFW(InfoLog(_L("Server was started")))
+    return pS;
+    }
+
+/*---------------------------------------------------------------------------*/
+CHtiBtCommServer::~CHtiBtCommServer()
+    {
+    LOGFW(DebugLog(_L("CHtiBtCommServer: ~CHtiBtCommServer()")))
+    }
+
+/*---------------------------------------------------------------------------*/
+void CHtiBtCommServer::SessionFreed()
+    {
+    LOGFW(DebugLog(_L("CHtiBtCommServer: SessionFreed(): Stopping active scheduler"));)
+    iSession = NULL; // iSession is owned by server framework, not deleted here
+    CActiveScheduler::Stop();
+    LOGFW(DebugLog(_L("CHtiBtCommServer: SessionFreed(): Done"));)
+    }
+
+/*---------------------------------------------------------------------------*/
+void CHtiBtCommServer::SessionCreated( CHtiBtCommServerSession* aSession )
+    {
+    LOGFW(DebugLog(_L("CHtiBtCommServer: SessionCreated()"));)
+    iSession = aSession;
+    }
+
+/*---------------------------------------------------------------------------*/
+CSession2* CHtiBtCommServer::NewSessionL( const TVersion &aVersion,
+    const RMessage2& aMessage ) const
+    {
+    LOGFW(DebugLog(_L("CHtiBtCommServer: NewSessionL() - IPC V2"));)
+    aMessage.IsNull();
+    if ( iSession )
+        User::Leave( KErrAlreadyExists ); // Allow only one session
+
+    // Check that server is the right version
+    TVersion ver( KBtCommServerMajorVersionNumber,
+                  KBtCommServerMinorVersionNumber,
+                  KBtCommServerBuildVersionNumber );
+    if ( !User::QueryVersionSupported( ver, aVersion ) )
+        {
+        User::Leave( KErrNotSupported );
+        }
+    return CHtiBtCommServerSession::NewL( (CHtiBtCommServer*)this );
+    }
+
+/*---------------------------------------------------------------------------*/
+GLDEF_C TInt CHtiBtCommServer::ThreadFunction( TAny* anArg )
+    {
+    LOGFW(_L("CHtiBtCommServer: ThreadFunction(): Starting"));
+
+    __UHEAP_MARK;
+
+    CTrapCleanup* cleanup = CTrapCleanup::New();
+
+    // Convert argument into semaphore reference
+    RSemaphore& semaphore = *(RSemaphore*)anArg;
+
+    // Start scheduler...
+    LOGFW(DebugLog(_L("CHtiBtCommServer: ThreadFunction(): Installing active scheduler"));)
+    CActiveScheduler *pA = new CActiveScheduler;
+    __ASSERT_ALWAYS( pA != NULL, PanicServer( EMainSchedulerError ) );
+    CActiveScheduler::Install( pA );
+
+    CHtiBtCommServer* pS = NULL;
+    TRAPD(err,
+        // ...and server
+        LOGFW(DebugLog(_L("CHtiBtCommServer: ThreadFunction(): Creating server instance"));)
+        pS = CHtiBtCommServer::NewL();
+        )
+
+    if ( err != KErrNone )
+        {
+        LOGFW(DebugLog(_L("CHtiBtCommServer: ThreadFunction(): Failed creating server instance"));)
+        }
+
+    LOGFW(DebugLog(_L("CHtiBtCommServer: ThreadFunction(): Starting server"));)
+    __ASSERT_ALWAYS( pS->Start(KBtCommServerName) == KErrNone,
+        PanicServer( ESvrStartServer ) ); // Make first request pending,
+
+    // Signal that server has started
+    LOGFW(DebugLog(_L("CHtiBtCommServer: ThreadFunction(): Signalling client: server is up and running"));)
+    semaphore.Signal();
+
+    LOGFW(DebugLog(_L("CHtiBtCommServer: ThreadFunction(): Waiting for server's death"));)
+    // Start receiving requests from clients
+    CActiveScheduler::Start();
+    LOGFW(DebugLog(_L("CHtiBtCommServer: ThreadFunction(): Server was stopped"));)
+    LOGFW(InfoLog(_L("Server was stopped")))
+    delete pS;
+    LOGFW(DebugLog(_L("CHtiBtCommServer: ThreadFunction(): Server was deleted"));)
+
+    // Finished
+    delete pA;
+    pA = NULL;
+
+     // Destroy clean-up stack
+    delete cleanup;
+    cleanup = NULL;
+
+    __UHEAP_MARKEND;
+    return KErrNone;
+    }
+
+/*---------------------------------------------------------------------------*/
+GLDEF_C void PanicServer( TBtCommServerPanic aPanic )
+    {
+    LOGFW(DebugLog(_L("CHtiBtCommServer: PanicServer()"));)
+    _LIT( KTxtServerPanic, "BtCommServer panic" );
+    User::Panic( KTxtServerPanic, aPanic );
+    }
+
+/*---------------------------------------------------------------------------*/
+EXPORT_C TInt StartThread()
+    {
+//    LOGFW(_L("CHtiBtCommServer: StartThread()"));
+    TInt res = KErrNone;
+
+    // Create server - if one of this name does not already exist
+    TFindServer findBtCommServer( KBtCommServerName );
+    TFullName name;
+    if ( findBtCommServer.Next( name ) != KErrNone ) // Server doesn't exist
+        {
+         // Create a semaphore to know when thread initialization has finished
+        RSemaphore semaphore;
+        semaphore.CreateLocal(0);
+
+//        LOGFW(_L("CHtiBtCommServer: Created Semaphore...\n"));
+
+        // Create new server thread and thread's main function
+        RThread thread;
+        res = thread.Create( KBtCommServerName,
+                             CHtiBtCommServer::ThreadFunction,
+                             KBtCommServerStackSize,
+                             KBtCommServerHeapSizeMin,
+                             KBtCommServerHeapSizeMax,
+                             &semaphore );
+
+
+        if ( res == KErrNone ) // Thread created ok - now start it going
+            {
+//            LOGFW(_L("CHtiBtCommServer: StartThread() - Create OK"));
+
+            thread.SetPriority( EPriorityNormal );
+//            TRequestStatus stat1;
+//            thread.Logon(stat1);
+
+            thread.Resume();  // Start it going
+
+            semaphore.Wait(); // Wait until it's initialized
+
+            thread.Close();   // No longer interest in the other thread
+            }
+        else // Thread not created ok
+            {
+            // No further interest in it
+//            LOGFW(_L("CHtiBtCommServer: StartThread() - Create FAIL"));
+            thread.Close();
+            }
+        semaphore.Close();
+        }
+    return res;
+    }
+
+/*---------------------------------------------------------------------------*/
+GLDEF_C TInt E32Main()
+    {
+    return KErrNone;
+    }
+
+// End of the file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommServer/src/HtiBtCommServerSession.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,419 @@
+/*
+* 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:  Implementation of CHtiBtCommServerSession class. This class
+*                represents the client session in server.
+*
+*/
+
+
+
+// INCLUDE FILES
+#include "HtiBtClientServerCommon.h"
+#include "HtiBtCommServerSession.h"
+#include "HtiBtCommServer.h"
+#include "BtSerialClient.h"
+#include "Logger.h"
+
+#include <e32base.h>
+#include <e32std.h>
+#include <e32svr.h>
+
+#include <HTICommPluginInterface.h> // KErrComModuleReset;
+
+// CONSTANTS
+ _LIT(KBtComSessPanic, "BtComSessAssrt");
+
+const TInt KBtAddressHexStringLength = 12; // 6 bytes
+const TInt KIncomingDataBufSize = 32 * 1024;
+
+//*****************************************************************************
+//
+// Class CHtiBtCommServerSession
+//
+//*****************************************************************************
+
+/*---------------------------------------------------------------------------*/
+CHtiBtCommServerSession::CHtiBtCommServerSession( CHtiBtCommServer* aServer )
+    : CSession2()
+    {
+    LOGFW(DebugLog(_L("CHtiBtCommServerSession: CHtiBtCommServerSession()")))
+
+    __DECLARE_NAME( _S( "CHtiBtCommServerSession" ) );
+    iBtCommServer = aServer;
+    iReadRequestComplete = ETrue;  // ready to accept read request
+    iWriteRequestComplete = ETrue;
+    iConnectRequestComplete = ETrue;
+    iBtCommServer->SessionCreated(this);
+    }
+
+/*---------------------------------------------------------------------------*/
+CHtiBtCommServerSession* CHtiBtCommServerSession::NewL(
+    CHtiBtCommServer* aServer )
+    {
+    LOGFW(DebugLog(_L("CHtiBtCommServerSession: NewL()")))
+    CHtiBtCommServerSession* session =
+        new (ELeave) CHtiBtCommServerSession( aServer );
+    CleanupStack::PushL( session );
+    session->ConstructL();
+    CleanupStack::Pop( session );
+    return session;
+    }
+
+/*---------------------------------------------------------------------------*/
+
+void CHtiBtCommServerSession::ConstructL()
+    {
+    LOGFW(DebugLog(_L("CHtiBtCommServerSession: ConstructL()")))
+    iBtClient = CBtSerialClient::NewL(*this);
+    iIncomingDataBuf = HBufC8::NewL(KIncomingDataBufSize);
+    LOGFW(DebugLog(_L("CHtiBtCommServerSession: ConstructL(): Done")))
+    }
+
+/*---------------------------------------------------------------------------*/
+CHtiBtCommServerSession::~CHtiBtCommServerSession()
+    {
+    LOGFW(DebugLog(_L("CHtiBtCommServerSession: ~CHtiBtCommServerSession()")))
+    delete iBtClient;
+    ResetAll(KErrCancel);
+    delete iIncomingDataBuf;
+    if ( iBtCommServer )
+        {
+        iBtCommServer->SessionFreed();
+        }
+    LOGFW(DebugLog(_L("CHtiBtCommServerSession: ~CHtiBtCommServerSession(): Done")))
+    }
+
+/*---------------------------------------------------------------------------*/
+void CHtiBtCommServerSession::ServiceL( const RMessage2& aMessage )
+    {
+    LOGFW(DebugLog(_L("CHtiBtCommServerSession: ServiceL()")))
+
+    TRAPD( error, DispatchMessageL( aMessage ) );
+    if ( error != KErrNone )
+        {
+        LOGFW(DebugLog(_L("CHtiBtCommServerSession::ServiceL error %d"), error);)
+        }
+    LOGFW(DebugLog(_L("CHtiBtCommServerSession: ServiceL(): Done")))
+    }
+
+
+/*---------------------------------------------------------------------------*/
+void CHtiBtCommServerSession::DispatchMessageL( const RMessage2 &aMessage )
+    {
+    LOGFW( DebugLog( _L( "CHtiBtCommServerSession: DispatchMessageL()" ) ) )
+
+    switch ( aMessage.Function() )
+        {
+        case EBtCommServerConnect:
+            {
+            HandleConnectRequestL( aMessage );
+            }
+            break;
+
+        case EBtCommServerSend:
+            {
+            HandleSendRequestL( aMessage );
+            }
+            break;
+        case EBtCommServerRecv:
+            {
+            HandleReadRequestL( aMessage );
+            }
+            break;
+
+        case ECancelBtCommServerRecv:
+        case ECancelBtCommServerSend:
+            {
+            HandleCancelRequestL( aMessage );
+            }
+            break;
+
+        case EGetServicePortNumber:
+            {
+            HandlePortNumberRequestL( aMessage );
+            }
+            break;
+
+        default:
+            {
+            LOGFW(ErrLog(_L("CHtiBtCommServerSession::DispatchMessageL: Unknown request: %d. Panicing Client"), aMessage.Function());)
+            PanicClient( EBadRequest );
+            User::Panic( KBtComSessPanic, 1 );
+            }
+            break;
+        }
+    LOGFW(DebugLog(_L("CHtiBtCommServerSession: DispatchMessageL(): Done")))
+    }
+
+/*---------------------------------------------------------------------------*/
+void CHtiBtCommServerSession::HandleConnectRequestL( const RMessage2& aMessage )
+    {
+    LOGFW(DebugLog(_L("CHtiBtCommServer:HandleConnectRequestL()")))
+    if ( !iConnectRequestComplete )
+        {
+        LOGFW(DebugLog(_L("CHtiBtCommServer:HandleConnectRequestL(): Already connecting")))
+        aMessage.Complete( KErrNotReady );
+        }
+    else
+        {
+        if ( iBtClient->Connected() )
+            {
+            LOGFW(DebugLog(_L("CHtiBtCommServer:HandleConnectRequestL(): Already connected")))
+            aMessage.Complete( KErrNone ); // Already connected. This is not an error?
+            }
+        else
+            {
+            LOGFW(DebugLog(_L("CHtiBtCommServer:HandleConnectRequestL(): Starting to connect to remote host")))
+            iConnectRequest = aMessage;
+            iConnectRequestComplete = EFalse;
+
+            TInt dataLength = (TUint16)aMessage.GetDesLength( 0 ); //first message slot
+            LOGFW(DebugLog(_L("CHtiBtCommServer:HandleConnectRequestL(): Data length = %d"), dataLength));
+
+            TInt port = aMessage.Int1();
+            LOGFW(DebugLog(_L("CHtiBtCommServer:HandleConnectRequestL(): Port = %d"), port));
+
+            if ( dataLength < 1 )
+                {
+                LOGFW(DebugLog(_L("CHtiBtCommServer:HandleConnectRequestL(): No address or name - need to ask device")))
+                iBtClient->ConnectL(); // Request is completed in ConnectedToServer
+                }
+            else if ( dataLength == KBtAddressHexStringLength )
+                {
+                TBuf8<KBtAddressHexStringLength> addressBuf8;
+                aMessage.ReadL( 0, addressBuf8 );
+                TBuf<KBtAddressHexStringLength> addressBuf;
+                addressBuf.Copy( addressBuf8 );
+                TBTDevAddr address;
+                TInt result = address.SetReadable( addressBuf );
+                LOGFW(DebugLog(_L("CHtiBtCommServer:HandleConnectRequestL(): SetReadable result = %d"), result));
+                if ( result != KBtAddressHexStringLength )
+                    {
+                    LOGFW(DebugLog(_L("CHtiBtCommServer:HandleConnectRequestL(): Not valid address - use it as name")))
+                    iBtClient->ConnectL( addressBuf, port );
+                    }
+                else
+                    {
+                    LOGFW(DebugLog(_L("CHtiBtCommServer:HandleConnectRequestL(): Valid address - connect")))
+                    iBtClient->ConnectL( address, port );
+                    }
+                }
+            else
+                {
+                LOGFW(DebugLog(_L("CHtiBtCommServer:HandleConnectRequestL(): Using name to connect")))
+                TBTDeviceName8 deviceName8;
+                aMessage.ReadL( 0, deviceName8 );
+                TBTDeviceName deviceName;
+                deviceName.Copy( deviceName8 );
+                iBtClient->ConnectL( deviceName, port );
+                }
+            }
+        }
+    LOGFW(DebugLog(_L("CHtiBtCommServer:HandleConnectRequestL(): Done")))
+    }
+
+/*---------------------------------------------------------------------------*/
+void CHtiBtCommServerSession::HandleReadRequestL( const RMessage2& aMessage )
+    {
+    LOGFW(DebugLog(_L("CHtiBtCommServerSession: HandleReadRequestL()")))
+
+    if ( !iReadRequestComplete )
+        {
+        LOGFW(WarnLog(_L("CHtiBtCommServerSession: HandleReadRequestL(): Pending request. ret=KErrNotReady")))
+        // Two simultaneous read requests are not allowed.
+        aMessage.Complete(KErrNotReady);
+        return;
+        }
+
+    // No data in read buffer. Must wait for new data before completing request
+    iReadRequest = aMessage;
+    iReadRequestComplete = EFalse; // Not ready to complete next request
+    TryCompleteReadRequest(); // if there is something in the readbuffer,
+                              // use it for completion.
+
+    if ( iIncomingDataBuf->Des().Length() == 0 )
+        {
+        // Read some bytes to buffer even before client's request.
+        iBtClient->ReadAsyncL(); // Issue async request to read more data.
+        }
+
+    LOGFW(DebugLog(_L("CHtiBtCommServerSession: HandleReadRequestL(): Done")))
+    }
+
+/*---------------------------------------------------------------------------*/
+void CHtiBtCommServerSession::HandleSendRequestL( const RMessage2& aMessage )
+    {
+    LOGFW(DebugLog(_L("CHtiBtCommServerSession: HandleSendRequestL()")))
+
+    TInt dataLength = (TUint16)aMessage.GetDesLength( 0 ); //first message slot
+    LOGFW( InfoLog( _L( "Framework requested to send data: %d bytes" ), dataLength ) )
+    if ( iBtClient->SendBufferMaxSize() < dataLength )
+        {
+        aMessage.Complete(KErrOverflow);
+        LOGFW(ErrLog(_L("CHtiBtCommServerSession: HandleSendRequestL(): client is giving too big data. Cannot handle.")))
+        }
+    else if ( !iWriteRequestComplete )
+        {
+        LOGFW(WarnLog(_L("CHtiBtCommServerSession: HandleSendRequestL(): Pending request. ret=KErrNotReady")))
+        // Already pending send request. Two simultaneous send requests not allowed.
+        aMessage.Complete( KErrNotReady );
+        }
+    else
+        {
+        if ( iBtClient->FreeSpaceInSendBuffer() < dataLength )
+            {
+            LOGFW(DebugLog(_L("CHtiBtCommServerSession: HandleSendRequestL(): Completing send request delayed")))
+            // No space in the iBtClient's send buffer. Copy the data to internal
+            // buffer and wait for iBtClient to send its data out before adding
+            // data to its send buffer.
+            delete iSendBuffer;
+            iSendBuffer = NULL;
+            iSendBuffer = HBufC8::NewL(dataLength);
+            TPtr8 ptr = iSendBuffer->Des();
+            aMessage.ReadL( 0, ptr );
+            iWriteRequestComplete = EFalse;
+            iWriteRequest = aMessage;
+            // Wait for callback call AllBufferedDataSent. Complete request there.
+            }
+        else
+            {
+            LOGFW(DebugLog(_L("CHtiBtCommServerSession: HandleSendRequestL(): Completing send request immediately")))
+            // All data can be sent immediately, because there is enough space in
+            // iBtClient's send buffer.
+            HBufC8* data = HBufC8::NewLC( dataLength );
+            TPtr8 ptr = data->Des();
+            aMessage.ReadL( 0, ptr );
+            iBtClient->SendL( ptr );
+            CleanupStack::PopAndDestroy( data );
+            aMessage.Complete( KErrNone );
+            }
+        }
+    LOGFW(DebugLog(_L("CHtiBtCommServerSession: HandleSendRequestL(): Done")))
+    }
+
+/*---------------------------------------------------------------------------*/
+void CHtiBtCommServerSession::HandleCancelRequestL( const RMessage2& aMessage )
+    {
+    ResetAll( KErrCancel );
+    aMessage.Complete( KErrNone );
+    }
+
+/*---------------------------------------------------------------------------*/
+void CHtiBtCommServerSession::HandlePortNumberRequestL(const RMessage2& aMessage)
+    {
+    TPckgBuf<TInt> p( iBtClient->ServicePort() );
+    TInt err = aMessage.Write( 0, p, 0 );
+    aMessage.Complete( err );
+    }
+
+/*---------------------------------------------------------------------------*/
+
+void CHtiBtCommServerSession::PanicClient(TInt aPanic) const
+    {
+    LOGFW(DebugLog(_L("CHtiBtCommServerSession: PanicClient(): %d"), aPanic))
+    LOGFW(WarnLog(_L("CHtiBtCommServerSession: PanicClient(): %d. NOT IMPLEMENTED"), aPanic))
+    aPanic = aPanic;
+    // should be done with RMessage2?
+    }
+
+/*---------------------------------------------------------------------------*/
+void CHtiBtCommServerSession::ResetAll(TInt aCompletionCode)
+    {
+    LOGFW(DebugLog(_L("CHtiBtCommServerSession: ResetAll()")))
+    if ( !iWriteRequestComplete )
+        iWriteRequest.Complete( aCompletionCode );
+    if ( !iReadRequestComplete )
+        iReadRequest.Complete( aCompletionCode );
+    if ( !iConnectRequestComplete )
+        iConnectRequest.Complete( aCompletionCode ); // error when making connection
+    iWriteRequestComplete = ETrue;
+    iReadRequestComplete = ETrue;
+    iConnectRequestComplete = ETrue;
+    delete iIncomingDataBuf;
+    iIncomingDataBuf = NULL;
+    delete iSendBuffer;
+    iSendBuffer = NULL;
+    iIncomingDataBuf = HBufC8::New(KIncomingDataBufSize);
+    LOGFW(DebugLog(_L("CHtiBtCommServerSession: ResetAll(): Done")))
+    }
+
+/*---------------------------------------------------------------------------*/
+void CHtiBtCommServerSession::ConnectedToServer(TInt aError)
+    {
+    // Connected to server. Reading has been started.
+    LOGFW(InfoLog(_L("CHtiBtCommServerSession: ConnectedToServer: connected to remote host")))
+    iConnectRequestComplete = ETrue;
+    iConnectRequest.Complete( aError );
+    }
+
+/*---------------------------------------------------------------------------*/
+void CHtiBtCommServerSession::DisconnectedFromServer()
+    {
+    LOGFW(InfoLog(_L("CHtiBtCommServerSession: DisconnectedFromServer: disconnected from remote host")))
+    ResetAll( KErrDisconnected );
+    }
+
+/*---------------------------------------------------------------------------*/
+void CHtiBtCommServerSession::DataFromServer(const TDesC8& aData)
+    {
+    LOGFW(DebugLog(_L("CHtiBtCommServerSession: DataFromServer: %d bytes"), aData.Length()))
+    TPtr8 ptr = iIncomingDataBuf->Des();
+    if ( aData.Length() > ptr.MaxLength() - ptr.Length() )
+        PanicClient( KErrUnderflow ); // Client is reading too slowly
+
+    ptr.Append( aData );
+    TryCompleteReadRequest();
+    LOGFW(DebugLog(_L("CHtiBtCommServerSession: DataFromServer: done"), aData.Length()))
+    }
+
+/*---------------------------------------------------------------------------*/
+void CHtiBtCommServerSession::AllBufferedDataSent()
+    {
+    LOGFW(DebugLog(_L("CHtiBtCommServerSession: AllBufferedDataSent")))
+    if ( !iWriteRequestComplete )
+        {
+        // iBtClient has sent all of its data and is ready to send more.
+        TPtr8 ptr = iSendBuffer->Des();
+        TRAPD( err, iBtClient->SendL( ptr ); )
+        iWriteRequest.Complete( err );
+        iWriteRequestComplete = ETrue;
+        delete iSendBuffer;
+        iSendBuffer = NULL;
+        }
+    LOGFW(DebugLog(_L("CHtiBtCommServerSession: AllBufferedDataSent: Done")))
+    }
+
+/*---------------------------------------------------------------------------*/
+void CHtiBtCommServerSession::TryCompleteReadRequest()
+    {
+    LOGFW(DebugLog(_L("CHtiBtCommServerSession: TryCompleteReadRequest")))
+    TPtr8 ptr = iIncomingDataBuf->Des();
+
+    if ( iReadRequestComplete || ptr.Length() == 0 )
+        {
+        LOGFW(DebugLog(_L("CHtiBtCommServerSession: TryCompleteReadRequest: Nothing to complete")))
+        return; // No outstanding client request to complete
+        }
+
+    TInt dataMaxLength = (TUint16)iReadRequest.GetDesMaxLength(0); //first message slot
+    TPtrC8 dataToClient = ptr.Left(dataMaxLength);
+    TRAPD(err, iReadRequest.WriteL(0, dataToClient);)
+
+    ptr.Delete(0, dataToClient.Length());
+    iReadRequest.Complete(err);
+    iReadRequestComplete = ETrue;
+    LOGFW(DebugLog(_L("CHtiBtCommServerSession: TryCompleteReadRequest: Done")))
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommServer/src/Logger.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,201 @@
+/*
+* 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:  Logger implementation.
+*
+*/
+
+
+// INCLUDE FILES
+#include "Logger.h"
+#include <f32file.h>
+
+#ifdef __ENABLE_LOGGING__
+
+// CONSTANTS
+_LIT(KDebugStr, "DEBUG: ");
+_LIT(KInfoStr,  "INFO:  ");
+_LIT(KWarnStr,  "WARN:  ");
+_LIT(KErrStr,   "ERROR: ");
+
+
+/*---------------------------------------------------------------------------*/
+void LogBytes( const TDesC8& aData, TInt aMaxBytesToLog )
+    {
+    TInt i = 0;
+    while ( i < aData.Length() && i < aMaxBytesToLog )
+        {
+        TBuf<64> hexbuf;
+        TBuf<32> stringbuf;
+        TInt k=0;
+        while ( i < aMaxBytesToLog && i < aData.Length() && k < 16 )
+            {
+            const TUint8 uint8 = aData[i];
+            hexbuf.AppendFormat( _L( "%02X "), uint8 );
+
+            if ( uint8 == '%' )
+                {
+                stringbuf.Append( _L( "%%" ) ); // escape character in format string
+                }
+            else if ( uint8 < 32 || uint8 > 126 )
+                {
+                stringbuf.Append( _L(".") );
+                }
+            else
+                {
+                stringbuf.Append( ( TChar ) uint8 );
+                }
+            i++;
+            k++;
+            }
+        TBuf<128> finalbuf;
+        finalbuf.Copy( hexbuf );
+        finalbuf.Append( _L(" | " ) );
+        finalbuf.Append( stringbuf );
+        DebugLog( finalbuf );
+        }
+    }
+
+/*---------------------------------------------------------------------------*/
+class TOverflowHandler : public TDes16Overflow
+    {
+    void Overflow( TDes16& aDes )
+        {
+        TBuf<KLogEntryMaxLength> logString( _L("LOG ERROR: overflow: ") );
+        logString.Append( aDes.Left(
+            KLogEntryMaxLength - logString.Length() ) );
+        aDes.Copy( logString );
+        }
+    };
+
+/*---------------------------------------------------------------------------*/
+// Usage example: DOLOG(_L("Logstring"));
+void DebugLog( TRefByValue<const TDesC> aFmt, ... )
+    {
+    VA_LIST list;
+    VA_START( list, aFmt );
+    Log( KLogLevelDebug, aFmt, list );
+    }
+
+/*---------------------------------------------------------------------------*/
+void InfoLog( TRefByValue<const TDesC> aFmt, ... )
+    {
+    VA_LIST list;
+    VA_START( list, aFmt );
+    Log( KLogLevelInfo, aFmt, list );
+    }
+
+/*---------------------------------------------------------------------------*/
+void WarnLog( TRefByValue<const TDesC> aFmt, ... )
+    {
+    VA_LIST list;
+    VA_START( list, aFmt );
+    Log( KLogLevelWarning, aFmt, list );
+    }
+
+/*---------------------------------------------------------------------------*/
+void ErrLog( TRefByValue<const TDesC> aFmt, ...)
+    {
+    VA_LIST list;
+    VA_START( list, aFmt );
+    Log( KLogLevelError, aFmt, list );
+    }
+
+/*---------------------------------------------------------------------------*/
+void Log( TInt aLevel, TRefByValue<const TDesC> aText, VA_LIST list )
+    {
+
+    if ( aLevel < KMinimumLogLevel )
+        return;
+
+    _LIT( KLineFeed, "\n" );
+
+    /**
+     *  Log time format (see TTime) is
+     *  Day-Month-Year Hours:Minutes:Seconds:Milliseconds
+     *
+     *  Example: 30-12-2004 23:00:55:990
+     */
+    _LIT( KLogTimeFormat, "%F%D-%M-%Y %H:%T:%S:%*C3" );
+
+    TBuf8<KLogEntryMaxLength> writeBuffer;
+    TBuf16<KLogEntryMaxLength> logEntry;
+    RFs FileServer;
+    RFile File;
+
+    if ( FileServer.Connect() != KErrNone )
+        {
+        FileServer.Close(); // just in case
+        User::Panic( KLogPanicCategory(), KPanicFsConnectFailed );
+        return;
+        }
+
+    // Open file for writing, if exists. Othervise create new file.
+    if ( File.Open( FileServer, KLogFileName(), EFileWrite ) != KErrNone )
+        {
+        if ( File.Create( FileServer, KLogFileName(), EFileWrite )
+            != KErrNone )
+            {
+            FileServer.Close();
+            User::Panic( KLogPanicCategory(), KPanicFileCreateFailed );
+            }
+        }
+
+    TTime currentTime;
+    currentTime.UniversalTime();
+    TBuf<32> timeString;
+
+    // currentTime is now in universal time. Convert it to home time.
+    TLocale locale;
+    TTimeIntervalSeconds universalTimeOffset( locale.UniversalTimeOffset() );
+    TTimeIntervalHours daylightSaving( 0 );
+    if ( locale.QueryHomeHasDaylightSavingOn() )
+        {
+        daylightSaving = 1;
+        }
+    currentTime = currentTime + universalTimeOffset + daylightSaving;
+    currentTime.FormatL( timeString, KLogTimeFormat );
+
+    // Add LogString to the end of file and close the file
+    TInt currentSize = 0, returnCode;
+    writeBuffer.Append( timeString );
+    writeBuffer.Append( _L(": ") );
+
+    if ( aLevel < KLogLevelInfo )
+        writeBuffer.Append(KDebugStr);
+    else if ( aLevel < KLogLevelWarning )
+        writeBuffer.Append(KInfoStr);
+    else if ( aLevel < KLogLevelError )
+        writeBuffer.Append(KWarnStr);
+    else
+        writeBuffer.Append(KErrStr);
+
+    logEntry.AppendFormatList( aText, list ); //, &overFlowHandler );
+    writeBuffer.Append( logEntry.Left(
+        KLogEntryMaxLength - writeBuffer.Length() ) );
+    writeBuffer.Append( KLineFeed );
+    File.Size( currentSize );
+    returnCode = File.Write( currentSize,
+                             writeBuffer,
+                             writeBuffer.Length() );
+    File.Close();
+    // Close file server session
+    FileServer.Close();
+
+    if ( returnCode != KErrNone )
+        {
+        User::Panic( KLogPanicCategory(), KPanicFileWriteFailed );
+        }
+    }
+
+#endif // __ENABLE_LOGGING__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/eabi/HtiBtCommInterfaceu.def	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,14 @@
+EXPORTS
+	_ZN19RHtiBtCommInterface10CancelSendEv @ 1 NONAME
+	_ZN19RHtiBtCommInterface13CancelReceiveEv @ 2 NONAME
+	_ZN19RHtiBtCommInterface4SendERK6TDesC8R14TRequestStatus @ 3 NONAME
+	_ZN19RHtiBtCommInterface5CloseEv @ 4 NONAME
+	_ZN19RHtiBtCommInterface7ConnectER6TDesC8i @ 5 NONAME
+	_ZN19RHtiBtCommInterface7ReceiveER5TDes8R14TRequestStatus @ 6 NONAME
+	_ZN19RHtiBtCommInterfaceC1Ev @ 7 NONAME
+	_ZN19RHtiBtCommInterfaceC2Ev @ 8 NONAME
+	_ZNK19RHtiBtCommInterface13GetPortNumberEv @ 9 NONAME
+	_ZNK19RHtiBtCommInterface17GetSendBufferSizeEv @ 10 NONAME
+	_ZNK19RHtiBtCommInterface20GetReceiveBufferSizeEv @ 11 NONAME
+	_ZNK19RHtiBtCommInterface7VersionEv @ 12 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/eabi/HtiBtCommServeru.def	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,7 @@
+EXPORTS
+	_Z11StartThreadv @ 1 NONAME
+	_ZTI16CHtiBtCommServer @ 2 NONAME ; #<TI>#
+	_ZTI23CHtiBtCommServerSession @ 3 NONAME ; #<TI>#
+	_ZTV16CHtiBtCommServer @ 4 NONAME ; #<VT>#
+	_ZTV23CHtiBtCommServerSession @ 5 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/eabi/HtiBtSerialComHelperu.def	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,32 @@
+EXPORTS
+	_ZN15CBtSerialClient10ConnectingEv @ 1 NONAME
+	_ZN15CBtSerialClient10DisconnectEv @ 2 NONAME
+	_ZN15CBtSerialClient10ReadAsyncLEv @ 3 NONAME
+	_ZN15CBtSerialClient11ServicePortEv @ 4 NONAME
+	_ZN15CBtSerialClient14ServerAddressLEv @ 5 NONAME
+	_ZN15CBtSerialClient17SendBufferMaxSizeEv @ 6 NONAME
+	_ZN15CBtSerialClient21FreeSpaceInSendBufferEv @ 7 NONAME
+	_ZN15CBtSerialClient4NewLER23MBtSerialClientObserver @ 8 NONAME
+	_ZN15CBtSerialClient5SendLERK6TDesC8 @ 9 NONAME
+	_ZN15CBtSerialClient8ConnectLE10TBTDevAddri @ 10 NONAME
+	_ZN15CBtSerialClient8ConnectLERK7TDesC16i @ 11 NONAME
+	_ZN15CBtSerialClient8ConnectLEv @ 12 NONAME
+	_ZN15CBtSerialClient9ConnectedEv @ 13 NONAME
+	_ZN15CBtSerialClientD0Ev @ 14 NONAME
+	_ZN15CBtSerialClientD1Ev @ 15 NONAME
+	_ZN15CBtSerialClientD2Ev @ 16 NONAME
+	_ZTI13CTimeOutTimer @ 17 NONAME ; #<TI>#
+	_ZTI14CSocketsReader @ 18 NONAME ; #<TI>#
+	_ZTI14CSocketsWriter @ 19 NONAME ; #<TI>#
+	_ZTI15CBtSerialClient @ 20 NONAME ; #<TI>#
+	_ZTI18CBTServiceSearcher @ 21 NONAME ; #<TI>#
+	_ZTI19TSdpAttributeParser @ 22 NONAME ; #<TI>#
+	_ZTI23CMessageServiceSearcher @ 23 NONAME ; #<TI>#
+	_ZTV13CTimeOutTimer @ 24 NONAME ; #<VT>#
+	_ZTV14CSocketsReader @ 25 NONAME ; #<VT>#
+	_ZTV14CSocketsWriter @ 26 NONAME ; #<VT>#
+	_ZTV15CBtSerialClient @ 27 NONAME ; #<VT>#
+	_ZTV18CBTServiceSearcher @ 28 NONAME ; #<VT>#
+	_ZTV19TSdpAttributeParser @ 29 NONAME ; #<VT>#
+	_ZTV23CMessageServiceSearcher @ 30 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/group/HtiBtComm.cfg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,12 @@
+# HTIBtComm communication plugin configuration file
+
+# Following parameters configure the PC where HTI will try to connect.
+# Define only one of them, either PC's Bluetooth name or Bluetooth address.
+# If both are defined, address will be used and name is ignored.
+# If neither is defined the device selection dialog will be shown and user
+# has to select the device where to connect.
+#
+# The BtDeviceAddress must be 12 hex characters.
+
+#BtDeviceName=MyComputer
+#BtDeviceAddress=01A2B3C4D5EF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/group/HtiBtCommEcomPlugin.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ECOM Plugin project to support communication over serial port
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          HtiBtCommEcomPlugin.dll
+TARGETTYPE      PLUGIN
+
+// ECom Dll recognition UID followed by the unique UID for this dll
+UID             0x10009D8D 0x200212CB
+
+VENDORID        0x101FB657
+
+CAPABILITY      ALL -TCB
+
+SOURCEPATH      ../HtiBtCommEcomPlugin/src
+SOURCE          proxy.cpp
+SOURCE          HtiBtCommEcomPlugin.cpp
+
+USERINCLUDE     ../HtiBtCommEcomPlugin/inc ../BtEngine/inc ../HtiBtCommServer/inc
+APP_LAYER_SYSTEMINCLUDE
+
+START RESOURCE  ../data/200212CB.rss
+TARGET          HtiBtCommEcomPlugin.rsc
+END
+
+LIBRARY         euser.lib
+LIBRARY         ecom.lib
+LIBRARY         c32.lib
+LIBRARY         hticfg.lib
+LIBRARY         htibtcomminterface.lib
+LIBRARY         flogger.lib
+
+SMPSAFE
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/group/HtiBtCommInterface.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,43 @@
+/*
+* 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:  HtiBtCommInterface. Client interface to HtiBtCommServer
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          HtiBtCommInterface.dll
+TARGETTYPE      DLL
+
+UID             0x200212D2
+DEFFILE         HtiBtCommInterface.def
+
+VENDORID       0x101FB657
+
+CAPABILITY      ALL -TCB
+
+SOURCEPATH      ../HtiBtCommServer/src
+SOURCE          HtiBtCommInterface.cpp
+
+USERINCLUDE     ../HtiBtCommServer/inc
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY         euser.lib
+LIBRARY         htibtcommserver.lib
+LIBRARY         flogger.lib
+
+SMPSAFE
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/group/HtiBtCommServer.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,46 @@
+/*
+* 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:  HtiBtCommServer DLL project
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          HtiBtCommServer.dll
+TARGETTYPE      DLL
+
+UID             0x200212D1
+DEFFILE         HtiBtCommServer.def
+
+VENDORID        0x101FB657
+
+CAPABILITY      ALL -TCB
+
+SOURCEPATH      ../HtiBtCommServer/src
+SOURCE          HtiBtCommServer.cpp
+SOURCE          HtiBtCommServerSession.cpp
+SOURCE          Logger.cpp
+
+USERINCLUDE     ../HtiBtCommServer/inc  ../BtEngine/inc
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY         euser.lib
+LIBRARY         efsrv.lib
+LIBRARY         bluetooth.lib
+LIBRARY         htibtserialcomhelper.lib
+
+SMPSAFE
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/group/HtiBtSerialComHelper.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,62 @@
+/*
+* 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:  HtiBtSerialComHelper project definition.
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          HtiBtSerialComHelper.dll
+TARGETTYPE      DLL
+
+UID             0x1000008d 0x200212D3
+
+VENDORID        0x101FB657
+
+CAPABILITY      ALL -TCB
+
+SOURCEPATH      ../BtEngine/src
+SOURCE          timeouttimer.cpp
+SOURCE          socketsreader.cpp
+SOURCE          socketswriter.cpp
+SOURCE          BtSerialClient.cpp
+SOURCE          messageservicesearcher.cpp
+SOURCE          btservicesearcher.cpp
+SOURCE          sdpattributeparser.cpp
+
+USERINCLUDE     ../BtEngine/inc
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY         apparc.lib
+LIBRARY         avkon.lib
+LIBRARY         eikcoctl.lib
+LIBRARY         eikcore.lib
+LIBRARY         bafl.lib
+LIBRARY         bluetooth.lib
+LIBRARY         btextnotifiers.lib
+LIBRARY         btmanclient.lib
+LIBRARY         btdevice.lib
+LIBRARY         btengsettings.lib
+LIBRARY         cone.lib
+LIBRARY         efsrv.lib
+LIBRARY         esock.lib
+LIBRARY         euser.lib
+LIBRARY         flogger.lib
+LIBRARY         sdpagent.lib
+LIBRARY         sdpdatabase.lib
+
+SMPSAFE
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiCommPlugins/HtiBtCommPlugin/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  HtiBtCommPlugin build info
+*
+*/
+
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+HtiBtSerialComHelper.mmp
+HtiBtCommServer.mmp
+HtiBtCommInterface.mmp
+HtiBtCommEcomPlugin.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiDeviceReboot/group/HtiDeviceReboot.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,42 @@
+/*
+* 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:  Build description file for HtiDeviceReboot in APP layer
+*
+*/
+
+#include <platform_paths.hrh>
+
+TARGET          HtiDeviceRebootUI.exe
+TARGETTYPE      EXE
+
+UID             0x200212D6
+
+VENDORID        0x101FB657
+
+CAPABILITY      ALL -TCB
+
+SOURCEPATH      ../src
+SOURCE          HtiDeviceReboot.cpp
+
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY         euser.lib
+LIBRARY         hal.lib
+LIBRARY         starterclient.lib
+LIBRARY         syslangutil.lib
+LIBRARY         flogger.lib
+
+SMPSAFE
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiDeviceReboot/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,32 @@
+/*
+* 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:  Build information file for HtiDeviceReboot
+*
+*/
+
+
+PRJ_PLATFORMS
+
+DEFAULT
+
+PRJ_EXPORTS
+
+PRJ_TESTEXPORTS
+
+PRJ_MMPFILES
+HtiDeviceReboot.mmp
+
+PRJ_TESTMMPFILES
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiDeviceReboot/src/HtiDeviceReboot.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,138 @@
+/*
+* 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:  HtiDeviceReboot implementation.
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <hal.h>
+#include <starterclient.h>
+#include <syslangutil.h>
+
+// CONSTANTS
+_LIT( KHtiDeviceRebootName, "HtiDeviceReboot" );
+_LIT( KParamNormalRfs, "rfsnormal" );
+_LIT( KParamDeepRfs,   "rfsdeep" );
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+LOCAL_C TInt StartL();
+LOCAL_C TInt Reboot();
+LOCAL_C TInt RestoreFactorySettings( TBool aIsDeepRfs );
+
+
+// FORWARD DECLARATIONS
+
+// ============================ LOCAL FUNCTIONS ===============================
+
+LOCAL_C TInt StartL()
+    {
+    TInt error = KErrNone;
+
+    TInt cmdLen = User::CommandLineLength();
+    HBufC* cmdLine = HBufC::NewLC( cmdLen );
+    TPtr ptCmdLine = cmdLine->Des();
+    User::CommandLine( ptCmdLine );
+
+    if ( cmdLen == 0 )
+        {
+        error = Reboot();
+        }
+
+    else
+        {
+        TLex parser( *cmdLine );
+        parser.SkipCharacters();
+        if ( parser.MarkedToken().CompareF( KParamNormalRfs ) == 0 )
+            {
+            error = RestoreFactorySettings( EFalse );
+            }
+        else if ( parser.MarkedToken().CompareF( KParamDeepRfs ) == 0 )
+            {
+            error = RestoreFactorySettings( ETrue );
+            }
+        else
+            {
+            error = KErrArgument;  // Unknown argument
+            }
+        }
+
+    CleanupStack::PopAndDestroy(); // cmdLine
+    return error;
+    }
+
+LOCAL_C TInt Reboot()
+    {
+    RStarterSession session;
+    TInt error = session.Connect();
+    if ( error == KErrNone )
+        {
+        session.Reset( RStarterSession::EUnknownReset );
+        session.Close();
+        }
+    return error;
+    }
+
+LOCAL_C TInt RestoreFactorySettings( TBool aIsDeepRfs )
+    {
+    // In case of deep rfs, set language to default
+    if ( aIsDeepRfs )
+        {
+        TInt lang = 0;
+        if ( SysLangUtil::GetDefaultLanguage( lang ) == KErrNone )
+            {
+            HAL::Set( HALData::ELanguageIndex, lang );
+            }
+        }
+
+    // Do reboot with appropriate rfs reason code
+    RStarterSession session;
+    TInt error = session.Connect();
+    if ( error == KErrNone )
+        {
+        session.Reset( aIsDeepRfs ? RStarterSession::EDeepRFSReset :
+            RStarterSession::ENormalRFSReset );
+        session.Close();
+        }
+    return error;
+    }
+
+GLDEF_C TInt E32Main()
+    {
+    __UHEAP_MARK;
+
+    CTrapCleanup* cleanup = CTrapCleanup::New();
+    CActiveScheduler *scheduler = new(ELeave) CActiveScheduler;
+    CActiveScheduler::Install( scheduler );
+
+    User::RenameThread( KHtiDeviceRebootName );
+
+    TRAPD( err, StartL() );
+
+    delete scheduler;
+    delete cleanup;
+
+   __UHEAP_MARKEND;
+
+    return err;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiAppServicePlugin/bwins/HtiAppControlu.def	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?NewHtiAppControl@@YAPAVCHtiAppControl@@XZ @ 1 NONAME ; class CHtiAppControl * NewHtiAppControl(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiAppServicePlugin/eabi/HtiAppControlu.def	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	_Z16NewHtiAppControlv @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiAppServicePlugin/group/HtiAppControl.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,56 @@
+/*
+* 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:  Build description file for HtiAppControl
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include "../../../symbian_version.hrh"
+
+TARGET      HtiAppControl.dll
+TARGETTYPE  dll
+
+
+UID 0x1020DEB7 0x2002B3E9
+
+VENDORID    0x101FB657
+
+CAPABILITY      ALL -TCB
+
+SOURCEPATH  ../src
+SOURCE      HtiAppControl.cpp
+
+USERINCLUDE     ../inc
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY     bafl.lib
+LIBRARY     ecom.lib
+LIBRARY     efsrv.lib
+LIBRARY     euser.lib
+LIBRARY     apgrfx.lib
+LIBRARY     apparc.lib
+LIBRARY     apmime.lib
+LIBRARY     ws32.lib
+LIBRARY     swinstcli.lib
+LIBRARY     sisregistryclient.lib
+#if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 )
+LIBRARY     javaregistryclient.lib
+#endif
+LIBRARY     widgetregistryclient.lib
+LIBRARY     flogger.lib
+
+SMPSAFE
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiAppServicePlugin/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,26 @@
+/*
+* 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:  Build information file for HtiAppServicePlugin
+*
+*/
+
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+HtiAppControl.mmp
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiAppServicePlugin/inc/HtiAppControl.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,212 @@
+/*
+* 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:  Implementation of ECOM plug-in service interface providing
+*                process and application control service.
+*
+*/
+
+
+
+#ifndef HTIAPPSERVICEPLUGIN_H__
+#define HTIAPPSERVICEPLUGIN_H__
+
+//  INCLUDES
+#include <e32base.h>
+#include <apgcli.h>
+#include <w32std.h>
+#include <SWInstDefs.h>
+#include <swi/sisregistryentry.h>
+#include <HTIServicePluginInterface.h>
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+class CDesC8ArrayFlat;
+class TApaTask;
+
+// CLASS DECLARATION
+
+NONSHARABLE_CLASS (CHtiAppControl) : public CHTIServicePluginInterface
+    {
+protected:
+    //commands
+    enum TAppCommand
+        {
+        //commands
+        EProcessLastCommand = 0x0F, //!!! used to sort process control from
+                                    //!!! app control
+
+        //app control
+        EStartApp               = 0x10,
+        EStartApp_u             = 0x11,
+        EStartApp_uid           = 0x12,
+        EStartApp_uid_u         = 0x13,
+        EStartDoc               = 0x14,
+        EStartDoc_u             = 0x15,
+        EStatusApp              = 0x16,
+        EStatusApp_u            = 0x17,
+        EStatusDoc              = 0x18,
+        EStatusDoc_u            = 0x19,
+        EStatusApp_uid          = 0x1A,
+        EStopApp                = 0x1C,
+        EStopApp_u              = 0x1D,
+        EStopDoc                = 0x1E,
+        EStopDoc_u              = 0x1F,
+        EStopApp_uid            = 0x20,
+        EListApps               = 0x24,
+        EListApps_u             = 0x25,
+        EListInstalledApps      = 0x26,
+        EListInstalledApps_u    = 0x27,
+
+        EAppLastCommand     = 0x2F, //!!! used to sort process control from
+                                    //!!! app control
+        EInstall            = 0x30,
+        EInstall_u          = 0x31,
+        EUnInstall          = 0x32,
+        EUnInstallName_u    = 0x33,
+        EUnInstallName      = 0x34,
+
+        ESisLastCommand = 0x3F, //!!! used to sort sis control from
+                                //!!! app control
+        //responses
+        EOk             = 0xF0,
+        ENotFound       = 0xF1,
+        EAlreadyRunning = 0xF2,
+        EAlreadyStopped = 0xF3,
+        ERunning        = 0xF4,
+        EKilled         = 0xF5,
+        EPanic          = 0xF6
+        };
+
+public:
+    static CHtiAppControl* NewL();
+
+    // Interface implementation
+    void ProcessMessageL(const TDesC8& aMessage,
+                         THtiMessagePriority aPriority);
+
+protected:
+    CHtiAppControl();
+    void ConstructL();
+
+    virtual ~CHtiAppControl();
+    
+    void HandleAppControlL(const TDesC8& aMessage);
+    void HandleInstallerControlL( const TDesC8& aMessage );
+    /**
+    * Extracts string from incoming request and convert it to unicode
+    * for non-unicode request
+    * aResult should have enough maz length and it will contain
+    * Function returns either offset for a next parameter in aRequest
+    * or some symbian error code
+    */
+    TInt ParseString( const TDesC8& aRequest,
+                      TInt anOffset,
+                      TBool aUnicode,
+                      TDes& aResult);
+
+    //command handlers
+    void HandleStartProcessL( const TDesC& aProgramName,
+                              const TDesC& aCmdLine,
+                              TBool aStoreProcessHandle );
+
+    void HandleStopProcessL( RProcess& aProcess );
+    void HandleStatusProcessL( RProcess& aProcess );
+
+    void HandleListProcessesL( const TDesC& aMatch );
+
+    void HandleStartAppL( TApaAppInfo &aAppInfo, const TDesC& aDocName );
+
+    void HandleListAppsL( TBool aIncludeHidden,
+                          TBool aIncludeSystem,
+                          TBool aUnicode );
+
+    void HandleListInstalledAppsL( TBool aUnicode );
+
+    //construct and send short message
+    void SendMessageL(TAppCommand aResponseCode, const TDesC8& aMsg = KNullDesC8 );
+
+    /**
+    * Helper to send error message
+    * @return KErrNone or some system-wide error code
+    */
+    inline TInt SendErrorMsg( TInt anError, const TDesC8& aMsg );
+
+    /**
+    *
+    */
+    TInt OpenProcessL( RProcess& aProcess, const TDesC& aMatch );
+    TInt OpenProcessL( RProcess& aProcess, const TUint32 aProcessId );
+
+    SwiUI::TPolicy ConvertToPolicy( const TInt8 aValue );
+    TInt GetPackageUidL( const TDesC& aPackageName, TInt aMimeIndex );
+
+    TBool ValidateInstallParams( const TDesC8& aParams, TBool aIsUnicode );
+
+    /**
+    * Find application based on its full path name and fill in aAppInfo
+    * @return KErrNone or KErrNotFound
+    */
+    TBool FindAppL( TApaAppInfo &aAppInfo, const TDesC& aAppFullName );
+    TBool FindAppL( TApaAppInfo &aAppInfo, const TInt32 aUid );
+
+    /**
+     * Find a task running the application specified by the UID as a root app
+     * (i.e. not embedded.
+     * @param aAppUid the UID of the application to find
+     * @return the found task or an empty task if not found
+     */
+    TApaTask FindRunningRootApp( TUid aAppUid );
+
+    /**
+    * Convert string to T 32bit int (e.g. TUint, TInt32)
+    */
+    template<class T> T Parse32( const TDesC8& a32int);
+
+protected:
+
+    // Session to Window Server
+    RWsSession iWs;
+
+    // Session to Application Architecture Server
+    RApaLsSession iAppServer;
+
+    // A flag that is set to EFalse if connecting to Window Server or
+    // Application Architecture Server fails. In that case all application
+    // related commands will return a "not supported" error.
+    TBool iIsAppCmdsSupported;
+
+    // Container array for process handles for querying the process exit codes
+    RArray<RProcess> iProcessHandleArray;
+
+    // possible mimetypes for silent software uninstallation
+    CDesC8ArrayFlat* iMimeTypes;
+
+    SwiUI::TInstallOptions iInstOpts;
+    SwiUI::TInstallOptionsPckg iInstOptsPckg;
+    SwiUI::TUninstallOptions iUnInstOpts;
+    SwiUI::TUninstallOptionsPckg iUnInstOptsPckg;
+    RPointerArray<Swi::CSisRegistryPackage> iAugmentations;
+    TInt iAugmentationIndex;
+    };
+
+#endif
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiAppServicePlugin/src/HtiAppControl.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,1727 @@
+/*
+* 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:  HtiAppControl implementation
+*
+*/
+
+
+// INCLUDE FILES
+#include "../../../symbian_version.hrh"
+
+#include <apacmdln.h>
+#include <apgtask.h>
+#include <apgwgnam.h>
+#include <apmstd.h>
+
+#include <badesca.h>
+#include <f32file.h>
+
+#include "HtiAppControl.h"
+#include <HtiDispatcherInterface.h>
+#include <HTILogging.h>
+
+#include <swinstapi.h>
+#include <swi/sisregistrysession.h>
+#include <swi/sisregistrypackage.h>
+#if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 )
+    #include <javaregistryincludes.h>
+#endif
+#include <widgetregistryclient.h>
+
+#if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 )
+    using namespace Java;
+#endif
+
+// CONSTANTS
+const static TUid KAppServiceUid = { 0x1020DEC7 }; //This is Uid of AppServiceOS
+
+//error descriptions
+_LIT8( KErrDescrNoMemory, "No memory" );
+_LIT8( KErrDescrInvalidCmd, "Invalid command" );
+_LIT8( KErrDescrInvalidArguments, "Invalid arguments" );
+_LIT8( KErrDescrFailedCreateProcess, "Failed create process" );
+_LIT8( KErrDescrNotSupported, "Command not supported" );
+
+_LIT8( KErrDescrFailedStartApp, "Failed start app" );
+_LIT8( KErrDescrInvalidUid, "Invalid application uid" );
+_LIT8( KErrDescrFailedFindApp, "Failed find app" );
+
+_LIT8( KErrDescrFailedConnectSilentInstaller, "Failed to connect to silent installer" );
+_LIT8( KErrDescrFailedInstall, "Failed to install" );
+_LIT8( KErrDescrFailedUnInstall, "Failed to uninstall" );
+_LIT8( KErrDescrFailedFindPackage, "Failed to find the package" );
+
+_LIT8( KErrDescrFailedListInstApps, "Failed to list installed apps" );
+
+const static TUint8 KUnicodeMask = 0x01;
+const static TInt KTerminateReason = 0;
+const static TInt KTUintLength = sizeof(TUint);
+const static TInt KCloseTaskDelay = 250000; // microseconds
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================ MEMBER FUNCTIONS ===============================
+CHtiAppControl* CHtiAppControl::NewL()
+    {
+    CHtiAppControl* self = new ( ELeave ) CHtiAppControl;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// Constructor
+CHtiAppControl::CHtiAppControl():iIsAppCmdsSupported( EFalse )
+    {
+    }
+
+EXPORT_C CHtiAppControl* NewHtiAppControl()
+    {
+    return CHtiAppControl::NewL();
+    }
+
+CHtiAppControl::~CHtiAppControl()
+    {
+    HTI_LOG_FUNC_IN( "~CHtiAppControl" );
+
+    for ( TInt i = 0; i < iProcessHandleArray.Count(); i++ )
+        {
+        iProcessHandleArray[i].Close();
+        }
+    iProcessHandleArray.Close();
+
+    iAppServer.Close();
+    iWs.Close();
+
+    if ( iMimeTypes )
+        {
+        iMimeTypes->Reset();
+        delete iMimeTypes;
+        }
+
+    iAugmentations.ResetAndDestroy();
+
+    HTI_LOG_FUNC_OUT( "~CHtiAppControl" );
+    }
+
+// Second phase construction.
+void CHtiAppControl::ConstructL()
+    {
+    HTI_LOG_FUNC_IN( "CHtiAppControl::ConstructL" );
+    iMimeTypes = new (ELeave) CDesC8ArrayFlat( 8 );
+    iMimeTypes->AppendL( SwiUI::KSisxMimeType() );
+    iMimeTypes->AppendL( SwiUI::KSisMimeType() );
+    iMimeTypes->AppendL( SwiUI::KPipMimeType() );
+    iMimeTypes->AppendL( SwiUI::KJadMIMEType() );
+    iMimeTypes->AppendL( SwiUI::KJarMIMEType() );
+    iMimeTypes->AppendL( SwiUI::KJavaMIMEType() );
+    iMimeTypes->AppendL( SwiUI::KJarxMIMEType() );
+    iMimeTypes->AppendL( KWidgetMime() ); // from widgetregistryconstants.h
+    iAugmentationIndex = 0;
+
+    TInt err = iAppServer.Connect();
+    if ( err == KErrNone )
+        {
+        err = iWs.Connect();
+        }
+    if ( err == KErrNone )
+        {
+        iIsAppCmdsSupported = ETrue;
+        }
+    else
+        {
+        iAppServer.Close();
+        }
+    HTI_LOG_FUNC_OUT( "CHtiAppControl::ConstructL" );
+    }
+
+TInt CHtiAppControl::ParseString( const TDesC8& aRequest,
+                                        TInt anOffset,
+                                        TBool aUnicode,
+                                        TDes& aResult )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAppControl::ParseString" );
+    //validate parameters
+    //if offset outside the string return empty string
+    if ( anOffset >= aRequest.Size() )
+        {
+        return anOffset;
+        }
+
+    TInt len = aRequest[anOffset];
+    HTI_LOG_FORMAT( "length %d", len );
+
+    if ( len > aResult.MaxLength() )
+        {
+        return KErrBadDescriptor;
+        }
+
+    TInt nextOffset = ( aUnicode ? len * 2 : len ) + anOffset + 1;
+    HTI_LOG_FORMAT( "nextOffset %d", nextOffset );
+    HTI_LOG_FORMAT( "reqSize %d", aRequest.Size() );
+    if ( nextOffset > aRequest.Size() )
+        {
+        return KErrArgument;
+        }
+
+    if ( aUnicode )
+        {
+        const TPtrC8 aFrom( aRequest.Mid( anOffset + 1, len * 2 ) );
+        aResult.SetLength( len );
+        for ( TInt i = 0; i < len; ++i )
+            {
+            aResult[i] = ( TUint16 ) aFrom[i << 1] +
+                ( ( ( TUint16 ) aFrom[( i << 1 ) + 1] ) << 8 );
+            }
+        }
+    else
+        {
+        aResult.Copy( aRequest.Mid( anOffset + 1, len ) );
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiAppControl::ParseString" );
+    return nextOffset;
+    }
+
+void CHtiAppControl::ProcessMessageL( const TDesC8& aMessage,
+                THtiMessagePriority /*aPriority*/ )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAppControl::ProcessMessage" );
+    if ( aMessage.Length() < 1 )
+        {
+        // no command
+        SendErrorMsg( KErrArgument, KErrDescrInvalidCmd );
+        return;
+        }
+
+    if ( aMessage.Length() < 2 &&
+         aMessage[0] !=  EListInstalledApps &&
+         aMessage[0] !=  EListInstalledApps_u)
+        {
+         // parameter is required with all commands except
+         // listing processes or installed applications
+        SendErrorMsg( KErrArgument, KErrDescrInvalidCmd );
+        return;
+        }
+
+    HTI_LOG_FORMAT( "cmd %d", aMessage[0] );
+
+    if ( aMessage[0] > EProcessLastCommand &&
+              aMessage[0] < EAppLastCommand)
+        {
+        if ( iIsAppCmdsSupported )
+            {
+            HandleAppControlL( aMessage );
+            }
+        else
+            {
+            SendErrorMsg( KErrNotSupported, KErrDescrNotSupported );
+            }
+        }
+    else if ( aMessage[0] > EAppLastCommand &&
+              aMessage[0] < ESisLastCommand )
+        {
+        HandleInstallerControlL( aMessage );
+        }
+    else
+        {
+        SendErrorMsg( KErrArgument, KErrDescrInvalidCmd );
+        }
+    HTI_LOG_FUNC_OUT( "CHtiAppControl::ProcessMessage" );
+    }
+
+void CHtiAppControl::HandleAppControlL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAppControl::HandleAppControl" );
+
+    TBool unicode = aMessage[0] & KUnicodeMask;
+
+    HTI_LOG_FORMAT( "unicode %d", unicode );
+
+    TApaAppInfo appInfo;
+    TFileName appName;
+    TFileName docName;
+
+    switch ( aMessage[0] )
+        {
+        case EStartApp_uid:
+        case EStartApp_uid_u:
+            {
+            TPtrC8 parameters = aMessage.Mid( 1 );
+            if ( parameters.Length() >= 4 )
+                {
+                TInt32 uid = Parse32<TInt32>( parameters );
+
+                TInt offset = ParseString( parameters, 4, unicode, docName );
+                if ( offset >= 0)
+                    {
+                    if ( FindAppL( appInfo, uid ) )
+                        {
+                        HandleStartAppL( appInfo, docName );
+                        }
+                    }
+                else
+                    {
+                    SendErrorMsg( offset , KErrDescrInvalidArguments );
+                    }
+                }
+            else
+                {
+                SendErrorMsg( KErrArgument , KErrDescrInvalidUid );
+                }
+            }
+            break;
+        case EStartApp:
+        case EStartApp_u:
+            {
+            TInt offset = ParseString( aMessage, 1, unicode, appName );
+            if ( offset >= 0 )
+                {
+                offset = ParseString( aMessage, offset, unicode, docName );
+                if ( offset >= 0 )
+                    {
+                    //find appInfo by app full name
+                    if ( FindAppL( appInfo, appName ) )
+                        {
+                        HTI_LOG_TEXT( "call HandleStartAppL" );
+                        HandleStartAppL( appInfo, docName );
+                        }
+                    }
+                }
+
+            if ( offset < 0 )
+                {
+                SendErrorMsg( offset , KErrDescrInvalidArguments );
+                }
+            }
+            break;
+        case EStartDoc:
+        case EStartDoc_u:
+            {
+            TInt offset = ParseString( aMessage, 1, unicode, docName );
+            if ( offset >= 0 )
+                {
+                HandleStartAppL( appInfo, docName ); //appInfo is empty
+                }
+            else
+                {
+                SendErrorMsg( offset , KErrDescrInvalidArguments );
+                }
+            }
+            break;
+        case EStatusApp_uid:
+            {
+            TPtrC8 appUid8 = aMessage.Mid( 1 );
+            if ( appUid8.Length() == 4 )
+                {
+                TApaTaskList tl( iWs );
+                TInt32 appUid = Parse32<TInt32>( appUid8 );
+                TApaTask task = tl.FindApp( TUid::Uid( appUid ) );
+                if ( task.Exists() )
+                    {
+                    SendMessageL( ERunning );
+                    }
+                else
+                    {
+                    SendMessageL( ENotFound );
+                    }
+                }
+            else
+                {
+                SendErrorMsg( KErrArgument, KErrDescrInvalidUid );
+                }
+            }
+            break;
+        case EStatusApp:
+        case EStatusApp_u:
+            {
+            TInt offset = ParseString( aMessage, 1, unicode, appName );
+            if ( offset >= 0 )
+                {
+                TApaTaskList tl( iWs );
+                TApaTask task = tl.FindApp( appName );
+                if ( task.Exists() )
+                    {
+                    SendMessageL( ERunning );
+                    break; // we are done
+                    }
+
+                // Maybe the user gave path or filename instead of caption
+                if ( FindAppL( appInfo, appName ) )
+                    {
+                    TApaTask task2 = tl.FindApp( appInfo.iUid );
+                    if ( task2.Exists() )
+                        {
+                        SendMessageL( ERunning );
+                        }
+                    else
+                        {
+                        SendMessageL( ENotFound );
+                        }
+                    }
+                // If app was not found by FindAppL method, a response message
+                // has already been sent there - no need to send anything here.
+                }
+            else
+                {
+                SendErrorMsg( offset , KErrDescrInvalidArguments );
+                }
+            }
+            break;
+        case EStatusDoc:
+        case EStatusDoc_u:
+            {
+            TInt offset = ParseString( aMessage, 1, unicode, docName );
+            if ( offset >= 0 )
+                {
+                TApaTaskList tl( iWs );
+                TApaTask task = tl.FindDoc( docName );
+                if ( task.Exists() )
+                    {
+                    SendMessageL( ERunning );
+                    }
+                else
+                    {
+                    SendMessageL( ENotFound );
+                    }
+                }
+            else
+                {
+                SendErrorMsg( offset , KErrDescrInvalidArguments );
+                }
+            }
+            break;
+        case EStopApp:
+        case EStopApp_u:
+            {
+            TInt offset = ParseString( aMessage, 1, unicode, appName );
+            if ( offset >= 0 )
+                {
+                TApaTaskList tl( iWs );
+                TApaTask task = tl.FindApp( appName );
+                if ( task.Exists() )
+                    {
+                    task.EndTask();
+                    User::After( KCloseTaskDelay );
+                    TApaTask task = tl.FindApp( appName );
+                    if ( task.Exists() )
+                        {
+                        task.KillTask();
+                        }
+                    SendMessageL( EOk );
+                    break; // we are done
+                    }
+
+                // Maybe the user gave path or filename instead of caption
+                if ( FindAppL( appInfo, appName ) )
+                    {
+                    TApaTask task2 = tl.FindApp( appInfo.iUid );
+                    if ( task2.Exists() )
+                        {
+                        task2.EndTask();
+                        User::After( KCloseTaskDelay );
+                        TApaTask task2 = tl.FindApp( appInfo.iUid );
+                        if ( task2.Exists() )
+                            {
+                            task2.KillTask();
+                            }
+                        SendMessageL( EOk );
+                        }
+                    else
+                        {
+                        SendMessageL( ENotFound );
+                        }
+                    }
+                // If app was not found by FindAppL method, a response message
+                // has already been sent there - no need to send anything here.
+                }
+            else
+                {
+                SendErrorMsg( offset , KErrDescrInvalidArguments );
+                }
+            }
+            break;
+        case EStopDoc:
+        case EStopDoc_u:
+            {
+            TInt offset = ParseString( aMessage, 1, unicode, docName );
+            if ( offset >= 0 )
+                {
+                TApaTaskList tl( iWs );
+                TApaTask task = tl.FindDoc( docName );
+                if ( task.Exists() )
+                    {
+                    task.EndTask();
+                    User::After( KCloseTaskDelay );
+                    TApaTask task = tl.FindDoc( docName );
+                    if ( task.Exists() )
+                        {
+                        task.KillTask();
+                        }
+                    SendMessageL( EOk );
+                    }
+                else
+                    {
+                    SendMessageL( ENotFound );
+                    }
+                }
+            else
+                {
+                SendErrorMsg( offset , KErrDescrInvalidArguments );
+                }
+            }
+            break;
+        case EStopApp_uid:
+            {
+            TPtrC8 appUid8 = aMessage.Mid( 1 );
+            if ( appUid8.Length() == 4 )
+                {
+                TApaTaskList tl( iWs );
+                TInt32 appUid = Parse32<TInt32>( appUid8 );
+                TApaTask task = tl.FindApp( TUid::Uid( appUid ) );
+                if ( task.Exists() )
+                    {
+                    task.EndTask();
+                    User::After(KCloseTaskDelay);
+                    TApaTask task = tl.FindApp( TUid::Uid( appUid ) );
+                    if ( task.Exists() )
+                        {
+                        task.KillTask();
+                        }
+                    SendMessageL( EOk );
+                    }
+                else
+                    {
+                    SendMessageL( ENotFound );
+                    }
+                }
+            else
+                {
+                SendErrorMsg( KErrArgument , KErrDescrInvalidUid );
+                }
+            }
+            break;
+        case EListApps:
+        case EListApps_u:
+            {
+            if ( aMessage.Length() != 3 )
+                {
+                SendErrorMsg( KErrArgument, KErrDescrInvalidArguments );
+                }
+            else
+                {
+                HandleListAppsL( aMessage[1], aMessage[2], unicode );
+                }
+            }
+            break;
+        case EListInstalledApps:
+        case EListInstalledApps_u:
+            {
+            if ( aMessage.Length() != 1 )
+                {
+                SendErrorMsg( KErrArgument, KErrDescrInvalidArguments );
+                }
+            else
+                {
+                HandleListInstalledAppsL( unicode );
+                }
+            }
+            break;
+        default:
+            {
+            SendErrorMsg( KErrArgument, KErrDescrInvalidCmd );
+            }
+        }
+
+    HTI_LOG_FUNC_OUT("CHtiAppControl::HandleAppControl");
+    }
+
+void CHtiAppControl::HandleInstallerControlL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAppControl::HandleInstallerControlL" );
+
+    if ( aMessage.Length() < 2 )
+        {
+        HTI_LOG_TEXT( "Command parameters missing" );
+        SendErrorMsg( KErrArgument , KErrDescrInvalidCmd );
+        return;
+        }
+
+    TBool unicode = aMessage[0] & KUnicodeMask;
+    HTI_LOG_FORMAT( "Unicode flag: %d", unicode );
+
+    TFileName path;
+    TBuf<SwiUI::KSWInstMaxPasswordLength> login;
+    TBuf<SwiUI::KSWInstMaxPasswordLength> password;
+
+    switch ( aMessage[0] )
+        {
+        case EInstall:
+        case EInstall_u:
+            {
+            TPtrC8 parameters = aMessage.Mid( 1 );
+            if ( ValidateInstallParams( parameters, unicode ) )
+                {
+                TInt offset = ParseString( parameters, 0, unicode, path );
+
+                HTI_LOG_TEXT( "Parsed path to install package:" );
+                HTI_LOG_DES( path )
+
+                if ( offset >= 0)
+                    {
+                    iInstOpts = SwiUI::TInstallOptions();
+
+                    iInstOpts.iUpgrade =            ConvertToPolicy( parameters[offset] ); offset++;
+                    iInstOpts.iOptionalItems =      ConvertToPolicy( parameters[offset] ); offset++;
+                    iInstOpts.iOCSP =               ConvertToPolicy( parameters[offset] ); offset++;
+                    iInstOpts.iIgnoreOCSPWarnings = ConvertToPolicy( parameters[offset] ); offset++;
+                    iInstOpts.iUntrusted =          ConvertToPolicy( parameters[offset] ); offset++;
+                    iInstOpts.iPackageInfo =        ConvertToPolicy( parameters[offset] ); offset++;
+                    iInstOpts.iCapabilities =       ConvertToPolicy( parameters[offset] ); offset++;
+                    iInstOpts.iKillApp =            ConvertToPolicy( parameters[offset] ); offset++;
+                    iInstOpts.iOverwrite =          ConvertToPolicy( parameters[offset] ); offset++;
+                    iInstOpts.iDownload =           ConvertToPolicy( parameters[offset] ); offset++;
+
+                    HTI_LOG_FORMAT( "iUpgrade: %d",            iInstOpts.iUpgrade );
+                    HTI_LOG_FORMAT( "iOptionalItems: %d",      iInstOpts.iOptionalItems );
+                    HTI_LOG_FORMAT( "iOCSP: %d",               iInstOpts.iOCSP );
+                    HTI_LOG_FORMAT( "iIgnoreOCSPWarnings: %d", iInstOpts.iIgnoreOCSPWarnings );
+                    HTI_LOG_FORMAT( "iUntrusted: %d",          iInstOpts.iUntrusted );
+                    HTI_LOG_FORMAT( "iPackageInfo: %d",        iInstOpts.iPackageInfo );
+                    HTI_LOG_FORMAT( "iCapabilities: %d",       iInstOpts.iCapabilities );
+                    HTI_LOG_FORMAT( "iKillApp: %d",            iInstOpts.iKillApp );
+                    HTI_LOG_FORMAT( "iOverwrite: %d",          iInstOpts.iOverwrite );
+                    HTI_LOG_FORMAT( "iDownload: %d",           iInstOpts.iDownload );
+
+                    offset = ParseString( parameters, offset, unicode, login );
+                    iInstOpts.iLogin.Copy( login );
+                    HTI_LOG_TEXT( "Parsed login:" );
+                    HTI_LOG_DES( login )
+
+                    offset = ParseString( parameters, offset, unicode, password );
+                    iInstOpts.iPassword.Copy( password );
+                    HTI_LOG_TEXT( "Parsed password:" );
+                    HTI_LOG_DES( password )
+
+                    iInstOpts.iDrive =        (TChar) parameters[offset]; offset++;
+                    iInstOpts.iLang =         (TLanguage) parameters[offset]; offset++;
+                    iInstOpts.iUsePhoneLang = (TBool) parameters[offset]; offset++;
+                    iInstOpts.iUpgradeData =  ConvertToPolicy( parameters[offset] );
+
+                    HTI_LOG_FORMAT( "iDrive: %c",        iInstOpts.iDrive.GetLowerCase() );
+                    HTI_LOG_FORMAT( "iLang: %d",         iInstOpts.iLang );
+                    HTI_LOG_FORMAT( "iUsePhoneLang: %d", iInstOpts.iUsePhoneLang );
+                    HTI_LOG_FORMAT( "iUpgradeData: %d",  iInstOpts.iUpgradeData );
+
+                    iInstOptsPckg = iInstOpts;
+
+                    // Connect to silent installer
+                    SwiUI::RSWInstSilentLauncher launcher;
+                    TInt err = launcher.Connect();
+                    if ( err )
+                        {
+                        HTI_LOG_FORMAT( "Error connecting to silent installer, err: %d", err );
+                        SendErrorMsg( err , KErrDescrFailedConnectSilentInstaller );
+                        break;
+                        }
+
+                    err = launcher.SilentInstall( path, iInstOptsPckg );
+                    if ( err )
+                        {
+                        HTI_LOG_FORMAT( "Error installing software, err: %d", err );
+                        launcher.Close();
+                        SendErrorMsg( err , KErrDescrFailedInstall );
+                        break;
+                        }
+
+                    launcher.Close();
+                    SendMessageL( EOk );
+                    }
+                else
+                    {
+                    HTI_LOG_TEXT( "Error parsing path" );
+                    SendErrorMsg( offset , KErrDescrInvalidArguments );
+                    }
+                }
+            else
+                {
+                SendErrorMsg( KErrArgument, KErrDescrInvalidCmd );
+                }
+            }
+            break;
+
+        case EUnInstall:
+        case EUnInstallName:
+        case EUnInstallName_u:
+            {
+            TPtrC8 parameters = aMessage.Mid( 1 );
+            if ( ( aMessage[0] == EUnInstall && parameters.Length() != 7 ) ||
+                 ( aMessage[0] == EUnInstallName &&
+                   parameters.Length() != parameters[0] + 4 ) ||
+                 ( aMessage[0] == EUnInstallName_u &&
+                   parameters.Length() != parameters[0] * 2 + 4 ) )
+                {
+                HTI_LOG_FORMAT( "Invalid command length: %d",
+                    parameters.Length() );
+                SendErrorMsg( KErrArgument, KErrDescrInvalidCmd );
+                break;
+                }
+
+            TInt offset = 0;
+            TInt32 uid = KErrNotFound;
+            HBufC* packageName = NULL;
+            if ( aMessage[0] == EUnInstall )
+                {
+                uid = Parse32<TInt32>( parameters );
+                offset += 4;
+                HTI_LOG_FORMAT( "Uninstall by uid: %d", uid );
+                }
+            else
+                {
+                packageName = HBufC::NewLC( parameters[offset] );
+                TPtr namePtr = packageName->Des();
+                offset = ParseString( parameters, offset, unicode, namePtr );
+                HTI_LOG_FORMAT( "Uninstall by name: %S", packageName );
+                }
+            iUnInstOpts = SwiUI::TUninstallOptions();
+            iUnInstOpts.iKillApp = ConvertToPolicy( parameters[offset] );
+            offset++;
+            iUnInstOpts.iBreakDependency = ConvertToPolicy( parameters[offset] );
+            offset++;
+            HTI_LOG_FORMAT( "iKillApp: %d",         iUnInstOpts.iKillApp );
+            HTI_LOG_FORMAT( "iBreakDependency: %d", iUnInstOpts.iBreakDependency );
+
+            TInt mimeIndex = parameters[offset];
+            if ( mimeIndex > iMimeTypes->Count() - 1 )
+                {
+                HTI_LOG_FORMAT( "Invalid mime type: %d", mimeIndex );
+                SendErrorMsg( KErrArgument, KErrDescrInvalidCmd );
+                break;
+                }
+
+            HTI_LOG_TEXT( "Uninstall mime type:" );
+            HTI_LOG_DES( (*iMimeTypes)[mimeIndex] );
+
+            TInt err = KErrNone;
+            iAugmentationIndex = 0;
+            if ( packageName )
+                {
+                TRAP( err, uid = GetPackageUidL( *packageName, mimeIndex ) );
+                CleanupStack::PopAndDestroy(); // packageName
+                iAugmentations.ResetAndDestroy();
+                if ( err != KErrNone )
+                    {
+                    SendErrorMsg( err, KErrDescrFailedFindPackage );
+                    break;
+                    }
+                }
+            HTI_LOG_FORMAT( "UID = %d", uid );
+
+            iUnInstOptsPckg = iUnInstOpts;
+
+            // Connect to silent installer
+            SwiUI::RSWInstSilentLauncher launcher;
+            err = launcher.Connect();
+            if ( err )
+                {
+                HTI_LOG_FORMAT( "Error connecting to silent installer, err: %d", err );
+                SendErrorMsg( err , KErrDescrFailedConnectSilentInstaller );
+                break;
+                }
+
+            if ( iAugmentationIndex > 0 )
+                {
+                SwiUI::TOpUninstallIndexParam params;
+                params.iUid = TUid::Uid( uid );
+                params.iIndex = iAugmentationIndex;
+                SwiUI::TOpUninstallIndexParamPckg paramPckg( params );
+                SwiUI::TOperation operation( SwiUI::EOperationUninstallIndex );
+                err = launcher.SilentCustomUninstall( operation, iUnInstOptsPckg,
+                    paramPckg, (*iMimeTypes)[mimeIndex] );
+                }
+            else
+                {
+                err = launcher.SilentUninstall( TUid::Uid( uid ), iUnInstOptsPckg,
+                        (*iMimeTypes)[mimeIndex] );
+                }
+
+            if ( err )
+                {
+                HTI_LOG_FORMAT( "Error uninstalling software, err: %d", err );
+                launcher.Close();
+                SendErrorMsg( err , KErrDescrFailedUnInstall );
+                break;
+                }
+
+            launcher.Close();
+            SendMessageL( EOk );
+            }
+            break;
+
+        default:
+            {
+            SendErrorMsg( KErrArgument, KErrDescrInvalidCmd );
+            }
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiAppControl::HandleInstallerControlL" );
+    }
+
+
+void CHtiAppControl::HandleStartProcessL( const TDesC& aProgramName,
+                                                const TDesC& aCmdLine,
+                                                TBool aStoreProcessHandle )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAppControl::HandleStartProcessL" );
+    HTI_LOG_FORMAT( "progr name %d", aProgramName.Length() );
+    HTI_LOG_DES( aProgramName );
+
+    RProcess process;
+    TInt err = process.Create( aProgramName, aCmdLine ); // command parameters
+
+    if ( err == KErrNone )
+        {
+        CleanupClosePushL( process );
+
+        //convert process id to binary des
+        TUint processId = process.Id();
+        HTI_LOG_FORMAT( "process id %d", processId );
+
+        TBuf8<KTUintLength> processIdDes;
+        processIdDes.Append(
+                ( TUint8* )( &processId ), KTUintLength );
+
+        SendMessageL( EOk, processIdDes );
+
+        process.Resume();
+
+        if ( aStoreProcessHandle )
+            {
+            HTI_LOG_TEXT( "Storing the process handle" );
+            iProcessHandleArray.Append( process );
+            CleanupStack::Pop();
+            }
+        else
+            {
+            CleanupStack::PopAndDestroy();
+            }
+        }
+    else if ( err == KErrNotFound )
+        {
+        SendMessageL( ENotFound );
+        }
+    else
+        {
+        SendErrorMsg( err ,KErrDescrFailedCreateProcess );
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiAppControl::HandleStartProcessL" );
+    }
+
+void CHtiAppControl::HandleStopProcessL( RProcess& aProcess )
+    {
+    if ( aProcess.ExitType() == EExitPending )
+        {
+        aProcess.Kill( KTerminateReason );
+        SendMessageL( EOk );
+        }
+    else
+        {
+        SendMessageL( EAlreadyStopped );
+        }
+    }
+
+void CHtiAppControl::HandleStatusProcessL( RProcess& aProcess )
+    {
+    TExitType exT = aProcess.ExitType();
+
+    switch ( exT )
+        {
+        case EExitPending:
+            {
+            SendMessageL( ERunning );
+            }
+            break;
+        case EExitKill:
+        case EExitTerminate:
+            {
+            SendMessageL( EKilled );
+            }
+            break;
+        case EExitPanic:
+            {
+            SendMessageL( EPanic );
+            }
+            break;
+        };
+    }
+
+
+void CHtiAppControl::HandleListProcessesL( const TDesC& aMatch )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAppControl::HandleListProcessesL" );
+
+    RProcess process;
+    TFullName processName;
+    TUint processId;
+    TBuf8<KTUintLength> processIdDes;
+    TExitType exitType;
+
+    TBuf8<128> buf;
+    CBufFlat* processListBuf = NULL;
+    TRAPD( err, processListBuf = CBufFlat::NewL( 128 ) );
+    if ( err )
+        {
+        SendErrorMsg( err ,KErrDescrNoMemory );
+        return;
+        }
+
+    CleanupStack::PushL( processListBuf );
+
+    // The default match pattern is the single character *
+    TFindProcess finder;
+
+    // if some real match pattern is defined, use it
+    if ( aMatch.Length() > 0 )
+        {
+        HTI_LOG_TEXT( "Match pattern was given:" );
+        HTI_LOG_DES( aMatch );
+        finder.Find( aMatch );
+        }
+
+    TInt pos = 0;
+    TUint numberOfEntries = 0;
+
+    while ( finder.Next( processName ) == KErrNone )
+        {
+        err = process.Open( finder );
+
+        //convert process id to binary des
+        processId = process.Id();
+        processIdDes.Append( ( TUint8* ) ( &processId ), KTUintLength );
+        buf.Append( processIdDes );
+
+        // status
+        exitType = process.ExitType();
+        switch ( exitType )
+            {
+            case EExitPending:
+                {
+                buf.Append( ERunning );
+                }
+                break;
+            case EExitKill:
+            case EExitTerminate:
+                {
+                buf.Append( EKilled );
+                }
+                break;
+            case EExitPanic:
+                {
+                buf.Append( EPanic );
+                }
+                break;
+            };
+
+        // name length
+        buf.Append( processName.Length() );
+
+        // name
+        buf.Append( processName );
+
+        process.Close();
+
+        TRAP( err, processListBuf->ExpandL( pos, buf.Length() ) );
+        if ( err )
+            {
+            SendErrorMsg( err , KErrDescrNoMemory );
+            delete processListBuf;
+            return;
+            }
+        processListBuf->Write( pos, buf, buf.Length() );
+
+        pos += buf.Length();
+        buf.Zero();
+        processIdDes.Zero();
+        numberOfEntries++;
+        }
+
+    // insert the number of entries in the beginning
+    TBuf8<2> entries;
+    entries.Append( ( TUint8* ) ( &numberOfEntries ), 2 );
+    processListBuf->ExpandL( 0, 2 );
+    processListBuf->Write( 0, entries, 2 );
+
+    SendMessageL( EOk, processListBuf->Ptr( 0 ) );
+
+    CleanupStack::PopAndDestroy( processListBuf );
+
+    HTI_LOG_FUNC_OUT( "CHtiAppControl::HandleListProcessesL" );
+    }
+
+
+void CHtiAppControl::HandleStartAppL( TApaAppInfo &aAppInfo,
+                                            const TDesC& aDocName )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAppControl::HandleStartAppL" );
+
+    // Check if app is running as a root app (not embedded)
+    TApaTask task = FindRunningRootApp( aAppInfo.iUid );
+    if ( task.Exists() )
+        {
+        User::ResetInactivityTime();
+        task.BringToForeground();
+        SendMessageL( EAlreadyRunning );
+        }
+    else
+        {
+        TThreadId threadId;
+        TInt err = KErrNone;
+        if ( aAppInfo.iUid != TUid::Null() )
+            {
+            TApaAppCapabilityBuf capBuf;
+            err = iAppServer.GetAppCapability( capBuf, aAppInfo.iUid );
+            TApaAppCapability& caps = capBuf();
+            CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
+            cmdLine->SetExecutableNameL( aAppInfo.iFullName );
+            if ( caps.iLaunchInBackground )
+                {
+                cmdLine->SetCommandL( EApaCommandBackground );
+                HTI_LOG_TEXT( "Launching in background" );
+                }
+            else
+                {
+                if ( aDocName != KNullDesC )
+                    {
+                    cmdLine->SetCommandL( EApaCommandOpen );
+                    cmdLine->SetDocumentNameL( aDocName );
+                    HTI_LOG_TEXT( "Launching with document" );
+                    }
+                else
+                    {
+                    cmdLine->SetCommandL( EApaCommandRun );
+                    HTI_LOG_TEXT( "Launching without document" );
+                    }
+                }
+            err = iAppServer.StartApp( *cmdLine, threadId );
+            CleanupStack::PopAndDestroy( cmdLine );
+            }
+        else if ( aDocName != KNullDesC )
+            {
+            HTI_LOG_TEXT( "Launching a document" );
+            /*
+             * If the app that should handle the doc is already running, we
+             * try to switch the open file and bring it to foreground. Whether
+             * switching the file works depends on the application: It must
+             * implement CEikAppUi::OpenFileL() or CAknAppUi::OpenFileL() in S60.
+             */
+            TUid appUid;
+            TDataType dataType;
+            err = iAppServer.AppForDocument( aDocName, appUid, dataType );
+            if ( err == KErrNone )
+                {
+                TApaTask task = FindRunningRootApp( appUid );
+                if ( task.Exists() )
+                    {
+                    HTI_LOG_TEXT( "App for doc already running, switch file" );
+                    err = task.SwitchOpenFile( aDocName );
+                    task.BringToForeground();
+                    }
+                else
+                    {
+                    err = iAppServer.StartDocument( aDocName, threadId );
+                    }
+                }
+            }
+        else
+            {
+            User::Leave( KErrArgument );
+            }
+
+        if ( err == KErrNone )
+            {
+            User::ResetInactivityTime();
+            //convert thread id to string
+            TUint threadIdUint = threadId; //cast to UInt
+            TBuf8<KTUintLength> threadIdDes;
+            threadIdDes.Append( ( TUint8* )( &threadIdUint ), KTUintLength );
+            SendMessageL( EOk, threadIdDes );
+            }
+        else if ( err == KErrNotFound )
+            {
+            SendMessageL( ENotFound );
+            }
+        else
+            {
+            SendErrorMsg( err, KErrDescrFailedStartApp );
+            }
+        }
+    HTI_LOG_FUNC_OUT( "CHtiAppControl::HandleStartAppL" );
+    }
+
+void CHtiAppControl::HandleListInstalledAppsL( TBool aUnicode )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAppControl::HandleListInstalledAppsL" );
+
+    // max file name + max caption + max short caption + 7 constant bytes
+    TInt bufSize = KMaxFileName + 2 * KApaMaxAppCaption + 7;
+    if ( aUnicode )
+        {
+        bufSize *= 2;
+        }
+
+    CBufFlat* appListBuf = CBufFlat::NewL( bufSize );
+    CleanupStack::PushL( appListBuf );
+
+    HBufC8* appsArray = HBufC8::NewLC( bufSize );
+    TPtr8 appsArrayPtr = appsArray->Des();
+
+    TInt err = KErrNone;
+    err = iAppServer.GetAllApps();
+    if ( err != KErrNone )
+        {
+        SendErrorMsg( err, KErrDescrFailedListInstApps );
+        }
+    else
+        {
+        TApaAppInfo appInfo;
+        TInt pos( 0 );
+
+        // Add application count
+        TInt numOfEntries = 0;
+        iAppServer.AppCount( numOfEntries );
+
+        appsArrayPtr.Append( ( TUint8*) ( &numOfEntries ), 2 );
+
+        while ( iAppServer.GetNextApp( appInfo ) == KErrNone )
+            {
+            TUint appUidUint = appInfo.iUid.iUid;
+            appsArrayPtr.Append( ( TUint8* ) &appUidUint, KTUintLength );
+
+            // Add length of full name
+            appsArrayPtr.Append( appInfo.iFullName.Length() );
+            // Add full name if there is one
+            if ( appInfo.iFullName.Length() > 0 )
+                {
+                if ( aUnicode )
+                    {
+                    appsArrayPtr.Append( ( TUint8* ) appInfo.iFullName.Ptr(),
+                        appInfo.iFullName.Length() * 2 );
+                    }
+                else
+                    {
+                    appsArrayPtr.Append( appInfo.iFullName );
+                    }
+                }
+
+            // Add length of caption
+            appsArrayPtr.Append( appInfo.iCaption.Length() );
+            // Add caption if there is one
+            if ( appInfo.iCaption.Length() > 0 )
+                {
+                if ( aUnicode )
+                    {
+                    appsArrayPtr.Append( ( TUint8* ) appInfo.iCaption.Ptr(),
+                        appInfo.iCaption.Length() * 2 );
+                    }
+                else
+                    {
+                    appsArrayPtr.Append( appInfo.iCaption );
+                    }
+                }
+
+            // Add length of short caption
+            appsArrayPtr.Append( appInfo.iShortCaption.Length() );
+            // Add short caption if there is one
+            if ( appInfo.iShortCaption.Length() > 0 )
+                {
+                if ( aUnicode )
+                    {
+                    appsArrayPtr.Append( ( TUint8* ) appInfo.iShortCaption.Ptr(),
+                        appInfo.iCaption.Length() * 2 );
+                    }
+                else
+                    {
+                    appsArrayPtr.Append( appInfo.iShortCaption );
+                    }
+                }
+
+            // Add app info to response buffer
+            appListBuf->ExpandL( pos, appsArray->Length() );
+            appListBuf->Write( pos, *appsArray, appsArray->Length() );
+
+            pos += appsArray->Length();
+            appsArrayPtr.Zero();
+            }
+
+        SendMessageL( EOk, appListBuf->Ptr( 0 ) );
+        }
+
+    CleanupStack::PopAndDestroy( 2 ); //appListBuf, appsArray
+
+    HTI_LOG_FUNC_IN( "CHtiAppControl::HandleListInstalledAppsL" );
+    }
+
+void CHtiAppControl::HandleListAppsL( TBool aIncludeHidden,
+                                            TBool aIncludeSystem,
+                                            TBool aUnicode )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAppControl::HandleListAppsL" );
+
+    RArray<RWsSession::TWindowGroupChainInfo>* wgChain = new ( ELeave )
+                            RArray<RWsSession::TWindowGroupChainInfo>( 12 );
+    CleanupDeletePushL( wgChain );
+    CleanupClosePushL( *wgChain );
+    User::LeaveIfError( iWs.WindowGroupList( 0, wgChain ) );
+    TInt wgCount = wgChain->Count();
+
+    HTI_LOG_FORMAT( "%d Window Groups in the chain", wgCount );
+
+    TInt bufSize = 2 * KMaxFileName + 11; // caption & document + 11 constant bytes
+    if ( aUnicode )
+        {
+        bufSize *= 2;
+        }
+    CBufFlat* appListBuf = CBufFlat::NewL( bufSize );
+    CleanupStack::PushL( appListBuf );
+    HBufC8* buf = HBufC8::NewLC( bufSize );
+    TPtr8 bufPtr = buf->Des();
+
+    TInt pos = 0;
+    TInt numOfEntries = 0;
+
+    for ( TInt i = 0; i < wgCount; i++ )
+        {
+        const RWsSession::TWindowGroupChainInfo& info = ( *wgChain )[i];
+        CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC( iWs, info.iId );
+
+        HTI_LOG_FORMAT( "WG ID: %d", info.iId );
+        HTI_LOG_DES( wgName->WindowGroupName() );
+
+        // Info is returned only from root tasks and system and hidden tasks
+        // are included only if requested.
+        if ( info.iParentId <= 0 &&
+             ( !wgName->IsSystem() || aIncludeSystem ) &&
+             ( !wgName->Hidden() || aIncludeHidden ) )
+            {
+            // Add application UID
+            TUint appUidUint = wgName->AppUid().iUid;
+            bufPtr.Append( ( TUint8* ) &appUidUint, KTUintLength );
+
+            // Add caption
+            TPtrC caption = wgName->Caption();
+            bufPtr.Append( caption.Length() );
+            if ( caption.Length() > 0 )
+                {
+                if ( aUnicode )
+                    {
+                    bufPtr.Append(
+                        ( TUint8* ) caption.Ptr(), caption.Length() * 2 );
+                    }
+                else
+                    {
+                    bufPtr.Append( caption );
+                    }
+                }
+
+            // Add document name
+            TPtrC document = wgName->DocName();
+            bufPtr.Append( document.Length() );
+            if ( document.Length() > 0 )
+                {
+                if ( aUnicode )
+                    {
+                    bufPtr.Append(
+                        ( TUint8* ) document.Ptr(), document.Length() * 2 );
+                    }
+                else
+                    {
+                    bufPtr.Append( document );
+                    }
+                }
+
+            // Add Hidden flag
+            if ( wgName->Hidden() )
+                bufPtr.Append( 1 );
+            else
+                bufPtr.Append( 0 );
+
+            // Add System flag
+            if ( wgName->IsSystem() )
+                bufPtr.Append( 1 );
+            else
+                bufPtr.Append( 0 );
+
+            // Add Ready flag
+            if ( wgName->IsAppReady() )
+                bufPtr.Append( 1 );
+            else
+                bufPtr.Append( 0 );
+
+            // Add Busy flag
+            if ( wgName->IsBusy() )
+                bufPtr.Append( 1 );
+            else
+                bufPtr.Append( 0 );
+
+            // Add Shutdown response flag
+            if ( wgName->RespondsToShutdownEvent() )
+                bufPtr.Append( 1 );
+            else
+                bufPtr.Append( 0 );
+
+            // Add this task's info to response buffer
+            appListBuf->ExpandL( pos, buf->Length() );
+            appListBuf->Write( pos, *buf, buf->Length() );
+
+            pos += buf->Length();
+            bufPtr.Zero();
+            numOfEntries++;
+            } // if
+        CleanupStack::PopAndDestroy(); // wgName
+        } // for
+
+    CleanupStack::PopAndDestroy(); // buf
+
+    // Add number of entries to the beginning of the response
+    TBuf8<2> entries;
+    entries.Append( ( TUint8* ) ( &numOfEntries ), 2 );
+    appListBuf->ExpandL( 0, 2 );
+    appListBuf->Write( 0, entries, 2 );
+
+    SendMessageL( EOk, appListBuf->Ptr( 0 ) );
+
+    CleanupStack::PopAndDestroy( 3 ); // appListBuf, wgChain Close, wgChain delete
+
+    HTI_LOG_FUNC_OUT( "CHtiAppControl::HandleListAppsL" );
+    }
+
+TBool CHtiAppControl::FindAppL( TApaAppInfo& aAppInfo,
+                                    const TDesC& aAppFullName )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAppControl::FindAppL name" );
+    TInt err = KErrNone;
+    err = iAppServer.GetAllApps();
+    if ( err != KErrNone )
+        {
+        SendErrorMsg( err, KErrDescrFailedFindApp );
+        return EFalse;
+        }
+
+    TParse toFind;
+    err = toFind.SetNoWild( aAppFullName, NULL, NULL );
+    if ( err != KErrNone )
+        {
+        SendErrorMsg( err, KErrDescrFailedFindApp );
+        return EFalse;
+        }
+
+    TBool isFullName = ( toFind.DrivePresent() && toFind.PathPresent() );
+
+    while ( ( err = iAppServer.GetNextApp( aAppInfo) ) == KErrNone )
+        {
+        if ( isFullName )  // assume that full path has been given
+            {
+            if ( !aAppFullName.CompareF( aAppInfo.iFullName )  )
+                {
+                return ETrue;
+                }
+            }
+        else // assume that only filename has been given
+            {
+            TParsePtrC current( aAppInfo.iFullName );
+
+            // does the given filename contain extension
+            if ( toFind.ExtPresent() )
+                {
+                // compare with filename + extension
+                if ( !toFind.NameAndExt().CompareF( current.NameAndExt() ) )
+                    {
+                    return ETrue;
+                    }
+                }
+            else
+                {
+                // compare with filename only
+                if ( !toFind.Name().CompareF( current.Name() ) )
+                    {
+                    return ETrue;
+                    }
+                // Try to match the caption.
+                // For Java MIDlets the full name is like C:\270194328.fakeapp
+                // so we have to use caption to find MIDlets.
+                if ( !toFind.Name().CompareF( aAppInfo.iCaption ) )
+                    {
+                    return ETrue;
+                    }
+                }
+            }
+        }
+
+    if ( err == RApaLsSession::ENoMoreAppsInList )
+        {
+        SendMessageL( ENotFound );
+        }
+    else if ( err != KErrNone )
+        {
+        SendErrorMsg( err,KErrDescrFailedFindApp );
+        }
+    HTI_LOG_FUNC_OUT( "CHtiAppControl::FindAppL name" );
+    return EFalse;
+    }
+
+TBool CHtiAppControl::FindAppL( TApaAppInfo &aAppInfo,
+                                     const TInt32 aUid )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAppControl::FindAppL uid" );
+    TInt err = iAppServer.GetAppInfo( aAppInfo, TUid::Uid( aUid ) );
+    if ( err == KErrNone )
+        {
+        return ETrue;
+        }
+    else if ( err == KErrNotFound )
+        {
+        SendMessageL( ENotFound );
+        }
+    else
+        {
+        SendErrorMsg( err , KErrDescrFailedFindApp );
+        }
+    HTI_LOG_FUNC_OUT( "CHtiAppControl::FindAppL uid" );
+    return EFalse;
+    }
+
+TApaTask CHtiAppControl::FindRunningRootApp( TUid aAppUid )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAppControl::FindRunningRootApp" );
+    TApaTask task( iWs );
+    task.SetWgId( 0 ); // initialize to empty task
+
+    TInt wgId = 0; // on first call to FindByAppUid wgId must be zero
+    CApaWindowGroupName::FindByAppUid( aAppUid, iWs, wgId );
+    HTI_LOG_FORMAT( "FindByAppUid returned WG ID: %d", wgId );
+
+    RArray<RWsSession::TWindowGroupChainInfo> wgs;
+    TInt err = KErrNone;
+    TInt wgCount = 0;
+    if ( wgId != KErrNotFound )
+        {
+        // Get a list of Window Group Chain Infos
+        err = iWs.WindowGroupList( 0, &wgs ); // get only priority 0 WGs
+        wgCount = wgs.Count();
+        HTI_LOG_FORMAT( "WindowGroupList returned %d WGs", wgCount );
+        }
+    while ( wgId != KErrNotFound && task.WgId() == 0 && err == KErrNone )
+        {
+        // App was found - check if it is root by looping through the
+        // WG chain infos to find the one with out wgId
+        TInt i = 0;
+        while ( task.WgId() == 0 && i < wgCount )
+            {
+            const RWsSession::TWindowGroupChainInfo& info = wgs[i];
+            if ( info.iId == wgId && info.iParentId <= 0 )
+                {
+                // This is the one and it is root (does not have parent)
+                task.SetWgId( wgId );
+                }
+            i++;
+            }
+        if ( task.WgId() == 0 )
+            {
+            // This was not root - check if there's more instances of the app
+            CApaWindowGroupName::FindByAppUid( aAppUid, iWs, wgId );
+            HTI_LOG_FORMAT( "FindByAppUid returned WG ID: %d", wgId );
+            }
+        }
+
+    wgs.Close();
+    HTI_LOG_FORMAT( "Returning task with WG ID %d", task.WgId() );
+    HTI_LOG_FUNC_OUT( "CHtiAppControl::FindRunningRootApp" );
+    return task;
+    }
+
+TInt CHtiAppControl::OpenProcessL( RProcess& aProcess,
+                                         const TDesC& aMatch )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAppControl::OpenProcessL" );
+    TFullName processName;
+    TInt err = KErrNone;
+    TFindProcess finder( aMatch );
+
+    err = finder.Next( processName );
+    if ( err == KErrNone )
+        {
+        err = aProcess.Open( finder );
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiAppControl::OpenProcessL" );
+    return err;
+    }
+
+template<class T> T CHtiAppControl::Parse32(
+                        const TDesC8& a32int )
+    {
+    //manually construct TUint or TInt32
+    return T( a32int[0] + ( a32int[1] << 8 ) +
+                      ( a32int[2] << 16) + ( a32int[3] << 24) );
+    }
+
+void CHtiAppControl::SendMessageL( TAppCommand aResponseCode,
+                                         const TDesC8& aMsg )
+    {
+    HTI_LOG_FORMAT( "SendMessage %d", aResponseCode );
+    HTI_LOG_FORMAT( "Message len %d", aMsg.Length() );
+    HBufC8* sendMsg = HBufC8::NewL( 1 + aMsg.Length() );
+    CleanupStack::PushL( sendMsg );
+    sendMsg->Des().Append( aResponseCode );
+    sendMsg->Des().Append( aMsg );
+
+    User::LeaveIfError( iDispatcher->DispatchOutgoingMessage(
+                            sendMsg,
+                            KAppServiceUid ) );
+    CleanupStack::Pop();
+    }
+
+inline TInt CHtiAppControl::SendErrorMsg( TInt anError,
+                                                const TDesC8& aMsg )
+    {
+    return iDispatcher->DispatchOutgoingErrorMessage( anError,
+                                               aMsg,
+                                               KAppServiceUid );
+    }
+
+SwiUI::TPolicy CHtiAppControl::ConvertToPolicy( const TInt8 aValue )
+    {
+    if ( aValue == 0 ) return SwiUI::EPolicyNotAllowed;
+
+    return  SwiUI::EPolicyAllowed;
+    }
+
+TBool CHtiAppControl::ValidateInstallParams( const TDesC8& aParams, TBool aIsUnicode )
+    {
+    if ( aParams.Length() > 0 )
+        {
+        TInt offset = 0;
+        TInt length = aParams[offset]; // inst package path length;
+        if ( aIsUnicode ) length *= 2;
+        offset++;
+        if ( aParams.Length() < offset + length )
+            {
+            HTI_LOG_TEXT( "ValidateInstallParams: Failed, data missing in inst pkg path" );
+            return EFalse;
+            }
+
+        offset += length; // skip over inst package path
+        offset += 10;     // skip over the following one byte params
+
+        if ( aParams.Length() < offset )
+            {
+            HTI_LOG_TEXT( "ValidateInstallParams: Failed, data missing in one byte params" );
+            return EFalse;
+            }
+
+        length = aParams[offset]; // login username length;
+        if ( aIsUnicode ) length *= 2;
+        offset++;
+        if ( aParams.Length() < offset + length )
+            {
+            HTI_LOG_TEXT( "ValidateInstallParams: Failed, data missing in username" );
+            return EFalse;
+            }
+
+        offset += length; // skip over login username
+
+        length = aParams[offset]; // password length;
+        if ( aIsUnicode ) length *= 2;
+        offset++;
+        if ( aParams.Length() < offset + length )
+            {
+            HTI_LOG_TEXT( "ValidateInstallParams: Failed, data missing in password" );
+            return EFalse;
+            }
+
+        offset += length; // skip over password
+        offset += 4;      // the last one byte params
+
+        if ( aParams.Length() != offset )
+            {
+            HTI_LOG_TEXT( "ValidateInstallParams: Failed, final length incorrect" );
+            return EFalse;
+            }
+
+        return ETrue;
+        }
+
+    return EFalse;
+    }
+
+TInt CHtiAppControl::GetPackageUidL( const TDesC& aPackageName,
+                                          TInt aMimeIndex )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAppControl::GetPackageUidL" );
+
+    if ( aMimeIndex >= 0 && aMimeIndex < 2 ) // SIS
+        {
+        Swi::RSisRegistrySession regSession;
+        User::LeaveIfError( regSession.Connect() );
+        CleanupClosePushL( regSession );
+
+        RArray<TUid> uids;
+        CleanupClosePushL( uids );
+        regSession.InstalledUidsL( uids );
+        TInt count = uids.Count();
+        HTI_LOG_FORMAT( "Found %d SISx installations", count );
+        for ( TInt i = 0; i < count; i++ )
+            {
+            Swi::RSisRegistryEntry entry;
+            CleanupClosePushL( entry );
+            User::LeaveIfError( entry.Open( regSession, uids[i] ) );
+            if ( !entry.IsInRomL() && entry.IsPresentL() )
+                {
+                if ( aPackageName.Compare( *( entry.PackageNameL() ) ) == 0 )
+                    {
+                    HTI_LOG_TEXT( "Matching SIS package found" );
+                    TInt uid = entry.UidL().iUid;
+                    CleanupStack::PopAndDestroy( 3 ); // entry, uids, regSession
+                    return uid;
+                    }
+                }
+            // Check augmentations of this entry
+            entry.AugmentationsL( iAugmentations );
+            TInt augCount = iAugmentations.Count();
+            for ( TInt j = 0; j < augCount; j++ )
+                {
+                Swi::RSisRegistryEntry augmentation;
+                CleanupClosePushL( augmentation );
+                augmentation.OpenL( regSession, *iAugmentations[j] );
+                if ( aPackageName.Compare(
+                        *( augmentation.PackageNameL() ) ) == 0 )
+                    {
+                    if ( !augmentation.IsInRomL() && augmentation.IsPresentL() )
+                        {
+                        HTI_LOG_TEXT( "Matching SIS augmentation found" );
+                        TInt uid = augmentation.UidL().iUid;
+                        Swi::CSisRegistryPackage* pkg = augmentation.PackageL();
+                        iAugmentationIndex = pkg->Index();
+                        delete pkg;
+                        HTI_LOG_FORMAT( "Aug. index %d", iAugmentationIndex );
+                        CleanupStack::PopAndDestroy( 4 ); // augmentation, entry, uids, regSession
+                        return uid;
+                        }
+                    }
+                CleanupStack::PopAndDestroy(); // augmentation
+                } // for j
+            iAugmentations.ResetAndDestroy();
+            CleanupStack::PopAndDestroy(); // entry
+            } // for i
+        User::Leave( KErrNotFound );
+        }
+
+    else if ( aMimeIndex > 2 && aMimeIndex < 7 ) // Java
+        {
+        #if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 )
+            RArray<TUid> uids;
+            CleanupClosePushL( uids );
+
+            CJavaRegistry* javaRegistry = CJavaRegistry::NewLC();
+            javaRegistry->GetRegistryEntryUidsL( uids );
+
+            TInt uid = KErrNotFound;
+            TInt count = uids.Count();
+            HTI_LOG_FORMAT( "Found %d Java installations", count );
+            for ( TInt i = 0; i < count; i++ )
+                {
+                CJavaRegistryEntry* entry = javaRegistry->RegistryEntryL( uids[i] );
+                if ( entry )
+                    {
+                    CleanupStack::PushL( entry );
+                    if ( entry->Type() >= EGeneralPackage &&
+                            entry->Type() < EGeneralApplication )
+                        {
+                        // entry was a package (MIDlet suite)
+                        CJavaRegistryPackageEntry* packageEntry =
+                            ( CJavaRegistryPackageEntry* ) entry;
+                        if ( aPackageName.Compare( packageEntry->Name() ) == 0 )
+                            {
+                            HTI_LOG_TEXT( "Matching Java installation found" );
+                            uid = packageEntry->Uid().iUid;
+                            CleanupStack::PopAndDestroy( entry );
+                            break;
+                            }
+                        }
+                    CleanupStack::PopAndDestroy( entry );
+                    }
+                }
+            CleanupStack::PopAndDestroy( javaRegistry );
+            CleanupStack::PopAndDestroy( &uids );
+            User::LeaveIfError( uid );
+            return uid;
+        #else
+            User::Leave( KErrNotSupported );
+        #endif
+        }
+
+    else if ( aMimeIndex == 7 ) // Widget
+        {
+        RWidgetRegistryClientSession widgetRegistry;
+        User::LeaveIfError( widgetRegistry.Connect() );
+
+        RWidgetInfoArray widgets;
+        TRAPD( err, widgetRegistry.InstalledWidgetsL( widgets ) );
+        if ( err != KErrNone )
+            {
+            HTI_LOG_FORMAT( "Failed to get installed widgets %d", err );
+            widgets.ResetAndDestroy();
+            widgetRegistry.Disconnect();
+            User::Leave( err );
+            }
+
+        TInt uid = KErrNotFound;
+        TInt count = widgets.Count();
+        HTI_LOG_FORMAT( "Found %d Widget installations", count );
+        for ( TInt i = 0; i < count; i++ )
+            {
+            CWidgetInfo* widgetInfo = widgets[i];
+            HTI_LOG_DES( *( widgetInfo->iBundleName ) );
+            if ( aPackageName.Compare( *( widgetInfo->iBundleName ) ) == 0 )
+                {
+                HTI_LOG_TEXT( "Matching Widget installation found" );
+                uid = widgetInfo->iUid.iUid;
+                break;
+                }
+            }
+        widgets.ResetAndDestroy();
+        widgetRegistry.Disconnect();
+        User::LeaveIfError( uid );
+        return uid;
+        }
+
+    else  // invalid mime index
+        {
+        User::Leave( KErrArgument );
+        }
+
+    return KErrNone; // never returns from here
+    }
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiAudioServicePlugin/data/1020DEC8.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,66 @@
+/*
+* 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:  HTI service plugin for playing audio.
+*
+*/
+
+
+
+//  RESOURCE IDENTIFIER
+
+//  INCLUDES
+#include <ecom/registryinfo.rh>
+
+//  CONSTANTS
+
+//  MACROS
+
+
+//  RESOURCE DEFINITIONS
+// -----------------------------------------------------------------------------
+//
+// theInfo
+// ECom registry info resource.
+//
+// -----------------------------------------------------------------------------
+//
+
+RESOURCE REGISTRY_INFO theInfo
+    {
+    // UID for the DLL
+    dll_uid = 0x1020DEC8;
+    // Declare array of interface info
+    interfaces =
+        {
+        INTERFACE_INFO
+            {
+            // UID of interface that is implemented
+            interface_uid = 0x1020DEB7;
+            implementations =
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = 0x10210CCB;
+                    version_no         = 1;
+                    display_name       = "Audio Control Service";
+                    default_data       = "AUDIO";
+                    opaque_data        = "";
+                    }
+                };
+            }
+        };
+    }
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiAudioServicePlugin/group/HtiAudioServicePlugin.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,54 @@
+/*
+* 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:  HTI service plugin for controlling audio playback.
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET      HtiAudioServicePlugin.dll
+TARGETTYPE  PLUGIN
+
+// ECom Dll recognition UID followed by the unique UID for this dll
+UID 0x10009D8D 0x1020DEC8
+
+VENDORID    0x101FB657
+
+CAPABILITY      ALL -TCB
+
+SOURCEPATH  ../src
+SOURCE      proxy.cpp
+SOURCE      HtiAudioServicePlugin.cpp
+
+USERINCLUDE     ../inc
+APP_LAYER_SYSTEMINCLUDE
+
+START RESOURCE  ../data/1020DEC8.rss
+TARGET          HtiAudioServicePlugin.rsc
+END
+
+LIBRARY     apgrfx.lib  // RApaLsSession
+LIBRARY     apmime.lib  // TDataType
+LIBRARY     bafl.lib
+LIBRARY     ecom.lib
+LIBRARY     efsrv.lib
+LIBRARY     euser.lib
+LIBRARY     mediaclientaudio.lib
+LIBRARY     platformenv.lib
+LIBRARY     flogger.lib
+
+SMPSAFE
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiAudioServicePlugin/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  Build information file for HtiAudioServicePlugin
+*
+*/
+
+
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+HtiAudioServicePlugin.mmp
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiAudioServicePlugin/inc/HtiAudioServicePlugin.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,279 @@
+/*
+* 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:  Defines the ECom plugin for HTI audio playback control service.
+*
+*/
+
+
+
+#ifndef HTIAUDIOSERVICEPLUGIN_H
+#define HTIAUDIOSERVICEPLUGIN_H
+
+//  INCLUDES
+#include <badesca.h>
+#include <HTIServicePluginInterface.h>
+#include <MdaAudioSamplePlayer.h>
+#include <MdaAudioTonePlayer.h>
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+*  The ECom plugin for HTI audio playback control service.
+*
+*/
+class CHtiAudioServicePlugin : public CHTIServicePluginInterface,
+                               public MMdaAudioPlayerCallback,
+                               public MMdaAudioToneObserver
+    {
+
+    protected:
+        // commands
+        enum TAudioCommands
+            {
+            ECmdListAudioFiles = 0x01,
+            ECmdPlayFile       = 0x02,
+            ECmdPlayTone       = 0x03,
+            ECmdPlayDtmf       = 0x04,
+            ECmdStop           = 0x05,
+            ECmdGetDuration    = 0x06,
+            ECmdGetMaxVol      = 0x07,
+            ECmdSetVol         = 0x08
+            };
+
+        // audio setting options
+        enum TAudioSetting
+            {
+            EDefault,
+            EGeneralMusic,
+            ERingTonePreview,
+            //EIncomingCall,
+            EDtmfString
+            };
+
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CHtiAudioServicePlugin* NewL();
+
+    public: // New functions
+
+    public: // Functions from base classes
+
+        /**
+        * From CHTIServicePluginInterface
+        * Called by the HTI Framework when sending message to this service.
+        * @param aMessage message body destinated to a servive
+        * @param aPriority message priority
+        */
+        void ProcessMessageL( const TDesC8& aMessage,
+            THtiMessagePriority aPriority );
+
+        /**
+        * From CHTIServicePluginInterface
+        * Called by HTI Framework to tell the service how much memory is
+        * available for messages in the message queue.
+        * @param aAvailableMemory amount of currently available memory
+        *        in the message queue
+        */
+        void NotifyMemoryChange( TInt aAvailableMemory );
+
+        /**
+        * From CHTIServicePluginInterface
+        * Indicates to HTI Framework whether the plugin is ready to process
+        * a new message or if it's busy processing previous message.
+        */
+        TBool IsBusy();
+
+        /**
+        * From MMdaAudioToneObserver
+        * Handle the event when a tone utility initialisation
+        * operation has completed.
+        * @param aError indicates whether an error occurred.
+        */
+        void MatoPrepareComplete( TInt aError );
+
+        /**
+        * From MMdaAudioToneObserver
+        * Handle the event when a tone playing operation has completed.
+        * @param aError indicates whether an error occurred.
+        */
+        void MatoPlayComplete( TInt aError );
+
+        /**
+        * From MMdaAudioPlayerCallback
+        * Handle the event when initialisation of
+        * the audio player utility is complete.
+        * @param aError The status of the audio sample after initialisation
+        * @param aDuration The duration of the sample
+        */
+        void MapcInitComplete( TInt aError,
+                               const TTimeIntervalMicroSeconds& aDuration );
+
+        /**
+        * From MMdaAudioPlayerCallback
+        * Handle the event when when the audio player utility
+        * completes asynchronous playing.
+        * @param aError The status of playback
+        */
+        void MapcPlayComplete( TInt aError );
+
+
+    protected:  // New functions
+
+        /**
+        * C++ default constructor.
+        */
+        CHtiAudioServicePlugin();
+
+        /**
+        * 2nd phase constructor.
+        */
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CHtiAudioServicePlugin();
+
+
+    protected:  // Functions from base classes
+
+    private:
+
+        void HandleListAudioFilesCmdL( const TDesC8& aMessage );
+
+        void HandlePlayFileCmdL( const TDesC8&aMessage );
+
+        void HandlePlayToneCmdL( const TDesC8& aMessage );
+
+        void HandlePlayDtmfCmdL( const TDesC8& aMessage );
+
+        void HandleStopCmdL( const TDesC8& aMessage );
+
+        void HandleGetDurationCmdL( const TDesC8& aMessage );
+
+        void HandleGetMaxVolCmdL( const TDesC8& aMessage );
+
+        void HandleSetVolCmdL( const TDesC8& aMessage );
+
+        TInt ParseString( const TDesC8& aRequest,
+                               TInt aOffset, TDes& aResult );
+
+        TInt SendResponseMsg( const TDesC8& aMsg,
+                             const TUint8 aCommandId = 0  );
+
+        TInt SendErrorResponseMsg( TInt aErrorCode,
+                                   const TDesC8& aErrorDescription,
+                                   const TUint8 aCommandId = 0 );
+
+        void AddSubdirsRecursivelyL( const TDesC& aPath,
+                                    CDesCArraySeg& aArray, RFs& aFs );
+
+        TBool MatchMimeTypeL( const TDesC& aFilePath,
+                              const TDesC& aMimeTypeMatchPattern );
+
+        void SetAudioSettings( TAudioSetting aSetting );
+
+        inline TUint ParseUint16( const TUint8* aPtr )
+            {
+            return aPtr[0] + ( aPtr[1] << 8 );
+            }
+
+        inline TUint ParseUint32( const TUint8* aPtr )
+            {
+            return aPtr[0] + ( aPtr[1] << 8 )
+                           + ( aPtr[2] << 16 ) + ( aPtr[3] << 24 );
+            }
+
+
+    public:     // Data
+
+    protected:  // Data
+
+    private:    // Data
+        // Flag telling if the service is busy processing a message
+        TBool iIsBusy;
+
+        // Flag telling if audio or tone is currently playing
+        TBool iIsPlaying;
+
+        // Id of the latest command
+        TUint8 iCommandId;
+
+        // Id of the latest play command
+        TUint8 iPlayCommandId;
+
+        // Container for the response message to be dispatched out
+        HBufC8* iMessage;
+
+        // Error code in the outgoing error message
+        TInt iErrorCode;
+
+        // Audio player utility object
+        CMdaAudioPlayerUtility* iAudioPlayer;
+
+        // Tone player utility object
+        CMdaAudioToneUtility* iTonePlayer;
+
+        // Current volume value
+        TInt iVolume;
+
+        // Current repeat value
+        TInt iRepeats;
+
+        // Current trailing silence value
+        TInt iTrailingSilence;
+
+        // DTMF tone length
+        TInt iDtmfLength;
+
+        // Silence between DTMF tones
+        TInt iDtmfGapLength;
+
+        // Playback start position
+        TInt iStartPos;
+
+        // Playback end position
+        TInt iEndPos;
+
+        // Audio priority setting
+        TInt iAudioPriority;
+
+        // Audio priority preference setting
+        TMdaPriorityPreference iAudioPriorityPreference;
+
+
+    public:     // Friend classes
+
+    protected:  // Friend classes
+
+    private:    // Friend classes
+
+    };
+
+#endif      // HTIAUDIOSERVICEPLUGIN_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiAudioServicePlugin/src/HtiAudioServicePlugin.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,1672 @@
+/*
+* 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:  Implements the ECom plugin for HTI audio playback control
+*                service.
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <apgcli.h>
+#include <audiopreference.h>
+#include <bautils.h>
+#include <e32std.h>
+#include <HtiDispatcherInterface.h>
+#include <HTILogging.h>
+#include <PathInfo.h>
+
+#include "HtiAudioServicePlugin.h"
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES
+
+// CONSTANTS
+const static TInt KPlayToneCmdLength    = 13;
+const static TInt KStopCmdLength        = 1;
+const static TInt KSetVolCmdLength      = 2;
+const static TInt KListCmdMinLength     = 4;
+const static TInt KPlayDtmfCmdMinLength = 17;
+const static TInt KPlayFileCmdMinLength = 21;
+const static TInt KDurationCmdMinLength = 6;
+const static TInt KMaxVolCmdMinLength   = 6;
+
+const static TInt KTUintSize = sizeof( TUint );
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+const static TUid KAudioServiceUid = { 0x10210CCB };
+
+_LIT( KBackslash, "\\" );
+_LIT( KRngMimeType, "application/vnd.nokia.ringing-tone" );
+_LIT( KAudioMimeType, "audio/*" );
+
+// NOTE: Max length for error description is defined
+// in HtiDispatcherInterface.h (currently 118).
+_LIT8( KErrorNoCmd, "ERROR: No command given" );
+_LIT8( KErrorUnknownCmd, "ERROR: Unknown Audio Service command" );
+_LIT8( KErrorInvalidParameters,
+    "ERROR: Invalid parameter data for this command" );
+_LIT8( KErrorInvalidPath, "ERROR: Invalid path" );
+_LIT8( KErrorToneInitFailed, "ERROR: Tone initialization failed" );
+_LIT8( KErrorTonePlayFailed, "ERROR: Tone playing failed" );
+_LIT8( KErrorFileInitFailed, "ERROR: File playing initialization failed" );
+_LIT8( KErrorFilePlayFailed, "ERROR: File playing failed" );
+_LIT8( KErrorBusyPlaying, "ERROR: Currently busy playing" );
+_LIT8( KErrorNothingPlaying, "ERROR: Nothing playing" );
+_LIT8( KErrorDurationFailed, "ERROR: Duration query failed" );
+_LIT8( KErrorMaxVolFailed, "ERROR: Max volume query failed" );
+_LIT8( KErrorPosition, "ERROR: Invalid start or end position value" );
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CHtiAudioServicePlugin::CHtiAudioServicePlugin
+// C++ default constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+//
+CHtiAudioServicePlugin::CHtiAudioServicePlugin():iIsBusy( EFalse ),
+                                                 iIsPlaying( EFalse ),
+                                                 iCommandId( 0 ),
+                                                 iPlayCommandId( 0 ),
+                                                 iMessage( NULL ),
+                                                 iErrorCode( 0 ),
+                                                 iVolume( 0 ),
+                                                 iRepeats( 0 ),
+                                                 iTrailingSilence( 0 ),
+                                                 iDtmfLength( 0 ),
+                                                 iDtmfGapLength( 0 ),
+                                                 iStartPos( 0 ),
+                                                 iEndPos( 0 )
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiAudioServicePlugin::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CHtiAudioServicePlugin::ConstructL()
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiAudioServicePlugin::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CHtiAudioServicePlugin* CHtiAudioServicePlugin::NewL()
+    {
+    CHtiAudioServicePlugin* self = new (ELeave) CHtiAudioServicePlugin;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+
+// Destructor
+CHtiAudioServicePlugin::~CHtiAudioServicePlugin()
+    {
+    delete iMessage;
+    iMessage = NULL;
+    delete iAudioPlayer;
+    iAudioPlayer = NULL;
+    delete iTonePlayer;
+    iTonePlayer = NULL;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiAudioServicePlugin::ProcessMessageL
+// -----------------------------------------------------------------------------
+//
+void CHtiAudioServicePlugin::ProcessMessageL( const TDesC8& aMessage,
+                                        THtiMessagePriority /*aPriority*/ )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAudioServicePlugin::ProcessMessageL" );
+    HTI_LOG_FORMAT( "Message length = %d", aMessage.Length() );
+
+    if ( iIsBusy )
+        {
+        HTI_LOG_TEXT( "Plugin is busy - leaving" );
+        User::Leave( KErrInUse );
+        }
+
+    // Will be set to EFalse in the SendResponseMsg or SendErrorResponseMsg
+    // methods when the response has been successfully sent and the plugin is
+    // ready for next message.
+    iIsBusy = ETrue;
+
+    if ( aMessage.Length() < 1 )
+        {
+        User::LeaveIfError(
+            SendErrorResponseMsg( KErrArgument, KErrorNoCmd ) );
+        return;
+        }
+
+    iCommandId = aMessage[0];
+    HTI_LOG_FORMAT( "Command = %d", iCommandId );
+    TInt err = KErrNone;
+
+    if ( iCommandId == ECmdListAudioFiles )
+        {
+        TRAP( err, HandleListAudioFilesCmdL( aMessage ) );
+        }
+
+    else if ( iCommandId == ECmdPlayFile )
+        {
+        TRAP( err, HandlePlayFileCmdL( aMessage ) );
+        }
+
+    else if ( iCommandId == ECmdPlayTone )
+        {
+        TRAP( err, HandlePlayToneCmdL( aMessage ) );
+        }
+
+    else if ( iCommandId == ECmdPlayDtmf )
+        {
+        TRAP( err, HandlePlayDtmfCmdL( aMessage ) );
+        }
+
+    else if ( iCommandId == ECmdStop )
+        {
+        TRAP( err, HandleStopCmdL( aMessage ) );
+        }
+
+    else if ( iCommandId == ECmdGetDuration )
+        {
+        TRAP( err, HandleGetDurationCmdL( aMessage ) );
+        }
+
+    else if ( iCommandId == ECmdGetMaxVol )
+        {
+        TRAP( err, HandleGetMaxVolCmdL( aMessage ) );
+        }
+
+    else if ( iCommandId == ECmdSetVol )
+        {
+        TRAP( err, HandleSetVolCmdL( aMessage ) );
+        }
+
+    else
+        {
+        User::LeaveIfError(
+            SendErrorResponseMsg( KErrArgument, KErrorUnknownCmd ) );
+        }
+
+    if ( err != KErrNone )
+        {
+        User::LeaveIfError(
+                SendErrorResponseMsg( err, KNullDesC8, iCommandId ) );
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiAudioServicePlugin::ProcessMessageL" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiAudioServicePlugin::HandleListAudioFilesCmdL()
+// -----------------------------------------------------------------------------
+//
+void CHtiAudioServicePlugin::HandleListAudioFilesCmdL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAudioServicePlugin::HandleListAudioFilesCmdL" );
+
+    RFs fsSession;
+    User::LeaveIfError( fsSession.Connect() );
+    CleanupClosePushL( fsSession );
+
+    // Build a list of directories to scan
+    CDesCArraySeg* directories = new (ELeave) CDesCArraySeg( 5 );
+    CleanupStack::PushL( directories );
+
+    if ( aMessage.Length() == 1 )  // Add default sound directories
+        {
+        TFileName directory;
+
+        // ROM
+        directory.Append( PathInfo::RomRootPath() );
+        directory.Append( PathInfo::SoundsPath() );
+        if ( BaflUtils::PathExists( fsSession, directory ) )
+            {
+            directories->AppendL( directory );
+            AddSubdirsRecursivelyL( directories->MdcaPoint(
+                directories->Count() - 1 ), *directories, fsSession );
+            }
+
+        // Phone memory
+        directory.Zero();
+        directory.Append( PathInfo::PhoneMemoryRootPath() );
+        directory.Append( PathInfo::SoundsPath() );
+        if ( BaflUtils::PathExists( fsSession, directory ) )
+            {
+            directories->AppendL( directory );
+            AddSubdirsRecursivelyL( directories->MdcaPoint(
+                directories->Count() - 1 ), *directories, fsSession );
+            }
+
+        // Memory card
+        directory.Zero();
+        directory.Append( PathInfo::MemoryCardRootPath() );
+        directory.Append( PathInfo::SoundsPath() );
+        if ( BaflUtils::PathExists( fsSession, directory ) )
+            {
+            directories->AppendL( directory );
+            AddSubdirsRecursivelyL( directories->MdcaPoint(
+                directories->Count() - 1 ), *directories, fsSession );
+            }
+        }
+
+    else  // Add given directory
+        {
+        if ( aMessage.Length() < KListCmdMinLength )
+            {
+            User::LeaveIfError( SendErrorResponseMsg(
+                                    KErrArgument, KErrorInvalidParameters ) );
+            CleanupStack::PopAndDestroy( 2 ); // directories, fsSession
+            return;
+            }
+
+        TInt pathLength = aMessage[1];
+        if ( ( aMessage.Length() - pathLength ) != KListCmdMinLength - 2 )
+            {
+            User::LeaveIfError( SendErrorResponseMsg(
+                                    KErrArgument, KErrorInvalidParameters ) );
+            CleanupStack::PopAndDestroy( 2 ); // directories, fsSession
+            return;
+            }
+
+        TFileName directory;
+        TInt nextOffset = ParseString( aMessage, 1, directory );
+        TInt dirLength = directory.Length();
+        if ( dirLength < 2 || nextOffset < 0 )
+            {
+            User::LeaveIfError( SendErrorResponseMsg(
+                                    KErrArgument, KErrorInvalidParameters ) );
+            CleanupStack::PopAndDestroy( 2 ); // directories, fsSession
+            return;
+            }
+
+        HTI_LOG_DES( directory );
+
+        if ( directory[dirLength - 1] != '\\' )
+            {
+            HTI_LOG_TEXT( "Adding backslash to the end" );
+            directory.Append( KBackslash );
+            HTI_LOG_DES( directory );
+            }
+
+        if ( BaflUtils::PathExists( fsSession, directory ) )
+            {
+            HTI_LOG_TEXT( "Given path exists" );
+            directories->AppendL( directory );
+            AddSubdirsRecursivelyL( directories->MdcaPoint(
+                directories->Count() - 1 ), *directories, fsSession );
+            }
+        }
+
+    // Buffer for the file list that is returned
+    CBufFlat* fileListBuf = CBufFlat::NewL( 256 );
+    CleanupStack::PushL( fileListBuf );
+    TInt bufPos = 0;
+
+    TInt audioFileCount = 0;
+    TInt dirCount( directories->Count() );
+    HTI_LOG_FORMAT( "Total directory count = %d", dirCount );
+
+    if ( dirCount == 0 )
+        {
+        HTI_LOG_TEXT( "The given directory did not exist" );
+        User::LeaveIfError( SendErrorResponseMsg(
+                                KErrArgument, KErrorInvalidPath ) );
+        CleanupStack::PopAndDestroy( 3 ); // fileListBuf, directories, fsSession
+        return;
+        }
+
+    // Loop all the directories
+    for ( TInt i = 0; i < dirCount; i++ )
+        {
+        HTI_LOG_TEXT( "Reading dir:" );
+        HTI_LOG_DES( directories->MdcaPoint( i ) );
+        CDir* dir;
+        TInt err = fsSession.GetDir( directories->MdcaPoint( i ),
+            KEntryAttNormal, ESortNone, dir );
+        if ( err )
+            {
+            delete dir;
+            dir = NULL;
+            continue; // This dir is skipped
+            }
+        CleanupStack::PushL( dir );
+
+        // Loop all the entries in this directory
+        TInt fileCount( dir->Count() );
+        for ( TInt j = 0; j < fileCount; j++ )
+            {
+            TFileName filePath;
+            filePath.Copy( directories->MdcaPoint( i ) );
+            filePath.Append( ( *dir )[j].iName );
+
+            // Check MIME type match
+            if ( MatchMimeTypeL( filePath, KAudioMimeType ) ||
+                 MatchMimeTypeL( filePath, KRngMimeType ) )
+                {
+                HBufC8* filePathBuf8 = HBufC8::NewLC( KMaxFileName );
+                filePathBuf8->Des().Copy( filePath );
+                TInt pathLength = filePathBuf8->Length();
+                HTI_LOG_DES( *filePathBuf8 );
+                fileListBuf->ExpandL( bufPos, pathLength + 1 );
+                TBuf8<1> lengthBuf;
+                lengthBuf.Append( pathLength );
+                fileListBuf->Write( bufPos, lengthBuf, 1 );
+                bufPos++;
+                fileListBuf->Write( bufPos, filePathBuf8->Ptr(), pathLength );
+                bufPos += pathLength;
+                CleanupStack::PopAndDestroy(); // filePathBuf8
+                audioFileCount++;
+                }
+
+            } // files loop
+        CleanupStack::PopAndDestroy(); // dir
+        } // directories loop
+
+    HTI_LOG_FORMAT( "Total audio file count = %d", audioFileCount );
+
+    // All files added - write number of files to the beginning of buffer...
+    TBuf8<2> countBuf;
+    countBuf.Append( (TUint8*)(&audioFileCount), 2 );
+    fileListBuf->InsertL( 0, countBuf, 2 );
+
+    // ...and send it away
+    TPtr8 ptr = fileListBuf->Ptr( 0 );
+    User::LeaveIfError( SendResponseMsg( ptr ) );
+
+    CleanupStack::PopAndDestroy( 3 ); // fileListBuf, directories, fsSession
+
+    HTI_LOG_FUNC_OUT( "CHtiAudioServicePlugin::HandleListAudioFilesCmdL" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiAudioServicePlugin::HandlePlayFileCmdL()
+// -----------------------------------------------------------------------------
+//
+void CHtiAudioServicePlugin::HandlePlayFileCmdL( const TDesC8&aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAudioServicePlugin::HandlePlayFileCmdL" );
+
+    if ( iIsPlaying )
+        {
+        User::LeaveIfError( SendErrorResponseMsg(
+                                KErrInUse, KErrorBusyPlaying ) );
+        return;
+        }
+
+    iPlayCommandId = ECmdPlayFile;
+
+    /*
+    Message bytes:
+             0 = command code
+             1 = path length
+         2 - n = full path to file
+        next 1 = volume
+        next 4 = start position
+        next 4 = end position
+        next 1 = repeats
+        next 4 = silence between repeats
+        next 1 = audio setting
+    */
+
+    if ( aMessage.Length() < KPlayFileCmdMinLength )
+        {
+        User::LeaveIfError( SendErrorResponseMsg(
+                                KErrArgument, KErrorInvalidParameters ) );
+        return;
+        }
+
+    // Parse parameter values from the message
+    const TUint8* ptr = aMessage.Ptr();
+    TInt pathLength = aMessage[1];
+
+    if ( ( aMessage.Length() - pathLength ) !=
+         ( KPlayFileCmdMinLength - 4 ) )
+        {
+        User::LeaveIfError( SendErrorResponseMsg(
+                                KErrArgument, KErrorInvalidParameters ) );
+        return;
+        }
+
+    TFileName filePath;
+    TInt nextOffset = ParseString( aMessage, 1, filePath );
+    if ( filePath.Length() < 2 || nextOffset < 0 )
+        {
+        User::LeaveIfError( SendErrorResponseMsg(
+                                KErrArgument, KErrorInvalidParameters ) );
+        return;
+        }
+    HTI_LOG_TEXT( "Full file path:" );
+    HTI_LOG_DES( filePath );
+    iVolume = aMessage[nextOffset];
+    nextOffset++;
+    HTI_LOG_FORMAT( "Volume = %d", iVolume );
+    iStartPos = ParseUint32( ptr + nextOffset );
+    HTI_LOG_FORMAT( "Start position = %d", iStartPos );
+    nextOffset += 4;
+    iEndPos = ParseUint32( ptr + nextOffset );
+    HTI_LOG_FORMAT( "End position = %d", iEndPos );
+    nextOffset += 4;
+    iRepeats = aMessage[nextOffset];
+    nextOffset++;
+    HTI_LOG_FORMAT( "Repeats = %d", iRepeats );
+    iTrailingSilence = ParseUint32( ptr + nextOffset );
+    HTI_LOG_FORMAT( "Trailing silence = %d", iTrailingSilence );
+    nextOffset += 4;
+    TInt audioSetting = aMessage[nextOffset];
+    HTI_LOG_FORMAT( "Audio setting = %d", audioSetting );
+
+    // Set audio settings
+    if ( audioSetting > ERingTonePreview ) audioSetting = EDefault;
+    SetAudioSettings( ( TAudioSetting ) audioSetting );
+
+    // Check if file is rng ringtone, it has to be played using tone player -
+    // other formats are played with audio player.
+
+    TInt err = KErrNone;
+    TBool isRng = EFalse;
+    TRAP( err, isRng = MatchMimeTypeL( filePath, KRngMimeType ) );
+
+    if ( err )
+        {
+        User::LeaveIfError( SendErrorResponseMsg( err, KErrorFileInitFailed ) );
+        return;
+        }
+
+    if ( isRng )
+        {
+        HTI_LOG_TEXT( "File is RNG - creating tone player" );
+        TRAP( err, iTonePlayer = CMdaAudioToneUtility::NewL(
+                *this, NULL, iAudioPriority, iAudioPriorityPreference ) );
+        }
+
+    else
+        {
+        HTI_LOG_TEXT( "File is not RNG - creating audio player" );
+        TRAP( err, iAudioPlayer = CMdaAudioPlayerUtility::NewFilePlayerL(
+                filePath, *this, iAudioPriority, iAudioPriorityPreference ) );
+        // MapcInitComplete callback function will be called
+        }
+
+    if ( err )
+        {
+        delete iAudioPlayer;
+        iAudioPlayer = NULL;
+        delete iTonePlayer;
+        iTonePlayer = NULL;
+        User::LeaveIfError( SendErrorResponseMsg(
+                                err, KErrorFileInitFailed ) );
+        }
+
+    if ( iTonePlayer )
+        {
+        iTonePlayer->PrepareToPlayFileSequence( filePath );
+        // MatoPrepareComplete callback function will be called
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiAudioServicePlugin::HandlePlayFileCmdL" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiAudioServicePlugin::HandlePlayToneCmdL()
+// -----------------------------------------------------------------------------
+//
+void CHtiAudioServicePlugin::HandlePlayToneCmdL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAudioServicePlugin::HandlePlayToneCmdL" );
+
+    if ( iIsPlaying )
+        {
+        User::LeaveIfError( SendErrorResponseMsg(
+                                KErrInUse, KErrorBusyPlaying ) );
+        return;
+        }
+
+    iPlayCommandId = ECmdPlayTone;
+
+    /*
+    Message bytes:
+            0  = command code
+        1 - 2  = frequency value
+        3 - 6  = duration value
+            7  = volume value
+            8  = repeat value
+        9 - 12 = silence between repeats
+    */
+
+    if ( aMessage.Length() != KPlayToneCmdLength )
+        {
+        User::LeaveIfError( SendErrorResponseMsg(
+                                KErrArgument, KErrorInvalidParameters ) );
+        return;
+        }
+
+    // Parse parameter values from the message
+    const TUint8* ptr = aMessage.Ptr();
+    TInt frequency = ParseUint16( ptr + 1 );
+    HTI_LOG_FORMAT( "Freq = %d", frequency );
+    TUint duration = ParseUint32( ptr + 3 );
+    HTI_LOG_FORMAT( "Duration = %d", duration );
+    iVolume = aMessage[7];
+    HTI_LOG_FORMAT( "Volume = %d", iVolume );
+    iRepeats = aMessage[8];
+    HTI_LOG_FORMAT( "Repeats = %d", iRepeats );
+    iTrailingSilence = ParseUint32( ptr + 9 );
+    HTI_LOG_FORMAT( "Silence = %d", iTrailingSilence );
+
+    TRAPD( err, iTonePlayer = CMdaAudioToneUtility::NewL( *this ) );
+
+    if ( err )
+        {
+        delete iTonePlayer;
+        iTonePlayer = NULL;
+        User::LeaveIfError( SendErrorResponseMsg(
+                                err, KErrorToneInitFailed ) );
+        }
+
+    iTonePlayer->PrepareToPlayTone( frequency,
+                              TTimeIntervalMicroSeconds( duration ) );
+    // MatoPrepareComplete callback function will be called when ready to play
+    HTI_LOG_FUNC_OUT( "CHtiAudioServicePlugin::HandlePlayToneCmdL" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiAudioServicePlugin::HandlePlayDtmfCmdL()
+// -----------------------------------------------------------------------------
+//
+void CHtiAudioServicePlugin::HandlePlayDtmfCmdL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAudioServicePlugin::HandlePlayDtmfCmdL" );
+
+    if ( iIsPlaying )
+        {
+        User::LeaveIfError( SendErrorResponseMsg(
+                                KErrInUse, KErrorBusyPlaying ) );
+        return;
+        }
+
+    iPlayCommandId = ECmdPlayDtmf;
+
+    /*
+    Message bytes:
+             0 = command code
+             1 = DTMF string length
+         2 - n = dtmf string
+        next 4 = tone length
+        next 4 = tone gap length
+        next 1 = volume
+        next 1 = repeats
+        next 4 = silence between repeats
+    */
+
+    if ( aMessage.Length() < KPlayDtmfCmdMinLength )
+        {
+        User::LeaveIfError( SendErrorResponseMsg(
+                                KErrArgument, KErrorInvalidParameters ) );
+        return;
+        }
+
+    // Parse parameter values from the message
+    const TUint8* ptr = aMessage.Ptr();
+    TInt stringLength = aMessage[1];
+
+    if ( ( aMessage.Length() - stringLength ) !=
+         ( KPlayDtmfCmdMinLength - 1 ) )
+        {
+        User::LeaveIfError( SendErrorResponseMsg(
+                                KErrArgument, KErrorInvalidParameters ) );
+        return;
+        }
+
+    TBuf<255> dtmfString;
+    TInt nextOffset = ParseString( aMessage, 1, dtmfString );
+    if ( dtmfString.Length() < 1 || nextOffset < 0 )
+        {
+        User::LeaveIfError( SendErrorResponseMsg(
+                                KErrArgument, KErrorInvalidParameters ) );
+        return;
+        }
+    HTI_LOG_TEXT( "DTMF string:" );
+    HTI_LOG_DES( dtmfString );
+    iDtmfLength = ParseUint32( ptr + nextOffset );
+    nextOffset += 4;
+    HTI_LOG_FORMAT( "DTMF length = %d", iDtmfLength );
+    iDtmfGapLength = ParseUint32( ptr + nextOffset );
+    nextOffset += 4;
+    HTI_LOG_FORMAT( "DTMF gap length = %d", iDtmfGapLength );
+    iVolume = aMessage[nextOffset];
+    nextOffset++;
+    HTI_LOG_FORMAT( "Volume = %d", iVolume );
+    iRepeats = aMessage[nextOffset];
+    nextOffset++;
+    HTI_LOG_FORMAT( "Repeats = %d", iRepeats );
+    iTrailingSilence = ParseUint32( ptr + nextOffset );
+    HTI_LOG_FORMAT( "Trailing silence = %d", iTrailingSilence );
+
+    SetAudioSettings( EDtmfString );
+
+    TRAPD( err, iTonePlayer = CMdaAudioToneUtility::NewL(
+            *this, NULL, iAudioPriority, iAudioPriorityPreference ) );
+
+    if ( err )
+        {
+        delete iTonePlayer;
+        iTonePlayer = NULL;
+        User::LeaveIfError( SendErrorResponseMsg( err, KErrorToneInitFailed ) );
+        }
+
+    iTonePlayer->PrepareToPlayDTMFString( dtmfString );
+    // MatoPrepareComplete callback function will be called when ready to play
+    HTI_LOG_FUNC_OUT( "CHtiAudioServicePlugin::HandlePlayDtmfCmdL" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiAudioServicePlugin::HandleStopCmdL()
+// -----------------------------------------------------------------------------
+//
+void CHtiAudioServicePlugin::HandleStopCmdL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAudioServicePlugin::HandleStopCmdL" );
+
+    if ( aMessage.Length() != KStopCmdLength )
+        {
+        User::LeaveIfError( SendErrorResponseMsg(
+                                KErrArgument, KErrorInvalidParameters ) );
+        return;
+        }
+
+    if ( !iIsPlaying )
+        {
+        HTI_LOG_TEXT( "Not playing - nothing to stop" );
+        // Just send "OK" reply if nothing is currently playing
+        User::LeaveIfError( SendResponseMsg( _L8( "OK" ) ) );
+        }
+
+    else
+        {
+        if ( iAudioPlayer )
+            {
+            HTI_LOG_TEXT( "Stopping audio player" );
+            iAudioPlayer->Stop();
+            iIsPlaying = EFalse;
+            delete iAudioPlayer;
+            iAudioPlayer = NULL;
+            // According to documentation should call MapcPlayComplete callback
+            // method but it doesn't, so sending reply here.
+            User::LeaveIfError( SendResponseMsg( _L8( "OK" ) ) );
+            }
+
+        else if ( iTonePlayer )
+            {
+            HTI_LOG_TEXT( "Stopping tone player" );
+            iTonePlayer->CancelPlay();
+            iIsPlaying = EFalse;
+            delete iTonePlayer;
+            iTonePlayer = NULL;
+            // Callback method MatoPlayComplete is not called -
+            // sending reply here.
+            User::LeaveIfError( SendResponseMsg( _L8( "OK" ) ) );
+            }
+        }
+    HTI_LOG_FUNC_OUT( "CHtiAudioServicePlugin::HandleStopCmdL" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiAudioServicePlugin::HandleGetDurationCmdL()
+// -----------------------------------------------------------------------------
+//
+void CHtiAudioServicePlugin::HandleGetDurationCmdL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAudioServicePlugin::HandleGetDurationCmdL" );
+
+    if ( iIsPlaying )
+        {
+         // If currently playing, no parameters allowed. Returns the duration
+         // of currently playing sound.
+        if ( aMessage.Length() != 1 )
+            {
+            User::LeaveIfError( SendErrorResponseMsg(
+                                    KErrInUse, KErrorBusyPlaying ) );
+            return;
+            }
+
+        if ( iAudioPlayer )
+            {
+            TTimeIntervalMicroSeconds durationValue =
+                                iAudioPlayer->Duration();
+
+            if ( I64HIGH( durationValue.Int64() ) > 0 )
+                {
+                User::LeaveIfError( SendErrorResponseMsg(
+                                        KErrOverflow, KErrorDurationFailed ) );
+                return;
+                }
+            else
+                {
+                TUint duration = I64LOW( durationValue.Int64() );
+                TBuf8<KTUintSize> durationBuf;
+                durationBuf.Append( (TUint8*)(&duration), KTUintSize );
+                User::LeaveIfError( SendResponseMsg( durationBuf ) );
+                return;
+                }
+            }
+
+        else  // Duration supported only for audio player
+            {
+            User::LeaveIfError( SendErrorResponseMsg(
+                                    KErrNotSupported, KErrorDurationFailed ) );
+            return;
+            }
+        }
+
+    /* Command must have file path parameter if not currently playing.
+    Message bytes:
+             0 = command code
+             1 = path length
+         2 - n = full path to file
+    */
+
+    if ( aMessage.Length() < KDurationCmdMinLength )
+        {
+        User::LeaveIfError( SendErrorResponseMsg(
+                                KErrArgument, KErrorInvalidParameters ) );
+        return;
+        }
+
+    TInt pathLength = aMessage[1];
+    if ( ( aMessage.Length() - pathLength ) !=
+         ( KDurationCmdMinLength - 4 ) )
+        {
+        User::LeaveIfError( SendErrorResponseMsg(
+                                KErrArgument, KErrorInvalidParameters ) );
+        return;
+        }
+
+    // Parse parameter values from the message
+    TFileName filePath;
+    TInt nextOffset = ParseString( aMessage, 1, filePath );
+    if ( filePath.Length() < 2 || nextOffset < 0 )
+        {
+        User::LeaveIfError( SendErrorResponseMsg(
+                                KErrArgument, KErrorInvalidParameters ) );
+        return;
+        }
+    HTI_LOG_TEXT( "Full file path:" );
+    HTI_LOG_DES( filePath );
+
+    TRAPD( err, iAudioPlayer = CMdaAudioPlayerUtility::NewFilePlayerL(
+                                                        filePath, *this ) );
+    if ( err )
+        {
+        delete iAudioPlayer;
+        iAudioPlayer = NULL;
+        User::LeaveIfError( SendErrorResponseMsg( err, KErrorDurationFailed ) );
+        }
+
+    // MapcInitComplete callback function will be called
+    HTI_LOG_FUNC_OUT( "CHtiAudioServicePlugin::HandleGetDurationCmdL" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiAudioServicePlugin::HandleGetMaxVolCmdL()
+// -----------------------------------------------------------------------------
+//
+void CHtiAudioServicePlugin::HandleGetMaxVolCmdL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAudioServicePlugin::HandleGetMaxVolCmdL" );
+
+    if ( iIsPlaying )
+        {
+         // If currently playing, no parameters allowed. Returns the max volume
+         // of currently playing sound.
+        if ( aMessage.Length() != 1 )
+            {
+            User::LeaveIfError( SendErrorResponseMsg(
+                                    KErrInUse, KErrorBusyPlaying ) );
+            return;
+            }
+
+        TInt maxVol = -1;
+
+        if ( iAudioPlayer )
+            {
+            maxVol = iAudioPlayer->MaxVolume();
+            }
+
+        else if ( iTonePlayer )
+            {
+            maxVol = iTonePlayer->MaxVolume();
+            }
+
+        HTI_LOG_FORMAT( "Max volume = %d", maxVol );
+
+        if ( maxVol < 0 )
+            {
+            // Should not happen
+            User::LeaveIfError( SendErrorResponseMsg(
+                                    KErrGeneral, KErrorMaxVolFailed ) );
+            return;
+            }
+
+        if ( maxVol > 255 ) maxVol = 255;
+        TBuf8<1> maxVolBuf;
+        maxVolBuf.Append( maxVol );
+        User::LeaveIfError( SendResponseMsg( maxVolBuf ) );
+        return;
+        }
+
+    /*
+    Message bytes:
+             0 = command code
+             1 = path length
+         2 - n = full path to file
+    */
+
+    if ( aMessage.Length() < KMaxVolCmdMinLength )
+        {
+        User::LeaveIfError( SendErrorResponseMsg(
+                                KErrArgument, KErrorInvalidParameters ) );
+        return;
+        }
+
+    TInt pathLength = aMessage[1];
+    if ( ( aMessage.Length() - pathLength ) != ( KMaxVolCmdMinLength - 4 ) )
+        {
+        User::LeaveIfError( SendErrorResponseMsg(
+                                KErrArgument, KErrorInvalidParameters ) );
+        return;
+        }
+
+    // Parse parameter values from the message
+    TFileName filePath;
+    TInt nextOffset = ParseString( aMessage, 1, filePath );
+    if ( filePath.Length() < 2 || nextOffset < 0 )
+        {
+        User::LeaveIfError( SendErrorResponseMsg(
+                                KErrArgument, KErrorInvalidParameters ) );
+        return;
+        }
+    HTI_LOG_TEXT( "Full file path:" );
+    HTI_LOG_DES( filePath );
+
+    TInt err = KErrNone;
+    TBool isRng = EFalse;
+    TRAP( err, isRng = MatchMimeTypeL( filePath, KRngMimeType ) );
+
+    if ( err )
+        {
+        User::LeaveIfError( SendErrorResponseMsg( err, KErrorMaxVolFailed ) );
+        return;
+        }
+
+    if ( isRng )
+        {
+        HTI_LOG_TEXT( "File is RNG - creating tone player" );
+        TRAP( err, iTonePlayer = CMdaAudioToneUtility::NewL( *this ) );
+        }
+
+    else
+        {
+        HTI_LOG_TEXT( "File is not RNG - creating audio player" );
+        TRAP( err, iAudioPlayer = CMdaAudioPlayerUtility::NewFilePlayerL(
+                                                        filePath, *this ) );
+        // MapcInitComplete callback function will be called
+        }
+
+    if ( err )
+        {
+        delete iAudioPlayer;
+        iAudioPlayer = NULL;
+        delete iTonePlayer;
+        iTonePlayer = NULL;
+        User::LeaveIfError( SendErrorResponseMsg( err, KErrorMaxVolFailed ) );
+        }
+
+    if ( iTonePlayer )
+        {
+        iTonePlayer->PrepareToPlayFileSequence( filePath );
+        // MatoPrepareComplete callback function will be called
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiAudioServicePlugin::HandleGetMaxVolCmdL" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiAudioServicePlugin::HandleSetVolCmdL()
+// -----------------------------------------------------------------------------
+//
+void CHtiAudioServicePlugin::HandleSetVolCmdL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAudioServicePlugin::HandleSetVolCmdL" );
+
+    if ( aMessage.Length() != KSetVolCmdLength )
+        {
+        User::LeaveIfError( SendErrorResponseMsg( KErrArgument,
+                                                  KErrorInvalidParameters ) );
+        }
+
+    if ( !iIsPlaying )
+        {
+        HTI_LOG_TEXT( "Nothing playing - not setting volume" );
+        User::LeaveIfError( SendErrorResponseMsg(
+                                KErrNotReady, KErrorNothingPlaying ) );
+        }
+
+    else
+        {
+        TInt volume = aMessage[1]; // [0] = command code, [1] = volume value
+        HTI_LOG_FORMAT( "requested volume = %d", volume );
+
+        if ( iAudioPlayer )
+            {
+            HTI_LOG_TEXT( "Setting audio player volume" );
+            TInt maxVol = iAudioPlayer->MaxVolume();
+            HTI_LOG_FORMAT( "max volume = %d", maxVol );
+            if ( volume > maxVol ) volume = maxVol;
+            iAudioPlayer->SetVolume( volume );
+            TBuf8<1> volBuf;
+            volBuf.Append( volume );
+            User::LeaveIfError( SendResponseMsg( volBuf ) );
+            }
+        else if ( iTonePlayer )
+            {
+            HTI_LOG_TEXT( "Setting tone player volume" );
+            TInt maxVol = iTonePlayer->MaxVolume();
+            HTI_LOG_FORMAT( "max volume = %d", maxVol );
+            if ( volume > maxVol ) volume = maxVol;
+            iTonePlayer->SetVolume( volume );
+            TBuf8<1> volBuf;
+            volBuf.Append( volume );
+            User::LeaveIfError( SendResponseMsg( volBuf ) );
+            }
+        }
+    HTI_LOG_FUNC_OUT( "CHtiAudioServicePlugin::HandleSetVolCmdL" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiAudioServicePlugin::MatoPrepareComplete()
+// Tone player prepare complete
+// -----------------------------------------------------------------------------
+//
+void CHtiAudioServicePlugin::MatoPrepareComplete( TInt aError )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAudioServicePlugin::MatoPrepareComplete" );
+
+    if ( iCommandId == ECmdGetMaxVol )
+        {
+        if ( aError )
+            {
+            SendErrorResponseMsg( aError, KErrorMaxVolFailed );
+            }
+
+        else
+            {
+            TInt maxVol = iTonePlayer->MaxVolume();
+            HTI_LOG_FORMAT( "Max volume = %d", maxVol );
+            if ( maxVol > 255 ) maxVol = 255;
+            TBuf8<1> maxVolBuf;
+            maxVolBuf.Append( maxVol );
+            SendResponseMsg( maxVolBuf );
+            }
+
+        delete iTonePlayer;
+        iTonePlayer = NULL;
+        return;
+        }
+
+    if ( aError )
+        {
+        SendErrorResponseMsg( aError, KErrorToneInitFailed );
+        delete iTonePlayer;
+        iTonePlayer = NULL;
+        }
+
+    else
+        {
+        if ( iCommandId == ECmdPlayDtmf )
+            {
+            iTonePlayer->SetDTMFLengths(
+                TTimeIntervalMicroSeconds32( iDtmfLength ),
+                TTimeIntervalMicroSeconds32( iDtmfGapLength ),
+                TTimeIntervalMicroSeconds32( 0 ) );
+            }
+
+        if ( iVolume > iTonePlayer->MaxVolume() )
+            {
+            iVolume = iTonePlayer->MaxVolume();
+            }
+
+        iTonePlayer->SetVolume( iVolume );
+        iTonePlayer->SetRepeats( iRepeats + 1,
+                        TTimeIntervalMicroSeconds( iTrailingSilence ) );
+        iIsPlaying = ETrue;
+        iTonePlayer->Play();
+        iIsBusy = EFalse;
+        // MatoPlayComplete callback function will be called when playing ends.
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiAudioServicePlugin::MatoPrepareComplete" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiAudioServicePlugin::MatoPlayComplete()
+// Tone play complete
+// -----------------------------------------------------------------------------
+//
+void CHtiAudioServicePlugin::MatoPlayComplete( TInt aError )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAudioServicePlugin::MatoPlayComplete" );
+
+    iIsPlaying = EFalse;
+    iIsBusy = ETrue; // Busy dispatching the play complete message
+
+    if ( aError )
+        {
+        SendErrorResponseMsg( aError, KErrorTonePlayFailed, iPlayCommandId );
+        }
+
+    else
+        {
+        SendResponseMsg( _L8( "OK" ), iPlayCommandId );
+        }
+
+    delete iTonePlayer;
+    iTonePlayer = NULL;
+
+    HTI_LOG_FUNC_OUT( "CHtiAudioServicePlugin::MatoPlayComplete" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiAudioServicePlugin::MapcInitComplete()
+// Audio player init complete
+// -----------------------------------------------------------------------------
+//
+void CHtiAudioServicePlugin::MapcInitComplete( TInt aError,
+                                 const TTimeIntervalMicroSeconds& aDuration )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAudioServicePlugin::MapcInitComplete" );
+
+    if ( iCommandId == ECmdPlayFile )
+        {
+        if ( aError )
+            {
+            SendErrorResponseMsg( aError, KErrorFileInitFailed );
+            delete iAudioPlayer;
+            iAudioPlayer = NULL;
+            }
+
+        else
+            {
+            if ( iEndPos < iStartPos ||
+                        TTimeIntervalMicroSeconds( iStartPos ) > aDuration )
+                {
+                SendErrorResponseMsg( KErrArgument, KErrorPosition );
+                delete iAudioPlayer;
+                iAudioPlayer = NULL;
+                return;
+                }
+
+            if ( iEndPos > 0 )
+                {
+                iAudioPlayer->SetPlayWindow(
+                    TTimeIntervalMicroSeconds( iStartPos ),
+                    TTimeIntervalMicroSeconds( iEndPos ) );
+                }
+
+            HTI_LOG_FORMAT( "Max volume = %d", iAudioPlayer->MaxVolume() );
+            HTI_LOG_FORMAT( "Setting volume = %d", iVolume );
+            if ( iVolume > iAudioPlayer->MaxVolume() )
+                {
+                iVolume = iAudioPlayer->MaxVolume();
+                }
+
+            iAudioPlayer->SetVolume( iVolume );
+            iAudioPlayer->SetRepeats( iRepeats,
+                            TTimeIntervalMicroSeconds( iTrailingSilence ) );
+            iIsPlaying = ETrue;
+            iAudioPlayer->Play();
+
+            // Have to do this after play command because
+            // volume setting before play seems to have no effect.
+            iAudioPlayer->SetVolume( 0 );
+            iAudioPlayer->SetVolume( iVolume );
+
+            iIsBusy = EFalse;
+            // MapcPlayComplete callback function is called when playing ends
+            }
+        }
+
+    else if ( iCommandId == ECmdGetDuration )
+        {
+        if ( aError )
+            {
+            SendErrorResponseMsg( aError, KErrorDurationFailed );
+            }
+
+        else
+            {
+            if ( I64HIGH( aDuration.Int64() ) > 0 )
+                {
+                SendErrorResponseMsg( KErrOverflow, KErrorDurationFailed );
+                }
+            else
+                {
+                TUint duration = I64LOW( aDuration.Int64() );
+                TBuf8<KTUintSize> durationBuf;
+                durationBuf.Append( (TUint8*)(&duration), KTUintSize );
+                SendResponseMsg( durationBuf );
+                }
+            }
+        delete iAudioPlayer;
+        iAudioPlayer = NULL;
+        }
+
+    else if ( iCommandId == ECmdGetMaxVol )
+        {
+        if ( aError )
+            {
+            SendErrorResponseMsg( aError, KErrorMaxVolFailed );
+            }
+
+        else
+            {
+            TInt maxVol = iAudioPlayer->MaxVolume();
+            HTI_LOG_FORMAT( "Max volume = %d", maxVol );
+            if ( maxVol > 255 ) maxVol = 255;
+            TBuf8<1> maxVolBuf;
+            maxVolBuf.Append( maxVol );
+            SendResponseMsg( maxVolBuf );
+            }
+        delete iAudioPlayer;
+        iAudioPlayer = NULL;
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiAudioServicePlugin::MapcInitComplete" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiAudioServicePlugin::MapcPlayComplete()
+// Audio play complete
+// -----------------------------------------------------------------------------
+//
+void CHtiAudioServicePlugin::MapcPlayComplete( TInt aError )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAudioServicePlugin::MapcPlayComplete" );
+
+    iIsPlaying = EFalse;
+    iIsBusy = ETrue; // Busy dispatching the play complete message
+
+    if ( aError )
+        {
+        SendErrorResponseMsg( aError, KErrorFilePlayFailed, ECmdPlayFile );
+        }
+
+    else
+        {
+        SendResponseMsg( _L8( "OK" ), iPlayCommandId );
+        }
+
+    delete iAudioPlayer;
+    iAudioPlayer = NULL;
+
+    HTI_LOG_FUNC_OUT( "CHtiAudioServicePlugin::MapcPlayComplete" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiAudioServicePlugin::NotifyMemoryChange
+// Called when HTI Framework has dispatched a message forward and the amount
+// of free memory in the message queue has changed.
+// -----------------------------------------------------------------------------
+//
+void CHtiAudioServicePlugin::NotifyMemoryChange( TInt aAvailableMemory )
+    {
+    if ( iIsBusy && iMessage )
+        {
+        if ( aAvailableMemory >= iMessage->Size() )
+            {
+            if ( iErrorCode == 0 )
+                {
+                TInt err = iDispatcher->DispatchOutgoingMessage(
+                    iMessage, KAudioServiceUid );
+
+                if ( err == KErrNone )
+                    {
+                    // Ownership of iMessage has been transferred
+                    iMessage = NULL;
+                    iIsBusy = EFalse;
+                    iDispatcher->RemoveMemoryObserver( this );
+                    }
+
+                else if ( err == KErrNoMemory )
+                    {
+                    // Keep retrying.
+                    }
+
+                else // Give up on sending
+                    {
+                    delete iMessage;
+                    iMessage = NULL;
+                    iIsBusy = EFalse;
+                    iDispatcher->RemoveMemoryObserver( this );
+                    }
+                }
+
+            else
+                {
+                TInt err = iDispatcher->DispatchOutgoingErrorMessage(
+                    iErrorCode, *iMessage, KAudioServiceUid );
+
+                // If it was success or some other error than KErrNoMemory
+                // we are done sending or trying to send this message.
+                if ( err != KErrNoMemory )
+                    {
+                    delete iMessage;
+                    iMessage = NULL;
+                    iIsBusy = EFalse;
+                    iDispatcher->RemoveMemoryObserver( this );
+                    }
+
+                else
+                    {
+                    // Keep retrying.
+                    }
+                }
+            }
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiAudioServicePlugin::IsBusy
+// -----------------------------------------------------------------------------
+//
+TBool CHtiAudioServicePlugin::IsBusy()
+    {
+    return iIsBusy;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiAudioServicePlugin::SendResponseMsg
+// Sends a message out to the message dispatcher.
+// -----------------------------------------------------------------------------
+//
+TInt CHtiAudioServicePlugin::SendResponseMsg( const TDesC8& aMsg,
+                                              const TUint8 aCommandId )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAudioServicePlugin::SendResponseMsg" );
+
+    iErrorCode = 0;
+
+    if ( iDispatcher == NULL )
+        {
+        iIsBusy = EFalse;
+        return KErrGeneral;
+        }
+
+    iDispatcher->RemoveMemoryObserver( this );
+
+    delete iMessage;
+    iMessage = NULL;
+    iMessage = HBufC8::New( aMsg.Length() + 1 );
+
+    if ( iMessage == NULL )
+        {
+        iIsBusy = EFalse;
+        return KErrNoMemory;
+        }
+
+    TPtr8 ptr8 = iMessage->Des();
+    if ( aCommandId != 0 )
+        {
+        ptr8.Append( aCommandId );
+        }
+    else
+        {
+        ptr8.Append( iCommandId );
+        }
+
+    ptr8.Append( aMsg );
+
+    TInt err = KErrNone;
+
+    err = iDispatcher->DispatchOutgoingMessage( iMessage, KAudioServiceUid );
+
+    if ( err == KErrNoMemory )
+        {
+        HTI_LOG_TEXT( "Message queue memory full - waiting" );
+        iIsBusy = ETrue; // Should already be true, but just in case
+        iDispatcher->AddMemoryObserver( this );
+        // For the caller of this method all is OK, sending is just delayed
+        err = KErrNone;
+        }
+
+    else if ( err == KErrNone )
+        {
+        HTI_LOG_TEXT( "Message sent to dispatcher" );
+        iMessage = NULL; // Ownership of iMessage has been transferred
+        iIsBusy = EFalse;
+        }
+
+    else // give up on sending
+        {
+        HTI_LOG_FORMAT( "Other dispatcher error %d", err );
+        delete iMessage;
+        iMessage = NULL;
+        iIsBusy = EFalse;
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiAudioServicePlugin::SendResponseMsg" );
+    return err;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiAudioServicePlugin::SendErrorResponseMsg
+// Sends an error message out to the message dispatcher.
+// -----------------------------------------------------------------------------
+//
+TInt CHtiAudioServicePlugin::SendErrorResponseMsg( TInt aErrorCode,
+                        const TDesC8& aErrorDescription,
+                        const TUint8 aCommandId )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAudioServicePlugin::SendErrorResponseMsg" );
+
+    iErrorCode = aErrorCode;
+
+    if ( iDispatcher == NULL )
+        {
+        iIsBusy = EFalse;
+        return KErrGeneral;
+        }
+
+    iDispatcher->RemoveMemoryObserver( this );
+
+    delete iMessage;
+    iMessage = NULL;
+    iMessage = HBufC8::New( aErrorDescription.Length() + 1 );
+
+    if ( iMessage == NULL )
+        {
+        iIsBusy = EFalse;
+        return KErrNoMemory;
+        }
+
+    TPtr8 ptr8 = iMessage->Des();
+    if ( aCommandId != 0 )
+        {
+        ptr8.Append( aCommandId );
+        }
+    else
+        {
+        ptr8.Append( iCommandId );
+        }
+
+    ptr8.Append( aErrorDescription );
+
+    TInt err = KErrNone;
+
+    err = iDispatcher->DispatchOutgoingErrorMessage(
+        aErrorCode, *iMessage, KAudioServiceUid );
+
+    if ( err == KErrNoMemory )
+        {
+        HTI_LOG_TEXT( "Message queue memory full - waiting" );
+        iIsBusy = ETrue; // Should already be true, but just in case
+        iDispatcher->AddMemoryObserver( this );
+        // For the caller of this method all is OK, sending is just delayed
+        err = KErrNone;
+        }
+
+    else if ( err == KErrNone )
+        {
+        HTI_LOG_TEXT( "Error message sent to dispatcher" );
+        delete iMessage;
+        iMessage = NULL;
+        iIsBusy = EFalse;
+        }
+
+    else // give up on sending
+        {
+        HTI_LOG_FORMAT( "Other dispatcher error %d", err );
+        delete iMessage;
+        iMessage = NULL;
+        iIsBusy = EFalse;
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiAudioServicePlugin::SendErrorResponseMsg" );
+    return err;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiAudioServicePlugin::ParseString()
+// -----------------------------------------------------------------------------
+//
+TInt CHtiAudioServicePlugin::ParseString( const TDesC8& aRequest,
+                                          TInt aOffset,
+                                          TDes& aResult )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAudioServicePlugin::ParseString" );
+
+    // If offset outside the string return empty string
+    if ( aOffset >= aRequest.Size() )
+        {
+        return aOffset;
+        }
+
+    TInt length = aRequest[aOffset];
+    HTI_LOG_FORMAT( "String length = %d", length );
+
+    // If length is zero return empty string
+    if ( length < 1 )
+        {
+        return aOffset + 1;
+        }
+
+    if ( length > aResult.MaxLength() )
+        {
+        return KErrBadDescriptor;
+        }
+
+    TInt nextOffset = length + aOffset + 1;
+    HTI_LOG_FORMAT( "Next offset = %d", nextOffset );
+    HTI_LOG_FORMAT( "Request size = %d", aRequest.Size() );
+
+    if ( nextOffset > aRequest.Size() )
+        {
+        return KErrArgument;
+        }
+
+    aResult.Copy( aRequest.Mid( aOffset + 1, length ) );
+
+    HTI_LOG_FUNC_OUT( "CHtiAudioServicePlugin::ParseString" );
+    return nextOffset;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiAudioServicePlugin::AddSubdirsRecursivelyL
+// Scan all subdirectories from the given path and add them to the aArray.
+// -----------------------------------------------------------------------------
+//
+void CHtiAudioServicePlugin::AddSubdirsRecursivelyL( const TDesC& aPath,
+                                                     CDesCArraySeg& aArray,
+                                                     RFs& aFs )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAudioServicePlugin::AddSubdirsRecursivelyL" );
+
+    CDirScan* dirScan = CDirScan::NewL( aFs );
+    CleanupStack::PushL( dirScan );
+
+    TFileName* path = new (ELeave) TFileName;
+    CleanupStack::PushL( path );
+
+    CDir* directory = NULL;
+    TPtrC currentPath;
+
+    dirScan->SetScanDataL( aPath, KEntryAttMatchExclusive | KEntryAttDir, ESortNone );
+    dirScan->NextL( directory );
+
+    while ( directory )
+        {
+        CleanupStack::PushL( directory );
+        currentPath.Set( dirScan->FullPath() );
+
+        TInt dirCount( directory->Count() );
+        for ( TInt i = 0; i < dirCount ; ++i )
+            {
+            path->Copy( currentPath );
+            path->Append( ( *directory )[ i ].iName );
+            path->Append( KBackslash );
+            aArray.AppendL( *path );
+            }
+
+        CleanupStack::PopAndDestroy( directory );
+        directory = NULL;
+
+        dirScan->NextL( directory );
+        }
+
+    CleanupStack::PopAndDestroy( 2 ); // path, dirScan
+
+    HTI_LOG_FUNC_OUT( "CHtiAudioServicePlugin::AddSubdirsRecursivelyL" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiAudioServicePlugin::MatchMimeTypeL
+// Check if the MIME type of the given file matches to the given pattern.
+// -----------------------------------------------------------------------------
+//
+TBool CHtiAudioServicePlugin::MatchMimeTypeL( const TDesC& aFilePath,
+                      const TDesC& aMimeTypeMatchPattern )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAudioServicePlugin::MatchMimeTypeL" );
+
+    RApaLsSession apaSession;
+    User::LeaveIfError( apaSession.Connect() );
+    CleanupClosePushL( apaSession );
+
+    TUid dummyUid( KNullUid );
+    TDataType dataType;
+    User::LeaveIfError( apaSession.AppForDocument( aFilePath,
+                                                   dummyUid,
+                                                   dataType ) );
+    CleanupStack::PopAndDestroy(); // apaSession
+
+    if ( dataType.Des().MatchF( aMimeTypeMatchPattern ) >= 0 )
+        {
+        HTI_LOG_TEXT( "Match" );
+        return ETrue;
+        }
+
+    HTI_LOG_TEXT( "Not match" );
+    HTI_LOG_FUNC_OUT( "CHtiAudioServicePlugin::MatchMimeTypeL" );
+    return EFalse;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiAudioServicePlugin::SetAudioSettings
+// Set the audio priority and priority preference values.
+// -----------------------------------------------------------------------------
+//
+void CHtiAudioServicePlugin::SetAudioSettings( TAudioSetting aSetting )
+    {
+    HTI_LOG_FUNC_IN( "CHtiAudioServicePlugin::SetAudioSettings" );
+    HTI_LOG_FORMAT( "Setting values for audio setting %d", aSetting );
+
+    switch ( aSetting )
+        {
+        case EGeneralMusic:
+            {
+            iAudioPriority = KAudioPriorityRealOnePlayer;
+            iAudioPriorityPreference =
+                ( TMdaPriorityPreference ) KAudioPrefRealOneLocalPlayback;
+            break;
+            }
+
+        case ERingTonePreview:
+            {
+            iAudioPriority = KAudioPriorityRingingTonePreview;
+            iAudioPriorityPreference =
+                ( TMdaPriorityPreference ) KAudioPrefRingFilePreview;
+            break;
+            }
+/*
+        case EIncomingCall:
+            {
+            iAudioPriority = KAudioPriorityPhoneCall;
+            iAudioPriorityPreference =
+                ( TMdaPriorityPreference ) KAudioPrefIncomingCall;
+            break;
+            }
+*/
+        case EDtmfString:
+            {
+
+            iAudioPriority = KAudioPriorityDTMFString;
+            iAudioPriorityPreference =
+                ( TMdaPriorityPreference ) KAudioDTMFString;
+            break;
+            }
+
+        default:
+            {
+            iAudioPriority = EMdaPriorityNormal;
+            iAudioPriorityPreference = EMdaPriorityPreferenceTimeAndQuality;
+            break;
+            }
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiAudioServicePlugin::SetAudioSettings" );
+    }
+
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiAudioServicePlugin/src/proxy.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,35 @@
+/*
+* 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:  Implementation proxy for the ECom plugin.
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <ecom/implementationproxy.h>
+#include "HtiAudioServicePlugin.h"
+
+const TImplementationProxy ImplementationTable[] =
+    {
+        IMPLEMENTATION_PROXY_ENTRY( 0x10210CCB, CHtiAudioServicePlugin::NewL )
+    };
+
+// Function used to return an instance of the proxy table.
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
+    {
+    aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
+    return ImplementationTable;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiFtpBackupFake/bwins/HtiFtpBackupFakeu.def	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?NewHtiFtpBackupFake@@YAPAVCHtiFtpBackupFake@@XZ @ 1 NONAME ; class CHtiFtpBackupFake * NewHtiFtpBackupFake(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiFtpBackupFake/eabi/HtiFtpBackupFakeu.def	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	_Z19NewHtiFtpBackupFakev @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiFtpBackupFake/group/HtiFtpBackupFake.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,45 @@
+/*
+* 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:  Build description file for HtiFtpBackupFake
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          HtiFtpBackupFake.dll
+TARGETTYPE      DLL
+
+// HtiFtpBackupFakeInterface UID followed by the unique UID for this DLL
+UID             0x20022D5F 0x20022D60
+
+VENDORID        0x101FB657
+
+CAPABILITY      ALL -TCB
+
+SOURCEPATH      ../src
+SOURCE          HtiFtpBackupFake.cpp
+
+USERINCLUDE     ../inc
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   /epoc32/include/connect
+
+LIBRARY         euser.lib
+LIBRARY         efsrv.lib
+LIBRARY         sbeclient.lib
+LIBRARY         flogger.lib
+
+SMPSAFE
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiFtpBackupFake/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,26 @@
+/*
+* 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:  Build information file for HtiFtpBackupFake
+*
+*/
+
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+HtiFtpBackupFake.mmp
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiFtpBackupFake/inc/HtiFtpBackupFake.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  Definition of the CHtiFtpBackupFake class.
+*
+*/
+
+
+#ifndef __HTIFTPBACKUPFAKE_H
+#define __HTIFTPBACKUPFAKE_H
+
+//  INCLUDES
+#include <e32std.h>
+#include <f32file.h>
+#include <connect/sbeclient.h>
+#include <HtiFtpBackupFakeBase.h>
+
+using namespace conn;
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+* Definition of the class implementing the CHtiFtpBackupFakeBase
+*/
+NONSHARABLE_CLASS( CHtiFtpBackupFake ) : public CHtiFtpBackupFakeBase
+    {
+    public:
+        // constructor support
+        virtual void ConstructL( RFs* aFs );
+
+        // destructor
+        virtual ~CHtiFtpBackupFake();
+
+    public: // from CHtiFtpBackupFakeBase
+        virtual TInt ActivateBackup();
+        virtual TInt DeactivateBackup();
+
+    private:
+        CSBEClient* iSBEClient; // owned
+    };
+
+#endif // __HTIFTPBACKUPFAKE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiFtpBackupFake/src/HtiFtpBackupFake.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  CHtiFtpBackupFake implementation
+*
+*/
+
+
+// INCLUDE FILES
+#include "HtiFtpBackupFake.h"
+#include <HtiLogging.h>
+
+// CONSTANTS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CHtiFtpBackupFake* NewHtiFtpBackupFake()
+// Function to construct the CHtiFtpBackupFakeBase derived object.
+// Exported at ordinal 1 and not a member of the class.
+// -----------------------------------------------------------------------------
+EXPORT_C CHtiFtpBackupFake* NewHtiFtpBackupFake()
+    {
+    return new ( ELeave ) CHtiFtpBackupFake();
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CHtiFtpBackupFake::ConstructL
+// -----------------------------------------------------------------------------
+void CHtiFtpBackupFake::ConstructL( RFs* aFs )
+    {
+    HTI_LOG_FUNC_IN( "CHtiFtpBackupFake::ConstructL" );
+    iFs = aFs;
+    iSBEClient = NULL;
+    HTI_LOG_FUNC_OUT( "CHtiFtpBackupFake::ConstructL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CHtiFtpBackupFake::~CHtiFtpBackupFake()
+// -----------------------------------------------------------------------------
+CHtiFtpBackupFake::~CHtiFtpBackupFake()
+    {
+    HTI_LOG_FUNC_IN( "CHtiFtpBackupFake::~CHtiFtpBackupFake" );
+    if ( iSBEClient )
+        {
+        DeactivateBackup(); // will delete iSBEClient
+        }
+    delete iSBEClient;  // just to be sure
+    iSBEClient = NULL;
+    iFs = NULL; // iFs is not owned
+    HTI_LOG_FUNC_OUT( "CHtiFtpBackupFake::~CHtiFtpBackupFake" );
+    }
+
+// -----------------------------------------------------------------------------
+// CHtiFtpBackupFake::ActivateBackup()
+// Activates the backup operation if isn't already active.
+// -----------------------------------------------------------------------------
+TInt CHtiFtpBackupFake::ActivateBackup()
+    {
+    HTI_LOG_FUNC_IN( "CHtiFtpBackupFake::ActivateBackup" );
+    TInt err = KErrNone;
+    if ( iSBEClient )
+        {
+        err = KErrAlreadyExists; // Backup already active
+        }
+    else
+        {
+        HTI_LOG_TEXT( "Activating backup" );
+        TDriveList drives;
+        err = iFs->DriveList( drives );
+        if ( !err )
+            {
+            TRAP( err, iSBEClient = CSBEClient::NewL() );
+            if ( !err )
+                {
+                TRAP( err, iSBEClient->SetBURModeL(
+                    drives, EBURBackupFull, EBackupBase ) );
+                HTI_LOG_FORMAT( "CSBEClient::SetBURModeL returned %d", err );
+                if ( !err )
+                    {
+                    User::After( 1000000 ); // wait for the backup to activate
+                    }
+                }
+            }
+        }
+    HTI_LOG_FUNC_OUT( "CHtiFtpBackupFake::ActivateBackup" );
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// CHtiFtpBackupFake::DeactivateBackup()
+// Deactivates the backup operation if it's active.
+// -----------------------------------------------------------------------------
+TInt CHtiFtpBackupFake::DeactivateBackup()
+    {
+    HTI_LOG_FUNC_IN( "CHtiFtpBackupFake::DeactivateBackup" );
+    TInt err = KErrNone;
+
+    if ( !iSBEClient )
+        {
+        err = KErrNotReady; // Backup not active
+        }
+    else
+        {
+        HTI_LOG_TEXT( "Deactivating Backup" );
+        TDriveList drives;
+        err = iFs->DriveList( drives );
+        if ( !err )
+            {
+            TRAP( err, iSBEClient->SetBURModeL(
+                drives, EBURNormal, ENoBackup ) );
+            HTI_LOG_FORMAT( "CSBEClient::SetBURModeL returned %d", err );
+            }
+        delete iSBEClient;
+        iSBEClient = NULL;
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiFtpBackupFake::DeactivateBackup" );
+    return err;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiKeyEventServicePlugin/data/1020DEC0.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  Resource definitions for key event service ECOM plugin.
+*
+*/
+
+
+// INCLUDES
+#include <ecom/registryinfo.rh>
+
+
+//  RESOURCE DEFINITIONS
+RESOURCE REGISTRY_INFO theInfo
+    {
+    // UID for the DLL
+    dll_uid = 0x1020DEC0;
+    // Declare array of interface info
+    interfaces =
+        {
+        INTERFACE_INFO
+            {
+            // UID of interface that is implemented
+            interface_uid = 0x1020DEB7;
+            implementations =
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = 0x1020DEC1;
+                    version_no         = 1;
+                    display_name       = "Key event service";
+                    default_data       = "KEYEVENT";
+                    opaque_data        = "";
+                    }
+                };
+            }
+        };
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiKeyEventServicePlugin/group/HtiKeyEventServicePlugin.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,54 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ECOM implementation of key event service
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          HtiKeyEventServicePlugin.dll
+TARGETTYPE      PLUGIN
+
+// ECom Dll recognition UID followed by the unique UID for this dll
+UID             0x10009D8D 0x1020DEC0
+
+VENDORID        0x101FB657
+
+CAPABILITY      ALL -TCB
+
+SOURCEPATH      ../src
+SOURCE          proxy.cpp
+SOURCE          HtiKeyEventServicePlugin.cpp
+SOURCE          KeyEventHandler.cpp
+SOURCE          PointerEventHandler.cpp
+
+USERINCLUDE     ../inc
+APP_LAYER_SYSTEMINCLUDE
+
+START RESOURCE  ../data/1020DEC0.rss
+TARGET          HtiKeyEventServicePlugin.rsc
+END
+
+LIBRARY         apgrfx.lib
+LIBRARY         centralrepository.lib
+LIBRARY         cenrepnotifhandler.lib
+LIBRARY         ecom.lib
+LIBRARY         euser.lib
+LIBRARY         ws32.lib
+LIBRARY         flogger.lib
+
+SMPSAFE
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiKeyEventServicePlugin/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,26 @@
+/*
+* 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:  Build info for HtiKeyEventServicePlugin
+*
+*/
+
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+HtiKeyEventServicePlugin.mmp
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiKeyEventServicePlugin/inc/HtiKeyEventServicePlugin.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,76 @@
+/*
+* 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:  Implementation of ECOM plug-in service interface. Provides
+*                key event service.
+*
+*/
+
+
+#ifndef CHTIKEYEVENTSERVICEPLUGIN_H
+#define CHTIKEYEVENTSERVICEPLUGIN_H
+
+// INCLUDES
+#include <HTIServicePluginInterface.h>
+#include <w32std.h>
+#include <centralrepository.h>
+#include <CenRepNotifyHandler.h>
+
+
+// CONSTANTS
+const TInt KKeyEventServiceUidValue = 0x1020DEC1; // ECOM Implementation UID
+const TUid KKeyEventServiceUid = { KKeyEventServiceUidValue };
+
+// FORWARD DECLARATIONS
+class CKeyEventHandler;
+class CPointerEventHandler;
+
+// CLASS DECLARATION
+
+/**
+* Implementation of ECOM plug-in service interface.
+*/
+class CHtiKeyEventServicePlugin : public CHTIServicePluginInterface
+                                 ,public MCenRepNotifyHandlerCallback
+    {
+public:
+
+    static CHtiKeyEventServicePlugin* NewL();
+
+    // Interface implementation
+    void ProcessMessageL( const TDesC8& aMessage,
+        THtiMessagePriority aPriority );
+
+protected:
+
+    CHtiKeyEventServicePlugin();
+    void ConstructL();
+
+    virtual ~CHtiKeyEventServicePlugin();
+
+    // from MCenRepNotifyHandlerCallback
+    void HandleNotifyInt( TUint32 aId, TInt aNewValue );
+    void HandleNotifyError( TUint32 aId, TInt error,
+            CCenRepNotifyHandler* aHandler );
+
+private:
+
+    CKeyEventHandler* iKeyHandler;
+    CPointerEventHandler* iPointerHandler;
+    TInt iLightTimeout;
+    CRepository* iCenRepSession;
+    CCenRepNotifyHandler* iLightTimeoutSettingHandler;
+    };
+
+#endif // CHTIKEYEVENTSERVICEPLUGIN_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiKeyEventServicePlugin/inc/KeyEventHandler.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,117 @@
+/*
+* 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:  Functional implentation of key event service.
+*
+*/
+
+
+#ifndef CKEYEVENTHANDLER_H
+#define CKEYEVENTHANDLER_H
+
+
+// INCLUDES
+#include <HTIServicePluginInterface.h>
+#include <w32std.h>
+
+// CONSTANTS
+
+// CLASS DECLARATION
+
+/**
+*  Functional implentation of key event service.
+*/
+class CKeyEventHandler : public CActive
+    {
+public:
+
+    static CKeyEventHandler* NewL();
+
+    // Interface implementation
+    void ProcessMessageL( const TDesC8& aMessage,
+        THtiMessagePriority aPriority );
+
+    virtual ~CKeyEventHandler();
+
+    void SetDispatcher( MHtiDispatcher* aDispatcher );
+
+    enum TError
+        {
+        EMissingCommand          = 0x01,
+        EUnrecognizedCommand     = 0x02,
+        ENotReadyCommand         = 0x03,
+        EInvalidScancode         = 0x80,
+        EEmptyUnicodeCharArray   = 0x90,
+        EInvalidUnicodeCharArray = 0x91
+        };
+
+    enum TCommand
+        {
+        EPressKey         = 0x01,
+        EKeyDown          = 0x02,
+        EKeyUp            = 0x03,
+        ETypeText         = 0x04,
+        ELongKeyPress     = 0x05,
+        ETypeTextPassword = 0x06,
+        EPressKeySequence = 0x07,
+        EResultOk = 0xFF // only for response message
+        };
+
+protected:
+
+    void RunL();
+    TInt RunError(TInt aError);
+    void DoCancel();
+
+private:
+
+    CKeyEventHandler();
+    void ConstructL();
+
+private: // helpers
+
+    void HandleTypeTextFuncL( const TDesC8& aUnicodeChars );
+    void HandleKeyboardFuncL( const TDesC8& aData );
+    void HandleLongKeyPressFuncL( const TDesC8& aData );
+    void HandlePressKeySequenceFuncL( const TDesC8& aData );
+
+    void SendOkMsgL();
+    void SendErrorMessageL( TInt aError, const TDesC8& aDescription );
+
+    void TypeTextWithDelay( TInt aNextIndex );
+    void SimulateKeyEventL( const TDesC8& aUnicodeChars, TInt aIndex );
+    void PressKeySequenceKeyL();
+
+    void KeyUp( TUint aCode );
+    void KeyDown( TUint aCode );
+
+private:
+
+    RWsSession iWsSession;
+    MHtiDispatcher* iDispatcher; // referenced
+
+    // Typetext specialities:
+    RTimer  iTimer;
+    TInt    iFocusedWindowGroup;
+    HBufC8* iUnicodeChars;
+    TInt    iUnicodeCharIndex;
+
+    TBool                           iReady;
+    TUint8                          iCommand;
+    TUint                           iHoldingScanCode;
+    TTimeIntervalMicroSeconds32     iKeySequenceHoldTime;
+    TTimeIntervalMicroSeconds32     iKeySequenceInterval;
+    TBool                           iHoldingKey;
+    };
+
+#endif // CKEYEVENTHANDLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiKeyEventServicePlugin/inc/PointerEventHandler.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,149 @@
+/*
+* 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:  Functional implentation of pointer event service.
+*
+*/
+
+
+#ifndef CPOINTEREVENTHANDLER_H
+#define CPOINTEREVENTHANDLER_H
+
+// INCLUDES
+#include <HTIServicePluginInterface.h>
+#include <w32std.h>
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+*  Functional implentation of pointer event service.
+*/
+class CPointerEventHandler : public CActive
+    {
+    public:
+
+        enum TError
+            {
+            EMissingCommand          = 0x01,
+            EUnrecognizedCommand     = 0x02,
+            ENotReadyCommand         = 0x03,
+            EInvalidParameters       = 0x9A
+            };
+
+        enum TCommand
+            {
+            ETapScreen = 0x10,
+            ETapAndDrag = 0x11,
+            ETapAndDragMultipoint = 0x12,
+            EPressPointerDown = 0x13,
+            ELiftPointerUp = 0x14,
+            EResultOk = 0xFF // only for response message
+            };
+
+        enum TPointerState
+            {
+            EPointerUp,
+            EPointerDown,
+            EPointerMoving
+            };
+
+        /**
+        * Two-phased constructor.
+        */
+        static CPointerEventHandler* NewL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CPointerEventHandler();
+
+        /**
+        * Called by the HtiKeyEventServicePlugin when a pointer event
+        * command is received.
+        * @param aMessage message body destinated to the servive
+        * @param aPriority message priority
+        */
+        void ProcessMessageL( const TDesC8& aMessage,
+            THtiMessagePriority aPriority );
+
+        /**
+        * Sets the dispatcher to send outgoing messages to.
+        * @param aDispatcher pointer to dispatcher instance
+        */
+        void SetDispatcher( MHtiDispatcher* aDispatcher );
+
+
+    protected: // Functions from base classes
+
+        // From CActive
+        void RunL();
+        TInt RunError(TInt aError);
+        void DoCancel();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CPointerEventHandler();
+
+        /**
+        * 2nd phase constructor.
+        */
+        void ConstructL();
+
+        // Helper methods
+        void HandleTapScreenL( const TDesC8& aData );
+        void HandleTapAndDragL( const TDesC8& aData );
+        void HandleTapAndDragMultipointL( const TDesC8& aData );
+        void HandlePointerDownOrUpL( const TDesC8& aData );
+
+        void SendOkMsgL();
+        void SendErrorMessageL( TInt aError, const TDesC8& aDescription );
+
+        void ChangePointerStateL();
+        void MoveToNextPointL();
+        void PointerDown();
+        void PointerUp();
+        void PointerMove();
+        void SimulatePointerEvent( TRawEvent::TType aType );
+
+
+    private: // data
+
+        RWsSession iWsSession;
+        MHtiDispatcher* iDispatcher; // referenced
+
+        RTimer iTimer;
+        TBool  iReady;
+        TUint8 iCommand;
+        TInt   iX;
+        TInt   iY;
+        TInt   iTapCount;
+        TTimeIntervalMicroSeconds32 iEventDelay;
+        TTimeIntervalMicroSeconds32 iActionDelay;
+        TPointerState iState;
+        RArray<TInt>* iCoords;
+    };
+
+#endif // CKEYEVENTHANDLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiKeyEventServicePlugin/src/HtiKeyEventServicePlugin.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,165 @@
+/*
+* 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:  KeyEventPlugin entry implementation
+*
+*/
+
+
+// INCLUDE FILES
+#include "HtiKeyEventServiceplugin.h"
+#include "KeyEventHandler.h"
+#include "PointerEventHandler.h"
+
+#include <HtiDispatcherInterface.h>
+#include <HTILogging.h>
+#include <HWRMLightDomainCRKeys.h>
+
+// CONSTANTS
+_LIT8( KErrorMissingCommand, "Command was not given - message was empty" );
+const TInt KDefaultMinLightTimeout = 5;
+const TInt KWakeupWaitTime = 200000; // 0.2 sec
+
+// ----------------------------------------------------------------------------
+// CHtiKeyEventServicePlugin::NewL()
+// Create instance of concrete ECOM interface implementation
+// ----------------------------------------------------------------------------
+CHtiKeyEventServicePlugin* CHtiKeyEventServicePlugin::NewL()
+    {
+    CHtiKeyEventServicePlugin* self = new (ELeave) CHtiKeyEventServicePlugin;
+    CleanupStack::PushL (self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CHtiKeyEventServicePlugin::CHtiKeyEventServicePlugin()
+// ----------------------------------------------------------------------------
+CHtiKeyEventServicePlugin::CHtiKeyEventServicePlugin()
+        : iLightTimeout( KDefaultMinLightTimeout ),
+          iCenRepSession( NULL ),
+          iLightTimeoutSettingHandler( NULL )
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CHtiKeyEventServicePlugin::~CHtiKeyEventServicePlugin()
+// ----------------------------------------------------------------------------
+CHtiKeyEventServicePlugin::~CHtiKeyEventServicePlugin()
+    {
+    HTI_LOG_TEXT( "CHtiKeyEventServicePlugin destroy" );
+    delete iKeyHandler;
+    delete iPointerHandler;
+    if ( iLightTimeoutSettingHandler )
+        {
+        iLightTimeoutSettingHandler->StopListening();
+        }
+    delete iLightTimeoutSettingHandler;
+    delete iCenRepSession;
+    }
+
+// ----------------------------------------------------------------------------
+// CHtiKeyEventServicePlugin::ConstructL()
+// ----------------------------------------------------------------------------
+void CHtiKeyEventServicePlugin::ConstructL()
+    {
+    HTI_LOG_FUNC_IN( "CHtiKeyEventServicePlugin::ConstructL" );
+    iCenRepSession = CRepository::NewL( KCRUidLightSettings );
+    iLightTimeoutSettingHandler = CCenRepNotifyHandler::NewL( *this,
+            *iCenRepSession, CCenRepNotifyHandler::EIntKey,
+            KDisplayLightsTimeout );
+    iLightTimeoutSettingHandler->StartListeningL();
+    HTI_LOG_FUNC_OUT( "CHtiKeyEventServicePlugin::ConstructL" );
+    }
+
+// ----------------------------------------------------------------------------
+// CHtiKeyEventServicePlugin::ProcessMessageL()
+// ----------------------------------------------------------------------------
+void CHtiKeyEventServicePlugin::ProcessMessageL( const TDesC8& aMessage,
+    THtiMessagePriority aPriority)
+    {
+    HTI_LOG_FUNC_IN( "CHtiKeyEventServicePlugin::ProcessMessageL" );
+
+    if ( aMessage.Length() == 0 )
+        {
+        User::LeaveIfNull( iDispatcher );
+        User::LeaveIfError( iDispatcher->DispatchOutgoingErrorMessage(
+            CKeyEventHandler::EMissingCommand,
+            KErrorMissingCommand, KKeyEventServiceUid ) );
+        return;
+        }
+
+    HTI_LOG_FORMAT( "Light timeout = %d", iLightTimeout );
+    TTimeIntervalSeconds inactivityTime = User::InactivityTime();
+    HTI_LOG_FORMAT( "Inactivity time = %d", inactivityTime.Int() );
+    if ( inactivityTime.Int() >= iLightTimeout )
+        {
+        HTI_LOG_TEXT( "Waking up" );
+        User::ResetInactivityTime();
+        User::After( KWakeupWaitTime );
+        }
+
+    if ( aMessage[0] <= CKeyEventHandler::EPressKeySequence )
+        {
+        if ( iKeyHandler == NULL )
+            {
+            iKeyHandler = CKeyEventHandler::NewL();
+            iKeyHandler->SetDispatcher( iDispatcher );
+            }
+        iKeyHandler->ProcessMessageL( aMessage, aPriority );
+        }
+
+    else
+        {
+        if ( iPointerHandler == NULL )
+            {
+            iPointerHandler = CPointerEventHandler::NewL();
+            iPointerHandler->SetDispatcher( iDispatcher );
+            }
+        iPointerHandler->ProcessMessageL( aMessage, aPriority );
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiKeyEventServicePlugin::ProcessMessageL: Done" );
+    }
+
+// ---------------------------------------------------------------------------
+// From MCenRepNotifyHandlerCallback.
+// CHtiKeyEventServicePlugin::HandleNotifyInt
+// ---------------------------------------------------------------------------
+//
+void CHtiKeyEventServicePlugin::HandleNotifyInt( TUint32 aId, TInt aNewValue )
+    {
+    HTI_LOG_FUNC_IN( "CHtiKeyEventServicePlugin::HandleNotifyInt" );
+    if ( aId == KDisplayLightsTimeout )
+        {
+        HTI_LOG_FORMAT( "New light timeout value %d", aNewValue );
+        iLightTimeout = aNewValue;
+        }
+    HTI_LOG_FUNC_OUT( "CHtiKeyEventServicePlugin::HandleNotifyInt" );
+    }
+
+// ---------------------------------------------------------------------------
+// From MCenRepNotifyHandlerCallback.
+// CHtiKeyEventServicePlugin::HandleNotifyError
+// ---------------------------------------------------------------------------
+//
+void CHtiKeyEventServicePlugin::HandleNotifyError( TUint32 /*aId*/,
+        TInt /*error*/, CCenRepNotifyHandler* /*aHandler*/ )
+    {
+    HTI_LOG_TEXT( "CHtiKeyEventServicePlugin::HandleNotifyError()" );
+    iLightTimeout = KDefaultMinLightTimeout;
+    TRAP_IGNORE( iLightTimeoutSettingHandler->StartListeningL() );
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiKeyEventServicePlugin/src/KeyEventHandler.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,663 @@
+/*
+* 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:  Functional implementation of key event service
+*
+*/
+
+
+// INCLUDE FILES
+#include "HtiKeyEventServiceplugin.h"
+#include "KeyEventHandler.h"
+
+#include <apgtask.h>
+#include <HtiDispatcherInterface.h>
+#include <HTILogging.h>
+
+
+// CONSTANTS
+_LIT8( KErrorServiceNotReady, "Service is busy - possibly executing long running typetext or long key press functionality" );
+_LIT8( KErrorUnrecognizedCommand, "Unrecognized command" );
+_LIT8( KErrorEmptyUnicodeArray, "Unicode char array was empty" );
+_LIT8( KErrorInvalidUnicodeCharArray, "Invalid unicode character array" );
+_LIT8( KErrorInvalidScancode, "Invalid scancode. Wrong length" );
+_LIT8( KErrorTypeTextFailure, "Internal typetext failure" );
+_LIT8( KErrorLongKeyPressFailure, "Internal long key press failure" );
+
+const TInt KKeyboardFuncDataLength = 2;  // scancode with 2 bytes
+const TInt KLongKeyPressDataLength = 4;  // scancode 2 bytes + time 2 bytes
+const TInt KPressKeySequenceMinDataLength = 6;  // hold time 2 bytes + key press interval 2 bytes + at least one scancode 2 bytes
+const TInt KTypeTextDelayBetweenCharsInMicroSeconds = 50000; // 50 milliseconds
+const TInt KTypeTextStartPausing = 200; // start pausing after this many characters
+const TInt KTypeTextPauseInterval = 50; // how many chars to type before pausing
+const TInt KTypeTextPauseInMicroSeconds = 800000; // 0.8 sec
+
+
+// ----------------------------------------------------------------------------
+// UintValue()
+// Helper: aPtr must point to 16 bits area where the value will be extracted
+// ----------------------------------------------------------------------------
+TUint UintValue( const TUint8* aPtr )
+    {
+    // This is short way to do it..
+    //return (aPtr[1]<<8) + aPtr[0];
+
+    TUint8 uInt8Low = *aPtr;
+    TUint8 uInt8High = *(aPtr+1);
+
+    HTI_LOG_FORMAT( "UintValue:: Low: %d", uInt8Low );
+    HTI_LOG_FORMAT( "UintValue:: High: %d", uInt8High );
+
+    TUint16 uInt16 = (TUint16)uInt8High;
+    uInt16 = (uInt16 << 8);
+    uInt16 = uInt16 + (TUint)uInt8Low;
+
+    HTI_LOG_FORMAT( "UintValue:: 16-bit value: %d", uInt16 );
+
+    TUint uInt = (TUint)uInt16;
+    HTI_LOG_FORMAT( "UintValue:: 32-bit value: %d", uInt );
+
+    return uInt;
+    }
+
+// ----------------------------------------------------------------------------
+// CKeyEventHandler::NewL()
+// ----------------------------------------------------------------------------
+CKeyEventHandler* CKeyEventHandler::NewL()
+    {
+    HTI_LOG_FUNC_IN( "CKeyEventHandler::NewL" );
+    CKeyEventHandler* self = new (ELeave) CKeyEventHandler();
+    CleanupStack::PushL ( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    HTI_LOG_FUNC_OUT( "CKeyEventHandler::Done" );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CKeyEventHandler::CKeyEventHandler()
+// ----------------------------------------------------------------------------
+CKeyEventHandler::CKeyEventHandler()
+    : CActive( CActive::EPriorityStandard ), iReady( ETrue ), iCommand( 0 ),
+      iHoldingScanCode( 0 )
+
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CKeyEventHandler::~CKeyEventHandler()
+// ----------------------------------------------------------------------------
+CKeyEventHandler::~CKeyEventHandler()
+    {
+    HTI_LOG_TEXT( "CKeyEventHandler destroy" );
+    Cancel();
+    iTimer.Close();
+    iWsSession.Close();
+    delete iUnicodeChars;
+    iUnicodeChars = NULL;
+    }
+
+// ----------------------------------------------------------------------------
+// CKeyEventHandler::ConstructL()
+// ----------------------------------------------------------------------------
+void CKeyEventHandler::ConstructL()
+    {
+    HTI_LOG_TEXT( "CKeyEventHandler::ConstructL" );
+    User::LeaveIfError( iWsSession.Connect() );
+    User::LeaveIfError( iTimer.CreateLocal() );
+    CActiveScheduler::Add( this );
+    }
+
+// ----------------------------------------------------------------------------
+// CKeyEventHandler::SetDispatcher()
+// ----------------------------------------------------------------------------
+void CKeyEventHandler::SetDispatcher( MHtiDispatcher* aDispatcher )
+    {
+    iDispatcher = aDispatcher;
+    }
+
+// ----------------------------------------------------------------------------
+// CKeyEventHandler::RunL()
+// ----------------------------------------------------------------------------
+void CKeyEventHandler::RunL()
+    {
+    HTI_LOG_FUNC_IN( "CKeyEventHandler::RunL" );
+
+    if ( iCommand == ELongKeyPress )
+        {
+        KeyUp( iHoldingScanCode );
+        SendOkMsgL();
+        iReady = ETrue;
+        HTI_LOG_TEXT( "CKeyEventHandler::RunL: LongKeyPress has finished" );
+        }
+
+    else if ( iCommand == ETypeText || iCommand == ETypeTextPassword )
+        {
+        SimulateKeyEventL( *iUnicodeChars, iUnicodeCharIndex );
+
+        if ( iUnicodeCharIndex == iUnicodeChars->Length() / 2 - 1 )
+            {
+            delete iUnicodeChars;
+            iUnicodeChars = NULL;
+            SendOkMsgL();
+            iReady = ETrue;
+            HTI_LOG_TEXT( "CKeyEventHandler::RunL: TypeText has finished: OK" );
+            }
+        else
+            {
+            iUnicodeCharIndex++;
+            TypeTextWithDelay( iUnicodeCharIndex );
+            }
+        }
+
+    else if ( iCommand == EPressKeySequence )
+        {
+        PressKeySequenceKeyL();
+        }
+
+    HTI_LOG_FUNC_OUT( "CKeyEventHandler::RunL" );
+    }
+
+// ----------------------------------------------------------------------------
+// CKeyEventHandler::RunError()
+// ----------------------------------------------------------------------------
+TInt CKeyEventHandler::RunError( TInt aError )
+    {
+    TInt dispatchResult = KErrNone;
+
+    if ( iCommand == ELongKeyPress )
+        {
+        HTI_LOG_FORMAT( "CKeyEventHandler::RunError: LongKeyPress failure: %d.", aError );
+        dispatchResult = iDispatcher->DispatchOutgoingErrorMessage( aError,
+                KErrorLongKeyPressFailure,  KKeyEventServiceUid );
+        }
+
+    else // it's TypeText
+        {
+        HTI_LOG_FORMAT( "CKeyEventHandler::RunError: TypeText failure: %d.", aError );
+        dispatchResult = iDispatcher->DispatchOutgoingErrorMessage( aError,
+                KErrorTypeTextFailure,  KKeyEventServiceUid );
+        }
+
+    if ( dispatchResult != KErrNone )
+        {
+        HTI_LOG_FORMAT( "CKeyEventHandler::RunError: Failed to send error report to framework: %d.", dispatchResult );
+        }
+    iReady = ETrue;
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// CKeyEventHandler::DoCancel()
+// ----------------------------------------------------------------------------
+void CKeyEventHandler::DoCancel()
+    {
+    iTimer.Cancel();
+    delete iUnicodeChars;
+    iUnicodeChars = NULL;
+    }
+
+// ----------------------------------------------------------------------------
+// CKeyEventHandler::ProcessMessageL()
+// ----------------------------------------------------------------------------
+void CKeyEventHandler::ProcessMessageL( const TDesC8& aMessage,
+    THtiMessagePriority /*aPriority*/ )
+    {
+    HTI_LOG_FUNC_IN("CKeyEventHandler::ProcessMessageL");
+    HTI_LOG_FORMAT("Msg len: %d.", aMessage.Length());
+
+    if ( !iReady )
+        {
+        SendErrorMessageL( ENotReadyCommand, KErrorServiceNotReady );
+        return;
+        }
+
+    iCommand = aMessage.Ptr()[0];
+    switch ( iCommand )
+        {
+        case EPressKey:
+        case EKeyDown:
+        case EKeyUp:
+            HandleKeyboardFuncL( aMessage.Right( aMessage.Length() - 1 ) );
+            break;
+        case ETypeText:
+        case ETypeTextPassword:
+            HandleTypeTextFuncL( aMessage.Right( aMessage.Length() - 1 ) );
+            break;
+        case ELongKeyPress:
+            HandleLongKeyPressFuncL( aMessage.Right( aMessage.Length() - 1 ) );
+            break;
+        case EPressKeySequence:
+            HandlePressKeySequenceFuncL( aMessage.Right( aMessage.Length() - 1 ) );
+            break;
+        default:
+            SendErrorMessageL( EUnrecognizedCommand,
+                KErrorUnrecognizedCommand );
+        break;
+        }
+
+    HTI_LOG_FUNC_OUT( "CKeyEventHandler::ProcessMessageL: Done" );
+    }
+
+// ----------------------------------------------------------------------------
+// CKeyEventHandler::HandleTypeTextFuncL()
+// Handle request to send one or more unicode characters to top most
+// focused UI application.
+// ----------------------------------------------------------------------------
+void CKeyEventHandler::HandleTypeTextFuncL(
+    const TDesC8& aUnicodeChars )
+    {
+    HTI_LOG_FUNC_IN( "CKeyEventHandler::HandleTypeTextFunc" );
+
+    // For UCS-2 and common unicode key code areas, see
+    // http://czyborra.com/unicode/characters.html
+    // "How are the Unicode characters numbered?"
+
+    if ( aUnicodeChars.Size() == 0 )
+        {
+        SendErrorMessageL( EEmptyUnicodeCharArray, KErrorEmptyUnicodeArray );
+        return;
+        }
+
+#ifdef __ENABLE_LOGGING__
+    CArrayFixFlat<TInt> *windowGroups = new (ELeave) CArrayFixFlat<TInt>(5);
+    iWsSession.WindowGroupList(windowGroups);
+    HTI_LOG_FORMAT("WindowGroupList, %d groups:",windowGroups->Count());
+    for ( TInt i = 0; i < windowGroups->Count(); i++ )
+    {
+        TBuf<125> wgname; // max length for wg name?
+        iWsSession.GetWindowGroupNameFromIdentifier((*windowGroups)[i], wgname);
+
+        TBuf<145> logmsg;
+        logmsg.AppendFormat(_L("WgId %3d - \""), (*windowGroups)[i]);
+        logmsg.Append(wgname);
+        logmsg.Append(_L("\""));
+        HTI_LOG_DES(logmsg);
+    }
+    delete windowGroups;
+#endif
+
+    // Get the front most focused window group. Note that this might
+    // not necessarily be the front-most window group, as
+    // window groups can disable keyboard focus.
+    iFocusedWindowGroup = iWsSession.GetFocusWindowGroup();
+
+    HTI_LOG_TEXT("FocusWindowGroup name :");
+    TBuf<125> focusWindowGroupName; // max length for wg name?
+    iWsSession.GetWindowGroupNameFromIdentifier(iFocusedWindowGroup, focusWindowGroupName);
+    HTI_LOG_DES(focusWindowGroupName);
+
+    // ...exception to above! (in EKA2) :
+    // When we are in idle state the text must be sent to 'Telephone' task's
+    // windowgroup because 'idle' windowgroup does not handle keyevents.
+    //
+    // Also when typing in idle state we need EKeyUp event to prevent the key
+    // beeing stuck in the pressed position.
+    //
+    // Window group name contains UID - we are using UID to find the
+    // 'Idle' window group so it will be found also with different
+    // localizations. The name 'Idle' cannot be used since the name is
+    // localized.
+
+    if ( ( focusWindowGroupName.Find( _L( "101fd64c" ) ) != KErrNotFound ) ||
+         ( focusWindowGroupName.Find( _L( "102750f0" ) ) != KErrNotFound ) )
+        {
+        HTI_LOG_TEXT( "FocusWindowGroup is \"Idle\". Sending text to \"Telephone\" task." );
+        TApaTaskList taskList( iWsSession );
+        TApaTask telephoneTask = taskList.FindApp( TUid::Uid( 0x100058b3 ) );
+        if ( !telephoneTask.Exists() )
+            {
+            HTI_LOG_FUNC_OUT( "CKeyEventHandler::SimulateKeyEventL: \"Telephone\" task does not exist" );
+            User::Leave( KErrNotFound );
+            }
+
+        iFocusedWindowGroup = telephoneTask.WgId();
+
+        // We must also get focus to 'Telephone' task for it
+        // to receive our text.
+        TWsEvent event;
+        event.SetType( EEventFocusGained );
+        iWsSession.SendEventToWindowGroup( telephoneTask.WgId(), event );
+        }
+
+    if ( aUnicodeChars.Size() % 2 == 1 )
+        {
+        // aUnicodeChars descriptor must be divisible by two,
+        // because expecting two-byte characters
+        SendErrorMessageL( EInvalidUnicodeCharArray,
+            KErrorInvalidUnicodeCharArray );
+        return;
+        }
+
+    // Start work
+    if ( iUnicodeChars )
+        {
+        delete iUnicodeChars;
+        iUnicodeChars = NULL;
+        }
+
+    // If the string begins with unicode byte order mark 0xfffe, strip it away
+    if ( ( aUnicodeChars[0] == 0xff && aUnicodeChars[1] == 0xfe ) )
+        {
+        HTI_LOG_TEXT( "Ignoring Unicode BOM (first 2 bytes) from the string" );
+        iUnicodeChars = aUnicodeChars.Mid( 2 ).AllocL();
+        }
+    else // take the string as it is
+        {
+        iUnicodeChars = aUnicodeChars.AllocL();
+        }
+    iReady = EFalse;
+
+    TypeTextWithDelay( 0 );
+
+    HTI_LOG_FUNC_OUT("CKeyEventHandler::HandleTypeTextFunc: Done (operation started)");
+    }
+
+// ----------------------------------------------------------------------------
+// CKeyEventHandler::TypeTextWithDelay()
+// ----------------------------------------------------------------------------
+void CKeyEventHandler::TypeTextWithDelay( TInt aNextIndex )
+    {
+    iUnicodeCharIndex = aNextIndex;
+    // Keep a longer pause in some character intervals if the given text
+    // is very long to avoid losing characters.
+    if ( iUnicodeCharIndex > KTypeTextStartPausing &&
+        iUnicodeCharIndex % KTypeTextPauseInterval == 0 )
+        {
+        iTimer.After( iStatus, KTypeTextPauseInMicroSeconds );
+        }
+    else
+        {
+        iTimer.After( iStatus, KTypeTextDelayBetweenCharsInMicroSeconds );
+        }
+    SetActive();
+    }
+
+// ----------------------------------------------------------------------------
+// CKeyEventHandler::SimulateKeyEventL()
+// ----------------------------------------------------------------------------
+void CKeyEventHandler::SimulateKeyEventL( const TDesC8& aUnicodeChars,
+    TInt aIndex )
+    {
+
+    // Expect aUnicodeChars to be Unicode characters (each two bytes)
+    // Note: aIndex is within range of 0 to aUnicodeChars/2
+
+    HTI_LOG_FUNC_IN("CKeyEventHandler::SimulateKeyEventL");
+    TKeyEvent keyEvent;
+    const TUint8* rawDataStart = aUnicodeChars.Ptr();
+    keyEvent.iCode = *( (TUint16*) ( rawDataStart + aIndex * 2 ) );
+    // Set modifier to treat key events as events from external keyboard
+    // so that AknFep won't interfere with numbers and * and # characters.
+    keyEvent.iModifiers = EModifierKeyboardExtend;
+    keyEvent.iRepeats = 0;
+    //keyEvent.iScanCode = EStdKeyNull;
+    // change because FEP got confused about EStdKeyNull in key-up event and
+    // opened the edit menu
+    keyEvent.iScanCode = 255;
+
+    TWsEvent event;
+    *event.Key() = keyEvent;
+
+    if ( iCommand == ETypeTextPassword )
+        {
+        // Typing a password needs only EEventKey.
+        // Otherwise it will appear to be pressed twice.
+        HTI_LOG_FORMAT( "EEventKey 0x%x", keyEvent.iCode );
+        event.SetType( EEventKey );
+        iWsSession.SendEventToWindowGroup( iFocusedWindowGroup, event );
+        }
+    else
+        {
+        // EEventKeyUp is needed when typing a SMS or MMS. Otherwise the
+        // counters will not be updated and message will be corrupt.
+        // Also typing in idle state requires EEventKeyUp for the key to be
+        // released.
+        HTI_LOG_FORMAT( "EEventKey&EEventKeyUp 0x%x", keyEvent.iCode );
+        event.SetType( EEventKey );
+        iWsSession.SendEventToWindowGroup( iFocusedWindowGroup, event );
+
+        event.SetType( EEventKeyUp );
+        iWsSession.SendEventToWindowGroup( iFocusedWindowGroup, event );
+        }
+
+    HTI_LOG_FUNC_OUT( "CKeyEventHandler::SimulateKeyEventL" );
+    }
+
+// ----------------------------------------------------------------------------
+// CKeyEventHandler::KeyUp()
+// ----------------------------------------------------------------------------
+void CKeyEventHandler::KeyUp( TUint aCode )
+    {
+    HTI_LOG_FUNC_IN( "CKeyEventHandler::KeyUp: Starting" );
+    TRawEvent rawEvent;
+    rawEvent.Set( TRawEvent::EKeyUp, aCode );
+    iWsSession.SimulateRawEvent( rawEvent );
+    iWsSession.Flush();
+    HTI_LOG_FUNC_OUT( "CKeyEventHandler::KeyUp: Done" );
+    }
+
+// ----------------------------------------------------------------------------
+// CKeyEventHandler::KeyDown()
+// ----------------------------------------------------------------------------
+void CKeyEventHandler::KeyDown( TUint aCode )
+    {
+    HTI_LOG_FUNC_IN( "CKeyEventHandler::KeyDown: Starting" );
+    User::ResetInactivityTime();
+    TRawEvent rawEvent;
+    rawEvent.Set( TRawEvent::EKeyDown, aCode );
+    iWsSession.SimulateRawEvent( rawEvent );
+    iWsSession.Flush();
+    HTI_LOG_FUNC_OUT( "CKeyEventHandler::KeyDown: Done" );
+    }
+
+// ----------------------------------------------------------------------------
+// CKeyEventHandler::HandleKeyboardFuncL()
+// Handle request to emulate pressing keyboard keys in sequence.
+// ----------------------------------------------------------------------------
+void CKeyEventHandler::HandleKeyboardFuncL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CKeyEventHandler::HandleKeyboardFuncL" );
+
+    HTI_LOG_FORMAT( "CKeyEventHandler::HandleKeyboardFuncL: Size of data: %d", aData.Length() );
+    HTI_LOG_TEXT( "CKeyEventHandler::HandleKeyboardFuncL: Data: " );
+    HTI_LOG_DES( aData );
+
+//  <scancode> is unsigned short integer, a scancode of
+//  keyboard key. Theses are defined in E32KEYS.H. It depends on
+//  device how these are mapped to actual keyboard keys in the
+//  device.
+//
+//  Client note: each call to KEYDOWN should be followed by KEYUP
+//               with the same scancode at some point.
+
+    if ( aData.Length() != KKeyboardFuncDataLength )
+        {
+//        HTI_LOG_FORMAT( "PRESSKEY: Invalid scancode length: %d (expecting 2 bytes).", ptr.Length() - 1);
+        SendErrorMessageL( EInvalidScancode, KErrorInvalidScancode );
+        return;
+        }
+
+    iReady = EFalse;
+
+    TUint scanCode = UintValue( aData.Ptr() );
+
+    switch ( iCommand )
+        {
+        case EPressKey:
+            KeyDown( scanCode );
+            KeyUp( scanCode );
+            break;
+
+        case EKeyDown:
+            KeyDown( scanCode );
+            break;
+
+        case EKeyUp:
+            KeyUp( scanCode );
+            break;
+
+        default:
+        break;
+        }
+    SendOkMsgL();
+    iReady = ETrue;
+    HTI_LOG_FUNC_OUT("CKeyEventHandler::HandleKeyboardFuncL: Done");
+    }
+
+// ----------------------------------------------------------------------------
+// CKeyEventHandler::HandleLongKeyPressFuncL()
+// Handle request to emulate holding a key down for specified time.
+// ----------------------------------------------------------------------------
+void CKeyEventHandler::HandleLongKeyPressFuncL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CKeyEventHandler::HanldeLongKeyPressFuncL" );
+
+    if ( aData.Length() != KLongKeyPressDataLength )
+        {
+        SendErrorMessageL( EInvalidScancode, KErrorInvalidScancode );
+        return;
+        }
+
+    iReady = EFalse;
+    iHoldingScanCode = UintValue( aData.Ptr() );
+    TTimeIntervalMicroSeconds32 holdTime( UintValue( aData.Ptr() + 2 ) * 1000 );
+    KeyDown( iHoldingScanCode );
+    iTimer.After( iStatus, holdTime );
+    SetActive();
+
+    HTI_LOG_FUNC_OUT( "CKeyEventHandler::HanldeLongKeyPressFuncL" );
+    }
+
+// ----------------------------------------------------------------------------
+// CKeyEventHandler::HandlePressKeySequenceFuncL()
+// Handle request to press keys in sequence.
+// ----------------------------------------------------------------------------
+void CKeyEventHandler::HandlePressKeySequenceFuncL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CKeyEventHandler::HandlePressKeySequenceFuncL" );
+
+    if ( aData.Length() % 2 != 0 )
+        {
+        HTI_LOG_FORMAT( "Invalid data length: %d", aData.Length() );
+        SendErrorMessageL( EInvalidUnicodeCharArray, KErrorInvalidUnicodeCharArray );
+        return;
+        }
+
+    if ( aData.Length() < KPressKeySequenceMinDataLength )
+        {
+        HTI_LOG_FORMAT( "Too short data: %d", aData.Length() );
+        SendErrorMessageL( EEmptyUnicodeCharArray, KErrorEmptyUnicodeArray );
+        return;
+        }
+
+    iReady = EFalse;
+
+    iKeySequenceHoldTime = UintValue( aData.Ptr() ) * 1000;
+    iKeySequenceInterval = UintValue( aData.Ptr() + 2 ) * 1000;
+    HTI_LOG_FORMAT( "Parsed key sequence hold time: %d", iKeySequenceHoldTime.Int() / 1000 );
+    HTI_LOG_FORMAT( "Parsed key sequence interval: %d", iKeySequenceInterval.Int() / 1000 );
+    if ( iKeySequenceInterval.Int() < KTypeTextDelayBetweenCharsInMicroSeconds )
+        {
+        HTI_LOG_TEXT( "Given key sequence interval too low, using the default value" );
+        iKeySequenceInterval = KTypeTextDelayBetweenCharsInMicroSeconds;
+        }
+
+    if(iUnicodeChars)
+		{
+			delete iUnicodeChars;
+			iUnicodeChars = NULL;
+		}
+	
+	iUnicodeChars = aData.Mid( 4 ).AllocL();
+    iUnicodeCharIndex = 0;
+    iHoldingKey = EFalse;
+
+    PressKeySequenceKeyL();
+
+    HTI_LOG_FUNC_OUT( "CKeyEventHandler::HandlePressKeySequenceFuncL" );
+    }
+
+// ----------------------------------------------------------------------------
+// CKeyEventHandler::PressKeySequenceKeyL()
+// Handle a single key press from press keys in sequence command.
+// ----------------------------------------------------------------------------
+void CKeyEventHandler::PressKeySequenceKeyL()
+    {
+    HTI_LOG_FUNC_IN( "CKeyEventHandler::PressKeySequenceKeyL" );
+
+    if ( iHoldingKey )
+        {
+        KeyUp( iHoldingScanCode );
+        iHoldingKey = EFalse;
+
+        HTI_LOG_FORMAT( "Released key: %d", iHoldingScanCode );
+
+        if ( iUnicodeChars->Length() > iUnicodeCharIndex )
+            {
+            iTimer.After( iStatus, iKeySequenceInterval );
+            SetActive();
+            }
+        else
+            {
+            HTI_LOG_TEXT( "PressKeySequence has finished: OK" );
+            SendOkMsgL();
+            iReady = ETrue;
+            }
+        }
+    else
+        {
+        iHoldingScanCode = UintValue( iUnicodeChars->Ptr() + iUnicodeCharIndex );
+        iUnicodeCharIndex += 2;
+
+        KeyDown( iHoldingScanCode );
+        iHoldingKey = ETrue;
+
+        HTI_LOG_FORMAT( "Holding down key: %d", iHoldingScanCode );
+
+        iTimer.After( iStatus, iKeySequenceHoldTime );
+        SetActive();
+        }
+
+    HTI_LOG_FUNC_OUT( "CKeyEventHandler::HandlePressKeySequenceFuncL" );
+    }
+
+// ----------------------------------------------------------------------------
+// CKeyEventHandler::SendOkMsgL()
+// ----------------------------------------------------------------------------
+void CKeyEventHandler::SendOkMsgL()
+    {
+    HTI_LOG_FUNC_IN("CKeyEventHandler::SendOkMsgL: Starting");
+
+    User::LeaveIfNull( iDispatcher );
+    TBuf8<1> response;
+    response.Append( EResultOk );
+    HBufC8* respH8 = response.AllocL();
+    User::LeaveIfError( iDispatcher->DispatchOutgoingMessage(
+        respH8, KKeyEventServiceUid ) );
+
+    HTI_LOG_FUNC_OUT("CKeyEventHandler::SendOkMsgL: Done");
+    }
+
+// ----------------------------------------------------------------------------
+// CKeyEventHandler::SendErrorMessageL()
+// ----------------------------------------------------------------------------
+void CKeyEventHandler::SendErrorMessageL( TInt aError,
+        const TDesC8& aDescription )
+    {
+    HTI_LOG_FUNC_IN("CKeyEventHandler::SendErrorMessageL: Starting");
+    User::LeaveIfNull( iDispatcher );
+    User::LeaveIfError( iDispatcher->DispatchOutgoingErrorMessage(
+        aError, aDescription, KKeyEventServiceUid ) );
+    HTI_LOG_FUNC_OUT("CKeyEventHandler::SendErrorMessageL: Done");
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiKeyEventServicePlugin/src/PointerEventHandler.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,542 @@
+/*
+* 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:  Functional implementation of pointer event service
+*
+*/
+
+
+// INCLUDE FILES
+#include "HtiKeyEventServiceplugin.h"
+#include "PointerEventHandler.h"
+
+#include <HtiDispatcherInterface.h>
+#include <HTILogging.h>
+
+
+// CONSTANTS
+_LIT8( KErrorMissingCommand, "Command was not given - message was empty" );
+_LIT8( KErrorServiceNotReady, "Service is busy - possibly executing long running pointer events" );
+_LIT8( KErrorInvalidParameters, "Command parameters not valid" );
+_LIT8( KErrorUnrecognizedCommand, "Unrecognized command" );
+_LIT8( KErrorInternalFailure, "Internal pointer command failure" );
+
+const TInt KTapCmdLength = 10;
+const TInt KDragMultiCmdMinLength = 14;
+const TInt KSinglePointerCmdLength = 4;
+
+// ----------------------------------------------------------------------------
+// CPointerEventHandler::NewL()
+// ----------------------------------------------------------------------------
+CPointerEventHandler* CPointerEventHandler::NewL()
+    {
+    HTI_LOG_FUNC_IN( "CPointerEventHandler::NewL" );
+    CPointerEventHandler* self = new (ELeave) CPointerEventHandler();
+    CleanupStack::PushL ( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    HTI_LOG_FUNC_OUT( "CPointerEventHandler::Done" );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CPointerEventHandler::CPointerEventHandler()
+// ----------------------------------------------------------------------------
+CPointerEventHandler::CPointerEventHandler()
+    : CActive( CActive::EPriorityStandard ), iReady( ETrue ), iCommand( 0 ),
+      iState( EPointerUp )
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CPointerEventHandler::~CPointerEventHandler()
+// ----------------------------------------------------------------------------
+CPointerEventHandler::~CPointerEventHandler()
+    {
+    HTI_LOG_TEXT( "CPointerEventHandler destroy" );
+    Cancel();
+    iTimer.Close();
+    iWsSession.Close();
+    if ( iCoords )
+        {
+        iCoords->Close();
+        }
+    delete iCoords;
+    }
+
+// ----------------------------------------------------------------------------
+// CPointerEventHandler::ConstructL()
+// ----------------------------------------------------------------------------
+void CPointerEventHandler::ConstructL()
+    {
+    HTI_LOG_TEXT( "CPointerEventHandler::ConstructL" );
+    User::LeaveIfError( iWsSession.Connect() );
+    User::LeaveIfError( iTimer.CreateLocal() );
+    CActiveScheduler::Add( this );
+    }
+
+// ----------------------------------------------------------------------------
+// void CPointerEventHandler::SetDispatcher()
+// ----------------------------------------------------------------------------
+void CPointerEventHandler::SetDispatcher( MHtiDispatcher* aDispatcher )
+    {
+    iDispatcher = aDispatcher;
+    }
+
+// ----------------------------------------------------------------------------
+// CPointerEventHandler::RunL()
+// ----------------------------------------------------------------------------
+void CPointerEventHandler::RunL()
+    {
+    HTI_LOG_FUNC_IN( "CPointerEventHandler::RunL" );
+
+    if ( iCommand == ETapScreen )
+        {
+        ChangePointerStateL();
+        }
+
+    else if ( iCommand == ETapAndDrag && iState == EPointerDown )
+        {
+        PointerMove();
+        PointerUp();
+        SendOkMsgL();
+        iReady = ETrue;
+        }
+
+    else if ( iCommand == ETapAndDragMultipoint )
+        {
+        if ( iState == EPointerUp )  // Starting a new line
+            {
+            PointerDown();
+            iTapCount--;
+            iTimer.After( iStatus, iEventDelay );
+            SetActive();
+            }
+        else
+            {
+            MoveToNextPointL(); // Continuing current line
+            }
+        }
+
+    HTI_LOG_FUNC_OUT( "CPointerEventHandler::RunL" );
+    }
+
+// ----------------------------------------------------------------------------
+// CPointerEventHandler::RunError()
+// ----------------------------------------------------------------------------
+TInt CPointerEventHandler::RunError( TInt aError )
+    {
+    HTI_LOG_FORMAT( "CPointerEventHandler::RunError %d", aError );
+
+    TInt dispatchResult = KErrNone;
+    TRAP( dispatchResult, SendErrorMessageL( aError, KErrorInternalFailure ) );
+    if ( dispatchResult != KErrNone )
+        {
+        HTI_LOG_FORMAT( "CPointerEventHandler::RunError: Failed to send error report to framework: %d.", dispatchResult );
+        }
+    iReady = ETrue;
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// CPointerEventHandler::DoCancel()
+// ----------------------------------------------------------------------------
+void CPointerEventHandler::DoCancel()
+    {
+    iTimer.Cancel();
+    }
+
+// ----------------------------------------------------------------------------
+// CPointerEventHandler::ProcessMessageL()
+// ----------------------------------------------------------------------------
+void CPointerEventHandler::ProcessMessageL( const TDesC8& aMessage,
+    THtiMessagePriority /*aPriority*/ )
+    {
+    HTI_LOG_FUNC_IN("CPointerEventHandler::ProcessMessageL");
+    HTI_LOG_FORMAT("Msg len: %d.", aMessage.Length());
+
+    if ( !iReady )
+        {
+        SendErrorMessageL( ENotReadyCommand, KErrorServiceNotReady );
+        return;
+        }
+    if ( aMessage.Length() == 0 )
+        {
+        SendErrorMessageL( EMissingCommand, KErrorMissingCommand );
+        return;
+        }
+
+    User::ResetInactivityTime();
+    iCommand = aMessage.Ptr()[0];
+    switch ( iCommand )
+        {
+        case ETapScreen:
+            HandleTapScreenL( aMessage.Right( aMessage.Length() - 1 ) );
+            break;
+        case ETapAndDrag:
+            HandleTapAndDragL( aMessage.Right( aMessage.Length() - 1 ) );
+            break;
+        case ETapAndDragMultipoint:
+            HandleTapAndDragMultipointL(
+                aMessage.Right( aMessage.Length() - 1 ) );
+            break;
+        case EPressPointerDown:
+        case ELiftPointerUp:
+            HandlePointerDownOrUpL( aMessage.Right( aMessage.Length() - 1 ) );
+            break;
+        default:
+            SendErrorMessageL( EUnrecognizedCommand,
+                KErrorUnrecognizedCommand );
+            break;
+        }
+
+    HTI_LOG_FUNC_OUT( "CPointerEventHandler::ProcessMessageL: Done" );
+    }
+
+// ----------------------------------------------------------------------------
+// CPointerEventHandler::HandleTapScreenL()
+// Handles single or multiple taps to one point.
+// ----------------------------------------------------------------------------
+void CPointerEventHandler::HandleTapScreenL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CPointerEventHandler::HandleTapScreenL" );
+
+    if ( aData.Length() != KTapCmdLength )
+        {
+        SendErrorMessageL( EInvalidParameters, KErrorInvalidParameters );
+        return;
+        }
+
+    // Parse the parameters - correct length is already verified
+    TInt offset = 0;
+    iX = aData[offset] + ( aData[offset+1] << 8 );
+    offset += 2;
+    HTI_LOG_FORMAT( "X coord = %d", iX );
+    iY = aData[offset] + ( aData[offset+1] << 8 );
+    offset += 2;
+    HTI_LOG_FORMAT( "Y coord = %d", iY );
+    iEventDelay = ( aData[offset] + ( aData[offset+1] << 8 ) ) * 1000;
+    offset += 2;
+    HTI_LOG_FORMAT( "Time to hold down = %d", iEventDelay.Int() );
+    iTapCount = aData[offset] + ( aData[offset+1] << 8 );
+    offset += 2;
+    HTI_LOG_FORMAT( "Tap count = %d", iTapCount );
+    iActionDelay = ( aData[offset] + ( aData[offset+1] << 8 ) ) * 1000;
+    HTI_LOG_FORMAT( "Pause between taps = %d", iActionDelay.Int() );
+
+    // Start tapping
+    iReady = EFalse;
+    ChangePointerStateL();
+
+    HTI_LOG_FUNC_OUT( "CPointerEventHandler::HandleTapScreenL" );
+    }
+
+// ----------------------------------------------------------------------------
+// CPointerEventHandler::HandleTapAndDragL()
+// Handles a single drag and drop with straight line.
+// ----------------------------------------------------------------------------
+void CPointerEventHandler::HandleTapAndDragL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CPointerEventHandler::HandleTapAndDragL" );
+
+    if ( aData.Length() != KTapCmdLength )
+        {
+        SendErrorMessageL( EInvalidParameters, KErrorInvalidParameters );
+        return;
+        }
+
+    TInt offset = 0;
+    iX = aData[offset] + ( aData[offset+1] << 8 );
+    offset += 2;
+    HTI_LOG_FORMAT( "X coord down = %d", iX );
+    iY = aData[offset] + ( aData[offset+1] << 8 );
+    offset += 2;
+    HTI_LOG_FORMAT( "Y coord down = %d", iY );
+    TInt xUp = aData[offset] + ( aData[offset+1] << 8 );
+    offset += 2;
+    HTI_LOG_FORMAT( "X coord up = %d", xUp );
+    TInt yUp = aData[offset] + ( aData[offset+1] << 8 );
+    offset += 2;
+    HTI_LOG_FORMAT( "Y coord up = %d", yUp );
+    iEventDelay = ( aData[offset] + ( aData[offset+1] << 8 ) ) * 1000;
+    HTI_LOG_FORMAT( "Drag time = %d", iEventDelay.Int() );
+
+    iReady = EFalse;
+    PointerDown();
+    iX = xUp;
+    iY = yUp;
+    iTimer.After( iStatus, iEventDelay );
+    SetActive();
+
+    HTI_LOG_FUNC_OUT( "CPointerEventHandler::HandleTapAndDragL" );
+    }
+
+// ----------------------------------------------------------------------------
+// CPointerEventHandler::HandleTapAndDragMultipointL()
+// Handles drawing one or more curvy lines.
+// ----------------------------------------------------------------------------
+void CPointerEventHandler::HandleTapAndDragMultipointL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CPointerEventHandler::HandleTapAndDragMultipointL" );
+
+    TInt dataLength = aData.Length();
+    if ( dataLength < KDragMultiCmdMinLength || dataLength % 2 != 0 )
+        {
+        SendErrorMessageL( EInvalidParameters, KErrorInvalidParameters );
+        return;
+        }
+
+    TInt offset = 0;
+    iEventDelay = ( aData[offset] + ( aData[offset+1] << 8 ) ) * 1000;
+    offset += 2;
+    HTI_LOG_FORMAT( "Time between events = %d", iEventDelay.Int() );
+    iActionDelay = ( aData[offset] + ( aData[offset+1] << 8 ) ) * 1000;
+    offset += 2;
+    HTI_LOG_FORMAT( "Pause between lines = %d", iActionDelay.Int() );
+
+    if ( iCoords == NULL )
+        {
+        iCoords = new ( ELeave ) RArray<TInt>();
+        }
+    iCoords->Reset();
+
+    // Read integers from aData to the array, all integers are 2 bytes
+    while ( offset < dataLength )
+        {
+        iCoords->AppendL( aData[offset] + ( aData[offset + 1] << 8 ) );
+        offset += 2;
+        }
+
+    iReady = EFalse;
+    iTapCount = ( *iCoords )[0];
+    iCoords->Remove( 0 );
+    iX = ( *iCoords )[0];
+    iCoords->Remove( 0 );
+    iY = ( *iCoords )[0];
+    iCoords->Remove( 0 );
+    HTI_LOG_FORMAT( "Point count for first line = %d", iTapCount );
+    PointerDown();
+    iTapCount--;
+    iTimer.After( iStatus, iEventDelay );
+    SetActive();
+
+    HTI_LOG_FUNC_OUT( "CPointerEventHandler::HandleTapAndDragMultipointL" );
+    }
+
+// ----------------------------------------------------------------------------
+// CPointerEventHandler::HandlePointerDownOrUpL()
+// Handles pushing pointer down in one point or lifting it up.
+// This is synchronous operation and sends OK message right after the event
+// is simulated.
+// ----------------------------------------------------------------------------
+void CPointerEventHandler::HandlePointerDownOrUpL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CPointerEventHandler::HandlePointerDownOrUpL" );
+    if ( aData.Length() != KSinglePointerCmdLength )
+        {
+        SendErrorMessageL( EInvalidParameters, KErrorInvalidParameters );
+        return;
+        }
+
+    // Parse the parameters - correct length is already verified
+    TInt offset = 0;
+    iX = aData[offset] + ( aData[offset+1] << 8 );
+    offset += 2;
+    HTI_LOG_FORMAT( "X coord = %d", iX );
+    iY = aData[offset] + ( aData[offset+1] << 8 );
+    offset += 2;
+    HTI_LOG_FORMAT( "Y coord = %d", iY );
+
+    if ( iCommand == EPressPointerDown )
+        {
+        PointerDown();
+        }
+    else
+        {
+        PointerUp();
+        }
+    SendOkMsgL();
+    HTI_LOG_FUNC_OUT( "CPointerEventHandler::HandlePointerDownOrUpL" );
+    }
+
+// ----------------------------------------------------------------------------
+// CPointerEventHandler::ChangePointerStateL()
+// Decides whether to do  "pointer down" or "pointer up" event next or if
+// operation is complete.
+// This function is used by ETapScreen command.
+// ----------------------------------------------------------------------------
+void CPointerEventHandler::ChangePointerStateL()
+    {
+    HTI_LOG_FUNC_IN( "CPointerEventHandler::ChangePointerStateL" );
+    HTI_LOG_FORMAT( "Taps remaining = %d", iTapCount );
+    if ( iTapCount < 1 )
+        {
+        SendOkMsgL();
+        iReady = ETrue;
+        return;
+        }
+
+    if ( iState == EPointerUp )
+        {
+        PointerDown();
+        iTimer.After( iStatus, iEventDelay );
+        SetActive();
+        }
+    else if ( iState == EPointerDown )
+        {
+        PointerUp();
+        iTapCount--; // one tap done
+        if ( iTapCount > 0 ) // do we continue tapping?
+            {
+            iTimer.After( iStatus, iActionDelay );
+            SetActive();
+            }
+        else
+            {
+            SendOkMsgL();  // tapping done
+            iReady = ETrue;
+            }
+        }
+    HTI_LOG_FUNC_OUT( "CPointerEventHandler::ChangePointerStateL" );
+    }
+
+// ----------------------------------------------------------------------------
+// CPointerEventHandler::MoveToNextPointL()
+// Takes the next point from the coordinate array and initiates pointer moving
+// to that point.
+// This function is used by ETapAndDragMultipoint command and called from
+// the RunL().
+// ----------------------------------------------------------------------------
+void CPointerEventHandler::MoveToNextPointL()
+    {
+    HTI_LOG_FUNC_IN( "CPointerEventHandler::MoveToNextPointL" );
+    HTI_LOG_FORMAT( "Points remaining for this line = %d", iTapCount );
+
+    if ( iTapCount == 0 ) // End of current line
+        {
+        PointerUp();
+        if ( iCoords->Count() < 5 ) // point count & at least 2 points
+            {
+            // This was the last line, we are done
+            SendOkMsgL();
+            iReady = ETrue;
+            }
+        else
+            {
+            // New line starts: take the point count of this line and
+            // first coordinates.
+            iTapCount = ( *iCoords )[0];
+            iCoords->Remove( 0 );
+            iX = ( *iCoords )[0];
+            iCoords->Remove( 0 );
+            iY = ( *iCoords )[0];
+            iCoords->Remove( 0 );
+            HTI_LOG_FORMAT( "Point count for new line = %d", iTapCount );
+            iTimer.After( iStatus, iActionDelay );
+            SetActive();
+            }
+        }
+
+    else  // Current line continues: take next point coords and move
+        {
+        iX = ( *iCoords )[0];
+        iCoords->Remove( 0 );
+        iY = ( *iCoords )[0];
+        iCoords->Remove( 0 );
+        PointerMove();
+        iTapCount--;
+        iTimer.After( iStatus, iEventDelay );
+        SetActive();
+        }
+
+    HTI_LOG_FUNC_OUT( "CPointerEventHandler::MoveToNextPointL" );
+    }
+
+// ----------------------------------------------------------------------------
+// CPointerEventHandler::PointerDown()
+// ----------------------------------------------------------------------------
+void CPointerEventHandler::PointerDown()
+    {
+    HTI_LOG_FUNC_IN( "CPointerEventHandler::PointerDown" );
+    SimulatePointerEvent( TRawEvent::EButton1Down );
+    iState = EPointerDown;
+    HTI_LOG_FUNC_OUT( "CPointerEventHandler::PointerDown" );
+    }
+
+// ----------------------------------------------------------------------------
+// CPointerEventHandler::PointerUp()
+// ----------------------------------------------------------------------------
+void CPointerEventHandler::PointerUp()
+    {
+    HTI_LOG_FUNC_IN( "CPointerEventHandler::PointerUp" );
+    SimulatePointerEvent( TRawEvent::EButton1Up );
+    iState = EPointerUp;
+    HTI_LOG_FUNC_OUT( "CPointerEventHandler::PointerUp" );
+    }
+
+// ----------------------------------------------------------------------------
+// CPointerEventHandler::PointerMove()
+// ----------------------------------------------------------------------------
+void CPointerEventHandler::PointerMove()
+    {
+    HTI_LOG_FUNC_IN( "CPointerEventHandler::PointerMove" );
+    SimulatePointerEvent( TRawEvent::EPointerMove );
+    iState = EPointerMoving;
+    HTI_LOG_FUNC_OUT( "CPointerEventHandler::PointerMove" );
+    }
+
+// ----------------------------------------------------------------------------
+// CPointerEventHandler::SimulatePointerEvent()
+// Sends the pointer event as a raw event.
+// ----------------------------------------------------------------------------
+void CPointerEventHandler::SimulatePointerEvent( TRawEvent::TType aType )
+    {
+    HTI_LOG_FUNC_IN( "CPointerEventHandler::SimulatePointerEvent" );
+    TRawEvent rawEvent;
+    rawEvent.Set( aType, iX, iY );
+    iWsSession.SimulateRawEvent( rawEvent );
+    iWsSession.Flush();
+    HTI_LOG_FUNC_OUT( "CPointerEventHandler::SimulatePointerEvent" );
+    }
+
+// ----------------------------------------------------------------------------
+// CPointerEventHandler::SendOkMsgL()
+// ----------------------------------------------------------------------------
+void CPointerEventHandler::SendOkMsgL()
+    {
+    HTI_LOG_FUNC_IN("CPointerEventHandler::SendOkMsgL");
+
+    User::LeaveIfNull( iDispatcher );
+    TBuf8<1> response;
+    response.Append( EResultOk );
+    HBufC8* respH8 = response.AllocL();
+    User::LeaveIfError( iDispatcher->DispatchOutgoingMessage(
+        respH8, KKeyEventServiceUid ) );
+
+    HTI_LOG_FUNC_OUT("CPointerEventHandler::SendOkMsgL");
+    }
+
+// ----------------------------------------------------------------------------
+// CPointerEventHandler::SendErrorMessageL()
+// ----------------------------------------------------------------------------
+void CPointerEventHandler::SendErrorMessageL(
+        TInt aError, const TDesC8& aDescription )
+    {
+    HTI_LOG_FUNC_IN("CPointerEventHandler::SendErrorMessageL");
+    User::LeaveIfNull( iDispatcher );
+    User::LeaveIfError( iDispatcher->DispatchOutgoingErrorMessage(
+        aError, aDescription, KKeyEventServiceUid ) );
+    HTI_LOG_FUNC_OUT("CPointerEventHandler::SendErrorMessageL");
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiKeyEventServicePlugin/src/proxy.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,37 @@
+/*
+* 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:  Implementation proxy for key event service plugin dll
+*
+*/
+
+
+// INCLUDE FILES
+#include "HtiKeyEventServicePlugin.h"
+
+#include <e32std.h>
+#include <ecom/implementationproxy.h>
+
+// Provides a key value pair table, this is used to identify
+// the correct construction function for the requested interface.
+const TImplementationProxy ImplementationTable[] =
+    {
+        IMPLEMENTATION_PROXY_ENTRY(0x1020DEC1,  CHtiKeyEventServicePlugin::NewL)
+    };
+
+// Function used to return an instance of the proxy table.
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    return ImplementationTable;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiMessagesServicePlugin/data/200212C5.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  Resource definitions for Message management (inbox, etc)
+*                service ECOM plugin.
+*
+*/
+
+
+// INCLUDES
+#include <ecom/registryinfo.rh>
+
+
+//  RESOURCE DEFINITIONS
+RESOURCE REGISTRY_INFO theInfo
+    {
+    // UID for the DLL
+    dll_uid = 0x200212C5;
+    // Declare array of interface info
+    interfaces =
+        {
+        INTERFACE_INFO
+            {
+            // UID of interface that is implemented
+            interface_uid = 0x1020DEB7;
+            implementations =
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = 0x200212C6;
+                    version_no         = 1;
+                    display_name       = "Message management service (inbox etc.)";
+                    default_data       = "MessageMgmnt";
+                    opaque_data        = "";
+                    }
+                };
+            }
+        };
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiMessagesServicePlugin/group/HtiMessagesServicePlugin.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ECOM implementation of HtiMessagesServicePlugin service
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          HtiMessagesServicePlugin.dll
+TARGETTYPE      PLUGIN
+
+UID             0x10009D8D 0x200212C5
+
+VENDORID        0x101FB657
+
+CAPABILITY      ALL -TCB
+
+SOURCEPATH      ../src
+SOURCE          proxy.cpp
+SOURCE          HtiMessagesServicePlugin.cpp
+SOURCE          MessageMgmntHandler.cpp
+SOURCE          HtiIAPHandler.cpp
+SOURCE          HtiMailboxHandler.cpp
+SOURCE          HtiMsgSettingsHandler.cpp
+
+USERINCLUDE     ../inc
+APP_LAYER_SYSTEMINCLUDE
+
+START RESOURCE  ../data/200212C5.rss
+TARGET          HtiMessagesServicePlugin.rsc
+END
+
+LIBRARY         apgrfx.lib
+LIBRARY         apmime.lib
+LIBRARY         bafl.lib
+LIBRARY         centralRepository.lib
+LIBRARY         charconv.lib
+LIBRARY         cmmanager.lib
+LIBRARY         connmon.lib
+LIBRARY         ecom.lib
+LIBRARY         efsrv.lib
+LIBRARY         euser.lib
+LIBRARY         gsmu.lib
+LIBRARY         imcm.lib
+LIBRARY         mmscli.lib
+LIBRARY         msgs.lib
+LIBRARY         smcm.lib
+LIBRARY         etel.lib
+LIBRARY         etelmm.lib
+LIBRARY         etext.lib
+LIBRARY         imumutils.lib
+LIBRARY         mmsserversettings.lib
+LIBRARY         flogger.lib
+
+SMPSAFE
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiMessagesServicePlugin/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,26 @@
+/*
+* 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:  Build information file for HtiMessagesServicePlugin
+*
+*/
+
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+HtiMessagesServicePlugin.mmp
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiMessagesServicePlugin/inc/HtiIAPHandler.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,170 @@
+/*
+* 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:  HTI Internet Access Point handler.
+*
+*/
+
+
+#ifndef CHTIIAPHANDLER_H
+#define CHTIIAPHANDLER_H
+
+
+// INCLUDES
+#include <cmpsettingsconsts.h>
+#include <HTIServicePluginInterface.h>
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+enum TApFieldDataType
+    {
+    EDataTypeText,
+    EDataTypeBool,
+    EDataTypeUint,
+    EDataTypeText8,
+    EDataTypeUnknown
+    };
+
+struct TApField
+    {
+    TInt      iId;
+    HBufC*    iData;
+    TApFieldDataType iDataType;
+    };
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+/**
+*  HTI Internet Access Point handler.
+*/
+class CHtiIAPHandler : public CBase
+    {
+    public:
+        enum TLegacyApFieldCodes
+        {
+        EApWapStartPage            =   3,
+        EApIspDefaultTelNumber     =  18,
+        EApIspUseLoginScript       =  20,
+        EApIspLoginScript          =  21,
+        EApIspLoginName            =  23,
+        EApIspLoginPass            =  24,
+        EApIspIfPromptForAuth      =  29,
+        EApIspIfCallbackEnabled    =  33,
+        EApIspIfCallbackType       =  34,
+        EApIspIfCallbackInfo       =  35,
+        EApIspIPAddr               =  38,
+        EApIspIPNameServer1        =  42,
+        EApIspIPNameServer2        =  43,
+        EApIspEnableIpHeaderComp   =  44,
+        EApIspDisablePlainTextAuth =  46,
+        EApIspBearerSpeed          =  49,
+        EApIspBearerCallTypeIsdn   =  50,
+        EApIspInitString           =  52,
+        EApGprsAccessPointName     =  58,
+        EApGprsPdpType             =  59,
+        EApProxyServerAddress      =  91,
+        EApProxyPortNumber         =  93,
+        EApIP6NameServer1          = 104,
+        EApIP6NameServer2          = 105,
+        EApWlanNetworkName         = 163,
+        EApWlanNetworkMode         = 164,
+        EApWlanSecurityMode        = 165,
+
+        // new fields that do not exist in legacy TApMember enum
+        EApSeamlessnessLevel       = 200
+        };
+
+        /**
+        * Two-phased constructor.
+        */
+        static CHtiIAPHandler* NewL();
+
+        /**
+        * Called when there is a message to be processed by this service.
+        * @param aMessage message body destinated to the servive
+        * @param aPriority message priority
+        */
+        void ProcessMessageL( const TDesC8& aMessage,
+                              THtiMessagePriority aPriority );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CHtiIAPHandler();
+
+        /**
+        * Sets the dispatcher to send outgoing messages to.
+        * @param aDispatcher pointer to dispatcher instance
+        */
+        void SetDispatcher( MHtiDispatcher* aDispatcher );
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CHtiIAPHandler();
+
+        /**
+        * 2nd phase constructor.
+        */
+        void ConstructL();
+
+    private: // helpers
+
+        void HandleCreateIapL( const TDesC8& aData );
+        void HandleDeleteIapL( const TDesC8& aData );
+        void HandleCreateDestinationL( const TDesC8& aData );
+        void HandleDeleteDestinationL( const TDesC8& aData );
+        void ModifyDestinationL( const TInt aCommand, const TDesC8& aData );
+        void SetDefaultConnectionL( const TDesC8& aData );
+
+        void ParseCreateMessageL( const TDesC8& aData );
+        TInt GetAccessPointUIDL();
+        TInt GetDestinationIDL( const TDesC& aName );
+        void CloseActiveConnectionsL();
+
+        TUint GetBearerUID( const TInt aBearerType );
+        void MapLegacyFieldIDs();
+        void ResolveFieldDataTypes();
+
+        void SendOkMsgL( const TDesC8& aData );
+        void SendErrorMessageL( TInt aError, const TDesC8& aDescription );
+
+    private:  // Data
+
+        // Pointer to the dispatcher (referenced)
+        MHtiDispatcher* iDispatcher; // referenced
+
+        // Name of the connection to create/delete
+        TBuf<KMaxConnNameLength>   iConnName;
+        TBuf<KMaxConnNameLength>   iDestName;
+
+        // The type of Access Point to create
+        TUint         iBearerType;
+
+        // The fields to add to the Access Point
+        RArray<TApField> iFields;
+
+    };
+
+#endif // CHTIIAPHANDLER_H
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiMessagesServicePlugin/inc/HtiMailboxHandler.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,145 @@
+/*
+* 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:  HTI Mailbox settings handler.
+*
+*/
+
+
+#ifndef HTIMAILBOXHANDLER_H_
+#define HTIMAILBOXHANDLER_H_
+
+// INCLUDES
+#include <cmmanager.h>
+#include <msvapi.h>
+#include <HTIServicePluginInterface.h>
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+class TSmtpAccount;
+
+// CLASS DECLARATION
+/**
+*  HTI Mailbox settings handler.
+*/
+class CHtiMailboxHandler : public CBase,
+                           public MMsvSessionObserver
+    {
+    public:
+
+        /**
+        * Two-phased constructor.
+        */
+        static CHtiMailboxHandler* NewL();
+
+        /**
+        * Called when there is a message to be processed by this service.
+        * @param aMessage message body destinated to the servive
+        * @param aPriority message priority
+        */
+        void ProcessMessageL( const TDesC8& aMessage,
+                              THtiMessagePriority aPriority );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CHtiMailboxHandler();
+
+        /**
+        * Sets the dispatcher to send outgoing messages to.
+        * @param aDispatcher pointer to dispatcher instance
+        */
+        void SetDispatcher( MHtiDispatcher* aDispatcher );
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CHtiMailboxHandler();
+
+        /**
+        * 2nd phase constructor.
+        */
+        void ConstructL();
+
+    private: // helpers
+
+        void HandleCreateMailboxL( const TDesC8& aData );
+        void HandleDeleteMailboxL( const TDesC8& aData );
+        void ParseCreateMsgL( const TDesC8& aData );
+        HBufC*  ParseStringL( const TDesC8& aData, TInt aStrLenOffset,
+                                TInt aStrLenBytes = 1 );
+        HBufC8* ParseString8L( const TDesC8& aData, TInt aStrLenOffset,
+                                TInt aStrLenBytes = 1 );
+        TInt AccessPointUIDL( const TDesC& aApName );
+        TInt FindSmtpAccount( const TDesC& aAccountName,
+                              TSmtpAccount& aAccount );
+        void GetDeviceImeiL( TDes& aResult );
+        void ResetVariables();
+        void SendOkMsgL( const TDesC8& aData );
+        void SendErrorMessageL( TInt aError, const TDesC8& aDescription );
+
+    private: // from MMsvSessionObserver
+
+        void HandleSessionEventL( TMsvSessionEvent aEvent,
+                                  TAny* aArg1, TAny* aArg2, TAny* aArg3 );
+
+    private:  // Data
+
+        // Pointer to the dispatcher (referenced)
+        MHtiDispatcher* iDispatcher;
+
+        // Handle to connection manager
+        RCmManager iCmManager;
+
+        // Email account settings
+        TInt    iMailboxType;
+        HBufC*  iMailboxName;
+        HBufC*  iIncomingServer;
+        HBufC*  iIncomingApName;
+        HBufC8* iIncomingUserName;
+        HBufC8* iIncomingPassword;
+        TInt    iIncomingSecurity;
+        TInt    iIncomingPort;
+        TBool   iAPopSecureLogin;
+        HBufC*  iOutgoingServer;
+        HBufC*  iOutgoingApName;
+        HBufC8* iOutgoingUserName;
+        HBufC8* iOutgoingPassword;
+        TInt    iOutgoingSecurity;
+        TInt    iOutgoingPort;
+        HBufC*  iOwnMailAddress;
+        HBufC*  iOwnName;
+        TInt    iSendOption;           // (enum TImSMTPSendMessageOption)
+        TInt    iSendCopyToOwnAddress; // (enum TImSMTPSendCopyToSelf)
+        HBufC*  iSignatureText;
+        TBool   iNewMailIndicators;
+        TInt    iRetrievedParts;
+        TInt    iRetrieveSizeLimitKb;
+        TInt    iEmailsToRetrieve;
+        HBufC8* iImapFolderPath;
+        TInt    iAutomaticUpdate;
+        TBool   iSetAsDefault;
+    };
+
+#endif // HTIMAILBOXHANDLER_H_
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiMessagesServicePlugin/inc/HtiMessagesServicePlugin.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,103 @@
+/*
+* 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:  Implementation of ECOM plug-in service interface. Provides
+*                HtiMessagesServicePlugin service.
+*
+*/
+
+
+#ifndef CHTIMESSAGESSERVICEPLUGIN_H
+#define CHTIMESSAGESSERVICEPLUGIN_H
+
+// INCLUDES
+#include <HTIServicePluginInterface.h>
+
+// CONSTANTS
+const TInt KHtiMessagesServiceUidValue = 0x10210CCF; // ECOM Implementation UID
+const TUid KHtiMessagesServiceUid = {KHtiMessagesServiceUidValue};
+
+// FORWARD DECLARATIONS
+class CMessageMgmntHandler;
+class CHtiIAPHandler;
+class CHtiMailboxHandler;
+class CHtiMsgSettingsHandler;
+
+// CLASS DECLARATION
+
+/**
+* Implementation of ECOM plug-in service interface.
+*/
+class CHtiMessagesServicePlugin : public CHTIServicePluginInterface
+    {
+public:
+
+    enum TCommand
+        {
+        // MessagesMgmntHandler
+        EAddSms              = 0x01,
+        EAddMms              = 0x02,
+        EAddEmail            = 0x03,
+        EAddIrMsg            = 0x04,
+        EAddBtMsg            = 0x05,
+        EAddSmartMsg         = 0x06,
+        EAddAudioMsg         = 0x07,
+        EDeleteMessage       = 0x10,
+        EDeleteFolderContent = 0x11,
+
+        // MailboxHandler
+        ECreateMailBox       = 0x20,
+        EDeleteMailBox       = 0x21,
+
+        // IAPHandler
+        ECreateIAP           = 0x30,
+        EDeleteIAP           = 0x31,
+        ECreateDestination   = 0x32,
+        EDeleteDestination   = 0x33,
+        EAddToDestination    = 0x34,
+        ERemoveFromDestination = 0x35,
+        ESetDefaultConnection = 0x36,
+
+        // MgsSettingsHandler
+        ESetDefaultSmsCenter = 0x40,
+        EDeleteSmsCenter     = 0x41,
+        ESetSmsSettings      = 0x42,
+        ESetMmsSettings      = 0x45,
+
+        // only for response message
+        EResultOk            = 0xFF,
+        };
+
+    static CHtiMessagesServicePlugin* NewL();
+
+    // Interface implementation
+    void ProcessMessageL( const TDesC8& aMessage,
+        THtiMessagePriority aPriority );
+
+protected:
+
+    CHtiMessagesServicePlugin();
+    void ConstructL();
+
+    virtual ~CHtiMessagesServicePlugin();
+
+private:
+
+    CMessageMgmntHandler*   iMessageHandler;
+    CHtiIAPHandler*         iIAPHandler;
+    CHtiMailboxHandler*     iMailboxHandler;
+    CHtiMsgSettingsHandler* iMsgSettingsHandler;
+    };
+
+#endif // CHTIMESSAGESSERVICEPLUGIN_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiMessagesServicePlugin/inc/HtiMsgSettingsHandler.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,110 @@
+/*
+* 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:  HTI message settings handler.
+*
+*/
+
+
+#ifndef CHTIMSGSETTINGSHANDLER_H
+#define CHTIMSGSETTINGSHANDLER_H
+
+
+// INCLUDES
+#include <HTIServicePluginInterface.h>
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+/**
+*  HTI Internet Access Point handler.
+*/
+class CHtiMsgSettingsHandler : public CBase
+    {
+    public:
+
+        /**
+        * Character support settings values.
+        */
+        enum TCharSetSupport
+            {
+            ECharSetFull,
+            ECharSetReduced,
+            ECharSetFullLocked,
+            ECharSetReducedLocked
+            };
+
+        /**
+        * Two-phased constructor.
+        */
+        static CHtiMsgSettingsHandler* NewL();
+
+        /**
+        * Called when there is a message to be processed by this service.
+        * @param aMessage message body destinated to the servive
+        * @param aPriority message priority
+        */
+        void ProcessMessageL( const TDesC8& aMessage,
+                              THtiMessagePriority aPriority );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CHtiMsgSettingsHandler();
+
+        /**
+        * Sets the dispatcher to send outgoing messages to.
+        * @param aDispatcher pointer to dispatcher instance
+        */
+        void SetDispatcher( MHtiDispatcher* aDispatcher );
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CHtiMsgSettingsHandler();
+
+        /**
+        * 2nd phase constructor.
+        */
+        void ConstructL();
+
+    private: // helpers
+
+        void HandleSetDefaultSmsCenterL( const TDesC8& aData );
+        void HandleDeleteSmsCenterL( const TDesC8& aData );
+        void HandleSetSmsSettingsL( const TDesC8& aData );
+
+        void HandleSetMmsSettingsL( const TDesC8& aData );
+
+        TInt GetAccessPointUIDL( const TDesC& aApName );
+        void SendOkMsgL( const TDesC8& aData );
+        void SendErrorMessageL( TInt aError, const TDesC8& aDescription );
+
+    private:  // Data
+
+        // Pointer to the dispatcher (referenced)
+        MHtiDispatcher* iDispatcher; // referenced
+    };
+
+
+#endif // CHTIMSGSETTINGSHANDLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiMessagesServicePlugin/inc/MessageMgmntHandler.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,150 @@
+/*
+* 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:  Functional implentation of message management service.
+*
+*/
+
+
+#ifndef CHTIMESSAGESSERVICEPLUGINHANDLER_H
+#define CHTIMESSAGESSERVICEPLUGINHANDLER_H
+
+
+// INCLUDES
+#include <msvapi.h>
+#include <HTIServicePluginInterface.h>
+
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class CClientMtmRegistry;
+
+// CLASS DECLARATION
+/**
+*  Functional implentation of message management service.
+*/
+class CMessageMgmntHandler : public CBase,
+                             public MMsvSessionObserver
+    {
+public:
+
+    static CMessageMgmntHandler* NewL();
+
+    // Interface implementation
+    void ProcessMessageL( const TDesC8& aMessage,
+                          THtiMessagePriority aPriority );
+
+    virtual ~CMessageMgmntHandler();
+
+    void SetDispatcher( MHtiDispatcher* aDispatcher );
+
+    enum TFolder
+        {
+        EAllFolders = 0x00,
+        EInbox,
+        EDrafts,
+        ESent,
+        EOutbox,
+        ENumberOfFolders, // this must always be the last one
+        };
+
+    enum TMessageType
+        {
+        EAllMessageTypes = 0x00,
+        ESMS,
+        EMMS,
+        ESmartMessage,
+        EEmail,
+        EIrMessage,
+        EBtMessage,
+        EAudioMessage,
+        EEmailPOP3,
+        EEmailIMAP4,
+        ENumberOfMessageTypes,  // this must always be the last one
+        };
+
+private:
+
+    CMessageMgmntHandler();
+    void ConstructL();
+
+private: // helpers
+
+    void HandleCreateSmsL( const TDesC8& aData );
+    void HandleCreateMmsL( const TDesC8& aData );
+    void HandleCreateEmailL( const TDesC8& aData );
+    void HandleCreateObexMsgL( const TDesC8& aData, TUid aMtmUid,  TUid aMsgTypeUid );
+    void HandleCreateSmartMsgL( const TDesC8& aData );
+
+    void HandleDeleteMessageL( const TDesC8& aData );
+    void HandleDeleteMessagesL( const TDesC8& aData );
+    void HandleDeleteFromAllFoldersL( TMessageType aType );
+    void HandleDeleteAllMessageTypesL( TFolder aFolder );
+    void HandleDeleteFromFolderByTypeL( TFolder aFolder, TMessageType aType );
+
+    void SendOkMsgL( const TDesC8& aData );
+    void SendErrorMessageL( TInt aError, const TDesC8& aDescription );
+
+    TBool ValidateAddSmsCommand( const TDesC8& aData );
+    TBool ValidateAddMmsOrAddEmailCommand( const TDesC8& aData );
+    TBool ValidateAddObexMsgCommand( const TDesC8& aData );
+    TBool ValidateAddSmartMsgCommand( const TDesC8& aData );
+
+    HBufC16* ExtractDesLC( const TDesC8& aUtf8Data, TInt& aPosition, TInt aSizeBytes );
+    HBufC8* ExtractDes8LC( const TDesC8& aUtf8Data, TInt& aPosition, TInt aSizeBytes );
+    TMsvId MapFolderToIdL( TFolder aFolder );
+    TUid MapMessageTypeToUidL( TMessageType aType );
+
+private: // from MMsvSessionObserver
+
+    void HandleSessionEventL( TMsvSessionEvent aEvent,
+                              TAny* aArg1,
+                              TAny* aArg2,
+                              TAny* aArg3 );
+
+private:
+
+    MHtiDispatcher*      iDispatcher; // referenced
+    CMsvSession*         iSession;
+    CClientMtmRegistry*  iMtmReg;
+    };
+
+
+
+// CLASS DECLARATION
+/**
+*  Helper class to wait the async requests.
+*/
+class CWaiter : public CActive
+    {
+public:
+    static CWaiter* NewL( TInt aPriority = EPriorityStandard );
+    static CWaiter* NewLC( TInt aPriority = EPriorityStandard );
+    ~CWaiter();
+
+    void StartAndWait();
+    TInt Result() const;
+
+private:
+    CWaiter( TInt aPriority );
+
+    // from CActive
+    void RunL();
+    void DoCancel();
+
+private:
+    CActiveSchedulerWait iWait;
+    TInt iResult;
+    };
+
+#endif // CHTIMESSAGESSERVICEPLUGINHANDLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiMessagesServicePlugin/src/HtiIAPHandler.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,1446 @@
+/*
+* 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:  Implementation of internet access point handling.
+*
+*/
+
+
+// INCLUDE FILES
+#include "HtiMessagesServicePlugin.h"
+#include "HtiIAPHandler.h"
+
+#include <HtiDispatcherInterface.h>
+#include <HTILogging.h>
+#include <cmconnectionmethodext.h>
+#include <cmconnectionmethoddef.h>
+#include <cmdestinationext.h>
+#include <cmmanagerext.h>
+#include <cmplugincsddef.h>
+#include <cmpluginhscsddef.h>
+#include <cmpluginpacketdatadef.h>
+#include <cmpluginwlandef.h>
+#include <RConnMon.h>
+
+using namespace CMManager;
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES
+
+// CONSTANTS
+const TInt KMinCreateMsgLength = 5;
+const TInt KMinDeleteMsgLength = 3;
+const TInt KMinCreateDestMsgLength = 3;
+const TInt KMinDeleteDestMsgLength = 3;
+const TInt KMinModifyDestMsgLength = 5;
+const TInt KMinSetDefConMsgLength = 3;
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+_LIT8( KErrorInvalidParameters, "Invalid command parameters" );
+_LIT8( KErrorCreateFailed, "Access Point creation failed" );
+_LIT8( KErrorDeleteFailed, "Access Point deletion failed" );
+_LIT8( KErrorDestCreateFailed, "Destination creation failed" );
+_LIT8( KErrorDestDeleteFailed, "Destination deletion failed" );
+_LIT8( KErrorApAlreadyExists, "Access Point with same name already exists" );
+_LIT8( KErrorApNotFound, "Access Point with given name not found" );
+_LIT8( KErrorConnCloseFailed,
+           "Failed to close a connection using the Access Point" );
+_LIT8( KErrorAddToDestFailed, "Adding to destination failed" );
+_LIT8( KErrorRemoveFromDestFailed, "Removing from destination failed" );
+_LIT8( KErrorDestNotFound, "Destination with given name not found" );
+_LIT8( KErrorSetDefConFailed, "Setting default connection failed" );
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CHtiIAPHandler::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+CHtiIAPHandler* CHtiIAPHandler::NewL()
+    {
+    HTI_LOG_FUNC_IN( "CHtiIAPHandler::NewL" );
+    CHtiIAPHandler* self = new (ELeave) CHtiIAPHandler();
+    CleanupStack::PushL ( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    HTI_LOG_FUNC_OUT( "CHtiIAPHandler::NewL" );
+    return self;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiIAPHandler::CHtiIAPHandler
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// ----------------------------------------------------------------------------
+CHtiIAPHandler::CHtiIAPHandler()
+    {
+    HTI_LOG_FUNC_IN( "CHtiIAPHandler::CHtiIAPHandler" );
+
+    HTI_LOG_FUNC_OUT( "CHtiIAPHandler::CHtiIAPHandler" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiIAPHandler::~CHtiIAPHandler
+// Destructor.
+// -----------------------------------------------------------------------------
+CHtiIAPHandler::~CHtiIAPHandler()
+    {
+    HTI_LOG_FUNC_IN( "CHtiIAPHandler::~CHtiIAPHandler" );
+
+    for ( TInt i = 0; i < iFields.Count(); i++ )
+        {
+        delete iFields[i].iData;
+        }
+    iFields.Reset();
+    iFields.Close();
+
+    HTI_LOG_FUNC_OUT( "CHtiIAPHandler::~CHtiIAPHandler" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiIAPHandler::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+void CHtiIAPHandler::ConstructL()
+    {
+    HTI_LOG_FUNC_IN( "CHtiIAPHandler::ConstructL" );
+
+    HTI_LOG_FUNC_OUT( "CHtiIAPHandler::ConstructL" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiIAPHandler::SetDispatcher
+// Sets the dispatcher pointer.
+// -----------------------------------------------------------------------------
+
+void CHtiIAPHandler::SetDispatcher( MHtiDispatcher* aDispatcher )
+    {
+    HTI_LOG_FUNC_IN( "CHtiIAPHandler::SetDispatcher" );
+    iDispatcher = aDispatcher;
+    HTI_LOG_FUNC_OUT( "CHtiIAPHandler::SetDispatcher" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiIAPHandler::ProcessMessageL
+// Parses the received message and calls handler functions.
+// -----------------------------------------------------------------------------
+void CHtiIAPHandler::ProcessMessageL( const TDesC8& aMessage,
+    THtiMessagePriority /*aPriority*/ )
+    {
+    HTI_LOG_FUNC_IN( "CHtiIAPHandler::ProcessMessageL" );
+
+    for ( TInt i = 0; i < iFields.Count(); i++ )
+        delete iFields[i].iData;
+    iFields.Reset();
+    iFields.Close();
+    iConnName.Zero();
+    iBearerType = 0;
+
+    // Zero length message and command code validity already checked
+    // in HtiMessagesServicePlugin.
+
+    if ( aMessage[0] == CHtiMessagesServicePlugin::ECreateIAP )
+        {
+        if ( aMessage.Length() < KMinCreateMsgLength )
+            {
+            SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+            }
+        else
+            {
+            TRAPD( err, HandleCreateIapL( aMessage.Mid( 1 ) ) );
+            if ( err != KErrNone )
+                {
+                SendErrorMessageL( err, KErrorCreateFailed );
+                }
+            }
+        }
+
+    else if ( aMessage[0] == CHtiMessagesServicePlugin::EDeleteIAP )
+        {
+        if ( aMessage.Length() < KMinDeleteMsgLength )
+            {
+            SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+            }
+        else
+            {
+            TRAPD( err, HandleDeleteIapL( aMessage.Mid( 1 ) ) );
+            if ( err != KErrNone )
+                {
+                SendErrorMessageL( err, KErrorDeleteFailed );
+                }
+            }
+        }
+
+    else if ( aMessage[0] == CHtiMessagesServicePlugin::ECreateDestination )
+        {
+        if ( aMessage.Length() < KMinCreateDestMsgLength )
+            {
+            SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+            }
+        else
+            {
+            TRAPD( err, HandleCreateDestinationL( aMessage.Mid( 1 ) ) );
+            if ( err != KErrNone )
+                {
+                SendErrorMessageL( err, KErrorDestCreateFailed );
+                }
+            }
+        }
+
+    else if ( aMessage[0] == CHtiMessagesServicePlugin::EDeleteDestination )
+        {
+        if ( aMessage.Length() < KMinDeleteDestMsgLength )
+            {
+            SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+            }
+        else
+            {
+            TRAPD( err, HandleDeleteDestinationL( aMessage.Mid( 1 ) ) );
+            if ( err != KErrNone )
+                {
+                SendErrorMessageL( err, KErrorDestDeleteFailed );
+                }
+            }
+        }
+
+    else if ( aMessage[0] == CHtiMessagesServicePlugin::EAddToDestination ||
+            aMessage[0] == CHtiMessagesServicePlugin::ERemoveFromDestination )
+        {
+        if ( aMessage.Length() < KMinModifyDestMsgLength )
+            {
+            SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+            }
+        else
+            {
+            TRAPD( err, ModifyDestinationL( aMessage[0], aMessage.Mid( 1 ) ) );
+            if ( err != KErrNone )
+                {
+                if ( aMessage[0] == CHtiMessagesServicePlugin::EAddToDestination )
+                    {
+                    SendErrorMessageL( err, KErrorAddToDestFailed );
+                    }
+                else
+                    {
+                    SendErrorMessageL( err, KErrorRemoveFromDestFailed );
+                    }
+                }
+            }
+        }
+    else if ( aMessage[0] == CHtiMessagesServicePlugin::ESetDefaultConnection )
+        {
+        if ( aMessage.Length() < KMinSetDefConMsgLength )
+            {
+            SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+            }
+        else
+            {
+            TRAPD( err, SetDefaultConnectionL( aMessage.Mid( 1 ) ) );
+            if ( err != KErrNone )
+                {
+                SendErrorMessageL( err, KErrorSetDefConFailed );
+                }
+            }
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiIAPHandler::ProcessMessageL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiIAPHandler::HandleCreateIapL
+// Creates new Internet Access Point.
+// ----------------------------------------------------------------------------
+void CHtiIAPHandler::HandleCreateIapL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CHtiIAPHandler::HandleCreateIapL" );
+
+    TRAPD( err, ParseCreateMessageL( aData ) );
+    if ( err != KErrNone )
+        {
+        SendErrorMessageL( err, KErrorInvalidParameters );
+        return;
+        }
+
+    if ( GetAccessPointUIDL() != KErrNotFound )
+        {
+        SendErrorMessageL( KErrAlreadyExists, KErrorApAlreadyExists );
+        return;
+        }
+
+    MapLegacyFieldIDs();
+    ResolveFieldDataTypes();
+
+    RCmManagerExt cmManager;
+    cmManager.OpenL();
+    CleanupClosePushL( cmManager );
+
+    RCmConnectionMethodExt cm = cmManager.CreateConnectionMethodL( iBearerType );
+    CleanupClosePushL( cm );
+    HTI_LOG_TEXT( "Connection method created" );
+
+    cm.SetStringAttributeL( ECmName, iConnName );
+    HTI_LOG_TEXT( "Name set" );
+
+    TUint32 requestedSeamlessness = 1; // default
+
+    // Set attributes
+    HTI_LOG_FORMAT( "Fields to write: %d", iFields.Count() );
+    for ( TInt i = 0; i < iFields.Count(); i++ )
+        {
+        if ( err != KErrNone ) break;
+
+        HTI_LOG_FORMAT( "Writing field %d", ( i + 1 ) );
+        TApField field = iFields[i];
+        HTI_LOG_FORMAT( "Field ID = %d", field.iId );
+
+        switch ( field.iDataType )
+            {
+            case EDataTypeText:
+                {
+                TRAP( err, cm.SetStringAttributeL( field.iId, *field.iData ) );
+                break;
+                }
+            case EDataTypeBool:
+                {
+                TLex lex( *field.iData );
+                TInt result = 0;
+                lex.Val( result );
+                TRAP( err, cm.SetBoolAttributeL( field.iId, ( TBool ) result ) );
+                break;
+                }
+            case EDataTypeUint:
+                {
+                TLex lex( *field.iData );
+                TUint32 result;
+                err = lex.Val( result, EDecimal );
+                if ( err == KErrNone )
+                    TRAP( err, cm.SetIntAttributeL( field.iId, result ) );
+                if ( field.iId == ECmSeamlessnessLevel )
+                    requestedSeamlessness = result;
+                break;
+                }
+            case EDataTypeText8:
+                {
+                HBufC8* buf8 = HBufC8::NewL( field.iData->Length() );
+                buf8->Des().Copy( *field.iData );
+                TRAP( err, cm.SetString8AttributeL( field.iId, *buf8 ) );
+                delete buf8;
+                buf8 = NULL;
+                break;
+                }
+            default:
+                {
+                HTI_LOG_FORMAT( "Unsupported field type %d", field.iDataType );
+                err = KErrNotSupported;
+                break;
+                }
+            }
+        }
+
+    if ( err != KErrNone )
+        {
+        HTI_LOG_FORMAT( "Error occurred %d", err );
+        User::Leave( err );
+        }
+
+    cm.UpdateL();
+    TUint32 uid = cm.GetIntAttributeL( ECmId );
+    CleanupStack::PopAndDestroy(); // cm
+
+    // The seamlessness value is not always set correctly when the connection
+    // method is created. Have to update seamlessness value separately after
+    // creation.
+    cm = cmManager.ConnectionMethodL( uid );
+    CleanupClosePushL( cm );
+    TUint32 currentSeamlessness = cm.GetIntAttributeL( ECmSeamlessnessLevel );
+    HTI_LOG_FORMAT( "Requested seamlessness = %d", requestedSeamlessness );
+    HTI_LOG_FORMAT( "Current seamlessness = %d", currentSeamlessness );
+    if ( currentSeamlessness != requestedSeamlessness )
+        {
+        cm.SetIntAttributeL( ECmSeamlessnessLevel, requestedSeamlessness );
+        cm.UpdateL();
+        HTI_LOG_TEXT( "Seamlessness value updated" );
+        }
+    CleanupStack::PopAndDestroy(); // cm
+    CleanupStack::PopAndDestroy(); // cmManager
+
+    HTI_LOG_FORMAT( "AP created with uid %d", uid );
+
+    TBuf8<4> idBuf;
+    idBuf.Append( ( TUint8* ) &uid, 4 );
+    SendOkMsgL( idBuf );
+
+    HTI_LOG_FUNC_OUT( "CHtiIAPHandler::HandleCreateIapL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiIAPHandler::HandleDeleteIapL
+// Deletes the named Internet Access Point
+// ----------------------------------------------------------------------------
+void CHtiIAPHandler::HandleDeleteIapL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CHtiIAPHandler::HandleDeleteIapL" );
+    if ( aData.Length() < KMinDeleteMsgLength )
+        {
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return;
+        }
+
+    TInt nameLength = aData[0];
+    if ( nameLength > KMaxConnNameLength ||
+         aData.Length() != ( nameLength + 1 ) )
+        {
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return;
+        }
+
+    iConnName.Copy( aData.Mid( 1, nameLength ) );
+    HTI_LOG_FORMAT( "Searching connection with name: %S", &iConnName );
+    TInt uid = GetAccessPointUIDL();
+
+    if ( uid == KErrNotFound )
+        {
+        SendErrorMessageL( KErrNotFound, KErrorApNotFound );
+        return;
+        }
+
+    RCmManagerExt cmManagerExt;
+    cmManagerExt.OpenL();
+    CleanupClosePushL( cmManagerExt );
+    RCmConnectionMethodExt connMethod = cmManagerExt.ConnectionMethodL( uid );
+    CleanupClosePushL( connMethod );
+    if ( connMethod.GetBoolAttributeL( ECmConnected ) )
+        {
+        HTI_LOG_TEXT( "AP in use - trying to close connections" );
+        TRAPD( err, CloseActiveConnectionsL() );
+        if ( err != KErrNone )
+            {
+            SendErrorMessageL( err, KErrorConnCloseFailed );
+            CleanupStack::PopAndDestroy( 2 ); // connMethod, cmManagerExt
+            return;
+            }
+        }
+
+    HTI_LOG_TEXT( "AP not in use - unlinking from all destinations" );
+    cmManagerExt.RemoveAllReferencesL( connMethod );
+    HTI_LOG_TEXT( "Deleting the AP" );
+    TBool deleted = connMethod.DeleteL(); // returns ETrue if really deleted
+    if ( !deleted )
+        {
+        HTI_LOG_TEXT( "Delete failed" );
+        User::Leave( KErrGeneral );
+        }
+    HTI_LOG_FORMAT( "AP deleted with uid %d", uid );
+    CleanupStack::PopAndDestroy(); // connMethod
+    CleanupStack::PopAndDestroy(); // cmManagerExt
+
+    SendOkMsgL( KNullDesC8 );
+    HTI_LOG_FUNC_OUT( "CHtiIAPHandler::HandleDeleteIapL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiIAPHandler::HandleCreateDestinationL
+// Creates a new Destination.
+// ----------------------------------------------------------------------------
+void CHtiIAPHandler::HandleCreateDestinationL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CHtiIAPHandler::HandleCreateDestinationL" );
+
+    TInt nameLength = aData[0];
+    if ( aData.Length() - 1 != nameLength || nameLength > KMaxConnNameLength )
+        {
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return;
+        }
+
+    RCmManagerExt cmManager;
+    cmManager.OpenL();
+    CleanupClosePushL( cmManager );
+
+    iDestName.Copy( aData.Mid( 1 ) );
+
+    RCmDestinationExt dest = cmManager.CreateDestinationL( iDestName );
+    CleanupClosePushL( dest );
+    dest.UpdateL();
+
+    CleanupStack::PopAndDestroy( 2 ); // dest, cmManager
+    SendOkMsgL( KNullDesC8 );
+
+    HTI_LOG_FUNC_OUT( "CHtiIAPHandler::HandleCreateDestinationL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiIAPHandler::HandleDeleteDestinationL
+// Deletes a named Destination.
+// ----------------------------------------------------------------------------
+void CHtiIAPHandler::HandleDeleteDestinationL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CHtiIAPHandler::HandleDeleteDestinationL" );
+
+    TInt nameLength = aData[0];
+    if ( aData.Length() - 1 != nameLength || nameLength > KMaxConnNameLength )
+        {
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return;
+        }
+
+    iDestName.Copy( aData.Mid( 1 ) );
+    TInt id = GetDestinationIDL( iDestName );
+
+    RCmManagerExt cmManager;
+    cmManager.OpenL();
+    CleanupClosePushL( cmManager );
+
+    RCmDestinationExt dest = cmManager.DestinationL ( id );
+    dest.DeleteLD();
+
+    CleanupStack::PopAndDestroy(); // cmManager
+    SendOkMsgL( KNullDesC8 );
+
+    HTI_LOG_FUNC_OUT( "CHtiIAPHandler::HandleDeleteDestinationL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiIAPHandler::ModifyDestinationL
+// Adds or removes IAP to/from a Destination.
+// ----------------------------------------------------------------------------
+void CHtiIAPHandler::ModifyDestinationL( const TInt aCommand, const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CHtiIAPHandler::ModifyDestinationL" );
+
+    TInt dataLength = aData.Length();
+    TInt offset = 0;
+    TInt cmNameLength = aData[offset];
+    offset++;
+    if ( dataLength < cmNameLength + 3 || cmNameLength > KMaxConnNameLength )
+        {
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return;
+        }
+    iConnName.Copy( aData.Mid( offset, cmNameLength ) );
+    offset += cmNameLength;
+    TInt destNameLength = aData[offset];
+    offset++;
+    if ( dataLength != cmNameLength + destNameLength + 2 ||
+            destNameLength > KMaxConnNameLength )
+        {
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return;
+        }
+
+    iDestName.Copy( aData.Mid( offset, destNameLength ) );
+
+    TInt cmId = GetAccessPointUIDL();
+    if ( cmId == KErrNotFound )
+        {
+        SendErrorMessageL( KErrNotFound, KErrorApNotFound );
+        return;
+        }
+    TInt destId = GetDestinationIDL( iDestName );
+    if ( destId == KErrNotFound )
+        {
+        SendErrorMessageL( KErrNotFound, KErrorDestNotFound );
+        return;
+        }
+
+    RCmManagerExt cmManager;
+    cmManager.OpenL();
+    CleanupClosePushL( cmManager );
+
+    RCmConnectionMethodExt cm = cmManager.ConnectionMethodL( cmId );
+    CleanupClosePushL( cm );
+    HTI_LOG_TEXT( "Got Connection Method" );
+
+    RCmDestinationExt dest = cmManager.DestinationL( destId );
+    CleanupClosePushL( dest );
+    HTI_LOG_TEXT( "Got Destination" );
+
+    if ( aCommand == CHtiMessagesServicePlugin::EAddToDestination )
+        {
+        dest.AddConnectionMethodL( cm );
+        }
+    else if ( aCommand == CHtiMessagesServicePlugin::ERemoveFromDestination)
+        {
+        dest.RemoveConnectionMethodL( cm );
+        }
+    else
+        {
+        // Programming error
+        User::Panic( _L( "CHtiIAPHandler"), 1 );
+        }
+    dest.UpdateL();
+    HTI_LOG_TEXT( "Destination updated" );
+
+    CleanupStack::PopAndDestroy( 3 ); // dest, cm, cmManager
+    SendOkMsgL( KNullDesC8 );
+
+    HTI_LOG_FUNC_OUT( "CHtiIAPHandler::ModifyDestinationL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiIAPHandler::SetDefaultConnectionL
+// Sets the default connection setting.
+// ----------------------------------------------------------------------------
+void CHtiIAPHandler::SetDefaultConnectionL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CHtiIAPHandler::SetDefaultConnectionL" );
+
+    if ( aData[0] > 3 || aData.Length() != aData[1] + 2 )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    TCmDefConnValue defConnValue;
+    defConnValue.iType = ( TCmDefConnType ) aData[0]; // cmdefconnvalues.h
+    HTI_LOG_FORMAT( "Requested type: %d", defConnValue.iType );
+
+    TInt id = 0;
+    if ( defConnValue.iType == ECmDefConnDestination )
+        {
+        if ( aData[1] == 0 || aData[1] > KMaxConnNameLength )
+            {
+            User::Leave( KErrArgument );
+            }
+        iDestName.Copy( aData.Mid( 2 ) );
+        HTI_LOG_FORMAT( "Destination name: %S", &iDestName );
+        id = GetDestinationIDL( iDestName );
+        if ( id == KErrNotFound )
+            {
+            SendErrorMessageL( KErrNotFound, KErrorDestNotFound );
+            return;
+            }
+        }
+
+    else if ( defConnValue.iType == ECmDefConnConnectionMethod )
+        {
+        if ( aData[1] == 0 || aData[1] > KMaxConnNameLength )
+            {
+            User::Leave( KErrArgument );
+            }
+        iConnName.Copy( aData.Mid( 2 ) );
+        HTI_LOG_FORMAT( "Connection method name: %S", &iConnName );
+        id = GetAccessPointUIDL();
+        if ( id == KErrNotFound )
+            {
+            SendErrorMessageL( KErrNotFound, KErrorApNotFound );
+            return;
+            }
+        }
+
+    defConnValue.iId = id;
+
+    RCmManagerExt cmManager;
+    cmManager.OpenL();
+    CleanupClosePushL( cmManager );
+    cmManager.WriteDefConnL( defConnValue );
+    CleanupStack::PopAndDestroy();
+    SendOkMsgL( KNullDesC8 );
+
+    HTI_LOG_FUNC_OUT( "CHtiIAPHandler::SetDefaultConnectionL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiIAPHandler::ParseCreateMessageL
+// Parses the parameters from the create IAP message. Leaves on error.
+// ----------------------------------------------------------------------------
+void CHtiIAPHandler::ParseCreateMessageL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CHtiIAPHandler::ParseCreateMessageL" );
+
+    TInt dataLength = aData.Length();
+    TInt offset = 0;
+
+    iBearerType = GetBearerUID( aData[offset] );
+    offset++;
+    HTI_LOG_FORMAT( "Bearer type %d", iBearerType );
+    if ( iBearerType == 0 )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    TInt nameLength = aData[offset];
+    offset++;
+    if ( dataLength < ( nameLength + offset + 1 ) ||
+         nameLength > KMaxConnNameLength )
+        {
+        User::Leave( KErrArgument );
+        }
+    iConnName.Copy( aData.Mid( offset, nameLength ) );
+    offset += nameLength;
+    HTI_LOG_FORMAT( "Connection name: %S", &iConnName );
+
+    TInt fieldCount = aData[offset];
+    offset++;
+    HTI_LOG_FORMAT( "Field count %d", fieldCount );
+
+    for ( TInt i = 0; i < fieldCount; i++ )
+        {
+        if ( dataLength < ( offset + 3 ) )
+            {
+            User::Leave( KErrArgument );
+            }
+        HTI_LOG_FORMAT( "Parsing field %d", i + 1 );
+        TApField field;
+        field.iId = aData[offset];
+        offset++;
+        TInt fieldLength = aData[offset];
+        offset++;
+        HTI_LOG_FORMAT( "Field data length %d", fieldLength );
+        if ( fieldLength < 1 || dataLength < ( fieldLength + offset ) )
+            {
+            User::Leave( KErrArgument );
+            }
+        field.iData = HBufC::NewL( fieldLength );
+        field.iData->Des().Copy( aData.Mid( offset, fieldLength ) );
+        offset += fieldLength;
+        HTI_LOG_FORMAT( "Field data: %S", field.iData );
+        field.iDataType = EDataTypeUnknown; // set later
+        User::LeaveIfError( iFields.Append( field ) );
+        }
+
+    if ( offset != dataLength )  // too much data
+        {
+        User::Leave( KErrArgument );
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiIAPHandler::ParseCreateMessageL" );
+    }
+
+// ----------------------------------------------------------------------------
+// CHtiIAPHandler::GetAccessPointUIDL
+// Gets the UID of Access Point named by iConnName.
+// Returns KErrNotFound if AP not found.
+// ----------------------------------------------------------------------------
+TInt CHtiIAPHandler::GetAccessPointUIDL()
+    {
+    HTI_LOG_FUNC_IN( "CHtiIAPHandler::GetAccessPointUIDL" );
+    TInt uid = KErrNotFound;
+
+    RCmManagerExt cmManager;
+    cmManager.OpenL();
+    CleanupClosePushL( cmManager );
+
+    // Search from uncategorised first
+    RArray<TUint32> array = RArray<TUint32>();
+    cmManager.ConnectionMethodL( array );
+    CleanupClosePushL( array );
+    TInt i = 0;
+    while ( i < array.Count() && uid == KErrNotFound )
+        {
+        RCmConnectionMethodExt cm = cmManager.ConnectionMethodL( array[i] );
+        CleanupClosePushL( cm );
+        HBufC* name = cm.GetStringAttributeL( ECmName );
+        HTI_LOG_FORMAT( "Found name: %S", name );
+        CleanupStack::PushL( name );
+        if ( iConnName.Compare( *name ) == 0 )
+            {
+            uid = cm.GetIntAttributeL( ECmId );
+            HTI_LOG_FORMAT( "Match: UID = %d", uid );
+            }
+        CleanupStack::PopAndDestroy(); // name
+        CleanupStack::PopAndDestroy(); // cm
+        i++;
+        }
+    CleanupStack::PopAndDestroy(); // array
+
+    // If not found from uncategorised, search from all destinations
+    if ( uid == KErrNotFound )
+        {
+        HTI_LOG_TEXT( "Not found from uncategorised" );
+        RArray<TUint32> destIdArray = RArray<TUint32>();
+        cmManager.AllDestinationsL( destIdArray );
+        CleanupClosePushL( destIdArray );
+        i = 0;
+        while ( i < destIdArray.Count() && uid == KErrNotFound )
+            {
+            RCmDestinationExt dest = cmManager.DestinationL( destIdArray[i] );
+            CleanupClosePushL( dest );
+            TInt j = 0;
+            while ( j < dest.ConnectionMethodCount() && uid == KErrNotFound )
+                {
+                HBufC* name = dest.ConnectionMethodL( j ).GetStringAttributeL(
+                        ECmName );
+                CleanupStack::PushL( name );
+                HTI_LOG_FORMAT( "Found name: %S", name );
+                if ( iConnName.Compare( *name ) == 0 )
+                    {
+                    uid = dest.ConnectionMethodL( j ).GetIntAttributeL(
+                            ECmId );
+                    HTI_LOG_FORMAT( "Match: UID = %d", uid );
+                    }
+                CleanupStack::PopAndDestroy(); // name
+                j++;
+                }
+            CleanupStack::PopAndDestroy(); // dest
+            i++;
+            }
+        CleanupStack::PopAndDestroy(); // destIdArray
+        }
+
+    CleanupStack::PopAndDestroy(); // cmManager
+    HTI_LOG_FUNC_OUT( "CHtiIAPHandler::GetAccessPointUIDL" );
+    return uid;
+    }
+
+// ----------------------------------------------------------------------------
+// CHtiIAPHandler::GetDestinationIDL
+// Gets the ID of Destination named by aName.
+// Returns KErrNotFound if Destination is not found.
+// ----------------------------------------------------------------------------
+TInt CHtiIAPHandler::GetDestinationIDL( const TDesC& aName )
+    {
+    HTI_LOG_FUNC_IN( "CHtiIAPHandler::GetDestinationIDL" );
+    HTI_LOG_FORMAT( "Searching Destination %S", &aName );
+
+    RCmManagerExt cmManager;
+    cmManager.OpenL();
+    CleanupClosePushL( cmManager );
+
+    TInt id = KErrNotFound;
+    RArray<TUint32> destIdArray = RArray<TUint32>( 8 );
+    CleanupClosePushL( destIdArray );
+
+    cmManager.AllDestinationsL( destIdArray );
+    TInt i = 0;
+    while ( i < destIdArray.Count() && id == KErrNotFound )
+        {
+        RCmDestinationExt dest = cmManager.DestinationL( destIdArray[i] );
+        CleanupClosePushL( dest );
+        HBufC* destName = dest.NameLC();
+        HTI_LOG_FORMAT( "Found Destination: %S", destName );
+        if ( destName->Compare( aName ) == 0 )
+            {
+            id = dest.Id();
+            HTI_LOG_FORMAT( "Match: ID = %d", id );
+            }
+        CleanupStack::PopAndDestroy( 2 ); // destName, dest
+        i++;
+        }
+
+    CleanupStack::PopAndDestroy( 2 ); // destIdArray, cmManager
+    HTI_LOG_FUNC_OUT( "CHtiIAPHandler::GetDestinationIDL" );
+    return id;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiIAPHandler::CloseActiveConnectionsL
+// Closes connection(s) that are using the Access Point named by iConnName.
+// Leaves if closing fails.
+// ----------------------------------------------------------------------------
+void CHtiIAPHandler::CloseActiveConnectionsL()
+    {
+    HTI_LOG_FUNC_IN( "CHtiIAPHandler::CloseActiveConnectionsL" );
+
+    RConnectionMonitor monitor;
+    monitor.ConnectL();
+    CleanupClosePushL( monitor );
+    HTI_LOG_TEXT( "RConnectionMonitor connected" );
+
+    TUint connCount = 0;
+    TUint subConnCount = 0;
+    TUint connId = 0;
+    //TUint iapId = 0;
+    TName iapName;
+    TRequestStatus status;
+
+    monitor.GetConnectionCount( connCount, status );
+    User::WaitForRequest( status );
+    User::LeaveIfError( status.Int() );
+    HTI_LOG_FORMAT( "Found %d connections", connCount );
+
+    for ( TUint i = 1; i <= connCount; i++ )
+        {
+        HTI_LOG_FORMAT( "Connection %d", i );
+        User::LeaveIfError(
+            monitor.GetConnectionInfo( i, connId, subConnCount ) );
+        HTI_LOG_FORMAT( " Connection ID = %d", connId );
+        HTI_LOG_FORMAT( " Sub connections = %d", subConnCount );
+        /*
+        monitor.GetUintAttribute( connId, 0, KIAPId, iapId, status );
+        User::WaitForRequest( status );
+        User::LeaveIfError( status.Int() );
+        HTI_LOG_FORMAT( " IAP ID = %d", iapId );
+        */
+        monitor.GetStringAttribute( connId, 0, KIAPName, iapName, status );
+        User::WaitForRequest( status );
+        User::LeaveIfError( status.Int() );
+        HTI_LOG_FORMAT( " IAP name = %S", &iapName );
+        if ( iapName.Compare( iConnName ) == 0 )
+            {
+            HTI_LOG_TEXT( " Match: Trying to close this connection" );
+            User::LeaveIfError(
+                monitor.SetBoolAttribute( connId, 0, KConnectionStop, ETrue ) );
+            }
+        }
+
+    CleanupStack::PopAndDestroy(); // monitor
+    HTI_LOG_FUNC_OUT( "CHtiIAPHandler::CloseActiveConnectionsL" );
+    }
+
+// ----------------------------------------------------------------------------
+// CHtiIAPHandler::GetBearerUID
+// Helper function for mapping old TApBearerType value to new bearer type
+// ECom UID.
+// ----------------------------------------------------------------------------
+TUint CHtiIAPHandler::GetBearerUID( const TInt aBearerType )
+    {
+    HTI_LOG_FUNC_IN( "CHtiIAPHandler::GetBearerUID" );
+    TUint uid = 0;
+    switch ( aBearerType )
+        {
+        case 0x01:  // CSD
+            uid = KUidCSDBearerType;
+            break;
+        case 0x02:  // GPRS
+            uid = KUidPacketDataBearerType;
+            break;
+        case 0x04:  // HSCSD
+            uid = KUidHSCSDBearerType;
+            break;
+        case 0x10:  // CDMA
+            uid = KUidPacketDataBearerType;
+            break;
+        case 0x20:  // WLAN
+            uid = KUidWlanBearerType;
+            break;
+        default:
+            break;
+
+        }
+    HTI_LOG_FUNC_OUT( "CHtiIAPHandler::GetBearerUID" );
+    return uid;
+    }
+
+// ----------------------------------------------------------------------------
+// CHtiIAPHandler::MapLegacyFieldIDs
+// Helper function for mapping the old access point field ID numbers to
+// new ones.
+// ----------------------------------------------------------------------------
+void CHtiIAPHandler::MapLegacyFieldIDs()
+    {
+    HTI_LOG_FUNC_IN( "CHtiIAPHandler::MapLegacyFieldIDs" );
+
+    for ( TInt i = 0; i < iFields.Count(); i++ )
+        {
+        TApField field = iFields[i];
+        switch ( field.iId )
+            {
+            case EApWapStartPage:
+                {
+                field.iId = ECmStartPage;
+                break;
+                }
+            case EApIspDefaultTelNumber:
+                {
+                field.iId = EDialDefaultTelNum;
+                break;
+                }
+            case EApIspUseLoginScript:
+                {
+                field.iId = EDialUseLoginScript;
+                break;
+                }
+            case EApIspLoginScript:
+                {
+                field.iId = EDialLoginScript;
+                break;
+                }
+            case EApIspLoginName:
+                {
+                if ( iBearerType == KUidCSDBearerType || iBearerType == KUidHSCSDBearerType )
+                    field.iId = EDialIFAuthName;
+                else if ( iBearerType == KUidPacketDataBearerType )
+                    field.iId = EPacketDataIFAuthName;
+                else
+                    field.iId = ECmIFAuthName;
+                break;
+                }
+            case EApIspLoginPass:
+                {
+                if ( iBearerType == KUidCSDBearerType || iBearerType == KUidHSCSDBearerType )
+                    field.iId = EDialIFAuthPass;
+                else if ( iBearerType == KUidPacketDataBearerType )
+                    field.iId = EPacketDataIFAuthPass;
+                else
+                    field.iId = ECmIFAuthPass;
+                break;
+                }
+            case EApIspIfPromptForAuth:
+                {
+                if ( iBearerType == KUidCSDBearerType || iBearerType == KUidHSCSDBearerType )
+                    field.iId = EDialIFPromptForAuth;
+                else if ( iBearerType == KUidPacketDataBearerType )
+                    field.iId = EPacketDataIFPromptForAuth;
+                else
+                    field.iId = ECmIFPromptForAuth;
+                break;
+                }
+            case EApIspIfCallbackEnabled:
+                {
+                field.iId = EDialIFCallbackEnabled;
+                break;
+                }
+            case EApIspIfCallbackType:
+                {
+                field.iId = EDialIFCallbackType;
+                break;
+                }
+            case EApIspIfCallbackInfo:
+                {
+                field.iId = EDialIFCallbackInfo;
+                break;
+                }
+            case EApIspIPAddr:
+                {
+                if ( iBearerType == KUidCSDBearerType || iBearerType == KUidHSCSDBearerType )
+                    field.iId = EDialIPAddress;
+                else if ( iBearerType == KUidPacketDataBearerType )
+                    field.iId = EPacketDataIPAddr;
+                else if ( iBearerType == KUidWlanBearerType )
+                    field.iId = EWlanIpAddr;
+                else
+                    field.iId = ECmIPAddress;
+                break;
+                }
+            case EApIspIPNameServer1:
+                {
+                if ( iBearerType == KUidCSDBearerType || iBearerType == KUidHSCSDBearerType )
+                    field.iId = EDialIPNameServer1;
+                else if ( iBearerType == KUidPacketDataBearerType )
+                    field.iId = EPacketDataIPNameServer1;
+                else if ( iBearerType == KUidWlanBearerType )
+                    field.iId = EWlanIpNameServer1;
+                else
+                    field.iId = ECmIPNameServer1;
+                break;
+                }
+            case EApIspIPNameServer2:
+                {
+                if ( iBearerType == KUidCSDBearerType || iBearerType == KUidHSCSDBearerType )
+                    field.iId = EDialIPNameServer2;
+                else if ( iBearerType == KUidPacketDataBearerType )
+                    field.iId = EPacketDataIPNameServer2;
+                else if ( iBearerType == KUidWlanBearerType )
+                    field.iId = EWlanIpNameServer2;
+                else
+                    field.iId = ECmIPNameServer2;
+                break;
+                }
+            case EApIspEnableIpHeaderComp:
+                {
+                if ( iBearerType == KUidCSDBearerType || iBearerType == KUidHSCSDBearerType )
+                    field.iId = EDialEnableIPHeaderComp;
+                else if ( iBearerType == KUidPacketDataBearerType )
+                    field.iId = EPacketDataHeaderCompression;
+                break;
+                }
+            case EApIspDisablePlainTextAuth:
+                {
+                if ( iBearerType == KUidCSDBearerType || iBearerType == KUidHSCSDBearerType )
+                    field.iId = EDialDisablePlainTextAuth;
+                else if ( iBearerType == KUidPacketDataBearerType )
+                    field.iId = EPacketDataDisablePlainTextAuth;
+                else
+                    field.iId = ECmDisablePlainTextAuth;
+                break;
+                }
+            case EApIspBearerSpeed:
+                {
+                field.iId = EDialMaxConnSpeed;
+                break;
+                }
+            case EApIspBearerCallTypeIsdn:
+                {
+                field.iId = EDialCallType;
+                break;
+                }
+            case EApIspInitString:
+                {
+                field.iId = EDialInitString;
+                break;
+                }
+            case EApGprsAccessPointName:
+                {
+                field.iId = EPacketDataAPName;
+                break;
+                }
+            case EApGprsPdpType:
+                {
+                field.iId = EPacketDataPDPType;
+                break;
+                }
+            case EApProxyServerAddress:
+                {
+                field.iId = ECmProxyServerName;
+                break;
+                }
+            case EApProxyPortNumber:
+                {
+                field.iId = ECmProxyPortNumber;
+                break;
+                }
+            case EApIP6NameServer1:
+                {
+                if ( iBearerType == KUidCSDBearerType || iBearerType == KUidHSCSDBearerType )
+                    field.iId = EDialIP6NameServer1;
+                else if ( iBearerType == KUidPacketDataBearerType )
+                    field.iId = EPacketDataIPIP6NameServer1;
+                else if ( iBearerType == KUidWlanBearerType )
+                    field.iId = EWlanIp6NameServer1;
+                else
+                    field.iId = ECmIP6NameServer1;
+                break;
+                }
+            case EApIP6NameServer2:
+                {
+                if ( iBearerType == KUidCSDBearerType || iBearerType == KUidHSCSDBearerType )
+                    field.iId = EDialIP6NameServer2;
+                else if ( iBearerType == KUidPacketDataBearerType )
+                    field.iId = EPacketDataIPIP6NameServer2;
+                else if ( iBearerType == KUidWlanBearerType )
+                    field.iId = EWlanIp6NameServer2;
+                else
+                    field.iId = ECmIP6NameServer2;
+                break;
+                }
+            case EApWlanNetworkName:
+                {
+                field.iId = EWlanSSID;
+                break;
+                }
+            case EApWlanNetworkMode:
+                {
+                field.iId = EWlanConnectionMode;
+                break;
+                }
+            case EApWlanSecurityMode:
+                {
+                field.iId = EWlanSecurityMode;
+                break;
+                }
+            case EApSeamlessnessLevel:
+                {
+                field.iId = ECmSeamlessnessLevel;
+                break;
+                }
+            default:
+                break;
+            }
+        iFields[i] = field;
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiIAPHandler::MapLegacyFieldIDs" );
+    }
+
+// ----------------------------------------------------------------------------
+// CHtiIAPHandler::ResolveFieldDataTypes
+// Helper function for resolving the data types for different AP settings
+// fields based on field ID and bearer type.
+// ----------------------------------------------------------------------------
+void CHtiIAPHandler::ResolveFieldDataTypes()
+    {
+    HTI_LOG_FUNC_IN( "CHtiIAPHandler::ResolveFieldDataTypes" );
+
+    for ( TInt i = 0; i < iFields.Count(); i++ )
+        {
+        if ( iFields[i].iDataType != EDataTypeUnknown ) continue; // already set
+
+        // Common fields
+        switch ( iFields[i].iId )
+            {
+            // String types
+            case ECmStartPage:
+            case ECmProxyServerName:
+            case ECmProxyProtocolName:
+            case ECmProxyExceptions:
+            case ECmIFName:
+            case ECmIFParams:
+            case ECmIFNetworks:
+            case ECmIFAuthName:
+            case ECmIFAuthPass:
+            case ECmIPGateway:
+            case ECmIPAddress:
+            case ECmIPNameServer1:
+            case ECmIPNameServer2:
+            case ECmIP6NameServer1:
+            case ECmIP6NameServer2:
+                iFields[i].iDataType = EDataTypeText;
+                break;
+
+            // Bool types
+            case ECmProtected:
+            case ECmIFPromptForAuth:
+            case ECmIPAddFromServer:
+            case ECmIPDNSAddrFromServer:
+            case ECmIP6DNSAddrFromServer:
+            case ECmEnableLPCExtension:
+            case ECmDisablePlainTextAuth:
+                iFields[i].iDataType = EDataTypeBool;
+                break;
+
+            // Uint types
+            case ECmSeamlessnessLevel:
+            case ECmProxyPortNumber:
+            case ECmIFAuthRetries:
+                iFields[i].iDataType = EDataTypeUint;
+                break;
+
+            default:
+                break;
+            }
+
+        // If it was found from common fields, we can continue to next field
+        if ( iFields[i].iDataType != EDataTypeUnknown ) continue;
+
+        // Check from bearer specific fields.
+        // Different bearers have to be in separate switch-cases because
+        // there are same values in different bearers.
+
+        // Data call fields
+        if ( iBearerType == KUidCSDBearerType ||
+                iBearerType == KUidHSCSDBearerType )
+            {
+            switch ( iFields[i].iId )
+                {
+                // String types
+                case EDialDescription:
+                case EDialDefaultTelNum:
+                case EDialLoginScript:
+                case EDialLoginName:
+                case EDialLoginPassword:
+                case EDialIFParams:
+                case EDialIFNetworks:
+                case EDialIFAuthName:
+                case EDialIFAuthPass:
+                case EDialIPAddress:
+                case EDialIPNetmask:
+                case EDialIPGateway:
+                case EDialIPNameServer1:
+                case EDialIPNameServer2:
+                case EDialIP6NameServer1:
+                case EDialIP6NameServer2:
+                    iFields[i].iDataType = EDataTypeText;
+                    break;
+
+                // Bool types
+                case EDialOut:
+                case EDialDialResolution:
+                case EDialUseLoginScript:
+                case EDialPromptForLogin:
+                case EDialDisplayPCT:
+                case EDialIFPromptForAuth:
+                case EDialIFCallbackEnabled:
+                case EDialIFServerMode:
+                case EDialIPAddressFromServer:
+                case EDialIPDNSAddressFromServer:
+                case EDialIP6DNSAddressFromServer:
+                case EDialEnableIPHeaderComp:
+                case EDialEnableLCPExtension:
+                case EDialDisablePlainTextAuth:
+                case EDialEnableSWComp:
+                case EDialUseEdge:
+                    iFields[i].iDataType = EDataTypeBool;
+                    break;
+
+                // Uint types
+                case EDialCallType:
+                case EDialMaxConnSpeed:
+                case EDialType:
+                case EDialChargeCard:
+                case EDialIFAuthRetries:
+                case EDialIFCallbackType:
+                case EDialCallbackTimeout:
+                case EDialBearerName:
+                case EDialBearerSpeed:
+                case EDialBearerCE:
+                case EDialBearerService:
+                case EDialBearerProtocol:
+                case EDialRLPVersion:
+                case EDialIWFtoMS:
+                case EDialMStoIWF:
+                case EDialAckTimer:
+                case EDialRetransmissionAttempts:
+                case EDialResequencePeriod:
+                case EDialV42Compression:
+                case EDialV42CodeWords:
+                case EDialV42MaxLength:
+                case EHscsdAsymmetry:
+                case EHscsdUserInitUpgrade:
+                    iFields[i].iDataType = EDataTypeUint;
+                    break;
+
+                // 8-bit string types
+                case EDialIFCallbackInfo:
+                case EDialInitString:
+                    iFields[i].iDataType = EDataTypeText8;
+                    break;
+
+                default:
+                    break;
+                }
+            }
+
+        // Packet data fields
+        else if ( iBearerType == KUidPacketDataBearerType )
+            {
+            switch ( iFields[i].iId )
+                {
+                // String types
+                case EPacketDataAPName:
+                case EPacketDataPDPAddress:
+                case EPacketDataIFParams:
+                case EPacketDataIFNetworks:
+                case EPacketDataIFAuthName:
+                case EPacketDataIFAuthPass:
+                case EPacketDataIPNetmask:
+                case EPacketDataIPGateway:
+                case EPacketDataIPAddr:
+                case EPacketDataIPNameServer1:
+                case EPacketDataIPNameServer2:
+                case EPacketDataIPIP6NameServer1:
+                case EPacketDataIPIP6NameServer2:
+                    iFields[i].iDataType = EDataTypeText;
+                    break;
+
+                // Bool types
+                case EPacketDataDataCompression:
+                case EPacketDataHeaderCompression:
+                case EPacketDataUseEdge:
+                case EPacketDataAnonymousAccess:
+                case EPacketDataIFPromptForAuth:
+                case EPacketDataIPAddrFromServer:
+                case EPacketDataIPDNSAddrFromServer:
+                case EPacketDataIPIP6DNSAddrFromServer:
+                case EPacketDataEnableLcpExtension:
+                case EPacketDataDisablePlainTextAuth:
+                case EPacketDataServiceEnableLLMNR:
+                    iFields[i].iDataType = EDataTypeBool;
+                    break;
+
+                // Uint types
+                case EPacketDataPDPType:
+                case EPacketDataIFAuthRetries:
+                case EPacketDataApType:
+                    iFields[i].iDataType = EDataTypeUint;
+                    break;
+
+                default:
+                    break;
+                }
+            }
+
+        // WLAN fields
+        else if ( iBearerType == KUidWlanBearerType )
+            {
+            switch ( iFields[i].iId )
+            {
+                // String types
+                case EWlanIfNetworks:
+                case EWlanIpNetMask:
+                case EWlanIpGateway:
+                case EWlanIpAddr:
+                case EWlanIpNameServer1:
+                case EWlanIpNameServer2:
+                case EWlanIp6NameServer1:
+                case EWlanIp6NameServer2:
+                case EWlanSSID:
+                case EWlanUsedSSID:
+                    iFields[i].iDataType = EDataTypeText;
+                    break;
+
+                // Bool types
+                case EWlanIpAddrFromServer:
+                case EWlanIpDNSAddrFromServer:
+                case EWlanIp6DNSAddrFromServer:
+                case EWlanScanSSID:
+                case EWlanAllowSSIDRoaming:
+                    iFields[i].iDataType = EDataTypeBool;
+                    break;
+
+                // Uint types
+                case EWlanServiceId:
+                case EWlanConnectionMode:
+                case EWlanSecurityMode:
+                case EWlanAuthenticationMode:
+                case EWlanChannelID:
+                    iFields[i].iDataType = EDataTypeUint;
+                    break;
+
+                default:
+                    break;
+                }
+            }
+
+        else
+            {
+            HTI_LOG_TEXT( "Unknown bearer type" )
+            }
+        }
+    HTI_LOG_FUNC_OUT( "CHtiIAPHandler::ResolveFieldDataTypes" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiIAPHandler::SendOkMsgL
+// Helper function for sending response messages.
+// ----------------------------------------------------------------------------
+void CHtiIAPHandler::SendOkMsgL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CHtiIAPHandler::SendOkMsgL" );
+    User::LeaveIfNull( iDispatcher );
+    HBufC8* temp = HBufC8::NewL( aData.Length() + 1 );
+    TPtr8 response = temp->Des();
+    response.Append( ( TChar ) CHtiMessagesServicePlugin::EResultOk );
+    response.Append( aData );
+    User::LeaveIfError( iDispatcher->DispatchOutgoingMessage(
+        temp, KHtiMessagesServiceUid ) );
+    HTI_LOG_FUNC_OUT( "CHtiIAPHandler::SendOkMsgL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiIAPHandler::SendErrorMessageL
+// Helper function for sending error response messages.
+// ----------------------------------------------------------------------------
+void CHtiIAPHandler::SendErrorMessageL( TInt aError, const TDesC8& aDescription )
+    {
+    HTI_LOG_FUNC_IN( "CHtiIAPHandler::SendErrorMessageL" );
+    User::LeaveIfNull( iDispatcher );
+    User::LeaveIfError( iDispatcher->DispatchOutgoingErrorMessage(
+        aError, aDescription, KHtiMessagesServiceUid ) );
+    HTI_LOG_FUNC_OUT( "CHtiIAPHandler::SendErrorMessageL" );
+    }
+
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiMessagesServicePlugin/src/HtiMailboxHandler.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,1159 @@
+/*
+* 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:  Implementation of HTI mailbox settings handling.
+*
+*/
+
+
+// INCLUDE FILES
+#include <cmconnectionmethod.h>
+#include <cmconnectionmethoddef.h>
+#include <cmdestination.h>
+#include <cmmanager.h>
+#include <cemailaccounts.h>
+#include <etelmm.h>
+#include <iapprefs.h>
+#include <imapset.h>
+#include <mtmuibas.h>
+#include <senduiconsts.h>
+#include <pop3set.h>
+#include <smtpset.h>
+#include <txtrich.h>
+
+#include <HtiDispatcherInterface.h>
+#include <HTILogging.h>
+#include "HtiMessagesServicePlugin.h"
+#include "HtiMailboxHandler.h"
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES
+
+// CONSTANTS
+const TInt KMinCreateMsgLength = 36;
+const TInt KMinDeleteMsgLength = 3;
+
+const TInt KImeiLength = 15;
+
+const TInt KDefaultImapPortSSL = 993;
+const TInt KDefaultPopPortSSL  = 995;
+const TInt KDefaultSmtpPortSSL = 465;
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+_LIT8( KErrorInvalidParameters, "Invalid command parameters" );
+_LIT8( KErrorCreateFailed, "Mailbox creation failed" );
+_LIT8( KErrorDeleteFailed, "Mailbox deletion failed" );
+
+#ifdef __WINS__
+_LIT( KWinsImei, "123456789012345" );
+#else
+_LIT( KTsyName, "phonetsy" );
+#endif
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CHtiMailboxHandler::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+CHtiMailboxHandler* CHtiMailboxHandler::NewL()
+    {
+    HTI_LOG_FUNC_IN( "CHtiMailboxHandler::NewL" );
+    CHtiMailboxHandler* self = new (ELeave) CHtiMailboxHandler();
+    CleanupStack::PushL ( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    HTI_LOG_FUNC_OUT( "CHtiMailboxHandler::NewL" );
+    return self;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiMailboxHandler::CHtiMailboxHandler
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// ----------------------------------------------------------------------------
+CHtiMailboxHandler::CHtiMailboxHandler()
+    {
+    HTI_LOG_FUNC_IN( "CHtiMailboxHandler::CHtiMailboxHandler" );
+
+    HTI_LOG_FUNC_OUT( "CHtiMailboxHandler::CHtiMailboxHandler" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiMailboxHandler::~CHtiMailboxHandler
+// Destructor.
+// -----------------------------------------------------------------------------
+CHtiMailboxHandler::~CHtiMailboxHandler()
+    {
+    HTI_LOG_FUNC_IN( "CHtiMailboxHandler::~CHtiMailboxHandler" );
+    delete iMailboxName;
+    delete iIncomingServer;
+    delete iIncomingApName;
+    delete iIncomingUserName;
+    delete iIncomingPassword;
+    delete iOutgoingServer;
+    delete iOutgoingApName;
+    delete iOutgoingUserName;
+    delete iOutgoingPassword;
+    delete iOwnMailAddress;
+    delete iOwnName;
+    delete iSignatureText;
+    delete iImapFolderPath;
+    HTI_LOG_FUNC_OUT( "CHtiMailboxHandler::~CHtiMailboxHandler" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiMailboxHandler::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+void CHtiMailboxHandler::ConstructL()
+    {
+    HTI_LOG_FUNC_IN( "CHtiMailboxHandler::ConstructL" );
+
+    HTI_LOG_FUNC_OUT( "CHtiMailboxHandler::ConstructL" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiMailboxHandler::SetDispatcher
+// Sets the dispatcher pointer.
+// -----------------------------------------------------------------------------
+
+void CHtiMailboxHandler::SetDispatcher( MHtiDispatcher* aDispatcher )
+    {
+    HTI_LOG_FUNC_IN( "CHtiMailboxHandler::SetDispatcher" );
+    iDispatcher = aDispatcher;
+    HTI_LOG_FUNC_OUT( "CHtiMailboxHandler::SetDispatcher" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiMailboxHandler::ProcessMessageL
+// Parses the received message and calls handler functions.
+// -----------------------------------------------------------------------------
+void CHtiMailboxHandler::ProcessMessageL( const TDesC8& aMessage,
+    THtiMessagePriority /*aPriority*/ )
+    {
+    HTI_LOG_FUNC_IN( "CHtiMailboxHandler::ProcessMessageL" );
+
+    // Zero length message and command code validity already checked
+    // in HtiMessagesServicePlugin.
+
+    if ( aMessage[0] == CHtiMessagesServicePlugin::ECreateMailBox )
+        {
+        if ( aMessage.Length() < KMinCreateMsgLength )
+            {
+            SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+            }
+        else
+            {
+            iCmManager.OpenL();
+            TRAPD( err, HandleCreateMailboxL(
+                    aMessage.Right( aMessage.Length() - 1 ) ) );
+            if ( err != KErrNone )
+                {
+                if ( err == KErrArgument )
+                    {
+                    SendErrorMessageL( err, KErrorInvalidParameters );
+                    }
+                else
+                    {
+                    HTI_LOG_FORMAT( "Create error %d", err );
+                    SendErrorMessageL( err, KErrorCreateFailed );
+                    }
+                }
+            else
+                {
+                SendOkMsgL( KNullDesC8 );
+                }
+            ResetVariables();
+            }
+        }
+
+    else
+        {
+        if ( aMessage.Length() < KMinDeleteMsgLength )
+            {
+            SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+            }
+        else
+            {
+            TRAPD( err, HandleDeleteMailboxL(
+                    aMessage.Right( aMessage.Length() - 1 ) ) );
+            if ( err != KErrNone )
+                {
+                HTI_LOG_FORMAT( "Delete error %d", err );
+                SendErrorMessageL( err, KErrorDeleteFailed );
+                }
+            else
+                {
+                SendOkMsgL( KNullDesC8 );
+                }
+            }
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiMailboxHandler::ProcessMessageL" );
+    }
+
+// ----------------------------------------------------------------------------
+// CHtiMailboxHandler::HandleCreateMailboxL
+// Creates new mailbox.
+// ----------------------------------------------------------------------------
+void CHtiMailboxHandler::HandleCreateMailboxL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CHtiMailboxHandler::HandleCreateMailboxL" );
+
+    ParseCreateMsgL( aData );
+
+    TSmtpAccount smtpAcc;
+    TInt result = FindSmtpAccount( *iMailboxName, smtpAcc );
+    if ( result != KErrNotFound )
+        {
+        User::Leave( KErrAlreadyExists );
+        }
+
+    CImImap4Settings* imap4Set = new (ELeave) CImImap4Settings;
+    CleanupStack::PushL( imap4Set );
+    CImPop3Settings* pop3Set = new (ELeave) CImPop3Settings;
+    CleanupStack::PushL( pop3Set );
+    CImSmtpSettings* smtpSet = new (ELeave) CImSmtpSettings;
+    CleanupStack::PushL( smtpSet );
+
+    CImIAPPreferences* incomingIapSet = CImIAPPreferences::NewLC();
+    CImIAPPreferences* outgoingIapSet = CImIAPPreferences::NewLC();
+
+    CEmailAccounts* accounts = CEmailAccounts::NewLC();
+    accounts->PopulateDefaultSmtpSettingsL( *smtpSet, *outgoingIapSet );
+    if ( iMailboxType == 0 )  // POP3
+        {
+        accounts->PopulateDefaultPopSettingsL( *pop3Set, *incomingIapSet );
+        }
+    else // IMAP4
+        {
+        accounts->PopulateDefaultImapSettingsL( *imap4Set, *incomingIapSet );
+        }
+
+    // Set access point settings
+    TImIAPChoice imIAPChoice;
+    imIAPChoice.iIAP = 0;
+    imIAPChoice.iDialogPref = ECommDbDialogPrefPrompt;
+
+    if ( iIncomingApName->Length() > 0 )
+        {
+        User::LeaveIfError(
+            imIAPChoice.iIAP = AccessPointUIDL( *iIncomingApName ) );
+        imIAPChoice.iDialogPref = ECommDbDialogPrefDoNotPrompt;
+        HTI_LOG_TEXT( "Incoming IAP user defined" );
+        }
+    incomingIapSet->AddIAPL( imIAPChoice );
+
+    imIAPChoice.iIAP = 0;
+    imIAPChoice.iDialogPref = ECommDbDialogPrefPrompt;
+
+    if ( iOutgoingApName->Length() > 0 )
+        {
+        User::LeaveIfError(
+            imIAPChoice.iIAP = AccessPointUIDL( *iOutgoingApName ) );
+        imIAPChoice.iDialogPref = ECommDbDialogPrefDoNotPrompt;
+        HTI_LOG_TEXT( "Outgoing IAP user defined" );
+        }
+    outgoingIapSet->AddIAPL( imIAPChoice );
+
+    // Set SMTP settings
+    HTI_LOG_TEXT( "Setting SMTP settings" );
+    smtpSet->SetServerAddressL( *iOutgoingServer );
+    smtpSet->SetLoginNameL( *iOutgoingUserName );
+    smtpSet->SetPasswordL( *iOutgoingPassword );
+    smtpSet->SetEmailAddressL( *iOwnMailAddress );
+    smtpSet->SetReplyToAddressL( *iOwnMailAddress );
+    smtpSet->SetEmailAliasL( *iOwnName );
+    if ( iSignatureText->Length() > 0 )
+        {
+        smtpSet->SetAddSignatureToEmail( ETrue );
+        }
+    else
+        {
+        smtpSet->SetAddSignatureToEmail( EFalse );
+        }
+    smtpSet->SetSendCopyToSelf( (TImSMTPSendCopyToSelf) iSendCopyToOwnAddress );
+    smtpSet->SetSendMessageOption( (TImSMTPSendMessageOption) iSendOption );
+    if ( iOutgoingSecurity == 0 )
+        {
+        smtpSet->SetSecureSockets( EFalse );
+        }
+    else
+        {
+        smtpSet->SetSecureSockets( ETrue );
+        if ( iOutgoingSecurity == 1 )
+            {
+            smtpSet->SetSSLWrapper( EFalse );
+            }
+        else // 2 = SSL
+            {
+            smtpSet->SetSSLWrapper( ETrue );
+            }
+        }
+    if ( iOutgoingPort > 0 )
+        {
+        smtpSet->SetPort( (TUint) iOutgoingPort );
+        }
+    else
+        {
+        if ( iOutgoingSecurity == 2 ) // SSL
+            {
+            smtpSet->SetPort( KDefaultSmtpPortSSL );
+            }
+        else
+            {
+            smtpSet->SetPort( KSMTPDefaultPortNumber );
+            }
+        }
+    smtpSet->SetBodyEncoding( EMsgOutboxMIME );
+    smtpSet->SetAddVCardToEmail( EFalse );
+    smtpSet->SetRequestReceipts( EFalse );
+    smtpSet->SetSMTPAuth( ETrue );
+
+    TSmtpAccount smtpAccount;
+    TPopAccount popAccount;
+    TImapAccount imapAccount;
+
+    // Set POP3 settings
+    if ( iMailboxType == 0 )  // POP3
+        {
+        HTI_LOG_TEXT( "Setting POP3 settings" );
+        pop3Set->SetServerAddressL( *iIncomingServer );
+        pop3Set->SetLoginNameL( *iIncomingUserName );
+        pop3Set->SetPasswordL( *iIncomingPassword );
+        pop3Set->SetApop( iAPopSecureLogin );
+        if ( iIncomingSecurity == 0 )
+            {
+            pop3Set->SetSecureSockets( EFalse );
+            }
+        else
+            {
+            pop3Set->SetSecureSockets( ETrue );
+            if ( iIncomingSecurity == 1 )
+                {
+                pop3Set->SetSSLWrapper( EFalse );
+                }
+            else
+                {
+                pop3Set->SetSSLWrapper( ETrue );
+                }
+            }
+        if ( iIncomingPort > 0 )
+            {
+            pop3Set->SetPort( (TUint) iIncomingPort );
+            }
+        else
+            {
+            if ( iIncomingSecurity == 2 ) // SSL
+                {
+                pop3Set->SetPort( KDefaultPopPortSSL );
+                }
+            else
+                {
+                pop3Set->SetPort( KPOP3DefaultPortNumber );
+                }
+            }
+        if ( iRetrievedParts == 0 ) // Only headers
+            {
+            pop3Set->SetGetMailOptions( EGetPop3EmailHeaders );
+            pop3Set->SetPopulationLimitL( -2 ); // -2 = headers only (EmailUtils.h)
+            }
+        else
+            {
+            pop3Set->SetGetMailOptions( EGetPop3EmailMessages );
+            if ( iRetrievedParts == 1 ) // Less than (kb)
+                {
+                pop3Set->SetMaxEmailSize( iRetrieveSizeLimitKb );
+                pop3Set->SetPopulationLimitL( iRetrieveSizeLimitKb );
+                }
+            else
+                {
+                pop3Set->SetPopulationLimitL( -1 ); // -1 = body and attachment (EmailUtils.h)
+                }
+            }
+
+        if ( iEmailsToRetrieve > 0 )
+            {
+            pop3Set->SetInboxSynchronisationLimit( iEmailsToRetrieve );
+            }
+        else
+            {
+            // If limit is not set (zero), retrieves all
+            pop3Set->SetInboxSynchronisationLimit( KErrNotFound );
+            }
+
+        pop3Set->SetAcknowledgeReceipts( EFalse );
+        pop3Set->SetDisconnectedUserMode( ETrue );
+        pop3Set->SetAutoSendOnConnect( ETrue );
+        pop3Set->SetDeleteEmailsWhenDisconnecting( EFalse );
+
+        popAccount = accounts->CreatePopAccountL(
+            *iMailboxName, *pop3Set, *incomingIapSet, EFalse );
+        HTI_LOG_FORMAT( "Created POP3 account %d", popAccount.iPopAccountId );
+        smtpAccount = accounts->CreateSmtpAccountL(
+            popAccount, *smtpSet, *outgoingIapSet, EFalse );
+        HTI_LOG_FORMAT( "Created SMTP account %d", smtpAccount.iSmtpAccountId );
+        }
+
+    // Set IMAP4 settings
+    else
+        {
+        HTI_LOG_TEXT( "Setting IMAP4 settings" );
+        imap4Set->SetServerAddressL( *iIncomingServer );
+        imap4Set->SetLoginNameL( *iIncomingUserName );
+        imap4Set->SetPasswordL( *iIncomingPassword );
+        if ( iIncomingSecurity == 0 )
+            {
+            imap4Set->SetSecureSockets( EFalse );
+            }
+        else
+            {
+            imap4Set->SetSecureSockets( ETrue );
+            if ( iIncomingSecurity == 1 )
+                {
+                imap4Set->SetSSLWrapper( EFalse );
+                }
+            else
+                {
+                imap4Set->SetSSLWrapper( ETrue );
+                }
+            }
+        if ( iIncomingPort > 0 )
+            {
+            imap4Set->SetPort( (TUint) iIncomingPort );
+            }
+        else
+            {
+            if ( iIncomingSecurity == 2 ) // SSL
+                {
+                imap4Set->SetPort( KDefaultImapPortSSL );
+                }
+            else
+                {
+                imap4Set->SetPort( KIMAPDefaultPortNumber );
+                }
+            }
+        if ( iEmailsToRetrieve > 0 )
+            {
+            imap4Set->SetInboxSynchronisationLimit( iEmailsToRetrieve );
+            imap4Set->SetMailboxSynchronisationLimit( iEmailsToRetrieve );
+            }
+        else
+            {
+            // If limit is not set (zero), retrieves all
+            imap4Set->SetInboxSynchronisationLimit( KErrNotFound );
+            imap4Set->SetMailboxSynchronisationLimit( KErrNotFound );
+            }
+
+        imap4Set->SetFolderPathL( *iImapFolderPath );
+
+        imap4Set->SetGetMailOptions( EGetImap4EmailHeaders );
+        imap4Set->SetPartialMailOptionsL( ENoSizeLimits );
+        imap4Set->SetBodyTextSizeLimitL( KMaxTInt );
+        imap4Set->SetAttachmentSizeLimitL( KMaxTInt );
+        imap4Set->SetAcknowledgeReceipts( EFalse );
+        imap4Set->SetDisconnectedUserMode( ETrue );
+        imap4Set->SetSynchronise( EUseLocal );
+        imap4Set->SetSubscribe( EUpdateNeither );
+        imap4Set->SetAutoSendOnConnect( ETrue );
+        imap4Set->SetDeleteEmailsWhenDisconnecting( EFalse );
+        imap4Set->SetImapIdle( ETrue );
+        imap4Set->SetUpdatingSeenFlags( ETrue );
+
+        imapAccount = accounts->CreateImapAccountL(
+            *iMailboxName, *imap4Set, *incomingIapSet, EFalse );
+        HTI_LOG_FORMAT( "Created IMAP4 account %d", imapAccount.iImapAccountId );
+        smtpAccount = accounts->CreateSmtpAccountL(
+            imapAccount, *smtpSet, *outgoingIapSet, EFalse );
+        HTI_LOG_FORMAT( "Created SMTP account %d", smtpAccount.iSmtpAccountId );
+        }
+
+    // Set as default if requested
+     if ( iSetAsDefault )
+        {
+        accounts->SetDefaultSmtpAccountL( smtpAccount );
+        }
+
+    // accounts, outgoingIapSet, incomingIapSet, smtpSet, pop3Set, imap4set
+    CleanupStack::PopAndDestroy( 6 );
+
+    // Get IDs of created incoming mail account
+    TMsvId mailboxId = 0;
+    TUint32 accountId = 0;
+    TUid protocol = TUid::Null();
+    if ( iMailboxType == 0 ) // POP3
+        {
+        mailboxId = popAccount.iPopService;
+        accountId = popAccount.iPopAccountId;
+        protocol.iUid = KSenduiMtmPop3UidValue;
+        }
+
+    else // IMAP4
+        {
+        mailboxId = imapAccount.iImapService;
+        accountId = imapAccount.iImapAccountId;
+        protocol.iUid = KSenduiMtmImap4UidValue;
+        iRetrievedParts = 0;
+        }
+
+    // Get the created mailbox entries
+    HTI_LOG_TEXT( "Opening MSV session" );
+    CMsvSession* session = CMsvSession::OpenSyncL( *this );
+    CleanupStack::PushL( session );
+    HTI_LOG_TEXT( "Getting mailbox MSV entries" );
+    CMsvEntry* incomingEntry = session->GetEntryL( mailboxId );
+    CleanupStack::PushL( incomingEntry );
+    CMsvEntry* outgoingEntry = session->GetEntryL( smtpAccount.iSmtpService );
+    CleanupStack::PushL( outgoingEntry );
+
+    // Store account IDs and device IMEI to entries
+    HTI_LOG_TEXT( "Storing account IDs and IMEI" );
+    TBuf<KImeiLength> phoneImei;
+    GetDeviceImeiL( phoneImei );
+    HTI_LOG_FORMAT( "Got IMEI: %S", &phoneImei );
+    TMsvEntry inTEntry = incomingEntry->Entry();
+    inTEntry.iMtmData2 = accountId;
+    inTEntry.iDescription.Set( phoneImei );
+    incomingEntry->ChangeL( inTEntry );
+    TMsvEntry outTEntry = outgoingEntry->Entry();
+    outTEntry.iMtmData2 = smtpAccount.iSmtpAccountId;
+    outTEntry.iDescription.Set( phoneImei );
+    outgoingEntry->ChangeL( outTEntry );
+
+    // Create the signature text if given
+    if ( iSignatureText->Length() > 0 )
+        {
+        // Get signature store
+        HTI_LOG_TEXT( "Getting signature store" );
+        CMsvStore* store = outgoingEntry->EditStoreL();
+        CleanupStack::PushL( store );
+
+        // Create signarure rich text
+        HTI_LOG_TEXT( "Creating signature CRichText" );
+        CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL();
+        CleanupStack::PushL( paraFormatLayer );
+        CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL();
+        CleanupStack::PushL( charFormatLayer );
+        CRichText* signature = CRichText::NewL( paraFormatLayer,
+                                                charFormatLayer );
+        CleanupStack::PushL( signature );
+        signature->InsertL( 0, *iSignatureText );
+
+        // Store the signature
+        store->StoreBodyTextL( *signature );
+        store->CommitL();
+
+        // signature, charFormatLayer, paraFormatLayer, store
+        CleanupStack::PopAndDestroy( 4 );
+        }
+
+    CleanupStack::PopAndDestroy( 3 ); // outgoingEntry, incomingEntry, session
+    HTI_LOG_FUNC_OUT( "CHtiMailboxHandler::HandleCreateMailboxL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiMailboxHandler::HandleDeleteMailboxL
+// Deletes a mailbox.
+// ----------------------------------------------------------------------------
+void CHtiMailboxHandler::HandleDeleteMailboxL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CHtiMailboxHandler::HandleDeleteMailboxL" );
+    // Deprecated
+    aData.Size();
+    User::Leave( KErrNotSupported );
+    HTI_LOG_FUNC_OUT( "CHtiMailboxHandler::HandleDeleteMailboxL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiMailboxHandler::ParseCreateMsgL
+// Parses the parameters from the create account message.
+// ----------------------------------------------------------------------------
+void CHtiMailboxHandler::ParseCreateMsgL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CHtiMailboxHandler::ParseCreateMsgL" );
+    /*  ACCOUNT SETTINGS
+     *   Field                              Size      Values    Mandatory
+     *   ---------------------------------------------------------------------
+     *   Mailbox type                       1 byte    0,1       YES
+     *   Mailbox name length                1 byte    1-30      YES
+     *   Mailbox name                       1-30                YES
+     *   Incoming mail server length        1 byte    3-50      YES
+     *   Incoming mail server               3-50                YES
+     *   Incoming access point name length  1 byte    0-255     YES
+     *   Incoming access point name         0-255               NO
+     *   Incoming user name length          1 byte    0-50      YES
+     *   Incoming user name                 0-50                NO
+     *   Incoming password length           1 byte    0-50      YES
+     *   Incoming password                  0-50                NO
+     *   Incoming security                  1 byte    0,1,2     YES
+     *   Incoming port                      2 bytes   0-999     YES
+     *   A POP secure login                 1 byte    0,1       YES
+     *   Outgoing mail server length        1 byte    1-50      YES
+     *   Outgoing mail server               1-50                YES
+     *   Outgoing access point name length  1 byte    0-255     YES
+     *   Outgoing access point name         0-255               NO
+     *   Outgoing user name length          1 byte    0-50      YES
+     *   Outgoing user name                 0-50                NO
+     *   Outgoing password length           1 byte    0-50      YES
+     *   Outgoing password                  0-50                NO
+     *   Outgoing security                  1 byte    0,1,2     YES
+     *   Outgoing port                      2 bytes   0-999     YES
+     *   Own mail address length            1 byte    1-100     YES
+     *   Own mail address                   1-100               YES
+     *   Own name length                    1 byte    0-100     YES
+     *   Own name                           0-100               NO
+     *   Send message option                1 byte    0,1,2     YES
+     *   Copy to own mail address           1 byte    0,1,2,3   YES
+     *   Signature length                   2 bytes   0-500     YES
+     *   Signature text                     0-500               NO
+     *   New mail indicators                1 byte    0,1       YES
+     *   Retrieved parts                    1 byte    0,1,2     YES
+     *   Retrieve size limit                2 bytes   1-999     YES
+     *   Emails to retrieve                 2 bytes   0-999     YES
+     *   IMAP4 folder path length           1 byte    0-100     YES
+     *   IMAP4 folder path                  0-100               NO
+     *   Automatic update                   1 byte    0,1,2     YES
+     *   Set as default for outgoing mail   1 byte    0,1       YES
+     */
+
+    TInt dataLength = aData.Length();
+    HTI_LOG_FORMAT( "Data length = %d", dataLength );
+    TInt offset = 0;
+    iMailboxType = aData[offset];
+    HTI_LOG_FORMAT( "Mailbox type = %d", iMailboxType );
+    if ( iMailboxType != 0 && iMailboxType != 1 )
+        {
+        User::Leave( KErrArgument );
+        }
+    offset++;
+
+    iMailboxName = ParseStringL( aData, offset );
+    offset += iMailboxName->Length() + 1;
+
+    iIncomingServer = ParseStringL( aData, offset );
+    offset += iIncomingServer->Length() + 1;
+
+
+    iIncomingApName = ParseStringL( aData, offset );
+    offset += iIncomingApName->Length() + 1;
+
+    iIncomingUserName = ParseString8L( aData, offset );
+    offset += iIncomingUserName->Length() + 1;
+
+    iIncomingPassword = ParseString8L( aData, offset );
+    offset += iIncomingPassword->Length() + 1;
+
+    // Check that it's safe to read next 4 bytes
+    if ( offset + 3 >= dataLength )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    iIncomingSecurity = aData[offset];
+    offset++;
+    HTI_LOG_FORMAT( "Incoming security = %d", iIncomingSecurity );
+
+    iIncomingPort = aData[offset] + ( aData[offset+1] << 8 );
+    offset += 2;
+    HTI_LOG_FORMAT( "Incoming port = %d", iIncomingPort );
+
+    iAPopSecureLogin = (TBool) aData[offset];
+    offset++;
+    HTI_LOG_FORMAT( "A POP secure login = %d", iAPopSecureLogin );
+
+    iOutgoingServer = ParseStringL( aData, offset );
+    offset += iOutgoingServer->Length() + 1;
+
+    iOutgoingApName = ParseStringL( aData, offset );
+    offset += iOutgoingApName->Length() + 1;
+
+    iOutgoingUserName = ParseString8L( aData, offset );
+    offset += iOutgoingUserName->Length() + 1;
+
+    iOutgoingPassword = ParseString8L( aData, offset );
+    offset += iOutgoingPassword->Length() + 1;
+
+    // Check that it's safe to read next 3 bytes
+    if ( offset + 2 >= dataLength )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    iOutgoingSecurity = aData[offset];
+    offset++;
+    HTI_LOG_FORMAT( "Outgoing security = %d", iOutgoingSecurity );
+
+    iOutgoingPort = aData[offset] + ( aData[offset+1] << 8 );
+    offset += 2;
+    HTI_LOG_FORMAT( "Outgoing port = %d", iOutgoingPort );
+
+    iOwnMailAddress = ParseStringL( aData, offset );
+    offset += iOwnMailAddress->Length() + 1;
+
+    iOwnName = ParseStringL( aData, offset );
+    offset += iOwnName->Length() + 1;
+
+    // Check that it's safe to read next 2 bytes
+    if ( offset + 1 >= dataLength )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    iSendOption = aData[offset];
+    offset++;
+    HTI_LOG_FORMAT( "Send option = %d", iSendOption );
+
+    iSendCopyToOwnAddress = aData[offset];
+    offset++;
+    HTI_LOG_FORMAT( "Send copy = %d", iSendCopyToOwnAddress );
+
+    iSignatureText = ParseStringL( aData, offset, 2 );
+    offset += iSignatureText->Length() + 2;
+
+    // Check that it's safe to read next 6 bytes
+    if ( offset + 5 >= dataLength )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    iNewMailIndicators = (TBool) aData[offset];
+    offset++;
+    HTI_LOG_FORMAT( "Indicators = %d", iNewMailIndicators );
+
+    iRetrievedParts = aData[offset];
+    offset++;
+    HTI_LOG_FORMAT( "Retrieved parts = %d", iRetrievedParts );
+
+    iRetrieveSizeLimitKb = aData[offset] + ( aData[offset+1] << 8 );
+    offset += 2;
+    HTI_LOG_FORMAT( "Size limit = %d", iRetrieveSizeLimitKb );
+
+    iEmailsToRetrieve = aData[offset] + ( aData[offset+1] << 8 );
+    offset += 2;
+    HTI_LOG_FORMAT( "Emails to retrieve = %d", iEmailsToRetrieve );
+
+    iImapFolderPath = ParseString8L( aData, offset );
+    offset += iImapFolderPath->Length() + 1;
+
+    // Check that it's safe to read next 2 bytes
+    if ( offset + 1 >= dataLength )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    iAutomaticUpdate = aData[offset];
+    offset++;
+    HTI_LOG_FORMAT( "Automatic update = %d", iAutomaticUpdate );
+
+    iSetAsDefault = (TBool) aData[offset];
+    offset++;
+    HTI_LOG_FORMAT( "Set as default = %d", iSetAsDefault );
+
+    HTI_LOG_FORMAT( "Final offset= %d", offset );
+    // Check that there's no extra bytes
+    if ( offset != dataLength )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    // Validate fields - limits based on S60 3.0 mailbox settings UI
+    if ( iMailboxName->Length()      < 1   ||
+         iMailboxName->Length()      > 30  ||
+         iIncomingServer->Length()   < 3   ||    // a.b
+         iIncomingServer->Length()   > 50  ||
+         iOutgoingServer->Length()   < 3   ||    // a.b
+         iOutgoingServer->Length()   > 50  ||
+         iOwnMailAddress->Length()   < 5   ||    // a@b.c
+         iOwnMailAddress->Length()   > 100 ||
+         iIncomingUserName->Length() > 50 ||
+         iIncomingPassword->Length() > 50 ||
+         iOutgoingUserName->Length() > 50 ||
+         iOutgoingPassword->Length() > 50 ||
+         iOwnName->Length()          > 100 ||
+         iSignatureText->Length()    > 500 ||
+         iImapFolderPath->Length()   > 100 ||
+         iIncomingPort               > 999 ||
+         iOutgoingPort               > 999 ||
+         iRetrieveSizeLimitKb        > 999 ||
+         iEmailsToRetrieve           > 999 ||
+         iIncomingSecurity           > 2   ||
+         iOutgoingSecurity           > 2   ||
+         iSendOption                 > 2   ||
+         iSendCopyToOwnAddress       > 3   ||
+         iRetrievedParts             > 2   ||
+         iAutomaticUpdate            > 2      )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiMailboxHandler::ParseCreateMsgL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiMailboxHandler::ParseStringL
+// Helper for parsing one string from the message.
+// ----------------------------------------------------------------------------
+HBufC* CHtiMailboxHandler::ParseStringL( const TDesC8& aData,
+                                         TInt aStrLenOffset,
+                                         TInt aStrLenBytes )
+    {
+    HTI_LOG_FUNC_IN( "CHtiMailboxHandler::ParseStringL" );
+    if ( aStrLenOffset >= aData.Length() ||
+         aStrLenBytes > 2 || aStrLenBytes < 1 )
+        {
+        User::Leave( KErrArgument );
+        }
+    TInt strLen = 0;
+    if ( aStrLenBytes == 1 )
+        {
+        strLen = aData[aStrLenOffset];
+        }
+    else
+        {
+        strLen = aData[aStrLenOffset] + ( aData[aStrLenOffset +1 ] << 8 );
+        }
+
+    if ( aData.Length() <= aStrLenOffset + strLen )
+        {
+        User::Leave( KErrArgument );
+        }
+    HTI_LOG_FORMAT( "String length = %d", strLen );
+    HBufC* result = HBufC::NewL( strLen );
+    result->Des().Copy( aData.Mid( aStrLenOffset + aStrLenBytes, strLen ) );
+    HTI_LOG_FORMAT( "Parsed: %S", result );
+    HTI_LOG_FUNC_OUT( "CHtiMailboxHandler::ParseStringL" );
+    return result;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiMailboxHandler::ParseString8L
+// Helper for parsing one string from the message.
+// ----------------------------------------------------------------------------
+HBufC8* CHtiMailboxHandler::ParseString8L( const TDesC8& aData,
+                                           TInt aStrLenOffset,
+                                           TInt aStrLenBytes )
+    {
+    HTI_LOG_FUNC_IN( "CHtiMailboxHandler::ParseString8L" );
+    if ( aStrLenOffset >= aData.Length() ||
+         aStrLenBytes > 2 || aStrLenBytes < 1  )
+        {
+        User::Leave( KErrArgument );
+        }
+    TInt strLen = 0;
+    if ( aStrLenBytes == 1 )
+        {
+        strLen = aData[aStrLenOffset];
+        }
+    else
+        {
+        strLen = aData[aStrLenOffset] + ( aData[aStrLenOffset + 1] << 8 );
+        }
+    if ( aData.Length() <= aStrLenOffset + strLen )
+        {
+        User::Leave( KErrArgument );
+        }
+    HTI_LOG_FORMAT( "String length = %d", strLen );
+    HBufC8* result = aData.Mid( aStrLenOffset + aStrLenBytes, strLen ).AllocL();
+    HTI_LOG_FORMAT( "Parsed: %S", result );
+    HTI_LOG_FUNC_OUT( "CHtiMailboxHandler::ParseString8L" );
+    return result;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiMailboxHandler::AccessPointUIDL
+// Gets the UID of Access Point named by aApName.
+// Returns KErrNotFound if AP not found.
+// ----------------------------------------------------------------------------
+TInt CHtiMailboxHandler::AccessPointUIDL( const TDesC& aApName )
+    {
+    HTI_LOG_FUNC_IN( "CHtiMailboxHandler::AccessPointUIDL" );
+    TInt iapId = KErrNotFound;
+
+    // Search from uncategorised first
+    RArray<TUint32> array = RArray<TUint32>();
+    iCmManager.ConnectionMethodL( array );
+    CleanupClosePushL( array );
+    TInt i = 0;
+    while ( i < array.Count() && iapId == KErrNotFound )
+        {
+        RCmConnectionMethod cm = iCmManager.ConnectionMethodL( array[i] );
+        CleanupClosePushL( cm );
+        HBufC* name = cm.GetStringAttributeL( CMManager::ECmName );
+        HTI_LOG_FORMAT( "Found name: %S", name );
+        CleanupStack::PushL( name );
+        if ( aApName.Compare( *name ) == 0 )
+            {
+            iapId = cm.GetIntAttributeL( CMManager::ECmId );
+            HTI_LOG_FORMAT( "Match: UID = %d", iapId );
+            }
+        CleanupStack::PopAndDestroy(); // name
+        CleanupStack::PopAndDestroy(); // cm
+        i++;
+        }
+    CleanupStack::PopAndDestroy(); // array
+
+    // If not found from uncategorised, search from all destinations
+    if ( iapId == KErrNotFound )
+        {
+        HTI_LOG_TEXT( "Not found from uncategorised" );
+        RArray<TUint32> destIdArray = RArray<TUint32>();
+        iCmManager.AllDestinationsL( destIdArray );
+        CleanupClosePushL( destIdArray );
+        i = 0;
+        while ( i < destIdArray.Count() && iapId == KErrNotFound )
+            {
+            RCmDestination dest = iCmManager.DestinationL( destIdArray[i] );
+            CleanupClosePushL( dest );
+            TInt j = 0;
+            while ( j < dest.ConnectionMethodCount() && iapId == KErrNotFound )
+                {
+                HBufC* name = dest.ConnectionMethodL( j ).GetStringAttributeL(
+                        CMManager::ECmName );
+                CleanupStack::PushL( name );
+                HTI_LOG_FORMAT( "Found name: %S", name );
+                if ( aApName.Compare( *name ) == 0 )
+                    {
+                    iapId = dest.ConnectionMethodL( j ).GetIntAttributeL(
+                            CMManager::ECmId );
+                    HTI_LOG_FORMAT( "Match: UID = %d", iapId );
+                    }
+                CleanupStack::PopAndDestroy(); // name
+                j++;
+                }
+            CleanupStack::PopAndDestroy(); // dest
+            i++;
+            }
+        CleanupStack::PopAndDestroy(); // destIdArray
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiMailboxHandler::AccessPointUIDL" );
+    return iapId;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiMailboxHandler::FindSmtpAccount
+// Searches for an SMTP account by name.
+// Returns KErrNone if found, otherwise KErrNotFound or other error.
+// ----------------------------------------------------------------------------
+TInt CHtiMailboxHandler::FindSmtpAccount( const TDesC& aAccountName,
+                                          TSmtpAccount& aAccount )
+    {
+    HTI_LOG_FUNC_IN( "CHtiMailboxHandler::FindSmtpAccount" );
+
+    TInt err = KErrNone;
+    TInt popCount = 0;
+
+    RArray<TSmtpAccount> smtpAccounts;
+    CleanupClosePushL( smtpAccounts );
+    popCount++; // smtpAccounts
+
+    CEmailAccounts* accounts = NULL;
+    TRAP( err, accounts = CEmailAccounts::NewL() );
+
+    if ( err == KErrNone )
+        {
+        CleanupStack::PushL( accounts );
+        popCount++; // accounts
+        TRAP( err, accounts->GetSmtpAccountsL( smtpAccounts ) );
+        }
+
+    if ( err == KErrNone )
+        {
+        TInt count = smtpAccounts.Count();
+        HTI_LOG_FORMAT( "Found %d SMTP accounts", count );
+        err = KErrNotFound;
+        for ( TInt i = 0; i < count; i++ )
+            {
+            aAccount = smtpAccounts[i];
+            HTI_LOG_FORMAT( "Account name: %S", &aAccount.iSmtpAccountName );
+            if ( aAccount.iSmtpAccountName.Compare( aAccountName ) == 0 )
+                {
+                HTI_LOG_FORMAT( "Match - MSV ID %d", aAccount.iSmtpService );
+                err = KErrNone;
+                break;
+                }
+            }
+        }
+
+    CleanupStack::PopAndDestroy( popCount );
+    HTI_LOG_FUNC_OUT( "CHtiMailboxHandler::FindSmtpAccount" );
+    return err;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiMailboxHandler::GetDeviceImeiL()
+// Gets the device IMEI code and stores it to aResult.
+// ----------------------------------------------------------------------------
+//
+void CHtiMailboxHandler::GetDeviceImeiL( TDes& aResult )
+    {
+    if ( aResult.MaxLength() < KImeiLength )
+        {
+        User::Leave( KErrBadDescriptor );
+        }
+#ifdef __WINS__
+    aResult.Copy( KWinsImei );
+#else
+    RTelServer telServer;
+    User::LeaveIfError( telServer.Connect() );
+    CleanupClosePushL( telServer );
+    User::LeaveIfError( telServer.LoadPhoneModule( KTsyName ) );
+
+    TInt phoneCount = 0;
+    User::LeaveIfError( telServer.EnumeratePhones( phoneCount ) );
+    if ( phoneCount < 1 )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    RTelServer::TPhoneInfo phoneInfo;
+    User::LeaveIfError( telServer.GetPhoneInfo( 0, phoneInfo ) );
+    RMobilePhone mobilePhone;
+    User::LeaveIfError( mobilePhone.Open( telServer, phoneInfo.iName ) );
+    CleanupClosePushL( mobilePhone );
+
+    RMobilePhone::TMobilePhoneIdentityV1 identity;
+    TRequestStatus status;
+    mobilePhone.GetPhoneId( status, identity );
+    User::WaitForRequest( status );
+    User::LeaveIfError( status.Int() );
+
+    aResult.Copy( identity.iSerialNumber );
+    CleanupStack::PopAndDestroy( 2 ); // mobilePhone, telServer
+#endif
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiMailboxHandler::ResetVariables
+// Clears the instance variables that store the create message parameters.
+// ----------------------------------------------------------------------------
+void CHtiMailboxHandler::ResetVariables()
+    {
+    HTI_LOG_FUNC_IN( "CHtiMailboxHandler::ResetVariables" );
+    delete iMailboxName;
+    iMailboxName = NULL;
+    delete iIncomingServer;
+    iIncomingServer = NULL;
+    delete iIncomingApName;
+    iIncomingApName = NULL;
+    delete iIncomingUserName;
+    iIncomingUserName = NULL;
+    delete iIncomingPassword;
+    iIncomingPassword = NULL;
+    delete iOutgoingServer;
+    iOutgoingServer = NULL;
+    delete iOutgoingApName;
+    iOutgoingApName = NULL;
+    delete iOutgoingUserName;
+    iOutgoingUserName = NULL;
+    delete iOutgoingPassword;
+    iOutgoingPassword = NULL;
+    delete iOwnMailAddress;
+    iOwnMailAddress = NULL;
+    delete iOwnName;
+    iOwnName = NULL;
+    delete iSignatureText;
+    iSignatureText = NULL;
+    delete iImapFolderPath;
+    iImapFolderPath = NULL;
+
+    iMailboxType          = KErrUnknown;
+    iIncomingSecurity     = KErrUnknown;
+    iIncomingPort         = KErrUnknown;
+    iOutgoingSecurity     = KErrUnknown;
+    iOutgoingPort         = KErrUnknown;
+    iSendOption           = KErrUnknown;
+    iSendCopyToOwnAddress = KErrUnknown;
+    iRetrievedParts       = KErrUnknown;
+    iRetrieveSizeLimitKb  = KErrUnknown;
+    iEmailsToRetrieve     = KErrUnknown;
+    iAutomaticUpdate      = KErrUnknown;
+
+    iAPopSecureLogin   = EFalse;
+    iNewMailIndicators = EFalse;
+    iSetAsDefault      = EFalse;
+
+    iCmManager.Close();
+
+    HTI_LOG_FUNC_OUT( "CHtiMailboxHandler::ResetVariables" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiMailboxHandler::SendOkMsgL
+// Helper function for sending response messages.
+// ----------------------------------------------------------------------------
+void CHtiMailboxHandler::SendOkMsgL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CHtiMailboxHandler::SendOkMsgL" );
+    User::LeaveIfNull( iDispatcher );
+    HBufC8* temp = HBufC8::NewL( aData.Length() + 1 );
+    TPtr8 response = temp->Des();
+    response.Append( ( TChar ) CHtiMessagesServicePlugin::EResultOk );
+    response.Append( aData );
+    User::LeaveIfError( iDispatcher->DispatchOutgoingMessage(
+        temp, KHtiMessagesServiceUid ) );
+    HTI_LOG_FUNC_OUT( "CHtiMailboxHandler::SendOkMsgL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiMailboxHandler::SendErrorMessageL
+// Helper function for sending error response messages.
+// ----------------------------------------------------------------------------
+void CHtiMailboxHandler::SendErrorMessageL( TInt aError, const TDesC8& aDescription )
+    {
+    HTI_LOG_FUNC_IN( "CHtiMailboxHandler::SendErrorMessageL" );
+    User::LeaveIfNull( iDispatcher );
+    User::LeaveIfError( iDispatcher->DispatchOutgoingErrorMessage(
+        aError, aDescription, KHtiMessagesServiceUid ) );
+    HTI_LOG_FUNC_OUT( "CHtiMailboxHandler::SendErrorMessageL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiMailboxHandler::HandleSessionEventL
+// From MMsvSessionObserver.
+// ----------------------------------------------------------------------------
+void CHtiMailboxHandler::HandleSessionEventL( TMsvSessionEvent /*aEvent*/,
+                            TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/ )
+    {
+    // HTI_LOG_FUNC_IN( "CHtiMailboxHandler::HandleSessionEventL" );
+
+    // HTI_LOG_FUNC_OUT( "CHtiMailboxHandler::HandleSessionEventL" );
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiMessagesServicePlugin/src/HtiMessagesServicePlugin.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  MessagesServicePlugin implementation
+*
+*/
+
+
+// INCLUDE FILES
+#include "HtiMessagesServicePlugin.h"
+#include "MessageMgmntHandler.h"
+#include "HtiIAPHandler.h"
+#include "HtiMailboxHandler.h"
+#include "HtiMsgSettingsHandler.h"
+
+#include <HtiDispatcherInterface.h>
+#include <HTILogging.h>
+
+// CONSTANTS
+_LIT8( KErrorMissingCommand, "Command was not given - message was empty" );
+_LIT8( KErrorUnrecognizedCommand, "Unrecognized command" );
+
+// ----------------------------------------------------------------------------
+// Create instance of concrete ECOM interface implementation
+CHtiMessagesServicePlugin* CHtiMessagesServicePlugin::NewL()
+    {
+    CHtiMessagesServicePlugin* self = new (ELeave) CHtiMessagesServicePlugin;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+CHtiMessagesServicePlugin::CHtiMessagesServicePlugin()
+    {
+    }
+
+// ----------------------------------------------------------------------------
+CHtiMessagesServicePlugin::~CHtiMessagesServicePlugin()
+    {
+    HTI_LOG_TEXT( "CHtiMessagesServicePlugin destroy" );
+    delete iMessageHandler;
+    delete iIAPHandler;
+    delete iMailboxHandler;
+    }
+
+// ----------------------------------------------------------------------------
+void CHtiMessagesServicePlugin::ConstructL()
+    {
+    HTI_LOG_TEXT( "CHtiMessagesServicePlugin::ConstructL" );
+
+    }
+
+// ----------------------------------------------------------------------------
+void CHtiMessagesServicePlugin::ProcessMessageL( const TDesC8& aMessage,
+    THtiMessagePriority aPriority)
+    {
+    HTI_LOG_FUNC_IN( "CHtiMessagesServicePlugin::ProcessMessageL" );
+    HTI_LOG_FORMAT( "Msg len: %d.", aMessage.Length() );
+
+    if ( aMessage.Length() == 0 )
+        {
+        User::LeaveIfError( iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument, KErrorMissingCommand, KHtiMessagesServiceUid ) );
+        return;
+        }
+
+    TUint8 command = aMessage.Ptr()[0];
+
+    if ( command >= EAddSms && command <= EDeleteFolderContent )
+        {
+        if ( !iMessageHandler )
+            {
+            iMessageHandler = CMessageMgmntHandler::NewL();
+            iMessageHandler->SetDispatcher( iDispatcher );
+            }
+        iMessageHandler->ProcessMessageL( aMessage, aPriority );
+        }
+    else if ( command >= ECreateMailBox && command <= EDeleteMailBox  )
+        {
+        if ( !iMailboxHandler )
+            {
+            iMailboxHandler = CHtiMailboxHandler::NewL();
+            iMailboxHandler->SetDispatcher( iDispatcher );
+            }
+        iMailboxHandler->ProcessMessageL( aMessage, aPriority );
+        }
+    else if ( command >= ECreateIAP && command <= ESetDefaultConnection )
+        {
+        if ( !iIAPHandler )
+            {
+            iIAPHandler = CHtiIAPHandler::NewL();
+            iIAPHandler->SetDispatcher( iDispatcher );
+            }
+        iIAPHandler->ProcessMessageL( aMessage, aPriority );
+        }
+
+    else if ( command >= ESetDefaultSmsCenter && command <= ESetMmsSettings )
+        {
+        if ( !iMsgSettingsHandler )
+            {
+            iMsgSettingsHandler = CHtiMsgSettingsHandler::NewL();
+            iMsgSettingsHandler->SetDispatcher( iDispatcher );
+            }
+        iMsgSettingsHandler->ProcessMessageL( aMessage, aPriority );
+        }
+
+    else
+        {
+        User::LeaveIfError( iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument, KErrorUnrecognizedCommand, KHtiMessagesServiceUid ) );
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiMessagesServicePlugin::ProcessMessageL: Done" );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiMessagesServicePlugin/src/HtiMsgSettingsHandler.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,829 @@
+/*
+* 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:  Implementation of message settings handling.
+*
+*/
+
+
+// INCLUDE FILES
+#include "HtiMessagesServicePlugin.h"
+#include "HtiMsgSettingsHandler.h"
+
+#include <HtiDispatcherInterface.h>
+#include <HTILogging.h>
+
+#include <cmconnectionmethod.h>
+#include <cmconnectionmethoddef.h>
+#include <cmdestination.h>
+#include <cmmanager.h>
+
+#include <csmsaccount.h>
+#include <mmssettings.h>
+#include <smutset.h>
+#include <CentralRepository.h>
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES
+
+// CONSTANTS
+const TUid KCRUidSmum = { 0x101F87EF }; // from MessagingInternalCRKeys.h
+
+const TInt KMinSetDefaultSmsCenterLength = 4;
+const TInt KMinDeleteSmsCenterLength     = 2;
+const TInt KMinSetMmsSettingsLength      = 10;
+
+// set SMS settings has a fixed length
+const TInt KSetSmsSettingsLength         = 6;
+
+// message validity times in seconds
+const TInt KValidityTimeMax  = 0;
+const TInt KValidityTime1h   = 3600;
+const TInt KValidityTime6h   = 6 * 3600;
+const TInt KValidityTime24h  = 24 * 3600;
+const TInt KValidityTime3d   = 3 * 24 * 3600;
+const TInt KValidityTime1w   = 7 * 24 * 3600;
+
+// from MmsSettingsDefs.h
+const TInt KMmsUniImageSmallWidth = 640;
+const TInt KMmsUniImageSmallHeight = 480;
+const TInt KMmsUniImageLargeWidth = 1600;
+const TInt KMmsUniImageLargeHeight = 1200;
+
+const TInt KApMaxConnNameLength = 30;
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+_LIT8( KErrorInvalidParameters, "Invalid command parameters" );
+_LIT8( KErrorSetDefaultSmsCenterFailed, "Setting default SMS center failed" );
+_LIT8( KErrorDeleteSmsCenterFailed, "SMS center deletion failed" );
+_LIT8( KErrorSmsCenterAlreadyExists, "SMS center with given name already exists with different number" );
+_LIT8( KErrorSmsCenterNotFound, "SMS center with given name not found" );
+_LIT8( KErrorSetSmsSettingsFailed, "Setting SMS service settings failed" );
+_LIT8( KErrorSetMmsSettingsFailed, "Setting MMS service settings failed" );
+_LIT8( KErrorApNotFound, "Access Point not found" );
+_LIT8( KErrorUnrecognizedCommand, "Unrecognized command" );
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CHtiMsgSettingsHandler::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+CHtiMsgSettingsHandler* CHtiMsgSettingsHandler::NewL()
+    {
+    HTI_LOG_FUNC_IN( "CHtiMsgSettingsHandler::NewL" );
+    CHtiMsgSettingsHandler* self = new (ELeave) CHtiMsgSettingsHandler();
+    CleanupStack::PushL ( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    HTI_LOG_FUNC_OUT( "CHtiMsgSettingsHandler::NewL" );
+    return self;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiMsgSettingsHandler::CHtiMsgSettingsHandler
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// ----------------------------------------------------------------------------
+CHtiMsgSettingsHandler::CHtiMsgSettingsHandler()
+    {
+    HTI_LOG_FUNC_IN( "CHtiMsgSettingsHandler::CHtiMsgSettingsHandler" );
+
+    HTI_LOG_FUNC_OUT( "CHtiMsgSettingsHandler::CHtiMsgSettingsHandler" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiMsgSettingsHandler::~CHtiMsgSettingsHandler
+// Destructor.
+// -----------------------------------------------------------------------------
+CHtiMsgSettingsHandler::~CHtiMsgSettingsHandler()
+    {
+    HTI_LOG_FUNC_IN( "CHtiMsgSettingsHandler::~CHtiMsgSettingsHandler" );
+
+    HTI_LOG_FUNC_OUT( "CHtiMsgSettingsHandler::~CHtiMsgSettingsHandler" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiMsgSettingsHandler::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+void CHtiMsgSettingsHandler::ConstructL()
+    {
+    HTI_LOG_FUNC_IN( "CHtiMsgSettingsHandler::ConstructL" );
+
+    HTI_LOG_FUNC_OUT( "CHtiMsgSettingsHandler::ConstructL" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiMsgSettingsHandler::SetDispatcher
+// Sets the dispatcher pointer.
+// -----------------------------------------------------------------------------
+
+void CHtiMsgSettingsHandler::SetDispatcher( MHtiDispatcher* aDispatcher )
+    {
+    HTI_LOG_FUNC_IN( "CHtiMsgSettingsHandler::SetDispatcher" );
+    iDispatcher = aDispatcher;
+    HTI_LOG_FUNC_OUT( "CHtiMsgSettingsHandler::SetDispatcher" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiMsgSettingsHandler::ProcessMessageL
+// Parses the received message and calls handler functions.
+// -----------------------------------------------------------------------------
+void CHtiMsgSettingsHandler::ProcessMessageL( const TDesC8& aMessage,
+                                              THtiMessagePriority /*aPriority*/ )
+    {
+    HTI_LOG_FUNC_IN( "CHtiMsgSettingsHandler::ProcessMessageL" );
+
+    // Zero length message and command code validity already checked
+    // in HtiMessagesServicePlugin.
+
+    if ( aMessage[0] == CHtiMessagesServicePlugin::ESetDefaultSmsCenter )
+        {
+        if ( aMessage.Length() < 1 + KMinSetDefaultSmsCenterLength )
+            {
+            SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+            }
+        else
+            {
+            TRAPD( err, HandleSetDefaultSmsCenterL(
+                    aMessage.Right( aMessage.Length() - 1 ) ) );
+            if ( err != KErrNone )
+                {
+                SendErrorMessageL( err, KErrorSetDefaultSmsCenterFailed );
+                }
+            }
+        }
+
+    else if ( aMessage[0] == CHtiMessagesServicePlugin::EDeleteSmsCenter )
+        {
+        if ( aMessage.Length() < 1 + KMinDeleteSmsCenterLength )
+            {
+            SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+            }
+        else
+            {
+            TRAPD( err, HandleDeleteSmsCenterL(
+                    aMessage.Right( aMessage.Length() - 1 ) ) );
+            if ( err != KErrNone )
+                {
+                SendErrorMessageL( err, KErrorDeleteSmsCenterFailed );
+                }
+            }
+        }
+
+    else if ( aMessage[0] == CHtiMessagesServicePlugin::ESetSmsSettings )
+        {
+        if ( aMessage.Length() != 1 + KSetSmsSettingsLength )
+            {
+            SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+            }
+        else
+            {
+            TRAPD( err, HandleSetSmsSettingsL(
+                    aMessage.Right( aMessage.Length() - 1 ) ) );
+            if ( err != KErrNone )
+                {
+                SendErrorMessageL( err, KErrorSetSmsSettingsFailed );
+                }
+            }
+        }
+
+    else if ( aMessage[0] == CHtiMessagesServicePlugin::ESetMmsSettings )
+        {
+        if ( aMessage.Length() < 1 + KMinSetMmsSettingsLength )
+            {
+            SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+            }
+        else
+            {
+            TRAPD( err, HandleSetMmsSettingsL(
+                    aMessage.Right( aMessage.Length() - 1 ) ) );
+            if ( err != KErrNone )
+                {
+                SendErrorMessageL( err, KErrorSetMmsSettingsFailed );
+                }
+            }
+        }
+
+    else
+        {
+        SendErrorMessageL( KErrArgument, KErrorUnrecognizedCommand );
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiMsgSettingsHandler::ProcessMessageL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiMsgSettingsHandler::HandleSetDefaultSmsCenterL
+// Creates new default SMS center.
+// ----------------------------------------------------------------------------
+void CHtiMsgSettingsHandler::HandleSetDefaultSmsCenterL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CHtiMsgSettingsHandler::HandleSetDefaultSmsCenterL" );
+
+    TBuf<255> name;
+    TBuf<255> number;
+
+    TInt dataLength = aData.Length();
+    TInt offset = 0;
+    TInt fieldLength = aData[offset];
+    offset++;
+
+    if ( offset + fieldLength > dataLength )
+        {
+        HTI_LOG_TEXT( "Invalid length specified for name" );
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return;
+        }
+    name.Copy( aData.Mid( offset, fieldLength ) );
+    offset += fieldLength;
+    fieldLength = aData[offset];
+    offset++;
+
+    if ( offset + fieldLength > dataLength )
+        {
+        HTI_LOG_TEXT( "Invalid length specified for number" );
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return;
+        }
+    number.Copy( aData.Mid( offset, fieldLength ) );
+
+    HTI_LOG_FORMAT( "SMS center name: %S", &name );
+    HTI_LOG_FORMAT( "SMS center number: %S", &number );
+
+    HTI_LOG_TEXT( "Loading current settings..." );
+    CSmsSettings* smsSettings = CSmsSettings::NewLC();
+    CSmsAccount* smsAccount = CSmsAccount::NewLC();
+    smsAccount->LoadSettingsL( *smsSettings );
+
+    HTI_LOG_TEXT( "Looping through existing SMS centers..." );
+    TInt i = 0;
+    for ( i = 0; i < smsSettings->ServiceCenterCount(); i++ )
+        {
+        CSmsServiceCenter &center = smsSettings->GetServiceCenter( i );
+
+        HTI_LOG_FORMAT( "Found SMS center: %S", &( center.Name() ) );
+
+        if ( center.Name() == name && center.Address() != number )
+            {
+            HTI_LOG_TEXT( "Error, SMS center with given name already exists" );
+            SendErrorMessageL( KErrAlreadyExists, KErrorSmsCenterAlreadyExists );
+            CleanupStack::PopAndDestroy( 2 ); // smsAccount, smsSettings
+            return;
+            }
+        else if ( center.Name() == name && center.Address() == number )
+            {
+            HTI_LOG_TEXT( "The defined SMS center already exists, setting it to default" );
+            smsSettings->SetDefaultServiceCenter( i );
+            smsAccount->SaveSettingsL( *smsSettings );
+
+            CleanupStack::PopAndDestroy( 2 ); // smsAccount, smsSettings
+            SendOkMsgL( KNullDesC8 );
+
+            return;
+            }
+        }
+
+    HTI_LOG_TEXT( "Creating new default SMS center" );
+    smsSettings->AddServiceCenterL( name, number );
+    smsSettings->SetDefaultServiceCenter( i );
+    smsAccount->SaveSettingsL( *smsSettings );
+
+    CleanupStack::PopAndDestroy( 2 ); // smsAccount, smsSettings
+
+    SendOkMsgL( KNullDesC8 );
+
+    HTI_LOG_FUNC_OUT( "CHtiMsgSettingsHandler::HandleSetDefaultSmsCenterL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiMsgSettingsHandler::HandleDeleteSmsCenterL
+// Deletes the defined SMS center.
+// ----------------------------------------------------------------------------
+void CHtiMsgSettingsHandler::HandleDeleteSmsCenterL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CHtiMsgSettingsHandler::HandleDeleteSmsCenterL" );
+
+    TBuf<255> name;
+
+    TInt dataLength = aData.Length();
+    TInt offset = 0;
+    TInt fieldLength = aData[offset];
+    offset++;
+
+    if ( offset + fieldLength > dataLength )
+        {
+        HTI_LOG_TEXT( "Invalid length specified for name" );
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return;
+        }
+    name.Copy( aData.Mid( offset, fieldLength ) );
+
+    HTI_LOG_FORMAT( "SMS center name: %S", &name );
+
+    HTI_LOG_TEXT( "Loading current settings..." );
+    CSmsSettings* smsSettings = CSmsSettings::NewLC();
+    CSmsAccount* smsAccount = CSmsAccount::NewLC();
+    smsAccount->LoadSettingsL( *smsSettings );
+
+    HTI_LOG_TEXT( "Looping through existing SMS centers..." );
+    TInt i = 0;
+    for ( i = 0; i < smsSettings->ServiceCenterCount(); i++ )
+        {
+        CSmsServiceCenter &center = smsSettings->GetServiceCenter( i );
+
+        HTI_LOG_FORMAT( "Found SMS center: %S", &( center.Name() ) );
+
+        if ( center.Name() == name )
+            {
+            HTI_LOG_TEXT( "Name matches, deleting..." );
+            smsSettings->RemoveServiceCenter( i );
+            smsAccount->SaveSettingsL( *smsSettings );
+
+            CleanupStack::PopAndDestroy( 2 ); // smsAccount, smsSettings
+
+            SendOkMsgL( KNullDesC8 );
+            return;
+            }
+        }
+
+    CleanupStack::PopAndDestroy( 2 ); // smsAccount, smsSettings
+
+    SendErrorMessageL( KErrNotFound, KErrorSmsCenterNotFound );
+
+    HTI_LOG_FUNC_OUT( "CHtiMsgSettingsHandler::HandleDeleteSmsCenterL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiMsgSettingsHandler::HandleSetSmsSettingsL
+// Sets the SMS service settings.
+// ----------------------------------------------------------------------------
+void CHtiMsgSettingsHandler::HandleSetSmsSettingsL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CHtiMsgSettingsHandler::HandleSetSmsSettingsL" );
+
+    // extract values
+    TInt offset = 0;
+    TInt characterSupport = aData[offset];
+    offset++;
+    HTI_LOG_FORMAT( "Character support     = %d", characterSupport );
+
+    TBool deliveryReport = aData[offset];
+    offset++;
+    HTI_LOG_FORMAT( "Delivery report       = %d", deliveryReport );
+
+    TInt validityPeriod = aData[offset];
+    offset++;
+    HTI_LOG_FORMAT( "Validity period       = %d", validityPeriod );
+
+    TInt messageConversion = aData[offset];
+    offset++;
+    HTI_LOG_FORMAT( "Message conversion    = %d", messageConversion );
+
+    TInt preferredConnection = aData[offset];
+    offset++;
+    HTI_LOG_FORMAT( "Preferred connection  = %d", preferredConnection );
+
+    TBool replyViaSameCenter = aData[offset];
+    offset++;
+    HTI_LOG_FORMAT( "Reply via same center = %d", replyViaSameCenter );
+
+    // Validate values
+    if ( characterSupport > 1 || validityPeriod > 5 ||
+         messageConversion > 3 || preferredConnection > 1 )
+        {
+        HTI_LOG_TEXT( "Invalid values found" );
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return;
+        }
+
+    HTI_LOG_TEXT( "Loading current settings..." );
+    CSmsSettings* smsSettings = CSmsSettings::NewLC();
+    CSmsAccount* smsAccount = CSmsAccount::NewLC();
+    smsAccount->LoadSettingsL( *smsSettings );
+
+    HTI_LOG_TEXT( "Opening SMS settings Central Repository" );
+    CRepository* cenRep = CRepository::NewLC( KCRUidSmum );
+    HTI_LOG_TEXT( "Setting character support setting to SMS settings Central Repository" );
+    TUint32 KSmumCharSupport = 0x00000008; // from MessagingInternalCRKeys.h
+    switch ( characterSupport )
+        {
+        case 0:
+            cenRep->Set( KSmumCharSupport, ECharSetFull );
+            break;
+        case 1:
+            cenRep->Set( KSmumCharSupport, ECharSetReduced );
+            break;
+        default:
+            User::Leave( KErrArgument );
+            break;
+        }
+    CleanupStack::PopAndDestroy( cenRep );
+    HTI_LOG_TEXT( "SMS settings Central Repository closed" );
+
+    smsSettings->SetDeliveryReport( deliveryReport );
+
+    switch ( validityPeriod )
+        {
+        case 0:
+            smsSettings->SetValidityPeriod( TTimeIntervalMinutes( 0 ) );
+            break;
+        case 1:
+            smsSettings->SetValidityPeriod(
+                TTimeIntervalMinutes( KValidityTime1h / 60 ) );
+            break;
+        case 2:
+            smsSettings->SetValidityPeriod(
+                TTimeIntervalMinutes( KValidityTime6h / 60 ) );
+            break;
+        case 3:
+            smsSettings->SetValidityPeriod(
+                TTimeIntervalMinutes( KValidityTime24h / 60 ) );
+            break;
+        case 4:
+            smsSettings->SetValidityPeriod(
+                TTimeIntervalMinutes( KValidityTime3d / 60 ) );
+            break;
+        case 5:
+            smsSettings->SetValidityPeriod(
+                TTimeIntervalMinutes( KValidityTime1w / 60 ) );
+            break;
+        default:
+            User::Leave( KErrArgument );
+            break;
+        }
+
+    switch ( messageConversion )
+        {
+        case 0:
+            smsSettings->SetMessageConversion( ESmsConvPIDNone );
+            break;
+        case 1:
+            smsSettings->SetMessageConversion( ESmsConvFax );
+            break;
+        case 2:
+            smsSettings->SetMessageConversion( ESmsConvPaging );
+            break;
+        case 3:
+            smsSettings->SetMessageConversion( ESmsConvMail );
+            break;
+        default:
+            User::Leave( KErrArgument );
+            break;
+        }
+
+    switch ( preferredConnection )
+        {
+        case 0:
+            smsSettings->SetSmsBearer( CSmsSettings::ESmsBearerCircuitPreferred );
+            break;
+        case 1:
+            smsSettings->SetSmsBearer( CSmsSettings::ESmsBearerPacketPreferred );
+            break;
+        default:
+            User::Leave( KErrArgument );
+            break;
+        }
+
+    smsSettings->SetReplyPath( replyViaSameCenter );
+
+    HTI_LOG_TEXT( "Saving the settings" );
+    smsAccount->SaveSettingsL( *smsSettings );
+
+    CleanupStack::PopAndDestroy( 2 ); // smsAccount, smsSettings
+
+    SendOkMsgL( KNullDesC8 );
+
+    HTI_LOG_FUNC_OUT( "CHtiMsgSettingsHandler::HandleSetSmsSettingsL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiMsgSettingsHandler::HandleSetMmsSettingsL
+// Sets the MMS service settings.
+// ----------------------------------------------------------------------------
+void CHtiMsgSettingsHandler::HandleSetMmsSettingsL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CHtiMsgSettingsHandler::HandleSetMmsSettingsL" );
+    TInt offset = 0;
+
+    // Get the access point name and search UID for that AP.
+    TInt apNameLength = aData[offset];
+    offset++;
+    if ( apNameLength > KApMaxConnNameLength ||
+         aData.Length() != ( KMinSetMmsSettingsLength + apNameLength - 1 ) )
+        {
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return;
+        }
+
+    TBuf<KApMaxConnNameLength> apName;
+    apName.Copy( aData.Mid( offset, apNameLength ) );
+    offset += apNameLength;
+    HTI_LOG_FORMAT( "Searching AP with name: %S", &apName );
+    TInt apUid = GetAccessPointUIDL( apName );
+    if ( apUid == KErrNotFound )
+        {
+        SendErrorMessageL( KErrNotFound, KErrorApNotFound );
+        return;
+        }
+
+    // Extract other values
+    TMmsCreationMode creationMode = ( TMmsCreationMode ) aData[offset];
+    offset++;
+    HTI_LOG_FORMAT( "creation mode      = %d", creationMode );
+
+    TInt imageSize = aData[offset];
+    offset++;
+    HTI_LOG_FORMAT( "image size         = %d", imageSize );
+
+    TInt receptionMode = aData[offset];
+    offset++;
+    HTI_LOG_FORMAT( "reception mode     = %d", receptionMode );
+
+    TBool receiveAnonymous = aData[offset];
+    offset++;
+    HTI_LOG_FORMAT( "receive anonymous  = %d", receiveAnonymous );
+
+    TBool receiveAdvert = aData[offset];
+    offset++;
+    HTI_LOG_FORMAT( "receive adverts    = %d", receiveAdvert );
+
+    TBool requestDeliveryReport = aData[offset];
+    offset++;
+    HTI_LOG_FORMAT( "request deliv reps = %d", requestDeliveryReport );
+
+    TBool sendDeliveryReport = aData[offset];
+    offset++;
+    HTI_LOG_FORMAT( "send deliv reps    = %d", sendDeliveryReport );
+
+    TInt validityPeriod = aData[offset];
+    offset++;
+    HTI_LOG_FORMAT( "validity period    = %d", validityPeriod );
+
+    // Validate values
+    if ( creationMode > 2 || imageSize > 2 ||
+         receptionMode > 3 || validityPeriod > 5 ||
+         ( creationMode == 0 && imageSize == 2 ) )
+        {
+        HTI_LOG_TEXT( "Invalid values found" );
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return;
+        }
+
+    // Load current settings
+    CMmsSettings* mmsSettings = CMmsSettings::NewL();
+    CleanupStack::PushL( mmsSettings );
+    mmsSettings->LoadSettingsL();
+    HTI_LOG_TEXT( "Settings loaded - now updating" );
+
+    // Update the values
+    if ( mmsSettings->AccessPointCount() > 0 )
+        {
+        mmsSettings->DeleteAccessPointL( 0 );
+        }
+    mmsSettings->AddAccessPointL( apUid, 0 );
+
+    mmsSettings->SetCreationMode( creationMode );
+
+    switch ( imageSize )
+        {
+        case 0:
+            mmsSettings->SetImageWidth( KMmsUniImageSmallWidth );
+            mmsSettings->SetImageHeight( KMmsUniImageSmallHeight );
+            break;
+        case 1:
+            mmsSettings->SetImageWidth( KMmsUniImageLargeWidth );
+            mmsSettings->SetImageHeight( KMmsUniImageLargeHeight );
+            break;
+        default:
+            User::Leave( KErrArgument );
+            break;
+        }
+
+    switch ( receptionMode )
+        {
+        case 0:
+            mmsSettings->SetReceivingModeHome( EMmsReceivingAutomatic );
+            mmsSettings->SetReceivingModeForeign( EMmsReceivingAutomatic );
+            break;
+        case 1:
+            mmsSettings->SetReceivingModeHome( EMmsReceivingAutomatic );
+            mmsSettings->SetReceivingModeForeign( EMmsReceivingManual );
+            break;
+        case 2:
+            mmsSettings->SetReceivingModeHome( EMmsReceivingManual );
+            mmsSettings->SetReceivingModeForeign( EMmsReceivingManual );
+            break;
+        case 3:
+            mmsSettings->SetReceivingModeHome( EMmsReceivingReject );
+            mmsSettings->SetReceivingModeForeign( EMmsReceivingReject );
+            break;
+        default:
+            User::Leave( KErrArgument );
+            break;
+        }
+
+    mmsSettings->SetAcceptAnonymousMessages( receiveAnonymous );
+    mmsSettings->SetAcceptAdvertisementMessages( receiveAdvert );
+
+    if ( requestDeliveryReport )
+        {
+        mmsSettings->SetDeliveryReportWanted( KMmsYes );
+        }
+    else
+        {
+        mmsSettings->SetDeliveryReportWanted( KMmsNo );
+        }
+
+    if ( sendDeliveryReport )
+        {
+        mmsSettings->SetDeliveryReportSendingAllowed( KMmsYes );
+        }
+    else
+        {
+        mmsSettings->SetDeliveryReportSendingAllowed( KMmsNo );
+        }
+
+    switch ( validityPeriod )
+        {
+        case 0:
+            mmsSettings->SetExpiryInterval( KValidityTimeMax );
+            break;
+        case 1:
+            mmsSettings->SetExpiryInterval( KValidityTime1h );
+            break;
+        case 2:
+            mmsSettings->SetExpiryInterval( KValidityTime6h );
+            break;
+        case 3:
+            mmsSettings->SetExpiryInterval( KValidityTime24h );
+            break;
+        case 4:
+            mmsSettings->SetExpiryInterval( KValidityTime3d );
+            break;
+        case 5:
+            mmsSettings->SetExpiryInterval( KValidityTime1w );
+            break;
+        default:
+            User::Leave( KErrArgument );
+            break;
+        }
+
+    // Check validity of updated settings and save if valid.
+    if ( mmsSettings->ValidateSettings() != KErrNone )
+        {
+        HTI_LOG_TEXT( "Settings not valid - won't save" );
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        }
+    else
+        {
+        HTI_LOG_TEXT( "Settings valid - now saving" );
+        mmsSettings->SaveSettingsL();
+        SendOkMsgL( KNullDesC8 );
+        }
+
+    CleanupStack::PopAndDestroy(); // mmsSettings
+    HTI_LOG_FUNC_OUT( "CHtiMsgSettingsHandler::HandleSetMmsSettingsL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiMsgSettingsHandler::GetAccessPointUIDL
+// Gets the UID of Access Point named by aApName.
+// Returns KErrNotFound if AP not found.
+// ----------------------------------------------------------------------------
+TInt CHtiMsgSettingsHandler::GetAccessPointUIDL( const TDesC& aApName )
+    {
+    HTI_LOG_FUNC_IN( "CHtiMsgSettingsHandler::GetAccessPointUIDL" );
+    TInt uid = KErrNotFound;
+
+    RCmManager cmManager;
+    cmManager.OpenL();
+    CleanupClosePushL( cmManager );
+
+    // Search from uncategorised first
+    RArray<TUint32> array = RArray<TUint32>();
+    cmManager.ConnectionMethodL( array );
+    CleanupClosePushL( array );
+    TInt i = 0;
+    while ( i < array.Count() && uid == KErrNotFound )
+        {
+        RCmConnectionMethod cm = cmManager.ConnectionMethodL( array[i] );
+        CleanupClosePushL( cm );
+        HBufC* name = cm.GetStringAttributeL( CMManager::ECmName );
+        HTI_LOG_FORMAT( "Found name: %S", name );
+        CleanupStack::PushL( name );
+        if ( aApName.Compare( *name ) == 0 )
+            {
+            uid = cm.GetIntAttributeL( CMManager::ECmWapId );
+            HTI_LOG_FORMAT( "Match: UID = %d", uid );
+            }
+        CleanupStack::PopAndDestroy(); // name
+        CleanupStack::PopAndDestroy(); // cm
+        i++;
+        }
+    CleanupStack::PopAndDestroy(); // array
+
+    // If not found from uncategorised, search from all destinations
+    if ( uid == KErrNotFound )
+        {
+        HTI_LOG_TEXT( "Not found from uncategorised" );
+        RArray<TUint32> destIdArray = RArray<TUint32>();
+        cmManager.AllDestinationsL( destIdArray );
+        CleanupClosePushL( destIdArray );
+        i = 0;
+        while ( i < destIdArray.Count() && uid == KErrNotFound )
+            {
+            RCmDestination dest = cmManager.DestinationL( destIdArray[i] );
+            CleanupClosePushL( dest );
+            TInt j = 0;
+            while ( j < dest.ConnectionMethodCount() && uid == KErrNotFound )
+                {
+                HBufC* name = dest.ConnectionMethodL( j ).GetStringAttributeL(
+                        CMManager::ECmName );
+                CleanupStack::PushL( name );
+                HTI_LOG_FORMAT( "Found name: %S", name );
+                if ( aApName.Compare( *name ) == 0 )
+                    {
+                    uid = dest.ConnectionMethodL( j ).GetIntAttributeL(
+                            CMManager::ECmWapId );
+                    HTI_LOG_FORMAT( "Match: UID = %d", uid );
+                    }
+                CleanupStack::PopAndDestroy(); // name
+                j++;
+                }
+            CleanupStack::PopAndDestroy(); // dest
+            i++;
+            }
+        CleanupStack::PopAndDestroy(); // destIdArray
+        }
+
+    CleanupStack::PopAndDestroy(); // cmManager
+
+    HTI_LOG_FUNC_OUT( "CHtiMsgSettingsHandler::GetAccessPointUIDL" );
+    return uid;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiMsgSettingsHandler::SendOkMsgL
+// Helper function for sending response messages.
+// ----------------------------------------------------------------------------
+void CHtiMsgSettingsHandler::SendOkMsgL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CHtiMsgSettingsHandler::SendOkMsgL" );
+    User::LeaveIfNull( iDispatcher );
+    HBufC8* temp = HBufC8::NewL( aData.Length() + 1 );
+    TPtr8 response = temp->Des();
+    response.Append( ( TChar ) CHtiMessagesServicePlugin::EResultOk );
+    response.Append( aData );
+    User::LeaveIfError( iDispatcher->DispatchOutgoingMessage(
+        temp, KHtiMessagesServiceUid ) );
+    HTI_LOG_FUNC_OUT( "CHtiMsgSettingsHandler::SendOkMsgL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiMsgSettingsHandler::SendErrorMessageL
+// Helper function for sending error response messages.
+// ----------------------------------------------------------------------------
+void CHtiMsgSettingsHandler::SendErrorMessageL( TInt aError, const TDesC8& aDescription )
+    {
+    HTI_LOG_FUNC_IN( "CHtiMsgSettingsHandler::SendErrorMessageL" );
+    User::LeaveIfNull( iDispatcher );
+    User::LeaveIfError( iDispatcher->DispatchOutgoingErrorMessage(
+        aError, aDescription, KHtiMessagesServiceUid ) );
+    HTI_LOG_FUNC_OUT( "CHtiMsgSettingsHandler::SendErrorMessageL" );
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiMessagesServicePlugin/src/MessageMgmntHandler.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,1879 @@
+/*
+* 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:  Functional implementation of HtiMessagesServicePlugin service
+*
+*/
+
+
+// INCLUDE FILES
+#include "HtiMessagesServicePlugin.h"
+#include "MessageMgmntHandler.h"
+
+#include <HtiDispatcherInterface.h>
+#include <HTILogging.h>
+#include <mtclreg.h>
+#include <smscmds.h>
+#include <smtcmtm.h>
+#include <smuthdr.h>
+#include <smsclnt.h>
+#include <utf.h>
+#include <mmsclient.h>
+#include <mmsconst.h>
+#include <miutset.h>
+#include <irmsgtypeuid.h>
+#include <btmsgtypeuid.h>
+#include <biouids.h>
+#include <apgcli.h>
+#include <apmstd.h>
+#include <bautils.h>
+#include <obexclientmtm.h>
+#include <cmsvmimeheaders.h>
+#include <mmsvattachmentmanager.h>
+
+// CONSTANTS
+_LIT8( KErrorMissingCommand,        "Command was not given - message was empty" );
+_LIT8( KErrorUnrecognizedCommand,   "Unrecognized command" );
+_LIT8( KErrorInvalidParameters,     "Invalid command parameters");
+_LIT8( KErrorTooLongSmsBody,        "Too long SMS body" );
+_LIT8( KErrorInvalidId,             "Invalid SMS id parameter" );
+_LIT8( KErrorInvalidFolder,         "Invalid folder parameter" );
+_LIT8( KErrorItemNotFound,          "Item not found" );
+_LIT8( KErrorFailedDelete,          "Failed to delete item" );
+_LIT8( KErrorNotSupported,          "Not supported" );
+_LIT8( KErrorSmsSettingNotDefined,  "SMS settings not defined" );
+_LIT8( KErrorMmsSettingNotDefined,  "MMS settings not defined" );
+_LIT8( KErrorMailboxNotDefined,     "Mailbox not defined" );
+_LIT8( KErrorMsgTypeNotFound,       "Message type module not found" );
+_LIT8( KErrorMsgStoreOpenFailed,    "Could not open message store" );
+_LIT8( KErrorRfsConnectFailed,      "Could not connect to file server session" );
+_LIT8( KErrorAttachmentNotFound,    "Attachment not found" );
+_LIT8( KErrorInvalidFolderForSmartMsg, "Only inbox allowed for smart messages" );
+
+const static TInt KAddSmsCmdMinLength        = 7;
+const static TInt KAddMmsOrEmailCmdMinLength = 8;
+const static TInt KAddObexMsgCmdMinLength    = 6;
+const static TInt KAddSmartMsgCmdMinLength   = 11;
+const static TInt KAddAudioCmdMinLength      = 10;
+
+// ----------------------------------------------------------------------------
+CMessageMgmntHandler* CMessageMgmntHandler::NewL()
+    {
+    HTI_LOG_FUNC_IN( "CMessageMgmntHandler::NewL" );
+    CMessageMgmntHandler* self = new (ELeave) CMessageMgmntHandler();
+    CleanupStack::PushL ( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    HTI_LOG_FUNC_OUT( "CMessageMgmntHandler::NewL: Done" );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+CMessageMgmntHandler::CMessageMgmntHandler()
+    {
+    }
+
+// ----------------------------------------------------------------------------
+CMessageMgmntHandler::~CMessageMgmntHandler()
+    {
+    delete iMtmReg;
+    delete iSession;
+    }
+
+// ----------------------------------------------------------------------------
+void CMessageMgmntHandler::ConstructL()
+    {
+    HTI_LOG_FUNC_IN( "CMessageMgmntHandler::ConstructL" );
+    iSession = CMsvSession::OpenSyncL( *this );
+    iMtmReg = CClientMtmRegistry::NewL( *iSession );
+    HTI_LOG_FUNC_OUT( "CMessageMgmntHandler::ConstructL: Done" );
+    }
+
+// ----------------------------------------------------------------------------
+void CMessageMgmntHandler::SetDispatcher( MHtiDispatcher* aDispatcher )
+    {
+    iDispatcher = aDispatcher;
+    }
+
+// ----------------------------------------------------------------------------
+void CMessageMgmntHandler::ProcessMessageL( const TDesC8& aMessage,
+                                            THtiMessagePriority /*aPriority*/ )
+    {
+    HTI_LOG_FUNC_IN( "CMessageMgmntHandler::ProcessMessageL" );
+    HTI_LOG_FORMAT( "Msg length: %d", aMessage.Length() );
+
+    if ( aMessage.Length() == 0 )
+        {
+        SendErrorMessageL( KErrArgument, KErrorMissingCommand );
+        return;
+        }
+
+    switch ( aMessage[0] )
+        {
+        case CHtiMessagesServicePlugin::EAddSms:
+            HTI_LOG_TEXT( "Add SMS" );
+            HandleCreateSmsL( aMessage.Right( aMessage.Length() - 1 ) );
+            break;
+
+        case CHtiMessagesServicePlugin::EAddMms:
+        case CHtiMessagesServicePlugin::EAddAudioMsg: // special MMS sub type
+            HTI_LOG_TEXT( "Add MMS" );
+            HandleCreateMmsL( aMessage );
+            break;
+
+        case CHtiMessagesServicePlugin::EAddEmail:
+            HTI_LOG_TEXT( "Add Email" );
+            HandleCreateEmailL( aMessage );
+            break;
+
+        case CHtiMessagesServicePlugin::EAddIrMsg:
+            HTI_LOG_TEXT( "Add IR msg" );
+            HandleCreateObexMsgL( aMessage.Right( aMessage.Length() - 1 ),
+                                  TUid::Uid( KUidMsgTypeIrTInt32 ),
+                                  KUidMsgTypeIrUID );
+            break;
+
+        case CHtiMessagesServicePlugin::EAddBtMsg:
+            HTI_LOG_TEXT( "Add BT msg" );
+            HandleCreateObexMsgL( aMessage.Right( aMessage.Length() - 1 ),
+                                  TUid::Uid( KUidMsgTypeBtTInt32 ),
+                                  KUidMsgTypeBt );
+            break;
+
+        case CHtiMessagesServicePlugin::EAddSmartMsg:
+            HTI_LOG_TEXT( "Add smart msg" );
+            HandleCreateSmartMsgL( aMessage.Right( aMessage.Length() - 1 ) );
+            break;
+
+        case CHtiMessagesServicePlugin::EDeleteMessage:
+            HTI_LOG_TEXT( "Delete message" );
+            HandleDeleteMessageL( aMessage.Right( aMessage.Length() - 1 ) );
+            break;
+
+        case CHtiMessagesServicePlugin::EDeleteFolderContent:
+            HTI_LOG_TEXT( "Delete messages" );
+            HandleDeleteMessagesL( aMessage.Right( aMessage.Length() - 1 ) );
+            break;
+
+        default:
+            HTI_LOG_TEXT( "Unknown command" );
+            SendErrorMessageL( KErrUnknown, KErrorUnrecognizedCommand );
+            break;
+        }
+
+    HTI_LOG_FUNC_OUT( "CMessageMgmntHandler::ProcessMessageL: Done" );
+    }
+
+// ----------------------------------------------------------------------------
+void CMessageMgmntHandler::HandleCreateSmsL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CMessageMgmntHandler::HandleSmsImportFuncL" );
+
+    if ( ValidateAddSmsCommand( aData ) )
+        {
+        TInt position( 0 );
+        HBufC16* fromTo = ExtractDesLC( aData, position, 1 );
+        HBufC16* description = ExtractDesLC( aData, position, 1 );
+        HBufC16* body = ExtractDesLC( aData, position, 2 );
+        TBool isNew = (TBool)aData[position];
+        TBool isUnread = (TBool)aData[position+1];
+        TFolder folder = (TFolder)aData[position+2];
+
+        CSmsClientMtm* smsMtm = NULL;
+        TRAPD( err, smsMtm = ( CSmsClientMtm* )iMtmReg->NewMtmL(
+                KUidMsgTypeSMS ) );
+        if ( err || !smsMtm )
+            {
+            HTI_LOG_TEXT( "SMS message type module not found" );
+            SendErrorMessageL( KErrNotFound, KErrorMsgTypeNotFound );
+            CleanupStack::PopAndDestroy( body );
+            CleanupStack::PopAndDestroy( description );
+            CleanupStack::PopAndDestroy( fromTo );
+            return;
+            }
+        CleanupStack::PushL( smsMtm );
+
+        CMsvEntry* entry = CMsvEntry::NewL( *iSession,
+                                            KMsvGlobalInBoxIndexEntryId,
+                                            TMsvSelectionOrdering() );
+        CleanupStack::PushL( entry );
+
+        // get the default service
+        TMsvId defaultServiceId = 0;
+        TRAP( err, defaultServiceId = smsMtm->DefaultServiceL() );
+        if ( err )
+            {
+            HTI_LOG_FORMAT( "Could not get default service, err: %d", err );
+            SendErrorMessageL( err, KErrorSmsSettingNotDefined );
+            CleanupStack::PopAndDestroy( entry );
+            CleanupStack::PopAndDestroy( smsMtm );
+            CleanupStack::PopAndDestroy( body );
+            CleanupStack::PopAndDestroy( description );
+            CleanupStack::PopAndDestroy( fromTo );
+            return;
+            }
+
+        // map the folder parameter to folder id
+        TMsvId folderId = KMsvGlobalInBoxIndexEntryId;
+        TRAP( err, folderId = MapFolderToIdL( folder ) );
+        if ( err )
+            {
+            HTI_LOG_FORMAT( "Invalid folder: %d", folder );
+            SendErrorMessageL( err, KErrorInvalidFolder );
+            CleanupStack::PopAndDestroy( entry );
+            CleanupStack::PopAndDestroy( smsMtm );
+            CleanupStack::PopAndDestroy( body );
+            CleanupStack::PopAndDestroy( description );
+            CleanupStack::PopAndDestroy( fromTo );
+            return;
+            }
+        entry->SetEntryL( folderId );
+
+        // mtm takes ownership of entry context
+        smsMtm->SetCurrentEntryL( entry );
+        CleanupStack::Pop( entry );
+
+        // create a new message
+        smsMtm->CreateMessageL( defaultServiceId );
+
+        if ( folder == EInbox )
+            {
+            CSmsHeader* smsHeader = &( smsMtm->SmsHeader() );
+            delete smsHeader;
+            smsHeader = NULL;
+            smsHeader = CSmsHeader::NewL( CSmsPDU::ESmsDeliver, smsMtm->Body() );
+            smsHeader->SetFromAddressL( fromTo->Des() );
+            }
+        else
+            {
+            smsMtm->AddAddresseeL( fromTo->Des() );
+
+            // set delivery settings
+            CSmsSettings* sendOptions = CSmsSettings::NewL();
+            CleanupStack::PushL( sendOptions );
+            sendOptions->CopyL( smsMtm->ServiceSettings() );
+            sendOptions->SetDelivery( ESmsDeliveryImmediately );
+
+            CSmsHeader* smsHeader = &( smsMtm->SmsHeader() );
+            smsHeader->SetSmsSettingsL( *sendOptions );
+            CleanupStack::PopAndDestroy( sendOptions );
+            }
+
+
+
+        // set body
+        smsMtm->Body().Reset();
+        smsMtm->Body().InsertL( 0, *body );
+
+        // save the message
+        smsMtm->SaveMessageL();
+
+        // get the entry of the message
+        TMsvEntry tentry = smsMtm->Entry().Entry();
+
+        // set the details field
+        tentry.iDetails.Set( fromTo->Des() );
+
+        // set the description field if it is given.
+        // (with no description the beginning of the message body
+        //  is used as a description)
+        if ( description->Length() > 0 )
+            {
+            tentry.iDescription.Set( description->Des() );
+            }
+
+        // final fine tuning
+        tentry.SetAttachment( EFalse );
+        tentry.iDate.UniversalTime();
+        tentry.SetVisible( ETrue );
+        tentry.SetInPreparation( EFalse );
+        tentry.SetUnread( isUnread );
+        tentry.SetNew( isNew );
+        tentry.SetComplete( ETrue );
+        tentry.SetSendingState( KMsvSendStateWaiting );
+        tentry.iServiceId = defaultServiceId;
+        tentry.iRelatedId = 0;
+        if ( folder == EInbox )
+            {
+            tentry.SetReadOnly( ETrue );
+            }
+
+        smsMtm->Entry().ChangeL( tentry );
+
+        // send the message, if it is in outbox
+        if ( folder == EOutbox )
+            {
+            CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
+            CleanupStack::PushL( selection );
+            selection->AppendL( tentry.Id() );
+
+            TBuf8<1> dummyParameter;
+            CMsvOperationWait* waiter = CMsvOperationWait::NewLC();
+            CMsvOperation* op = smsMtm->InvokeAsyncFunctionL(
+                    ESmsMtmCommandScheduleCopy, *selection,
+                    dummyParameter, waiter->iStatus );
+            CleanupStack::PushL( op );
+            waiter->Start();
+            CActiveScheduler::Start();
+            CleanupStack::PopAndDestroy( op );
+            CleanupStack::PopAndDestroy( waiter );
+            CleanupStack::PopAndDestroy( selection );
+            }
+
+        CleanupStack::PopAndDestroy( smsMtm );
+        CleanupStack::PopAndDestroy( body );
+        CleanupStack::PopAndDestroy( description );
+        CleanupStack::PopAndDestroy( fromTo );
+
+        TInt32 id = tentry.Id();
+        TBuf8<8> idStr;
+        idStr.Copy( ( TUint8* )( &id ), sizeof( id ) );
+        SendOkMsgL( idStr );
+        }
+
+    HTI_LOG_FUNC_OUT("CMessageMgmntHandler::HandleSmsImportFuncL: Done");
+    }
+
+// ----------------------------------------------------------------------------
+void CMessageMgmntHandler::HandleCreateMmsL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CMessageMgmntHandler::HandleCreateMmsL" );
+
+    if ( !ValidateAddMmsOrAddEmailCommand( aData ) )
+        {
+        // Error message has been sent from validation method.
+        return;
+        }
+
+    // parse the parameters
+    TInt position( 0 );
+    TInt cmdCode = aData[position];
+    position++;
+    HBufC16* fromTo = ExtractDesLC( aData, position, 1 );
+    HBufC16* description = ExtractDesLC( aData, position, 1 );
+    HBufC8* body = NULL;
+    if ( cmdCode == CHtiMessagesServicePlugin::EAddMms )
+        {
+        body = ExtractDes8LC( aData, position, 2 );
+        }
+    else // Audio msg does not have body text
+        {
+        body = HBufC8::NewLC( 0 );
+        }
+    HBufC16* attPath = ExtractDesLC( aData, position, 1 );
+    TBool isNew = (TBool)aData[position];
+    TBool isUnread = (TBool)aData[position+1];
+    TFolder folder = (TFolder)aData[position+2];
+
+    HTI_LOG_TEXT( "Creating MMS Client MTM" );
+    CMmsClientMtm* mmsMtm = NULL;
+    TRAPD( err , mmsMtm = ( CMmsClientMtm* )iMtmReg->NewMtmL(
+            KUidMsgTypeMultimedia ) );
+    if ( err || !mmsMtm )
+        {
+        HTI_LOG_TEXT( "MMS message type module not found" );
+        SendErrorMessageL( KErrNotFound, KErrorMsgTypeNotFound );
+        CleanupStack::PopAndDestroy( attPath );
+        CleanupStack::PopAndDestroy( body );
+        CleanupStack::PopAndDestroy( description );
+        CleanupStack::PopAndDestroy( fromTo );
+        return;
+        }
+    CleanupStack::PushL( mmsMtm );
+
+    HTI_LOG_TEXT( "Creating MMS Client MTM" );
+    CMsvEntry* entry = CMsvEntry::NewL( *iSession,
+                                        KMsvGlobalInBoxIndexEntryId,
+                                        TMsvSelectionOrdering() );
+    CleanupStack::PushL( entry );
+
+    // get the default service
+    TMsvId defaultServiceId = 0;
+    TRAP( err, defaultServiceId = mmsMtm->DefaultServiceL() );
+    if ( err )
+        {
+        HTI_LOG_FORMAT( "Could not get default service, err: %d", err );
+        SendErrorMessageL( err, KErrorMmsSettingNotDefined );
+        CleanupStack::PopAndDestroy( entry );
+        CleanupStack::PopAndDestroy( mmsMtm );
+        CleanupStack::PopAndDestroy( attPath );
+        CleanupStack::PopAndDestroy( body );
+        CleanupStack::PopAndDestroy( description );
+        CleanupStack::PopAndDestroy( fromTo );
+        return;
+        }
+
+    // map the folder parameter to folder id
+    TMsvId folderId = KMsvGlobalInBoxIndexEntryId;
+    TRAP( err, folderId = MapFolderToIdL( folder ) );
+    if ( err )
+        {
+        HTI_LOG_FORMAT( "Invalid folder: %d", folder );
+        SendErrorMessageL( err, KErrorInvalidFolder );
+        CleanupStack::PopAndDestroy( entry );
+        CleanupStack::PopAndDestroy( mmsMtm );
+        CleanupStack::PopAndDestroy( attPath );
+        CleanupStack::PopAndDestroy( body );
+        CleanupStack::PopAndDestroy( description );
+        CleanupStack::PopAndDestroy( fromTo );
+        return;
+        }
+    entry->SetEntryL( folderId );
+
+    // mtm takes ownership of entry context
+    mmsMtm->SetCurrentEntryL( entry );
+    CleanupStack::Pop( entry );
+
+    HTI_LOG_TEXT( "Creating MMS..." );
+    mmsMtm->CreateMessageL( defaultServiceId );
+    mmsMtm->SetMessageClass( EMmsClassPersonal );
+    mmsMtm->SetExpiryInterval( 86400 );
+    mmsMtm->SetDeliveryTimeInterval( 0 );
+    mmsMtm->SetMessagePriority( EMmsPriorityNormal );
+    mmsMtm->SetSenderVisibility( EMmsMaximumSenderVisibility );
+    mmsMtm->SetDeliveryReport( EMmsDeliveryReportNo );
+    mmsMtm->SetReadReply( EMmsReadReplyYes );
+
+    if ( description->Length() > 0 )
+        {
+        mmsMtm->SetSubjectL( description->Des() );
+        }
+
+    if ( folder == EInbox )
+        {
+        mmsMtm->SetSenderL( fromTo->Des() );
+        }
+    else
+        {
+        mmsMtm->AddAddresseeL( fromTo->Des() );
+        }
+
+    // get an access to the message store
+    HTI_LOG_TEXT( "Getting message store..." );
+    CMsvStore* store = NULL;
+    TRAP( err, store = entry->EditStoreL() );
+    if ( err )
+        {
+        HTI_LOG_FORMAT( "Could not get access to message store, err: %d", err );
+        SendErrorMessageL( err, KErrorMsgStoreOpenFailed );
+        CleanupStack::PopAndDestroy( mmsMtm );
+        CleanupStack::PopAndDestroy( attPath );
+        CleanupStack::PopAndDestroy( body );
+        CleanupStack::PopAndDestroy( description );
+        CleanupStack::PopAndDestroy( fromTo );
+        return;
+        }
+    CleanupStack::PushL( store );
+
+    MMsvAttachmentManager& attachMan = store->AttachmentManagerL();
+    // set body attachment only for normal MMS - audio message doesn't have body
+    if ( cmdCode == CHtiMessagesServicePlugin::EAddMms )
+        {
+        // Set the message body as attachment
+        // Use UTF-8 as charset because MMS created with MMS editor seems to
+        // save text attachments also as UTF-8.
+        HTI_LOG_TEXT( "Setting body..." );
+        CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL();
+        CleanupStack::PushL( mimeHeaders );
+        mimeHeaders->SetContentTypeL( _L8( "text" ) );
+        mimeHeaders->SetContentSubTypeL( _L8( "plain" ) );
+        mimeHeaders->SetMimeCharset( KMmsUtf8 );
+        mimeHeaders->SetSuggestedFilenameL( _L( "body.txt" ) );
+
+        // ownership of bodyAttachment will be transferred
+        CMsvAttachment* bodyAttachment = CMsvAttachment::NewL(
+                CMsvAttachment::EMsvFile );
+        CleanupStack::PushL( bodyAttachment );
+        bodyAttachment->SetAttachmentNameL( _L( "body.txt" ) );
+        bodyAttachment->SetMimeTypeL( _L8( "text/plain" ) );
+        mimeHeaders->StoreL( *bodyAttachment );
+
+        RFile textFile;
+        CleanupClosePushL( textFile );
+        CWaiter* waiter = CWaiter::NewLC();
+        attachMan.CreateAttachmentL( _L( "body.txt" ), textFile,
+                bodyAttachment, waiter->iStatus );
+        waiter->StartAndWait();
+        CleanupStack::PopAndDestroy( waiter );
+
+        // write the UTF-8 body data to attachment file
+        textFile.Write( *body );
+        CleanupStack::PopAndDestroy(); // textFile
+        CleanupStack::Pop( bodyAttachment ); // ownership transfered
+        CleanupStack::PopAndDestroy( mimeHeaders );
+        }
+
+    // get the entry of the message
+    TMsvEntry tentry = mmsMtm->Entry().Entry();
+
+    // set the details field
+    tentry.iDetails.Set( *fromTo );
+
+    // set the description field
+    if ( description->Length() > 0 )
+        {
+        tentry.iDescription.Set( description->Left( KMmsMaxDescription ) );
+        }
+    else
+        {
+        TBuf<KMmsMaxDescription> descr;
+        CnvUtfConverter::ConvertToUnicodeFromUtf8( descr, *body );
+        tentry.iDescription.Set( descr );
+        }
+
+    // if this is audio message, set the bio type uid
+    if ( cmdCode == CHtiMessagesServicePlugin::EAddAudioMsg )
+        {
+        tentry.iBioType = KUidMsgSubTypeMmsAudioMsg.iUid;
+        }
+
+    // handle attachment
+    TBool attachmentsExist = EFalse;
+    if ( attPath->Length() > 0 )
+        {
+        HTI_LOG_TEXT( "Handling attachment..." );
+        // check that attachment exists
+        RFs fsSession;
+        if ( fsSession.Connect() != KErrNone )
+            {
+            HTI_LOG_FORMAT( "Error in connecting to file server session: %d", err );
+            SendErrorMessageL( KErrCouldNotConnect, KErrorRfsConnectFailed );
+            CleanupStack::PopAndDestroy( store );
+            CleanupStack::PopAndDestroy( mmsMtm );
+            CleanupStack::PopAndDestroy( attPath );
+            CleanupStack::PopAndDestroy( body );
+            CleanupStack::PopAndDestroy( description );
+            CleanupStack::PopAndDestroy( fromTo );
+            return;
+            }
+
+        TBool fileExists = BaflUtils::FileExists( fsSession, attPath->Des() );
+        fsSession.Close();
+        if ( !fileExists )
+            {
+            HTI_LOG_TEXT( "Attachment file not found" );
+            SendErrorMessageL( KErrPathNotFound, KErrorAttachmentNotFound );
+            store->RevertL();
+            CleanupStack::PopAndDestroy( store );
+            CleanupStack::PopAndDestroy( mmsMtm );
+            CleanupStack::PopAndDestroy( attPath );
+            CleanupStack::PopAndDestroy( body );
+            CleanupStack::PopAndDestroy( description );
+            CleanupStack::PopAndDestroy( fromTo );
+            return;
+            }
+        else
+            {
+            // save the attachment
+            TParse parser;
+            parser.Set( *attPath, NULL, NULL);
+            TFileName shortFileName = parser.NameAndExt();
+
+            // get the mime type
+            RApaLsSession ls;
+            User::LeaveIfError( ls.Connect() );
+            CleanupClosePushL( ls );
+            TUid appUid;
+            TDataType dataType;
+            ls.AppForDocument( *attPath, appUid, dataType );
+            CleanupStack::PopAndDestroy(); // ls
+            TPtrC8 mimeType = dataType.Des8();
+
+            // attachment settings
+            // ownership of attachment will be transferred
+            CMsvAttachment* attachment = CMsvAttachment::NewL(
+                    CMsvAttachment::EMsvFile );
+            attachment->SetAttachmentNameL( shortFileName );
+            attachment->SetMimeTypeL( mimeType );
+
+            // save
+            CWaiter* waiter = CWaiter::NewLC();
+            attachMan.AddAttachmentL( *attPath, attachment, waiter->iStatus );
+            waiter->StartAndWait();
+            CleanupStack::PopAndDestroy( waiter );
+            attachmentsExist = ETrue;
+            }
+        }
+
+    // save the changes made to the message store
+    store->CommitL();
+    CleanupStack::PopAndDestroy( store );
+
+    // save the message
+    mmsMtm->SaveMessageL();
+
+    // final fine tuning
+    tentry.SetAttachment( attachmentsExist );
+    tentry.iDate.UniversalTime();
+    tentry.SetVisible( ETrue );
+    tentry.SetInPreparation( EFalse );
+    if ( folder == EDrafts )
+        {
+        tentry.SetReadOnly( EFalse );
+        }
+    else
+        {
+        tentry.SetReadOnly( ETrue );
+        }
+    tentry.SetUnread( isUnread );
+    tentry.SetNew( isNew );
+    tentry.SetComplete( ETrue );
+    tentry.SetSendingState( KMsvSendStateWaiting );
+    tentry.iServiceId = defaultServiceId;
+    tentry.iRelatedId = 0;
+    tentry.iMtmData1 = KMmsMessageMRetrieveConf | KMmsMessageMobileTerminated;
+
+    mmsMtm->Entry().ChangeL( tentry );
+
+    HTI_LOG_TEXT( "MMS created and ready" );
+
+    // send the message, if it is in outbox
+    if ( folder == EOutbox )
+        {
+        HTI_LOG_TEXT( "MMS is in Outbox, sending it..." );
+
+        CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
+        CleanupStack::PushL( selection );
+        selection->AppendL( tentry.Id() );
+
+        CMsvOperationWait* waiter = CMsvOperationWait::NewLC();
+        CMsvOperation* op = mmsMtm->SendL( *selection,
+                                           waiter->iStatus,
+                                           tentry.iDate );
+        CleanupStack::PushL( op );
+        waiter->Start();
+        CActiveScheduler::Start();
+        CleanupStack::PopAndDestroy( op );
+        CleanupStack::PopAndDestroy( waiter );
+        CleanupStack::PopAndDestroy( selection );
+        }
+
+    HTI_LOG_TEXT( "Cleaning up" );
+    CleanupStack::PopAndDestroy( mmsMtm );
+    CleanupStack::PopAndDestroy( attPath );
+    CleanupStack::PopAndDestroy( body );
+    CleanupStack::PopAndDestroy( description );
+    CleanupStack::PopAndDestroy( fromTo );
+
+    // send the message id back
+    TInt32 id = tentry.Id();
+    TBuf8<8> idStr;
+    idStr.Copy( ( TUint8* )( &id ), sizeof( id ) );
+    SendOkMsgL( idStr );
+
+    HTI_LOG_FUNC_OUT("CMessageMgmntHandler::HandleCreateMmsL: Done");
+    }
+
+
+// ----------------------------------------------------------------------------
+void CMessageMgmntHandler::HandleCreateEmailL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CMessageMgmntHandler::HandleCreateEmailL" );
+
+    if ( ValidateAddMmsOrAddEmailCommand( aData ) )
+        {
+        // parse the parameters
+        TInt position( 1 ); // position 0 is command code
+        HBufC16* fromTo = ExtractDesLC( aData, position, 1 );
+        HBufC16* description = ExtractDesLC( aData, position, 1 );
+        HBufC16* body = ExtractDesLC( aData, position, 2 );
+        HBufC16* attPath = ExtractDesLC( aData, position, 1 );
+        TBool isNew = (TBool)aData[position];
+        TBool isUnread = (TBool)aData[position+1];
+        TFolder folder = (TFolder)aData[position+2];
+
+        HTI_LOG_TEXT( "Creating SMTP Client MTM" );
+        CSmtpClientMtm* smtpMtm = NULL;
+        TRAPD( err, smtpMtm = ( CSmtpClientMtm* )iMtmReg->NewMtmL(
+                KUidMsgTypeSMTP ) );
+        if ( err || !smtpMtm )
+            {
+            HTI_LOG_TEXT( "SMTP message type module not found" );
+            SendErrorMessageL( KErrNotFound, KErrorMsgTypeNotFound );
+            CleanupStack::PopAndDestroy( attPath );
+            CleanupStack::PopAndDestroy( body );
+            CleanupStack::PopAndDestroy( description );
+            CleanupStack::PopAndDestroy( fromTo );
+            return;
+            }
+        CleanupStack::PushL( smtpMtm );
+
+        HTI_LOG_TEXT( "Creating a new CMsvEntry" );
+        CMsvEntry* entry = CMsvEntry::NewL( *iSession,
+                                            KMsvGlobalInBoxIndexEntryId,
+                                            TMsvSelectionOrdering() );
+        CleanupStack::PushL( entry );
+
+        // get the default service
+        HTI_LOG_TEXT( "Getting the default service" );
+        TMsvId defaultServiceId = 0;
+        TRAP( err, defaultServiceId = smtpMtm->DefaultServiceL() );
+        if ( err )
+            {
+            HTI_LOG_FORMAT( "Could not get default service, err: %d", err );
+            SendErrorMessageL( err, KErrorMailboxNotDefined );
+            CleanupStack::PopAndDestroy( entry );
+            CleanupStack::PopAndDestroy( smtpMtm );
+            CleanupStack::PopAndDestroy( attPath );
+            CleanupStack::PopAndDestroy( body );
+            CleanupStack::PopAndDestroy( description );
+            CleanupStack::PopAndDestroy( fromTo );
+            return;
+            }
+
+        // map the folder parameter to folder id
+        HTI_LOG_TEXT( "Mapping the folder parameter to folder id" );
+        TMsvId folderId = KMsvGlobalInBoxIndexEntryId;
+        TRAP( err, folderId = MapFolderToIdL( folder ) );
+        if ( err )
+            {
+            HTI_LOG_FORMAT( "Invalid folder: %d", folder );
+            SendErrorMessageL( err, KErrorInvalidFolder );
+            CleanupStack::PopAndDestroy( entry );
+            CleanupStack::PopAndDestroy( smtpMtm );
+            CleanupStack::PopAndDestroy( attPath );
+            CleanupStack::PopAndDestroy( body );
+            CleanupStack::PopAndDestroy( description );
+            CleanupStack::PopAndDestroy( fromTo );
+            return;
+            }
+        entry->SetEntryL( folderId );
+
+        // mtm takes ownership of entry context
+        smtpMtm->SetCurrentEntryL( entry );
+        CleanupStack::Pop( entry );
+
+        // create a message and set subject and body
+        smtpMtm->CreateMessageL( defaultServiceId );
+        smtpMtm->SetSubjectL( description->Des() );
+        smtpMtm->Body().Reset();
+        smtpMtm->Body().InsertL( 0, body->Des() );
+
+        // get the entry of the message
+        TMsvEntry tentry = smtpMtm->Entry().Entry();
+
+        // add addressee
+        smtpMtm->AddAddresseeL( fromTo->Des() );
+        tentry.iDetails.Set( fromTo->Des() );
+
+        // If creating to Inbox use other than KUidMsgTypeSMTP so that the
+        // mail displays "from" field and not "to" field.
+        if ( folder == EInbox )
+            {
+            tentry.iMtm = KUidMsgTypeIMAP4;
+            }
+
+        // set the description field same as the message subject
+        tentry.iDescription.Set( description->Des() );
+
+        // save the changes done above
+        smtpMtm->Entry().ChangeL( tentry );
+
+        // get an access to the message store
+        CMsvStore* store = entry->EditStoreL();
+        CleanupStack::PushL( store );
+        CImHeader* header = CImHeader::NewLC();
+        header->RestoreL( *store );
+        TUint charset = header->Charset();
+        CleanupStack::PopAndDestroy( header );
+        CleanupStack::PopAndDestroy( store );
+
+        // handle attachment
+        TBool attachmentsExist = EFalse;
+        if ( attPath->Length() > 0 )
+            {
+            // check that attachment exists
+            RFs fsSession;
+            if ( fsSession.Connect() != KErrNone )
+                {
+                HTI_LOG_FORMAT( "Error in connecting to file server session: %d", err );
+                SendErrorMessageL( KErrCouldNotConnect, KErrorRfsConnectFailed );
+                CleanupStack::PopAndDestroy( smtpMtm );
+                CleanupStack::PopAndDestroy( attPath );
+                CleanupStack::PopAndDestroy( body );
+                CleanupStack::PopAndDestroy( description );
+                CleanupStack::PopAndDestroy( fromTo );
+                return;
+                }
+            CleanupClosePushL( fsSession );
+
+            TBool fileExists = BaflUtils::FileExists( fsSession, attPath->Des() );
+            if ( !fileExists )
+                {
+                HTI_LOG_TEXT( "Attachment file not found" );
+                SendErrorMessageL( KErrPathNotFound, KErrorAttachmentNotFound );
+                CleanupStack::PopAndDestroy(); // fsSession
+                CleanupStack::PopAndDestroy( smtpMtm );
+                CleanupStack::PopAndDestroy( attPath );
+                CleanupStack::PopAndDestroy( body );
+                CleanupStack::PopAndDestroy( description );
+                CleanupStack::PopAndDestroy( fromTo );
+                return;
+                }
+            else
+                {
+                // get the mime type
+                HTI_LOG_TEXT( "Getting the attachment's mime type" );
+                RApaLsSession ls;
+                User::LeaveIfError( ls.Connect() );
+                TUid appUid;
+                TDataType dataType;
+                ls.AppForDocument( *attPath, appUid, dataType );
+                TPtrC8 mimeType = dataType.Des8();
+
+                HTI_LOG_TEXT( "Adding the attachment" );
+                CWaiter* waiter = CWaiter::NewLC();
+                smtpMtm->AddAttachmentL( attPath->Des(), mimeType, charset,
+                        waiter->iStatus );
+                waiter->StartAndWait();
+                CleanupStack::PopAndDestroy( waiter );
+                HTI_LOG_TEXT( "Attachment added succesfully" );
+
+                attachmentsExist = ETrue;
+                }
+
+            CleanupStack::PopAndDestroy(); // fsSession
+            }
+
+        // save the message
+        smtpMtm->SaveMessageL();
+
+        // final fine tuning
+        TMsvEmailEntry temailEntry = static_cast<TMsvEmailEntry>( tentry );
+        temailEntry.SetMessageFolderType( EFolderTypeUnknown );
+        temailEntry.SetDisconnectedOperation( ENoDisconnectedOperations );
+        temailEntry.SetEncrypted( EFalse );
+        temailEntry.SetSigned( EFalse );
+        temailEntry.SetVCard( EFalse );
+        temailEntry.SetVCalendar( EFalse );
+        temailEntry.SetReceipt( EFalse );
+        temailEntry.SetMHTMLEmail( EFalse );
+        temailEntry.SetBodyTextComplete( ETrue );
+        temailEntry.SetAttachment( attachmentsExist );
+        temailEntry.iDate.UniversalTime();
+        temailEntry.SetVisible( ETrue );
+        temailEntry.SetInPreparation( EFalse );
+        temailEntry.SetSendingState( KMsvSendStateWaiting );
+        temailEntry.SetUnread( isUnread );
+        temailEntry.SetNew( isNew );
+        temailEntry.SetComplete( ETrue );
+        temailEntry.iServiceId = defaultServiceId;
+        temailEntry.iRelatedId = 0;
+
+        smtpMtm->Entry().ChangeL( temailEntry );
+
+        // get an access to the message store
+        store = entry->EditStoreL();
+        CleanupStack::PushL( store );
+
+        // set email header info
+        header = CImHeader::NewLC();
+        header->RestoreL( *store );
+        header->SetSubjectL( description->Des() );
+        header->SetFromL( fromTo->Des() );
+        header->SetReceiptAddressL( fromTo->Des() );
+        header->StoreL( *store );
+        store->CommitL();
+        CleanupStack::PopAndDestroy( header );
+        CleanupStack::PopAndDestroy( store );
+
+        // send the message, if it is in outbox
+        if ( folder == EOutbox )
+            {
+            HTI_LOG_TEXT( "E-Mail was created in outbox, marking it to be sent on next connection" );
+
+            CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
+            CleanupStack::PushL( selection );
+            selection->AppendL( temailEntry.Id() );
+
+            TBuf8<1> dummyParameter;
+            CMsvOperationActiveSchedulerWait* waiter =
+                    CMsvOperationActiveSchedulerWait::NewLC();
+            CMsvOperation* op = smtpMtm->InvokeAsyncFunctionL(
+                    KSMTPMTMSendOnNextConnection, *selection,
+                    dummyParameter, waiter->iStatus );
+            CleanupStack::PushL( op );
+            waiter->Start();
+            CleanupStack::PopAndDestroy( op );
+            CleanupStack::PopAndDestroy( waiter );
+            CleanupStack::PopAndDestroy( selection );
+            }
+
+        HTI_LOG_TEXT( "Cleaning up" );
+        CleanupStack::PopAndDestroy( smtpMtm );
+        CleanupStack::PopAndDestroy( attPath );
+        CleanupStack::PopAndDestroy( body );
+        CleanupStack::PopAndDestroy( description );
+        CleanupStack::PopAndDestroy( fromTo );
+
+        // send the message id back
+        TInt32 id = tentry.Id();
+        TBuf8<8> idStr;
+        idStr.Copy( ( TUint8* )( &id ), sizeof( id ) );
+        SendOkMsgL( idStr );
+        }
+
+    HTI_LOG_FUNC_OUT("CMessageMgmntHandler::HandleCreateEmailL: Done");
+    }
+
+// ----------------------------------------------------------------------------
+void CMessageMgmntHandler::HandleCreateObexMsgL( const TDesC8& aData,
+                                                 TUid aMtmUid,
+                                                 TUid aMsgTypeUid )
+    {
+    HTI_LOG_FUNC_IN( "CMessageMgmntHandler::HandleCreateObexMsgL" );
+
+    if ( ValidateAddObexMsgCommand( aData ) )
+        {
+        // parse the parameters
+        TInt position( 0 );
+        HBufC16* fromTo = ExtractDesLC( aData, position, 1 );
+        HBufC16* description = ExtractDesLC( aData, position, 1 );
+        HBufC16* attPath = ExtractDesLC( aData, position, 1 );
+        TBool isNew = (TBool)aData[position];
+        TBool isUnread = (TBool)aData[position+1];
+        TFolder folder = (TFolder)aData[position+2];
+
+        // Adding Obex messages to the outbox is not allowed
+        if ( folder == EOutbox )
+            {
+            HTI_LOG_TEXT( "Outbox not supported with Obex messages" );
+            SendErrorMessageL( KErrNotSupported, KErrorNotSupported );
+            CleanupStack::PopAndDestroy( attPath );
+            CleanupStack::PopAndDestroy( description );
+            CleanupStack::PopAndDestroy( fromTo );
+            return;
+            }
+
+        CObexClientMtm* obexMtm = NULL;
+        TRAPD( err, obexMtm = ( CObexClientMtm* )iMtmReg->NewMtmL( aMtmUid ) );
+        if ( err || !obexMtm )
+            {
+            HTI_LOG_TEXT( "Obex message type module not found" );
+            SendErrorMessageL( KErrNotFound, KErrorMsgTypeNotFound );
+            CleanupStack::PopAndDestroy( attPath );
+            CleanupStack::PopAndDestroy( description );
+            CleanupStack::PopAndDestroy( fromTo );
+            return;
+            }
+        CleanupStack::PushL( obexMtm );
+
+        CMsvEntry* entry = CMsvEntry::NewL( *iSession,
+                                            KMsvGlobalInBoxIndexEntryId,
+                                            TMsvSelectionOrdering() );
+        CleanupStack::PushL( entry );
+
+        TMsvId defaultServiceId = 0;
+
+        // map the folder parameter to folder id
+        TMsvId folderId = KMsvGlobalInBoxIndexEntryId;
+        TRAP( err, folderId = MapFolderToIdL( folder ) );
+        if ( err )
+            {
+            HTI_LOG_FORMAT( "Invalid folder: %d", folder );
+            SendErrorMessageL( err, KErrorInvalidFolder );
+            CleanupStack::PopAndDestroy( entry );
+            CleanupStack::PopAndDestroy( obexMtm );
+            CleanupStack::PopAndDestroy( attPath );
+            CleanupStack::PopAndDestroy( description );
+            CleanupStack::PopAndDestroy( fromTo );
+            return;
+            }
+        entry->SetEntryL( folderId );
+
+        // mtm takes ownership of entry context
+        obexMtm->SetCurrentEntryL( entry );
+        CleanupStack::Pop( entry );
+
+        // create a new message
+        obexMtm->CreateMessageL( defaultServiceId );
+
+        // get the entry of the message
+        TMsvEntry tentry = obexMtm->Entry().Entry();
+
+        // set subject
+        obexMtm->SetSubjectL( description->Des() );
+        tentry.iDescription.Set( description->Des() );
+
+        // set body, must be empty for obex messages
+        obexMtm->Body().Reset();
+
+        // set the details field and
+        tentry.iDetails.Set( fromTo->Des() );
+
+        // set mtm
+        tentry.iMtm = aMtmUid;
+        tentry.iType = KUidMsvMessageEntry;
+        tentry.iServiceId = KMsvUnknownServiceIndexEntryId;
+
+        // save the changes done above
+        obexMtm->Entry().ChangeL( tentry );
+
+        // save the message
+        obexMtm->SaveMessageL();
+
+        // final fine tuning
+        tentry.iDate.HomeTime();
+        tentry.SetVisible( ETrue );
+        tentry.SetInPreparation( EFalse );
+        tentry.SetUnread( isUnread );
+        tentry.SetNew( isNew );
+        tentry.SetComplete( ETrue );
+        obexMtm->Entry().ChangeL( tentry );
+
+        // handle attachment
+        if ( attPath->Length() > 0 )
+            {
+            // check that attachment exists
+            RFs fsSession;
+            if ( fsSession.Connect() != KErrNone )
+                {
+                HTI_LOG_FORMAT( "Error in connecting to file server session: %d", err );
+                SendErrorMessageL( KErrCouldNotConnect, KErrorRfsConnectFailed );
+                CleanupStack::PopAndDestroy( obexMtm );
+                CleanupStack::PopAndDestroy( attPath );
+                CleanupStack::PopAndDestroy( description );
+                CleanupStack::PopAndDestroy( fromTo );
+                return;
+                }
+
+            TBool fileExists = BaflUtils::FileExists( fsSession, attPath->Des() );
+            fsSession.Close();
+            if ( !fileExists )
+                {
+                HTI_LOG_TEXT( "Attachment file not found" );
+                SendErrorMessageL( KErrPathNotFound, KErrorAttachmentNotFound );
+                CleanupStack::PopAndDestroy( obexMtm );
+                CleanupStack::PopAndDestroy( attPath );
+                CleanupStack::PopAndDestroy( description );
+                CleanupStack::PopAndDestroy( fromTo );
+                return;
+                }
+            else
+                {
+                // create a new entry for the attachment
+                TMsvEntry attachTEntry;
+                attachTEntry.iType = KUidMsvAttachmentEntry;
+                attachTEntry.iServiceId = KMsvUnknownServiceIndexEntryId;
+                attachTEntry.iMtm = aMsgTypeUid; //save as bt message
+
+                entry->CreateL( attachTEntry );
+
+                CMsvEntry* attachEntry = iSession->GetEntryL( attachTEntry.Id() );
+                obexMtm->SetCurrentEntryL( attachEntry );
+
+                // get source file
+                TFileName sourceFileName = attPath->Des();
+
+                // get the mime type
+                RApaLsSession ls;
+                User::LeaveIfError( ls.Connect() );
+                CleanupClosePushL<RApaLsSession>(ls);
+                TUid appUid;
+                TDataType mimeType;
+                ls.AppForDocument( sourceFileName, appUid, mimeType );
+                CleanupStack::PopAndDestroy(); //ls
+
+                CWaiter* waiter = CWaiter::NewLC();
+
+                // add an attachment to the current message entry
+                obexMtm->AddAttachmentL( sourceFileName, mimeType.Des8(), 0,
+                        waiter->iStatus );
+                waiter->StartAndWait();
+                CleanupStack::PopAndDestroy( waiter );
+                }
+            }
+
+        CleanupStack::PopAndDestroy( obexMtm );
+        CleanupStack::PopAndDestroy( attPath );
+        CleanupStack::PopAndDestroy( description );
+        CleanupStack::PopAndDestroy( fromTo );
+
+        // send the message id back
+        TInt32 id = tentry.Id();
+        TBuf8<8> idStr;
+        idStr.Copy( ( TUint8* )( &id ), sizeof( id ) );
+        SendOkMsgL( idStr );
+        }
+
+    HTI_LOG_FUNC_OUT("CMessageMgmntHandler::HandleCreateObexMsgL: Done");
+    }
+
+
+// ----------------------------------------------------------------------------
+void CMessageMgmntHandler::HandleCreateSmartMsgL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CMessageMgmntHandler::HandleCreateSmartMsgL" );
+
+    if ( ValidateAddSmartMsgCommand( aData ) )
+        {
+        TInt position( 0 );
+        HBufC16* fromTo = ExtractDesLC( aData, position, 1 );
+        HBufC16* description = ExtractDesLC( aData, position, 1 );
+        HBufC16* body = ExtractDesLC( aData, position, 2 );
+        TBool isNew = (TBool)aData[position];
+        TBool isUnread = (TBool)aData[position+1];
+        TFolder folder = (TFolder)aData[position+2];
+        TInt bioUidValue =   aData[position+3] +
+                           ( aData[position+4] << 8 ) +
+                           ( aData[position+5] << 16 ) +
+                           ( aData[position+6] << 24 );
+
+
+        // Smart messages can be created only to inbox.
+        // For sending smart messages, create a normal SMS with smart message
+        // content as a body and send it.
+        if ( folder != EInbox )
+            {
+            HTI_LOG_TEXT( "Invalid folder specified for smart message" );
+            SendErrorMessageL( KErrArgument, KErrorInvalidFolderForSmartMsg );
+            CleanupStack::PopAndDestroy( body );
+            CleanupStack::PopAndDestroy( description );
+            CleanupStack::PopAndDestroy( fromTo );
+            return;
+
+            }
+
+        CSmsClientMtm* smsMtm = NULL;
+        TRAPD( err, smsMtm = ( CSmsClientMtm* )iMtmReg->NewMtmL( KUidMsgTypeSMS ) );
+        if ( err || !smsMtm )
+            {
+            HTI_LOG_TEXT( "SMS message type module not found" );
+            SendErrorMessageL( KErrNotFound, KErrorMsgTypeNotFound );
+            CleanupStack::PopAndDestroy( body );
+            CleanupStack::PopAndDestroy( description );
+            CleanupStack::PopAndDestroy( fromTo );
+            return;
+            }
+        CleanupStack::PushL( smsMtm );
+
+        CMsvEntry* entry = CMsvEntry::NewL( *iSession,
+                KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering() );
+        CleanupStack::PushL( entry );
+
+        // get the default service
+        TMsvId defaultServiceId = 0;
+        TRAP( err, defaultServiceId = smsMtm->DefaultServiceL() );
+        if ( err )
+            {
+            HTI_LOG_FORMAT( "Could not get default service, err: %d", err );
+            SendErrorMessageL( err, KErrorSmsSettingNotDefined );
+            CleanupStack::PopAndDestroy( entry );
+            CleanupStack::PopAndDestroy( smsMtm );
+            CleanupStack::PopAndDestroy( body );
+            CleanupStack::PopAndDestroy( description );
+            CleanupStack::PopAndDestroy( fromTo );
+            return;
+            }
+
+        // no need for folder mapping, since only inbox allowed for smart messages
+        TMsvId folderId = KMsvGlobalInBoxIndexEntryId;
+        entry->SetEntryL( folderId );
+
+        // mtm takes ownership of entry context
+        smsMtm->SetCurrentEntryL( entry );
+        CleanupStack::Pop( entry );
+
+        // create a new message
+        smsMtm->CreateMessageL( defaultServiceId );
+
+        // update the message header
+        CSmsHeader* smsHeader = &( smsMtm->SmsHeader() );
+        delete smsHeader;
+        smsHeader = NULL;
+        smsHeader = CSmsHeader::NewL( CSmsPDU::ESmsDeliver, smsMtm->Body() );
+        smsHeader->SetFromAddressL( fromTo->Des() );
+
+        // set body, the actual BIO message content
+        smsMtm->Body().Reset();
+        smsMtm->Body().InsertL( 0, body->Des() );
+
+        // get the entry of the message
+        TMsvEntry tentry = smsMtm->Entry().Entry();
+
+        // set BIO message type specific data
+        tentry.iBioType = bioUidValue;
+        smsMtm->BioTypeChangedL( TUid::Uid( bioUidValue ) );
+
+        // set details field
+        tentry.iDetails.Set( fromTo->Des() );
+
+        // set the description field
+        tentry.iDescription.Set( description->Des() );
+
+        // set correct MTM type
+        tentry.iMtm= KUidBIOMessageTypeMtm;
+
+        // final fine tuning
+        tentry.SetAttachment( EFalse );
+        tentry.iDate.UniversalTime();
+        tentry.SetVisible( ETrue );
+        tentry.SetInPreparation( EFalse );
+        tentry.SetUnread( isUnread );
+        tentry.SetNew( isNew );
+        tentry.SetComplete( ETrue );
+        tentry.SetSendingState( KMsvSendStateWaiting );
+        tentry.iServiceId = defaultServiceId;
+        tentry.iRelatedId = 0;
+
+        // save the changes done above
+        smsMtm->Entry().ChangeL( tentry );
+
+        // save the message
+        smsMtm->SaveMessageL();
+
+        CleanupStack::PopAndDestroy( smsMtm );
+        CleanupStack::PopAndDestroy( body );
+        CleanupStack::PopAndDestroy( description );
+        CleanupStack::PopAndDestroy( fromTo );
+
+        TInt32 id = tentry.Id();
+        TBuf8<8> idStr;
+        idStr.Copy( ( TUint8* )( &id ), sizeof( id ) );
+        SendOkMsgL( idStr );
+        }
+
+    HTI_LOG_FUNC_OUT("CMessageMgmntHandler::HandleCreateSmartMsgL: Done");
+    }
+
+
+// ----------------------------------------------------------------------------
+void CMessageMgmntHandler::HandleDeleteMessageL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CMessageMgmntHandler::HandleDeleteMessageL" );
+
+    if ( aData.Length() != 4 )
+        {
+        HTI_LOG_TEXT( "CMessageMgmntHandler: Error: wrong length of data" );
+        SendErrorMessageL( KErrArgument, KErrorInvalidId );
+        return;
+        }
+
+    TMsvId entryId =   aData[0] +
+                     ( aData[1] << 8 ) +
+                     ( aData[2] << 16 ) +
+                     ( aData[3] << 24 );
+    HTI_LOG_FORMAT( "CMessageMgmntHandler: Deleting one message, id: %d", entryId );
+    TMsvEntry entry;
+    TMsvId service;
+    User::LeaveIfError( iSession->GetEntry( entryId, service, entry ) );
+
+    CMsvEntry* parentCEntry = iSession->GetEntryL( entry.Parent() );
+    CleanupStack::PushL( parentCEntry );
+    TRAPD( err, parentCEntry->DeleteL( entry.Id() ) );
+    CleanupStack::PopAndDestroy( parentCEntry );
+
+    if ( err == KErrNone )
+        {
+        SendOkMsgL( KNullDesC8 );
+        }
+    else if ( err == KErrNotFound )
+        {
+        SendErrorMessageL( err, KErrorItemNotFound );
+        }
+    else
+        {
+        SendErrorMessageL( err, KErrorFailedDelete );
+        }
+
+    HTI_LOG_FUNC_OUT("CMessageMgmntHandler::HandleDeleteMessageL: Done");
+    }
+
+// ----------------------------------------------------------------------------
+void CMessageMgmntHandler::HandleDeleteMessagesL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CMessageMgmntHandler::HandleDeleteMessagesFuncL" );
+
+    if ( aData.Length() != 2 )
+        {
+        HTI_LOG_TEXT( "CMessageMgmntHandler: Error: wrong length of data" );
+        SendErrorMessageL( KErrArgument, KErrorInvalidFolder );
+        return;
+        }
+
+    if ( aData[0] == EAllFolders )
+        {
+        HandleDeleteFromAllFoldersL( (TMessageType)aData[1] );
+        }
+    else if ( aData[1] == EAllMessageTypes )
+        {
+        HandleDeleteAllMessageTypesL( (TFolder)aData[0] );
+        }
+    else
+        {
+        HandleDeleteFromFolderByTypeL( (TFolder)aData[0],
+                                       (TMessageType)aData[1] );
+        }
+
+    SendOkMsgL( KNullDesC8 );
+    HTI_LOG_FUNC_OUT("CMessageMgmntHandler::HandleDeleteMessagesFuncL: Done");
+    }
+
+// ----------------------------------------------------------------------------
+void CMessageMgmntHandler::HandleDeleteFromAllFoldersL( TMessageType aType )
+    {
+    HTI_LOG_FUNC_IN( "CMessageMgmntHandler::HandleDeleteFromAllFoldersL" );
+
+    if ( aType == EAllMessageTypes )
+        {
+        for ( TInt i = 1; i < ENumberOfFolders; i++ )
+            {
+            HandleDeleteAllMessageTypesL( (TFolder)i );
+            }
+        }
+    else
+        {
+        for ( TInt i = 1; i < ENumberOfFolders; i++ )
+            {
+            HandleDeleteFromFolderByTypeL( (TFolder)i, aType );
+            }
+        }
+
+    HTI_LOG_FUNC_OUT("CMessageMgmntHandler::HandleDeleteFromAllFoldersL: Done");
+    }
+
+// ----------------------------------------------------------------------------
+void CMessageMgmntHandler::HandleDeleteAllMessageTypesL( TFolder aFolder )
+    {
+    HTI_LOG_FUNC_IN( "CMessageMgmntHandler::HandleDeleteAllMessageTypesL" );
+
+    if ( aFolder == EAllFolders )
+        {
+        for ( TInt i = 1; i < ENumberOfMessageTypes; i++ )
+            {
+            HandleDeleteFromAllFoldersL( (TMessageType)i );
+            }
+        }
+    else
+        {
+        for ( TInt i = 1; i < ENumberOfMessageTypes; i++ )
+            {
+            HandleDeleteFromFolderByTypeL( aFolder, (TMessageType)i );
+            }
+        }
+
+    HTI_LOG_FUNC_OUT("CMessageMgmntHandler::HandleDeleteAllMessageTypesL: Done");
+    }
+
+// ----------------------------------------------------------------------------
+void CMessageMgmntHandler::HandleDeleteFromFolderByTypeL( TFolder aFolder,
+                                                          TMessageType aType )
+    {
+    HTI_LOG_FUNC_IN( "CMessageMgmntHandler::HandleDeleteFromFolderByTypeL" );
+
+    TMsvId folderId = MapFolderToIdL( aFolder );
+    TUid msgTypeUid = MapMessageTypeToUidL( aType );
+
+    HTI_LOG_TEXT( "Deleting messages..." );
+    HTI_LOG_FORMAT( "Folder: %d", aFolder );
+    HTI_LOG_FORMAT( "Message type: %d", aType );
+
+    CMsvEntry* folder = CMsvEntry::NewL( *iSession,
+                                         folderId,
+                                         TMsvSelectionOrdering() );
+    CleanupStack::PushL( folder );
+    CMsvEntrySelection* sel = folder->ChildrenWithMtmL( msgTypeUid );
+
+    CleanupStack::PushL( sel );
+    HTI_LOG_FORMAT( "Found %d matching items", sel->Count() );
+
+    for ( TInt i = 0; i < sel->Count(); i++ )
+        {
+        TMsvId entryId = sel->At( i );
+        TMsvEntry entry;
+        TMsvId service;
+        User::LeaveIfError( iSession->GetEntry( entryId, service, entry ) );
+        if ( ( aType == EAudioMessage && entry.iBioType != KUidMsgSubTypeMmsAudioMsg.iUid ) ||
+                ( aType == EMMS && entry.iBioType == KUidMsgSubTypeMmsAudioMsg.iUid ) )
+            {
+            // do not delete audio messages when MMS deletion
+            // requested and vice versa
+            continue;
+            }
+        CMsvEntry* parentCEntry = iSession->GetEntryL( entry.Parent() );
+        CleanupStack::PushL( parentCEntry );
+        parentCEntry->DeleteL( entry.Id() );
+        CleanupStack::PopAndDestroy( parentCEntry );
+        }
+
+    CleanupStack::PopAndDestroy( sel );
+    CleanupStack::PopAndDestroy( folder );
+
+    if ( aType == EEmail )
+        {
+        HandleDeleteFromFolderByTypeL( aFolder, EEmailPOP3 );
+        HandleDeleteFromFolderByTypeL( aFolder, EEmailIMAP4 );
+        }
+
+    HTI_LOG_FUNC_OUT("CMessageMgmntHandler::HandleDeleteFromFolderByTypeL: Done");
+    }
+
+// ----------------------------------------------------------------------------
+void CMessageMgmntHandler::SendOkMsgL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN("CMessageMgmntHandler::SendOkMsgL: Starting");
+
+    User::LeaveIfNull( iDispatcher );
+
+    HBufC8* temp = HBufC8::NewL( aData.Length() + 1 );
+    TPtr8 response = temp->Des();
+    response.Append( (TChar) CHtiMessagesServicePlugin::EResultOk );
+    response.Append( aData );
+    User::LeaveIfError( iDispatcher->DispatchOutgoingMessage(
+        temp, KHtiMessagesServiceUid ) );
+
+    HTI_LOG_FUNC_OUT("CMessageMgmntHandler::SendOkMsgL: Done");
+    }
+
+// ----------------------------------------------------------------------------
+void CMessageMgmntHandler::SendErrorMessageL( TInt aError,
+                                              const TDesC8& aDescription )
+    {
+    HTI_LOG_FUNC_IN("CMessageMgmntHandler::SendErrorMessageL: Starting");
+    User::LeaveIfNull( iDispatcher );
+    User::LeaveIfError( iDispatcher->DispatchOutgoingErrorMessage(
+        aError, aDescription, KHtiMessagesServiceUid ) );
+    HTI_LOG_FUNC_OUT("CMessageMgmntHandler::SendErrorMessageL: Done");
+    }
+
+// ----------------------------------------------------------------------------
+TBool CMessageMgmntHandler::ValidateAddSmsCommand( const TDesC8& aData )
+    {
+    if ( aData.Length() < KAddSmsCmdMinLength )
+        {
+        HTI_LOG_TEXT( "ValidateAddSmsCommand: Error: missing data" );
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return EFalse;
+        }
+
+    TInt offset = 0;
+    TInt fromLength = aData[offset];
+
+    offset = 1 + fromLength;
+    if ( offset > aData.Length() - 1 )
+        {
+        HTI_LOG_TEXT( "ValidateAddSmsCommand: Error: wrong length of data" );
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return EFalse;
+        }
+    TInt descrLength = aData[offset];
+
+    offset = offset + 1 + descrLength;
+    if ( offset > aData.Length() - 2 ) // body length in two bytes
+        {
+        HTI_LOG_TEXT( "ValidateAddSmsCommand: Error: wrong length of data" );
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return EFalse;
+        }
+    TInt bodyLength = aData[offset] + ( aData[offset+1] << 8 );
+
+    TInt wholeLength = 1 + fromLength +
+                       1 + descrLength +
+                       2 + bodyLength +
+                       1 + // is new
+                       1 + // is unread
+                       1;  // folder
+
+    if ( wholeLength != aData.Length() )
+        {
+        HTI_LOG_TEXT( "ValidateAddSmsCommand: Error: wrong length of data" );
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return EFalse;
+        }
+
+    if ( bodyLength > 160 )
+        {
+        HTI_LOG_TEXT( "ValidateAddSmsCommand: Error: too long SMS body" );
+        SendErrorMessageL( KErrOverflow, KErrorTooLongSmsBody );
+        return EFalse;
+        }
+
+    return ETrue;
+    }
+
+
+// ----------------------------------------------------------------------------
+TBool CMessageMgmntHandler::ValidateAddMmsOrAddEmailCommand( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CMessageMgmntHandler::ValidateAddMmsOrAddEmailCommand" );
+    if ( aData.Length() < KAddMmsOrEmailCmdMinLength + 1 ) // +1 = cmd code
+        {
+        HTI_LOG_TEXT( "Error: missing data" );
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return EFalse;
+        }
+
+    if ( aData[0] == CHtiMessagesServicePlugin::EAddAudioMsg &&
+            aData.Length() < KAddAudioCmdMinLength + 1 ) // +1 = cmd code
+        {
+        HTI_LOG_TEXT( "ValidateAddMmsOrAddEmailCommand: Error: missing data" );
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return EFalse;
+        }
+
+    TInt offset = 0;
+    TInt cmdCode = aData[offset];
+    offset++;
+    TInt fromToLength = aData[offset];
+    fromToLength++; // the length byte
+
+    offset = offset + fromToLength;
+    if ( offset > aData.Length() - 1 )
+        {
+        HTI_LOG_TEXT( "Error: wrong length of data" );
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return EFalse;
+        }
+    TInt descrLength = aData[offset];
+    descrLength++; // the length byte
+
+    offset = offset + descrLength;
+    TInt bodyLength = 0;
+    if ( cmdCode != CHtiMessagesServicePlugin::EAddAudioMsg )
+        {
+        if ( offset > aData.Length() - 2 ) // body length in two bytes
+            {
+            HTI_LOG_TEXT( "Error: wrong length of data" );
+            SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+            return EFalse;
+            }
+        bodyLength = aData[offset] + ( aData[offset+1] << 8 );
+        bodyLength += 2; // the body length bytes
+        }
+
+    offset = offset + bodyLength;
+    if ( offset > aData.Length() - 1 )
+        {
+        HTI_LOG_TEXT( ": wrong length of data" );
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return EFalse;
+        }
+    TInt attPathLength = aData[offset];
+    if ( attPathLength == 0 && cmdCode == CHtiMessagesServicePlugin::EAddAudioMsg )
+        {
+        // attachment (the audio) is mandatory for audio message
+        HTI_LOG_TEXT( "Error: missing attachment" );
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return EFalse;
+        }
+    attPathLength++; // the length byte
+
+    TInt wholeLength = 1 + // command code
+                       fromToLength + descrLength +  bodyLength + attPathLength +
+                       1 + // is new
+                       1 + // is unread
+                       1;  // folder
+
+    if ( wholeLength != aData.Length() )
+        {
+        HTI_LOG_TEXT( "Error: wrong length of data (wholeLength)" );
+        HTI_LOG_FORMAT( "Expected: %d", wholeLength );
+        HTI_LOG_FORMAT( "Was:      %d", aData.Length() );
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return EFalse;
+        }
+
+    return ETrue;
+    }
+
+
+// ----------------------------------------------------------------------------
+TBool CMessageMgmntHandler::ValidateAddObexMsgCommand( const TDesC8& aData )
+    {
+    if ( aData.Length() < KAddObexMsgCmdMinLength )
+        {
+        HTI_LOG_TEXT( "ValidateAddObexMsgCommand: Error: missing data" );
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return EFalse;
+        }
+
+    TInt offset = 0;
+    TInt fromToLength = aData[offset];
+
+    offset = 1 + fromToLength;
+    if ( offset > aData.Length() - 1 )
+        {
+        HTI_LOG_TEXT( "ValidateAddObexMsgCommand: Error: wrong length of data" );
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return EFalse;
+        }
+    TInt descrLength = aData[offset];
+
+    offset = offset + 1 + descrLength;
+    if ( offset > aData.Length() - 1 )
+        {
+        HTI_LOG_TEXT( "ValidateAddObexMsgCommand: Error: wrong length of data" );
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return EFalse;
+        }
+    TInt attPathLength = aData[offset];
+
+    TInt wholeLength = 1 + fromToLength +
+                       1 + descrLength +
+                       1 + attPathLength +
+                       1 + // is new
+                       1 + // is unread
+                       1;  // folder
+
+    if ( wholeLength != aData.Length() )
+        {
+        HTI_LOG_TEXT( "ValidateAddObexMsgCommand: Error: wrong length of data" );
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return EFalse;
+        }
+
+    return ETrue;
+    }
+
+// ----------------------------------------------------------------------------
+TBool CMessageMgmntHandler::ValidateAddSmartMsgCommand( const TDesC8& aData )
+    {
+    if ( aData.Length() < KAddSmartMsgCmdMinLength )
+        {
+        HTI_LOG_TEXT( "ValidateAddSmartMsgCommand: Error: missing data" );
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return EFalse;
+        }
+
+    TInt offset = 0;
+    TInt fromToLength = aData[offset];
+
+    offset = 1 + fromToLength;
+    if ( offset > aData.Length() - 1 )
+        {
+        HTI_LOG_TEXT( "ValidateAddSmartMsgCommand: Error: wrong length of data" );
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return EFalse;
+        }
+    TInt descrLength = aData[offset];
+
+    offset = offset + 1 + descrLength;
+    if ( offset > aData.Length() - 2 ) // body length in two bytes
+        {
+        HTI_LOG_TEXT( "ValidateAddSmartMsgCommand: Error: wrong length of data" );
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return EFalse;
+        }
+    TInt bodyLength = aData[offset] + ( aData[offset+1] << 8 );
+
+    TInt wholeLength = 1 + fromToLength +
+                       1 + descrLength +
+                       2 + bodyLength +
+                       1 + // is new
+                       1 + // is unread
+                       1 + // folder
+                       4;  // biomessage uid
+
+    if ( wholeLength != aData.Length() )
+        {
+        HTI_LOG_TEXT( "ValidateAddSmartMsgCommand: Error: wrong length of data" );
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        return EFalse;
+        }
+
+    return ETrue;
+    }
+
+
+// ----------------------------------------------------------------------------
+// Extracts UTF-8 data, converts it to Unicode and returns as 16-bit descriptor.
+// Within aData, read descriptor from aPosition:
+//  - first bytes tell the size of data for UTF8 formatted data
+//  - next bytes are the data as indicated by the size
+//  - position is finally set to the end of UTF8 data area
+// ----------------------------------------------------------------------------
+HBufC16* CMessageMgmntHandler::ExtractDesLC( const TDesC8& aUtf8Data,
+                                             TInt& aPosition,
+                                             TInt aSizeBytes )
+    {
+    HTI_LOG_FUNC_IN( "CMessageMgmntHandler::ExtractDesLC" );
+    TInt length = 0;
+    for ( TInt i = 0; i < aSizeBytes; i++ )
+        {
+        length += ( aUtf8Data[aPosition+i] << ( i * 8 ) );
+        }
+
+    if ( length < 0 ||
+         length > aUtf8Data.Mid( aPosition ).Length() )
+        {
+        User::Leave( KErrBadDescriptor );
+        }
+
+    HBufC16* result = NULL;
+
+    if ( length > 0 )
+        {
+        result = CnvUtfConverter::ConvertToUnicodeFromUtf8L(
+            aUtf8Data.Mid( aPosition + aSizeBytes, length ) );
+        HTI_LOG_TEXT( "ExtractDesLC: Conversion to Unicode done" );
+        CleanupStack::PushL( result );
+        }
+
+    else
+        {
+        result = HBufC16::NewLC( 0 );
+        }
+
+    aPosition += ( aSizeBytes + length );
+
+    HTI_LOG_FUNC_OUT( "CMessageMgmntHandler::ExtractDesLC" );
+    return result;
+    }
+
+
+// ----------------------------------------------------------------------------
+// Extracts UTF-8 data to 8-bit descriptor without doing any conversions.
+// ----------------------------------------------------------------------------
+HBufC8* CMessageMgmntHandler::ExtractDes8LC( const TDesC8& aUtf8Data,
+                                             TInt& aPosition,
+                                             TInt aSizeBytes )
+    {
+    HTI_LOG_FUNC_IN( "CMessageMgmntHandler::ExtractDes8LC" );
+    TInt length = 0;
+    for ( TInt i = 0; i < aSizeBytes; i++ )
+        {
+        length += ( aUtf8Data[aPosition+i] << ( i * 8 ) );
+        }
+
+    if ( length < 0 ||
+         length > aUtf8Data.Mid( aPosition ).Length() )
+        {
+        User::Leave( KErrBadDescriptor );
+        }
+
+    HBufC8* result = HBufC8::NewLC( length );
+
+    if ( length > 0 )
+        {
+        result->Des().Copy( aUtf8Data.Mid( aPosition + aSizeBytes, length ) );
+        }
+
+    aPosition += ( aSizeBytes + length );
+
+    HTI_LOG_FUNC_OUT( "CMessageMgmntHandler::ExtractDes8LC" );
+    return result;
+    }
+
+
+// ----------------------------------------------------------------------------
+TMsvId CMessageMgmntHandler::MapFolderToIdL( TFolder aFolder )
+    {
+    TMsvId id = 0;
+
+    switch ( aFolder )
+        {
+        case EInbox:  { id = KMsvGlobalInBoxIndexEntryId;   break; }
+        case EDrafts: { id = KMsvDraftEntryId;              break; }
+        case ESent:   { id = KMsvSentEntryId;               break; }
+        case EOutbox: { id = KMsvGlobalOutBoxIndexEntryId;  break; }
+        default:      { User::Leave( KErrArgument );        break; }
+        }
+
+    return id;
+    }
+
+// ----------------------------------------------------------------------------
+TUid CMessageMgmntHandler::MapMessageTypeToUidL( TMessageType aType )
+    {
+    TUid uid = { 0 };
+
+    switch ( aType )
+        {
+        case ESMS:          { uid = KUidMsgTypeSMS;            break; }
+        case EAudioMessage: // fall through - audio msg is MMS sub type
+        case EMMS:          { uid = KUidMsgTypeMultimedia;     break; }
+        case ESmartMessage: { uid = KUidBIOMessageTypeMtm;     break; }
+        case EEmail:        { uid = KUidMsgTypeSMTP;           break; }
+        case EEmailPOP3:    { uid = KUidMsgTypePOP3;           break; }
+        case EEmailIMAP4:   { uid = KUidMsgTypeIMAP4;          break; }
+        case EIrMessage:    { uid = KUidMsgTypeIrUID;          break; }
+        case EBtMessage:    { uid = KUidMsgTypeBt;             break; }
+        default:            { User::Leave( KErrArgument );     break; }
+        }
+
+    return uid;
+    }
+
+// ----------------------------------------------------------------------------
+void CMessageMgmntHandler::HandleSessionEventL( TMsvSessionEvent /*aEvent*/,
+                                                TAny* /*aArg1*/,
+                                                TAny* /*aArg2*/,
+                                                TAny* /*aArg3*/ )
+    {
+    }
+
+
+
+// ----------------------------------------------------------------------------
+CWaiter* CWaiter::NewL( TInt aPriority )
+    {
+    CWaiter* self = new(ELeave) CWaiter( aPriority );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+CWaiter* CWaiter::NewLC( TInt aPriority )
+    {
+    CWaiter* self = new(ELeave) CWaiter( aPriority );
+    CleanupStack::PushL( self );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+CWaiter::CWaiter( TInt aPriority ) : CActive( aPriority )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// ----------------------------------------------------------------------------
+CWaiter::~CWaiter()
+    {
+    Cancel();
+    }
+
+// ----------------------------------------------------------------------------
+void CWaiter::StartAndWait()
+    {
+    iStatus = KRequestPending;
+    SetActive();
+    iWait.Start();
+    }
+
+// ----------------------------------------------------------------------------
+TInt CWaiter::Result() const
+    {
+    return iResult;
+    }
+
+// ----------------------------------------------------------------------------
+void CWaiter::RunL()
+    {
+    iResult = iStatus.Int();
+    iWait.AsyncStop();
+    }
+
+// ----------------------------------------------------------------------------
+void CWaiter::DoCancel()
+    {
+    iResult = KErrCancel;
+    if ( iStatus == KRequestPending )
+        {
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete( status, KErrCancel );
+        }
+
+    iWait.AsyncStop();
+    }
+
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiMessagesServicePlugin/src/proxy.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,37 @@
+/*
+* 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:  Implementation proxy for HtiMessagesServicePlugin service plugin dll
+*
+*/
+
+
+// INCLUDE FILES
+#include "HtiMessagesServicePlugin.h"
+
+#include <e32std.h>
+#include <ecom/implementationproxy.h>
+
+// Provides a key value pair table, this is used to identify
+// the correct construction function for the requested interface.
+const TImplementationProxy ImplementationTable[] =
+    {
+    IMPLEMENTATION_PROXY_ENTRY( 0x200212C6,  CHtiMessagesServicePlugin::NewL )
+    };
+
+// Function used to return an instance of the proxy table.
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    return ImplementationTable;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiPIMServicePlugin/data/200212C3.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,50 @@
+/*
+* 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:  Resource definitions for Personal data (vCard, vCalendar)
+*                service ECOM plugin.
+*
+*/
+
+
+// INCLUDES
+#include <ecom/registryinfo.rh>
+
+
+//  RESOURCE DEFINITIONS
+RESOURCE REGISTRY_INFO theInfo
+    {
+    // UID for the DLL
+    dll_uid = 0x200212C3;
+    // Declare array of interface info
+    interfaces =
+        {
+        INTERFACE_INFO
+            {
+            // UID of interface that is implemented
+            interface_uid = 0x1020DEB7;
+            implementations =
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = 0x200212C4;
+                    version_no         = 1;
+                    display_name       = "Personal information manager service";
+                    default_data       = "PIM";
+                    opaque_data        = "";
+                    }
+                };
+            }
+        };
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiPIMServicePlugin/group/HtiNpdHlp.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,40 @@
+/*
+* 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:  Build description file for HtiNpdHlp
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET      HtiNpdHlp.exe
+TARGETTYPE  exe
+UID         0x1000008d 0x200212D5
+
+VENDORID    0x101FB657
+
+CAPABILITY      ALL -TCB
+
+SOURCE          ../src/HtiNpdHlp.cpp
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY     euser.lib
+LIBRARY     efsrv.lib
+LIBRARY     cone.lib
+LIBRARY     npdlib.lib
+LIBRARY     flogger.lib
+
+SMPSAFE
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiPIMServicePlugin/group/HtiPIMServicePlugin.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ECOM implementation of PIM service
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          HtiPIMServicePlugin.dll
+TARGETTYPE      PLUGIN
+
+// ECom Dll recognition UID followed by the unique UID for this dll
+UID             0x10009D8D 0x200212C3
+
+VENDORID        0x101FB657
+
+CAPABILITY      ALL -TCB
+
+SOURCEPATH      ../src
+SOURCE          proxy.cpp
+SOURCE          HtiPIMServicePlugin.cpp
+SOURCE          PIMHandler.cpp
+SOURCE          HtiBookmarkHandler.cpp
+SOURCE          HtiSimDirHandlerVPbk.cpp
+
+USERINCLUDE     ../inc
+APP_LAYER_SYSTEMINCLUDE
+
+START RESOURCE  ../data/200212C3.rss
+TARGET          HtiPIMServicePlugin.rsc
+END
+
+LIBRARY         cmmanager.lib
+LIBRARY         apgrfx.lib
+LIBRARY         calenimp.lib
+LIBRARY         calinterimapi.lib
+LIBRARY         charconv.lib
+LIBRARY         ecom.lib
+LIBRARY         estor.lib
+LIBRARY         euser.lib
+LIBRARY         favouritesengine.lib
+LIBRARY         ws32.lib
+LIBRARY         vpbkeng.lib
+LIBRARY         vpbkvcardeng.lib
+LIBRARY         flogger.lib
+
+SMPSAFE
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiPIMServicePlugin/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  Build information file for HtiPIMServicePlugin
+*
+*/
+
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+HtiPIMServicePlugin.mmp
+HtiNpdHlp.mmp
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiPIMServicePlugin/inc/HtiBookmarkHandler.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,122 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Class that handles browser bookmark creation and deletion.
+*
+*/
+
+
+#ifndef HTIBOOKMARKHANDLER_H
+#define HTIBOOKMARKHANDLER_H
+
+// INCLUDES
+#include <e32std.h>
+#include <FavouritesLimits.h>
+#include <FavouritesSession.h>
+#include <HTIServicePluginInterface.h>
+
+// CONSTANTS
+const TInt KApMaxConnNameLength = 30;
+
+// MACROS
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+*  Class that handles browser bookmark creation and deletion.
+*/
+class CHtiBookmarkHandler : public CBase
+    {
+    public:
+
+        /**
+        * Two-phased constructor.
+        */
+        static CHtiBookmarkHandler* NewL();
+
+        /**
+        * Called when there is a message to be processed by this service.
+        * @param aMessage message body destinated to the servive
+        * @param aPriority message priority
+        */
+        void ProcessMessageL( const TDesC8& aMessage,
+            THtiMessagePriority aPriority );
+
+        /**
+        * Indicates whether this handler is ready to receive
+        * a new message or if it's busy processing previous message.
+        * @return ETrue if processing, EFalse if ready for new request
+        */
+        TBool IsBusy();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CHtiBookmarkHandler();
+
+        /**
+        * Sets the dispatcher to send outgoing messages to.
+        * @param aDispatcher pointer to dispatcher instance
+        */
+        void SetDispatcher( MHtiDispatcher* aDispatcher );
+
+    private: // constructors
+
+        /**
+        * C++ default constructor.
+        */
+        CHtiBookmarkHandler();
+
+        /**
+        * 2nd phase constructor.
+        */
+        void ConstructL();
+
+    private: // helpers
+
+        void HandleCreateBookmarkL();
+        void HandleDeleteBookmarkL();
+        void ParseCreateMessageL( const TDesC8& aMessage );
+        void ParseDeleteMessageL( const TDesC8& aMessage );
+        TInt ExtractStringL( const TDesC8& aMessage, TInt aOffset,
+                             TInt aLengthBytes, TInt aMinLength,
+                             TInt aMaxLength, TDes& aResult );
+        TInt GetFolderUidL( const TDesC& aFolderName );
+        TInt GetApUidL( const TDesC& aApName );
+        void SendOkMsgL( const TDesC8& aData );
+        void SendErrorMessageL( TInt aError, const TDesC8& aDescription );
+
+    private: // data
+
+        // Pointer to the dispatcher (referenced)
+        MHtiDispatcher* iDispatcher;
+
+        // Session to the favourites engine
+        RFavouritesSession iFavSession;
+
+        // The parsed parameter values from the command messages
+        TBuf<KFavouritesMaxName>     iFolderName;
+        TBuf<KFavouritesMaxName>     iBookmarkName;
+        TBuf<KApMaxConnNameLength>   iApName;
+        TBuf<KFavouritesMaxUserName> iUserName;
+        TBuf<KFavouritesMaxPassword> iPassword;
+        HBufC*                       iUrl;
+    };
+
+#endif // HTIBOOKMARKHANDLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiPIMServicePlugin/inc/HtiPIMServicePlugin.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,107 @@
+/*
+* 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:  Implementation of ECOM plug-in service interface. Provides
+*                PIM service (vCard & vCalendar import).
+*
+*/
+
+
+#ifndef CHTIPIMSERVICEPLUGIN_H
+#define CHTIPIMSERVICEPLUGIN_H
+
+// INCLUDES
+#include <HTIServicePluginInterface.h>
+#include <w32std.h>
+
+// CONSTANTS
+const TInt KPIMServiceUidValue = 0x10210CCD; // ECOM Implementation UID
+const TUid KPIMServiceUid = { KPIMServiceUidValue };
+
+// FORWARD DECLARATIONS
+class CPIMHandler;
+class CHtiBookmarkHandler;
+class CHtiSimDirHandlerVPbk;
+
+// CLASS DECLARATION
+
+/**
+* Implementation of ECOM plug-in service interface.
+*/
+class CHtiPIMServicePlugin : public CHTIServicePluginInterface
+    {
+    public:
+
+        enum TCommand
+            {
+            EImportVCard            = 0x01,
+            EImportVCalendar        = 0x02,
+
+            EDeleteContact          = 0x03,
+            EDeleteCalendar         = 0x04,
+
+            ENotepadAddMemo         = 0x05,
+            ENotepadAddMemoFromFile = 0x06,
+            ENotepadDeleteAll       = 0x07,
+
+            ESimCardInfo            = 0x10,
+            EImportSimContact       = 0x11,
+            EDeleteSimContact       = 0x12,
+
+            ECreateBookmark         = 0x1A,
+            EDeleteBookmark         = 0x1B,
+
+            EResultOk               = 0xFF // only for response message
+            };
+
+    public:
+
+        static CHtiPIMServicePlugin* NewL();
+
+        // Interface implementation
+
+        /**
+        * From CHTIServicePluginInterface
+        * Called by the HTI Framework when sending message to this service.
+        * @param aMessage message body destinated to a servive
+        * @param aPriority message priority
+        */
+        void ProcessMessageL( const TDesC8& aMessage,
+            THtiMessagePriority aPriority );
+
+        /**
+        * From CHTIServicePluginInterface
+        * Indicates to HTI Framework whether the plugin is ready to process
+        * a new message or if it's busy processing previous message.
+        * @return ETrue if processing, EFalse if ready for new request
+        */
+        TBool IsBusy();
+
+
+    protected:
+
+        CHtiPIMServicePlugin();
+        void ConstructL();
+
+        virtual ~CHtiPIMServicePlugin();
+
+    private:
+
+        CPIMHandler* iPimHandler;
+        CHtiBookmarkHandler* iBookmarkHandler;
+        CHtiSimDirHandlerVPbk* iSimDirHandler;
+        };
+
+#endif // CHTIPIMSERVICEPLUGIN_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiPIMServicePlugin/inc/HtiSimDirHandlerVPbk.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,255 @@
+/*
+* 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:  Class that handles SIM card contacts creation and deletion
+*                using the new Virtual Phonebook API
+*
+*/
+
+
+#ifndef HTISIMDIRHANDLERVPBK_H
+#define HTISIMDIRHANDLERVPBK_H
+
+
+// INCLUDES
+#include <MVPbkContactObserver.h>
+#include <MVPbkContactStoreObserver.h>
+#include <MVPbkContactViewObserver.h>
+#include <MVPbkBatchOperationObserver.h>
+//#include <MVPbkContactStoreListObserver.h>
+#include <HTIServicePluginInterface.h>
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+class CVPbkContactManager;
+class MVPbkContactStore;
+class MVPbkContactView;
+
+// CLASS DECLARATION
+
+/**
+*  Class that handles SIM card contacts creation and deletion using the
+*  new Virtual Phonebook API.
+*/
+class CHtiSimDirHandlerVPbk : public CBase,
+//                              public MVPbkContactStoreListObserver,
+                              public MVPbkContactStoreObserver,
+                              public MVPbkContactObserver,
+                              public MVPbkContactViewObserver,
+                              public MVPbkBatchOperationObserver
+    {
+    public:
+
+    enum TContactFieldType
+        {
+        ENameField        = 0x01,
+        ESecondNameField  = 0x02,
+        EPhoneNumberField = 0x03,
+        EEMailField       = 0x04,
+        EAdditNumberField = 0x05
+        };
+
+    public:
+
+        /**
+        * Two-phased constructor.
+        */
+        static CHtiSimDirHandlerVPbk* NewL();
+
+        /**
+        * Called when there is a message to be processed by this service.
+        * @param aMessage message body destinated to the servive
+        * @param aPriority message priority
+        */
+        void ProcessMessageL( const TDesC8& aMessage,
+            THtiMessagePriority aPriority );
+
+        /**
+        * Indicates whether this handler is ready to receive
+        * a new message or if it's busy processing previous message.
+        * @return ETrue if processing, EFalse if ready for new request
+        */
+        TBool IsBusy();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CHtiSimDirHandlerVPbk();
+
+        /**
+        * Sets the dispatcher to send outgoing messages to.
+        * @param aDispatcher pointer to dispatcher instance
+        */
+        void SetDispatcher( MHtiDispatcher* aDispatcher );
+
+    public: // Functions from base classes
+
+        // From MVPbkContactStoreListObserver
+
+        /**
+         * Called when the opening process is complete, ie. all stores
+         * have been reported either failed or successful open.
+         */
+        //void OpenComplete();
+
+        // From MVPbkContactStoreObserver
+
+        /**
+         * Called when a contact store is ready to use.
+         */
+        void StoreReady( MVPbkContactStore& aContactStore );
+
+        /**
+         * Called when a contact store becomes unavailable.
+         * @param aContactStore The store that became unavailable.
+         * @param aReason The reason why the store is unavailable.
+         *                This is one of the system wide error codes.
+         */
+        void StoreUnavailable( MVPbkContactStore& aContactStore, TInt aReason );
+
+        /**
+         * Called when changes occur in the contact store.
+         * @param aContactStore The store the event occurred in.
+         * @param aStoreEvent   Event that has occured.
+         */
+        void HandleStoreEventL( MVPbkContactStore& aContactStore,
+                                TVPbkContactStoreEvent aStoreEvent);
+
+        // From MVPbkContactObserver
+
+        /**
+         * Called when a contact operation has succesfully completed.
+         */
+        void ContactOperationCompleted( TContactOpResult aResult );
+
+        /**
+         * Called when a contact operation has failed.
+         */
+        void ContactOperationFailed( TContactOp aOpCode, TInt aErrorCode,
+                TBool aErrorNotified );
+
+        // From MVPbkContactViewObserver
+
+        /**
+         * Called when a view is ready for use.
+         */
+        void ContactViewReady( MVPbkContactViewBase& aView );
+
+        /**
+         * Called when a view is unavailable for a while.
+         */
+        void ContactViewUnavailable( MVPbkContactViewBase& aView );
+
+        /**
+         * Called when a contact has been added to the view.
+         */
+        void ContactAddedToView( MVPbkContactViewBase& aView,
+                                 TInt aIndex,
+                                 const MVPbkContactLink& aContactLink );
+
+        /**
+         * Called when a contact has been removed from a view.
+         */
+        void ContactRemovedFromView( MVPbkContactViewBase& aView,
+                                     TInt aIndex,
+                                     const MVPbkContactLink& aContactLink );
+
+        /**
+         * Called when an error occurs in the view.
+         */
+        void ContactViewError( MVPbkContactViewBase& aView,
+                               TInt aError,
+                               TBool aErrorNotified );
+
+        // From MVPbkBatchOperationObserver
+
+        /**
+         * Called when one step of the operation is complete
+         */
+        void StepComplete( MVPbkContactOperationBase& aOperation,
+                           TInt aStepSize );
+
+        /**
+         * Called when one step of the operation fails
+         */
+        TBool StepFailed( MVPbkContactOperationBase& aOperation,
+                          TInt aStepSize, TInt aError );
+
+        /**
+         * Called when operation is completed
+         */
+        void OperationComplete( MVPbkContactOperationBase& aOperation );
+
+
+    private: // constructors
+
+        /**
+        * C++ default constructor.
+        */
+        CHtiSimDirHandlerVPbk();
+
+        /**
+        * 2nd phase constructor.
+        */
+        void ConstructL();
+
+    private: // helpers
+
+        void HandleSimCardInfoL();
+        void HandleSimContactImportL();
+        void HandleSimContactDeleteL();
+
+        void DeleteContactsInViewL();
+        TBool CheckImportMsg();
+
+        void SendOkMsgL( const TDesC8& aData );
+        void SendErrorMessageL( TInt aError, const TDesC8& aDescription );
+
+    private: // data
+
+        // Pointer to the dispatcher (referenced)
+        MHtiDispatcher* iDispatcher;
+
+        // The contact manager
+        CVPbkContactManager* iContactManager;
+
+        // The SIM contact store (referenced)
+        MVPbkContactStore* iSimStore;
+
+        // The contact view
+        MVPbkContactViewBase* iContactView;
+
+        // The current/latest contact operation
+        MVPbkContactOperationBase* iCurrentOperation;
+
+        // The latest received command message without the command code
+        HBufC8* iMessage;
+
+        // The command code of the latest/current command
+        TUint8 iCommand;
+
+        // Flag indicating if service is busy processing a request
+        TBool iIsBusy;
+
+        TBool iIsStoreOpen;
+
+    };
+
+#endif // HTISIMDIRHANDLERVPBK_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiPIMServicePlugin/inc/PIMHandler.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,208 @@
+/*
+* 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:  Functional implentation of PIM service.
+*
+*/
+
+
+#ifndef CPIMHANDLER_H
+#define CPIMHANDLER_H
+
+// INCLUDES
+#include <e32base.h>
+#include <s32mem.h>
+#include <HTIServicePluginInterface.h>
+#include <MVPbkBatchOperationObserver.h>
+#include <MVPbkContactCopyObserver.h>
+#include <MVPbkContactStoreObserver.h>
+#include <MVPbkContactViewObserver.h>
+#include <calprogresscallback.h>
+
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class CVPbkContactManager;
+class CVPbkVCardEng;
+class CCalSession;
+class CCalEntryView;
+
+// CLASS DECLARATION
+
+/**
+*  Functional implentation of PIM service.
+*/
+class CPIMHandler : public CBase,
+                    public MVPbkContactStoreObserver,
+                    public MVPbkContactCopyObserver,
+                    public MVPbkContactViewObserver,
+                    public MVPbkBatchOperationObserver,
+                    public MCalProgressCallBack
+    {
+    public:
+
+        static CPIMHandler* NewL();
+
+        // Interface implementation
+        void ProcessMessageL( const TDesC8& aMessage,
+            THtiMessagePriority aPriority );
+
+        TBool IsBusy();
+
+        virtual ~CPIMHandler();
+
+        void SetDispatcher( MHtiDispatcher* aDispatcher );
+
+
+        // From MVPbkContactStoreObserver
+
+        /**
+         * Called when a contact store is ready to use.
+         */
+        void StoreReady( MVPbkContactStore& aContactStore );
+
+        /**
+         * Called when a contact store becomes unavailable.
+         * @param aContactStore The store that became unavailable.
+         * @param aReason The reason why the store is unavailable.
+         *                This is one of the system wide error codes.
+         */
+        void StoreUnavailable( MVPbkContactStore& aContactStore, TInt aReason );
+
+        /**
+         * Called when changes occur in the contact store.
+         * @param aContactStore The store the event occurred in.
+         * @param aStoreEvent   Event that has occured.
+         */
+        void HandleStoreEventL( MVPbkContactStore& aContactStore,
+                                TVPbkContactStoreEvent aStoreEvent);
+
+        // From MVPbkContactCopyObserver
+
+        /**
+         * Called when the contact has been successfully commited or
+         * copied. Caller takes the ownership of results.
+         * @param aOperation    The operation that this observer monitors.
+         * @param aResults  An array of links to copied contacts.
+         *                  Caller takes the ownership of the
+         *                  object immediately.
+         */
+        void ContactsSaved( MVPbkContactOperationBase& aOperation,
+            MVPbkContactLinkArray* aResults );
+
+        /**
+         * Called when there was en error while saving contact(s).
+         * @param aOperation    The operation that this observer monitors.
+         * @param aError an error that occured.
+         */
+        void ContactsSavingFailed(
+                MVPbkContactOperationBase& aOperation, TInt aError );
+
+        // From MVPbkContactViewObserver
+
+        /**
+         * Called when a view is ready for use.
+         */
+        void ContactViewReady( MVPbkContactViewBase& aView );
+
+        /**
+         * Called when a view is unavailable for a while.
+         */
+        void ContactViewUnavailable( MVPbkContactViewBase& aView );
+
+        /**
+         * Called when a contact has been added to the view.
+         */
+        void ContactAddedToView( MVPbkContactViewBase& aView,
+                                 TInt aIndex,
+                                 const MVPbkContactLink& aContactLink );
+
+        /**
+         * Called when a contact has been removed from a view.
+         */
+        void ContactRemovedFromView( MVPbkContactViewBase& aView,
+                                     TInt aIndex,
+                                     const MVPbkContactLink& aContactLink );
+
+        /**
+         * Called when an error occurs in the view.
+         */
+        void ContactViewError( MVPbkContactViewBase& aView,
+                               TInt aError,
+                               TBool aErrorNotified );
+
+        // From MVPbkBatchOperationObserver
+
+        /**
+         * Called when one step of the operation is complete
+         */
+        void StepComplete( MVPbkContactOperationBase& aOperation,
+                           TInt aStepSize );
+
+        /**
+         * Called when one step of the operation fails
+         */
+        TBool StepFailed( MVPbkContactOperationBase& aOperation,
+                          TInt aStepSize, TInt aError );
+
+        /**
+         * Called when operation is completed
+         */
+        void OperationComplete( MVPbkContactOperationBase& aOperation );
+
+
+        // From MCalProgressCallBack
+
+        void Progress( TInt aPercentageCompleted );
+        void Completed( TInt aError );
+        TBool NotifyProgress();
+
+    private:
+
+        CPIMHandler();
+        void ConstructL();
+
+    private: // helpers
+
+        void HandleVCardImportFuncL( const TDesC8& aData );
+        void HandleVCalendarImportFuncL( const TDesC8& aData );
+        void HandleContactDeleteFuncL( const TDesC8& aData );
+        void HandleCalendarDeleteFuncL( const TDesC8& aData );
+        void HandleNotepadAddMemoFuncL( const TDesC8& aData );
+        void HandleNotepadAddMemoFromFileFuncL( const TDesC8& aData );
+        void HandleNotepadDeleteAllFuncL();
+        void CreateContactDeleteViewL();
+        void DeleteContactsInViewL();
+
+        void SendOkMsgL( const TDesC8& aData );
+        void SendNotepadOkMsgL( CHtiPIMServicePlugin::TCommand aCommand );
+        void SendErrorMessageL( TInt aError, const TDesC8& aDescription );
+
+    private: // data
+        TUint8                iCommand;
+        TBool                 iIsBusy;
+        CBufFlat*             iBuffer;
+        RBufReadStream        iReadStream;
+        CCalSession*          iCalSession;
+        CCalEntryView*        iEntryView;
+        CVPbkContactManager*  iContactManager;
+        CVPbkVCardEng*        iVCardEngine;
+        MVPbkContactStore*    iContactStore;
+        MVPbkContactOperationBase* iOp;
+        MVPbkContactViewBase* iContactView;
+        MHtiDispatcher*       iDispatcher; // referenced
+        CActiveSchedulerWait* iWaiter;
+        TInt                  iEntryViewErr;
+    };
+
+#endif // CPIMHANDLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiPIMServicePlugin/src/HtiBookmarkHandler.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,702 @@
+/*
+* 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:  Implementation of browser bookmark handling.
+*
+*/
+
+
+// INCLUDE FILES
+#include "HtiBookmarkHandler.h"
+#include "HtiPIMServicePlugin.h"
+
+#include <cmconnectionmethod.h>
+#include <cmconnectionmethoddef.h>
+#include <cmdestination.h>
+#include <cmmanager.h>
+
+#include <FavouritesItem.h>
+#include <FavouritesItemList.h>
+#include <FavouritesDb.h>
+#include <FavouritesFile.h>
+#include <FavouritesWapAp.h>
+
+#include <HtiDispatcherInterface.h>
+#include <HTILogging.h>
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+_LIT8( KErrorUnrecognizedCommand, "Unrecognized command" );
+_LIT8( KErrorInvalidParameters, "Invalid command parameters" );
+_LIT8( KErrorCreateFailed, "Bookmark creation failed" );
+_LIT8( KErrorDeleteFailed, "Bookmark deletion failed" );
+_LIT8( KErrorBookmarkNotFound, "Bookmark not found" );
+_LIT8( KErrorFolderNotFound, "Folder not found" );
+_LIT8( KErrorApNotFound, "Access point not found" );
+_LIT8( KErrorFolderSearchFailed, "Error when searching folder" );
+_LIT8( KErrorApSearchFailed, "Error when searching access point" );
+
+const TInt KCreateMessageMinLength = 10;
+const TInt KDeleteMessageMinLength = 3;
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CHtiBookmarkHandler::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+CHtiBookmarkHandler* CHtiBookmarkHandler::NewL()
+    {
+    HTI_LOG_FUNC_IN( "CHtiBookmarkHandler::NewL" );
+    CHtiBookmarkHandler* self = new ( ELeave ) CHtiBookmarkHandler();
+    CleanupStack::PushL ( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    HTI_LOG_FUNC_OUT( "CHtiBookmarkHandler::NewL" );
+    return self;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiBookmarkHandler::CHtiBookmarkHandler
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// ----------------------------------------------------------------------------
+CHtiBookmarkHandler::CHtiBookmarkHandler()
+    {
+    HTI_LOG_FUNC_IN( "CHtiBookmarkHandler::CHtiBookmarkHandler" );
+    HTI_LOG_FUNC_OUT( "CHtiBookmarkHandler::CHtiBookmarkHandler" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiBookmarkHandler::~CHtiBookmarkHandler
+// Destructor.
+// -----------------------------------------------------------------------------
+CHtiBookmarkHandler::~CHtiBookmarkHandler()
+    {
+    HTI_LOG_FUNC_IN( "CHtiBookmarkHandler::~CHtiBookmarkHandler" );
+    delete iUrl;
+    iFavSession.Close();
+    HTI_LOG_FUNC_OUT( "CHtiBookmarkHandler::~CHtiBookmarkHandler" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiBookmarkHandler::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+void CHtiBookmarkHandler::ConstructL()
+    {
+    HTI_LOG_FUNC_IN( "CHtiBookmarkHandler::ConstructL" );
+    User::LeaveIfError( iFavSession.Connect() );
+    HTI_LOG_FUNC_OUT( "CHtiBookmarkHandler::ConstructL" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiBookmarkHandler::SetDispatcher
+// Sets the dispatcher pointer.
+// -----------------------------------------------------------------------------
+
+void CHtiBookmarkHandler::SetDispatcher( MHtiDispatcher* aDispatcher )
+    {
+    HTI_LOG_FUNC_IN( "CHtiBookmarkHandler::SetDispatcher" );
+    iDispatcher = aDispatcher;
+    HTI_LOG_FUNC_OUT( "CHtiBookmarkHandler::SetDispatcher" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiBookmarkHandler::ProcessMessageL
+// Parses the received message and calls handler functions.
+// -----------------------------------------------------------------------------
+void CHtiBookmarkHandler::ProcessMessageL( const TDesC8& aMessage,
+    THtiMessagePriority /*aPriority*/ )
+    {
+    HTI_LOG_FUNC_IN( "CHtiBookmarkHandler::ProcessMessageL" );
+    // Zero legth of aMessage tested already in CHtiPIMServicePlugin.
+    // Other sanity checks must be done here.
+    if ( aMessage[0] == CHtiPIMServicePlugin::ECreateBookmark )
+        {
+        TRAPD( err, ParseCreateMessageL( aMessage ) );
+        if ( err != KErrNone )
+            {
+            SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+            }
+        else
+            {
+            TRAP( err, HandleCreateBookmarkL() );
+            if ( err != KErrNone )
+                {
+                SendErrorMessageL( err, KErrorCreateFailed );
+                }
+            }
+        }
+
+    else if ( aMessage[0] == CHtiPIMServicePlugin::EDeleteBookmark )
+        {
+        TRAPD( err, ParseDeleteMessageL( aMessage ) );
+        if ( err != KErrNone )
+            {
+            SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+            }
+        else
+            {
+            TRAP( err, HandleDeleteBookmarkL() );
+            if ( err != KErrNone )
+                {
+                SendErrorMessageL( err, KErrorDeleteFailed );
+                }
+            }
+        }
+
+    else
+        {
+        SendErrorMessageL( KErrArgument, KErrorUnrecognizedCommand );
+        }
+    HTI_LOG_FUNC_OUT( "CHtiBookmarkHandler::ProcessMessageL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiBookmarkHandler::IsBusy
+// Returns the status whether this handler is busy processing a request.
+// ----------------------------------------------------------------------------
+TBool CHtiBookmarkHandler::IsBusy()
+    {
+    // Never busy if ProcessMessageL has completed.
+    return EFalse;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiBookmarkHandler::HandleCreateBookmarkL
+// Handles the bookmark and/or folder creation command.
+// ----------------------------------------------------------------------------
+void CHtiBookmarkHandler::HandleCreateBookmarkL()
+    {
+    HTI_LOG_FUNC_IN( "CHtiBookmarkHandler::HandleCreateBookmarkL" );
+    TInt err = KErrNone;
+    // If folder given, get the UID if it exists
+    TInt folderUid = KFavouritesRootUid;
+    if ( iFolderName.Length() > 0 )
+        {
+        TRAP( err, folderUid = GetFolderUidL( iFolderName ) );
+        if ( err != KErrNone )
+            {
+            SendErrorMessageL( err, KErrorFolderSearchFailed );
+            return;
+            }
+        }
+    HTI_LOG_FORMAT( "Folder UID = %d", folderUid );
+
+    // If access point given, search the UID. It's an error if AP is not found.
+    TInt apUid = KErrNotFound;
+    if ( iApName.Length() > 0 )
+        {
+        TRAP( err, apUid = GetApUidL( iApName ) );
+        if ( err != KErrNone )
+            {
+            SendErrorMessageL( err, KErrorApSearchFailed );
+            return;
+            }
+        if ( apUid == KErrNotFound )
+            {
+            SendErrorMessageL( KErrNotFound, KErrorApNotFound );
+            return;
+            }
+        }
+
+    RFavouritesDb db;
+    User::LeaveIfError( db.Open( iFavSession, KBrowserBookmarks ) );
+    CleanupClosePushL<RFavouritesDb>( db );
+
+    TInt itemsCreated = 0;
+    // If folder was given but was not found, create the folder first.
+    if ( iFolderName.Length() > 0 && folderUid == KErrNotFound )
+        {
+        CFavouritesItem* folder = CFavouritesItem::NewLC();
+        folder->SetType( CFavouritesItem::EFolder );
+        folder->SetParentFolder( KFavouritesRootUid ) ;
+        folder->SetNameL( iFolderName );
+
+        HTI_LOG_TEXT( "Adding the folder item to DB" );
+        err = db.Add( *folder, EFalse );
+        HTI_LOG_FORMAT( "Add returned %d", err );
+        if ( err != KErrNone )
+            {
+            User::Leave( err );
+            }
+        folderUid = folder->Uid();
+        HTI_LOG_FORMAT( "New folder UID = %d", folderUid );
+        CleanupStack::PopAndDestroy(); // folder
+        itemsCreated++;
+        }
+
+    // Now create the actual bookmark item
+    CFavouritesItem* item = CFavouritesItem::NewLC();
+    item->SetType( CFavouritesItem::EItem );
+    item->SetParentFolder( folderUid ) ;
+    item->SetNameL( iBookmarkName );
+    item->SetUrlL( *iUrl );
+    if ( apUid != KErrNotFound )
+        {
+        TFavouritesWapAp favAp;
+        favAp.SetApId(  ( TUint32 ) apUid );
+        item->SetWapAp( favAp );
+        }
+    if ( iUserName.Length() > 0 )
+        {
+        item->SetUserNameL( iUserName );
+        }
+    if ( iPassword.Length() > 0 )
+        {
+        item->SetPasswordL( iPassword );
+        }
+
+    HTI_LOG_TEXT( "Adding the bookmark item to DB" );
+    err = db.Add( *item, EFalse );
+    HTI_LOG_FORMAT( "Add returned %d", err );
+    if ( err )
+        {
+        User::Leave( err );
+        }
+    HTI_LOG_FORMAT( "Bookmark UID = %d", item->Uid() );
+    CleanupStack::PopAndDestroy(); // item
+    itemsCreated++;
+
+    CleanupStack::PopAndDestroy(); // db
+
+    TBuf8<1> response;
+    response.Append( itemsCreated );
+    SendOkMsgL( response );
+
+    HTI_LOG_FUNC_OUT( "CHtiBookmarkHandler::HandleCreateBookmarkL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiBookmarkHandler::HandleDeleteBookmarkL
+// Handles the bookmark and/or folder deletion.
+// ----------------------------------------------------------------------------
+void CHtiBookmarkHandler::HandleDeleteBookmarkL()
+    {
+    HTI_LOG_FUNC_IN( "CHtiBookmarkHandler::HandleDeleteBookmarkL" );
+    TInt err = KErrNone;
+    // If folder given, get the UID if it exists.
+    // It is an error if the given folder does not exist.
+    TInt folderUid = KFavouritesRootUid;
+    if ( iFolderName.Length() > 0 )
+        {
+        TRAP( err, folderUid = GetFolderUidL( iFolderName ) );
+        if ( err != KErrNone )
+            {
+            SendErrorMessageL( err, KErrorFolderSearchFailed );
+            return;
+            }
+        if ( folderUid == KErrNotFound )
+            {
+            SendErrorMessageL( KErrNotFound, KErrorFolderNotFound );
+            return;
+            }
+        }
+    HTI_LOG_FORMAT( "Folder UID = %d", folderUid );
+
+    RFavouritesDb db;
+    User::LeaveIfError( db.Open( iFavSession, KBrowserBookmarks ) );
+    CleanupClosePushL<RFavouritesDb>( db );
+
+    CArrayFixFlat<TInt>* deleteList = new ( ELeave ) CArrayFixFlat<TInt>( 10 );
+    CleanupStack::PushL( deleteList );
+    if ( iBookmarkName.Length() > 0 )
+        {
+        // Get the UID of bookmark item matching to iBookmarkName
+        // It is an error if nothing found.
+        CFavouritesItemList* items = new ( ELeave ) CFavouritesItemList();
+        CleanupStack::PushL( items );
+        User::LeaveIfError( db.GetAll( *items, folderUid,
+            CFavouritesItem::EItem ) );
+        TInt uid = KErrNotFound;
+        TInt itemCount = items->Count();
+        HTI_LOG_FORMAT( "Found %d items", itemCount );
+        TInt i = 0;
+        while ( uid == KErrNotFound && i < itemCount )
+            {
+            if ( ( *items )[i]->Name().CompareF( iBookmarkName ) == 0 )
+                {
+                uid = ( *items )[i]->Uid();
+                }
+            i++;
+            }
+        CleanupStack::PopAndDestroy(); // items
+        HTI_LOG_FORMAT( "Matching item UID: %d", uid );
+        if ( uid == KErrNotFound )
+            {
+            SendErrorMessageL( KErrNotFound, KErrorBookmarkNotFound );
+            CleanupStack::PopAndDestroy( 2 ); // deleteList, db
+            return;
+            }
+        else
+            {
+            deleteList->AppendL( uid );
+            }
+        }
+    else
+        {
+        // We are deleting a folder (whose UID we already have) or deleting all.
+        if ( folderUid != KFavouritesRootUid )
+            {
+            deleteList->AppendL( folderUid );
+            }
+        else
+            {
+            // We don't have folder or bookmark name - deleting all
+            User::LeaveIfError( db.GetUids( *deleteList, KFavouritesRootUid ) );
+            HTI_LOG_FORMAT( "Found %d matching items", deleteList->Count() );
+            }
+        }
+
+    TInt beginningCount = KErrNotFound;
+    User::LeaveIfError( db.Count( beginningCount ) );
+    HTI_LOG_FORMAT( "Items in DB before delete: %d", beginningCount );
+
+    // Start deleting
+    TInt deleteCount = 0;
+    for ( TInt i = 0; i < deleteList->Count(); i++ )
+        {
+        HTI_LOG_FORMAT( "Deleting with UID %d", ( *deleteList )[i] );
+        err = db.Delete( ( *deleteList )[i] );
+        HTI_LOG_FORMAT( "Delete returned %d", err );
+        if ( err == KErrNone )
+            {
+            deleteCount++;
+            }
+        if ( err != KErrNone && err != KErrAccessDenied )
+            {
+            HTI_LOG_TEXT( "Unexpected error when deleting - leaving" );
+            User::Leave( err );
+            }
+        }
+
+    TInt endingCount = KErrNotFound;
+    User::LeaveIfError( db.Count( endingCount ) );
+    HTI_LOG_FORMAT( "Items in DB after delete: %d", endingCount );
+
+    CleanupStack::PopAndDestroy( 2 ); // deleteList, db
+
+    TBuf8<1> response;
+    response.Append( beginningCount - endingCount );
+    SendOkMsgL( response );
+
+    HTI_LOG_FUNC_OUT( "CHtiBookmarkHandler::HandleDeleteBookmarkL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiBookmarkHandler::ParseCreateMessageL
+// Extracts the parameters from a create bookmark message.
+// ----------------------------------------------------------------------------
+void CHtiBookmarkHandler::ParseCreateMessageL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiBookmarkHandler::ParseCreateMessageL" );
+    TInt length = aMessage.Length();
+    HTI_LOG_FORMAT( "CreateBookmark message length = %d", length );
+
+    if ( length < KCreateMessageMinLength )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    // Extract folder name
+    TInt offset = 1; // skip the command code in position 0
+    offset = ExtractStringL( aMessage, offset, 1, 0, KFavouritesMaxName,
+                             iFolderName );
+    HTI_LOG_FORMAT( "Folder name: %S", &iFolderName );
+
+    // Extract bookmark name
+    offset = ExtractStringL( aMessage, offset, 1, 1, KFavouritesMaxName,
+                             iBookmarkName );
+    HTI_LOG_FORMAT( "Bookmark name: %S", &iBookmarkName );
+
+    // Extract URL
+    delete iUrl;
+    iUrl = NULL;
+    iUrl = HBufC::NewL( KFavouritesMaxUrl );
+    TPtr urlPtr = iUrl->Des();
+    offset = ExtractStringL( aMessage, offset, 2, 1, KFavouritesMaxUrl,
+                             urlPtr );
+    HTI_LOG_FORMAT( "URL: %S", iUrl );
+
+    // Extract AP name
+    offset = ExtractStringL( aMessage, offset, 1, 0, KApMaxConnNameLength,
+                             iApName );
+    HTI_LOG_FORMAT( "AP name: %S", &iApName );
+
+    // Extract user name
+    offset = ExtractStringL( aMessage, offset, 1, 0, KFavouritesMaxUserName,
+                             iUserName );
+    HTI_LOG_FORMAT( "User name: %S", &iUserName );
+
+    // Extract password
+    offset = ExtractStringL( aMessage, offset, 1, 0, KFavouritesMaxPassword,
+                             iPassword );
+    HTI_LOG_FORMAT( "Password: %S", &iPassword );
+
+    // Check that there's no extra data
+    if ( offset != length  )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiBookmarkHandler::ParseCreateMessageL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiBookmarkHandler::ParseDeleteMessageL
+// Extracts the parameters from a delete bookmark message.
+// ----------------------------------------------------------------------------
+void CHtiBookmarkHandler::ParseDeleteMessageL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiBookmarkHandler::ParseDeleteMessageL" );
+    TInt length = aMessage.Length();
+    HTI_LOG_FORMAT( "DeleteBookmark message length = %d", length );
+
+    if ( length < KDeleteMessageMinLength )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    // Extract folder name
+    TInt offset = 1; // skip the command code in position 0
+    offset = ExtractStringL( aMessage, offset, 1, 0, KFavouritesMaxName,
+                             iFolderName );
+    HTI_LOG_FORMAT( "Folder name: %S", &iFolderName );
+
+    // Extract bookmark name
+    offset = ExtractStringL( aMessage, offset, 1, 0, KFavouritesMaxName,
+                             iBookmarkName );
+    HTI_LOG_FORMAT( "Bookmark name: %S", &iBookmarkName );
+
+    HTI_LOG_FUNC_OUT( "CHtiBookmarkHandler::ParseDeleteMessageL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiBookmarkHandler::ExtractStringL
+// Extract one string from the given message. Leaves on syntax errors.
+// ----------------------------------------------------------------------------
+TInt CHtiBookmarkHandler::ExtractStringL( const TDesC8& aMessage, TInt aOffset,
+        TInt aLengthBytes, TInt aMinLength, TInt aMaxLength, TDes& aResult )
+    {
+    HTI_LOG_FUNC_IN( "CHtiBookmarkHandler::ExtractStringL" );
+    __ASSERT_ALWAYS( aResult.MaxLength() >= aMaxLength,
+                     User::Panic( _L( "HtiPimAssert" ), 1 ) );
+    __ASSERT_ALWAYS( aLengthBytes > 0, User::Panic( _L( "HtiPimAssert" ), 2 ) );
+
+    TInt length = aMessage.Length();
+    if ( length < aOffset + 1 )
+        {
+        User::Leave( KErrArgument );
+        }
+    TInt parseLength = aMessage[aOffset];
+    aOffset++;
+    if ( aLengthBytes > 1 )
+        {
+        for ( TInt i = 1; i < aLengthBytes; i++ )
+            {
+            parseLength += aMessage[aOffset] << ( i * 8 );
+            aOffset++;
+            }
+        }
+    HTI_LOG_FORMAT( "Parse length = %d", parseLength );
+    if ( parseLength < aMinLength  || parseLength > aMaxLength ||
+         parseLength + aOffset > length )
+        {
+        User::Leave( KErrArgument );
+        }
+    else
+        {
+        aResult.Copy( aMessage.Mid( aOffset, parseLength ) );
+        aOffset += parseLength;
+        }
+    HTI_LOG_FUNC_OUT( "CHtiBookmarkHandler::ExtractStringL" );
+    return aOffset;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiBookmarkHandler::GetFolderUidL
+// Finds the UID of the named folder if it exists.
+// ----------------------------------------------------------------------------
+TInt CHtiBookmarkHandler::GetFolderUidL( const TDesC& aFolderName )
+    {
+    HTI_LOG_FUNC_IN( "CHtiBookmarkHandler::GetFolderUidL" );
+    HTI_LOG_FORMAT( "Searching folder %S", &aFolderName );
+    RFavouritesDb db;
+    User::LeaveIfError( db.Open( iFavSession, KBrowserBookmarks ) );
+    CleanupClosePushL<RFavouritesDb>( db );
+
+    /* Doing the name matching ourselves 'cause giving the name match pattern
+     * parameter to GetAll or GetUids methods crashes the favourites server.
+     */
+    CFavouritesItemList* folders = new ( ELeave ) CFavouritesItemList();
+    CleanupStack::PushL( folders );
+    User::LeaveIfError( db.GetAll( *folders, KFavouritesNullUid,
+        CFavouritesItem::EFolder ) );
+    TInt uid = KErrNotFound;
+    TInt folderCount = folders->Count();
+    HTI_LOG_FORMAT( "Found %d folders", folderCount );
+    TInt i = 0;
+    while ( uid == KErrNotFound && i < folderCount )
+        {
+        if ( ( *folders )[i]->Name().CompareF( aFolderName ) == 0 )
+            {
+            uid = ( *folders )[i]->Uid();
+            }
+        i++;
+        }
+
+    CleanupStack::PopAndDestroy( 2 ); // folders, db
+    HTI_LOG_FORMAT( "Matching UID: %d", uid );
+    HTI_LOG_FUNC_OUT( "CHtiBookmarkHandler::GetFolderUidL" );
+    return uid;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiBookmarkHandler::GetApUidL
+// Gets the WAP Access Point ID of access point named by iConnName.
+// Favourites item needs the WAP ID for identifying access point.
+// Returns KErrNotFound if AP not found.
+// ----------------------------------------------------------------------------
+TInt CHtiBookmarkHandler::GetApUidL( const TDesC& aApName )
+    {
+    HTI_LOG_FUNC_IN( "CHtiBookmarkHandler::GetApUidL" );
+    TInt uid = KErrNotFound;
+
+    RCmManager cmManager;
+    cmManager.OpenL();
+    CleanupClosePushL( cmManager );
+
+    // Search from uncategorised first
+    RArray<TUint32> array = RArray<TUint32>();
+    cmManager.ConnectionMethodL( array );
+    CleanupClosePushL( array );
+    TInt i = 0;
+    while ( i < array.Count() && uid == KErrNotFound )
+        {
+        RCmConnectionMethod cm = cmManager.ConnectionMethodL( array[i] );
+        CleanupClosePushL( cm );
+        HBufC* name = cm.GetStringAttributeL( CMManager::ECmName );
+        HTI_LOG_FORMAT( "Found name: %S", name );
+        CleanupStack::PushL( name );
+        if ( aApName.Compare( *name ) == 0 )
+            {
+            uid = cm.GetIntAttributeL( CMManager::ECmWapId );
+            HTI_LOG_FORMAT( "Match: UID = %d", uid );
+            }
+        CleanupStack::PopAndDestroy(); // name
+        CleanupStack::PopAndDestroy(); // cm
+        i++;
+        }
+    CleanupStack::PopAndDestroy(); // array
+
+    // If not found from uncategorised, search from all destinations
+    if ( uid == KErrNotFound )
+        {
+        HTI_LOG_TEXT( "Not found from uncategorised" );
+        RArray<TUint32> destIdArray = RArray<TUint32>();
+        cmManager.AllDestinationsL( destIdArray );
+        CleanupClosePushL( destIdArray );
+        i = 0;
+        while ( i < destIdArray.Count() && uid == KErrNotFound )
+            {
+            RCmDestination dest = cmManager.DestinationL( destIdArray[i] );
+            CleanupClosePushL( dest );
+            TInt j = 0;
+            while ( j < dest.ConnectionMethodCount() && uid == KErrNotFound )
+                {
+                HBufC* name = dest.ConnectionMethodL( j ).GetStringAttributeL(
+                        CMManager::ECmName );
+                CleanupStack::PushL( name );
+                HTI_LOG_FORMAT( "Found name: %S", name );
+                if ( aApName.Compare( *name ) == 0 )
+                    {
+                    uid = dest.ConnectionMethodL( j ).GetIntAttributeL(
+                            CMManager::ECmWapId );
+                    HTI_LOG_FORMAT( "Match: UID = %d", uid );
+                    }
+                CleanupStack::PopAndDestroy(); // name
+                j++;
+                }
+            CleanupStack::PopAndDestroy(); // dest
+            i++;
+            }
+        CleanupStack::PopAndDestroy(); // destIdArray
+        }
+
+    CleanupStack::PopAndDestroy(); // cmManager
+    HTI_LOG_FUNC_OUT( "CHtiBookmarkHandler::GetApUidL" );
+    return uid;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiBookmarkHandler::SendOkMsgL
+// Helper function for sending response messages.
+// ----------------------------------------------------------------------------
+void CHtiBookmarkHandler::SendOkMsgL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CHtiBookmarkHandler::SendOkMsgL" );
+    User::LeaveIfNull( iDispatcher );
+    HBufC8* temp = HBufC8::NewL( aData.Length() + 1 );
+    TPtr8 response = temp->Des();
+    response.Append( ( TChar ) CHtiPIMServicePlugin::EResultOk );
+    response.Append( aData );
+    User::LeaveIfError( iDispatcher->DispatchOutgoingMessage(
+        temp, KPIMServiceUid ) );
+    HTI_LOG_FUNC_OUT( "CHtiBookmarkHandler::SendOkMsgL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiBookmarkHandler::SendErrorMessageL
+// Helper function for sending error response messages.
+// ----------------------------------------------------------------------------
+void CHtiBookmarkHandler::SendErrorMessageL( TInt aError,
+        const TDesC8& aDescription )
+    {
+    HTI_LOG_FUNC_IN( "CHtiBookmarkHandler::SendErrorMessageL" );
+    User::LeaveIfNull( iDispatcher );
+    User::LeaveIfError( iDispatcher->DispatchOutgoingErrorMessage(
+        aError, aDescription, KPIMServiceUid ) );
+    HTI_LOG_FUNC_OUT( "CHtiBookmarkHandler::SendErrorMessageL" );
+    }
+
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiPIMServicePlugin/src/HtiNpdHlp.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,237 @@
+/*
+* 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:  HtiNpdHlp implementation.
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <NpdApi.h>
+#include <eikenv.h>
+
+
+#ifdef __ENABLE_LOGGING__
+
+#include <flogger.h>
+_LIT( KLogFolder, "hti" );
+_LIT( KLogFile,   "HtiNpdHlp.txt" );
+
+#define HTI_LOG_TEXT(a1) {_LIT(temp, a1); RFileLogger::Write(KLogFolder, KLogFile, EFileLoggingModeAppend, temp);}
+#define HTI_LOG_DES(a1) {RFileLogger::Write(KLogFolder, KLogFile, EFileLoggingModeAppend, a1);}
+#define HTI_LOG_FORMAT(a1,a2) {_LIT(temp, a1); RFileLogger::WriteFormat(KLogFolder, KLogFile, EFileLoggingModeAppend, temp, (a2));}
+
+_LIT8(KFuncIn, "-=> %S");
+_LIT8(KFuncOut, "<=- %S");
+
+#define HTI_LOG_FUNC_IN(a1) {_LIT8(temp, a1); RFileLogger::WriteFormat(KLogFolder, KLogFile, EFileLoggingModeAppend, KFuncIn, &temp);}
+#define HTI_LOG_FUNC_OUT(a1) {_LIT8(temp, a1); RFileLogger::WriteFormat(KLogFolder, KLogFile, EFileLoggingModeAppend, KFuncOut, &temp);}
+
+#else   // !__ENABLE_LOGGING__
+
+#define HTI_LOG_TEXT(a1)
+#define HTI_LOG_DES(a1)
+#define HTI_LOG_FORMAT(a1,a2)
+#define HTI_LOG_FUNC_IN(a1)
+#define HTI_LOG_FUNC_OUT(a1)
+
+#endif // __ENABLE_LOGGING__
+
+// CONSTANTS
+_LIT( KHtiNpdHlp, "HtiNpdHlp" );
+
+_LIT( KCmdAddMemo,         "AddMemo" );
+_LIT( KCmdAddMemoFromFile, "AddMemoFromFile" );
+_LIT( KCmdDeleteAll,       "DeleteAll" );
+
+_LIT( KNotepadDatabaseFile, "c:\\Private\\100012a5\\DBS_101F8878_Notepad.dat" );
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================ LOCAL FUNCTIONS ===============================
+void HandleAddMemoL( TLex& aParser )
+    {
+    HTI_LOG_FUNC_IN( "HandleAddMemoL" );
+
+    aParser.SkipSpace();
+    TPtrC text = aParser.Remainder();
+
+    if ( text.Length() == 0 )
+        {
+        HTI_LOG_TEXT( "missing text arg" );
+        User::Leave(KErrArgument);
+        }
+
+    // NOTE: We need to create CCoeEnv to make CNotepadApi work.
+    // This also creates a new cleaupstack so we need to destory
+    // CCoeEnv's cleanupstack before leaving to make our cleanupstack
+    // the topmost stack
+
+    CCoeEnv* env = new CCoeEnv;
+    TRAPD( err, env->ConstructL() );
+    if ( err )
+        {
+        HTI_LOG_FORMAT( "CEikonEnv::ConstructL err %d", err );
+        User::Leave( err );
+        }
+
+    TRAP( err, CNotepadApi::AddContentL( text ) );
+    if ( err )
+        {
+        HTI_LOG_FORMAT( "CNotepadApi::AddContentL err %d", err );
+        env->DestroyEnvironment();
+        User::Leave( err );
+        }
+
+    env->DestroyEnvironment();
+
+    HTI_LOG_FUNC_OUT( "HandleAddMemoL" );
+    }
+
+
+void HandleAddMemoFromFileL( TLex& aParser )
+    {
+    HTI_LOG_FUNC_IN( "HandleAddMemoFromFileL" );
+
+    aParser.SkipSpaceAndMark();
+    aParser.SkipCharacters();
+    if ( aParser.TokenLength() <= 0 )
+        {
+        User::Leave(KErrArgument);
+        }
+
+    TPtrC filename = aParser.MarkedToken();
+
+    /*
+    NOTE: Maybe will add this later
+
+    aParser.SkipSpaceAndMark();
+    aParser.SkipCharacters();
+
+    TPtrC encoding = KNullDesC;
+    if ( aParser.TokenLength() > 0 )
+        {
+        encoding.Set( aParser.MarkedToken() );
+        }
+    */
+
+    CCoeEnv* env = new CCoeEnv;
+    TRAPD( err, env->ConstructL() );
+    if ( err )
+        {
+        HTI_LOG_FORMAT( "CEikonEnv::ConstructL err %d", err );
+        User::Leave( err );
+        }
+
+    TRAP( err, CNotepadApi::SaveFileAsMemoL( filename ) );
+    if ( err )
+        {
+        HTI_LOG_FORMAT( "CNotepadApi::SaveFileAsMemoL err %d", err );
+        env->DestroyEnvironment();
+        User::Leave( err );
+        }
+
+    env->DestroyEnvironment();
+
+    HTI_LOG_FUNC_OUT( "HandleAddMemoFromFileL" );
+    }
+
+void HandleDeleteAllL()
+    {
+    HTI_LOG_FUNC_IN( "HandleDeleteAllL" );
+    TInt err = KErrNone;
+    RFs fs;
+    err = fs.Connect();
+    if ( err == KErrNone )
+        {
+        err = fs.Delete( KNotepadDatabaseFile );
+        fs.Close();
+        }
+    if ( err != KErrNone && err != KErrNotFound )
+        {
+        HTI_LOG_FORMAT( "Notepad database delete failed %d", err );
+        User::Leave( err );
+        }
+    HTI_LOG_FUNC_OUT( "HandleDeleteAllL" );
+    }
+
+
+LOCAL_C TInt StartL()
+    {
+    HTI_LOG_FUNC_IN( "StartL" );
+    TInt cmdLen = User::CommandLineLength();
+    HBufC* cmdLine = HBufC::NewLC( cmdLen );
+    TPtr ptCmdLine = cmdLine->Des();
+    User::CommandLine( ptCmdLine );
+
+    HTI_LOG_DES( *cmdLine );
+
+    //parse command line
+    TLex parser( *cmdLine );
+    parser.SkipCharacters();
+
+    if ( parser.TokenLength() <= 0 )
+        {
+        HTI_LOG_TEXT( "missing arguments" );
+        User::Leave( KErrArgument );
+        }
+
+
+    TPtrC cmd = parser.MarkedToken();
+
+    if ( cmd == KCmdAddMemo )
+        {
+        HandleAddMemoL( parser );
+        }
+    else if ( cmd == KCmdAddMemoFromFile )
+        {
+        HandleAddMemoFromFileL( parser );
+        }
+    else if ( cmd == KCmdDeleteAll )
+        {
+        HandleDeleteAllL();
+        }
+    else
+        {
+        HTI_LOG_TEXT( "Unknown argument" );
+        User::Leave( KErrArgument );
+        }
+
+    CleanupStack::PopAndDestroy(); // cmdLine
+    HTI_LOG_FUNC_OUT( "StartL" );
+    return KErrNone;
+    }
+
+
+GLDEF_C TInt E32Main()
+    {
+    __UHEAP_MARK;
+    CTrapCleanup* cleanup = CTrapCleanup::New();
+    User::RenameThread( KHtiNpdHlp );
+    TRAPD( err, StartL() );
+    delete cleanup;
+   __UHEAP_MARKEND;
+    return err;
+    }
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiPIMServicePlugin/src/HtiPIMServicePlugin.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,128 @@
+/*
+* 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:  PIMServicePlugin implementation
+*
+*/
+
+
+// INCLUDE FILES
+#include "HtiPIMServicePlugin.h"
+#include "PIMHandler.h"
+#include "HtiBookmarkHandler.h"
+#include "HtiSimDirHandlerVPbk.h"
+
+#include <HtiDispatcherInterface.h>
+#include <HTILogging.h>
+
+// CONSTANTS
+_LIT8( KErrorMissingCommand, "Command was not given - message was empty" );
+
+// ----------------------------------------------------------------------------
+// Create instance of concrete ECOM interface implementation
+CHtiPIMServicePlugin* CHtiPIMServicePlugin::NewL()
+    {
+    CHtiPIMServicePlugin* self = new (ELeave) CHtiPIMServicePlugin;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+CHtiPIMServicePlugin::CHtiPIMServicePlugin()
+    {
+    }
+
+// ----------------------------------------------------------------------------
+CHtiPIMServicePlugin::~CHtiPIMServicePlugin()
+    {
+    HTI_LOG_TEXT("CHtiPIMServicePlugin destroy");
+    delete iPimHandler;
+    delete iBookmarkHandler;
+    delete iSimDirHandler;
+    }
+
+// ----------------------------------------------------------------------------
+void CHtiPIMServicePlugin::ConstructL()
+    {
+    HTI_LOG_TEXT("CHtiPIMServicePlugin::ConstructL");
+    }
+
+// ----------------------------------------------------------------------------
+void CHtiPIMServicePlugin::ProcessMessageL( const TDesC8& aMessage,
+    THtiMessagePriority aPriority )
+    {
+    HTI_LOG_FUNC_IN( "CHtiPIMServicePlugin::ProcessMessageL" );
+    HTI_LOG_FORMAT( "Msg len: %d.", aMessage.Length() );
+
+    if ( aMessage.Length() == 0 )
+        {
+        User::LeaveIfError( iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument, KErrorMissingCommand, KPIMServiceUid ) );
+        return;
+        }
+
+    TUint8 aCommand = aMessage.Ptr()[0];
+    if ( aCommand < ESimCardInfo )
+        {
+        if ( iPimHandler == NULL )
+            {
+            iPimHandler = CPIMHandler::NewL();
+            iPimHandler->SetDispatcher( iDispatcher );
+            }
+        iPimHandler->ProcessMessageL( aMessage, aPriority );
+        }
+    else if ( aCommand < ECreateBookmark )
+        {
+        if ( iSimDirHandler == NULL )
+            {
+            iSimDirHandler = CHtiSimDirHandlerVPbk::NewL();
+            iSimDirHandler->SetDispatcher( iDispatcher );
+            }
+        iSimDirHandler->ProcessMessageL( aMessage, aPriority );
+        }
+    else
+        {
+        if ( iBookmarkHandler == NULL )
+            {
+            iBookmarkHandler = CHtiBookmarkHandler::NewL();
+            iBookmarkHandler->SetDispatcher( iDispatcher );
+            }
+        iBookmarkHandler->ProcessMessageL( aMessage, aPriority );
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiPIMServicePlugin::ProcessMessageL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+TBool CHtiPIMServicePlugin::IsBusy()
+    {
+    if ( iPimHandler )
+        {
+        if ( iPimHandler->IsBusy() )
+            return ETrue;
+        }
+    if ( iSimDirHandler )
+        {
+        if ( iSimDirHandler->IsBusy() )
+            return ETrue;
+        }
+    if ( iBookmarkHandler )
+        {
+        if ( iBookmarkHandler->IsBusy() )
+            return ETrue;
+        }
+    return EFalse;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiPIMServicePlugin/src/HtiSimDirHandlerVPbk.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,1002 @@
+/*
+* 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:  Implementation of SIM card contacts handling using the new
+*                Virtual Phonebook API
+*
+*/
+
+
+// INCLUDE FILES
+#include "HtiSimDirHandlerVPbk.h"
+#include "HtiPIMServicePlugin.h"
+
+#include <CVPbkContactManager.h>
+#include <CVPbkContactLinkArray.h>
+#include <CVPbkContactStoreUriArray.h>
+#include <CVPbkContactViewDefinition.h>
+#include <CVPbkSortOrder.h>
+#include <MVPbkContactFieldTextData.h>
+#include <MVPbkContactLink.h>
+#include <MVPbkContactOperationBase.h>
+#include <MVPbkContactStore.h>
+#include <MVPbkContactStoreInfo.h>
+#include <MVPbkContactStoreList.h>
+#include <MVPbkContactStoreProperties.h>
+#include <MVPbkContactView.h>
+#include <MVPbkContactViewBase.h>
+#include <MVPbkFieldType.h>
+#include <MVPbkStoreContact.h>
+#include <MVPbkStoreContactField.h>
+#include <MVPbkContactStoreObserver.h>
+#include <TVPbkContactStoreUriPtr.h>
+#include <TVPbkFieldVersitProperty.h>
+#include <VPbkContactStoreUris.h>
+#include <VPbkContactView.hrh>
+#include <VPbkFieldType.hrh>
+#include <VPbkEng.rsg>
+
+#include <HtiDispatcherInterface.h>
+#include <HTILogging.h>
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES
+
+// CONSTANTS
+const TInt KSimInfoResponseLength = 12;
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+_LIT8( KErrorUnrecognizedCommand, "Unrecognized command" );
+_LIT8( KErrorInvalidParameters, "Invalid command parameters" );
+_LIT8( KErrorImportFailed, "Contact import failed" );
+_LIT8( KErrorDeleteFailed, "Failed to delete contact" );
+_LIT8( KErrorSimCardInfoFailed, "Failed to get SIM card info" );
+_LIT8( KErrorSimStoreOpenFailed, "Failed to open SIM contact store" );
+_LIT8( KErrorSimStoreUnavailable, "SIM contact store unavailable" );
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+CHtiSimDirHandlerVPbk* CHtiSimDirHandlerVPbk::NewL()
+    {
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::NewL" );
+    CHtiSimDirHandlerVPbk* self = new (ELeave) CHtiSimDirHandlerVPbk();
+    CleanupStack::PushL ( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    HTI_LOG_FUNC_OUT( "CHtiSimDirHandlerVPbk::NewL" );
+    return self;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::CHtiSimDirHandlerVPbk
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// ----------------------------------------------------------------------------
+CHtiSimDirHandlerVPbk::CHtiSimDirHandlerVPbk():iIsBusy( EFalse ),
+                                               iIsStoreOpen( EFalse )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::CHtiSimDirHandlerVPbk" );
+
+    HTI_LOG_FUNC_OUT( "CHtiSimDirHandlerVPbk::CHtiSimDirHandlerVPbk" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::~CHtiSimDirHandlerVPbk
+// Destructor.
+// -----------------------------------------------------------------------------
+CHtiSimDirHandlerVPbk::~CHtiSimDirHandlerVPbk()
+    {
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::~CHtiSimDirHandlerVPbk" );
+
+    if ( iContactView )
+        {
+        HTI_LOG_TEXT( "Deleting iContactView" );
+        iContactView->RemoveObserver( *this );
+        delete iContactView;
+        }
+    if ( iSimStore )
+        {
+        HTI_LOG_TEXT( "Closing iSimStore" );
+        iSimStore->Close( *this );
+        }
+    if ( iContactManager )
+        {
+        HTI_LOG_TEXT( "Deleting iContactManager" );
+        delete iContactManager;
+        }
+    if ( iMessage )
+        {
+        HTI_LOG_TEXT( "Deleting iMessage" );
+        delete iMessage;
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiSimDirHandlerVPbk::~CHtiSimDirHandlerVPbk" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+void CHtiSimDirHandlerVPbk::ConstructL()
+    {
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::ConstructL" );
+
+    CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewLC();
+    uriArray->AppendL( TVPbkContactStoreUriPtr(
+        VPbkContactStoreUris::SimGlobalAdnUri() ) );
+
+    iContactManager = CVPbkContactManager::NewL( *uriArray );
+    CleanupStack::PopAndDestroy( uriArray );
+
+    MVPbkContactStoreList& storeList = iContactManager->ContactStoresL();
+    iSimStore = storeList.Find( TVPbkContactStoreUriPtr(
+        VPbkContactStoreUris::SimGlobalAdnUri() ) );
+
+    if ( !iSimStore )
+        {
+        HTI_LOG_TEXT( "SIM ADN store not found - leaving" );
+        User::Leave( KErrNotFound );
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiSimDirHandlerVPbk::ConstructL" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::SetDispatcher
+// Sets the dispatcher pointer.
+// -----------------------------------------------------------------------------
+
+void CHtiSimDirHandlerVPbk::SetDispatcher( MHtiDispatcher* aDispatcher )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::SetDispatcher" );
+    iDispatcher = aDispatcher;
+    HTI_LOG_FUNC_OUT( "CHtiSimDirHandlerVPbk::SetDispatcher" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::ProcessMessageL
+// Parses the received message and calls handler functions.
+// -----------------------------------------------------------------------------
+void CHtiSimDirHandlerVPbk::ProcessMessageL( const TDesC8& aMessage,
+    THtiMessagePriority /*aPriority*/ )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::ProcessMessageL" );
+
+    if ( iIsBusy )
+        {
+        HTI_LOG_TEXT( "HtiSimDirHandlerVPbk is busy - leaving" );
+        User::Leave( KErrInUse );
+        }
+
+    // Will be set to EFalse in the SendOkMsgL or SendErrorMessageL methods.
+    iIsBusy = ETrue;
+
+    delete iMessage;
+    iMessage = NULL;
+
+    // Zero legth of aMessage tested already in CHtiPIMServicePlugin.
+    // Other sanity checks must be done here.
+
+    // Trap the AllocL to be able to set iIsBusy false before leaving.
+    TRAPD( err, iMessage = aMessage.Right( aMessage.Length() - 1 ).AllocL() );
+    if ( err != KErrNone )
+        {
+        iIsBusy = EFalse;
+        User::Leave( err );
+        }
+
+    iCommand = aMessage.Ptr()[0];
+
+    // Do basic validity checking for message
+    TBool isParamsOk = ETrue;
+    switch ( iCommand )
+        {
+        case CHtiPIMServicePlugin::ESimCardInfo:
+            {
+            if ( iMessage->Length() != 0 )
+                {
+                isParamsOk = EFalse;
+                }
+            break;
+            }
+        case CHtiPIMServicePlugin::EImportSimContact:
+            {
+            if ( !CheckImportMsg() )
+                {
+                isParamsOk = EFalse;
+                }
+            break;
+            }
+        case CHtiPIMServicePlugin::EDeleteSimContact:
+            {
+            if ( iMessage->Length() != 4 && iMessage->Length() != 0 )
+                {
+                isParamsOk = EFalse;
+                }
+            break;
+            }
+        default:
+            {
+            SendErrorMessageL( KErrArgument, KErrorUnrecognizedCommand );
+            return;
+            }
+        }
+
+    if ( !isParamsOk )
+        {
+        SendErrorMessageL( KErrArgument, KErrorInvalidParameters );
+        }
+
+    else
+        {
+        if ( iIsStoreOpen )
+            {
+            StoreReady( *iSimStore );
+            }
+        else
+            {
+            // Start async open operation.
+            // StoreReady callback will be called when opening is complete.
+            TRAPD( err, iSimStore->OpenL( *this ) );
+            if ( err != KErrNone )
+                {
+                HTI_LOG_FORMAT(
+                        "Leave from CHtiSimDirHandler::OpenL() %d", err );
+                SendErrorMessageL( err, KErrorSimStoreOpenFailed );
+                }
+            }
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiSimDirHandlerVPbk::ProcessMessageL" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::IsBusy
+// -----------------------------------------------------------------------------
+//
+TBool CHtiSimDirHandlerVPbk::IsBusy()
+    {
+    return iIsBusy;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::OpenComplete
+// Called when the opening process is complete.
+// From MVPbkContactStoreListObserver
+// ----------------------------------------------------------------------------
+/*
+void CHtiSimDirHandlerVPbk::OpenComplete()
+    {
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::OpenComplete" );
+
+    HTI_LOG_FUNC_OUT( "CHtiSimDirHandlerVPbk::OpenComplete" );
+    }
+*/
+
+// ----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::StoreReady
+// Called when a contact store is ready to use.
+// From MVPbkContactStoreObserver
+// ----------------------------------------------------------------------------
+void CHtiSimDirHandlerVPbk::StoreReady( MVPbkContactStore& aContactStore )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::StoreReady" );
+
+    if ( !iIsBusy || iSimStore != &aContactStore )
+        {
+        return;
+        }
+
+    iIsStoreOpen = ETrue;
+
+    if ( iCommand == CHtiPIMServicePlugin::ESimCardInfo )
+        {
+        TRAPD( err, HandleSimCardInfoL() );
+        if ( err != KErrNone )
+            {
+            TRAP_IGNORE( SendErrorMessageL( err, KErrorSimCardInfoFailed ) );
+            }
+        }
+
+    else if ( iCommand == CHtiPIMServicePlugin::EImportSimContact )
+        {
+        TRAPD( err, HandleSimContactImportL() );
+        if ( err != KErrNone )
+            {
+            TRAP_IGNORE( SendErrorMessageL( err, KErrorImportFailed ) );
+            }
+        }
+
+    else if ( iCommand == CHtiPIMServicePlugin::EDeleteSimContact )
+        {
+        TRAPD( err, HandleSimContactDeleteL() );
+        if ( err != KErrNone )
+            {
+            TRAP_IGNORE( SendErrorMessageL( err, KErrorDeleteFailed ) );
+            }
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiSimDirHandlerVPbk::StoreReady" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::StoreUnavailable
+// Called when a contact store becomes unavailable.
+// From MVPbkContactStoreObserver
+// ----------------------------------------------------------------------------
+void CHtiSimDirHandlerVPbk::StoreUnavailable( MVPbkContactStore& aContactStore,
+                                              TInt aReason )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::StoreUnavailable" );
+
+    if ( iIsBusy && iSimStore == &aContactStore )
+        {
+        TRAP_IGNORE( SendErrorMessageL( aReason, KErrorSimStoreUnavailable ) );
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiSimDirHandlerVPbk::StoreUnavailable" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::HandleStoreEventL
+// Called when changes occur in the contact store.
+// From MVPbkContactStoreObserver
+// ----------------------------------------------------------------------------
+void CHtiSimDirHandlerVPbk::HandleStoreEventL( MVPbkContactStore& aContactStore,
+                        TVPbkContactStoreEvent aStoreEvent )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::HandleStoreEventL" );
+
+    if ( iIsBusy && iSimStore == &aContactStore &&
+         aStoreEvent.iEventType == TVPbkContactStoreEvent::EContactAdded )
+        {
+        HTI_LOG_TEXT( "Contact added" );
+        TInt entryId = 0;
+        TBuf8<4> idBuf;
+        idBuf.Append( ( TUint8* ) &entryId, 4 );
+        TRAP_IGNORE( SendOkMsgL( idBuf ) );
+        }
+
+    else if ( iIsBusy && iSimStore == &aContactStore &&
+              aStoreEvent.iEventType == TVPbkContactStoreEvent::EContactDeleted )
+        {
+        HTI_LOG_TEXT( "Contact deleted" );
+        if ( iMessage->Length() > 0 )  // This is a single deletion
+            {
+            TRAP_IGNORE( SendOkMsgL( KNullDesC8 ) );
+            }
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiSimDirHandlerVPbk::HandleStoreEventL" );
+    }
+
+// ----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::ContactOperationCompleted
+// Called when a contact operation has succesfully completed.
+// From MVPbkContactObserver
+// ----------------------------------------------------------------------------
+void CHtiSimDirHandlerVPbk::ContactOperationCompleted( TContactOpResult /*aResult*/ )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::ContactOperationCompleted" );
+
+    HTI_LOG_FUNC_OUT( "CHtiSimDirHandlerVPbk::ContactOperationCompleted" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::ContactOperationFailed
+// Called when a contact operation has failed.
+// From MVPbkContactObserver
+// ----------------------------------------------------------------------------
+void CHtiSimDirHandlerVPbk::ContactOperationFailed( TContactOp /*aOpCode*/,
+                                                    TInt /*aErrorCode*/,
+                                                    TBool /*aErrorNotified*/ )
+    {
+
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::ContactOperationFailed" );
+
+    HTI_LOG_FUNC_OUT( "CHtiSimDirHandlerVPbk::ContactOperationFailed" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::ContactViewReady
+// Called when a view is ready for use.
+// From MVPbkContactViewObserver
+// ----------------------------------------------------------------------------
+void CHtiSimDirHandlerVPbk::ContactViewReady( MVPbkContactViewBase& aView )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::ContactViewReady" );
+
+    if ( iContactView == &aView && iIsBusy &&
+            iCommand == CHtiPIMServicePlugin::EDeleteSimContact )
+        {
+        TRAPD( err, DeleteContactsInViewL() );
+        if ( err != KErrNone )
+            {
+            TRAP_IGNORE( SendErrorMessageL( err, KErrorDeleteFailed ) );
+            }
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiSimDirHandlerVPbk::ContactViewReady" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::ContactViewUnavailable
+// Called when a view is unavailable for a while.
+// From MVPbkContactViewObserver
+// ----------------------------------------------------------------------------
+void CHtiSimDirHandlerVPbk::ContactViewUnavailable( MVPbkContactViewBase& /*aView*/ )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::ContactViewUnavailable" );
+
+    HTI_LOG_FUNC_OUT( "CHtiSimDirHandlerVPbk::ContactViewUnavailable" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::ContactAddedToView
+// Called when a contact has been added to the view.
+// From MVPbkContactViewObserver
+// ----------------------------------------------------------------------------
+void CHtiSimDirHandlerVPbk::ContactAddedToView( MVPbkContactViewBase& /*aView*/,
+        TInt /*aIndex*/, const MVPbkContactLink& /*aContactLink*/ )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::ContactAddedToView" );
+
+    HTI_LOG_FUNC_OUT( "CHtiSimDirHandlerVPbk::ContactAddedToView" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::ContactRemovedFromView
+// Called when a contact has been removed from a view.
+// From MVPbkContactViewObserver
+// ----------------------------------------------------------------------------
+void CHtiSimDirHandlerVPbk::ContactRemovedFromView( MVPbkContactViewBase& /*aView*/,
+        TInt /*aIndex*/, const MVPbkContactLink& /*aContactLink*/ )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::ContactRemovedFromView" );
+
+    HTI_LOG_FUNC_OUT( "CHtiSimDirHandlerVPbk::ContactRemovedFromView" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::ContactViewError
+// Called when an error occurs in the view.
+// From MVPbkContactViewObserver
+// ----------------------------------------------------------------------------
+void CHtiSimDirHandlerVPbk::ContactViewError( MVPbkContactViewBase& aView,
+                                              TInt aError,
+                                              TBool aErrorNotified )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::ContactViewError" );
+    HTI_LOG_FORMAT( "CHtiSimDirHandlerVPbk::ContactViewError: %d", aError );
+    HTI_LOG_FORMAT( "ErrorNotified = %d", aErrorNotified );
+    if ( iContactView == &aView )
+        {
+        iContactView->RemoveObserver( *this );
+        if ( iIsBusy && iCommand == CHtiPIMServicePlugin::EDeleteSimContact )
+            {
+            SendErrorMessageL( aError, KErrorDeleteFailed );
+            }
+        }
+    aErrorNotified = aErrorNotified;  // avoid compiler warning
+    HTI_LOG_FUNC_OUT( "CHtiSimDirHandlerVPbk::ContactViewError" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::StepComplete
+// Called when one step of the batch operation is complete.
+// From MVPbkBatchOperationObserver
+// ----------------------------------------------------------------------------
+void CHtiSimDirHandlerVPbk::StepComplete( MVPbkContactOperationBase& /*aOperation*/,
+                           TInt aStepSize )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::StepComplete" );
+    HTI_LOG_FORMAT( "Step size = %d", aStepSize );
+    HTI_LOG_FUNC_OUT( "CHtiSimDirHandlerVPbk::StepComplete" );
+    aStepSize = aStepSize; // avoid compiler warning
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::StepFailed
+// Called when one step of the batch operation fails.
+// From MVPbkBatchOperationObserver
+// ----------------------------------------------------------------------------
+TBool CHtiSimDirHandlerVPbk::StepFailed( MVPbkContactOperationBase& aOperation,
+                                         TInt aStepSize, TInt aError )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::StepFailed" );
+    HTI_LOG_FORMAT( "Error %d", aError );
+    if ( iCurrentOperation == &aOperation )
+        {
+        // We are returning EFalse (= do not continue) we can delete
+        // the operation. OperationComplete() won't be called.
+        delete iCurrentOperation;
+        iCurrentOperation = NULL;
+        TRAP_IGNORE( SendErrorMessageL( aError, KErrorDeleteFailed ) );
+        }
+    HTI_LOG_FUNC_OUT( "CHtiSimDirHandlerVPbk::StepFailed" );
+    aStepSize = aStepSize; // avoid compiler warning
+    return EFalse; // do not continue
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::OperationComplete
+// Called when operation is completed.
+// From MVPbkBatchOperationObserver
+// ----------------------------------------------------------------------------
+void CHtiSimDirHandlerVPbk::OperationComplete(
+            MVPbkContactOperationBase& aOperation )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::OperationComplete" );
+    // Operation is complete -> delete it
+    if ( iCurrentOperation == &aOperation )
+        {
+        delete iCurrentOperation;
+        iCurrentOperation = NULL;
+        if ( iIsBusy && iCommand == CHtiPIMServicePlugin::EDeleteSimContact )
+            {
+            // Delete operation has completed
+            TRAP_IGNORE( SendOkMsgL( KNullDesC8 ) );
+            }
+        }
+    HTI_LOG_FUNC_OUT( "CHtiSimDirHandlerVPbk::OperationComplete" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::HandleSimCardInfoL
+// Gets information about the SIM card.
+// ----------------------------------------------------------------------------
+void CHtiSimDirHandlerVPbk::HandleSimCardInfoL()
+    {
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::HandleSimCardInfoL" );
+
+    // Get entry counts
+    const MVPbkContactStoreInfo& info = iSimStore->StoreInfo();
+    TInt maxEntries = info.MaxNumberOfContactsL();
+    TInt currentEntries = info.NumberOfContactsL();
+    HTI_LOG_FORMAT( "Current entries = %d", currentEntries );
+    HTI_LOG_FORMAT( "Max entries = %d", maxEntries );
+
+    // Create new entry object to get field informations
+    MVPbkStoreContact* entry = iSimStore->CreateNewContactLC();
+    TVPbkFieldVersitProperty prop;
+    TVPbkFieldTypeParameters param;
+
+    // Resolve field types
+    prop.SetName( EVPbkVersitNameN );
+    const MVPbkFieldType* nameFieldType =
+        iContactManager->FieldTypes().FindMatch( prop, 0 );
+
+    const MVPbkFieldType* secNameFieldType =
+        iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_SECONDNAME );
+
+    param.Reset();
+    param.Add( EVPbkVersitParamCELL );
+    prop.SetName( EVPbkVersitNameTEL );
+    prop.SetParameters( param );
+    const MVPbkFieldType* numberFieldType =
+        iContactManager->FieldTypes().FindMatch( prop, 0 );
+
+    param.Reset();
+    param.Add( EVPbkVersitParamINTERNET );
+    prop.SetName( EVPbkVersitNameEMAIL );
+    prop.SetParameters( param );
+    const MVPbkFieldType* mailFieldType =
+        iContactManager->FieldTypes().FindMatch( prop, 0 );
+
+    // Get max field counts
+    TInt maxNumbers = entry->MaxNumberOfFieldL( *numberFieldType );
+    TInt maxSecondNames = entry->MaxNumberOfFieldL( *secNameFieldType );
+    TInt maxEmails = entry->MaxNumberOfFieldL( *mailFieldType );
+
+    HTI_LOG_FORMAT( "Max numbers = %d", maxNumbers );
+    HTI_LOG_FORMAT( "Max second names = %d", maxSecondNames );
+    HTI_LOG_FORMAT( "Max emails = %d", maxEmails );
+
+    // Create field objects to get field data max lengths and verify that
+    // fields can be created. It is assumed that all SIM cards support name
+    // and number fields but e-mail and second name fields are TRAP:ed as
+    // creating them would cause a leave if not supported by the SIM card.
+    // It was noticed that with a SIM card not supporting the second name
+    // field the MaxNumberOfFieldL method for that field returns 1 but then
+    // the CreateFieldLC leaves with KErrNotSupported.
+    MVPbkStoreContactField* nameField = entry->CreateFieldLC( *nameFieldType );
+    MVPbkContactFieldTextData& nameFieldData =
+        MVPbkContactFieldTextData::Cast( nameField->FieldData() );
+    TInt maxNameLength = nameFieldData.MaxLength();
+    CleanupStack::PopAndDestroy(); // nameField
+
+    MVPbkStoreContactField* numberField = entry->CreateFieldLC( *numberFieldType );
+    MVPbkContactFieldTextData& numberFieldData =
+        MVPbkContactFieldTextData::Cast( numberField->FieldData() );
+    TInt maxNumberLength = numberFieldData.MaxLength();
+    CleanupStack::PopAndDestroy(); // numberField
+
+    MVPbkStoreContactField* mailField = NULL;
+    TInt maxMailLength = 0;
+    if ( maxEmails > 0 )
+        {
+        TRAPD( err, mailField = entry->CreateFieldLC( *mailFieldType );
+            CleanupStack::Pop(); ); // Popping inside the TRAP
+        if ( err != KErrNone )
+            {
+            maxEmails = 0;
+            }
+        else
+            {
+            MVPbkContactFieldTextData& mailFieldData =
+                MVPbkContactFieldTextData::Cast( mailField->FieldData() );
+            maxMailLength = mailFieldData.MaxLength();
+            delete mailField;
+            mailField = NULL;
+            }
+        }
+
+    MVPbkStoreContactField* secNameField = NULL;
+    TInt maxSecNameLength = 0;
+    if ( maxSecondNames > 0 )
+        {
+        TRAPD( err, secNameField = entry->CreateFieldLC( *secNameFieldType );
+            CleanupStack::Pop(); ); // Popping inside the TRAP
+        if ( err != KErrNone )
+            {
+            maxSecondNames = 0;
+            }
+        else
+            {
+            MVPbkContactFieldTextData& secNameFieldData =
+                MVPbkContactFieldTextData::Cast( secNameField->FieldData() );
+            maxSecNameLength = secNameFieldData.MaxLength();
+            delete secNameField;
+            secNameField = NULL;
+            }
+        }
+
+    HTI_LOG_FORMAT( "Max name length = %d", maxNameLength );
+    HTI_LOG_FORMAT( "Max 2nd name length = %d", maxSecNameLength );
+    HTI_LOG_FORMAT( "Max number length = %d", maxNumberLength );
+    HTI_LOG_FORMAT( "Max mail length = %d", maxMailLength );
+
+    CleanupStack::PopAndDestroy(); // entry
+
+    // Create and send response message
+    TBuf8<KSimInfoResponseLength> reply;
+    reply.Append( maxSecondNames );
+    reply.Append( maxNumbers - 1 ); // max num of additional numbers, so -1
+    reply.Append( maxEmails );
+    reply.Append( maxNameLength );
+    reply.Append( maxNumberLength );
+    reply.Append( maxSecNameLength );
+    reply.Append( maxNumberLength ); // additional number uses same field type
+    reply.Append( maxMailLength );
+    reply.Append( ( TUint8* ) ( &maxEntries ), 2 );
+    reply.Append( ( TUint8* ) ( &currentEntries ), 2 );
+
+    SendOkMsgL( reply );
+
+    HTI_LOG_FUNC_OUT( "CHtiSimDirHandlerVPbk::HandleSimCardInfoL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::HandleSimContactImportL
+// Imports the contact to SIM card.
+// ----------------------------------------------------------------------------
+void CHtiSimDirHandlerVPbk::HandleSimContactImportL()
+    {
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::HandleSimContactImportL" );
+
+    MVPbkStoreContact* newEntry = iSimStore->CreateNewContactLC();
+
+    TInt offset = 0;
+    TInt fieldCount = iMessage->Des()[offset];
+    offset++;
+
+    for ( TInt i = 0; i < fieldCount; i++ )
+        {
+        HTI_LOG_FORMAT( "Processing field %d", i + 1 );
+
+        MVPbkStoreContactField* field = NULL;
+        TVPbkFieldVersitProperty prop;
+        TVPbkFieldTypeParameters param;
+        const MVPbkFieldType* fieldType = NULL;
+        TContactFieldType type = ( TContactFieldType ) iMessage->Des()[offset];
+        offset++;
+        switch ( type )
+            {
+            case ENameField:
+                prop.SetName( EVPbkVersitNameN );
+                fieldType = iContactManager->FieldTypes().FindMatch( prop, 0 );
+                break;
+            case ESecondNameField:
+                fieldType = iContactManager->FieldTypes().Find(
+                    R_VPBK_FIELD_TYPE_SECONDNAME );
+                break;
+            case EPhoneNumberField:
+                param.Add( EVPbkVersitParamCELL );
+                prop.SetName( EVPbkVersitNameTEL );
+                prop.SetParameters( param );
+                fieldType = iContactManager->FieldTypes().FindMatch( prop, 0 );
+                break;
+            case EEMailField:
+                param.Add( EVPbkVersitParamINTERNET );
+                prop.SetName( EVPbkVersitNameEMAIL );
+                prop.SetParameters( param );
+                fieldType = iContactManager->FieldTypes().FindMatch( prop, 0 );
+                break;
+            case EAdditNumberField:
+                param.Add( EVPbkVersitParamCELL );
+                prop.SetName( EVPbkVersitNameTEL );
+                prop.SetParameters( param );
+                fieldType = iContactManager->FieldTypes().FindMatch( prop, 0 );
+                break;
+            default:
+                HTI_LOG_FORMAT( "Unknown field type %d", type );
+                User::Leave( KErrArgument );
+                break;
+            }
+
+        if ( fieldType == NULL )
+            {
+            User::Leave( KErrArgument );
+            }
+
+        HTI_LOG_FORMAT( "Field type res id %d", fieldType->FieldTypeResId() );
+
+        field = newEntry->CreateFieldLC( *fieldType );
+
+        TInt fieldLength = iMessage->Des()[offset];
+        offset++;
+        HBufC* fieldData = HBufC::NewLC( fieldLength );
+        fieldData->Des().Copy( iMessage->Mid( offset, fieldLength ) );
+        HTI_LOG_FORMAT( "Field created - adding data: %S", fieldData );
+
+        MVPbkContactFieldTextData& targetData =
+            MVPbkContactFieldTextData::Cast( field->FieldData() );
+        targetData.SetTextL( *fieldData );
+
+        CleanupStack::PopAndDestroy(); // fieldData
+
+        HTI_LOG_TEXT( "Data set - Adding the field" );
+        newEntry->AddFieldL( field );
+        CleanupStack::Pop(); // field
+
+        offset += fieldLength;
+        }
+
+    HTI_LOG_TEXT( "Entry created - Commiting" );
+    // Starts the async commit operation. Takes ownership of newEntry.
+    newEntry->CommitL( *this );
+    CleanupStack::Pop(); // newEntry
+
+    HTI_LOG_FUNC_OUT( "CHtiSimDirHandlerVPbk::HandleSimContactImportL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::HandleSimContactDeleteL
+// Creates a contact view containing the contacts to be deleted.
+// ----------------------------------------------------------------------------
+void CHtiSimDirHandlerVPbk::HandleSimContactDeleteL()
+    {
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::HandleSimContactDeleteL" );
+
+    if ( iContactView )
+        {
+        iContactView->RemoveObserver( *this );
+        delete iContactView;
+        iContactView = NULL;
+        }
+
+    // Delete one entry based on ID
+    if ( iMessage->Length() == 4 )
+        {
+        TPtr8 msgPtr = iMessage->Des();
+        TInt id = msgPtr[0] + ( msgPtr[1] << 8 )
+                            + ( msgPtr[2] << 16 )
+                            + ( msgPtr[3] << 24 );
+        HTI_LOG_FORMAT( "Delete with id %d", id );
+
+        User::Leave( KErrNotSupported );
+        }
+
+    // Delete all
+    else
+        {
+        CVPbkContactViewDefinition* viewDef = CVPbkContactViewDefinition::NewL();
+        CleanupStack::PushL( viewDef );
+        viewDef->SetType( EVPbkContactsView );
+        viewDef->SetSharing( EVPbkLocalView );
+        viewDef->SetSortPolicy( EVPbkUnsortedContactView ); // in SIM index order
+        CVPbkSortOrder* sortOrder = CVPbkSortOrder::NewL(
+                iSimStore->StoreProperties().SupportedFields() );
+        CleanupStack::PushL( sortOrder );
+        iContactView = iSimStore->CreateViewLC( *viewDef, *this, *sortOrder );
+        CleanupStack::Pop(); // view;
+        CleanupStack::PopAndDestroy( 2 ); // sortOrder, viewDef
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiSimDirHandlerVPbk::HandleSimContactDeleteL" );
+    }
+
+// ----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::DeleteContactsInViewL
+// Deletes the contacts that are currently in iContactView.
+// ----------------------------------------------------------------------------
+void CHtiSimDirHandlerVPbk::DeleteContactsInViewL()
+    {
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::DeleteContactsInViewL" );
+
+    TInt cntCount( iContactView->ContactCountL() );
+    HTI_LOG_FORMAT( "Contact count in view = %d", cntCount );
+    if ( cntCount > 0 )
+        {
+        CVPbkContactLinkArray* contactLinks = CVPbkContactLinkArray::NewLC();
+        for ( TInt i = 0; i < cntCount; ++i )
+            {
+            MVPbkContactLink* link =
+                iContactView->ContactAtL( i ).CreateLinkLC();
+            contactLinks->AppendL( link );
+            CleanupStack::Pop(); // link
+            }
+        // Following DeleteContactsL will result in calls to StepComplete
+        // and finally OperationComplete (StepFailed if error occurs)
+        iCurrentOperation = iContactManager->DeleteContactsL(
+                *contactLinks, *this );
+        CleanupStack::PopAndDestroy(); // contactLinks
+        }
+    else
+        {
+        // Nothing to delete
+        SendOkMsgL( KNullDesC8 );
+        }
+
+    // We don't need the view anymore
+    HTI_LOG_TEXT( "Deleting the contact view" );
+    iContactView->RemoveObserver( *this );
+    delete iContactView;
+    iContactView = NULL;
+
+    HTI_LOG_FUNC_OUT( "CHtiSimDirHandlerVPbk::DeleteContactsInViewL" );
+    }
+
+// ----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::CheckImportMsg
+// Validates the syntax of import contact message.
+// ----------------------------------------------------------------------------
+TBool CHtiSimDirHandlerVPbk::CheckImportMsg()
+    {
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::CheckImportMsg" );
+    // Import command syntax:
+    //   amount of fields     (1 byte)   __
+    //   type of field        (1 byte)     |
+    //   length of data field (1 byte)     | repeated <amount of fields> times
+    //   field data           (variable) __|
+
+    TInt length = iMessage->Length();
+    if ( length < 4 ) // min length 4 bytes
+        {
+        HTI_LOG_FORMAT( "Message too short %d", length );
+        return EFalse;
+        }
+
+    TInt offset = 0;
+    TInt fieldCount = iMessage->Des()[offset];
+    HTI_LOG_FORMAT( "Fields %d", fieldCount );
+    if ( fieldCount < 1 ) // must be at least one field
+        {
+        return EFalse;
+        }
+
+    offset++;
+    TInt fieldsFound = 0;
+    while ( offset < length )
+        {
+        fieldsFound++;
+        TInt fieldType = iMessage->Des()[offset];
+        HTI_LOG_FORMAT( "Field type %d", fieldType );
+        if ( fieldType < ENameField || fieldType > EAdditNumberField )
+            {
+            return EFalse; // invalid field type
+            }
+        offset++; // the type of field byte
+        if ( offset >= length )
+            {
+            return EFalse;
+            }
+        TInt fieldLength = iMessage->Des()[offset];
+        HTI_LOG_FORMAT( "Field length %d", fieldLength );
+        if ( fieldLength < 1 )
+            {
+            return EFalse; // Field data can not be empty
+            }
+        offset++; // advance over the length of data byte
+        offset += fieldLength; // and the field data
+        }
+
+    if ( offset == length && fieldsFound == fieldCount )
+        {
+        HTI_LOG_TEXT( "Message OK" );
+        return ETrue;
+        }
+
+    return EFalse;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::SendOkMsgL
+// Helper function for sending response messages.
+// ----------------------------------------------------------------------------
+void CHtiSimDirHandlerVPbk::SendOkMsgL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::SendOkMsgL" );
+    iIsBusy = EFalse; // Done with the current request
+    User::LeaveIfNull( iDispatcher );
+    HBufC8* temp = HBufC8::NewL( aData.Length() + 1 );
+    TPtr8 response = temp->Des();
+    response.Append( ( TChar ) CHtiPIMServicePlugin::EResultOk );
+    response.Append( aData );
+    User::LeaveIfError( iDispatcher->DispatchOutgoingMessage(
+        temp, KPIMServiceUid ) );
+    HTI_LOG_FUNC_OUT( "CHtiSimDirHandlerVPbk::SendOkMsgL" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::SendErrorMessageL
+// Helper function for sending error response messages.
+// ----------------------------------------------------------------------------
+void CHtiSimDirHandlerVPbk::SendErrorMessageL( TInt aError, const TDesC8& aDescription )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSimDirHandlerVPbk::SendErrorMessageL" );
+    iIsBusy = EFalse; // Done with the current request
+    User::LeaveIfNull( iDispatcher );
+    User::LeaveIfError( iDispatcher->DispatchOutgoingErrorMessage(
+        aError, aDescription, KPIMServiceUid ) );
+    HTI_LOG_FUNC_OUT( "CHtiSimDirHandlerVPbk::SendErrorMessageL" );
+    }
+
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiPIMServicePlugin/src/PIMHandler.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,1038 @@
+/*
+* 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:  Functional implementation of PIM service (for vCalendar, vCard)
+*
+*/
+
+
+// INCLUDE FILES
+#include "HtiPIMServicePlugin.h"
+#include "PIMHandler.h"
+
+#include <HtiDispatcherInterface.h>
+#include <HTILogging.h>
+
+#include <utf.h>
+#include <calcommon.h>
+#include <calsession.h>
+#include <calenimporter.h>
+#include <calentryview.h>
+
+#include <CVPbkContactLinkArray.h>
+#include <CVPbkContactManager.h>
+#include <CVPbkContactViewDefinition.h>
+#include <CVPbkContactStoreUriArray.h>
+#include <CVPbkSortOrder.h>
+#include <CVPbkVCardEng.h>
+#include <MVPbkContactLinkArray.h>
+#include <MVPbkContactOperationBase.h>
+#include <MVPbkContactStore.h>
+#include <MVPbkContactStoreList.h>
+#include <MVPbkContactStoreObserver.h>
+#include <MVPbkContactStoreProperties.h>
+#include <MVPbkContactView.h>
+#include <MVPbkContactViewBase.h>
+#include <MVPbkViewContact.h>
+#include <TVPbkContactStoreUriPtr.h>
+#include <VPbkContactStoreUris.h>
+
+// CONSTANTS
+_LIT8( KErrorUnrecognizedCommand, "Unrecognized command" );
+_LIT8( KErrorVCardImportFailed, "vCard import failed" );
+_LIT8( KErrorVCalendarImportFailed, "vCalendar import failed" );
+_LIT8( KErrorMissingVCalendar, "Missing vCalendar object" );
+_LIT8( KErrorMissingVCard, "Missing vCard object" );
+_LIT8( KErrorInvalidId, "Invalid ID parameter" );
+_LIT8( KErrorItemNotFound, "Item not found" );
+_LIT8( KErrorFailedDelete, "Failed to delete item" );
+_LIT8( KErrorFailedDeleteAll, "Failed to delete all items" );
+_LIT8( KErrorIdDeleteNotSupported, "Deleting with ID not supported anymore" );
+
+_LIT8( KErrorMissingText, "Text parameter missing" );
+_LIT8( KErrorMissingFilepath, "Filepath parameter missing" );
+_LIT8( KErrorNotepadAddMemoFailed, "Notepad add memo failed" );
+_LIT8( KErrorNotepadAddMemoFromFileFailed, "Notepad add memo from file failed" );
+_LIT8( KErrorNotepadDeleteAllFailed, "Notepad delete all failed" );
+
+_LIT( KHtiNpdHlpExe,       "HtiNpdHlp.exe" );
+_LIT( KCmdAddMemo,         "AddMemo" );
+_LIT( KCmdAddMemoFromFile, "AddMemoFromFile" );
+_LIT( KCmdDeleteAll,       "DeleteAll" );
+_LIT( KCmdDelim,           " " );
+
+_LIT( KDefaultAgendaFile, "" ); // A default file is opened if fileName is KNullDesC
+
+
+// ----------------------------------------------------------------------------
+CPIMHandler* CPIMHandler::NewL()
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::NewL" );
+    CPIMHandler* self = new (ELeave) CPIMHandler();
+    CleanupStack::PushL ( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    HTI_LOG_FUNC_OUT( "CPIMHandler::Done" );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+CPIMHandler::CPIMHandler():iIsBusy( EFalse ), iEntryViewErr( KErrNone )
+    {
+    }
+
+// ----------------------------------------------------------------------------
+CPIMHandler::~CPIMHandler()
+    {
+    HTI_LOG_TEXT( "CPIMHandler destroy" );
+    HTI_LOG_TEXT( "Deleting iEntryView" );
+    delete iEntryView;
+    HTI_LOG_TEXT( "Deleting iCalSession" );
+    delete iCalSession;
+    if ( iContactView )
+        {
+        HTI_LOG_TEXT( "Deleting iContactView" );
+        iContactView->RemoveObserver( *this );
+        delete iContactView;
+        }
+    HTI_LOG_TEXT( "Deleting iVCardEngine" );
+    delete iVCardEngine;
+    HTI_LOG_TEXT( "Deleting iContactManager" );
+    delete iContactManager;
+    HTI_LOG_TEXT( "Deleting iBuffer" );
+    delete iBuffer;
+    HTI_LOG_TEXT( "Deleting iWaiter" );
+    delete iWaiter;
+    }
+
+// ----------------------------------------------------------------------------
+void CPIMHandler::ConstructL()
+    {
+    HTI_LOG_TEXT( "CPIMHandler::ConstructL" );
+    iWaiter = new ( ELeave ) CActiveSchedulerWait;
+
+    }
+
+// ----------------------------------------------------------------------------
+void CPIMHandler::SetDispatcher( MHtiDispatcher* aDispatcher )
+    {
+    iDispatcher = aDispatcher;
+    }
+
+// ----------------------------------------------------------------------------
+void CPIMHandler::ProcessMessageL( const TDesC8& aMessage,
+    THtiMessagePriority /*aPriority*/ )
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::ProcessMessageL" );
+
+    iIsBusy = ETrue;
+    TInt err = KErrNone;
+
+    // Zero legth of aMessage tested already in CHtiPIMServicePlugin.
+    // Other sanity checks must be done here.
+
+    iCommand = aMessage.Ptr()[0];
+    switch ( iCommand )
+        {
+        case CHtiPIMServicePlugin::EImportVCard:
+            {
+            TRAP( err, HandleVCardImportFuncL(
+                    aMessage.Right( aMessage.Length() - 1 ) ) );
+            break;
+            }
+        case CHtiPIMServicePlugin::EImportVCalendar:
+            {
+            TRAP( err, HandleVCalendarImportFuncL(
+                    aMessage.Right( aMessage.Length() - 1 ) ) );
+            break;
+            }
+        case CHtiPIMServicePlugin::EDeleteContact:
+            {
+            TRAP( err, HandleContactDeleteFuncL(
+                    aMessage.Right( aMessage.Length() - 1 ) ) );
+            break;
+            }
+        case CHtiPIMServicePlugin::EDeleteCalendar:
+            {
+            TRAP( err, HandleCalendarDeleteFuncL(
+                    aMessage.Right( aMessage.Length() - 1 ) ) );
+            break;
+            }
+        case CHtiPIMServicePlugin::ENotepadAddMemo:
+            {
+            TRAP( err, HandleNotepadAddMemoFuncL( aMessage.Mid( 1 ) ) );
+            break;
+            }
+        case CHtiPIMServicePlugin::ENotepadAddMemoFromFile:
+            {
+            TRAP( err, HandleNotepadAddMemoFromFileFuncL( aMessage.Mid( 1 ) ) );
+            break;
+            }
+        case CHtiPIMServicePlugin::ENotepadDeleteAll:
+            {
+            TRAP( err, HandleNotepadDeleteAllFuncL() );
+            break;
+            }
+        default:
+            {
+            TRAP( err, SendErrorMessageL(
+                    KErrArgument, KErrorUnrecognizedCommand ) );
+            break;
+            }
+        }
+
+    if ( err != KErrNone )
+        {
+        iIsBusy = EFalse;
+        User::Leave( err );
+        }
+
+    HTI_LOG_FUNC_OUT( "CPIMHandler::ProcessMessageL: Done" );
+    }
+
+// ----------------------------------------------------------------------------
+TBool CPIMHandler::IsBusy()
+    {
+    return iIsBusy;
+    }
+
+// ----------------------------------------------------------------------------
+void CPIMHandler::HandleVCardImportFuncL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::HandleVCardImportFuncL" );
+
+    if ( aData.Length() == 0 )
+        {
+        SendErrorMessageL( KErrArgument, KErrorMissingVCard );
+        return;
+        }
+
+    if ( iBuffer ) // delete if exists (just to be sure)
+        {
+        delete iBuffer;
+        iBuffer = NULL;
+        }
+    iBuffer = CBufFlat::NewL( aData.Length() );
+    iBuffer->ExpandL( 0, aData.Length() );
+
+    HTI_LOG_FORMAT( "Data length = %d", aData.Length() );
+    HTI_LOG_FORMAT( "Buffer length = %d", iBuffer->Ptr( 0 ).MaxLength() );
+    iBuffer->Ptr( 0 ).Copy( aData );
+
+    if ( iContactManager == NULL )
+        {
+        CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewLC();
+        uriArray->AppendL( TVPbkContactStoreUriPtr(
+            VPbkContactStoreUris::DefaultCntDbUri() ) );
+        iContactManager = CVPbkContactManager::NewL( *uriArray );
+        CleanupStack::PopAndDestroy( uriArray );
+        }
+
+    if ( iVCardEngine == NULL )
+        {
+        iVCardEngine = CVPbkVCardEng::NewL( *iContactManager );
+        }
+
+    MVPbkContactStoreList& stores = iContactManager->ContactStoresL();
+    iContactStore = &stores.At( 0 );
+    iContactStore->OpenL( *this );
+
+    HTI_LOG_FUNC_OUT( "CPIMHandler::HandleVCardImportFuncL: Done" );
+    }
+
+// ----------------------------------------------------------------------------
+void CPIMHandler::HandleVCalendarImportFuncL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::HandleVCalendarImportFuncL" );
+
+    if ( aData.Length() == 0 )
+        {
+        HTI_LOG_TEXT( "CPIMHandler::HandleVCalendarImportFuncL: Error: length of data is zero" )
+        SendErrorMessageL( KErrArgument, KErrorMissingVCalendar );
+        return;
+        }
+
+    if ( iBuffer ) // delete if exists (just to be sure)
+        {
+        delete iBuffer;
+        iBuffer = NULL;
+        }
+    iBuffer = CBufFlat::NewL( aData.Length() );
+    iBuffer->ExpandL( 0, aData.Length() );
+    iBuffer->Ptr( 0 ).Copy( aData );
+    RBufReadStream readStream;
+    readStream.Open( *iBuffer, 0 );
+    CleanupClosePushL( readStream );
+
+    if ( iCalSession == NULL )
+        {
+        HTI_LOG_TEXT( "CPIMHandler: Creating Calendar session" );
+        iCalSession = CCalSession::NewL();
+        iCalSession->OpenL( KDefaultAgendaFile );
+        HTI_LOG_TEXT( "CPIMHandler: Calendar session open" );
+        }
+
+    CCalenImporter* importer = CCalenImporter::NewL( *iCalSession );
+    CleanupStack::PushL( importer );
+    HTI_LOG_TEXT( "CPIMHandler: Calendar importer created" );
+
+    RPointerArray<CCalEntry> entryArray;
+    CleanupClosePushL( entryArray );
+
+    TInt err = KErrNone;
+    TInt size = 0;
+    importer->SetImportMode( ECalenImportModeExtended );
+    // First try to import as iCalendar
+    TRAP( err, importer->ImportICalendarL( readStream, entryArray ) );
+    HTI_LOG_FORMAT( "ImportICalendarL return value %d", err );
+    size = entryArray.Count();
+    HTI_LOG_FORMAT( "Import ICalendarL imported %d entries", size );
+    // If import didn't succeed, try as vCalendar
+    if ( err != KErrNone || size == 0 )
+        {
+        readStream.Close();
+        readStream.Open( *iBuffer, 0 ); // reset read stream
+        entryArray.ResetAndDestroy(); // avoid double imports
+        TRAP( err, importer->ImportVCalendarL( readStream, entryArray ) );
+        HTI_LOG_FORMAT( "ImportVCalendarL return value %d", err );
+        size = entryArray.Count();
+        HTI_LOG_FORMAT( "Import VCalendarL imported %d entries", size );
+        }
+    TCalLocalUid uniqueId = 0;
+    TInt success = 0;
+    if ( size > 0 )
+        {
+        iEntryView = CCalEntryView::NewL( *iCalSession, *this );
+        iWaiter->Start();
+        if ( iEntryViewErr == KErrNone )
+            {
+            TRAP( err, iEntryView->StoreL( entryArray, success ) );
+            HTI_LOG_FORMAT( "StoreL return value %d", err );
+            HTI_LOG_FORMAT( "Successfully stored %d entries", success );
+            uniqueId = entryArray[0]->LocalUidL();
+            }
+        delete iEntryView;
+        iEntryView = NULL;
+        }
+    entryArray.ResetAndDestroy();
+    CleanupStack::PopAndDestroy(); // entryArray
+
+    if ( err == KErrNone && success > 0 )
+        {
+        TBuf8<8> uniqueIdStr;
+        uniqueIdStr.Copy( ( TUint8* ) ( &uniqueId ), sizeof( uniqueId ) );
+        SendOkMsgL( uniqueIdStr );
+        }
+    else
+        {
+        if ( err == KErrNone ) err = KErrGeneral;
+        SendErrorMessageL( err, KErrorVCalendarImportFailed );
+        }
+
+    CleanupStack::PopAndDestroy( 2 ); // readStream, importer
+    delete iCalSession;
+    iCalSession = NULL;
+    delete iBuffer;
+    iBuffer = NULL;
+    HTI_LOG_FUNC_OUT( "CPIMHandler::HandleVCalendarImportFuncL: Done" );
+    }
+
+// ----------------------------------------------------------------------------
+void CPIMHandler::HandleContactDeleteFuncL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::HandleContactDeleteFuncL" );
+
+    TInt dataLength = aData.Length();
+    if ( dataLength != 0 && dataLength != 4 )
+        {
+        HTI_LOG_TEXT( "CPIMHandler: Error: wrong length of data" )
+        SendErrorMessageL( KErrArgument, KErrorInvalidId );
+        return;
+        }
+
+    if ( dataLength == 4 )
+        {
+        SendErrorMessageL( KErrNotSupported, KErrorIdDeleteNotSupported );
+        return;
+        }
+
+    if ( iContactManager == NULL )
+        {
+        CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewLC();
+        uriArray->AppendL( TVPbkContactStoreUriPtr(
+            VPbkContactStoreUris::DefaultCntDbUri() ) );
+        iContactManager = CVPbkContactManager::NewL( *uriArray );
+        CleanupStack::PopAndDestroy( uriArray );
+        }
+
+    if ( iContactStore == NULL )
+        {
+        MVPbkContactStoreList& stores = iContactManager->ContactStoresL();
+        iContactStore = &stores.At( 0 );
+        }
+
+    iContactStore->OpenL( *this );
+
+    HTI_LOG_FUNC_OUT( "CPIMHandler::HandleContactDeleteFuncL" );
+    }
+
+// ----------------------------------------------------------------------------
+void CPIMHandler::HandleCalendarDeleteFuncL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::HandleVCalendarDeleteFuncL" );
+
+    TInt dataLength = aData.Length();
+    if ( dataLength != 0 && dataLength != 4 )
+        {
+        HTI_LOG_TEXT( "CPIMHandler: Error: wrong length of data" )
+        SendErrorMessageL( KErrArgument, KErrorInvalidId );
+        return;
+        }
+
+    if ( iBuffer ) // delete if exists (just to be sure)
+        {
+        delete iBuffer;
+        iBuffer = NULL;
+        }
+    if ( aData.Length() > 0 )
+        {
+        iBuffer = CBufFlat::NewL( aData.Length() );
+        iBuffer->ExpandL( 0, aData.Length() );
+        iBuffer->Ptr( 0 ).Copy( aData );
+        }
+
+    if ( iCalSession == NULL )
+        {
+        HTI_LOG_TEXT( "CPIMHandler: Creating Calendar session" );
+        iCalSession = CCalSession::NewL();
+        iCalSession->OpenL( KDefaultAgendaFile );
+        HTI_LOG_TEXT( "CPIMHandler: Calendar session open" );
+        }
+
+    HTI_LOG_TEXT( "CPIMHandler: Creating entry view" );
+    iEntryView = CCalEntryView::NewL( *iCalSession, *this );
+    iWaiter->Start();
+    if ( iEntryViewErr != KErrNone )
+        {
+        delete iEntryView;
+        iEntryView = NULL;
+        delete iCalSession;
+        iCalSession = NULL;
+        delete iBuffer;
+        iBuffer = NULL;
+        User::Leave( iEntryViewErr );
+        }
+
+    // If iBuffer is NULL, no ID given, delete all calendar entries
+    if ( iBuffer == NULL )
+        {
+        HTI_LOG_TEXT( "CPIMHandler: Deleting all calendar entries" );
+        TCalTime minTime;
+        TCalTime maxTime;
+        minTime.SetTimeUtcL( TCalTime::MinTime() );
+        maxTime.SetTimeUtcL( TCalTime::MaxTime() );
+        CalCommon::TCalTimeRange timeRange( minTime, maxTime );
+        TRAPD( err, iEntryView->DeleteL( timeRange,
+                CalCommon::EIncludeAll, *this ) );
+        iWaiter->Start();
+        if ( err == KErrNone && iEntryViewErr == KErrNone )
+            {
+            SendOkMsgL( KNullDesC8 );
+            }
+        else
+            {
+            SendErrorMessageL( KErrGeneral, KErrorFailedDeleteAll );
+            }
+        }
+
+    // If id given, delete only calendar entry having that id
+    else
+        {
+        TPtr8 data = iBuffer->Ptr( 0 );
+        TCalLocalUid id = data[0] + ( data[1] << 8 )
+                             + ( data[2] << 16 )
+                             + ( data[3] << 24 );
+        HTI_LOG_FORMAT( "CPIMHandler: Deleting one calendar entry %d", id );
+        CCalEntry* entryToDelete = NULL;
+        TRAPD( err, entryToDelete = iEntryView->FetchL( id ) );
+
+        if ( err || entryToDelete == NULL )
+            {
+            HTI_LOG_TEXT( "CPIMHandler: Calendar entry not found" );
+            SendErrorMessageL( KErrNotFound, KErrorItemNotFound );
+            }
+        else
+            {
+            CleanupStack::PushL( entryToDelete );
+            TRAP( err, iEntryView->DeleteL( *entryToDelete ) );
+            if ( err == KErrNone )
+                {
+                SendOkMsgL( KNullDesC8 );
+                }
+            else
+                {
+                HTI_LOG_TEXT( "CPIMHandler: Error deleting calendar entry" )
+                SendErrorMessageL( KErrGeneral, KErrorFailedDelete );
+                }
+            CleanupStack::PopAndDestroy( entryToDelete );
+            }
+        }
+    delete iEntryView;
+    iEntryView = NULL;
+    delete iCalSession;
+    iCalSession = NULL;
+    delete iBuffer;
+    iBuffer = NULL;
+    HTI_LOG_FUNC_OUT( "CPIMHandler::HandleVCalendarDeleteFuncL" );
+    }
+
+// ----------------------------------------------------------------------------
+void CPIMHandler::SendOkMsgL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::SendOkMsgL: Starting" );
+
+    User::LeaveIfNull( iDispatcher );
+
+    HBufC8* temp = HBufC8::NewL( aData.Length() + 1 );
+    TPtr8 response = temp->Des();
+    response.Append( ( TChar ) CHtiPIMServicePlugin::EResultOk );
+    response.Append( aData );
+    User::LeaveIfError( iDispatcher->DispatchOutgoingMessage(
+        temp, KPIMServiceUid ) );
+    iIsBusy = EFalse;
+    HTI_LOG_FUNC_OUT( "CPIMHandler::SendOkMsgL: Done" );
+    }
+
+// ----------------------------------------------------------------------------
+void CPIMHandler::SendErrorMessageL( TInt aError, const TDesC8& aDescription )
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::SendErrorMessageL: Starting" );
+    User::LeaveIfNull( iDispatcher );
+    User::LeaveIfError( iDispatcher->DispatchOutgoingErrorMessage(
+        aError, aDescription, KPIMServiceUid ) );
+    iIsBusy = EFalse;
+    HTI_LOG_FUNC_OUT( "CPIMHandler::SendErrorMessageL: Done" );
+    }
+
+// ----------------------------------------------------------------------------
+TInt CallNpdHlp( const TDesC& aCmd )
+    {
+    HTI_LOG_FUNC_IN( "CallNpdHlp" );
+
+    RProcess HtiNpdHlp;
+    TInt err = HtiNpdHlp.Create( KHtiNpdHlpExe, aCmd );
+    if ( err )
+        {
+        HTI_LOG_FORMAT( "Could not create HtiNpdHlp.Exe process %d", err );
+        return err;
+        }
+
+    TRequestStatus status;
+    HtiNpdHlp.Logon( status );
+    HtiNpdHlp.Resume();
+    User::WaitForRequest( status );
+    if ( status.Int() != KErrNone )
+        {
+        HTI_LOG_FORMAT( "status     %d", status.Int() );
+        HTI_LOG_FORMAT( "ExitReason %d", HtiNpdHlp.ExitReason() );
+        HTI_LOG_FORMAT( "ExitType   %d", HtiNpdHlp.ExitType() );
+        HtiNpdHlp.Close();
+        return status.Int();
+        }
+
+    HtiNpdHlp.Close();
+
+    HTI_LOG_FUNC_OUT( "CallNpdHlp" );
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+void CPIMHandler::SendNotepadOkMsgL( CHtiPIMServicePlugin::TCommand aCommand )
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::SendNotepadOkMsgL" );
+    TBuf8<1> msg;
+    msg.Append( aCommand );
+    User::LeaveIfError( iDispatcher->DispatchOutgoingMessage(
+                        msg.AllocL(), KPIMServiceUid ) );
+    iIsBusy = EFalse;
+    HTI_LOG_FUNC_OUT( "CPIMHandler::SendNotepadOkMsgL" );
+    }
+
+// ----------------------------------------------------------------------------
+void CPIMHandler::HandleNotepadAddMemoFuncL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::HandleNotepadAddMemoFuncL" );
+
+    if ( aData.Length() < 1 )
+        {
+        SendErrorMessageL( KErrArgument, KErrorMissingText );
+        return;
+        }
+
+    // convert text from TDesC8 -> TDesC
+    // expecting the input TDesC8 contains UTF-8 data
+    HBufC* text = CnvUtfConverter::ConvertToUnicodeFromUtf8L( aData );
+    HTI_LOG_TEXT( "CPIMHandler: Conversion to Unicode done" );
+    CleanupStack::PushL( text );
+
+    HBufC* cmd = HBufC::NewLC( KCmdAddMemo().Length() + 1 + ( *text ).Length() );
+    cmd->Des().Copy( KCmdAddMemo );
+    cmd->Des().Append( KCmdDelim );
+    cmd->Des().Append( *text );
+
+    TInt err = CallNpdHlp( *cmd );
+    if ( err )
+        {
+        SendErrorMessageL( err, KErrorNotepadAddMemoFailed );
+        }
+    else
+        {
+        SendNotepadOkMsgL( CHtiPIMServicePlugin::ENotepadAddMemo );
+        }
+
+    CleanupStack::PopAndDestroy( 2 ); // text, cmd
+
+    HTI_LOG_FUNC_OUT( "CPIMHandler::HandleNotepadAddMemoFuncL" );
+    }
+
+// ----------------------------------------------------------------------------
+void CPIMHandler::HandleNotepadAddMemoFromFileFuncL( const TDesC8& aData )
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::HandleNotepadAddMemoFromFileFuncL" );
+
+    if ( aData.Length() < 1 )
+        {
+        SendErrorMessageL( KErrArgument, KErrorMissingFilepath );
+        return;
+        }
+
+    // convert filename from TDesC8 -> TDesC
+    // expecting the input TDesC8 contains UTF-8 data
+    HBufC* filename = CnvUtfConverter::ConvertToUnicodeFromUtf8L( aData );
+    HTI_LOG_TEXT( "CPIMHandler: Conversion to Unicode done" );
+    CleanupStack::PushL( filename );
+
+    HBufC* cmd = HBufC::NewLC( KCmdAddMemoFromFile().Length() + 1 + ( *filename ).Length() );
+    cmd->Des().Copy( KCmdAddMemoFromFile );
+    cmd->Des().Append( KCmdDelim );
+    cmd->Des().Append( *filename );
+
+    TInt err = CallNpdHlp( *cmd );
+    if ( err )
+        {
+        SendErrorMessageL( err, KErrorNotepadAddMemoFromFileFailed );
+        }
+    else
+        {
+        SendNotepadOkMsgL( CHtiPIMServicePlugin::ENotepadAddMemoFromFile );
+        }
+
+    CleanupStack::PopAndDestroy( 2 ); // filename, cmd
+
+    HTI_LOG_FUNC_OUT( "CPIMHandler::HandleNotepadAddMemoFromFileFuncL" );
+    }
+
+// ----------------------------------------------------------------------------
+void CPIMHandler::HandleNotepadDeleteAllFuncL()
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::HandleNotepadDeleteAllFuncL" );
+
+    TInt err = CallNpdHlp( KCmdDeleteAll() );
+    if ( err )
+        {
+        SendErrorMessageL( err, KErrorNotepadDeleteAllFailed );
+        }
+    else
+        {
+        SendNotepadOkMsgL( CHtiPIMServicePlugin::ENotepadDeleteAll );
+        }
+
+    HTI_LOG_FUNC_OUT( "CPIMHandler::HandleNotepadDeleteAllFuncL" );
+    }
+
+// ----------------------------------------------------------------------------
+// CPIMHandler::CreateContactDeleteViewL
+// Creates a contact view containing the contacts to be deleted.
+// ----------------------------------------------------------------------------
+void CPIMHandler::CreateContactDeleteViewL()
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::CreateContactDeleteViewL" );
+
+    if ( iContactView )
+        {
+        iContactView->RemoveObserver( *this );
+        delete iContactView;
+        iContactView = NULL;
+        }
+
+    CVPbkContactViewDefinition* viewDef = CVPbkContactViewDefinition::NewL();
+    CleanupStack::PushL( viewDef );
+    viewDef->SetType( EVPbkContactsView );
+    viewDef->SetSharing( EVPbkLocalView );
+    viewDef->SetSortPolicy( EVPbkSortedContactView );
+    CVPbkSortOrder* sortOrder = CVPbkSortOrder::NewL(
+            iContactStore->StoreProperties().SupportedFields() );
+    CleanupStack::PushL( sortOrder );
+    iContactView = iContactStore->CreateViewLC( *viewDef, *this, *sortOrder );
+    CleanupStack::Pop(); // view;
+    CleanupStack::PopAndDestroy( 2 ); // sortOrder, viewDef
+
+    HTI_LOG_FUNC_OUT( "CPIMHandler::CreateContactDeleteViewL" );
+    }
+
+// ----------------------------------------------------------------------------
+// CPIMHandler::DeleteContactsInViewL
+// Deletes the contacts that are currently in iContactView.
+// ----------------------------------------------------------------------------
+void CPIMHandler::DeleteContactsInViewL()
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::DeleteContactsInViewL" );
+
+    TInt cntCount( iContactView->ContactCountL() );
+    HTI_LOG_FORMAT( "Contact count in view = %d", cntCount );
+    if ( cntCount > 0 )
+        {
+        CVPbkContactLinkArray* contactLinks = CVPbkContactLinkArray::NewLC();
+        for ( TInt i = 0; i < cntCount; ++i )
+            {
+            MVPbkContactLink* link =
+                iContactView->ContactAtL( i ).CreateLinkLC();
+            contactLinks->AppendL( link );
+            CleanupStack::Pop(); // link
+            }
+        // Following DeleteContactsL will result in calls to StepComplete
+        // and finally OperationComplete (StepFailed if error occurs)
+        iOp = iContactManager->DeleteContactsL( *contactLinks, *this );
+        CleanupStack::PopAndDestroy(); // contactLinks
+        }
+    else
+        {
+        // Nothing to delete
+        iContactStore->Close( *this );
+        SendOkMsgL( KNullDesC8 );
+        }
+
+    // We don't need the view anymore
+    HTI_LOG_TEXT( "Deleting the contact view" );
+    iContactView->RemoveObserver( *this );
+    delete iContactView;
+    iContactView = NULL;
+
+    HTI_LOG_FUNC_OUT( "CPIMHandler::DeleteContactsInViewL" );
+    }
+
+// ----------------------------------------------------------------------------
+// CPIMHandler::StoreReady
+// Called when a contact store is ready to use.
+// From MVPbkContactStoreObserver
+// ----------------------------------------------------------------------------
+void CPIMHandler::StoreReady( MVPbkContactStore& aContactStore )
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::StoreReady" );
+    if ( iIsBusy && iContactStore == &aContactStore )
+        {
+        if ( iCommand == CHtiPIMServicePlugin::EImportVCard )
+            {
+            iReadStream.Open( *iBuffer, 0 );
+            HTI_LOG_TEXT( "Starting vCard import" );
+            TRAPD( err, iOp = iVCardEngine->ImportVCardL(
+                    *iContactStore, iReadStream, *this ) );
+            HTI_LOG_FORMAT( "ImpoortVCardL returned %d", err );
+            if ( err != KErrNone )
+                {
+                delete iOp;
+                iOp = NULL;
+                iReadStream.Close();
+                delete iBuffer;
+                iBuffer = NULL;
+                iContactStore->Close( *this );
+                TRAP_IGNORE( SendErrorMessageL( err, KErrorVCardImportFailed ) );
+                }
+            }
+        else if ( iCommand == CHtiPIMServicePlugin::EDeleteContact )
+            {
+            TRAPD( err, CreateContactDeleteViewL() );
+            if ( err != KErrNone )
+                {
+                iContactStore->Close( *this );
+                TRAP_IGNORE( SendErrorMessageL( err, KErrorFailedDelete ) );
+                }
+            }
+        }
+    HTI_LOG_FUNC_OUT( "CPIMHandler::StoreReady" );
+    }
+
+// ----------------------------------------------------------------------------
+// CPIMHandler::StoreUnavailable
+// Called when a contact store becomes unavailable.
+// From MVPbkContactStoreObserver
+// ----------------------------------------------------------------------------
+void CPIMHandler::StoreUnavailable( MVPbkContactStore& aContactStore,
+        TInt aReason )
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::StoreUnavailable" );
+
+    if ( iIsBusy && iContactStore == &aContactStore )
+        {
+        delete iBuffer;
+        iBuffer = NULL;
+        TRAP_IGNORE( SendErrorMessageL( aReason, KErrorVCardImportFailed ) );
+        }
+
+    HTI_LOG_FUNC_OUT( "CPIMHandler::StoreUnavailable" );
+    }
+
+// ----------------------------------------------------------------------------
+// CPIMHandler::HandleStoreEventL
+// Called when changes occur in the contact store.
+// From MVPbkContactStoreObserver
+// ----------------------------------------------------------------------------
+void CPIMHandler::HandleStoreEventL( MVPbkContactStore& /*aContactStore*/,
+                        TVPbkContactStoreEvent /*aStoreEvent*/ )
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::HandleStoreEventL" );
+    HTI_LOG_FUNC_OUT( "CPIMHandler::HandleStoreEventL" );
+    }
+
+// ----------------------------------------------------------------------------
+// CPIMHandler::ContactsSaved
+// Called when the contact has been successfully commited or copied.
+// From MVPbkContactCopyObserver
+// ----------------------------------------------------------------------------
+void CPIMHandler::ContactsSaved( MVPbkContactOperationBase& aOperation,
+        MVPbkContactLinkArray* aResults )
+{
+    HTI_LOG_FUNC_IN( "CPIMHandler::ContactsSaved" );
+
+    if ( iIsBusy && iOp == &aOperation )
+        {
+        TInt count = aResults->Count();
+        HTI_LOG_FORMAT( "%d contact(s) added", count );
+        delete aResults;
+        delete iOp;
+        iOp = NULL;
+        iReadStream.Close();
+        delete iBuffer;
+        iBuffer = NULL;
+        iContactStore->Close( *this );
+        TInt entryId = 0; // We can't get the ID, just send zero
+        TBuf8<4> idBuf;
+        idBuf.Append( ( TUint8* ) &entryId, 4 );
+        TRAP_IGNORE( SendOkMsgL( idBuf ) );
+        }
+
+    HTI_LOG_FUNC_OUT( "CPIMHandler::ContactsSaved" );
+}
+
+// ----------------------------------------------------------------------------
+// CPIMHandler::ContactsSavingFailed
+// Called when there was en error while saving contact(s).
+// From MVPbkContactCopyObserver
+// ----------------------------------------------------------------------------
+void CPIMHandler::ContactsSavingFailed(
+        MVPbkContactOperationBase& aOperation, TInt aError )
+{
+    HTI_LOG_FUNC_IN( "CPIMHandler::ContactsSavingFailed" );
+
+    if ( iIsBusy && iOp == &aOperation )
+        {
+        delete iOp;
+        iOp = NULL;
+        iReadStream.Close();
+        delete iBuffer;
+        iBuffer = NULL;
+        iContactStore->Close( *this );
+        TRAP_IGNORE( SendErrorMessageL( aError, KErrorVCardImportFailed ) );
+        }
+
+    HTI_LOG_FUNC_OUT( "CPIMHandler::ContactsSavingFailed" );
+}
+
+// ----------------------------------------------------------------------------
+// CPIMHandler::ContactViewReady
+// Called when a view is ready for use.
+// From MVPbkContactViewObserver
+// ----------------------------------------------------------------------------
+void CPIMHandler::ContactViewReady( MVPbkContactViewBase& aView )
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::ContactViewReady" );
+
+    if ( iContactView == &aView && iIsBusy &&
+            iCommand == CHtiPIMServicePlugin::EDeleteContact )
+        {
+        TRAPD( err, DeleteContactsInViewL() );
+        if ( err != KErrNone )
+            {
+            TRAP_IGNORE( SendErrorMessageL( err, KErrorFailedDelete ) );
+            }
+        }
+
+    HTI_LOG_FUNC_OUT( "CPIMHandler::ContactViewReady" );
+    }
+
+// ----------------------------------------------------------------------------
+// CHtiSimDirHandlerVPbk::ContactViewUnavailable
+// Called when a view is unavailable for a while.
+// From MVPbkContactViewObserver
+// ----------------------------------------------------------------------------
+void CPIMHandler::ContactViewUnavailable( MVPbkContactViewBase& /*aView*/ )
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::ContactViewUnavailable" );
+    HTI_LOG_FUNC_OUT( "CPIMHandler::ContactViewUnavailable" );
+    }
+
+// ----------------------------------------------------------------------------
+// CPIMHandler::ContactAddedToView
+// Called when a contact has been added to the view.
+// From MVPbkContactViewObserver
+// ----------------------------------------------------------------------------
+void CPIMHandler::ContactAddedToView( MVPbkContactViewBase& /*aView*/,
+        TInt /*aIndex*/, const MVPbkContactLink& /*aContactLink*/ )
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::ContactAddedToView" );
+    HTI_LOG_FUNC_OUT( "CPIMHandler::ContactAddedToView" );
+    }
+
+// ----------------------------------------------------------------------------
+// CPIMHandler::ContactRemovedFromView
+// Called when a contact has been removed from a view.
+// From MVPbkContactViewObserver
+// ----------------------------------------------------------------------------
+void CPIMHandler::ContactRemovedFromView( MVPbkContactViewBase& /*aView*/,
+        TInt /*aIndex*/, const MVPbkContactLink& /*aContactLink*/ )
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::ContactRemovedFromView" );
+    HTI_LOG_FUNC_OUT( "CPIMHandler::ContactRemovedFromView" );
+    }
+
+// ----------------------------------------------------------------------------
+// CPIMHandler::ContactViewError
+// Called when an error occurs in the view.
+// From MVPbkContactViewObserver
+// ----------------------------------------------------------------------------
+void CPIMHandler::ContactViewError( MVPbkContactViewBase& aView,
+        TInt aError, TBool aErrorNotified )
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::ContactViewError" );
+    HTI_LOG_FORMAT( "CPIMHandler::ContactViewError: %d", aError );
+    HTI_LOG_FORMAT( "ErrorNotified = %d", aErrorNotified );
+    if ( iContactView == &aView )
+        {
+        iContactView->RemoveObserver( *this );
+        delete iContactView;
+        iContactView = NULL;
+        if ( iIsBusy && iCommand == CHtiPIMServicePlugin::EDeleteContact )
+            {
+            SendErrorMessageL( aError, KErrorFailedDelete );
+            }
+        iContactStore->Close( *this );
+        }
+    aErrorNotified = aErrorNotified;  // avoid compiler warning
+    HTI_LOG_FUNC_OUT( "CPIMHandler::ContactViewError" );
+    }
+
+// ----------------------------------------------------------------------------
+// CPIMHandler::StepComplete
+// Called when one step of the batch operation is complete.
+// From MVPbkBatchOperationObserver
+// ----------------------------------------------------------------------------
+void CPIMHandler::StepComplete( MVPbkContactOperationBase& /*aOperation*/,
+                           TInt /*aStepSize*/ )
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::StepComplete" );
+    HTI_LOG_FUNC_OUT( "CPIMHandler::StepComplete" );
+    }
+
+// ----------------------------------------------------------------------------
+// CPIMHandler::StepFailed
+// Called when one step of the batch operation fails.
+// From MVPbkBatchOperationObserver
+// ----------------------------------------------------------------------------
+TBool CPIMHandler::StepFailed( MVPbkContactOperationBase& aOperation,
+                                         TInt /*aStepSize*/, TInt aError )
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::StepFailed" );
+    HTI_LOG_FORMAT( "Error %d", aError );
+    if ( iOp == &aOperation )
+        {
+        // We are returning EFalse (= do not continue) we can delete
+        // the operation. OperationComplete() won't be called.
+        delete iOp;
+        iOp = NULL;
+        iContactStore->Close( *this );
+        TRAP_IGNORE( SendErrorMessageL( aError, KErrorFailedDelete ) );
+        }
+    HTI_LOG_FUNC_OUT( "CPIMHandler::StepFailed" );
+    return EFalse; // do not continue
+    }
+
+// ----------------------------------------------------------------------------
+// CPIMHandler::OperationComplete
+// Called when operation is completed.
+// From MVPbkBatchOperationObserver
+// ----------------------------------------------------------------------------
+void CPIMHandler::OperationComplete(
+            MVPbkContactOperationBase& aOperation )
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::OperationComplete" );
+    // Operation is complete -> delete it
+    if ( iOp == &aOperation )
+        {
+        delete iOp;
+        iOp = NULL;
+        iContactStore->Close( *this );
+        if ( iIsBusy && iCommand == CHtiPIMServicePlugin::EDeleteContact )
+            {
+            // Delete operation has completed
+            TRAP_IGNORE( SendOkMsgL( KNullDesC8 ) );
+            }
+        }
+    HTI_LOG_FUNC_OUT( "CPIMHandler::OperationComplete" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CPIMHandler::Progress
+// Called during calendar entry view creation and operations.
+// Called only if NotifyProgress returns ETrue.
+// From MCalProgressCallBack
+// ----------------------------------------------------------------------------
+void CPIMHandler::Progress( TInt /*aProgress*/ )
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CPIMHandler::Completed
+// Called on completion of calendar entry view creation and operations
+// From MCalProgressCallBack
+// ----------------------------------------------------------------------------
+void CPIMHandler::Completed( TInt aError )
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::Completed" );
+    HTI_LOG_FORMAT( "Completed with error code %d", aError );
+    iEntryViewErr = aError;
+    iWaiter->AsyncStop();
+    HTI_LOG_FUNC_OUT( "CPIMHandler::Completed" );
+    }
+
+// ----------------------------------------------------------------------------
+// CPIMHandler::NotifyProgress
+// Returns whether or not progress notification is required
+// From MCalProgressCallBack
+// ----------------------------------------------------------------------------
+TBool CPIMHandler::NotifyProgress()
+    {
+    HTI_LOG_FUNC_IN( "CPIMHandler::NotifyProgress" );
+    HTI_LOG_FUNC_OUT( "CPIMHandler::NotifyProgress" );
+    return EFalse; // Don't notify about progress
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiPIMServicePlugin/src/proxy.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,37 @@
+/*
+* 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:  Implementation proxy for PIM service plugin dll
+*
+*/
+
+
+// INCLUDE FILES
+#include "HtiPIMServicePlugin.h"
+
+#include <e32std.h>
+#include <ecom/implementationproxy.h>
+
+// Provides a key value pair table, this is used to identify
+// the correct construction function for the requested interface.
+const TImplementationProxy ImplementationTable[] =
+    {
+    IMPLEMENTATION_PROXY_ENTRY( 0x200212C4, CHtiPIMServicePlugin::NewL )
+    };
+
+// Function used to return an instance of the proxy table.
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    return ImplementationTable;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiScreenshotServicePlugin/data/1020DEC2.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,48 @@
+/*
+* 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:  Resource definitions for screenshot service ECOM plugin.
+*
+*/
+
+
+// INCLUDES
+#include <ecom/registryinfo.rh>
+
+//  RESOURCE DEFINITIONS
+RESOURCE REGISTRY_INFO theInfo
+    {
+    // UID for the DLL
+    dll_uid = 0x1020DEC2;
+    // Declare array of interface info
+    interfaces =
+        {
+        INTERFACE_INFO
+            {
+            // UID of interface that is implemented
+            interface_uid = 0x1020DEB7;
+            implementations =
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = 0x1020DEC3;
+                    version_no         = 1;
+                    display_name       = "Screenshot service";
+                    default_data       = "SCREEN";
+                    opaque_data        = "";
+                    }
+                };
+            }
+        };
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiScreenshotServicePlugin/group/HtiScreenshotServicePlugin.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,59 @@
+/*
+* 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:  HTI service plugin for taking screenshot.
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          HtiScreenshotServicePlugin.dll
+TARGETTYPE      PLUGIN
+
+// ECom Dll recognition UID followed by the unique UID for this dll
+UID             0x10009D8D 0x1020DEC2
+
+VENDORID        0x101FB657
+
+CAPABILITY      ALL -TCB
+
+SOURCEPATH      ../src
+SOURCE          proxy.cpp
+SOURCE          HtiScreenshotServicePlugin.cpp
+SOURCE          HtiTextRcg.cpp
+
+USERINCLUDE     ../inc
+APP_LAYER_SYSTEMINCLUDE
+
+START RESOURCE  ../data/1020DEC2.rss
+TARGET          HtiScreenshotServicePlugin.rsc
+END
+
+LIBRARY         avkon.lib  // AknUtils for font handling
+LIBRARY         bitgdi.lib
+LIBRARY         ecom.lib
+LIBRARY         efsrv.lib
+LIBRARY         egul.lib
+LIBRARY         euser.lib
+LIBRARY         ezlib.lib
+LIBRARY         fbscli.lib
+LIBRARY         gdi.lib
+LIBRARY         hal.lib
+LIBRARY         imageconversion.lib
+LIBRARY         ws32.lib
+LIBRARY         flogger.lib
+
+SMPSAFE
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiScreenshotServicePlugin/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,26 @@
+/*
+* 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:  Build information file for HtiScreenshotServicePlugin
+*
+*/
+
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+HtiScreenshotServicePlugin.mmp
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiScreenshotServicePlugin/inc/HtiScreenshotServicePlugin.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,262 @@
+/*
+* 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:  Implementation of ECOM plug-in service interface. Provides
+*                screenshot service.
+*
+*/
+
+
+#ifndef SCREENSHOOTPLUGIN_H
+#define SCREENSHOOTPLUGIN_H
+
+// INCLUDES
+#include <HTIServicePluginInterface.h>
+#include <w32std.h>
+#include <f32file.h>
+#include "HtiTextRcg.h"
+
+
+// FORWARD DECLARATIONS
+class CImageEncoder;
+
+
+// CLASS DECLARATIONS
+class MICLObserver
+    {
+public:
+    virtual void ICLComplete( TInt anError) = 0;
+    };
+
+class CICLHandler : public CActive
+    {
+public:
+    CICLHandler(CImageEncoder* aService, MICLObserver* anObserver);
+    ~CICLHandler();
+
+    void Start();
+
+protected: //from CActive
+    void RunL();
+    void DoCancel();
+    //TInt RunError(TInt aError);
+
+protected:
+    MICLObserver* iObserver;
+    CImageEncoder* iService;
+    };
+
+
+
+
+
+class MSeriesShotTimerObserver
+    {
+public:
+    virtual void TimerExpired( TInt aId ) = 0;
+    };
+
+
+
+class CSeriesShotTimer : public CTimer
+    {
+public:
+    static CSeriesShotTimer* NewL(MSeriesShotTimerObserver* aObserver,
+                                 TInt aId,
+                                 TTimeIntervalMicroSeconds32 aTime);
+    ~CSeriesShotTimer();
+    void Start();
+
+protected:
+    void ConstructL();
+    CSeriesShotTimer(MSeriesShotTimerObserver* aObserver,
+                    TInt aId,
+                    TTimeIntervalMicroSeconds32 aTime);
+public: // from CTimer
+    void RunL();
+
+private:
+    MSeriesShotTimerObserver* iObserver;
+    TInt iId;
+    TTimeIntervalMicroSeconds32 iTime;
+    };
+
+
+class MSeriesShotObserver
+    {
+public:
+    virtual void SeriesShotCompletedL( HBufC8* aMsg ) = 0;
+    virtual TBool StartShotL(TRect aRegion, TDisplayMode aDisplayMode, TDesC8 &aMimeType) = 0;
+    };
+
+
+class CHtiScreenshotServicePlugin; // forward declaration
+
+class CSeriesShot : public CBase,
+                    public MSeriesShotTimerObserver
+    {
+    enum TTimerType
+        {
+        EDuration,
+        EInterval
+        };
+public:
+    static CSeriesShot* NewL( MSeriesShotObserver* aServicePluginObserver );
+    CSeriesShot( MSeriesShotObserver* aServicePluginObserver );
+    virtual ~CSeriesShot();
+
+    void StartL( TTimeIntervalMicroSeconds32 aDuration,
+                 TTimeIntervalMicroSeconds32 aInterval,
+                 TDisplayMode aDisplayMode,
+                 TRect aRegion,
+                 TPtrC8 aMime);
+    TBool IsOngoing();
+    void SaveImage( TDesC8* aImage, TBool isCompressed );
+    void TriggerNewShot();
+    void Cancel();
+    void EncodeCompleted();
+    HBufC8* ConstructCompletedMessageL();
+
+protected:
+    void ConstructL();
+    void ClearShots();
+    void GetMIMEExtension(TDesC8 &aMime, TDes &aExt);
+
+public: // from MSeriesShotTimerObserver
+    void TimerExpired(TInt aId);
+
+private:
+    MSeriesShotObserver* iServicePluginObserver;
+    CSeriesShotTimer* iDurationTimer;
+    CSeriesShotTimer* iIntervalTimer;
+    TDisplayMode iDisplayMode;
+    TInt iIndex;
+    RFs iFs;
+    TBool isEncoding;
+    TBuf8<30> iMimeType;
+    TBuf<10>  iExtension;
+    TRect iRegion;
+    };
+
+
+
+class CHtiScreenshotServicePlugin : public CHTIServicePluginInterface,
+                                    public MICLObserver,
+                                    public MSeriesShotObserver
+    {
+public:
+
+    static CHtiScreenshotServicePlugin* NewL();
+
+    // Interface implementation
+    TBool IsBusy();
+    void ProcessMessageL(const TDesC8& aMessage, THtiMessagePriority aPriority);
+    void NotifyMemoryChange( TInt aAvailableMemory );
+
+    // Observer implementation
+    void ICLComplete( TInt anError); // from MICLObserver
+    void SeriesShotCompletedL( HBufC8* aMsg ); // from MSeriesShotObserver
+    TBool StartShotL(TRect aRegion, TDisplayMode aDisplayMode, TDesC8 &aMimeType); // from MSeriesShotObserver
+
+protected:
+
+    void ProcessTextRcgMessageL(const TDesC8& aMessage);
+    void ProcessTextBitmapMessageL(const TDesC8& aMessage);
+
+    void SendTextRecgReplyL(const TBool aResult, const TRect& aLocation,
+                            const TInt aFontIndex);
+
+
+    /**
+    * Selects fonts based on predefined platform-dependent strategy
+    *
+    */
+    TBool RecognizeTextL(const TDesC& aText,
+                        TRect& aResult,
+                        TInt& aFontIndex);
+
+    /**
+    * Extracts string from incoming request and convert it to unicode
+    * for non-unicode request
+    * aResult should have enough length
+    * Function returns either offset for a next parameter in aRequest
+    * or some symbian error code
+    */
+    TInt ParseString( const TDesC8& aRequest,
+                        TInt anOffset,
+                        TBool aUnicode,
+                        TDes& aResult);
+
+    void CopyUnicode( TDes & aTo, const TDesC8& aFrom );
+
+    /**
+    * Extract from request font description (font name, height, style)
+    */
+    TInt ParseFontSpec( const TDesC8& aRequest,
+                        TInt anOffset,
+                        TBool aUnicode,
+                        TFontSpec& aResult);
+
+    CWsScreenDevice* GetScreenDeviceL();
+
+    void CreateBitmapL( TRect& aRegion, TDisplayMode aMode = ENone);
+
+    void SelectEncoder( const TUid aEncoderUid );
+
+    //encode iScreen
+    void EncodeBitmapL(const TDesC8& aImageTypeMIME = KNullDesC8);
+
+    inline TInt ParseInt16( const TUint8* aStart );
+    inline TInt ParseInt32( const TUint8* aStart );
+
+    /**
+    * Compress content of iEncodedBitmap descriptor
+    */
+    TInt Compress();
+
+    CHtiScreenshotServicePlugin();
+    void ConstructL();
+
+    virtual ~CHtiScreenshotServicePlugin();
+
+    //void InitFontCache();
+
+    TBool IsMIMETypeSupported(TDesC8 &aMime);
+
+protected:
+    CFbsBitmap* iScreen; //raw screen bitmap
+    HBufC8* iEncodedBitmap; //ready to send
+
+    RWsSession iWs;
+    CWsScreenDevice* iScreenDevice;
+
+    CImageEncoder* iBitmapEncoder;
+    CICLHandler* iICLHandler;
+
+    TBool iCompress;
+
+    //text recognition algorithms
+    CHtiTextRcg iTextRcg;
+    //fonts to use for recognition
+    RArray<TFontSpec> iFontCache;
+
+    // Series shot implementation
+    CSeriesShot*    iSeriesShot;
+
+    // Members for deltacapture
+    TBool       iDeltaCapture;
+    CFbsBitmap* iPreviousBitmap;
+    TRect       iDeltaRect;
+    };
+
+#endif // SCREENSHOOTPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiScreenshotServicePlugin/inc/HtiTextRcg.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,178 @@
+/*
+* 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:  Text recognition algorithm implementation.
+*
+*/
+
+
+#ifndef __HTI_TEXT_RCG_
+#define __HTI_TEXT_RCG_
+
+#include <fbs.h>
+#include <gulfont.h>
+#include <e32math.h>
+
+const TInt KDefaultAvgDiffMin = 50;
+const TInt KDefaultFgSSMin = 50;
+const TInt KDefaultFgAvgDiffMin = 5; //in "pure" (not AA) pixels
+const TInt KWorstCase = 0xFF;
+const TInt KSuccessThresold = 50;
+const TInt KNormCoefAcc = 2;
+
+const TInt KDefaultFGAAmount = 5;
+const TInt KDefaultBGAAmount = 10;
+
+const TInt KFgPatternColor = 0x00; //black
+const TInt KBgPatternColor = 0xff; //white
+
+TInt CompareTPoint(const TPoint& aP1,const TPoint& aP2);
+
+enum THtiTextRecgHints
+    {
+    EHintNone = 0,
+    EHintEdge = 1
+    };
+
+/**
+* The class implements text recognition algorithm on screenshots
+* based on system fonts
+*
+*/
+class CHtiTextRcg : public CBase
+{
+public:
+    CHtiTextRcg();
+    virtual ~CHtiTextRcg();
+
+    void SetHint(TInt aHint);
+
+    TBool RecognizeTextL(CFbsBitmap* aScreenshot,
+                        const TDesC& aText,
+                        const CFont* aFont,
+                        TRect& aResult);
+
+    /**
+    * aResult will contain the coordinates of the found text
+    *  Return 0 if match is perfect, 255 if text was not found
+    * return value from 0 to 255 means some error, the lower it is the better match
+    *
+    */
+    //brute force optim
+    TInt RecognizeAAL(CFbsBitmap* aScreenshot,const TDesC& aText, const CFont* aFont, TRect& aResult);
+    //brute force clean optim
+    TInt RecognizeBinL(CFbsBitmap* aScreenshot,const TDesC& aText, const CFont* aFont, TRect& aResult);
+
+    //static image processing routines
+    //convert image to 256-greyscale
+    static CFbsBitmap* ColorDownL(CFbsBitmap * aBitmap);
+    //generates bitmap of the text using the font given
+
+    static CFbsBitmap* GetTextBitmapL( const TDesC& aText,
+                            const CFont* fontUsed,
+                            const TInt aLength = KMaxTInt );
+
+    static CFbsBitmap* GetTextBitmapL( const TDesC& aText,
+                            const CFont* fontUsed,
+                            TRgb aForeground,
+                            TRgb aBackground,
+                            TDisplayMode aDisplayMode,
+                            const TInt aLength = KMaxTInt );
+
+    //calculates min max of a greyscale bitmap in question
+    static void MinMax(CFbsBitmap * aBitmap, TInt& aMin, TInt& aMax);
+
+    /**
+    * use FGA and BGA to speed-up comparation
+    * this function only returns 255 or 0
+    * Analyses only min and max colors
+    */
+    TInt ImageDiffBinSampleL(CFbsBitmap * aBitmap1, TPoint aOrigin1,
+                 CFbsBitmap * aBitmap2);
+
+    /**
+    * Iterations like in Diff5 but metrics from Diff6
+    * Used for full word checking if Diff6 is 0 for a letter
+    * this function only returns 255 or 0
+    */
+    TInt ImageDiffBinFullL(CFbsBitmap * aBitmap1, TPoint aOrigin1,
+                 CFbsBitmap * aBitmap2);
+
+    /**
+    * use FGA and BGA to speed-up comparation and AA pixels
+    */
+    TInt ImageDiffAASampleL(CFbsBitmap * aBitmap1, TPoint aOrigin1,
+                 CFbsBitmap * aBitmap2);
+
+    /**
+    * Iterations like in Diff5 but metrics from Diff6/DiffAASample
+    * Used for full word checking if Diff6 is 0 for a letter
+    */
+    TInt ImageDiffAAFullL(CFbsBitmap * aBitmap1, TPoint aOrigin1,
+                 CFbsBitmap * aBitmap2);
+
+    /*
+    * Analyze pattern and fills in FGA and BGA sets
+    * Return ETrue if pattern is valid (non empty)
+    */
+    TBool AnalyzePatternL(CFbsBitmap * aPattern);
+
+private:
+    //algorithm parameters
+    //minimal abs avarage difference beetwen foreground and background
+    TInt iAvgDiffMin;
+    //minimal SS for foreground, with plain color should be 0
+    TInt iFgSSMin;
+    /**
+    * minimal avg diff for foreground, used in Diff3
+    */
+    TInt iFgAvgDiffMin;
+
+    //TInt64 iSeed;
+
+    //following vars set by AnalyzePatternL
+    TInt iFGAAmount;
+    TInt iBGAAmount;
+    //foreground assesment point set
+    RArray<TPoint> iFGASet;
+    //background assesment point set
+    RArray<TPoint> iBGASet;
+
+    //font color in reference image
+    TInt iMaskFgColor;//
+    //background color in reference image
+    TInt iMaskBgColor;//
+
+    //used for AA algorithm
+    //set in Sample function and used in Full function
+    //for optimization
+    TInt iTestFgColor;
+    TInt iTestBgColor;
+
+    // normalization coeff to compare test image with mask directly
+    // |iMaskFgColor-iMaskBgColor|*NormCoefAcc)/|iTestFgColor-iTestBgColor|
+    // where NormCoefAcc multiplyer is used to increase accuracy (all ints)
+    // and is implemented as shif by KNormCoefAcc bits
+    // back shift is performed after color is multiplied by iTestNormCoef
+    TInt iTestNormCoef;
+
+    /**
+    * Current recognition method
+    * Changed by SetHint
+    */
+    TInt iCurrentStrategy;
+};
+
+#endif //__HTI_TEXT_RCG_
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiScreenshotServicePlugin/src/HtiScreenshotServicePlugin.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,2274 @@
+/*
+* 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:  SysInfoPlugin implementation
+*
+*/
+
+
+// INCLUDE FILES
+#include "HtiScreenshotServicePlugin.h"
+#include <HtiDispatcherInterface.h>
+#include <HTILogging.h>
+
+#include <ImageConversion.h>
+#include <EZCompressor.h>
+#include <hal.h>
+
+// CONSTANTS
+const static TUid KScreenshotServiceUid = {0x1020DEC3};
+
+enum TScreenCommands
+    {
+    // Normal screencapture
+    ECmdScreen                = 0x01,
+    ECmdScreenRegion          = 0x02,
+    ECmdScreenZip             = 0x03,
+    ECmdScreenRegionZip       = 0x04,
+
+    // Text recognition
+    ECmdTextRcg               = 0x10,
+    ECmdTextRcg_u             = 0x11,
+
+    // Text bitmap
+    ECmdTextBitmap            = 0x12,
+    ECmdTextBitmap_u          = 0x13,
+
+    // Screencapture in series
+    ECmdScreenSeries          = 0x21,
+    ECmdScreenRegionSeries    = 0x22,
+    ECmdScreenZipSeries       = 0x23,
+    ECmdScreenRegionZipSeries = 0x24,
+
+    // Selects the screen to use
+    ECmdSelectScreen          = 0x30,
+
+    // Gets the current screen size and orientation
+    ECmdScreenMode            = 0x3A,
+
+    // Screencapture on updated part of screen only
+    ECmdDeltaCaptureMask           = 0x80,
+    ECmdDeltaScreen                = 0x81,
+    ECmdDeltaScreenRegion          = 0x82,
+    ECmdDeltaScreenZip             = 0x83,
+    ECmdDeltaScreenRegionZip       = 0x84,
+    ECmdDeltaScreenReset           = 0x85
+    //ECmdDeltaScreenSeries          = 0xA1,
+    //ECmdDeltaScreenRegionSeries    = 0xA2,
+    //ECmdDeltaScreenZipSeries       = 0xA3,
+    //ECmdDeltaScreenRegionZipSeries = 0xA4
+    };
+
+enum TScreenResponse
+    {
+    ERspOk = 0xF0,
+    ERspNotFound = 0xF1
+    };
+
+enum THtiFontAttributes
+    {
+    EHtiFontAttBold = 0x01,
+    EHtiFontAttItalic = 0x02,
+    EHtiFontAttNotAA = 0x04,
+    EHtiFontAttPrintPositionFlag = 0x08,
+    EHtiFontAttPrintPositionValue = 0x10
+    };
+
+const static TInt KHtiFontAttSuperscriptValue = 0;
+const static TInt KHtiFontAttSubscriptValue = 1;
+
+//1 byte for cmd and 2*4 for 4 coordinates
+const static TInt KMinScreenRegionCmdLength = 9;
+const static TInt KScreenDisplayOffset = 1;
+const static TInt KScreenMIMEOffset = KScreenDisplayOffset + 1;
+const static TInt KRegionDisplayOffset = KMinScreenRegionCmdLength;
+const static TInt KRegionMIMEOffset = KRegionDisplayOffset + 1;
+
+
+const static TInt KSeriesDurationOffset = 1;
+const static TInt KSeriesIntervalOffset = KSeriesDurationOffset + 4;
+const static TInt KSeriesDisplayOffset = KSeriesIntervalOffset + 4;
+const static TInt KSeriesMIMEOffset = KSeriesDisplayOffset + 1;
+const static TInt KMinSeriesCmdLength = KSeriesMIMEOffset;
+
+const static TInt KRegionSeriesTlX = KSeriesDisplayOffset + 1;
+const static TInt KRegionSeriesTlY = KRegionSeriesTlX + 2;
+const static TInt KRegionSeriesBlX = KRegionSeriesTlY + 2;
+const static TInt KRegionSeriesBlY = KRegionSeriesBlX + 2;
+const static TInt KRegionSeriesMIMEOffset = KRegionSeriesBlY + 2;
+const static TInt KMinRegionSeriesCmdLength = KRegionSeriesMIMEOffset;
+
+const static TInt KDeltaResetCmdLength = 1;
+const static TInt KScreenModeCmdLength = 1;
+
+const static TInt KScreenNrOffset = 1;
+const static TInt KSelectScreenCmdLength = 2;
+
+_LIT( KSeriesShotPath, "c:\\Hti\\SeriesShot\\" );
+
+//errors' descriptions
+_LIT8( KErrDescrInvalid, "invalid arguments" );
+_LIT8( KErrDescrInvalidMode, "invalid color mode" );
+_LIT8( KErrDescrRegiontEmpty, "region is empty" );
+_LIT8( KErrDescrRegionNotNormailized, "region is not normalized" );
+_LIT8( KErrDescrRegionOutOfScreen, "region is out of screen" );
+_LIT8( KErrDescrUnknownCommand, "unknown command" );
+_LIT8( KErrDescrFailedConvert, "failed to convert to image format" );
+_LIT8( KErrDescrFailedCompress, "failed to compress" );
+_LIT8( KErrDescrMIMENotSupported, "MIME type not supported" );
+_LIT8( KErrDescrScreenNotSupported, "screen not supported" );
+
+_LIT( KScreenshotPanic, "Screenshot plug-in invalid state" );
+
+//_LIT(KS60Sans, "Series 60 Sans");
+//_LIT(KS60SansTitleBold, "Series 60 Sans TitleSmBd");
+
+//const TInt KFonHeighMin = 110;
+//const TInt KFonHeighMax = 190;
+/*
+// ----------------------------------------------------------------------------
+void CHtiScreenshotServicePlugin::InitFontCache()
+    {
+    //temporary
+    //just put harcoded data
+    //should be either external file or auto-defined based on logical fonts
+    //or some test app
+    TFontSpec fs;
+    fs.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
+    //primary font
+    fs.iTypeface.iName = KS60Sans;
+    fs.iHeight = 161;
+    fs.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
+    iFontCache.Append(fs);
+
+    fs.iFontStyle.SetStrokeWeight(EStrokeWeightNormal);
+
+    //Series 60 Sans TitleSmBd, 183
+    fs.iTypeface.iName = KS60SansTitleBold;
+    fs.iHeight = 183;
+    iFontCache.Append(fs);
+
+    //Series 60 Sans TitleSmBd, 172
+    fs.iTypeface.iName = KS60SansTitleBold;
+    fs.iHeight = 172;
+    iFontCache.Append(fs);
+
+    //Series 60 Sans,           122
+    fs.iTypeface.iName = KS60Sans;
+    fs.iHeight = 122;
+    iFontCache.Append(fs);
+    //Series 60 Sans,           116
+    fs.iTypeface.iName = KS60Sans;
+    fs.iHeight = 116;
+    iFontCache.Append(fs);
+
+    //Series 60 Sans TitleSmBd, 138
+    fs.iTypeface.iName = KS60SansTitleBold;
+    fs.iHeight = 138;
+    iFontCache.Append(fs);
+    }
+*/
+
+// ----------------------------------------------------------------------------
+TInt ImageDifferenceL( CFbsBitmap* aImage1, CFbsBitmap* aImage2,
+                       CFbsBitmap* &aResult, TRect &aRect )
+    {
+    HTI_LOG_TEXT( "ImageDifferenceL()" );
+
+    // By default return coordinates of the full image
+    aRect = TRect( 0, 0, aImage2->SizeInPixels().iWidth,
+                  aImage2->SizeInPixels().iHeight );
+
+//1. check that aImage1 and aImage2 are valid and can be compared
+    if ( aImage1 == NULL || aImage2 == NULL )
+        {
+        HTI_LOG_TEXT( "return KErrArgument" );
+        return KErrArgument;
+        }
+
+    if ( aImage1->SizeInPixels() != aImage2->SizeInPixels() )
+        {
+        HTI_LOG_TEXT( "return KErrGeneral (size)" );
+        return KErrGeneral;
+        }
+
+    if ( aImage1->DisplayMode() != aImage2->DisplayMode() )
+        {
+        HTI_LOG_TEXT( "return KErrGeneral (displaymode)" );
+        return KErrGeneral;
+        }
+
+
+//2. iterate through images from each border and compare to findout outline for diff region
+    TSize orgSize = aImage1->SizeInPixels();
+
+    TBitmapUtil srcBmpIterator1( aImage1 );
+    TBitmapUtil srcBmpIterator2( aImage2 );
+
+    srcBmpIterator1.Begin( TPoint( 0, 0 ) );
+    srcBmpIterator2.Begin( TPoint( 0, 0 ), srcBmpIterator1 );
+
+    TRect diffOutline = TRect( -1, -1, -1, -1 );
+
+    //2.1 top border iteration
+    TPoint c( 0,0 );
+    for ( ; c.iY < orgSize.iHeight && diffOutline.iTl.iY == -1; ++c.iY )
+        {
+        c.iX = 0;
+        srcBmpIterator1.SetPos( c );
+        srcBmpIterator2.SetPos( c );
+        for ( ; c.iX < orgSize.iWidth && diffOutline.iTl.iY == -1; ++c.iX )
+            {
+            if ( srcBmpIterator1.GetPixel() != srcBmpIterator2.GetPixel() )
+                {
+                diffOutline.iTl.iY = c.iY;
+                }
+
+            srcBmpIterator1.IncXPos();
+            srcBmpIterator2.IncXPos();
+            }
+        }
+
+    //2.2 bottom iteration
+    c.SetXY( 0, orgSize.iHeight - 1 );
+    for ( ; c.iY >= diffOutline.iTl.iY && diffOutline.iBr.iY == -1; --c.iY )
+        {
+        c.iX = 0;
+        srcBmpIterator1.SetPos( c );
+        srcBmpIterator2.SetPos( c );
+        for (; c.iX < orgSize.iWidth && diffOutline.iBr.iY == -1; ++c.iX )
+            {
+            if ( srcBmpIterator1.GetPixel() != srcBmpIterator2.GetPixel() )
+                {
+                diffOutline.iBr.iY = c.iY;
+                }
+
+            srcBmpIterator1.IncXPos();
+            srcBmpIterator2.IncXPos();
+            }
+        }
+
+    //2.3 left, goes in vertical lines
+    c.SetXY( 0, diffOutline.iTl.iY );
+    for ( ; c.iX < orgSize.iWidth && diffOutline.iTl.iX == -1; ++c.iX )
+        {
+        c.iY = diffOutline.iTl.iY;
+        srcBmpIterator1.SetPos( c );
+        srcBmpIterator2.SetPos( c );
+        for ( ; c.iY <= diffOutline.iBr.iY && diffOutline.iTl.iX == -1; ++c.iY )
+
+            {
+            if ( srcBmpIterator1.GetPixel() != srcBmpIterator2.GetPixel() )
+                {
+                diffOutline.iTl.iX = c.iX;
+                }
+
+            srcBmpIterator1.IncYPos();
+            srcBmpIterator2.IncYPos();
+            }
+        }
+    //2.4 right, goes in vertical lines
+    c.SetXY( orgSize.iWidth - 1, diffOutline.iTl.iY );
+    for ( ; c.iX >= diffOutline.iTl.iX && diffOutline.iBr.iX == -1; --c.iX )
+        {
+        c.iY = diffOutline.iTl.iY;
+        srcBmpIterator1.SetPos( c );
+        srcBmpIterator2.SetPos( c );
+        for ( ; c.iY <= diffOutline.iBr.iY && diffOutline.iBr.iX == -1; ++c.iY )
+
+            {
+            if ( srcBmpIterator1.GetPixel() != srcBmpIterator2.GetPixel() )
+                {
+                diffOutline.iBr.iX = c.iX;
+                }
+
+            srcBmpIterator1.IncYPos();
+            srcBmpIterator2.IncYPos();
+            }
+        }
+    srcBmpIterator2.End();
+    srcBmpIterator1.End();
+
+    //3. if there is some diff create CFbsBitmap in aResult and copy outlined image from aImage2
+    if ( diffOutline.iTl.iX == -1 &&
+         diffOutline.iTl.iY == -1 &&
+         diffOutline.iBr.iX == -1 &&
+         diffOutline.iBr.iY == -1 )
+        {
+        // No difference found
+        aRect = TRect( 0, 0, 0, 0 );
+        HTI_LOG_TEXT( "return KErrNotFound" );
+        return KErrNotFound;
+        }
+
+    aRect = diffOutline;
+
+    HTI_LOG_FORMAT( "Tlx - %d", aRect.iTl.iX );
+    HTI_LOG_FORMAT( "Tly - %d", aRect.iTl.iY );
+    HTI_LOG_FORMAT( "Bty - %d", aRect.iBr.iX );
+    HTI_LOG_FORMAT( "Bry - %d", aRect.iBr.iY );
+
+    // The bottom right co-ordinate is not included in the rectange
+    // (see TRect documentation) so we need to stretch the rectange
+    // for BitBlt to get the correct sized image.
+
+    TRect captureRect( diffOutline.iTl.iX, diffOutline.iTl.iY,
+                       diffOutline.iBr.iX + 1, diffOutline.iBr.iY + 1 );
+
+    aResult = new (ELeave) CFbsBitmap();
+    User::LeaveIfError( aResult->Create( captureRect.Size(), aImage2->DisplayMode() ) );
+    CleanupStack::PushL( aResult );
+
+    CFbsBitmapDevice* bmpDevice = CFbsBitmapDevice::NewL( aResult );
+    CleanupStack::PushL( bmpDevice );
+
+    CFbsBitGc* bmpCtx;
+    bmpDevice->CreateContext( bmpCtx );
+    bmpCtx->BitBlt( TPoint( 0, 0 ), aImage2, captureRect );
+
+    delete bmpCtx;
+    bmpCtx = NULL;
+
+    CleanupStack::PopAndDestroy(); // bmpDevice
+    CleanupStack::Pop(); // aResult
+
+    HTI_LOG_TEXT( "return KErrNone" );
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+CICLHandler::CICLHandler( CImageEncoder* aService, MICLObserver* anObserver ):
+    CActive( EPriorityStandard ),
+    iObserver( anObserver ),
+    iService( aService )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// ----------------------------------------------------------------------------
+CICLHandler::~CICLHandler()
+    {
+    Cancel();
+    }
+
+// ----------------------------------------------------------------------------
+void CICLHandler::Start()
+    {
+    SetActive();
+    }
+
+// ----------------------------------------------------------------------------
+void CICLHandler::RunL()
+    {
+    iObserver->ICLComplete( iStatus.Int() );
+    }
+
+// ----------------------------------------------------------------------------
+void CICLHandler::DoCancel()
+    {
+    iService->Cancel();
+    }
+
+/*
+// ----------------------------------------------------------------------------
+TInt CICLHandler::RunError(TInt aError)
+    {
+
+    }
+*/
+
+// ----------------------------------------------------------------------------
+// Create instance of concrete ECOM interface implementation
+CHtiScreenshotServicePlugin* CHtiScreenshotServicePlugin::NewL()
+    {
+    CHtiScreenshotServicePlugin* self = new (ELeave) CHtiScreenshotServicePlugin;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// Constructor
+CHtiScreenshotServicePlugin::CHtiScreenshotServicePlugin():
+    iScreen( NULL ),
+    iEncodedBitmap( NULL ),
+    iScreenDevice( NULL ),
+    iBitmapEncoder( NULL ),
+    iICLHandler( NULL ),
+    iCompress( EFalse ),
+    iDeltaCapture( EFalse ),
+    iPreviousBitmap( NULL )
+    {
+    }
+
+// ----------------------------------------------------------------------------
+CHtiScreenshotServicePlugin::~CHtiScreenshotServicePlugin()
+    {
+    HTI_LOG_FUNC_IN( "~CHtiScreenshotServicePlugin" );
+
+    iFontCache.Close();
+
+    delete iScreen;
+    delete iEncodedBitmap;
+
+    delete iICLHandler;
+    delete iBitmapEncoder;
+
+    delete iScreenDevice;
+
+    delete iSeriesShot;
+
+    if ( iPreviousBitmap )
+        delete iPreviousBitmap;
+
+    iWs.Close();
+    HTI_LOG_FUNC_OUT( "~CHtiScreenshotServicePlugin" );
+    }
+
+// ----------------------------------------------------------------------------
+// Second phase construction.
+void CHtiScreenshotServicePlugin::ConstructL()
+    {
+    HTI_LOG_FUNC_IN( "CHtiScreenshotServicePlugin::ConstructL" );
+    User::LeaveIfError( iWs.Connect() );
+
+    iScreenDevice = new ( ELeave ) CWsScreenDevice( iWs );
+    User::LeaveIfError( iScreenDevice->Construct() );
+
+    //InitFontCache();
+
+    iSeriesShot = CSeriesShot::NewL( this );
+
+    iPreviousBitmap = new ( ELeave ) CFbsBitmap;
+
+    //SelectEncoder( KImageTypeBMPUid );
+    HTI_LOG_FUNC_OUT( "CHtiScreenshotServicePlugin::ConstructL" );
+    }
+
+// ----------------------------------------------------------------------------
+TBool CHtiScreenshotServicePlugin::IsBusy()
+    {
+    if ( iICLHandler )
+        {
+        return iICLHandler->IsActive();
+        }
+
+    if ( iSeriesShot->IsOngoing() )
+        {
+        return ETrue;
+        }
+
+    return iEncodedBitmap != NULL;
+    }
+
+// ----------------------------------------------------------------------------
+inline TInt CHtiScreenshotServicePlugin::ParseInt16( const TUint8* aStart )
+    {
+    return aStart[0] + (aStart[1]<<8);
+    }
+
+// ----------------------------------------------------------------------------
+inline TInt CHtiScreenshotServicePlugin::ParseInt32( const TUint8* aStart )
+    {
+    return aStart[0] + (aStart[1]<<8) + (aStart[2]<<16) + (aStart[3]<<24);
+    }
+
+// ----------------------------------------------------------------------------
+void CHtiScreenshotServicePlugin::SendTextRecgReplyL(
+                                    const TBool aResult,
+                                    const TRect& aLocation,
+                                    const TInt aFontIndex)
+    {
+    HTI_LOG_FUNC_IN( "SendTextRecgReplyL" );
+    HBufC8* sendMsg = HBufC8::NewL( 10 );
+    CleanupStack::PushL( sendMsg );
+    if ( aResult )
+        {
+        sendMsg->Des().Append( ERspOk );
+        TUint16 co = aLocation.iTl.iX;
+        sendMsg->Des().Append( (TUint8*)(&co), 2 );
+        co = aLocation.iTl.iY;
+        sendMsg->Des().Append( (TUint8*)(&co), 2 );
+        co = aLocation.iBr.iX;
+        sendMsg->Des().Append( (TUint8*)(&co), 2 );
+        co = aLocation.iBr.iY;
+        sendMsg->Des().Append( (TUint8*)(&co), 2 );
+        sendMsg->Des().Append( (TUint8)aFontIndex );
+        }
+    else
+        {
+        sendMsg->Des().Append( ERspNotFound );
+        sendMsg->Des().AppendFill( 0, 5 );
+        }
+
+    User::LeaveIfError( iDispatcher->DispatchOutgoingMessage(
+                            sendMsg,
+                            KScreenshotServiceUid) );
+
+    CleanupStack::Pop();
+    HTI_LOG_FUNC_OUT( "SendTextRecgReplyL" );
+    }
+
+// ----------------------------------------------------------------------------
+void CHtiScreenshotServicePlugin::CopyUnicode( TDes & aTo, const TDesC8& aFrom )
+{
+    HTI_LOG_FUNC_IN( "CHtiScreenshotServicePlugin::CopyUnicode" );
+    //aTo.Copy( reinterpret_cast<const TUint16*>(aFrom.Ptr()), aFrom.Length() );
+    TInt len = aFrom.Length()>>1;
+    aTo.SetLength( len );
+    for ( TInt i = 0; i < len; ++i )
+    {
+        aTo[i] = (TUint16)aFrom[i<<1] + (((TUint16)aFrom[(i<<1)+1])<<8);
+    }
+    HTI_LOG_FUNC_OUT( "CHtiScreenshotServicePlugin::CopyUnicode" );
+}
+
+// ----------------------------------------------------------------------------
+TInt CHtiScreenshotServicePlugin::ParseString( const TDesC8& aRequest,
+                                        TInt anOffset,
+                                        TBool aUnicode,
+                                        TDes& aResult)
+    {
+    HTI_LOG_FUNC_IN( "CHtiScreenshotServicePlugin::ParseString" );
+    //validate parameters
+    //if offset outside the string return empty string
+    if ( anOffset >= aRequest.Size() )
+        {
+        return anOffset;
+        }
+
+    TInt len = aRequest[ anOffset ];
+    HTI_LOG_FORMAT( "len %d", len );
+
+    if ( len> aResult.MaxLength() )
+        {
+        return KErrBadDescriptor;
+        }
+
+    TInt nextOffset = ( aUnicode ? len * 2 : len ) + anOffset + 1;
+    HTI_LOG_FORMAT( "nextOffset %d", nextOffset );
+    HTI_LOG_FORMAT( "reqSize %d", aRequest.Size() );
+    if ( nextOffset > aRequest.Size() )
+        {
+        return KErrArgument;
+        }
+
+    if ( aUnicode )
+        {
+        //const TUint8* ptr = aRequest.Mid( anOffset + 1, len * 2 ).Ptr();
+        //aResult.Copy( (const TUint16*)ptr, len );
+        CopyUnicode( aResult, aRequest.Mid( anOffset + 1, len * 2 ) );
+        }
+    else
+        {
+        aResult.Copy( aRequest.Mid( anOffset + 1, len ) );
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiScreenshotServicePlugin::ParseString" );
+    return nextOffset;
+    }
+
+// ----------------------------------------------------------------------------
+TInt CHtiScreenshotServicePlugin::ParseFontSpec( const TDesC8& aRequest,
+                    TInt anOffset,
+                    TBool aUnicode,
+                    TFontSpec& aResult)
+    {
+    if ( anOffset >= aRequest.Size() )
+        {
+        return KErrArgument;
+        }
+
+    //get font name
+    TPtr tn = aResult.iTypeface.iName.Des();
+    TInt offset = ParseString( aRequest,
+                    anOffset,
+                    aUnicode,
+                    tn );
+
+    if ( offset > anOffset )
+        {
+        HTI_LOG_DES(aResult.iTypeface.iName);
+        //check that we have valid descr
+        if ( offset + 2 <= aRequest.Size() )
+            {
+            aResult.iHeight = ParseInt16( aRequest.Ptr() + offset );
+            HTI_LOG_FORMAT( "font height %d", aResult.iHeight );
+            //check style byte
+            TUint8 style = aRequest[ offset + 2 ];
+            HTI_LOG_FORMAT( "style %d", style );
+
+            //stroke bit
+            if ( style & EHtiFontAttBold )
+                {
+                aResult.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
+                }
+            else
+                {
+                aResult.iFontStyle.SetStrokeWeight(EStrokeWeightNormal);
+                }
+            //posture
+            if ( style & EHtiFontAttItalic )
+                {
+                aResult.iFontStyle.SetPosture(EPostureItalic);
+                }
+            else
+                {
+                aResult.iFontStyle.SetPosture(EPostureUpright);
+                }
+            //bitmap glyph type
+            if ( style & EHtiFontAttNotAA )
+                {
+                aResult.iFontStyle.SetBitmapType( EMonochromeGlyphBitmap );
+                }
+            else
+                {
+                aResult.iFontStyle.SetBitmapType( EAntiAliasedGlyphBitmap );
+                }
+            //print position
+            if ( style & EHtiFontAttPrintPositionFlag )
+                {
+                TInt printPos = style & EHtiFontAttPrintPositionValue;
+                if ( printPos == KHtiFontAttSuperscriptValue )
+                    {
+                    aResult.iFontStyle.SetPrintPosition( EPrintPosSuperscript );
+                    }
+                else if ( printPos == KHtiFontAttSubscriptValue )
+                    {
+                    aResult.iFontStyle.SetPrintPosition( EPrintPosSubscript );
+                    }
+                }
+            else
+                {
+                aResult.iFontStyle.SetPrintPosition( EPrintPosNormal );
+                }
+            return offset + 3;
+            }
+        else
+            {
+            return KErrArgument;
+            }
+        }
+    else
+        {
+        return offset<0?offset:KErrArgument;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+void CHtiScreenshotServicePlugin::ProcessTextRcgMessageL(
+                                    const TDesC8& aMessage)
+    {
+    HTI_LOG_FUNC_IN( "CHtiScreenshotServicePlugin::ProcessTextRcgMessageL" );
+    TBool unicode = aMessage[0] & 0x1;
+
+    TBuf<0xFF> text;
+
+    TInt offset = ParseString(aMessage, 1, unicode, text);
+
+    HTI_LOG_FORMAT( "offset %d ", offset );
+    if ( offset > 1 )
+        {
+        HTI_LOG_DES(text);
+
+        if ( offset + 1 < aMessage.Size() )
+            {
+            TInt numOfFonts = aMessage[ offset ];
+            HTI_LOG_FORMAT( "num of fonts %d", numOfFonts );
+            iFontCache.Reset();
+            TInt nextOffset  = offset + 1;
+            for ( TInt i = 0; i < numOfFonts; ++i )
+                {
+                TFontSpec fontSpec;
+                nextOffset = ParseFontSpec(aMessage,
+                                            nextOffset,
+                                            unicode,
+                                            fontSpec);
+                if ( nextOffset < 0 )
+                    {
+                    iDispatcher->DispatchOutgoingErrorMessage(
+                        nextOffset,
+                        KErrDescrInvalid,
+                        KScreenshotServiceUid);
+                    return;
+                    }
+                else
+                    {
+                    iFontCache.Append( fontSpec );
+                    }
+                }
+
+            //parameters parsing END
+            //get screenshot
+            TRect empty;
+            CreateBitmapL( empty, ENone );
+
+            //call text rcg routines
+            TInt fontIndex;
+            TRect resultRect;
+
+            //recognize text using fonts from iFontCache
+            TBool result = RecognizeTextL( text, resultRect, fontIndex );
+
+            SendTextRecgReplyL( result, resultRect, fontIndex );
+
+            delete iScreen;
+            iScreen = NULL;
+            }
+        else
+            {
+            //no fonts data
+            iDispatcher->DispatchOutgoingErrorMessage(
+                        KErrArgument,
+                        KErrDescrInvalid,
+                        KScreenshotServiceUid);
+
+            }
+        }
+    else if ( offset == 1 )
+        {
+        //empty text
+        iDispatcher->DispatchOutgoingErrorMessage(
+                        KErrArgument,
+                        KErrDescrInvalid,
+                        KScreenshotServiceUid);
+        }
+    else
+        {
+        //error
+        iDispatcher->DispatchOutgoingErrorMessage(
+                        offset,
+                        KErrDescrInvalid,
+                        KScreenshotServiceUid);
+        }
+    HTI_LOG_FUNC_OUT( "CHtiScreenshotServicePlugin::ProcessTextRcgMessageL" );
+    }
+
+// ----------------------------------------------------------------------------
+void CHtiScreenshotServicePlugin::ProcessTextBitmapMessageL(
+                                    const TDesC8& aMessage)
+    {
+    HTI_LOG_FUNC_IN( "CHtiScreenshotServicePlugin::ProcessTextBitmapMessageL" );
+    TBool unicode = aMessage[0] & 0x1;
+
+    TDisplayMode displayMode = ENone;
+    //check display
+    if ( aMessage.Size() > KScreenDisplayOffset )
+        {
+        displayMode = (TDisplayMode)aMessage[KScreenDisplayOffset];
+        if ( displayMode >= EColorLast )
+            {
+            iDispatcher->DispatchOutgoingErrorMessage(
+                            KErrArgument,
+                            KErrDescrInvalidMode,
+                            KScreenshotServiceUid);
+            return;
+            }
+        }
+
+    //check mime
+    TPtrC8 mime;
+    if ( aMessage[KScreenMIMEOffset] > 0 &&
+        ( aMessage[KScreenMIMEOffset] + KScreenMIMEOffset+1 ) < aMessage.Size() )
+        {
+        mime.Set( aMessage.Mid(KScreenMIMEOffset+1, aMessage[KScreenMIMEOffset] ) );
+        if ( !IsMIMETypeSupported( mime ) )
+            {
+            iDispatcher->DispatchOutgoingErrorMessage(
+                            KErrArgument,
+                            KErrDescrMIMENotSupported,
+                            KScreenshotServiceUid);
+            return;
+            }
+        }
+    else if ( aMessage[KScreenMIMEOffset] != 0 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+                        KErrArgument,
+                        KErrDescrInvalidMode,
+                        KScreenshotServiceUid);
+        return;
+        }
+
+    TBuf<0xFF> text;
+    TInt preTextOffset = KScreenMIMEOffset + aMessage[KScreenMIMEOffset] + 1;
+    TInt offset = ParseString( aMessage, preTextOffset, unicode, text );
+
+    HTI_LOG_FORMAT( "offset %d ", offset );
+    if ( offset == preTextOffset )
+        {
+        //empty text
+        iDispatcher->DispatchOutgoingErrorMessage(
+                        KErrArgument,
+                        KErrDescrInvalid,
+                        KScreenshotServiceUid);
+        }
+    else if ( offset < preTextOffset )
+        {
+        //error
+        iDispatcher->DispatchOutgoingErrorMessage(
+                        offset,
+                        KErrDescrInvalid,
+                        KScreenshotServiceUid);
+        }
+
+    HTI_LOG_DES(text);
+    TFontSpec fontSpec;
+    offset = ParseFontSpec(aMessage,
+                            offset,
+                            unicode,
+                            fontSpec);
+    if ( offset < 0 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            offset,
+            KErrDescrInvalid,
+            KScreenshotServiceUid);
+
+        return;
+        }
+
+    //check colors
+    HTI_LOG_TEXT( "check colors" );
+    if ( offset + 2*4 != aMessage.Size() )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            offset,
+            KErrDescrInvalid,
+            KScreenshotServiceUid);
+        return;
+        }
+
+    //extract colors
+    TUint32 fgColor = ParseInt32( aMessage.Ptr() + offset );
+    TUint32 bgColor = ParseInt32( aMessage.Ptr() + offset + 4 );
+    HTI_LOG_FORMAT( "FG color %d", fgColor );
+    HTI_LOG_FORMAT( "BG color %d", bgColor );
+
+    //END parsing
+    //generate and return bitmap
+    CFont* useFont;
+
+    User::LeaveIfError( iScreenDevice->GetNearestFontToDesignHeightInPixels(
+                            useFont, fontSpec ) );
+
+    TDisplayMode dm = displayMode==ENone || displayMode==0?
+                                        iScreenDevice->DisplayMode():
+                                        displayMode;
+
+
+    delete iScreen;
+    iScreen = NULL;
+    iScreen = CHtiTextRcg::GetTextBitmapL(
+                            text,
+                            useFont,
+                            TRgb( fgColor ),
+                            TRgb( bgColor ),
+                            dm );
+
+    iScreenDevice->ReleaseFont( useFont );
+
+    //Encode iBitmap
+    iCompress = EFalse;
+    if ( mime.Length() == 0 )
+        {
+        EncodeBitmapL(); //use default encoder BMP
+        }
+    else
+        {
+        HTI_LOG_DES( mime );
+        EncodeBitmapL( mime );
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiScreenshotServicePlugin::ProcessTextBitmapMessageL" );
+    }
+
+/*
+// ----------------------------------------------------------------------------
+TBool CHtiScreenshotServicePlugin::RecognizeTextAllL(
+                        const TDesC& aText,
+                        TPoint& aResult)
+    {
+    HTI_LOG_FUNC_IN( "CHtiScreenshotServicePlugin::RecognizeTextAllL" );
+
+    TSize screenRect = iScreenDevice->SizeInPixels();
+    TInt nofTF = iScreenDevice->NumTypefaces();
+    HTI_LOG_FORMAT( "Number of typefaces %d", nofTF );
+    TBool returnValue = EFalse;
+    for ( TInt i = 0; i < nofTF; ++i )
+        {
+        TTypefaceSupport tf;
+        iScreenDevice->TypefaceSupport(tf, i);
+
+        HTI_LOG_DES(tf.iTypeface.iName);
+
+        if ( tf.iIsScalable )
+            {
+            //iterate throuh heighes
+
+            HTI_LOG_FORMAT( "num of heighs %d", tf.iNumHeights );
+            HTI_LOG_FORMAT( "min h in tw %d", tf.iMinHeightInTwips );
+            HTI_LOG_FORMAT( "max h in tw %d", tf.iMaxHeightInTwips );
+            HTI_LOG_FORMAT( "scalable %d", tf.iIsScalable );
+
+            HTI_LOG_TEXT( "-----------------------" );
+
+            TInt minHeight = Max(tf.iMinHeightInTwips, KFonHeighMin );
+            TInt maxHeight = Min(tf.iMaxHeightInTwips, KFonHeighMax );
+
+            if ( minHeight > maxHeight )
+                {
+                continue;
+                }
+
+            for ( TInt v = 0; v < 2; ++v )
+                {
+                TInt lastFontHeight = 0;
+                for ( TInt fh = minHeight; fh <= maxHeight; ++fh )
+                    {
+                    TFontSpec fs( tf.iTypeface.iName, fh );
+                    fs.iFontStyle.SetBitmapType( EAntiAliasedGlyphBitmap );
+                    switch ( v )
+                        {
+                        case 1:
+                            {
+                            fs.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
+                            HTI_LOG_TEXT( "BOLD" );
+                            }
+                            break;
+                        default:
+                            {
+                            HTI_LOG_TEXT( "DEFAULT" );
+                            }
+                        }
+                    HTI_LOG_FORMAT( "hh  %d", fh );
+
+                    CFont* useFont = NULL;
+
+                    iScreenDevice->GetNearestFontToDesignHeightInTwips(useFont, fs);
+
+                    if ( screenRect.iHeight < useFont->HeightInPixels() ||
+                         screenRect.iWidth < useFont->MaxNormalCharWidthInPixels()
+                        )
+                        {
+                        break;
+                        }
+
+                    if ( useFont->HeightInPixels() == lastFontHeight )
+                        {
+                        continue;
+                        }
+
+
+                    lastFontHeight = useFont->HeightInPixels();
+
+                    returnValue = iTextRcg.RecognizeTextL(
+                                                iScreen,
+                                                aText,
+                                                useFont,
+                                                aResult);
+                    //HTI_LOG_TEXT( "ReleaseFont" );
+                    iScreenDevice->ReleaseFont(useFont);
+
+                    if ( returnValue )
+                        {
+                        HTI_LOG_TEXT( "Found" );
+                        HTI_LOG_DES( aText );
+                        HTI_LOG_DES( tf.iTypeface.iName );
+                        HTI_LOG_FORMAT( "Font height in twips %d", fh );
+                        HTI_LOG_FORMAT( "X %d", aResult.iX );
+                        HTI_LOG_FORMAT( "Y %d", aResult.iY );
+                        return returnValue;
+                        }
+                    }
+                }
+            }
+        else
+            {//non scal. font
+            TFontSpec fs( tf.iTypeface.iName,0 ); //height doesn't matter for
+                                                //not scalable font
+
+            CFont* useFont = NULL;
+            //HTI_LOG_TEXT( "GetFont" );
+            iScreenDevice->GetNearestFontToDesignHeightInTwips( useFont, fs );
+
+            returnValue = iTextRcg.RecognizeTextL(
+                                        iScreen,
+                                        aText,
+                                        useFont,
+                                        aResult );
+            //HTI_LOG_TEXT( "ReleaseFont" );
+            iScreenDevice->ReleaseFont( useFont );
+
+            if ( returnValue )
+                {
+                HTI_LOG_TEXT( "Found" );
+                HTI_LOG_DES( aText );
+                HTI_LOG_DES(tf.iTypeface.iName );
+                HTI_LOG_FORMAT( "X %d", aResult.iX );
+                HTI_LOG_FORMAT( "Y %d", aResult.iY );
+                return returnValue;
+                }
+            }
+        }
+
+    //
+
+    HTI_LOG_FUNC_OUT( "CHtiScreenshotServicePlugin::RecognizeTextAllL" );
+    //return returnValue;
+    return EFalse;
+    }
+*/
+
+// ----------------------------------------------------------------------------
+TBool CHtiScreenshotServicePlugin::RecognizeTextL(
+                        const TDesC& aText,
+                        TRect& aResult,
+                        TInt& aFontIndex)
+    {
+    HTI_LOG_FUNC_IN( "CHtiScreenshotServicePlugin::RecognizeTextL" );
+
+    TSize screenRect = iScreenDevice->SizeInPixels();
+    TInt cacheSize = iFontCache.Count();
+    HTI_LOG_FORMAT( "Cache size %d", cacheSize );
+
+    TBool returnValue = EFalse;
+    for ( TInt i = 0; i < cacheSize; ++i )
+        {
+        CFont* useFont = NULL;
+
+        User::LeaveIfError(iScreenDevice->GetNearestFontToDesignHeightInPixels(
+                                useFont, iFontCache[i] ) );
+        if ( iFontCache[i].iFontStyle.BitmapType()==EAntiAliasedGlyphBitmap )
+            {
+            iTextRcg.SetHint( EHintEdge );
+            }
+        else
+            {
+            iTextRcg.SetHint( EHintNone );
+            }
+
+        //check that font in valid size
+        if ( screenRect.iHeight < useFont->HeightInPixels() ||
+             screenRect.iWidth < useFont->MaxNormalCharWidthInPixels()
+            )
+            {
+            break;
+            }
+
+        returnValue = iTextRcg.RecognizeTextL( iScreen, aText, useFont,
+                aResult );
+
+        iScreenDevice->ReleaseFont( useFont );
+
+        if ( returnValue )
+            {
+            HTI_LOG_FORMAT( "Found! fontIndex %d", i );
+            HTI_LOG_DES( aText );
+            HTI_LOG_DES( iFontCache[i].iTypeface.iName );
+            HTI_LOG_FORMAT( "TL X %d", aResult.iTl.iX );
+            HTI_LOG_FORMAT( "TL Y %d", aResult.iTl.iY );
+            HTI_LOG_FORMAT( "BR X %d", aResult.iBr.iX );
+            HTI_LOG_FORMAT( "BR Y %d", aResult.iBr.iY );
+            aFontIndex = i;
+            return returnValue;
+            }
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiScreenshotServicePlugin::RecognizeTextL" );
+    return EFalse;
+    }
+
+/*
+TBool CHtiScreenshotServicePlugin::RecognizeTextL(
+                        const TDesC& aText,
+                        const TDesC& aTypeface,
+                        TPoint& aResult)
+    {
+    HTI_LOG_FUNC_IN( "RecognizeTextL typeface" );
+    //const CFont* fontUsed = NULL;// AknLayoutUtils::FontFromName(aTypeface);
+    CFont* useFont = NULL;
+    TFontSpec fs(aTypeface, 0);
+
+    iScreenDevice->GetNearestFontInTwips(useFont, fs);
+
+    TBool returnValue = iTextRcg.RecognizeTextL(iScreen, aText, useFont, aResult);
+
+HTI_LOG_FUNC_OUT( "RecognizeTextL" );
+    return returnValue;
+}
+*/
+
+// ----------------------------------------------------------------------------
+void CHtiScreenshotServicePlugin::ProcessMessageL(const TDesC8& aMessage,
+                THtiMessagePriority /*aPriority*/)
+    {
+    HTI_LOG_FUNC_IN( "CHtiScreenshotServicePlugin::ProcessMessage");
+
+    if ( iICLHandler )
+        {
+        if ( iICLHandler->IsActive() || iEncodedBitmap)
+            {
+            User::Leave( KErrInUse );
+            }
+        }
+
+    if ( iSeriesShot->IsOngoing() )
+        User::Leave( KErrInUse );
+
+    // update the current screen mode
+    TPixelsAndRotation currentPixelsAndRotation;
+    iScreenDevice->GetScreenModeSizeAndRotation(
+            iScreenDevice->CurrentScreenMode(), currentPixelsAndRotation );
+    iScreenDevice->SetScreenSizeAndRotation( currentPixelsAndRotation );
+
+    if ( aMessage.Length() > 0 )
+        {
+        // set/reset delta capture status
+        iDeltaCapture = ( aMessage[0] & ECmdDeltaCaptureMask ) ? ETrue : EFalse;
+        if ( iDeltaCapture )
+            {
+            HTI_LOG_TEXT( "DeltaCapture ETrue" );
+            }
+
+        //if text recogn call separate handler
+        if ( aMessage[0] == ECmdTextRcg ||
+             aMessage[0] == ECmdTextRcg_u )
+            {
+            ProcessTextRcgMessageL( aMessage );
+            return;
+            }
+        else if ( aMessage[0] == ECmdTextBitmap ||
+                  aMessage[0] == ECmdTextBitmap_u )
+            {
+            ProcessTextBitmapMessageL( aMessage );
+            return;
+            }
+
+        iCompress = ( aMessage[0] == ECmdScreenZip ) ||
+                    ( aMessage[0] == ECmdScreenRegionZip ) ||
+                    ( aMessage[0] == ECmdScreenZipSeries ) ||
+                    ( aMessage[0] == ECmdScreenRegionZipSeries ) ||
+                    ( aMessage[0] == ECmdDeltaScreenZip ) ||
+                    ( aMessage[0] == ECmdDeltaScreenRegionZip );
+
+        HTI_LOG_FORMAT( "cmd 0x%x", aMessage[0] );
+        TPtrC8 mime;
+
+        switch ( aMessage[0] )
+            {
+            case ECmdScreen:
+            case ECmdScreenZip:
+            case ECmdDeltaScreen:
+            case ECmdDeltaScreenZip:
+                {
+                TRect empty;
+                TDisplayMode displayMode = ENone;
+                //check display
+                if ( aMessage.Length() > KScreenDisplayOffset )
+                    {
+                    displayMode = ( TDisplayMode ) aMessage[KScreenDisplayOffset];
+                    if ( displayMode >= EColorLast )
+                        {
+                        iDispatcher->DispatchOutgoingErrorMessage(
+                                        KErrArgument,
+                                        KErrDescrInvalidMode,
+                                        KScreenshotServiceUid );
+                        return;
+                        }
+                    }
+
+                CreateBitmapL( empty, displayMode );
+                //check mime
+                if ( aMessage.Length() > KScreenMIMEOffset )
+                    {
+                    mime.Set( aMessage.Mid( KScreenMIMEOffset ) );
+                    if ( !IsMIMETypeSupported( mime ) )
+                        {
+                        iDispatcher->DispatchOutgoingErrorMessage(
+                                        KErrArgument,
+                                        KErrDescrMIMENotSupported,
+                                        KScreenshotServiceUid );
+                        return;
+                        }
+                    }
+                }
+                break;
+
+            case ECmdScreenRegion:
+            case ECmdScreenRegionZip:
+            case ECmdDeltaScreenRegion:
+            case ECmdDeltaScreenRegionZip:
+                {
+                if ( aMessage.Length() >= KMinScreenRegionCmdLength )
+                    {
+                    TRect region;
+                    const TUint8* ptr = aMessage.Ptr();
+                    region.iTl.iX = ParseInt16( ptr + 1 );
+                    region.iTl.iY = ParseInt16( ptr + 3 );
+                    region.iBr.iX = ParseInt16( ptr + 5 );
+                    region.iBr.iY = ParseInt16( ptr + 7 );
+
+                    //check empty and normmalizaed
+                    if ( !region.IsNormalized() )
+                        {
+                        iDispatcher->DispatchOutgoingErrorMessage(
+                                        KErrArgument,
+                                        KErrDescrRegionNotNormailized,
+                                        KScreenshotServiceUid );
+                        return;
+                        }
+
+                    if ( region.IsEmpty() )
+                        {
+                        iDispatcher->DispatchOutgoingErrorMessage(
+                                        KErrArgument,
+                                        KErrDescrRegiontEmpty,
+                                        KScreenshotServiceUid );
+                        return;
+                        }
+
+                    TRect screenRect;
+                    screenRect.iBr = iScreenDevice->SizeInPixels().AsPoint();
+                    screenRect.iBr.iX++; //TRect::Contains() omitts
+                    screenRect.iBr.iY++; //right bottom rows
+
+                    TDisplayMode displayMode = ENone;
+                    if ( aMessage.Length() > KRegionDisplayOffset )
+                        {
+                        displayMode = ( TDisplayMode ) aMessage[KRegionDisplayOffset];
+                        if ( displayMode >= EColorLast )
+                            {
+                            iDispatcher->DispatchOutgoingErrorMessage(
+                                            KErrArgument,
+                                            KErrDescrInvalidMode,
+                                            KScreenshotServiceUid );
+                            return;
+                            }
+                        }
+
+                    if ( screenRect.Contains( region.iTl ) &&
+                         screenRect.Contains( region.iBr ) )
+                        {
+                        CreateBitmapL( region, displayMode );
+                        }
+                    else
+                        {
+                        iDispatcher->DispatchOutgoingErrorMessage(
+                                        KErrArgument,
+                                        KErrDescrRegionOutOfScreen,
+                                        KScreenshotServiceUid );
+                        return;
+                        }
+
+                    //check mime
+                    if ( aMessage.Length() > KRegionMIMEOffset )
+                        {
+                        mime.Set( aMessage.Mid( KRegionMIMEOffset ) );
+                        if ( !IsMIMETypeSupported( mime ) )
+                            {
+                            iDispatcher->DispatchOutgoingErrorMessage(
+                                            KErrArgument,
+                                            KErrDescrMIMENotSupported,
+                                            KScreenshotServiceUid );
+                            return;
+                            }
+                        }
+                    }
+                else
+                    {
+                    iDispatcher->DispatchOutgoingErrorMessage(
+                                    KErrArgument,
+                                    KErrDescrInvalid,
+                                    KScreenshotServiceUid );
+                    return;
+                    }
+                }
+                break;
+
+            case ECmdScreenSeries:
+            case ECmdScreenZipSeries:
+                {
+                if ( aMessage.Length() < KMinSeriesCmdLength )
+                    {
+                    iDispatcher->DispatchOutgoingErrorMessage(
+                                    KErrArgument,
+                                    KErrDescrInvalid,
+                                    KScreenshotServiceUid );
+                    return;
+                    }
+                TInt duration = ParseInt32( aMessage.Ptr() + KSeriesDurationOffset );
+                TInt interval = ParseInt32( aMessage.Ptr() + KSeriesIntervalOffset );
+
+                TDisplayMode displayMode = ( TDisplayMode ) aMessage[KSeriesDisplayOffset];
+                if ( displayMode >= EColorLast )
+                    {
+                    iDispatcher->DispatchOutgoingErrorMessage(
+                                    KErrArgument,
+                                    KErrDescrInvalidMode,
+                                    KScreenshotServiceUid );
+                    return;
+                    }
+
+                if ( aMessage.Length() > KSeriesMIMEOffset )
+                    {
+                    mime.Set( aMessage.Mid( KSeriesMIMEOffset ) );
+                    if ( !IsMIMETypeSupported( mime ) )
+                        {
+                        iDispatcher->DispatchOutgoingErrorMessage(
+                                        KErrArgument,
+                                        KErrDescrMIMENotSupported,
+                                        KScreenshotServiceUid );
+                        return;
+                        }
+                    }
+
+                TRect empty;
+                iSeriesShot->StartL( duration, interval, displayMode, empty, mime );
+                }
+                return;
+
+            case ECmdScreenRegionSeries:
+            case ECmdScreenRegionZipSeries:
+                {
+                if ( aMessage.Length() < KMinRegionSeriesCmdLength )
+                    {
+                    iDispatcher->DispatchOutgoingErrorMessage(
+                                    KErrArgument,
+                                    KErrDescrInvalid,
+                                    KScreenshotServiceUid);
+                    return;
+                    }
+                TInt duration = ParseInt32( aMessage.Ptr() + KSeriesDurationOffset );
+                TInt interval = ParseInt32( aMessage.Ptr() + KSeriesIntervalOffset );
+
+                TDisplayMode displayMode = ( TDisplayMode ) aMessage[KSeriesDisplayOffset];
+                if ( displayMode >= EColorLast )
+                    {
+                    iDispatcher->DispatchOutgoingErrorMessage(
+                                    KErrArgument,
+                                    KErrDescrInvalidMode,
+                                    KScreenshotServiceUid );
+                    return;
+                    }
+
+                TRect region;
+                const TUint8* ptr = aMessage.Ptr();
+                region.iTl.iX = ParseInt16( ptr + KRegionSeriesTlX );
+                region.iTl.iY = ParseInt16( ptr + KRegionSeriesTlY );
+                region.iBr.iX = ParseInt16( ptr + KRegionSeriesBlX );
+                region.iBr.iY = ParseInt16( ptr + KRegionSeriesBlY );
+
+                //check empty and normmalizaed
+                if ( !region.IsNormalized() )
+                    {
+                    iDispatcher->DispatchOutgoingErrorMessage(
+                                    KErrArgument,
+                                    KErrDescrRegionNotNormailized,
+                                    KScreenshotServiceUid );
+                    return;
+                    }
+
+                if ( region.IsEmpty() )
+                    {
+                    iDispatcher->DispatchOutgoingErrorMessage(
+                                    KErrArgument,
+                                    KErrDescrRegiontEmpty,
+                                    KScreenshotServiceUid );
+                    return;
+                    }
+
+                TRect screenRect;
+                screenRect.iBr = iScreenDevice->SizeInPixels().AsPoint();
+                screenRect.iBr.iX++; //TRect::Contains() omitts
+                screenRect.iBr.iY++; //right bottom rows
+
+                if ( !screenRect.Contains( region.iTl ) ||
+                     !screenRect.Contains( region.iBr ) )
+                    {
+                    iDispatcher->DispatchOutgoingErrorMessage(
+                                    KErrArgument,
+                                    KErrDescrRegionOutOfScreen,
+                                    KScreenshotServiceUid );
+                    return;
+                    }
+
+                if ( aMessage.Length() > KRegionSeriesMIMEOffset )
+                    {
+                    mime.Set( aMessage.Mid( KRegionSeriesMIMEOffset ) );
+                    if ( !IsMIMETypeSupported( mime ) )
+                        {
+                        iDispatcher->DispatchOutgoingErrorMessage(
+                                        KErrArgument,
+                                        KErrDescrMIMENotSupported,
+                                        KScreenshotServiceUid );
+                        return;
+                        }
+                    }
+
+                iSeriesShot->StartL( duration, interval, displayMode, region, mime );
+                }
+                return;
+
+            case ECmdSelectScreen:
+                {
+                if ( aMessage.Length() != KSelectScreenCmdLength )
+                    {
+                    iDispatcher->DispatchOutgoingErrorMessage(
+                                    KErrArgument,
+                                    KErrDescrInvalid,
+                                    KScreenshotServiceUid );
+                    return;
+                    }
+
+                TInt screenNr = aMessage[KScreenNrOffset];
+
+                TInt screens;
+                TInt ret=HAL::Get( HAL::EDisplayNumberOfScreens, screens );
+                if ( ret )
+                    {
+                    HTI_LOG_FORMAT( "HAL::Get failed %d", ret );
+                    User::Leave( ret );
+                    }
+
+
+                if ( ( screenNr > screens - 1 ) || ( screenNr < 0 ) )
+                    {
+                    iDispatcher->DispatchOutgoingErrorMessage(
+                                    KErrArgument,
+                                    KErrDescrScreenNotSupported,
+                                    KScreenshotServiceUid );
+                    return;
+                    }
+
+
+                HTI_LOG_FORMAT( "Number of screens %d", screens );
+                HTI_LOG_FORMAT( "Setting to screen index %d", screenNr );
+
+                // Clear the previous delta bitmap to avoid error
+                iPreviousBitmap->Reset();
+
+                // delete old screendevice and create a new one
+                delete iScreenDevice;
+                iScreenDevice = NULL;
+                iScreenDevice = new ( ELeave ) CWsScreenDevice( iWs );
+                User::LeaveIfError( iScreenDevice->Construct( screenNr ) );
+
+                TBuf8<1> okMsg;
+                okMsg.Append( ECmdSelectScreen );
+                iDispatcher->DispatchOutgoingMessage(
+                    okMsg.AllocL(), KScreenshotServiceUid );
+                }
+                return;
+
+            case ECmdDeltaScreenReset:
+                {
+                if ( aMessage.Length() != KDeltaResetCmdLength )
+                    {
+                    iDispatcher->DispatchOutgoingErrorMessage(
+                                    KErrArgument,
+                                    KErrDescrInvalid,
+                                    KScreenshotServiceUid );
+                    return;
+                    }
+
+                iPreviousBitmap->Reset();
+                TBuf8<1> okMsg;
+                okMsg.Append( ECmdDeltaScreenReset );
+                iDispatcher->DispatchOutgoingMessage(
+                    okMsg.AllocL(), KScreenshotServiceUid );
+                }
+                return;
+
+            case ECmdScreenMode:
+                {
+                if ( aMessage.Length() != KScreenModeCmdLength )
+                    {
+                    iDispatcher->DispatchOutgoingErrorMessage(
+                                    KErrArgument,
+                                    KErrDescrInvalid,
+                                    KScreenshotServiceUid );
+                    return;
+                    }
+
+                TInt focusScreen = iWs.GetFocusScreen();
+                TPixelsAndRotation sizeAndRotation;
+                TDisplayMode mode = ENone;
+                TInt thisScreen = iScreenDevice->GetScreenNumber();
+                iScreenDevice->GetDefaultScreenSizeAndRotation( sizeAndRotation );
+                mode = iScreenDevice->DisplayMode();
+
+                HTI_LOG_FORMAT( "This screen   = %d", thisScreen );
+                HTI_LOG_FORMAT( "Screen width  = %d", sizeAndRotation.iPixelSize.iWidth );
+                HTI_LOG_FORMAT( "Screen height = %d", sizeAndRotation.iPixelSize.iHeight );
+                HTI_LOG_FORMAT( "Rotation      = %d", sizeAndRotation.iRotation );
+                HTI_LOG_FORMAT( "Display mode  = %d", mode );
+                HTI_LOG_FORMAT( "Focus screen  = %d", focusScreen );
+                TBuf8<8> respMsg;
+                respMsg.Append( thisScreen );
+                respMsg.Append( ( TUint8* )( &( sizeAndRotation.iPixelSize.iWidth ) ), 2 );
+                respMsg.Append( ( TUint8* )( &( sizeAndRotation.iPixelSize.iHeight ) ), 2 );
+                respMsg.Append( sizeAndRotation.iRotation );
+                respMsg.Append( mode );
+                respMsg.Append( focusScreen );
+                iDispatcher->DispatchOutgoingMessage(
+                    respMsg.AllocL(), KScreenshotServiceUid );
+                }
+                return;
+
+            default:
+                //Error: unknown command
+                iDispatcher->DispatchOutgoingErrorMessage(
+                                KErrArgument,
+                                KErrDescrUnknownCommand,
+                                KScreenshotServiceUid );
+                return;
+            } // switch
+
+        //Encode iBitmap
+        if ( mime.Length() == 0 )
+            {
+            EncodeBitmapL(); //use default encoder BMP
+            }
+        else
+            {
+            HTI_LOG_DES( mime );
+            EncodeBitmapL( mime );
+            }
+        }
+    else
+        {
+        //error: empty request
+        iDispatcher->DispatchOutgoingErrorMessage(
+                        KErrArgument,
+                        KErrDescrUnknownCommand,
+                        KScreenshotServiceUid );
+        }
+
+    HTI_LOG_FUNC_OUT( "HtiScreenshotServicePlugin::ProcessMessage" );
+    }
+
+
+// ----------------------------------------------------------------------------
+void CHtiScreenshotServicePlugin::CreateBitmapL( TRect& aRegion,
+                                                 TDisplayMode aMode )
+    {
+    HTI_LOG_FUNC_IN( "CreateBitmapL" );
+    //create bitmap
+    TSize imageSize = aRegion.IsEmpty() ? iScreenDevice->SizeInPixels() :
+                        aRegion.Size();
+
+    TDisplayMode displayMode = aMode == ENone ?
+                                        iScreenDevice->DisplayMode() : aMode;
+
+    delete iScreen;//in case ICLComplete was not called
+    iScreen = NULL;
+    iScreen = new( ELeave ) CFbsBitmap;
+    User::LeaveIfError( iScreen->Create( imageSize, displayMode ) );
+
+    if ( aRegion.IsEmpty() )
+        {
+        iScreenDevice->CopyScreenToBitmap( iScreen );
+        }
+    else
+        {
+        iScreenDevice->CopyScreenToBitmap( iScreen, aRegion );
+        }
+
+
+    if ( iDeltaCapture )
+        {
+        HTI_LOG_TEXT( "DeltaCapture enabled" );
+
+
+        CFbsBitmap* differenceBitmap = NULL;
+        TInt err = ImageDifferenceL( iPreviousBitmap,
+                                     iScreen,
+                                     differenceBitmap,
+                                     iDeltaRect );
+
+        iPreviousBitmap->Reset();
+        iPreviousBitmap->Duplicate( iScreen->Handle() );
+
+        if ( err == KErrNone )
+            {
+            delete iScreen;
+            iScreen = differenceBitmap;
+            }
+        else if ( err == KErrNotFound )
+            {
+            delete iScreen;
+            iScreen = NULL;
+
+            if ( !iSeriesShot->IsOngoing() )
+                {
+                // Nothing has changed on the screen.
+                // Send just iDeltaRect coordidates
+                HBufC8* buf = HBufC8::NewL( 4 * 2 ); // 2 bytes for each coordinate
+                buf->Des().SetLength( 4 * 2 );
+                TUint16* ptr = (TUint16*) buf->Des().Ptr();
+                ptr[0] = (TUint16) iDeltaRect.iTl.iX;
+                ptr[1] = (TUint16) iDeltaRect.iTl.iY;
+                ptr[2] = (TUint16) iDeltaRect.iBr.iX;
+                ptr[3] = (TUint16) iDeltaRect.iBr.iY;
+                // Response also sent in ICLComplete
+                iDispatcher->DispatchOutgoingMessage( buf, KScreenshotServiceUid );
+                }
+            }
+        }
+
+    HTI_LOG_FUNC_OUT( "CreateBitmapL" );
+    }
+/*
+
+// ----------------------------------------------------------------------------
+void CleanupRArray( TAny* object )
+    {
+    ((RImageTypeDescriptionArray*)object)->ResetAndDestroy();
+    }
+
+// ----------------------------------------------------------------------------
+void CHtiScreenshotServicePlugin::SelectEncoder( const TUid aEncoderUid )
+    {
+    //select encoder
+    RImageTypeDescriptionArray imageTypeArray;
+    CImageEncoder::GetImageTypesL( imageTypeArray );
+    CleanupStack::PushL( TCleanupItem(CleanupRArray, &imageTypeArray) );
+
+    //select specified encoder
+    TBool found = EFalse;
+    for ( TInt i = 0; i < imageTypeArray.Count(); ++i )
+        {
+        if ( imageTypeArray[i]->ImageType() == aEncoderUid )
+            {
+            iImageEncoderType = imageTypeArray[i]->ImageType();
+            iImageEncoderSubtype = imageTypeArray[i]->SubType();
+            found = ETrue;
+            }
+        }
+
+    if ( !found )
+        {
+        User::Leave( KErrNotFound );
+        }
+    CleanupStack::PopAndDestroy(); //imageTypeArray
+    }
+*/
+
+// ----------------------------------------------------------------------------
+TBool CHtiScreenshotServicePlugin::IsMIMETypeSupported(TDesC8 &aMime)
+    {
+    HTI_LOG_DES(aMime);
+    RFileExtensionMIMETypeArray array;
+    CImageEncoder::GetFileTypesL(array);
+    for ( TInt i = 0; i < array.Count(); i++ )
+        {
+        if ( array[i]->MIMEType() == aMime )
+            {
+            HTI_LOG_TEXT( "MIME supported" );
+            array.ResetAndDestroy();
+            return ETrue;
+            }
+        }
+    HTI_LOG_TEXT( "MIME not supported" );
+    array.ResetAndDestroy();
+    return EFalse;
+    }
+
+
+// ----------------------------------------------------------------------------
+void CHtiScreenshotServicePlugin::EncodeBitmapL(const TDesC8& aImageTypeMIME )
+    {
+    HTI_LOG_FUNC_IN( "EncodeBitmapL" );
+    delete iBitmapEncoder;
+    iBitmapEncoder = NULL;
+    delete iICLHandler;
+    iICLHandler = NULL;
+
+    if ( iScreen )
+        {
+        HTI_LOG_TEXT( "create encoder" );
+        if ( aImageTypeMIME  == KNullDesC8 )
+            {
+            iBitmapEncoder = CImageEncoder::DataNewL( iEncodedBitmap,
+                                        CImageEncoder::EOptionNone,
+                                        KImageTypeBMPUid);//,
+                                        //iImageEncoderSubtype);
+            }
+        else
+            {
+            iBitmapEncoder = CImageEncoder::DataNewL( iEncodedBitmap,
+                                        aImageTypeMIME);
+            }
+
+        HTI_LOG_TEXT( "create CICLHandler" );
+        iICLHandler = new(ELeave) CICLHandler( iBitmapEncoder, this );
+        iBitmapEncoder->Convert( &(iICLHandler->iStatus), *iScreen );
+
+        HTI_LOG_TEXT( "CICLHandler start");
+        iICLHandler->Start();
+        }
+    else
+        {
+        HTI_LOG_TEXT( "Nothing to encode" );
+        }
+
+    HTI_LOG_FUNC_OUT( "EncodeBitmapL" );
+    }
+
+// ----------------------------------------------------------------------------
+TInt CHtiScreenshotServicePlugin::Compress()
+    {
+    __ASSERT_ALWAYS(iEncodedBitmap!=NULL,User::Panic(KScreenshotPanic, KErrGeneral));
+    TInt err = KErrNone;
+    HBufC8* zippedTemp = NULL;
+
+    HTI_LOG_FORMAT( "image size %d", iEncodedBitmap->Size() );
+    TInt numOfSteps = 4;
+    TInt comprBufferIncrease = iEncodedBitmap->Size()/numOfSteps;
+
+    //straight way to handle cases
+    //when compressed data larger than uncompressed
+    //try until buffer for compr. data twice bigger than original data
+    for ( TInt i = 0; i < numOfSteps; ++i )
+        {
+        delete zippedTemp;
+        TRAP( err, zippedTemp = HBufC8::NewL( iEncodedBitmap->Size() +
+                                              i*comprBufferIncrease ) );
+        if ( err == KErrNone )
+            {
+            //try to zip
+            HTI_LOG_TEXT( "try to zip" );
+            TPtr8 zippedTempPtr = zippedTemp->Des();
+            TRAP( err, CEZCompressor::CompressL( zippedTempPtr,
+                                                 *iEncodedBitmap ) );
+            if ( err == KErrNone || err != KEZlibErrBuf )
+                {
+                break;
+                }
+            }
+        else
+            {
+            break;
+            }
+        }
+
+    if ( err == KErrNone )
+        {
+        delete iEncodedBitmap;
+        iEncodedBitmap = zippedTemp;
+        }
+    else
+        {
+        HTI_LOG_FORMAT( "compre error %d", err );
+        delete zippedTemp;
+        }
+
+    return err;
+    }
+
+// ----------------------------------------------------------------------------
+void CHtiScreenshotServicePlugin::ICLComplete( TInt anError)
+    {
+    HTI_LOG_FUNC_IN( "ICLComplete" );
+
+    //delete what we dont need right away
+    delete iBitmapEncoder;
+    iBitmapEncoder = NULL;
+    delete iICLHandler;
+    iICLHandler = NULL;
+
+
+    if ( anError==KErrNone )
+        {
+        TInt err = KErrNone;
+
+
+        //compress
+        if ( iCompress )
+            {
+            HTI_LOG_TEXT( "compress" );
+            err = Compress();
+            }
+
+        //send
+        if ( err == KErrNone )
+            {
+
+            if ( !iSeriesShot->IsOngoing() )
+                {
+                // Not a series shot
+
+                if ( iDeltaCapture )
+                    {
+                    // DeltaCapture on
+
+                    // If we have encoded the bitmap then we
+                    // also have some difference in the bitmap
+
+                    HTI_LOG_TEXT( "Sending image with coordinates..." );
+
+                    HBufC8* buf = HBufC8::NewL( (4*2) + iEncodedBitmap->Size() );
+                    buf->Des().SetLength(4*2);
+                    TUint16* ptr = (TUint16*) buf->Des().Ptr();
+                    ptr[0] = (TUint16) iDeltaRect.iTl.iX;
+                    ptr[1] = (TUint16) iDeltaRect.iTl.iY;
+                    ptr[2] = (TUint16) iDeltaRect.iBr.iX;
+                    ptr[3] = (TUint16) iDeltaRect.iBr.iY;
+
+                    buf->Des().Append(*iEncodedBitmap);
+
+                    delete iEncodedBitmap;
+                    iEncodedBitmap = NULL;
+
+                    // Response also sent in CreateBitmapL
+                    err = iDispatcher->DispatchOutgoingMessage(buf,
+                                            KScreenshotServiceUid);
+                    }
+                else
+                    {
+                    // Normal case
+                    HTI_LOG_TEXT( "Sending image..." );
+                    err = iDispatcher->DispatchOutgoingMessage(iEncodedBitmap,
+                                            KScreenshotServiceUid);
+                    }
+
+                if (  err == KErrNoMemory )
+                    {
+                    HTI_LOG_TEXT( "wait for memory" );
+                    iDispatcher->AddMemoryObserver( this );
+                    }
+                else if ( err == KErrNone )
+                    {
+                    iEncodedBitmap = NULL;
+                    }
+                else //just drop
+                    {
+                    HTI_LOG_TEXT( "ERROR: Impossible to send image" );
+                    delete iEncodedBitmap;
+                    iEncodedBitmap = NULL;
+                    }
+                }
+            }
+        else
+            {
+            iSeriesShot->Cancel();
+            iDispatcher->DispatchOutgoingErrorMessage(
+                    err,
+                    KErrDescrFailedCompress,
+                    KScreenshotServiceUid);
+            delete iEncodedBitmap;
+            iEncodedBitmap = NULL;
+            }
+        }
+    else
+        {
+        iSeriesShot->Cancel();
+        iDispatcher->DispatchOutgoingErrorMessage(
+                        anError,
+                        KErrDescrFailedConvert,
+                        KScreenshotServiceUid);
+        delete iEncodedBitmap;
+        iEncodedBitmap = NULL;
+        }
+
+    if ( iSeriesShot->IsOngoing() )
+        {
+        iSeriesShot->SaveImage( iEncodedBitmap, iCompress );
+        delete iEncodedBitmap;
+        iEncodedBitmap = NULL;
+
+        // Check if there's still more to do
+        if ( iSeriesShot->IsOngoing() )
+            {
+            iSeriesShot->TriggerNewShot();
+            }
+        else
+            {
+            // - No, timer still active
+            // SeriesShot can complete here and in CSeriesShot::TimerExpired
+            SeriesShotCompletedL(iSeriesShot->ConstructCompletedMessageL());
+            }
+        }
+
+    HTI_LOG_FUNC_OUT( "ICLComplete" );
+    }
+
+// ----------------------------------------------------------------------------
+void CHtiScreenshotServicePlugin::NotifyMemoryChange( TInt aAvailableMemory )
+    {
+    if ( iEncodedBitmap )
+        {
+        if ( aAvailableMemory>= iEncodedBitmap->Size() )
+            {
+            TInt err = iDispatcher->DispatchOutgoingMessage(iEncodedBitmap,
+                                KScreenshotServiceUid);
+
+            if ( err == KErrNone)
+                {
+                iEncodedBitmap = NULL;
+                iDispatcher->RemoveMemoryObserver( this );
+                }
+            else if ( err != KErrNoMemory )
+                {
+                delete iEncodedBitmap;
+                iEncodedBitmap = NULL;
+                iDispatcher->RemoveMemoryObserver( this );
+                }
+            }
+        }
+    else
+        {
+        //some error, should not be called
+        iDispatcher->RemoveMemoryObserver(this);
+        }
+    }
+
+// ----------------------------------------------------------------------------
+void CHtiScreenshotServicePlugin::SeriesShotCompletedL(HBufC8* aMsg)
+    {
+    HTI_LOG_FUNC_IN( "CHtiScreenshotServicePlugin::SeriesShotCompletedL" );
+    User::LeaveIfError( iDispatcher->DispatchOutgoingMessage(
+                        aMsg,
+                        KScreenshotServiceUid) );
+    HTI_LOG_FUNC_OUT( "CHtiScreenshotServicePlugin::SeriesShotCompletedL" );
+    }
+
+// ----------------------------------------------------------------------------
+TBool CHtiScreenshotServicePlugin::StartShotL(TRect aRegion, TDisplayMode aDisplayMode, TDesC8 &aMimeType)
+    {
+    HTI_LOG_FUNC_IN( "CHtiScreenshotServicePlugin::StartShot" );
+    CreateBitmapL( aRegion, aDisplayMode );
+
+    if ( aMimeType.Length()==0 )
+        EncodeBitmapL(); //use default encoder BMP
+    else
+        EncodeBitmapL( aMimeType );
+
+    HTI_LOG_FUNC_OUT( "CHtiScreenshotServicePlugin::StartShot" );
+    return iScreen ? ETrue : EFalse;
+    }
+
+// ----------------------------------------------------------------------------
+CSeriesShot* CSeriesShot::NewL( MSeriesShotObserver* aServicePlugin )
+    {
+    HTI_LOG_FUNC_IN( "CSeriesShot::NewL" );
+    CSeriesShot* self = new (ELeave) CSeriesShot( aServicePlugin );
+    CleanupStack::PushL (self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    HTI_LOG_FUNC_OUT( "CSeriesShot::NewL" );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+void CSeriesShot::ConstructL()
+    {
+    User::LeaveIfError(iFs.Connect());
+    }
+
+// ----------------------------------------------------------------------------
+CSeriesShot::CSeriesShot( MSeriesShotObserver* aServicePluginObserver ):
+    iServicePluginObserver( aServicePluginObserver ),
+    iDurationTimer( NULL ),
+    iIntervalTimer( NULL ),
+    isEncoding( EFalse )
+    {
+    }
+
+// ----------------------------------------------------------------------------
+CSeriesShot::~CSeriesShot()
+    {
+    Cancel();
+    iFs.Close();
+    }
+
+// ----------------------------------------------------------------------------
+void CSeriesShot::ClearShots()
+    {
+    HTI_LOG_FUNC_IN( "CSeriesShot::ClearShots" );
+
+    iFs.MkDirAll( KSeriesShotPath );
+
+    // Delete all files
+    TFileName files;
+    files.Append( KSeriesShotPath );
+    files.Append( _L( "*.*" ) );
+    HTI_LOG_DES(files);
+
+
+    CFileMan *fileman = CFileMan::NewL( iFs );
+    TInt err = fileman->Delete( files );
+    HTI_LOG_FORMAT( "delete %d", err );
+    if ( err != KErrNotFound )
+        User::LeaveIfError( err );
+    delete fileman;
+
+
+    HTI_LOG_FUNC_OUT( "CSeriesShot::ClearShots" );
+    }
+
+// ----------------------------------------------------------------------------
+void CSeriesShot::StartL( TTimeIntervalMicroSeconds32 aDuration,
+                         TTimeIntervalMicroSeconds32 aInterval,
+                         TDisplayMode aDisplayMode,
+                         TRect aRegion,
+                         TPtrC8 aMime )
+    {
+    HTI_LOG_FUNC_IN( "CSeriesShot::StartL" );
+    HTI_LOG_FORMAT( "Duration      : %d microseconds", aDuration.Int() );
+    HTI_LOG_FORMAT( "Interval      : %d microseconds", aInterval.Int() );
+    HTI_LOG_FORMAT( "Displaymode   : %d", aDisplayMode );
+    HTI_LOG_FORMAT( "TopLeft X     : %d", aRegion.iTl.iX );
+    HTI_LOG_FORMAT( "TopLeft Y     : %d", aRegion.iTl.iY );
+    HTI_LOG_FORMAT( "BottomRight X : %d", aRegion.iBr.iX );
+    HTI_LOG_FORMAT( "BottomRight Y : %d", aRegion.iBr.iY );
+
+    iDisplayMode = aDisplayMode;
+    iRegion = aRegion;
+    iIndex = 0;
+
+    iMimeType.Zero();
+    iMimeType.Append( aMime );
+    HTI_LOG_DES( iMimeType );
+
+#ifdef __ENABLE_LOGGING__
+    HTI_LOG_TEXT( "Supported MIME types:" );
+    RFileExtensionMIMETypeArray array;
+    CImageEncoder::GetFileTypesL( array );
+    for ( TInt i = 0; i < array.Count(); i++ )
+        HTI_LOG_DES( array[i]->MIMEType() );
+    array.ResetAndDestroy();
+#endif
+
+    iExtension.Zero();
+    if ( iMimeType.Length() == 0 )
+        iExtension.Append( _L( ".bmp" ) );
+    else
+        GetMIMEExtension( iMimeType, iExtension );
+
+    ClearShots();
+
+    iDurationTimer = CSeriesShotTimer::NewL( this, EDuration, aDuration );
+    iIntervalTimer = CSeriesShotTimer::NewL( this, EInterval, aInterval );
+    iDurationTimer->Start();
+    TimerExpired( EInterval ); // trigger first shot immidietly
+
+    HTI_LOG_FUNC_OUT( "CSeriesShot::StartL" );
+    }
+
+void CSeriesShot::TimerExpired( TInt aId )
+    {
+    HTI_LOG_FUNC_IN( "CSeriesShot::TimerExpired" );
+    switch ( aId )
+        {
+        case EDuration:
+            HTI_LOG_TEXT( "EDuration" );
+
+            delete iDurationTimer;
+            iDurationTimer = NULL;
+
+            if ( iIntervalTimer ) // I'm paranoid
+                {
+                delete iIntervalTimer;
+                iIntervalTimer = NULL;
+                }
+            // SeriesShot can complete here and in CHtiScreenshotServicePlugin::ICLComplete
+            if ( isEncoding == EFalse )
+                iServicePluginObserver->SeriesShotCompletedL( ConstructCompletedMessageL() );
+
+            break;
+
+        case EInterval:
+            HTI_LOG_TEXT( "EInterval" );
+
+            isEncoding = iServicePluginObserver->StartShotL( iRegion, iDisplayMode, iMimeType );
+
+            break;
+
+        default:
+            break;
+        }
+    HTI_LOG_FUNC_OUT( "CSeriesShot::TimerExpired" );
+    }
+
+// ----------------------------------------------------------------------------
+TBool CSeriesShot::IsOngoing()
+    {
+    // It still might be encoding when duration timer has expired
+    return ( iDurationTimer || isEncoding ) ? ETrue : EFalse;
+    }
+
+// ----------------------------------------------------------------------------
+void CSeriesShot::SaveImage( TDesC8* aImage, TBool isCompressed )
+    {
+    HTI_LOG_FUNC_IN( "CSeriesShot::SaveImage" );
+
+    isEncoding = EFalse;
+
+    TFileName filename( KSeriesShotPath );
+    filename.AppendFormat( _L( "%04d" ), iIndex );
+    iIndex++;
+    filename.Append( iExtension );
+    if ( isCompressed )
+        filename.Append( _L( "z" ) );
+    HTI_LOG_DES( filename );
+
+    RFile file;
+    User::LeaveIfError( file.Create( iFs, filename, EFileWrite ) );
+    User::LeaveIfError( file.Write( *aImage ) );
+    file.Close();
+
+    HTI_LOG_FUNC_IN( "CSeriesShot::SaveImage" );
+    }
+
+// ----------------------------------------------------------------------------
+void CSeriesShot::TriggerNewShot()
+    {
+    if ( iDurationTimer )
+        iIntervalTimer->Start();
+    }
+
+// ----------------------------------------------------------------------------
+void CSeriesShot::Cancel()
+    {
+    if ( iDurationTimer )
+        {
+        delete iDurationTimer;
+        iDurationTimer = NULL;
+        }
+    if ( iIntervalTimer )
+        {
+        delete iIntervalTimer;
+        iIntervalTimer = NULL;
+        }
+    ClearShots();
+    }
+
+// ----------------------------------------------------------------------------
+void CSeriesShot::EncodeCompleted()
+    {
+    isEncoding = EFalse;
+    }
+
+// ----------------------------------------------------------------------------
+void CSeriesShot::GetMIMEExtension( TDesC8 &aMime, TDes &aExt )
+    {
+    RFileExtensionMIMETypeArray array;
+    CImageEncoder::GetFileTypesL( array );
+    for ( TInt i = 0; i < array.Count(); i++ )
+        {
+        if ( array[i]->MIMEType() == aMime )
+            aExt.Append( array[i]->FileExtension() );
+        }
+    array.ResetAndDestroy();
+
+    if ( aExt == KNullDesC ) // should not happen
+        aExt.Append( _L( ".xxx" ) );
+    }
+
+// ----------------------------------------------------------------------------
+HBufC8* CSeriesShot::ConstructCompletedMessageL()
+    {
+    HTI_LOG_FUNC_IN( "CSeriesShot::ConstructCompletedMessageL" );
+    // Serialshot completed send ok message.
+
+    CDir* dir = NULL;
+    User::LeaveIfError( iFs.GetDir(
+        KSeriesShotPath, KEntryAttNormal, ESortByName, dir ) );
+
+    TInt msgSize = 0;
+
+    if ( dir->Count() == 0 )
+        {
+        HTI_LOG_TEXT( "No shots found! Leaving..." );
+        User::Leave( KErrNotFound );
+        }
+
+    for ( TInt i = 0; i < dir->Count(); i++ )
+        {
+        msgSize += 1; // for length field
+        msgSize += KSeriesShotPath().Length();
+        msgSize += (*dir)[i].iName.Length();
+        }
+
+    HBufC8* msg = HBufC8::NewL( msgSize );
+
+    for ( TInt i = 0; i < dir->Count(); i++ )
+        {
+        msg->Des().Append( KSeriesShotPath().Length() + (*dir)[i].iName.Length() );
+        msg->Des().Append( KSeriesShotPath );
+        msg->Des().Append( (*dir)[i].iName );
+        }
+
+    delete dir;
+
+    HTI_LOG_FUNC_OUT( "CSeriesShot::ConstructCompletedMessageL" );
+    return msg;
+    }
+
+// ----------------------------------------------------------------------------
+CSeriesShotTimer* CSeriesShotTimer::NewL( MSeriesShotTimerObserver* aObserver,
+                                        TInt aId,
+                                        TTimeIntervalMicroSeconds32 aTime )
+    {
+    HTI_LOG_FUNC_IN( "CSeriesShotTimer::NewL" );
+    CSeriesShotTimer* self = new (ELeave) CSeriesShotTimer( aObserver, aId, aTime );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    HTI_LOG_FUNC_OUT( "CSeriesShotTimer::NewL" );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+void CSeriesShotTimer::ConstructL()
+    {
+    HTI_LOG_FUNC_IN( "CSeriesShotTimer::ConstructL" );
+    CTimer::ConstructL();
+    if ( !IsAdded() ) // CTimer should add it but it seems that it does NOT!
+        {
+        CActiveScheduler::Add( this );
+        }
+    HTI_LOG_FUNC_OUT( "CSeriesShotTimer::ConstructL" );
+    }
+
+// ----------------------------------------------------------------------------
+CSeriesShotTimer::CSeriesShotTimer( MSeriesShotTimerObserver* aObserver,
+                                  TInt aId,
+                                  TTimeIntervalMicroSeconds32 aTime ):
+    CTimer( EPriorityStandard ),
+    iObserver( aObserver ),
+    iId( aId ),
+    iTime( aTime )
+    {
+    }
+
+// ----------------------------------------------------------------------------
+CSeriesShotTimer::~CSeriesShotTimer()
+    {
+    }
+
+// ----------------------------------------------------------------------------
+void CSeriesShotTimer::RunL()
+    {
+    iObserver->TimerExpired( iId );
+    }
+
+// ----------------------------------------------------------------------------
+void CSeriesShotTimer::Start()
+    {
+    HTI_LOG_FORMAT( "Start CSeriesShotTimer : %d microseconds", iTime.Int() );
+    After( iTime );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiScreenshotServicePlugin/src/HtiTextRcg.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,956 @@
+/*
+* 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:  Text recognition algorithm implementation.
+*
+*/
+
+
+#include "HtiTextRcg.h"
+#include <AknUtils.h>
+#include <HTILogging.h>
+
+const static TInt KDefaultStrategy = EHintEdge;
+
+TInt CompareTPoint(const TPoint& aP1,const TPoint& aP2)
+    {
+    //this functions is used only to avoid equal points when creating FGA or BGA
+    //so only equality of points is important, order doesnt matter
+    if ( aP1.iY == aP2.iY )
+        return aP1.iX - aP2.iX;
+    return aP1.iY - aP2.iY;
+    }
+
+CHtiTextRcg::CHtiTextRcg()
+    {
+    iAvgDiffMin = KDefaultAvgDiffMin;
+    //minimal SS for foreground, with plain color should be 0
+    iFgSSMin = KDefaultFgSSMin;
+    iFgAvgDiffMin = KDefaultFgAvgDiffMin;
+
+    iFGAAmount = KDefaultFGAAmount;
+    iBGAAmount = KDefaultBGAAmount;
+
+    SetHint(KDefaultStrategy);
+    }
+
+CHtiTextRcg::~CHtiTextRcg()
+    {
+    iFGASet.Close();
+    iBGASet.Close();
+    }
+
+void CHtiTextRcg::SetHint(TInt aHint)
+    {
+    //selects strategy and algorithm parameters
+    switch ( aHint )
+        {
+        case EHintEdge:
+            {
+            //AA strategy
+            iCurrentStrategy = EHintEdge;
+            }
+            break;
+        case EHintNone:
+        default:
+            {
+            //default strategy
+            iCurrentStrategy = EHintNone;
+            }
+        }
+    }
+
+
+TBool CHtiTextRcg::RecognizeTextL(CFbsBitmap* aScreenshot,
+                        const TDesC& aText,
+                        const CFont* aFont,
+                        TRect& aResult)
+    {
+HTI_LOG_FUNC_IN("RecognizeTextL");
+    TInt returnValue = KWorstCase;
+
+    CFbsBitmap* gray = ColorDownL(aScreenshot);
+    CleanupStack::PushL(gray);
+
+    switch ( iCurrentStrategy )
+        {
+        case EHintEdge:
+            {
+            returnValue = RecognizeAAL(gray,aText, aFont, aResult);
+            }
+            break;
+        case EHintNone:
+        default:
+            {
+            returnValue = RecognizeBinL(gray,aText, aFont, aResult);
+            }
+        }
+
+    CleanupStack::PopAndDestroy(gray);
+HTI_LOG_FUNC_OUT("RecognizeTextL");
+    return returnValue < KSuccessThresold;
+    }
+
+TInt CHtiTextRcg::RecognizeBinL(CFbsBitmap* aScreenshot,
+                            const TDesC& aText,
+                            const CFont* aFont,
+                            TRect& aResult)
+{
+    HTI_LOG_FUNC_IN("RecognizeBinL");
+    CFbsBitmap* searchFirstLetter = GetTextBitmapL(aText, aFont, 1);
+    CleanupStack::PushL(searchFirstLetter);
+    HTI_LOG_FORMAT("pattern size w %d", searchFirstLetter->SizeInPixels().iWidth);
+    HTI_LOG_FORMAT("pattern size h %d", searchFirstLetter->SizeInPixels().iHeight);
+
+    if ( !AnalyzePatternL(searchFirstLetter) )
+        {
+        CleanupStack::PopAndDestroy(searchFirstLetter);
+        return KWorstCase;
+        }
+    CFbsBitmap* searchText = GetTextBitmapL(aText, aFont);
+    CleanupStack::PushL(searchText);
+
+      //search range (0,0) - (reg.Size() - searchText.SizeInPixels)
+    TPoint end(aScreenshot->SizeInPixels().iWidth, aScreenshot->SizeInPixels().iHeight);
+    end -= searchText->SizeInPixels();
+    end += TPoint(1,1);
+
+    //search itself
+    for ( TPoint p( 0, 0 ); p.iY < end.iY; p.iY++ )
+        {
+        for ( p.iX = 0; p.iX < end.iX; p.iX++ )
+            {
+            TInt t = ImageDiffBinSampleL(aScreenshot, p, searchFirstLetter);
+            if ( t == 0 )
+                {
+                //check full word
+                TInt wordD = ImageDiffBinFullL(aScreenshot, p, searchText);
+                if ( wordD == 0 )
+                    {
+                    aResult.iTl.iX = p.iX;
+                    aResult.iTl.iY = p.iY;
+                    aResult.SetSize(searchText->SizeInPixels());
+                    CleanupStack::PopAndDestroy(searchText);
+                    CleanupStack::PopAndDestroy(searchFirstLetter);
+                    HTI_LOG_FUNC_OUT("RecognizeBinL");
+                    return 0;
+                    }
+                }
+            }
+        }
+    CleanupStack::PopAndDestroy(searchText);
+    CleanupStack::PopAndDestroy(searchFirstLetter);
+
+    HTI_LOG_FUNC_OUT("RecognizeBinL");
+    return KWorstCase;
+}
+
+
+TInt CHtiTextRcg::RecognizeAAL(CFbsBitmap* aScreenshot,
+                            const TDesC& aText,
+                            const CFont* aFont,
+                            TRect& aResult)
+{
+    HTI_LOG_FUNC_IN("RecognizeAAL");
+    CFbsBitmap* searchFirstLetter = GetTextBitmapL(aText, aFont, 1);
+    CleanupStack::PushL(searchFirstLetter);
+    if ( !AnalyzePatternL(searchFirstLetter) )
+        {
+        CleanupStack::PopAndDestroy(searchFirstLetter);
+        return KWorstCase;
+        }
+
+    CFbsBitmap* searchText = GetTextBitmapL(aText, aFont);
+    CleanupStack::PushL(searchText);
+
+
+    //search range (0,0) - (reg.Size() - searchText.SizeInPixels)
+    TPoint end(aScreenshot->SizeInPixels().iWidth, aScreenshot->SizeInPixels().iHeight);
+    end -= searchText->SizeInPixels();
+    end += TPoint(1,1);
+
+    //search itself
+    TInt min = KSuccessThresold;
+    TInt wordMin = KSuccessThresold;
+
+    for ( TPoint p( 0, 0 ); p.iY < end.iY; p.iY++ )
+        {
+        for ( p.iX = 0; p.iX < end.iX; p.iX++ )
+            {
+            TInt t = ImageDiffAASampleL(aScreenshot, p, searchFirstLetter);
+            if ( t < min )
+                {
+                //check full word
+                TInt wordD = ImageDiffAAFullL(aScreenshot, p, searchText);
+                if ( wordD < wordMin )
+                    {
+                    wordMin = wordD;
+                    min = t;
+                    aResult.iTl.iX = p.iX;
+                    aResult.iTl.iY = p.iY;
+                    aResult.SetSize(searchText->SizeInPixels());
+                    if ( wordMin == 0 )
+                        {
+                        CleanupStack::PopAndDestroy(searchText);
+                        CleanupStack::PopAndDestroy(searchFirstLetter);
+                        HTI_LOG_FUNC_OUT("RecognizeAAL");
+                        return 0;
+                        }
+                    }
+                }
+            }
+        }
+
+    CleanupStack::PopAndDestroy(searchText);
+    CleanupStack::PopAndDestroy(searchFirstLetter);
+
+    HTI_LOG_FUNC_OUT("RecognizeAAL");
+
+    return wordMin;
+}
+
+TBool CHtiTextRcg::AnalyzePatternL(CFbsBitmap * aPattern)
+{
+    HTI_LOG_FUNC_IN("AnalyzePatternL");
+    if ( aPattern->SizeInPixels().iWidth == 0 ||
+         aPattern->SizeInPixels().iHeight == 0 )
+        {
+        return EFalse;
+        }
+    //points are selected as follow
+    //take pair of FG-BG points which located next to each other
+    MinMax(aPattern,
+           iMaskFgColor, //min, black font
+           iMaskBgColor);//max, white bg
+
+    if ( iMaskFgColor == iMaskBgColor ) //pattern is empty
+        {
+        return EFalse;
+        }
+
+    TLinearOrder<TPoint> pointOrder(CompareTPoint);
+    TSize borders = aPattern->SizeInPixels();
+    iFGASet.Reset();
+    iBGASet.Reset();
+
+    TBitmapUtil bmpIterator(aPattern);
+    //lock bitmap
+    bmpIterator.Begin( TPoint(0,0));
+
+    //first take center lines and find take at least two pairs
+    //vertical1
+    TPoint startPoint(borders.iWidth/2, 0);
+    bmpIterator.SetPos(startPoint);
+
+    TInt lastColor = bmpIterator.GetPixel()&0xff;
+    TInt lastColorPos = 0;
+    bmpIterator.IncYPos();
+    TInt i=1;
+    TInt found = 0;
+
+    while ( found < 2 && i < borders.iHeight )
+        {
+        TInt c = bmpIterator.GetPixel()&0xff;
+
+        if ( lastColor != c )
+            {
+            if ( c == iMaskFgColor )
+                {
+                iFGASet.InsertInOrder(TPoint(startPoint.iX, i), pointOrder);
+                iBGASet.InsertInOrder(TPoint(startPoint.iX, lastColorPos), pointOrder);
+                lastColor = c;
+                lastColorPos = i;
+                ++found;
+                }
+            else if ( c == iMaskBgColor )
+                {
+                iBGASet.InsertInOrder(TPoint(startPoint.iX, i), pointOrder);
+                iFGASet.InsertInOrder(TPoint(startPoint.iX, lastColorPos), pointOrder);
+                lastColor = c;
+                lastColorPos = i;
+                ++found;
+                }
+            }
+        else
+            {
+            lastColorPos = i;
+            }
+
+        ++i;
+        bmpIterator.IncYPos();
+        }
+
+    //horizontal1
+    startPoint.SetXY(0,borders.iHeight/2);
+    bmpIterator.SetPos(startPoint);
+    lastColor = bmpIterator.GetPixel()&0xff;
+    bmpIterator.IncXPos();
+    i=1;
+    found = 0;
+    lastColorPos = 0;
+
+    while ( found < 2 && i < borders.iWidth )
+        {
+        TInt c = bmpIterator.GetPixel()&0xff;
+
+        if ( lastColor != c )
+            {
+            if ( c == iMaskFgColor )
+                {
+                iFGASet.InsertInOrder(TPoint(i, startPoint.iY), pointOrder);
+                iBGASet.InsertInOrder(TPoint(lastColorPos, startPoint.iY), pointOrder);
+                lastColor = c;
+                lastColorPos = i;
+                ++found;
+                }
+            else if ( c == iMaskBgColor )
+                {
+                iBGASet.InsertInOrder(TPoint(i, startPoint.iY), pointOrder);
+                iFGASet.InsertInOrder(TPoint(lastColorPos, startPoint.iY), pointOrder);
+                lastColor = c;
+                lastColorPos = i;
+                ++found;
+                }
+            }
+        else
+            {
+            lastColorPos = i;
+            }
+        ++i;
+        bmpIterator.IncXPos();
+        }
+
+    //unlock bitmap
+    bmpIterator.End();
+
+    iFGAAmount = iFGASet.Count();
+    iBGAAmount = iBGASet.Count();
+
+    HTI_LOG_FUNC_OUT("AnalyzePatternL");
+    return ETrue;
+
+}
+
+TInt CHtiTextRcg::ImageDiffAASampleL(CFbsBitmap * aBitmap1, TPoint aOrigin1,
+                 CFbsBitmap * aBitmap2)
+    {
+
+    if (iFGASet.Count()==0 || iBGASet.Count()==0)
+        return KWorstCase;
+
+    TSize aSize = aBitmap2->SizeInPixels();
+
+    //straight average difference
+    TBitmapUtil bmpIterator1(aBitmap1);
+    TBitmapUtil bmpIterator2(aBitmap2);
+
+    bmpIterator1.Begin( aOrigin1 );
+
+    //1. check FGA points are equal
+    bmpIterator1.SetPos( aOrigin1 + iFGASet[0]);
+    iTestFgColor = bmpIterator1.GetPixel()&0xff;
+
+    for ( TInt i = 1; i < iFGAAmount;++i )
+        {
+        bmpIterator1.SetPos( aOrigin1 + iFGASet[i]);
+        TInt c = bmpIterator1.GetPixel()&0xff;
+        if ( Abs(c-iTestFgColor) > iFgAvgDiffMin )
+            {
+            bmpIterator2.End();
+            bmpIterator1.End();
+            return KWorstCase;
+            }
+        }
+    // if we are here all FGA points are equal to colorFGA
+    //2. check that avg BGA point value is not equal to colorFGA
+    iTestBgColor = 0;
+    for ( TInt i = 0; i < iBGAAmount; ++i )
+        {
+        bmpIterator1.SetPos( aOrigin1 + iBGASet[i]);
+        iTestBgColor += bmpIterator1.GetPixel()&0xff;
+        }
+    iTestBgColor /= iBGAAmount;
+    //if difference is too small leave with false
+    if ( Abs(iTestBgColor-iTestFgColor) <  iAvgDiffMin )
+        {
+        bmpIterator2.End();
+        bmpIterator1.End();
+        return KWorstCase;
+        }
+
+    //all checking based on FGA and BGA are correct, chance to have match
+    //3. calculate sum of diff between colorFGA and ALL FG points
+    bmpIterator1.End();
+    bmpIterator1.Begin( aOrigin1 );
+    bmpIterator2.Begin( TPoint(0,0), bmpIterator1 );
+
+    TInt nofF = 0;
+    TInt sum = 0;
+    TBool iterFlag = EFalse;
+
+    TInt rowDelta = 2;
+    TInt columnDelta = 1;
+
+    TBool intellFlagBG;
+    iTestNormCoef = (Abs(iMaskFgColor-iMaskBgColor)<<KNormCoefAcc)/Abs(iTestFgColor-iTestBgColor);
+
+    for ( TInt i = 0; i < aSize.iHeight; i += rowDelta )
+        {
+        intellFlagBG = EFalse;
+        for ( TInt j = 0; j < aSize.iWidth; j += columnDelta )
+            {
+            TInt c1 = (bmpIterator1.GetPixel())&0xff;
+            TInt c2 = (bmpIterator2.GetPixel())&0xff;
+
+            if ( c2 != iMaskBgColor ) // if foreground
+                {
+                if ( c2 == iMaskFgColor ) //should be "pure" FG
+                    {
+                        if (  Abs( c1 - iTestFgColor ) > iFgAvgDiffMin )
+                        {
+                            bmpIterator2.End();
+                            bmpIterator1.End();
+                            return KWorstCase;
+                        }
+                        intellFlagBG = ETrue;
+                    }
+                else if ( intellFlagBG ) // AA pixels
+                    {
+                    //calculate diff. in relative diff in aa pixel
+                    //in mask and searh image
+                    //based on assumtion that aa pixels color
+                    // relative to fg color should correlate
+                    TInt normD = (Abs(c1-iTestFgColor)*iTestNormCoef)>>KNormCoefAcc;
+                    sum += Abs(Abs(iMaskFgColor-c2) - normD );
+
+                    ++nofF;
+                    intellFlagBG = EFalse;
+
+                    }
+                }
+            for ( TInt l = 0; l < columnDelta; l++ )
+                {
+                if ( iterFlag )
+                    {
+                    bmpIterator1.DecXPos();
+                    bmpIterator2.DecXPos();
+                    }
+                else
+                    {
+                    bmpIterator1.IncXPos();
+                    bmpIterator2.IncXPos();
+                    }
+                }
+            }
+
+        for ( int k = 0; k < rowDelta; k++ )
+        {
+            bmpIterator1.IncYPos();
+            bmpIterator2.IncYPos();
+        }
+        for ( int l = 0; l < columnDelta; l++ )
+            {
+            if ( iterFlag )
+                {
+                bmpIterator1.IncXPos();
+                bmpIterator2.IncXPos();
+                }
+            else
+                {
+                bmpIterator1.DecXPos();
+                bmpIterator2.DecXPos();
+                }
+            }
+        iterFlag = !iterFlag;
+        }
+
+
+    bmpIterator2.End();
+    bmpIterator1.End();
+
+    if ( nofF == 0 )
+        {
+        return 0;
+        }
+    return sum / nofF;
+    }
+
+
+TInt CHtiTextRcg::ImageDiffAAFullL(CFbsBitmap * aBitmap1, TPoint aOrigin1,
+                 CFbsBitmap * aBitmap2)
+    {
+    TSize aSize = aBitmap2->SizeInPixels();
+    //straight average difference
+    TBitmapUtil bmpIterator1(aBitmap1);
+    TBitmapUtil bmpIterator2(aBitmap2);
+
+    bmpIterator1.Begin( aOrigin1 );
+    bmpIterator2.Begin( TPoint(0,0), bmpIterator1 );
+
+    TInt nofF = 0;
+    TInt sumF = 0;
+    TBool intellFlagBG;
+    TBool iterFlag = EFalse;
+    TInt rowDelta = 2;
+    TInt columnDelta = 1;
+
+    for ( TInt i = 0; i < aSize.iHeight; i += rowDelta )
+        {
+        intellFlagBG = EFalse;
+        for ( TInt j = 0; j < aSize.iWidth; j += columnDelta )
+            {
+            TInt c1 = ( bmpIterator1.GetPixel() ) & 0xff;
+            TInt c2 = ( bmpIterator2.GetPixel() ) & 0xff;
+
+            if ( c2 != iMaskBgColor ) // if foreground
+                {
+                if ( c2 == iMaskFgColor ) //should be pure FG
+                    {
+                        if (  Abs(c1 - iTestFgColor) > iFgAvgDiffMin )
+                        {
+                            bmpIterator2.End();
+                            bmpIterator1.End();
+                            return KWorstCase;
+                        }
+                        intellFlagBG = ETrue;
+                    }
+                else if ( intellFlagBG ) // AA pixels
+                    {
+                    //calculate diff. in relative diff in aa pixel
+                    //in mask and searh image
+                    //based on assumtion that aa pixels color
+                    // relative to fg color should correlate
+                    TInt normD = (Abs(c1-iTestFgColor)*iTestNormCoef)>>KNormCoefAcc;
+                    sumF += Abs(Abs(iMaskFgColor-c2) - normD );
+
+                    ++nofF;
+                    intellFlagBG = EFalse;
+                    }
+                }
+            for ( TInt l = 0; l < columnDelta; l++ )
+                {
+                if ( iterFlag )
+                    {
+                    bmpIterator1.DecXPos();
+                    bmpIterator2.DecXPos();
+                    }
+                else
+                    {
+                    bmpIterator1.IncXPos();
+                    bmpIterator2.IncXPos();
+                    }
+                }
+            }
+
+        for ( TInt k = 0; k < rowDelta; k++ )
+        {
+            bmpIterator1.IncYPos();
+            bmpIterator2.IncYPos();
+        }
+        for ( TInt l = 0; l < columnDelta; l++ )
+            {
+            if ( iterFlag )
+                {
+                bmpIterator1.IncXPos();
+                bmpIterator2.IncXPos();
+                }
+            else
+                {
+                bmpIterator1.DecXPos();
+                bmpIterator2.DecXPos();
+                }
+            }
+        iterFlag = !iterFlag;
+        }
+    bmpIterator2.End();
+    bmpIterator1.End();
+
+    if ( nofF == 0 )
+        return 0;
+
+    return sumF/nofF;
+    }
+
+TInt CHtiTextRcg::ImageDiffBinSampleL(CFbsBitmap * aBitmap1, TPoint aOrigin1,
+                 CFbsBitmap * aBitmap2)
+    {
+    TSize aSize = aBitmap2->SizeInPixels();
+    if ( iFGASet.Count() == 0 || iBGASet.Count() == 0 )
+        return KWorstCase;
+
+    //straight average difference
+    TBitmapUtil bmpIterator1(aBitmap1);
+    TBitmapUtil bmpIterator2(aBitmap2);
+
+    bmpIterator1.Begin( aOrigin1 );
+
+    //1. check FGA points are equal
+    bmpIterator1.SetPos( aOrigin1 + iFGASet[0]);
+    TInt colorFGA = bmpIterator1.GetPixel()&0xff;
+
+    for ( TInt i = 1; i < iFGAAmount; ++i )
+        {
+        bmpIterator1.SetPos( aOrigin1 + iFGASet[i] );
+        TInt c = bmpIterator1.GetPixel()&0xff;
+        if ( c != colorFGA )
+            {
+            bmpIterator2.End();
+            bmpIterator1.End();
+            return KWorstCase;
+            }
+        }
+    // if we are here all FGA points are equal to colorFGA
+    //2. check that avg BGA point value is not equal to colorFGA
+    TInt avgColorBGA = 0;
+    for ( TInt i = 0; i < iBGAAmount; ++i )
+        {
+        bmpIterator1.SetPos( aOrigin1 + iBGASet[i] );
+        avgColorBGA += bmpIterator1.GetPixel() & 0xff;
+        }
+    avgColorBGA /= iBGAAmount;
+    //if difference is too small leave with false
+    if ( Abs(avgColorBGA-colorFGA) <  iAvgDiffMin )
+        {
+        bmpIterator2.End();
+        bmpIterator1.End();
+        return KWorstCase;
+        }
+
+    //all checking based on FGA and BGA are correct, chance to have math
+    //3. calculate sum of diff between colorFGA and ALL FG points
+    bmpIterator1.End();
+    bmpIterator1.Begin( aOrigin1 );
+    bmpIterator2.Begin( TPoint(0,0), bmpIterator1 );
+
+    TBool iterFlag = EFalse;
+
+    TInt rowDelta = 1;
+    TInt columnDelta = 1;
+
+    for ( TInt i = 0; i < aSize.iHeight; i += rowDelta )
+        {
+        for ( TInt j = 0; j < aSize.iWidth; j += columnDelta )
+            {
+            TInt c1 = ( bmpIterator1.GetPixel() ) & 0xff;
+            TInt c2 = ( bmpIterator2.GetPixel() ) & 0xff;
+
+            if ( c2 == iMaskFgColor ) // if foreground
+            {
+                if ( colorFGA != c1 )
+                {
+                    bmpIterator2.End();
+                    bmpIterator1.End();
+                    return KWorstCase;
+                }
+            }
+            for ( TInt l = 0; l < columnDelta; l++ )
+                {
+                if ( iterFlag )
+                    {
+                    bmpIterator1.DecXPos();
+                    bmpIterator2.DecXPos();
+                    }
+                else
+                    {
+                    bmpIterator1.IncXPos();
+                    bmpIterator2.IncXPos();
+                    }
+                }
+            }
+
+        for ( TInt k = 0; k < rowDelta; k++ )
+        {
+            bmpIterator1.IncYPos();
+            bmpIterator2.IncYPos();
+        }
+        for ( TInt l = 0; l < columnDelta; l++ )
+            {
+            if ( iterFlag )
+                {
+                bmpIterator1.IncXPos();
+                bmpIterator2.IncXPos();
+                }
+            else
+                {
+                bmpIterator1.DecXPos();
+                bmpIterator2.DecXPos();
+                }
+            }
+        iterFlag = !iterFlag;
+        }
+
+
+    bmpIterator2.End();
+    bmpIterator1.End();
+
+    return 0;
+    }
+
+TInt CHtiTextRcg::ImageDiffBinFullL(CFbsBitmap * aBitmap1, TPoint aOrigin1,
+                 CFbsBitmap * aBitmap2)
+    {
+    TSize aSize = aBitmap2->SizeInPixels();
+    //straight average difference
+    TBitmapUtil bmpIterator1(aBitmap1);
+    TBitmapUtil bmpIterator2(aBitmap2);
+
+    bmpIterator1.Begin( aOrigin1 );
+    bmpIterator2.Begin( TPoint(0,0), bmpIterator1 );
+
+    //TInt nofF = 0;
+    TInt nofB = 0;
+
+    TInt sumB = 0;
+    //TInt sumF = 0;
+    TBool intellFlagBG;
+    TBool iterFlag = EFalse;
+    TInt rowDelta = 1;
+    TInt columnDelta = 1;
+    TInt fgColor = -1;
+    for ( TInt i = 0; i < aSize.iHeight; i += rowDelta )
+        {
+        intellFlagBG = EFalse;
+        for ( TInt j = 0; j < aSize.iWidth; j += columnDelta )
+            {
+            TInt c1 = ( bmpIterator1.GetPixel() ) & 0xff;
+            TInt c2 = ( bmpIterator2.GetPixel() ) & 0xff;
+
+            if ( c2 == iMaskFgColor ) // if FG
+            {
+                if ( c1 != fgColor )
+                    {
+                    if ( fgColor != -1 )
+                        {
+                        //failed
+                        bmpIterator2.End();
+                        bmpIterator1.End();
+                        return KWorstCase;
+                        }
+                    else
+                        {
+                        fgColor = c1; //init fgColor
+                        }
+                    }
+                intellFlagBG = ETrue;
+            }
+            else if ( c2 == iMaskBgColor && intellFlagBG )
+            {
+                sumB += c1;
+                ++nofB;
+                intellFlagBG = EFalse;
+            }
+            for ( TInt l = 0; l < columnDelta; l++ )
+                {
+                if ( iterFlag )
+                    {
+                    bmpIterator1.DecXPos();
+                    bmpIterator2.DecXPos();
+                    }
+                else
+                    {
+                    bmpIterator1.IncXPos();
+                    bmpIterator2.IncXPos();
+                    }
+                }
+            }
+
+        for ( TInt k = 0; k < rowDelta; k++ )
+        {
+            bmpIterator1.IncYPos();
+            bmpIterator2.IncYPos();
+        }
+        for ( TInt l = 0; l < columnDelta; l++ )
+            {
+            if ( iterFlag )
+                {
+                bmpIterator1.IncXPos();
+                bmpIterator2.IncXPos();
+                }
+            else
+                {
+                bmpIterator1.DecXPos();
+                bmpIterator2.DecXPos();
+                }
+            }
+        iterFlag = !iterFlag;
+        }
+    bmpIterator2.End();
+    bmpIterator1.End();
+
+    if ( nofB == 0 ) //something wrong, should be some BG
+        return KWorstCase;
+
+    TInt avgB = sumB / ( nofB );
+
+    if ( Abs( fgColor - avgB ) < iAvgDiffMin )
+        {
+        return KWorstCase;
+        }
+
+    return 0;
+    }
+
+void CHtiTextRcg::MinMax(CFbsBitmap * aBitmap, TInt& aMin, TInt& aMax)
+    {
+    //straight average difference
+    TSize aSize = aBitmap->SizeInPixels();
+    TBitmapUtil bmpIterator(aBitmap);
+
+    bmpIterator.Begin( TPoint(0,0) );
+
+    aMin = KMaxTInt;
+    aMax = -1;
+    for ( TInt i = 0; i < aSize.iHeight; ++i )
+        {
+        for ( TInt j = 0; j < aSize.iWidth; ++j )
+            {
+            TInt c = ( bmpIterator.GetPixel() ) & 0xff;
+
+            if ( c < aMin )
+                {
+                aMin = c;
+                }
+            else if ( c > aMax )
+                {
+                aMax = c;
+                }
+
+            if ( i & 1 )
+                {
+                bmpIterator.DecXPos();
+                }
+            else
+                {
+                bmpIterator.IncXPos();
+                }
+            }
+        bmpIterator.IncYPos();
+
+        if ( i & 1 )
+            {
+            bmpIterator.IncXPos();
+            }
+        else
+            {
+            bmpIterator.DecXPos();
+            }
+        }
+
+    bmpIterator.End();
+    }
+
+CFbsBitmap* CHtiTextRcg::ColorDownL( CFbsBitmap * aBitmap )
+    {
+    TSize bmpSize = aBitmap->SizeInPixels();
+    CFbsBitmap* result = new ( ELeave )  CFbsBitmap();
+    User::LeaveIfError( result->Create( bmpSize, EGray256 ) );
+
+    TBitmapUtil srcBmpIterator( aBitmap );
+    TBitmapUtil resultBmpIterator( result );
+
+    srcBmpIterator.Begin( TPoint( 0, 0 ) );
+    resultBmpIterator.Begin( TPoint( 0, 0 ), srcBmpIterator );
+
+    TPoint point( 0, 0 );
+    for ( point.iY = 0; point.iY < bmpSize.iHeight; ++point.iY )
+        {
+        point.iX = 0;
+        srcBmpIterator.SetPos( point );
+        resultBmpIterator.SetPos( point );
+        for ( ; point.iX < bmpSize.iWidth; ++point.iX )
+            {
+            TUint32 c = srcBmpIterator.GetPixel();
+            TRgb col( c );
+            resultBmpIterator.SetPixel( col.Gray256() );
+            srcBmpIterator.IncXPos();
+            resultBmpIterator.IncXPos();
+            }
+        }
+
+    resultBmpIterator.End();
+    srcBmpIterator.End();
+
+    return result;
+    }
+
+CFbsBitmap* CHtiTextRcg::GetTextBitmapL( const TDesC& aText,
+                                         const CFont* fontUsed,
+                                         const TInt aLength )
+    {
+    return GetTextBitmapL( aText, fontUsed, KRgbBlack, KRgbWhite,
+            EGray256, aLength );
+    }
+
+
+
+CFbsBitmap* CHtiTextRcg::GetTextBitmapL( const TDesC& aText,
+                                    const CFont* fontUsed,
+                                    TRgb aForeground,
+                                    TRgb aBackground,
+                                    TDisplayMode aDisplayMode,
+                                    const TInt aLength )
+{
+    HTI_LOG_FUNC_IN( "CHtiTextRcg::GetTextBitmapL" )
+    // Measure the text to get needed bitmap size and baseline point
+    CFont::TMeasureTextOutput output;
+    TInt reqWidth = fontUsed->MeasureText( aText, NULL, &output );
+    reqWidth = Max( reqWidth, output.iBounds.Width() );
+
+    // If only partial text requested, calculate new width but keep the
+    // height (and baseline) as it needs to be the same as for the full text
+    // for the text recognition to work.
+    if ( aLength < aText.Length() )
+        {
+        CFont::TMeasureTextOutput partialOutput;
+        reqWidth = fontUsed->MeasureText( aText.Left( aLength ), NULL,
+                &partialOutput );
+        reqWidth = Max( reqWidth, partialOutput.iBounds.Width() );
+        }
+
+    TSize bmpSize( reqWidth, output.iBounds.Height() );
+    HTI_LOG_FORMAT( "Bitmap width = %d", bmpSize.iWidth );
+    HTI_LOG_FORMAT( "Bitmap height = %d", bmpSize.iHeight );
+
+    // Create the bitmap
+    CFbsBitmap* result = new ( ELeave ) CFbsBitmap();
+    User::LeaveIfError( result->Create( bmpSize, aDisplayMode ) );
+
+    CFbsBitGc* bitmapContext = NULL;
+    CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL( result );
+    CleanupStack::PushL( bitmapDevice );
+    User::LeaveIfError( bitmapDevice->CreateContext( bitmapContext ) );
+    CleanupStack::PushL( bitmapContext );
+    bitmapContext->SetBrushColor( aBackground );
+    bitmapContext->Clear();
+    bitmapContext->UseFont( fontUsed );
+    bitmapContext->SetPenColor( aForeground );
+
+    // Set the baseline point and draw the text
+    TPoint pos( 0, bmpSize.iHeight - output.iBounds.iBr.iY );
+    HTI_LOG_FORMAT( "Baseline Y = %d", pos.iY );
+    if ( aLength < aText.Length() )
+        {
+        bitmapContext->DrawText( aText.Left( aLength ), pos );
+        }
+    else
+        {
+        bitmapContext->DrawText( aText, pos );
+        }
+
+    CleanupStack::PopAndDestroy( 2 );
+    HTI_LOG_FUNC_OUT( "CHtiTextRcg::GetTextBitmapL" )
+    return result;
+}
+
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiScreenshotServicePlugin/src/proxy.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,37 @@
+/*
+* 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:  Implementation proxy for screenshot service plugin dll
+*
+*/
+
+
+// INCLUDES
+#include "HtiScreenshotServicePlugin.h"
+
+#include <e32std.h>
+#include <ecom/implementationproxy.h>
+
+
+const TImplementationProxy ImplementationTable[] =
+    {
+        IMPLEMENTATION_PROXY_ENTRY(0x1020DEC3, CHtiScreenshotServicePlugin::NewL)
+    };
+
+// Function used to return an instance of the proxy table.
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    return ImplementationTable;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiSysInfoServicePlugin/data/10210CC6.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  Resource definitions for system info service ECOM plugin.
+*
+*/
+
+
+// INCLUDES
+#include <ecom/registryinfo.rh>
+
+
+// RESOURCE DEFINITIONS
+RESOURCE REGISTRY_INFO theInfo
+    {
+    // UID for the DLL
+    dll_uid = 0x10210CC6;
+    // Declare array of interface info
+    interfaces =
+        {
+        INTERFACE_INFO
+            {
+            // UID of interface that is implemented
+            interface_uid = 0x1020DEB7;
+            implementations =
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = 0x10210CC7;
+                    version_no         = 1;
+                    display_name       = "SysInfo service";
+                    default_data       = "SysInfo";
+                    opaque_data        = "";
+                    }
+                };
+            }
+        };
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiSysInfoServicePlugin/group/HtiSysInfoServicePlugin.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,67 @@
+/*
+* 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:  HTI service plugin for getting system information from device.
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          HtiSysInfoServicePlugin.dll
+TARGETTYPE      PLUGIN
+
+// ECom Dll recognition UID followed by the unique UID for this dll
+UID             0x10009D8D 0x10210CC6
+
+VENDORID        0x101FB657
+
+CAPABILITY      ALL -TCB
+
+SOURCEPATH      ../src
+SOURCE          proxy.cpp
+SOURCE          HtiSysInfoServicePlugin.cpp
+SOURCE          HtiLightsController.cpp
+SOURCE          HtiPropertySubscriber.cpp
+
+USERINCLUDE     ../inc
+APP_LAYER_SYSTEMINCLUDE
+
+START RESOURCE  ../data/10210CC6.rss
+TARGET          HtiSysInfoServicePlugin.rsc
+END
+
+LIBRARY         aknskinsrv.lib
+LIBRARY         avkon.lib
+LIBRARY         bafl.lib
+LIBRARY         btdevice.lib
+LIBRARY         btmanclient.lib
+LIBRARY         btengsettings.lib
+LIBRARY         c32.lib
+LIBRARY         centralrepository.lib
+LIBRARY         customapi.lib
+LIBRARY         drmserverinterfaces.lib
+LIBRARY         ecom.lib
+LIBRARY         efsrv.lib
+LIBRARY         etel.lib
+LIBRARY         etelmm.lib
+LIBRARY         euser.lib
+LIBRARY         hal.lib
+LIBRARY         hwrmlightclient.lib
+LIBRARY         sysutil.lib
+LIBRARY         tzclient.lib
+LIBRARY         flogger.lib
+
+SMPSAFE
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiSysInfoServicePlugin/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,26 @@
+/*
+* 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:  Build information file for HtiSysInfoServicePlugin
+*
+*/
+
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+HtiSysInfoServicePlugin.mmp
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiSysInfoServicePlugin/inc/HtiLightsController.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,101 @@
+/*
+* 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:  For controlling S60 device lights.
+*                Helper for SysInfoServicePlugin.
+*
+*/
+
+
+#ifndef HTILIGHTSCONTROLLER_H
+#define HTILIGHTSCONTROLLER_H
+
+// INCLUDES
+#include <e32base.h>
+#include <HWRMLight.h>
+
+// FORWARD DECLARATIONS
+class MHtiDispatcher;
+
+// CLASS DECLARATION
+/**
+* For controlling S60 device lights. Helper class for SysInfoServicePlugin.
+*/
+class CHtiLightsController : public CBase,
+                             public MHWRMLightObserver
+    {
+public:
+
+    static CHtiLightsController* NewL( MHtiDispatcher* aDispatcher );
+
+    /**
+    * Called by the plugin when there is a message to be processed by
+    * the lights controller.
+    * @param aMessage message body destinated to the servive
+    * @param aReply on return contains the reply message (OK response)
+    */
+    void ProcessMessageL( const TDesC8& aMessage, TDes8& aReply );
+
+    ~CHtiLightsController();
+
+    // from MHWRMLightObserver
+    void LightStatusChanged( TInt aTarget,
+                             CHWRMLight::TLightStatus aStatus );
+
+protected:
+
+    CHtiLightsController( MHtiDispatcher* aDispatcher );
+    void ConstructL();
+
+private: // private helper methods
+
+    void HandleLightStatusL( const TDesC8& aMessage );
+    void HandleLightOnL( const TDesC8& aMessage );
+    void HandleLightOffL( const TDesC8& aMessage );
+    void HandleLightBlinkL( const TDesC8& aMessage );
+
+
+private: // private data
+
+    // The message dispatcher interface for dispatching error messages.
+    MHtiDispatcher* iDispatcher;
+
+    // The reply message to dispatch.
+    TBuf8<4> iReply;
+
+    // Light client session.
+    CHWRMLight* iLight;
+
+    // The latest command
+    TInt iCommand;
+
+    // The light target bitmask of latest call
+    TInt iTarget;
+
+    // The duration given in latest call
+    TInt iDuration;
+
+    // The lights on duration given in latest blink lights call
+    TInt iOnDuration;
+
+    // The lights off duration given in latest blink lights call
+    TInt iOffDuration;
+
+    // The intensity value of latest call
+    TInt iIntensity;
+
+    // The fade value of latest call
+    TBool iFade;
+    };
+
+#endif // HTILIGHTSCONTROLLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiSysInfoServicePlugin/inc/HtiPropertySubscriber.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,54 @@
+/*
+* 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:  For controlling S60 device lights.
+*                Subscribes to a property to monitor changes in it.
+*
+*/
+
+
+#ifndef HTIPROPERTYSUBSCRIBER_H
+#define HTIPROPERTYSUBSCRIBER_H
+
+// INCLUDES
+#include <e32base.h>
+#include <e32property.h>
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+/**
+* Subscribes to a property to monitor changes in it.
+*/
+class CHtiPropertySubscriber : public CActive
+    {
+    public:
+        CHtiPropertySubscriber( TCallBack aCallBack, RProperty& aProperty );
+        ~CHtiPropertySubscriber();
+
+    public: // New functions
+        void Subscribe();
+        void Unsubscribe();
+
+    private: // from CActive
+        void RunL();
+        void DoCancel();
+
+    private: // data
+        TCallBack   iCallBack;
+        RProperty&  iProperty;
+    };
+
+#endif // HTIPROPERTYSUBSCRIBER_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiSysInfoServicePlugin/inc/HtiSysInfoServicePlugin.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,174 @@
+/*
+* 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:  Implementation of ECOM plug-in service interface. Provides
+*                system info service.
+*
+*/
+
+
+#ifndef HTISYSINFOPLUGIN_H
+#define HTISYSINFOPLUGIN_H
+
+// INCLUDES
+#include <e32property.h>
+#include <f32file.h>
+#include <HTIServicePluginInterface.h>
+
+// FORWARD DECLARATIONS
+class CHtiLightsController;
+class CHtiPropertySubscriber;
+class CMGXFileManager;
+class CMGXFileNotificationHandler;
+class MDesCArray;
+
+// CLASS DECLARATION
+/**
+* System info service plugin.
+*/
+class CHtiSysInfoServicePlugin : public CHTIServicePluginInterface
+    {
+    public:
+
+        static CHtiSysInfoServicePlugin* NewL();
+
+        // Interface implementation
+        void ProcessMessageL( const TDesC8& aMessage,
+                              THtiMessagePriority aPriority );
+
+        void NotifyMemoryChange( TInt aAvailableMemory );
+
+        static TInt HandleAllowSSPropertyChange( TAny* aPtr );
+
+    protected:
+
+        CHtiSysInfoServicePlugin();
+        void ConstructL();
+        virtual ~CHtiSysInfoServicePlugin();
+
+
+    private: // private helper methods
+
+        void HandleGetHalAttrL( const TDesC8& aMessage );
+        void HandleGetImeiL( const TDesC8& aMessage );
+        void HandleGetSwVersionL( const TDesC8& aMessage );
+        void HandleGetLangVersionL( const TDesC8& aMessage );
+        void HandleGetSwLangVersionL( const TDesC8& aMessage );
+        void HandleGetUserAgentStringL( const TDesC8& aMessage );
+        void HandleGetFreeRamL( const TDesC8& aMessage );
+        void HandleGetUsedRamL( const TDesC8& aMessage );
+        void HandleGetTotalRamL( const TDesC8& aMessage );
+        void HandleEatRamL( const TDesC8& aMessage );
+        void HandleReleaseRamL( const TDesC8& aMessage );
+        void HandleGetFreeDiskSpaceL( const TDesC8& aMessage );
+        void HandleGetUsedDiskSpaceL( const TDesC8& aMessage );
+        void HandleGetTotalDiskSpaceL( const TDesC8& aMessage );
+        void HandleEatDiskSpaceL( const TDesC8& aMessage );
+        void HandleReleaseDiskSpaceL( const TDesC8& aMessage );
+        void HandleSetHomeTimeL( const TDesC8& aMessage );
+        void HandleGetHomeTimeL( const TDesC8& aMessage );
+        void HandleLightsCommandL( const TDesC8& aMessage );
+        void HandleScreenSaverCommandL( const TDesC8& aMessage );
+        void HandleScreenSaverTimeoutCommandL( const TDesC8& aMessage );
+        void HandleNetworkModeCommandL( const TDesC8& aMessage );
+        void HandleIrActivateCommandL( const TDesC8& aMessage );
+        void HandleBtPowerCommandL( const TDesC8& aMessage );
+        void HandleBtSettingsCommandL( const TDesC8& aMessage );
+        void HandleBtDeletePairingsL( const TDesC8& aMessage );
+        void HandleKeyLockToggleL( const TDesC8& aMessage );
+        void HandleAutoKeyGuardTimeL( const TDesC8& aMessage );
+        void HandleEmptyDrmRightsDbL( const TDesC8& aMessage );
+        void HandleBatteryStatusL( const TDesC8& aMessage );
+        void HandleSignalStrengthL( const TDesC8& aMessage );
+        void HandleSetDateTimeFormatL( const TDesC8& aMessage );
+        void HandleHsdpaCommandL( const TDesC8& aMessage );
+        void HandleUpdateMediaGalleryL( const TDesC8& aMessage );
+        void HandleActivateSkinL( const TDesC8& aMessage );
+
+        void ParseTimeDataL( const TDesC8& aTimeData, TTime& aResult );
+        TInt CleanUpTempFiles();
+        TBool CanTurnBluetoothOnL( const TBool aUseForce );
+
+    private: // private data
+        RFs iFs;
+        CFileMan* iFileMan;
+        HBufC8* iMemEater;
+        HBufC8* iReply;
+        CHtiLightsController* iLightsController;
+        TInt iAllowSSValue;
+        CHtiPropertySubscriber* iAllowSSSubscriber;
+        RProperty iAllowSSProperty;
+        TBool iAllowSSPropertyAttached;
+        TBool iGalleryUpdateSupported;
+    };
+
+
+// CLASS DECLARATION
+/**
+*  Helper class to wait the async requests.
+*/
+class CAsyncWaiter : public CActive
+    {
+    public:
+        static CAsyncWaiter* NewL( TInt aPriority = EPriorityStandard );
+        static CAsyncWaiter* NewLC( TInt aPriority = EPriorityStandard );
+        ~CAsyncWaiter();
+
+        void StartAndWait();
+        TInt Result() const;
+
+    private:
+        CAsyncWaiter( TInt aPriority );
+
+        // from CActive
+        void RunL();
+        void DoCancel();
+
+    private:
+        CActiveSchedulerWait* iWait;
+        TInt iResult;
+    };
+
+
+// CLASS DECLARATION
+/**
+*  Copied from MGXFileManagerFactory.h
+*/
+class MGXFileManagerFactory
+    {
+    public:
+        static CMGXFileManager* NewFileManagerL( RFs& aFs );
+        static CMGXFileNotificationHandler* NewFileNotificationHandlerL();
+    };
+
+
+// CLASS DECLARATION
+/**
+*  Copied from CMGXFileManager.h
+*/
+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 // HTISYSINFOPLUGIN_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiSysInfoServicePlugin/src/HtiLightsController.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,405 @@
+/*
+* 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:  Implementation for controlling S60 device lights.
+*
+*/
+
+
+// INCLUDE FILES
+#include <HtiDispatcherInterface.h>
+#include <HTILogging.h>
+#include "HtiLightsController.h"
+
+// CONSTANTS
+const static TUid KSysInfoServiceUid = { 0x10210CC7 };
+
+const static TInt KLightStatusCmdLength = 2;
+const static TInt KLightOnCmdLength     = 6;
+const static TInt KLightOffCmdLength    = 5;
+const static TInt KLightBlinkCmdLength  = 9;
+
+enum TSysInfoLightControlCommand
+    {
+    ELightStatus = 0x30,
+    ELightOn =     0x31,
+    ELightOff =    0x32,
+    ELightBlink =  0x33
+    };
+
+_LIT8( KErrDescrArgument,     "Invalid argument" );
+_LIT8( KErrDescrLightOn,      "LightOn failed" );
+_LIT8( KErrDescrLightOff,     "LightOff failed" );
+_LIT8( KErrDescrLightBlink,   "LightBlink failed" );
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CHtiLightsController::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CHtiLightsController* CHtiLightsController::NewL( MHtiDispatcher* aDispatcher )
+    {
+    CHtiLightsController* self = new (ELeave) CHtiLightsController(
+                                                  aDispatcher );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiLightsController::CHtiLightsController
+// C++ default constructor.
+// -----------------------------------------------------------------------------
+//
+CHtiLightsController::CHtiLightsController(
+        MHtiDispatcher* aDispatcher ):iDispatcher( aDispatcher ),
+                                      iCommand( 0 ),
+                                      iTarget( 0 ),
+                                      iDuration( 0 ),
+                                      iOnDuration( 0 ),
+                                      iOffDuration( 0 ),
+                                      iIntensity( 0 ),
+                                      iFade( EFalse )
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiLightsController::~CHtiLightsController()
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CHtiLightsController::~CHtiLightsController()
+    {
+    HTI_LOG_TEXT("CHtiLightsController destroy");
+    delete iLight;
+    }
+
+// Second phase construction
+void CHtiLightsController::ConstructL()
+    {
+    HTI_LOG_TEXT("CHtiLightsController::ConstructL");
+    iLight = CHWRMLight::NewL( this );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiLightsController::ProcessMessageL
+// Called by the plugin when there is a message to be processed by
+// the lights controller.
+// -----------------------------------------------------------------------------
+//
+void CHtiLightsController::ProcessMessageL( const TDesC8& aMessage,
+                                            TDes8& aReply )
+    {
+    HTI_LOG_FUNC_IN( "CHtiLightsController::ProcessMessageL" );
+
+    iCommand = aMessage[0];
+    iReply.Zero();
+
+    switch ( iCommand )
+        {
+        case ELightStatus:
+            {
+            HTI_LOG_TEXT( "ELightStatus" );
+            HandleLightStatusL( aMessage );
+            break;
+            }
+
+        case ELightOn:
+            {
+            HTI_LOG_TEXT( "ELightOn" );
+            HandleLightOnL( aMessage );
+            break;
+            }
+
+        case ELightOff:
+            {
+            HTI_LOG_TEXT( "ELightOff" );
+            HandleLightOffL( aMessage );
+            break;
+            }
+
+        case ELightBlink:
+            {
+            HTI_LOG_TEXT( "ELightBlink" );
+            HandleLightBlinkL( aMessage );
+            break;
+            }
+
+        default:
+            {
+            // If comes here it's an error from caller.
+            User::Leave( KErrArgument );
+            }
+        }
+
+    aReply.Copy( iReply );
+
+    HTI_LOG_FUNC_OUT("CHtiLightsController::ProcessMessageL");
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiLightsController::HandleLightStatusL
+// Gets the status of the given light target.
+// Returns "Not supported" for S60 2.x
+// -----------------------------------------------------------------------------
+//
+void CHtiLightsController::HandleLightStatusL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiLightsController::HandleLightStatusL" );
+
+    if ( aMessage.Length() != KLightStatusCmdLength )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument, KErrDescrArgument, KSysInfoServiceUid );
+        }
+
+    else
+        {
+        iTarget = aMessage[1];
+        iReply.Append( iLight->LightStatus( iTarget ) );
+        }
+    HTI_LOG_FUNC_OUT( "CHtiLightsController::HandleLightStatusL" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiLightsController::HandleLightOnL
+// Turns on light with specified parameters.
+// For S60 2.x just turns on lights forever, parameters are ignored.
+// -----------------------------------------------------------------------------
+//
+void CHtiLightsController::HandleLightOnL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiLightsController::HandleLightOnL" );
+
+    if ( aMessage.Length() != KLightOnCmdLength )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument, KErrDescrArgument, KSysInfoServiceUid );
+        return;
+        }
+
+    // parse values from message
+    iTarget    = aMessage[1];
+    iDuration  = aMessage[2] + ( aMessage[3] << 8 );
+    iIntensity = aMessage[4];
+    iFade      = (TBool)aMessage[5];
+
+    TInt err = KErrNone;
+
+    // normalize possibly abnormal values
+    if ( iIntensity < KHWRMLightMinIntensity )
+        iIntensity = KHWRMDefaultIntensity;
+
+    if ( iIntensity > KHWRMLightMaxIntensity )
+        iIntensity = KHWRMLightMaxIntensity;
+
+    if ( iDuration < 1 ) iDuration = KHWRMInfiniteDuration;
+
+    // shoot
+    TRAP( err, iLight->LightOnL( iTarget, iDuration, iIntensity, iFade ) );
+
+    if ( err )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            err, KErrDescrLightOn, KSysInfoServiceUid );
+        }
+
+    else
+        {
+        iReply.Append( 0 );
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiLightsController::HandleLightOnL ");
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiLightsController::HandleLightOffL
+// Turns off light with specified parameters.
+// Returns "Not supported" for S60 2.x
+// -----------------------------------------------------------------------------
+//
+void CHtiLightsController::HandleLightOffL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiLightsController::HandleLightOffL" );
+
+    if ( aMessage.Length() != KLightOffCmdLength )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument, KErrDescrArgument, KSysInfoServiceUid );
+        return;
+        }
+
+    // parse values from message
+    iTarget   = aMessage[1];
+    iDuration = aMessage[2] + ( aMessage[3] << 8 );
+    iFade     = (TBool)aMessage[4];
+
+    // normalize possibly abnormal values
+    if ( iDuration < 1 ) iDuration = KHWRMInfiniteDuration;
+
+    // shoot
+    TRAPD( err, iLight->LightOffL( iTarget, iDuration, iFade ) );
+
+    if ( err )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            err, KErrDescrLightOff, KSysInfoServiceUid );
+        }
+
+    else
+        {
+        iReply.Append( 0 );
+        }
+    HTI_LOG_FUNC_OUT( "CHtiLightsController::HandleLightOffL" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiLightsController::HandleLightBlinkL
+// Blinks light with specified parameters.
+// Returns "Not supported" for S60 2.x
+// -----------------------------------------------------------------------------
+//
+void CHtiLightsController::HandleLightBlinkL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiLightsController::HandleLightBlinkL" );
+
+    if ( aMessage.Length() != KLightBlinkCmdLength )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument, KErrDescrArgument, KSysInfoServiceUid );
+        return;
+        }
+
+    // parse values from message
+    iTarget      = aMessage[1];
+    iDuration    = aMessage[2] + ( aMessage[3] << 8 );
+    iOnDuration  = aMessage[4] + ( aMessage[5] << 8 );
+    iOffDuration = aMessage[6] + ( aMessage[7] << 8 );
+    iIntensity   = aMessage[8];
+
+    // normalize possibly abnormal values
+    if ( iIntensity < KHWRMLightMinIntensity )
+        iIntensity = KHWRMDefaultIntensity;
+
+    if ( iIntensity > KHWRMLightMaxIntensity )
+        iIntensity = KHWRMLightMaxIntensity;
+
+    if ( iDuration < 1 ) iDuration = KHWRMInfiniteDuration;
+
+    if ( iOnDuration < 1 || iOffDuration < 1 )
+        {
+        iOnDuration = KHWRMDefaultCycleTime;
+        iOffDuration = KHWRMDefaultCycleTime;
+        }
+
+    // shoot
+    TRAPD( err, iLight->LightBlinkL(
+            iTarget, iDuration, iOnDuration, iOffDuration, iIntensity ) );
+
+    if ( err )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            err, KErrDescrLightBlink, KSysInfoServiceUid );
+        }
+
+    else
+        {
+        iReply.Append( 0 );
+        }
+    HTI_LOG_FUNC_OUT( "CHtiLightsController::HandleLightBlinkL" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiLightsController::LightStatusChanged
+// Called when status of any light target changes.
+// If infinite duration is requested, restores the state back to what was
+// last requested.
+// This method does not exist for S60 2.x
+// -----------------------------------------------------------------------------
+//
+void CHtiLightsController::LightStatusChanged( TInt aTarget,
+                                     CHWRMLight::TLightStatus aStatus )
+    {
+    HTI_LOG_FORMAT( "Light status changed for target %d", aTarget );
+    HTI_LOG_FORMAT( "New status = %d", aStatus );
+    HTI_LOG_FORMAT( "Current target = %d", iTarget );
+
+    TInt target = aTarget & iTarget;
+    if ( !target )
+        {
+        HTI_LOG_TEXT( "Not interested about the target" );
+        return;
+        }
+
+    HTI_LOG_TEXT( "Matches current target" );
+
+    if ( iDuration != KHWRMInfiniteDuration )
+        {
+        return;
+        }
+
+    if ( ( aStatus == CHWRMLight::ELightOn && iCommand == ELightOn ) ||
+         ( aStatus == CHWRMLight::ELightOff && iCommand == ELightOff ) ||
+         ( aStatus == CHWRMLight::ELightBlink && iCommand == ELightBlink ) )
+        {
+        HTI_LOG_TEXT( "Status already OK" );
+        return;
+        }
+
+    HTI_LOG_TEXT( "Infinite duration wanted - restore light status" );
+    switch ( iCommand )
+        {
+        case ELightOn:
+            {
+            // Ignore error
+            TRAPD( err, iLight->LightOnL(
+                    target, iDuration, iIntensity, iFade ) );
+            HTI_LOG_FORMAT( "LightOnL return code %d", err );
+            err = err; // to get rid of compiler warning for non-logging
+            break;
+            }
+        case ELightOff:
+            {
+            // Ignore error
+            TRAPD( err, iLight->LightOffL( target, iDuration, iFade ) );
+            HTI_LOG_FORMAT( "LightOffL return code %d", err );
+            err = err; // to get rid of compiler warning for non-logging
+            break;
+            }
+        case ELightBlink:
+            {
+            // Ignore error
+            TRAPD( err, iLight->LightBlinkL(
+                    target, iDuration, iOnDuration,
+                    iOffDuration, iIntensity ) );
+            HTI_LOG_FORMAT( "LightBlinkL return code %d", err );
+            err = err; // to get rid of compiler warning for non-logging
+            break;
+            }
+        default:
+            break;
+        }
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiSysInfoServicePlugin/src/HtiPropertySubscriber.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,100 @@
+/*
+* 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:  Implementation for controlling S60 device lights.
+*
+*/
+
+
+// INCLUDE FILES
+#include <HTILogging.h>
+#include "HtiPropertySubscriber.h"
+
+// CONSTANTS
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CHtiPropertySubscriber::CHtiPropertySubscriber
+// -----------------------------------------------------------------------------
+//
+CHtiPropertySubscriber::CHtiPropertySubscriber( TCallBack aCallBack,
+    RProperty& aProperty) : CActive( EPriorityNormal ),
+                            iCallBack( aCallBack ),
+                            iProperty( aProperty )
+    {
+    HTI_LOG_TEXT( "CHtiPropertySubscriber construct" );
+    CActiveScheduler::Add( this );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiPropertySubscriber::~CHtiPropertySubscriber
+// -----------------------------------------------------------------------------
+//
+CHtiPropertySubscriber::~CHtiPropertySubscriber()
+    {
+    HTI_LOG_TEXT( "CHtiPropertySubscriber destroy" );
+    Cancel();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiPropertySubscriber::Subscribe
+// -----------------------------------------------------------------------------
+//
+void CHtiPropertySubscriber::Subscribe()
+    {
+    if ( !IsActive() )
+        {
+        iProperty.Subscribe( iStatus );
+        SetActive();
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiPropertySubscriber::Unsubscribe
+// -----------------------------------------------------------------------------
+//
+void CHtiPropertySubscriber::Unsubscribe()
+    {
+    Cancel();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiPropertySubscriber::RunL
+// -----------------------------------------------------------------------------
+//
+void CHtiPropertySubscriber::RunL()
+    {
+    if ( iStatus.Int() == KErrNone )
+        {
+        iCallBack.CallBack();
+        Subscribe();
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHtiPropertySubscriber::DoCancel
+// -----------------------------------------------------------------------------
+//
+void CHtiPropertySubscriber::DoCancel()
+    {
+    iProperty.Cancel();
+    }
+
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiSysInfoServicePlugin/src/HtiSysInfoServicePlugin.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,2993 @@
+/*
+* 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:  SysInfoPlugin implementation
+*
+*/
+
+
+// INCLUDE FILES
+#include "HtiSysInfoServiceplugin.h"
+#include "HtiLightsController.h"
+#include "HtiPropertySubscriber.h"
+#include <HtiDispatcherInterface.h>
+#include <HTILogging.h>
+
+#include <aknkeylock.h>
+#include <AknSkinsInternalCRKeys.h>
+#include <AknsSkinUID.h>
+#include <AknSSrvClient.h>
+#include <bautils.h>
+#include <btengsettings.h>
+#include <btengdomaincrkeys.h>
+#include <bt_subscribe.h>
+#include <btmanclient.h>
+#include <centralrepository.h>
+#include <CoreApplicationUIsSDKCRKeys.h>
+#include <DRMRightsClient.h>
+#include <e32property.h>
+#include <etel.h>
+#include <etelmm.h>
+#include <hal.h>
+#include <ir_sock.h>
+#include <mmtsy_names.h>
+#include <RMmCustomAPI.h>
+#include <HWRMPowerStateSDKPSKeys.h>
+#include <ScreenSaverInternalPSKeys.h>
+#include <SettingsInternalCRKeys.h>
+#include <sysutil.h>
+#include <tz.h>
+
+// CONSTANTS
+const static TUid KSysInfoServiceUid = { 0x10210CC7 };
+
+// from irinternalpskey.h
+const static TUid KPSUidIrdaActivation = { 0x2000276D };
+
+const TInt KTimeDataLength = 7;
+const TInt KMaxBtNameLength = 30;
+const TInt KDateTimeFormatCmdLength = 6;
+
+_LIT( KTempFilePath, "\\" );
+_LIT( KTempFileName, "HtiTempFile.tmp" );
+_LIT( KDateSeparatorChars, ".:/-" );
+_LIT( KTimeSeparatorChars, ".:" );
+
+_LIT8( KErrDescrArgument, "Invalid argument" );
+_LIT8( KErrDescrNotSupported, "Command not supported" );
+_LIT8( KErrDescrHAL, "Error retrieving HAL attribute" );
+_LIT8( KErrDescrAttOutOfRange, "HAL attribute argument is out of range" );
+_LIT8( KErrDescrFreeRAM, "Error retrieving the amount of free RAM" );
+_LIT8( KErrDescrTotalRAM, "Error retrieving the amount of total RAM" );
+_LIT8( KErrDescrAllocRAM, "Error allocating RAM" );
+_LIT8( KErrDescrInvalidRAM, "Requested free RAM larger than currently free" );
+_LIT8( KErrDescrVolInfo, "Error retrieving volume info" );
+_LIT8( KErrDescrNotEnoughSpace, "Not enough disk space" );
+_LIT8( KErrDescrCreateTempFile, "Error creating temp file" );
+_LIT8( KErrDescrSetSizeTempFile, "Error allocating size for temp file" );
+_LIT8( KErrDescrDeleteTempFile, "Error deleting temp file" );
+_LIT8( KErrDescrSysUtil, "SysUtil failed" );
+_LIT8( KErrDescrSetTime, "Setting time failed" );
+_LIT8( KErrDescrDateTimeFormat, "Setting date and time formats failed" );
+_LIT8( KErrDescrScreenSaver, "Setting screen saver state failed" );
+_LIT8( KErrDescrGetNetworkModes, "Getting network modes failed" );
+_LIT8( KErrDescrSetNetworkMode, "Setting network mode failed" );
+_LIT8( KErrDescrIrActivation, "IR activation failed" );
+_LIT8( KErrDescrGetBtPower, "Getting BT power state failed" );
+_LIT8( KErrDescrSetBtPower, "Setting BT power state failed" );
+_LIT8( KErrDescrBtOnDenied, "Turning BT on not allowed (Offline mode)" );
+_LIT8( KErrDescrBtOffDenied, "Turning BT off not allowed (active connections)" );
+_LIT8( KErrDescrBtSettings, "Bluetooth settings failed" );
+_LIT8( KErrDescrBtDeletePairings, "Deleting Bluetooth pairing(s) failed" );
+_LIT8( KErrDescrKeyLock, "Key lock toggle failed" );
+_LIT8( KErrDescrInvalidTime, "Auto key guard time value too large (max 3600)" );
+_LIT8( KErrDescrAutoKeyGuardFailed, "Setting auto key guard time failed" );
+_LIT8( KErrDescrInvalidSSTimeout, "Invalid screen saver timeout value" );
+_LIT8( KErrDescrSSTimeoutFailed, "Setting screen saver timeout failed" );
+_LIT8( KErrDescrDrmDbConnect, "DRM DB connect failed." );
+_LIT8( KErrDescrDrmDbDelete,  "DRM DB delete failed." );
+_LIT8( KErrDescrBatteryLevel, "Getting battery level failed." );
+_LIT8( KErrDescrChargingStatus, "Getting charging status failed." );
+_LIT8( KErrDescrSignalStrength, "Getting signal strength failed." );
+_LIT8( KErrDescrMGUpdate, "Update Media Gallery failed" );
+_LIT8( KErrDescrActivateSkin, "Activating Skin failed" );
+
+enum TSysInfoCommand
+    {
+    ESysInfoHAL =             0x01,
+    ESysInfoIMEI=             0x02,
+    ESysInfoSWVersion =       0x03,
+    ESysInfoLangVersion =     0x04,
+    ESysInfoSWLangVersion =   0x05,
+    ESysInfoUserAgent =       0x06,
+    EFreeRAM =                0x07,
+    EUsedRAM =                0x08,
+    ETotalRAM =               0x09,
+    EEatRAM =                 0x0A,
+    EReleaseRAM =             0x0B,
+    EFreeDiskSpace =          0x0C,
+    EUsedDiskSpace =          0x0D,
+    ETotalDiskSize =          0x0E,
+    EEatDiskSpace =           0x0F,
+    EReleaseDiskSpace =       0x10,
+
+    ESysInfoSetHomeTime =     0x20,
+    ESysInfoGetHomeTime =     0x21,
+    ESetDateTimeFormat =      0x22,
+
+    ELightStatus =            0x30,
+    ELightOn =                0x31,
+    ELightOff =               0x32,
+    ELightBlink =             0x33,
+    ELightRelease =           0x3A,
+
+    EScreenSaverDisable =     0x40,
+    EScreenSaverEnable  =     0x41,
+    EScreenSaverTimeout =     0x42,
+
+    ENetworkModeGet =         0x50,
+    ENetworkModeSet =         0x51,
+    ENetworkModeSetNoReboot = 0x52,
+    EHsdpaSet =               0x53,
+
+    EIrActivate =             0x5A,
+    EBtPower =                0x5B,
+    EBtSettings =             0x5C,
+    EBtDeletePairings =       0x5D,
+
+    EKeylockToggle =          0x60,
+    EAutoKeyGuardTime =       0x61,
+
+    EEmtpyDrmRightsDb =       0x65,
+
+    EBatteryStatus =          0x70,
+    ESignalStrength =         0x71,
+
+    EUpdateMediaGallery =     0x7A,
+
+    EActivateSkin =           0x80
+    };
+
+
+//------------------------------------------------------------------------------
+// Create instance of concrete ECOM interface implementation
+//------------------------------------------------------------------------------
+CHtiSysInfoServicePlugin* CHtiSysInfoServicePlugin::NewL()
+    {
+    CHtiSysInfoServicePlugin* self = new (ELeave) CHtiSysInfoServicePlugin;
+    CleanupStack::PushL (self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+//------------------------------------------------------------------------------
+// Constructor
+//------------------------------------------------------------------------------
+CHtiSysInfoServicePlugin::CHtiSysInfoServicePlugin():
+    iMemEater( NULL ), iReply( NULL ), iAllowSSValue( -1 ),
+    iAllowSSPropertyAttached( EFalse ), iGalleryUpdateSupported( ETrue )
+    {
+    }
+
+//------------------------------------------------------------------------------
+// Destructor
+//------------------------------------------------------------------------------
+CHtiSysInfoServicePlugin::~CHtiSysInfoServicePlugin()
+    {
+    HTI_LOG_TEXT( "CHtiSysInfoServicePlugin destroy" );
+    delete iMemEater;
+    delete iReply;
+
+    CleanUpTempFiles();
+    delete iFileMan;
+    iFs.Close();
+    delete iLightsController;
+
+    if ( iAllowSSSubscriber )
+        {
+        iAllowSSSubscriber->Unsubscribe();
+        }
+    iAllowSSProperty.Close();
+    delete iAllowSSSubscriber;
+    }
+
+//------------------------------------------------------------------------------
+// Second phase construction
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::ConstructL()
+    {
+    HTI_LOG_TEXT( "CHtiSysInfoServicePlugin::ConstructL" );
+    User::LeaveIfError( iFs.Connect() );
+    iFileMan = CFileMan::NewL( iFs );
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::ProcessMessageL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::ProcessMessageL(const TDesC8& aMessage,
+                                THtiMessagePriority /*aPriority*/)
+    {
+    HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::ProcessMessage" );
+    HTI_LOG_FORMAT( "Message length: %d", aMessage.Length() );
+
+    if ( aMessage.Length() > 0 )
+        {
+        HTI_LOG_FORMAT( "Command: %d", aMessage[0] );
+
+        switch ( aMessage[0] )
+            {
+            case ESysInfoHAL:
+                {
+                HTI_LOG_TEXT( "ESysInfoHAL" );
+                HandleGetHalAttrL( aMessage );
+                }
+                break;
+            case ESysInfoIMEI:
+                {
+                HTI_LOG_TEXT( "ESysInfoIMEI" );
+                HandleGetImeiL( aMessage );
+                }
+                break;
+            case ESysInfoSWVersion:
+                {
+                HTI_LOG_TEXT( "ESysInfoSWVersion" );
+                HandleGetSwVersionL( aMessage );
+                }
+                break;
+            case ESysInfoLangVersion:
+                {
+                HTI_LOG_TEXT( "ESysInfoLangVersion" );
+                HandleGetLangVersionL( aMessage );
+                }
+                break;
+            case ESysInfoSWLangVersion:
+                {
+                HTI_LOG_TEXT( "ESysInfoSWLangVersion" );
+                HandleGetSwLangVersionL( aMessage );
+                }
+                break;
+            case ESysInfoUserAgent:
+                {
+                HTI_LOG_TEXT( "ESysInfoUserAgent" );
+                HandleGetUserAgentStringL( aMessage );
+                }
+                break;
+            case EFreeRAM:
+                {
+                HTI_LOG_TEXT( "EFreeRAM" );
+                HandleGetFreeRamL( aMessage );
+                }
+                break;
+            case EUsedRAM:
+                {
+                HTI_LOG_TEXT( "EUsedRAM" );
+                HandleGetUsedRamL( aMessage );
+                }
+                break;
+            case ETotalRAM:
+                {
+                HTI_LOG_TEXT( "ETotalRAM" );
+                HandleGetTotalRamL( aMessage );
+                }
+                break;
+            case EEatRAM:
+                {
+                HTI_LOG_TEXT( "EEatRAM" );
+                HandleEatRamL( aMessage );
+                }
+                break;
+            case EReleaseRAM:
+                {
+                HTI_LOG_TEXT( "EReleaseRAM" );
+                HandleReleaseRamL( aMessage );
+                }
+                break;
+            case EFreeDiskSpace:
+                {
+                HTI_LOG_TEXT( "EFreeDiskSpace" );
+                HandleGetFreeDiskSpaceL( aMessage );
+                }
+                break;
+            case EUsedDiskSpace:
+                {
+                HTI_LOG_TEXT( "EUsedDiskSpace" );
+                HandleGetUsedDiskSpaceL( aMessage );
+                }
+                break;
+            case ETotalDiskSize:
+                {
+                HTI_LOG_TEXT( "ETotalDiskSize" );
+                HandleGetTotalDiskSpaceL( aMessage );
+                }
+                break;
+            case EEatDiskSpace:
+                {
+                HTI_LOG_TEXT( "EEatDiskSpace" );
+                HandleEatDiskSpaceL( aMessage );
+                }
+                break;
+            case EReleaseDiskSpace:
+                {
+                HTI_LOG_TEXT( "EReleaseDiskSpace" );
+                HandleReleaseDiskSpaceL( aMessage );
+                }
+                break;
+            case ESysInfoSetHomeTime:
+                {
+                HTI_LOG_TEXT( "ESysInfoSetHomeTime" );
+                HandleSetHomeTimeL( aMessage );
+                }
+                break;
+            case ESysInfoGetHomeTime:
+                {
+                HTI_LOG_TEXT( "ESysInfoGetHomeTime" );
+                HandleGetHomeTimeL( aMessage );
+                }
+                break;
+            case ESetDateTimeFormat:
+                {
+                HTI_LOG_TEXT( "ESetDateTimeFormat" );
+                HandleSetDateTimeFormatL( aMessage );
+                }
+                break;
+            case ELightStatus:
+            case ELightOn:
+            case ELightOff:
+            case ELightBlink:
+            case ELightRelease:
+                {
+                HTI_LOG_TEXT( "ELight*" );
+                HandleLightsCommandL( aMessage );
+                }
+                break;
+            case EScreenSaverDisable:
+            case EScreenSaverEnable:
+                {
+                HTI_LOG_TEXT( "EScreenSaver*" );
+                HandleScreenSaverCommandL( aMessage );
+                }
+                break;
+            case EScreenSaverTimeout:
+                {
+                HTI_LOG_TEXT( "EScreenSaverTimeout" );
+                HandleScreenSaverTimeoutCommandL( aMessage );
+                }
+                break;
+            case ENetworkModeSet:
+            case ENetworkModeSetNoReboot:
+            case ENetworkModeGet:
+                {
+                HTI_LOG_TEXT( "ENetworkMode*" );
+                HandleNetworkModeCommandL( aMessage );
+                }
+                break;
+            case EHsdpaSet:
+                {
+                HTI_LOG_TEXT( "EHsdpaSet" );
+                HandleHsdpaCommandL( aMessage );
+                }
+                break;
+            case EIrActivate:
+                {
+                HTI_LOG_TEXT( "EIrActivate" );
+                HandleIrActivateCommandL( aMessage );
+                }
+                break;
+            case EBtPower:
+                {
+                HTI_LOG_TEXT( "EBtPower" );
+                HandleBtPowerCommandL( aMessage );
+                }
+                break;
+            case EBtSettings:
+                {
+                HTI_LOG_TEXT( "EBtSettings" );
+                HandleBtSettingsCommandL( aMessage );
+                }
+                break;
+            case EBtDeletePairings:
+                {
+                HTI_LOG_TEXT( "EBtDeletePairings" );
+                HandleBtDeletePairingsL( aMessage );
+                }
+                break;
+            case EKeylockToggle:
+                {
+                HTI_LOG_TEXT( "EKeylockToggle" );
+                HandleKeyLockToggleL( aMessage );
+                }
+                break;
+            case EAutoKeyGuardTime:
+                {
+                HTI_LOG_TEXT( "EAutoKeyGuardTime" );
+                HandleAutoKeyGuardTimeL( aMessage );
+                }
+                break;
+            case EEmtpyDrmRightsDb:
+                {
+                HTI_LOG_TEXT( "EEmtpyDrmRightsDb" );
+                HandleEmptyDrmRightsDbL( aMessage );
+                }
+                break;
+            case EBatteryStatus:
+                {
+                HTI_LOG_TEXT( "EBatteryStatus" );
+                HandleBatteryStatusL( aMessage );
+                }
+                break;
+            case ESignalStrength:
+                {
+                HTI_LOG_TEXT( "ESignalStrength" );
+                HandleSignalStrengthL( aMessage );
+                }
+                break;
+            case EUpdateMediaGallery:
+                {
+                HTI_LOG_TEXT( "EUpdateMediaGallery" );
+                HandleUpdateMediaGalleryL( aMessage );
+                }
+                break;
+            case EActivateSkin:
+                {
+                HTI_LOG_TEXT( "EActivateSkin" );
+                HandleActivateSkinL( aMessage );
+                }
+                break;
+            default:
+                {
+                iDispatcher->DispatchOutgoingErrorMessage(
+                    KErrArgument,
+                    KErrDescrNotSupported,
+                    KSysInfoServiceUid );
+                }
+            }
+        }
+
+    else // aMessage.Length() > 0
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument,
+            KErrDescrArgument,
+            KSysInfoServiceUid);
+        }
+
+    if ( iReply )
+        {
+        TInt err = iDispatcher->DispatchOutgoingMessage( iReply,
+                                                         KSysInfoServiceUid );
+        if ( err == KErrNoMemory )
+            {
+            HTI_LOG_TEXT( "KErrNoMemory" );
+            iDispatcher->AddMemoryObserver( this );
+            }
+        else
+            {
+            iReply = NULL;
+            }
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::ProcessMessage" );
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::NotifyMemoryChange
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::NotifyMemoryChange( TInt aAvailableMemory )
+    {
+
+    if ( iReply )
+        {
+        if ( aAvailableMemory >= iReply->Size() )
+            {
+            TInt err = iDispatcher->DispatchOutgoingMessage(
+                iReply, KSysInfoServiceUid );
+
+            if ( err == KErrNone )
+                {
+                iReply = NULL;
+                iDispatcher->RemoveMemoryObserver( this );
+                }
+            else if ( err != KErrNoMemory ) //some other error
+                {
+                delete iReply;
+                iReply = NULL;
+                iDispatcher->RemoveMemoryObserver( this );
+                }
+            }
+        }
+    else
+        {
+        // some error, should not be called
+        iDispatcher->RemoveMemoryObserver( this );
+        }
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleAllowSSPropertyChange
+//------------------------------------------------------------------------------
+TInt CHtiSysInfoServicePlugin::HandleAllowSSPropertyChange( TAny* aPtr )
+    {
+    HTI_LOG_TEXT( "Allow SS property was changed" );
+    TInt newValue = -1;
+    TInt wantedValue =
+        STATIC_CAST( CHtiSysInfoServicePlugin*, aPtr )->iAllowSSValue;
+    RProperty::Get( KPSUidScreenSaver,
+                    KScreenSaverAllowScreenSaver, newValue );
+    HTI_LOG_FORMAT( "New value is %d", newValue );
+
+    TInt err = KErrNone;
+    if ( newValue == 0 && wantedValue == 1 )
+        {
+        HTI_LOG_TEXT( "Restoring the SS disabled value" );
+        err = RProperty::Set( KPSUidScreenSaver,
+                              KScreenSaverAllowScreenSaver, wantedValue );
+        }
+    return err;
+    }
+
+
+/*
+ * Private helper methods
+ */
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleGetHalAttrL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleGetHalAttrL( const TDesC8& aMessage )
+    {
+    // check the message length
+    if ( aMessage.Length() != 5 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument,
+            KErrDescrArgument,
+            KSysInfoServiceUid );
+        return;
+        }
+
+    TInt att =  aMessage[1] +
+              ( aMessage[2] << 8  ) +
+              ( aMessage[3] << 16 ) +
+              ( aMessage[4] << 24 );
+
+    // check that requested HAL attribute is valid
+    if ( att < 0 || att >= HALData::ENumHalAttributes )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument,
+            KErrDescrAttOutOfRange,
+            KSysInfoServiceUid);
+        return;
+        }
+
+    // get the HAL attribute
+    TInt result;
+    TInt err = HAL::Get( ( HALData::TAttribute ) att, result );
+    if ( err )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            err,
+            KErrDescrHAL,
+            KSysInfoServiceUid );
+        }
+    else
+        {
+        iReply = HBufC8::NewL( 4 );
+        iReply->Des().Append( ( TUint8* )( &result ), 4 );
+        }
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleGetImeiL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleGetImeiL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleGetImeiL" );
+
+    if ( aMessage.Length() != 1 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage( KErrArgument,
+            KErrDescrArgument, KSysInfoServiceUid );
+        return;
+        }
+
+#if !defined (__WINS__) // no IMEI in emulator
+    RTelServer server;
+    User::LeaveIfError( server.Connect() );
+    CleanupClosePushL( server );
+    User::LeaveIfError( server.LoadPhoneModule( KMmTsyModuleName ) );
+
+    RTelServer::TPhoneInfo info;
+    TInt ret = KErrNotSupported;
+    TInt count;
+
+    RMobilePhone mobilePhone;
+
+    User::LeaveIfError( server.EnumeratePhones( count ) );
+
+    for ( TInt i = 0; i < count; i++ )
+        {
+        ret = server.GetPhoneInfo( i, info );
+        if ( ret == KErrNone )
+            {
+            User::LeaveIfError( mobilePhone.Open( server, info.iName ) );
+            CleanupClosePushL( mobilePhone );
+            break;
+            }
+        }
+
+    TRequestStatus status;
+    RMobilePhone::TMobilePhoneIdentityV1 identity;
+
+    mobilePhone.GetPhoneId( status, identity );
+    User::WaitForRequest( status );
+
+    CleanupStack::PopAndDestroy(); // mobilePhone
+
+    server.UnloadPhoneModule( KMmTsyModuleName );
+    CleanupStack::PopAndDestroy(); // server
+
+    iReply = HBufC8::NewL( identity.iSerialNumber.Length() );
+    iReply->Des().Copy( identity.iSerialNumber );
+
+#else // __WINS__
+    // no IMEI in emulator
+    iDispatcher->DispatchOutgoingErrorMessage( KErrNotSupported,
+        KErrDescrNotSupported, KSysInfoServiceUid );
+#endif // __WINS__
+    HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleGetImeiL" );
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleGetSwVersionL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleGetSwVersionL( const TDesC8& aMessage )
+    {
+    if ( aMessage.Length() != 1 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument,
+            KErrDescrArgument,
+            KSysInfoServiceUid);
+        return;
+        }
+
+    TBuf<KSysUtilVersionTextLength> reply16;
+    TInt err = SysUtil::GetSWVersion( reply16 );
+    if ( err )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            err,
+            KErrDescrSysUtil,
+            KSysInfoServiceUid );
+        }
+    else
+        {
+        iReply = HBufC8::NewL( reply16.Size() );
+        iReply->Des().Append( ( TUint8* )reply16.Ptr(), reply16.Size() );
+        }
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleGetLangVersionL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleGetLangVersionL( const TDesC8& aMessage )
+    {
+    if ( aMessage.Length() != 1 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument,
+            KErrDescrArgument,
+            KSysInfoServiceUid );
+        return;
+        }
+
+    TBuf<KSysUtilVersionTextLength> reply16;
+    TInt err = SysUtil::GetLangVersion( reply16 );
+    if ( err )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            err,
+            KErrDescrSysUtil,
+            KSysInfoServiceUid );
+        }
+    else
+        {
+        iReply = HBufC8::NewL( reply16.Size() );
+        iReply->Des().Append( ( TUint8* )reply16.Ptr(), reply16.Size() );
+        }
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleGetSwLangVersionL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleGetSwLangVersionL( const TDesC8& aMessage )
+    {
+    if ( aMessage.Length() != 1 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument,
+            KErrDescrArgument,
+            KSysInfoServiceUid);
+        return;
+        }
+
+    TBuf<KSysUtilVersionTextLength> reply16;
+    TInt err = SysUtil::GetLangSWVersion( reply16 );
+    if ( err )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            err,
+            KErrDescrSysUtil,
+            KSysInfoServiceUid );
+        }
+    else
+        {
+        iReply = HBufC8::NewL( reply16.Size() );
+        iReply->Des().Append( ( TUint8* )reply16.Ptr(), reply16.Size() );
+        }
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleGetUserAgentStringL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleGetUserAgentStringL(
+        const TDesC8& aMessage )
+    {
+    aMessage.Length(); // get rid of compiler warning
+    iDispatcher->DispatchOutgoingErrorMessage(
+        KErrNotSupported,
+        KErrDescrNotSupported,
+        KSysInfoServiceUid);
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleGetFreeRamL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleGetFreeRamL( const TDesC8& aMessage )
+    {
+    if ( aMessage.Length() != 1 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument,
+            KErrDescrArgument,
+            KSysInfoServiceUid );
+        return;
+        }
+
+    User::CompressAllHeaps();
+    TInt result;
+    TInt err = HAL::Get( HALData::EMemoryRAMFree, result );
+    if ( err )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            err,
+            KErrDescrFreeRAM,
+            KSysInfoServiceUid );
+        }
+    else
+        {
+        iReply = HBufC8::NewL( 4 );
+        iReply->Des().Append( ( TUint8* )( &result ), 4 );
+        }
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleGetUsedRamL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleGetUsedRamL( const TDesC8& aMessage )
+    {
+    if ( aMessage.Length() != 1 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument,
+            KErrDescrArgument,
+            KSysInfoServiceUid);
+        return;
+        }
+
+    User::CompressAllHeaps();
+
+    TInt totalRam;
+    TInt freeRam;
+    TInt usedRam;
+
+    // first get the total RAM...
+    TInt err = HAL::Get( HALData::EMemoryRAM, totalRam );
+    if ( err != KErrNone )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            err,
+            KErrDescrTotalRAM,
+            KSysInfoServiceUid );
+        return;
+        }
+
+    // ...then get the free RAM
+    err = HAL::Get( HALData::EMemoryRAMFree, freeRam );
+    if ( err )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            err,
+            KErrDescrFreeRAM,
+            KSysInfoServiceUid );
+        return;
+        }
+
+    // calculate used RAM from total and free RAM
+    usedRam = totalRam - freeRam;
+    iReply = HBufC8::NewL( 4 );
+    iReply->Des().Append( ( TUint8* )( &usedRam ), 4 );
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleGetTotalRamL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleGetTotalRamL( const TDesC8& aMessage )
+    {
+    if ( aMessage.Length() != 1 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument,
+            KErrDescrArgument,
+            KSysInfoServiceUid);
+        return;
+        }
+
+    User::CompressAllHeaps();
+
+    TInt result;
+    TInt err = HAL::Get( HALData::EMemoryRAM, result );
+    if ( err )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            err,
+            KErrDescrTotalRAM,
+            KSysInfoServiceUid );
+        }
+    else
+        {
+        iReply = HBufC8::NewL( 4 );
+        iReply->Des().Append( ( TUint8* )( &result ), 4 );
+        }
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleEatRamL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleEatRamL( const TDesC8& aMessage )
+    {
+    if ( aMessage.Length() != 5 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument,
+            KErrDescrArgument,
+            KSysInfoServiceUid );
+        return;
+        }
+
+    // get the amount of memory to be left free from the message
+    TInt memLeftFree =  aMessage[1] +
+                      ( aMessage[2] << 8  ) +
+                      ( aMessage[3] << 16 ) +
+                      ( aMessage[4] << 24 );
+
+    // if there's a previous memory eater, delete it
+    if ( iMemEater != NULL )
+        {
+        delete iMemEater;
+        iMemEater = NULL;
+        }
+
+    User::CompressAllHeaps();
+
+    // get the current free memory
+    TInt memFree;
+    TInt err = HAL::Get( HALData::EMemoryRAMFree, memFree );
+    if ( err )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            err,
+            KErrDescrFreeRAM,
+            KSysInfoServiceUid );
+        return;
+        }
+
+    // try to eat the memory
+    TInt memToBeEaten = memFree - memLeftFree;
+
+    if ( memToBeEaten < 0 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+                KErrUnderflow,
+                KErrDescrInvalidRAM,
+                KSysInfoServiceUid );
+        return;
+        }
+
+    TRAP( err, iMemEater = HBufC8::NewL( memToBeEaten ) );
+    if ( err )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            err,
+            KErrDescrAllocRAM,
+            KSysInfoServiceUid );
+        return;
+        }
+
+    // get the amount of memory left
+    err = HAL::Get( HALData::EMemoryRAMFree, memFree );
+    if ( err )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            err,
+            KErrDescrFreeRAM,
+            KSysInfoServiceUid );
+        return;
+        }
+
+    // send the amount of memory back
+    iReply = HBufC8::NewL( 4 );
+    iReply->Des().Append( ( TUint8* )( &memFree ), 4 );
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleReleaseRamL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleReleaseRamL( const TDesC8& aMessage )
+    {
+    if ( aMessage.Length() != 1 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument,
+            KErrDescrArgument,
+            KSysInfoServiceUid );
+        return;
+        }
+
+    // if there's a memory eater, delete it
+    if ( iMemEater != NULL )
+        {
+        delete iMemEater;
+        iMemEater = NULL;
+        }
+
+    User::CompressAllHeaps();
+
+    // query the amount of memory and send it back
+    TInt memFree;
+    TInt err = HAL::Get( HALData::EMemoryRAMFree, memFree );
+    if ( err )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            err,
+            KErrDescrHAL,
+            KSysInfoServiceUid );
+        }
+    else
+        {
+        iReply = HBufC8::NewL( 4 );
+        iReply->Des().Append( ( TUint8* )( &memFree ), 4 );
+        }
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleGetFreeDiskSpaceL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleGetFreeDiskSpaceL( const TDesC8& aMessage )
+    {
+    if ( aMessage.Length() != 2 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument,
+            KErrDescrArgument,
+            KSysInfoServiceUid);
+        return;
+        }
+
+    TInt drive;
+    RFs::CharToDrive( TChar( aMessage[1] ), drive );
+    TVolumeInfo volInfo;
+    TInt err = iFs.Volume( volInfo, drive );
+
+    if ( err )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            err,
+            KErrDescrVolInfo,
+            KSysInfoServiceUid );
+        }
+    else
+        {
+        iReply = HBufC8::NewL( 8 );
+        iReply->Des().Append( ( TUint8* )( &volInfo.iFree ), 8 );
+        }
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleGetUsedDiskSpaceL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleGetUsedDiskSpaceL( const TDesC8& aMessage )
+    {
+    if ( aMessage.Length() != 2 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument,
+            KErrDescrArgument,
+            KSysInfoServiceUid);
+        return;
+        }
+
+    TInt drive;
+    RFs::CharToDrive( TChar( aMessage[1] ), drive );
+    TVolumeInfo volInfo;
+    TInt err = iFs.Volume( volInfo, drive );
+
+    if ( err )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            err,
+            KErrDescrVolInfo,
+            KSysInfoServiceUid );
+        }
+    else
+        {
+        TInt64 used = volInfo.iSize - volInfo.iFree;
+        iReply = HBufC8::NewL( 8 );
+        iReply->Des().Append( ( TUint8* )( &used ), 8 );
+        }
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleGetTotalDiskSpaceL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleGetTotalDiskSpaceL(
+        const TDesC8& aMessage )
+    {
+    if ( aMessage.Length() != 2 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument,
+            KErrDescrArgument,
+            KSysInfoServiceUid);
+        return;
+        }
+
+    TInt drive;
+    RFs::CharToDrive( TChar( aMessage[1] ), drive );
+    TVolumeInfo volInfo;
+    TInt err = iFs.Volume( volInfo, drive );
+
+    if ( err )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            err,
+            KErrDescrVolInfo,
+            KSysInfoServiceUid );
+        }
+    else
+        {
+        iReply = HBufC8::NewL( 8 );
+        iReply->Des().Append( ( TUint8* )( &volInfo.iSize ), 8 );
+        }
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleEatDiskSpaceL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleEatDiskSpaceL( const TDesC8& aMessage )
+    {
+    if ( aMessage.Length() != 10 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument,
+            KErrDescrArgument,
+            KSysInfoServiceUid );
+        return;
+        }
+
+
+    TFileName path;
+    path.Append( aMessage[1] );
+    path.Append( _L( ":" ) );
+    path.Append( KTempFilePath );
+    path.Append( KTempFileName );
+
+    HTI_LOG_TEXT( "Temp file path:" );
+    HTI_LOG_DES( path );
+
+    // check if previous temp file exists and delete it
+    if ( BaflUtils::FileExists( iFs, path ) )
+        {
+        TInt err = iFileMan->Delete( path );
+        if ( err )
+            {
+            iDispatcher->DispatchOutgoingErrorMessage(
+                err,
+                KErrDescrDeleteTempFile,
+                KSysInfoServiceUid );
+            return;
+            }
+        }
+
+    // get free disk space
+    TInt drive;
+    RFs::CharToDrive( TChar( aMessage[1] ), drive );
+    TVolumeInfo volInfo;
+    TInt err = iFs.Volume( volInfo, drive );
+    if ( err )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            err,
+            KErrDescrVolInfo,
+            KSysInfoServiceUid );
+        return;
+        }
+
+    // calculate how much we must eat the disk space
+    TInt64 temp1 = aMessage[2] +
+                 ( aMessage[3] << 8  ) +
+                 ( aMessage[4] << 16 ) +
+                 ( aMessage[5] << 24 );
+    TInt64 temp2 = aMessage[6] +
+                 ( aMessage[7] << 8  ) +
+                 ( aMessage[8] << 16 ) +
+                 ( aMessage[9] << 24 );
+
+    TInt64 spaceLeftFree = temp1 + ( temp2 << 32) ;
+    TInt64 spaceToEat = volInfo.iFree - spaceLeftFree;
+
+    HTI_LOG_FORMAT( "Disk space to eat: %Ld", spaceToEat );
+
+    // check that there is enough free disk space
+    if ( spaceToEat < 0 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrDiskFull,
+            KErrDescrNotEnoughSpace,
+            KSysInfoServiceUid );
+        return;
+        }
+
+    // check if scaceToEat is greater than KMaxTInt
+    //  --> it must be eaten in several chunks
+    //  --> not yet supported.
+    if ( spaceToEat > KMaxTInt )
+        {
+        HTI_LOG_TEXT( "Cannot allocate a file bigger than KMaxTInt" );
+
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrOverflow,
+            KErrDescrSetSizeTempFile,
+            KSysInfoServiceUid );
+        return;
+        }
+
+    // create a temp file
+    RFile diskEater;
+    err = diskEater.Replace( iFs, path, EFileWrite );
+    if ( err )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            err,
+            KErrDescrCreateTempFile,
+            KSysInfoServiceUid );
+        return;
+        }
+
+    // set the size for temp file
+    err = diskEater.SetSize( I64LOW( spaceToEat ) );
+    if ( err )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            err,
+            KErrDescrSetSizeTempFile,
+            KSysInfoServiceUid );
+        diskEater.Close();
+        return;
+        }
+    diskEater.Close();
+
+    err = iFs.Volume( volInfo, drive );
+    if ( err )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            err,
+            KErrDescrVolInfo,
+            KSysInfoServiceUid );
+        return;
+        }
+
+    // all ok, send the remaining disk size back
+    iReply = HBufC8::NewL( 8 );
+    iReply->Des().Append( ( TUint8* )( &volInfo.iFree ), 8 );
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleReleaseDiskSpaceL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleReleaseDiskSpaceL( const TDesC8& aMessage )
+    {
+    if ( aMessage.Length() != 2 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument,
+            KErrDescrArgument,
+            KSysInfoServiceUid);
+        return;
+        }
+
+    TFileName path;
+    path.Append( aMessage[1] );
+    path.Append( _L( ":" ) );
+    path.Append( KTempFilePath );
+    path.Append( KTempFileName );
+
+    HTI_LOG_TEXT( "Temp file path:" );
+    HTI_LOG_DES( path );
+
+    TInt err = KErrNone;
+    // check that temp file exists
+    if ( BaflUtils::FileExists( iFs, path ) )
+        {
+        // try to delete the temp file
+        err = iFileMan->Delete( path );
+        if ( err )
+            {
+            iDispatcher->DispatchOutgoingErrorMessage(
+                err,
+                KErrDescrDeleteTempFile,
+                KSysInfoServiceUid );
+
+            return;
+            }
+        }
+
+    // query the free disk space
+    TInt drive;
+    RFs::CharToDrive( TChar( aMessage[1] ), drive );
+    TVolumeInfo volInfo;
+    err = iFs.Volume( volInfo, drive );
+    if ( err )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            err,
+            KErrDescrVolInfo,
+            KSysInfoServiceUid );
+
+        return;
+        }
+
+    // all ok, send the free disk space back
+    iReply = HBufC8::NewL( 8 );
+    iReply->Des().Append( ( TUint8* )( &volInfo.iFree ), 8 );
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleSetHomeTimeL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleSetHomeTimeL( const TDesC8& aMessage )
+    {
+    TTime time;
+    TRAPD( err, ParseTimeDataL( aMessage.Mid( 1 ), time ) );
+    if ( err )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage( err,
+                               KErrDescrArgument,
+                               KSysInfoServiceUid);
+        return;
+        }
+
+    // User::SetHomeTime() does not work correctly with daylight saving time
+    // in S60 3.0 - have to use time zone server instead.
+    RTz tzServer;
+    err = tzServer.Connect();
+    if ( err == KErrNone )
+        {
+        err = tzServer.SetHomeTime( time );
+        }
+    tzServer.Close();
+
+    if ( err )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage( err,
+                               KErrDescrSetTime,
+                               KSysInfoServiceUid);
+        return;
+        }
+
+    iReply = HBufC8::NewL( 1 );
+    iReply->Des().Append( 0 );
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleGetHomeTimeL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleGetHomeTimeL( const TDesC8& aMessage )
+    {
+    if ( aMessage.Length() != 1 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument,
+            KErrDescrArgument,
+            KSysInfoServiceUid );
+
+        return;
+        }
+
+    TTime time;
+    time.HomeTime();
+    TDateTime dateTime = time.DateTime();
+    TUint year = dateTime.Year();
+    iReply = HBufC8::NewL( KTimeDataLength );
+    iReply->Des().Append( (TUint8*)(&year), 2 );
+    iReply->Des().Append( dateTime.Month() + 1 );
+    iReply->Des().Append( dateTime.Day() + 1 );
+    iReply->Des().Append( dateTime.Hour() );
+    iReply->Des().Append( dateTime.Minute() );
+    iReply->Des().Append( dateTime.Second() );
+    }
+
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleSetDateTimeFormatL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleSetDateTimeFormatL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleSetDateTimeFormatL" );
+
+    if ( aMessage.Length() != KDateTimeFormatCmdLength )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage( KErrArgument,
+            KErrDescrArgument, KSysInfoServiceUid );
+        return;
+        }
+
+    // Parse values from message
+    TDateFormat dateFormat = STATIC_CAST( TDateFormat, aMessage[1] );
+    TChar dateSepar = aMessage[2];
+    TTimeFormat timeFormat = STATIC_CAST( TTimeFormat, aMessage[3] );
+    TChar timeSepar = aMessage[4];
+    TClockFormat clockFormat = STATIC_CAST( TClockFormat, aMessage[5] );
+
+    HTI_LOG_FORMAT( "Date format   : %d", dateFormat );
+    HTI_LOG_FORMAT( "Date separator: %c", aMessage[2] );
+    HTI_LOG_FORMAT( "Time format   : %d", timeFormat );
+    HTI_LOG_FORMAT( "Time separator: %c", aMessage[4] );
+    HTI_LOG_FORMAT( "Clock format  : %d", clockFormat );
+
+    // Check validity of values
+    if ( dateFormat < EDateAmerican || dateFormat > EDateJapanese ||
+         timeFormat < ETime12 || timeFormat > ETime24 ||
+         clockFormat < EClockAnalog || clockFormat > EClockDigital ||
+         KDateSeparatorChars().Locate( dateSepar ) == KErrNotFound ||
+         KTimeSeparatorChars().Locate( timeSepar ) == KErrNotFound )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage( KErrArgument,
+            KErrDescrArgument, KSysInfoServiceUid );
+        return;
+        }
+
+    // Set the values
+    TLocale locale;
+    locale.SetDateFormat( dateFormat );
+    locale.SetDateSeparator( dateSepar, 1 );
+    locale.SetDateSeparator( dateSepar, 2 );
+    locale.SetTimeFormat( timeFormat );
+    locale.SetTimeSeparator( timeSepar, 1 );
+    locale.SetTimeSeparator( timeSepar, 2 );
+    locale.SetClockFormat( clockFormat );
+    TInt err = locale.Set();
+
+    if ( err != KErrNone )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage( err,
+            KErrDescrDateTimeFormat, KSysInfoServiceUid );
+        }
+    else
+        {
+        iReply = HBufC8::NewL( 1 );
+        iReply->Des().Append( 0 );
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleSetDateTimeFormatL" );
+    }
+
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleLightsCommandL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleLightsCommandL( const TDesC8& aMessage )
+    {
+    if ( aMessage[0] == ELightRelease )
+        {
+        if ( aMessage.Length() != 1 )
+            {
+            iDispatcher->DispatchOutgoingErrorMessage(
+                KErrArgument,
+                KErrDescrArgument,
+                KSysInfoServiceUid);
+            }
+
+        else
+            {
+            HTI_LOG_TEXT( "ELightRelease" );
+            delete iLightsController;
+            iLightsController = NULL;
+            iReply = HBufC8::NewL( 1 );
+            iReply->Des().Append( 0 );
+            }
+        }
+
+    else
+        {
+        if ( !iLightsController )
+            {
+            HTI_LOG_TEXT( "Creating lights controller" );
+            iLightsController = CHtiLightsController::NewL(
+                                    iDispatcher );
+            }
+        TBuf8<4> reply;
+        iLightsController->ProcessMessageL( aMessage, reply );
+        if ( reply.Length() > 0 )
+            {
+            iReply = HBufC8::NewL( reply.Length() );
+            iReply->Des().Copy( reply );
+            }
+        }
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleScreenSaverCommandL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleScreenSaverCommandL(
+                                    const TDesC8& aMessage )
+    {
+    if ( aMessage.Length() != 1 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument,
+            KErrDescrArgument,
+            KSysInfoServiceUid);
+        return;
+        }
+
+    if ( aMessage[0] == EScreenSaverDisable ) iAllowSSValue = 1;
+    else if ( aMessage[0] == EScreenSaverEnable ) iAllowSSValue = 0;
+    else User::Leave( KErrArgument );
+
+    HTI_LOG_FORMAT( "Setting allow screen saver state %d", iAllowSSValue );
+
+    TInt err = KErrNone;
+
+    if ( !iAllowSSPropertyAttached )
+        {
+        HTI_LOG_TEXT( "Attaching to KScreenSaverAllowScreenSaver property" );
+        err = iAllowSSProperty.Attach(
+                KPSUidScreenSaver, KScreenSaverAllowScreenSaver );
+
+        if ( err )
+            {
+            iDispatcher->DispatchOutgoingErrorMessage(
+                err, KErrDescrScreenSaver, KSysInfoServiceUid );
+            return;
+            }
+
+        iAllowSSPropertyAttached = ETrue;
+        }
+
+    if ( iAllowSSValue == 1 )
+        {
+        iAllowSSProperty.Set( iAllowSSValue ); // ignore error
+        // Screen saver disabled. We want to keep it disabled, so
+        // subscribe to the property to get notified about changes in it.
+        if ( !iAllowSSSubscriber )
+            {
+            iAllowSSSubscriber = new (ELeave) CHtiPropertySubscriber(
+                TCallBack( HandleAllowSSPropertyChange, this ),
+                iAllowSSProperty );
+            iAllowSSSubscriber->Subscribe();
+            }
+        }
+
+    else  // iAllowSSValue == 0
+        {
+        // Enabling screen saver. Cancel possible subscription so
+        // other applications can control the property.
+        if ( iAllowSSSubscriber )
+            {
+            iAllowSSSubscriber->Unsubscribe();
+            }
+        iAllowSSProperty.Set( iAllowSSValue ); // ignore error
+        iAllowSSProperty.Close();
+        iAllowSSPropertyAttached = EFalse;
+        delete iAllowSSSubscriber;
+        iAllowSSSubscriber = NULL;
+        }
+
+    iReply = HBufC8::NewL( 1 );
+    iReply->Des().Append( 0 );
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleScreenSaverTimeoutCommandL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleScreenSaverTimeoutCommandL(
+                                    const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN(
+            "CHtiSysInfoServicePlugin::HandleScreenSaverTimeoutCommandL" );
+    if ( aMessage.Length() != 2 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument,
+            KErrDescrArgument,
+            KSysInfoServiceUid);
+        return;
+        }
+
+    TInt time = aMessage[1];
+    HTI_LOG_FORMAT( "Requested timeout %d", time );
+    if ( time < 5 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage( KErrArgument,
+            KErrDescrInvalidSSTimeout, KSysInfoServiceUid );
+        return;
+        }
+
+    CRepository* persRep = CRepository::NewL( KCRUidPersonalizationSettings );
+    TInt err = persRep->Set( KSettingsScreenSaverPeriod, time );
+
+    if ( err == KErrNone )
+        {
+        iReply = HBufC8::NewL( 1 );
+        iReply->Des().Append( 0 );
+        }
+
+    else
+        {
+        iDispatcher->DispatchOutgoingErrorMessage( err,
+            KErrDescrSSTimeoutFailed, KSysInfoServiceUid );
+        }
+
+    delete persRep;
+    HTI_LOG_FUNC_OUT(
+        "CHtiSysInfoServicePlugin::HandleScreenSaverTimeoutCommandL" );
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleNetworkModeCommandL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleNetworkModeCommandL( const TDesC8& aMessage )
+{
+    HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleNetworkModeCommandL" );
+
+    TInt err = StartC32();
+    if ( ( err != KErrNone ) && ( err != KErrAlreadyExists ) )
+        {
+        HTI_LOG_FORMAT( "StartC32 failed %d", err );
+        User::Leave( err );
+        }
+
+    // Connect to telephony server
+    RTelServer telServer;
+    err = telServer.Connect();
+    if ( err != KErrNone )
+        {
+        HTI_LOG_FORMAT( "RTelServer::Connect() failed %d", err );
+        User::Leave( err );
+        }
+    CleanupClosePushL( telServer );
+
+    // load phonetsy
+    err = telServer.LoadPhoneModule( KMmTsyModuleName );
+    if ( err != KErrNone )
+        {
+        HTI_LOG_FORMAT( "RTelServer::LoadPhoneModule() failed %d", err );
+        User::Leave( err );
+        }
+
+    // get phones
+    TInt noOfPhones;
+    err = telServer.EnumeratePhones( noOfPhones );
+    if ( err != KErrNone )
+        {
+        HTI_LOG_FORMAT( "RTelServer::EnumeratePhones() failed %d", err );
+        User::Leave( err );
+        }
+
+    if ( noOfPhones == 0 )
+        {
+        HTI_LOG_TEXT( "No phones found" );
+        User::Leave( KErrNotFound );
+        }
+
+    HTI_LOG_FORMAT( "noOfPhones %d", noOfPhones );
+
+    RTelServer::TPhoneInfo phoneInfo;
+    for ( TInt i = 0; i < noOfPhones; i++ )
+        {
+        TName phoneTsy;
+        telServer.GetTsyName( i, phoneTsy );
+        HTI_LOG_DES( phoneTsy );
+
+        err = telServer.GetPhoneInfo( i, phoneInfo );
+        if ( err != KErrNone )
+            {
+            HTI_LOG_FORMAT( "RTelServer::GetPhoneInfo() %d", i );
+            HTI_LOG_FORMAT( "failed %d", err );
+            User::Leave( err );
+            }
+        HTI_LOG_DES( phoneInfo.iName );
+        }
+
+    // open phone
+    RMobilePhone phone;
+    err = phone.Open( telServer, phoneInfo.iName );
+    if ( err != KErrNone )
+        {
+        HTI_LOG_FORMAT( "RMobilePhone::Open() failed %d", err );
+        User::Leave( err );
+        }
+    CleanupClosePushL( phone );
+
+    err = phone.Initialise();
+    if ( err != KErrNone )
+        {
+        HTI_LOG_FORMAT( "RMobilePhone::Initialise() failed %d", err );
+        User::Leave( err );
+        }
+
+    // Open customapi
+    RMmCustomAPI customAPI;
+    err = customAPI.Open( phone );
+    if ( err != KErrNone )
+        {
+        HTI_LOG_FORMAT( "RMmCustomAPI::Open() %d", err );
+        User::LeaveIfError( err );
+        }
+    CleanupClosePushL( customAPI );
+
+    switch ( aMessage[0] )
+    {
+    case ENetworkModeGet:
+        {
+        HTI_LOG_TEXT( "ENetworkModeGet" );
+        TUint32 networkModes = 0;
+        err = customAPI.GetCurrentSystemNetworkModes( networkModes );
+        if ( err )
+            {
+            HTI_LOG_FORMAT(
+                    "RMmCustomAPI::GetCurrentSystemNetworkModes() failed %d",
+                    err );
+            User::LeaveIfError(
+                iDispatcher->DispatchOutgoingErrorMessage(
+                        err,
+                        KErrDescrGetNetworkModes,
+                        KSysInfoServiceUid ) );
+            }
+        else
+            {
+            HTI_LOG_FORMAT( "networkModes 0x%x", networkModes );
+            TBuf8<5> okMsg;
+            okMsg.Append( ENetworkModeGet );
+            okMsg.Append( (TUint8*) &networkModes, 4 );
+            iReply = okMsg.AllocL();
+            }
+        }
+        break;
+
+    case ENetworkModeSet:
+        HTI_LOG_TEXT( "ENetworkModeSet" );
+        if ( aMessage.Length() != 5 )
+            {
+            HTI_LOG_TEXT( "KErrArgument" );
+            User::LeaveIfError(
+                iDispatcher->DispatchOutgoingErrorMessage(
+                        KErrArgument,
+                        KErrDescrArgument,
+                        KSysInfoServiceUid ) );
+            }
+        else
+            {
+            TUint32 mode = aMessage[1] + ( aMessage[2] << 8 ) +
+                           ( aMessage[3] << 16 ) + ( aMessage[4] << 24 );
+
+            HTI_LOG_FORMAT( "SetSystemNetworkMode 0x%x", mode );
+            err = customAPI.SetSystemNetworkMode(
+                    ( RMmCustomAPI::TNetworkModeCaps ) mode );
+            if ( err )
+                {
+                HTI_LOG_FORMAT(
+                        "RMmCustomAPI::SetSystemNetworkMode() failed %d", err );
+                iDispatcher->DispatchOutgoingErrorMessage(
+                    err,
+                    KErrDescrSetNetworkMode,
+                    KSysInfoServiceUid );
+                }
+            else
+                {
+                iDispatcher->ShutdownAndRebootDeviceL();
+                }
+            }
+        break;
+
+    case ENetworkModeSetNoReboot:
+        {
+        HTI_LOG_TEXT( "ENetworkModeSetNoReboot" );
+        if ( aMessage.Length() != 5 )
+            {
+            HTI_LOG_TEXT( "KErrArgument" );
+            User::LeaveIfError(
+                iDispatcher->DispatchOutgoingErrorMessage(
+                        KErrArgument,
+                        KErrDescrArgument,
+                        KSysInfoServiceUid ) );
+            }
+        else
+            {
+            TUint32 mode = aMessage[1] + ( aMessage[2] << 8 ) +
+                           ( aMessage[3] << 16 ) + ( aMessage[4] << 24 );
+
+            HTI_LOG_FORMAT( "SetSystemNetworkMode 0x%x", mode );
+            err = customAPI.SetSystemNetworkMode(
+                    ( RMmCustomAPI::TNetworkModeCaps ) mode );
+            if ( err )
+                {
+                HTI_LOG_FORMAT(
+                        "RMmCustomAPI::SetSystemNetworkMode() failed %d", err );
+                iDispatcher->DispatchOutgoingErrorMessage(
+                    err,
+                    KErrDescrSetNetworkMode,
+                    KSysInfoServiceUid );
+                }
+            else
+                {
+                iReply = HBufC8::NewL( 1 );
+                iReply->Des().Append( 0 );
+                }
+            }
+        break;
+        }
+
+    default:
+        break;
+    }
+
+    CleanupStack::PopAndDestroy( 3 ); // telServer, phone, customAPI
+    HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleNetworkModeCommandL" );
+}
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleIrActivateCommandL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleIrActivateCommandL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleIrActivateCommandL" );
+
+    // Message validation
+    if ( aMessage.Length() != 1 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument,
+            KErrDescrArgument,
+            KSysInfoServiceUid );
+        return;
+        }
+
+    TInt irStatus = -1;
+    TInt err = RProperty::Get( KIrdaPropertyCategory, KIrdaStatus, irStatus );
+    if ( err != KErrNone || irStatus < TIrdaStatusCodes::EIrLoaded
+                         || irStatus > TIrdaStatusCodes::EIrDisconnected )
+        {
+        // values from irinternalpskey.h
+        err = RProperty::Set( KPSUidIrdaActivation, 1, 1 );
+        if ( err != KErrNone )
+            {
+            iDispatcher->DispatchOutgoingErrorMessage(
+                err, KErrDescrIrActivation, KSysInfoServiceUid );
+            }
+        else
+            {
+            // Activation OK
+            iReply = HBufC8::NewL( 1 );
+            iReply->Des().Append( 0 );
+            }
+        }
+    else
+        {
+        // Already active - just send a message
+        iReply = HBufC8::NewL( 1 );
+        iReply->Des().Append( 1 );
+        }
+
+     HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleIrActivateCommandL" );
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleBtPowerCommandL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleBtPowerCommandL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleBtPowerCommandL" );
+
+    // Message validation
+    if ( aMessage.Length() != 3 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument,
+            KErrDescrArgument,
+            KSysInfoServiceUid );
+        return;
+        }
+
+    TInt err = KErrNone;
+    TBool setBtOn = aMessage[1];
+    TBool useForce = aMessage[2];
+    TBool isBtOn = EFalse;
+
+    TBTPowerStateValue powerState = EBTPowerOff;
+    CBTEngSettings* btSettings = CBTEngSettings::NewLC();
+    err = btSettings->GetPowerState( powerState );
+    if ( err == KErrNone && powerState == EBTPowerOn )
+        {
+        isBtOn = ETrue;
+        }
+
+    if ( err )
+        {
+        HTI_LOG_FORMAT( "GetPowerState error %d", err );
+        CleanupStack::PopAndDestroy(); // btSettings
+        iDispatcher->DispatchOutgoingErrorMessage( err, KErrDescrGetBtPower,
+                                                   KSysInfoServiceUid );
+        return;
+        }
+    HTI_LOG_FORMAT( "Current BT power state %d", isBtOn );
+    HTI_LOG_FORMAT( "Requested BT power state %d", setBtOn );
+
+    if ( setBtOn == isBtOn )
+        {
+        // Already in requested state - just send message
+        CleanupStack::PopAndDestroy(); // btSettings
+        iReply = HBufC8::NewL( 1 );
+        iReply->Des().Append( 1 );
+        }
+
+    else
+        {
+        if ( setBtOn && !CanTurnBluetoothOnL( useForce ) )
+            {
+            iDispatcher->DispatchOutgoingErrorMessage( KErrAccessDenied,
+                KErrDescrBtOnDenied, KSysInfoServiceUid );
+            return;
+            }
+
+
+        if ( !setBtOn )
+            {
+            // If we are setting BT off, do checks for active connections.
+            TInt connCount = 0;
+            // Ignore error.
+            // If we cannot query, we act like there's no active connections.
+            RProperty::Get( KPropertyUidBluetoothCategory,
+                            KPropertyKeyBluetoothGetPHYCount,
+                            connCount );
+            // Check if there's Bluetooth audio accessory connected
+            TBool isBtAacConnected = EFalse;
+
+            // If there are connections, force flag is required in the
+            // command to turn BT off.
+            if ( ( connCount || isBtAacConnected ) && !useForce )
+                {
+                iDispatcher->DispatchOutgoingErrorMessage( KErrInUse,
+                    KErrDescrBtOffDenied, KSysInfoServiceUid );
+                CleanupStack::PopAndDestroy(); // btMcm/btSettings
+                return;
+                }
+            }
+
+        if ( setBtOn )
+            {
+            err = btSettings->SetPowerState( EBTPowerOn );
+            }
+        else
+            {
+            err = btSettings->SetPowerState( EBTPowerOff );
+            }
+
+        if ( err != KErrNone )
+            {
+            HTI_LOG_FORMAT( "CBTMCMSettings::SetPowerState error %d", err );
+            iDispatcher->DispatchOutgoingErrorMessage( err, KErrDescrSetBtPower,
+                                                       KSysInfoServiceUid );
+            }
+        else
+            {
+            iReply = HBufC8::NewL( 1 );
+            iReply->Des().Append( 0 );
+            }
+        CleanupStack::PopAndDestroy(); // btSettings
+        }
+    HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleBtPowerCommandL" );
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleBtSettingsCommandL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleBtSettingsCommandL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleBtSettingsCommandL" );
+
+    // Message validation
+    if ( aMessage.Length() < 4 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument,
+            KErrDescrArgument,
+            KSysInfoServiceUid );
+        return;
+    }
+    TInt btNameLength = aMessage[3];
+    if ( btNameLength > KMaxBtNameLength ||
+         aMessage.Length() != ( btNameLength + 4 ) )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument,
+            KErrDescrArgument,
+            KSysInfoServiceUid );
+        return;
+        }
+
+    TBTVisibilityMode visibilityMode = EBTVisibilityModeGeneral;
+    if ( aMessage[1] == 0 )
+        {
+        visibilityMode = EBTVisibilityModeHidden;
+        }
+    HTI_LOG_FORMAT( "Visibility mode = %d", visibilityMode );
+
+    TInt sapMode = 1;  // EBTSapEnabled
+    if ( aMessage[2] == 0 )
+        {
+        sapMode = 0;   // EBTSapDisabled
+        }
+    HTI_LOG_FORMAT( "SAP mode = %d", sapMode );
+
+    TBuf<KMaxBtNameLength> btName;
+    if ( btNameLength > 0 )
+        {
+        btName.Copy( aMessage.Mid( 4, btNameLength ) );
+        }
+    HTI_LOG_FORMAT( "BT name = %S", &btName );
+
+    TInt err = KErrNone;
+    CBTEngSettings* btSettings = CBTEngSettings::NewLC();
+    HTI_LOG_TEXT( "CBTEngSettings::NewLC done" );
+
+    HTI_LOG_TEXT( "Setting visibility mode" );
+    err = btSettings->SetVisibilityMode( visibilityMode );
+    if ( err == KErrNone )
+        {
+        HTI_LOG_TEXT( "Setting SAP mode" );
+        // CenRep UID and key value from btengprivatecrkeys.h
+        // const TUid KCRUidBTEngPrivateSettings = { 0x10204DAC }
+        // const TUint32 KBTSapEnabled  = 0x00000003
+        CRepository* btEngRep = CRepository::NewL( TUid::Uid( 0x10204DAC ) );
+        err = btEngRep->Set( 0x00000003, sapMode );
+        delete btEngRep;
+        btEngRep = NULL;
+        }
+    if ( err == KErrNone && btName.Length() > 0 )
+        {
+        HTI_LOG_TEXT( "Setting BT name" );
+        err = btSettings->SetLocalName( btName );
+        }
+
+    if ( err == KErrNone )
+        {
+        HTI_LOG_TEXT( "All set successfully" );
+        iReply = HBufC8::NewL( 1 );
+        iReply->Des().Append( 0 );
+        }
+    else
+        {
+        HTI_LOG_FORMAT( "Error %d", err );
+        iDispatcher->DispatchOutgoingErrorMessage(
+            err,
+            KErrDescrBtSettings,
+            KSysInfoServiceUid );
+        }
+
+    CleanupStack::PopAndDestroy(); // btSettings
+    HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleBtSettingsCommandL" );
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleBtDeletePairingsL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleBtDeletePairingsL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleBtDeletePairingsL" );
+
+    // Message validation
+    if ( aMessage.Length() < 3 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument,
+            KErrDescrArgument,
+            KSysInfoServiceUid );
+        return;
+        }
+
+    TInt btNameLength = aMessage[2];
+    if ( btNameLength > KMaxBluetoothNameLen ||
+         aMessage.Length() != ( btNameLength + 3 ) )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage(
+            KErrArgument,
+            KErrDescrArgument,
+            KSysInfoServiceUid );
+        return;
+        }
+
+    // Message parsing
+    TBool closeConnections = aMessage[1];
+    HTI_LOG_FORMAT( "Close connections = %d", closeConnections );
+    TBTDeviceName8 btName8;
+    if ( btNameLength > 0 )
+        {
+        btName8.Copy( aMessage.Mid( 3, btNameLength ) );
+        }
+    HTI_LOG_FORMAT( "BT name = %S",
+        &( BTDeviceNameConverter::ToUnicodeL( btName8 ) ) );
+
+    // Action
+    TInt deleteCount = 0;
+    TInt err = KErrNone;
+    RBTRegServ regServ;
+    RBTRegistry registry;
+    User::LeaveIfError( regServ.Connect() );
+    CleanupClosePushL( regServ );
+    User::LeaveIfError( registry.Open( regServ ) );
+    CleanupClosePushL( registry );
+    TBTRegistrySearch searchPattern;
+    searchPattern.FindBonded();
+
+    TRequestStatus status;
+    registry.CreateView( searchPattern, status );
+    User::WaitForRequest( status );
+    err = status.Int();
+    HTI_LOG_FORMAT( "RBTRegistry::CreateView returned %d", err );
+
+    if ( err > 0 )
+        {
+        CBTRegistryResponse* response = CBTRegistryResponse::NewL( registry );
+        CleanupStack::PushL( response );
+        HTI_LOG_TEXT( "Creating AsyncWaiter" );
+        CAsyncWaiter* waiter = CAsyncWaiter::NewLC();
+        HTI_LOG_TEXT( "Calling response->Start()" );
+        response->Start( waiter->iStatus );
+        HTI_LOG_TEXT( "Calling waiter->StartAndWait()" );
+        waiter->StartAndWait();
+        err = waiter->Result();
+        CleanupStack::PopAndDestroy( waiter );
+
+        if ( err == KErrNone )
+            {
+            RBTDeviceArray results = response->Results();
+            TInt count = results.Count();
+            for ( TInt i = 0; i < count; i++ )
+                {
+                HTI_LOG_FORMAT( "Device %d", i + 1 );
+                CBTDevice* device = results[i];
+                if ( btNameLength == 0 ||
+                     device->DeviceName().Match( btName8 ) != KErrNotFound )
+                    {
+                    HTI_LOG_TEXT( "Name qualifies for deletion" );
+                    registry.UnpairDevice( device->BDAddr(), status );
+                    User::WaitForRequest( status );
+                    err = status.Int();
+                    if ( err == KErrNone )
+                        {
+                        deleteCount++; // one deletion successfully done
+                        }
+                    }
+                if ( err != KErrNone )
+                    {
+                    // Break out if any failure occurs - the command has not
+                    // been able to do what it is expected to do.
+                    break;
+                    }
+                }
+            }
+        CleanupStack::PopAndDestroy( response );
+        }
+
+    CleanupStack::PopAndDestroy( &registry );
+    CleanupStack::PopAndDestroy( &regServ );
+
+    // Create OK response or send error
+    if ( err == KErrNone )
+        {
+        HTI_LOG_FORMAT( "%d pairings deleted successfully", deleteCount );
+        iReply = HBufC8::NewL( 1 );
+        iReply->Des().Append( deleteCount );
+        }
+    else
+        {
+        HTI_LOG_FORMAT( "Error %d", err );
+        iDispatcher->DispatchOutgoingErrorMessage(
+            err,
+            KErrDescrBtDeletePairings,
+            KSysInfoServiceUid );
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleBtDeletePairingsL" );
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleKeyLockToggleL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleKeyLockToggleL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleKeyLockToggleL" );
+
+    if ( aMessage.Length() != 3 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage( KErrArgument,
+            KErrDescrArgument, KSysInfoServiceUid );
+        return;
+        }
+
+    RAknKeyLock keyLock;
+    User::LeaveIfError( keyLock.Connect() );
+    HTI_LOG_TEXT( "RAknKeyLock connect OK" );
+
+    TBool isKeyLockOn = keyLock.IsKeyLockEnabled();
+    HTI_LOG_FORMAT( "Keylock status = %d", isKeyLockOn );
+
+    TBool requested = aMessage[1];
+    HTI_LOG_FORMAT( "Requested status = %d", requested );
+
+    if ( requested == isKeyLockOn )
+        {
+        // Already in requested state - just send message
+        iReply = HBufC8::NewL( 1 );
+        iReply->Des().Append( 1 );
+        }
+
+    else
+        {
+        TBool showNote = aMessage[2];
+        HTI_LOG_FORMAT( "Note request = %d", showNote );
+        if ( requested )
+            {
+            if ( showNote )
+                {
+                keyLock.EnableKeyLock();
+                }
+            else
+                {
+                keyLock.EnableWithoutNote();
+                }
+            }
+        else
+            {
+            if ( showNote )
+                {
+                keyLock.DisableKeyLock();
+                }
+            else
+                {
+                keyLock.DisableWithoutNote();
+                }
+            }
+        User::After( 500000 );
+        isKeyLockOn = keyLock.IsKeyLockEnabled();
+        HTI_LOG_FORMAT( "New keylock status = %d", isKeyLockOn );
+        if ( isKeyLockOn == requested )
+            {
+            iReply = HBufC8::NewL( 1 );
+            iReply->Des().Append( 0 );
+            }
+        else
+            {
+            iDispatcher->DispatchOutgoingErrorMessage( KErrGeneral,
+                KErrDescrKeyLock, KSysInfoServiceUid );
+            }
+        }
+
+    keyLock.Close();
+
+    HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleKeyLockToggleL" );
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleAutoKeyGuardTimeL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleAutoKeyGuardTimeL( const TDesC8& aMessage )
+    {
+
+    HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleAutoKeyGuardTimeL" );
+
+    if ( aMessage.Length() != 3 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage( KErrArgument,
+            KErrDescrArgument, KSysInfoServiceUid );
+        return;
+        }
+
+    TInt time = aMessage[1] + ( aMessage[2] << 8 );
+    HTI_LOG_FORMAT( "Requested auto key guard time %d", time );
+    if ( time > 3600 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage( KErrArgument,
+            KErrDescrInvalidTime, KSysInfoServiceUid );
+        return;
+        }
+
+    CRepository* secRep = CRepository::NewL( KCRUidSecuritySettings );
+    TInt err = secRep->Set( KSettingsAutomaticKeyguardTime, time );
+
+    if ( err == KErrNone )
+        {
+        iReply = HBufC8::NewL( 1 );
+        iReply->Des().Append( 0 );
+        }
+
+    else
+        {
+        iDispatcher->DispatchOutgoingErrorMessage( err,
+            KErrDescrAutoKeyGuardFailed, KSysInfoServiceUid );
+        }
+
+    delete secRep;
+
+    HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleAutoKeyGuardTimeL" );
+    }
+
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleEmptyDrmRightsDbL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleEmptyDrmRightsDbL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleEmptyDrmRightsDbL" );
+
+    if ( aMessage.Length() != 1 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage( KErrArgument,
+            KErrDescrArgument, KSysInfoServiceUid );
+        return;
+        }
+
+    RDRMRightsClient rightsClient;
+    TInt err = rightsClient.Connect();
+
+    if ( err != KErrNone )
+        {
+        HTI_LOG_FORMAT( "RDRMRightsClient connect failed %d", err );
+        iDispatcher->DispatchOutgoingErrorMessage( err,
+            KErrDescrDrmDbConnect, KSysInfoServiceUid );
+        }
+
+    else
+        {
+        HTI_LOG_TEXT( "RDRMRightsClient connect OK, clearing DB..." );
+        err = rightsClient.DeleteAll();
+        if ( err == KErrNone )
+            {
+            HTI_LOG_TEXT( "DB cleared OK" );
+            iReply = HBufC8::NewL( 1 );
+            iReply->Des().Append( 0 );
+            }
+        else
+            {
+            HTI_LOG_FORMAT( "DB clear failed %d", err );
+            iDispatcher->DispatchOutgoingErrorMessage( err,
+                KErrDescrDrmDbDelete, KSysInfoServiceUid );
+            }
+        rightsClient.Close();
+        }
+
+    HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleEmptyDrmRightsDbL" );
+    }
+
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleBatteryStatusL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleBatteryStatusL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleBatteryStatusL" );
+
+    if ( aMessage.Length() != 1 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage( KErrArgument,
+            KErrDescrArgument, KSysInfoServiceUid );
+        return;
+        }
+
+    TInt err = KErrNone;
+    TInt batteryLevel = EBatteryLevelUnknown;
+    TInt chargingStatus = EChargingStatusError;
+
+    err = RProperty::Get( KPSUidHWRMPowerState,
+                          KHWRMBatteryLevel, batteryLevel );
+    HTI_LOG_FORMAT( "Battery level = %d", batteryLevel );
+    if ( err != KErrNone || batteryLevel == EBatteryLevelUnknown )
+        {
+        if ( err == KErrNone ) err = KErrGeneral;
+        iDispatcher->DispatchOutgoingErrorMessage( err,
+            KErrDescrBatteryLevel, KSysInfoServiceUid );
+        return;
+        }
+
+    err = RProperty::Get( KPSUidHWRMPowerState,
+                          KHWRMChargingStatus, chargingStatus );
+    HTI_LOG_FORMAT( "Charging status = %d", chargingStatus );
+    if ( err != KErrNone || chargingStatus == EChargingStatusError )
+        {
+        if ( err == KErrNone ) err = KErrGeneral;
+        iDispatcher->DispatchOutgoingErrorMessage( err,
+            KErrDescrChargingStatus, KSysInfoServiceUid );
+        return;
+        }
+
+    iReply = HBufC8::NewL( 2 );
+    iReply->Des().Append( batteryLevel );
+    iReply->Des().Append( chargingStatus );
+
+    HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleBatteryStatusL" );
+    }
+
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleSignalStrengthL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleSignalStrengthL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleSignalStrengthL" );
+
+    if ( aMessage.Length() != 1 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage( KErrArgument,
+            KErrDescrArgument, KSysInfoServiceUid );
+        return;
+        }
+
+#if defined(__WINS__)
+    iDispatcher->DispatchOutgoingErrorMessage( KErrNotSupported,
+        KErrDescrNotSupported, KSysInfoServiceUid );
+#else
+    TInt err = KErrNone;
+    TInt popCount = 0;
+    RTelServer server;
+    err = server.Connect();
+
+    if ( err == KErrNone )
+        {
+        HTI_LOG_TEXT( "Connected to RTelServer" );
+        CleanupClosePushL( server );
+        popCount++;
+        err = server.LoadPhoneModule( KMmTsyModuleName );
+        if ( err == KErrAlreadyExists ) err = KErrNone; // ok if already loaded
+        }
+
+    RMobilePhone mobilePhone;
+
+    if ( err == KErrNone )
+        {
+        HTI_LOG_TEXT( "Phone module loaded" );
+        err = mobilePhone.Open( server, KMmTsyPhoneName );
+        }
+
+    TInt8  signalBars;
+    TInt32 signalStrength;
+
+    if ( err == KErrNone )
+        {
+        HTI_LOG_TEXT( "RMobilePhone open" );
+        CleanupClosePushL( mobilePhone );
+        popCount++;
+        TRequestStatus status;
+        mobilePhone.GetSignalStrength( status, signalStrength, signalBars );
+        User::WaitForRequest( status );
+        HTI_LOG_FORMAT( "GetSignalStrength return value %d", status.Int() );
+        err = status.Int();
+        }
+
+    if ( err == KErrNone )
+        {
+        HTI_LOG_FORMAT( "Signal bars = %d", signalBars );
+        HTI_LOG_FORMAT( "Signal strength = %d", signalStrength );
+        iReply = HBufC8::NewL( 1 );
+        iReply->Des().Append( signalBars );
+        }
+
+    else
+        {
+        iDispatcher->DispatchOutgoingErrorMessage( err,
+            KErrDescrSignalStrength, KSysInfoServiceUid );
+        }
+
+    if ( popCount > 0 )
+        {
+        CleanupStack::PopAndDestroy( popCount );
+        }
+#endif // __WINS__
+    HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleSignalStrengthL" );
+    }
+
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleHsdpaCommandL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleHsdpaCommandL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleHsdpaCommandL" );
+
+    if ( aMessage.Length() != 2 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage( KErrArgument,
+            KErrDescrArgument, KSysInfoServiceUid );
+        return;
+        }
+    TBool enableHsdpa = aMessage[1];
+
+    RTelServer telServer;
+    RMmCustomAPI customAPI;
+    RMobilePhone mobilePhone;
+    User::LeaveIfError( telServer.Connect() );
+    CleanupClosePushL( telServer );
+    User::LeaveIfError( mobilePhone.Open( telServer, KMmTsyPhoneName ) );
+    CleanupClosePushL( mobilePhone );
+    User::LeaveIfError( customAPI.Open( mobilePhone ) );
+    CleanupClosePushL( customAPI );
+
+    // Get current HSDPA status
+    TBool isHsdpaEnabled = EFalse;
+    TRequestStatus status;
+    RMmCustomAPI::THSxPAStatus hSxPAStatus;
+    customAPI.ReadHSxPAStatus( status, hSxPAStatus );
+    User::WaitForRequest( status );
+    HTI_LOG_FORMAT( "Reading HSxPA status returned %d", status.Int() );
+    User::LeaveIfError( status.Int() );
+    if ( hSxPAStatus == RMmCustomAPI::EHSxPAEnabled )
+        {
+        isHsdpaEnabled = ETrue;
+        }
+
+    HTI_LOG_FORMAT( "Current HSDPA status   = %d", isHsdpaEnabled );
+    HTI_LOG_FORMAT( "Requested HSDPA status = %d", enableHsdpa );
+
+    if ( isHsdpaEnabled == enableHsdpa )
+        {
+        // Already in requested state - just send message
+        iReply = HBufC8::NewL( 1 );
+        iReply->Des().Append( 1 );
+        }
+
+    else
+        {
+        // Try to change status
+        if ( enableHsdpa )
+            {
+            hSxPAStatus = RMmCustomAPI::EHSxPAEnabled;
+            }
+        else
+            {
+            hSxPAStatus = RMmCustomAPI::EHSxPADisabled;
+            }
+        customAPI.WriteHSxPAStatus( status, hSxPAStatus );
+        User::WaitForRequest( status );
+        HTI_LOG_FORMAT( "Writing HSxPA status returned %d", status.Int() );
+        User::LeaveIfError( status.Int() );
+        iReply = HBufC8::NewL( 1 );
+        iReply->Des().Append( 0 );
+        }
+
+    CleanupStack::PopAndDestroy( 3 ); // mobilePhone, customAPI, telServer
+
+    HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleHsdpaCommandL" );
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleUpdateMediaGalleryL()
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleUpdateMediaGalleryL(
+        const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleUpdateMediaGalleryL" );
+
+    if ( !iGalleryUpdateSupported )
+        {
+        HTI_LOG_TEXT( "Media Gallery update not supported" );
+        iDispatcher->DispatchOutgoingErrorMessage( KErrNotSupported,
+                KErrDescrNotSupported, KSysInfoServiceUid );
+        return;
+        }
+
+    if ( aMessage.Length() < 2 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage( KErrArgument,
+            KErrDescrArgument, KSysInfoServiceUid );
+        return;
+        }
+    TInt filePathLength = aMessage[1];
+    // Check that given file path length is valid: Index 0 is the
+    // command code, index 1 is the path length -> hence the + 2
+    if ( aMessage.Length() != filePathLength + 2 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage( KErrArgument,
+                KErrDescrArgument, KSysInfoServiceUid );
+        return;
+        }
+
+    // Try to load the Media File API DLL
+    TInt err = KErrNone;
+    RLibrary galleryUpdaterDLL;
+    err = galleryUpdaterDLL.Load( _L( "MGXMediaFileAPI.dll" ) );
+    if ( err == KErrNotFound )  // DLL does not exist
+        {
+        HTI_LOG_TEXT( "MGXMediaFileAPI.dll file not found" );
+        iGalleryUpdateSupported = EFalse;
+        iDispatcher->DispatchOutgoingErrorMessage( KErrNotSupported,
+                KErrDescrNotSupported, KSysInfoServiceUid );
+        return;
+        }
+    User::LeaveIfError( err ); // Some other error in loading the DLL
+
+    // DLL loaded successfully
+    CleanupClosePushL( galleryUpdaterDLL );
+
+    // Construct the CMGXFileManager object from the DLL
+    typedef CMGXFileManager* ( *TNewFileManagerFunc )( RFs& aFs );
+    TNewFileManagerFunc newFileManFunc =
+            ( TNewFileManagerFunc ) galleryUpdaterDLL.Lookup( 1 );
+    if ( newFileManFunc == NULL )
+        {
+        HTI_LOG_TEXT( "Function not found from DLL" );
+        iGalleryUpdateSupported = EFalse;
+        User::Leave( KErrNotSupported );
+        }
+
+    CMGXFileManager* mgManager = NULL;
+    TRAP( err, mgManager = newFileManFunc( iFs ) );
+    HTI_LOG_FORMAT( "NewFileManagerL returned %d", err );
+    User::LeaveIfError( err );
+    User::LeaveIfNull( mgManager );
+    CleanupStack::PushL( mgManager );
+
+    if ( filePathLength > 0 )
+        {
+        TBuf<KMaxFileName> path;
+        path.Copy( aMessage.Mid( 2 ) );
+        HTI_LOG_FORMAT( "Updating file %S to gallery", &path );
+        TRAP( err, mgManager->UpdateL( path ) );
+        }
+    else
+        {
+        HTI_LOG_TEXT( "Updating all files to gallery" );
+        TRAP( err, mgManager->UpdateL() );
+        }
+
+    if ( err != KErrNone )
+        {
+        HTI_LOG_FORMAT( "Gallery update failed with %d", err );
+        iDispatcher->DispatchOutgoingErrorMessage( err, KErrDescrMGUpdate,
+                KSysInfoServiceUid );
+        }
+
+    CleanupStack::PopAndDestroy( 2 ); // mgManager, galleryUpdaterDLL
+    iReply = HBufC8::NewL( 1 );
+    iReply->Des().Append( 0 );
+    HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleUpdateMediaGalleryL" );
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::HandleActivateSkinL()
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::HandleActivateSkinL( const TDesC8& aMessage )
+    {
+    HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleActivateSkinL" );
+
+    // Must be at least command code + name length byte
+    if ( aMessage.Length() < 2 || aMessage.Length() != aMessage[1] + 2 )
+        {
+        iDispatcher->DispatchOutgoingErrorMessage( KErrArgument,
+                KErrDescrArgument, KSysInfoServiceUid );
+        return;
+        }
+
+    TFileName skinName;
+    if ( aMessage[1] > 0 )
+        {
+        skinName.Copy( aMessage.Mid( 2 ) );
+        }
+    HTI_LOG_FORMAT( "Skin name: %S", &skinName );
+
+    // Check if we got full path to skn file
+    TParse fileParse;
+    fileParse.Set( skinName, NULL, NULL );
+    TBool isFullPath = fileParse.DrivePresent() && fileParse.PathPresent() &&
+            fileParse.NamePresent() && fileParse.ExtPresent();
+    HTI_LOG_FORMAT( "Is full path = %d", isFullPath );
+
+    // Check current skin
+    TAknsPkgIDBuf pidBuf;
+    TInt currentSkinLocation; // TAknSkinSrvSkinPackageLocation
+    CRepository* repository =
+            CRepository::NewL( KCRUidPersonalisation );
+    CleanupStack::PushL( repository );
+    repository->Get( KPslnActiveSkinUid, pidBuf );
+    repository->Get( KPslnActiveSkinLocation, currentSkinLocation );
+    TAknsPkgID currentSkinPid;
+    currentSkinPid.SetFromDesL( pidBuf );
+    HTI_LOG_FORMAT( "Current skin pkg ID buf = %S", &pidBuf );
+    HTI_LOG_FORMAT( "Current skin location = %d", currentSkinLocation );
+
+    // Connect to the skins server
+    RAknsSrvSession skinsSession;
+    User::LeaveIfError( skinsSession.Connect() );
+    CleanupClosePushL( skinsSession );
+
+    // Resolve the ID for the requested skin
+    TAknsPkgID requestedSkinPid = KAknsNullPkgID;
+    TInt requestedSkinLocation = EAknsSrvPhone;
+
+    if ( skinName.Length() == 0 )
+        {
+        // Default skin requested - resolve default skin ID
+        // Use KAknsPIDS60DefaultSkin if nothing else found from CenRep
+        requestedSkinPid.Set( KAknsPIDS60DefaultSkin );
+        TAknsPkgID defaultSkin = KAknsNullPkgID;
+        TAknsPkgIDBuf defaultPidBuf;
+        TInt ret = repository->Get( KPslnDefaultSkinUID, defaultPidBuf );
+        if ( ret != KErrNone || defaultPidBuf.Length() == 0 )
+            {
+            HTI_LOG_TEXT( "KPslnDefaultSkinUID not found" );
+            TInt defaultID = 0;
+            ret = repository->Get( KPslnDefaultSkinID, defaultID );
+            if ( ret == KErrNone && defaultID != 0 )
+                {
+                HTI_LOG_FORMAT( "KPslnDefaultSkinID found: %d", defaultID );
+                defaultSkin.Set( TUid::Uid( defaultID ) );
+                }
+            }
+        else
+            {
+            HTI_LOG_FORMAT( "KPslnDefaultSkinUID found: %S", &defaultPidBuf );
+            TLex lexer( defaultPidBuf );
+            TPtrC pidToken( lexer.NextToken() );
+            TUint pid = 0;
+            TUint timeStamp = 0;
+            // as hex UID is 8 characters
+            // as decimal UID is 9 or 10 characters
+            if ( pidToken.Length() == 8 )
+                {
+                ret = TLex( pidToken ).Val( pid, EHex ); // value is in hex
+                }
+            else
+                {
+                ret = TLex( pidToken ).Val( pid ); // value is in decimal
+                }
+            if ( ret == KErrNone )
+                {
+                TPtrC stampToken( lexer.NextToken() );
+                // Timestamp doesn't exist if PID is an UID
+                if ( stampToken.Length() )
+                    {
+                    if ( stampToken.Length() == 8 )
+                        {
+                        // value is in hex
+                        ret = TLex( stampToken ).Val( timeStamp, EHex );
+                        }
+                    else
+                        {
+                        // value is decimal
+                        ret = TLex( stampToken ).Val( timeStamp );
+                        }
+                    }
+                }
+            if ( ret == KErrNone )
+                {
+                // We have found some valid values.
+                // Timestamp is 0 if pid is UID value
+                HTI_LOG_FORMAT( "PID %d", pid );
+                HTI_LOG_FORMAT( "Timestamp %d", timeStamp );
+                defaultSkin.Set( timeStamp, pid );
+                }
+            }
+        // Did we find something from CenRep
+        if ( defaultSkin != KAknsNullPkgID )
+            {
+            requestedSkinPid.Set( defaultSkin );
+            }
+        }
+
+    else
+        {
+        // We have skin name - try to find it
+        CArrayPtr<CAknsSrvSkinInformationPkg>* skinInfoArray =
+                skinsSession.EnumerateSkinPackagesL( EAknsSrvAll );
+        HTI_LOG_FORMAT( "Skins found: %d", skinInfoArray->Count() );
+        TInt i = 0;
+        for ( ; i < skinInfoArray->Count(); i++ )
+            {
+            if ( isFullPath )
+                {
+                if ( skinName.CompareF(
+                        skinInfoArray->At( i )->FullName() ) == 0 )
+                    {
+                    requestedSkinPid = skinInfoArray->At( i )->PID();
+                    }
+                }
+            else
+                {
+                if ( skinName.CompareF( skinInfoArray->At( i )->Name() ) == 0 )
+                    {
+                    requestedSkinPid = skinInfoArray->At( i )->PID();
+                    }
+                }
+            if ( requestedSkinPid != KAknsNullPkgID )
+                {
+                // Requested skin was found - check the location
+                TUint16 drive = ( skinInfoArray->At( i )->Directory() )[0];
+                if (  drive == 'E' || drive == 'e' )
+                    {
+                    requestedSkinLocation = EAknsSrvMMC;
+                    }
+                else
+                    {
+                    requestedSkinLocation = EAknsSrvPhone;
+                    }
+                break;
+                }
+            }
+        skinInfoArray->ResetAndDestroy(); // not needed anymore
+        delete skinInfoArray;
+        skinInfoArray = NULL;
+        }
+
+    if ( requestedSkinPid != KAknsNullPkgID )
+        {
+        // Do we need to change skin
+        if ( requestedSkinPid != currentSkinPid )
+            {
+            HTI_LOG_FORMAT( "Activating skin %d", requestedSkinPid.iNumber );
+            TInt err = skinsSession.SetAllDefinitionSets( requestedSkinPid );
+            HTI_LOG_FORMAT( "Activation returned %d", err );
+            if ( err == KErrNone )
+                {
+                TAknsPkgIDBuf newPidBuf;
+                requestedSkinPid.CopyToDes( newPidBuf );
+                err = repository->Set( KPslnActiveSkinUid, newPidBuf );
+                HTI_LOG_FORMAT( "Set KPslnActiveSkinUid returned %d", err );
+                if ( err == KErrNone &&
+                        requestedSkinLocation != currentSkinLocation )
+                    {
+                    err = repository->Set(
+                            KPslnActiveSkinLocation, requestedSkinLocation );
+                    HTI_LOG_FORMAT( "Set KPslnActiveSkinLocation returned %d",
+                            err );
+                    }
+                if ( err == KErrNone )
+                    {
+                    // Send OK message
+                    iReply = HBufC8::NewL( 1 );
+                    iReply->Des().Append( 0 ); // 0 means OK
+                    }
+                }
+            if ( err != KErrNone )
+                {
+                HTI_LOG_FORMAT( "Skin activation failed with %d", err );
+                iDispatcher->DispatchOutgoingErrorMessage( err,
+                        KErrDescrActivateSkin, KSysInfoServiceUid );
+                }
+            }
+        else
+            {
+            // Requested skin already active - just send message
+            HTI_LOG_TEXT( "Already active - no need to change" );
+            iReply = HBufC8::NewL( 1 );
+            iReply->Des().Append( 1 );  // 1 means "already active"
+            }
+        }
+
+    else
+        {
+        // Skin was not found
+        HTI_LOG_TEXT( "Skin was not found" );
+        iDispatcher->DispatchOutgoingErrorMessage( KErrNotFound,
+                KErrDescrActivateSkin, KSysInfoServiceUid );
+        }
+
+    CleanupStack::PopAndDestroy( 2 ); // skinsSession, repository
+
+    HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleActivateSkinL" );
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::ParseTimeDataL
+//------------------------------------------------------------------------------
+void CHtiSysInfoServicePlugin::ParseTimeDataL( const TDesC8& aTimeData,
+                                               TTime& aResult )
+    {
+    /*
+      aTimeData =
+        bytes 0 - 1 = year
+                  2 = month
+                  3 = day
+                  4 = hour
+                  5 = minute
+                  6 = second
+    */
+    if ( aTimeData.Length() != KTimeDataLength )
+        {
+        User::Leave( KErrBadDescriptor );
+        }
+
+    TInt year   = aTimeData[0] + ( aTimeData[1] << 8 );
+    TInt month  = aTimeData[2];
+    TInt day    = aTimeData[3];
+    TInt hour   = aTimeData[4];
+    TInt minute = aTimeData[5];
+    TInt second = aTimeData[6];
+
+    TDateTime dateTime;
+    User::LeaveIfError( dateTime.Set(
+        year, TMonth( month - 1 ), day - 1, hour, minute, second, 0 ) );
+    aResult = dateTime;
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::CleanUpTempFiles
+//------------------------------------------------------------------------------
+TInt CHtiSysInfoServicePlugin::CleanUpTempFiles()
+    {
+    HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::CleanUpTempFiles" );
+
+    TFindFile finder( iFs );
+    TFileName path( KTempFilePath );
+    TInt err = finder.FindByPath( KTempFileName, &path );
+
+    while ( err == KErrNone )
+        {
+        TFileName tempFile = finder.File();
+
+        HTI_LOG_TEXT( "Found temp file: " );
+        HTI_LOG_DES( tempFile );
+
+        err = iFileMan->Delete( tempFile );
+
+        // return if deleting does not succeed to prevent mad man loop
+        if ( err != KErrNone ) return err;
+
+        // try to find next temp file
+        err = finder.FindByPath( KTempFileName, &path );
+        }
+
+    HTI_LOG_FUNC_OUT("CHtiSysInfoServicePlugin::CleanUpTempFiles");
+    return KErrNone;
+    }
+
+//------------------------------------------------------------------------------
+// CHtiSysInfoServicePlugin::CanTurnBluetoothOnL
+//------------------------------------------------------------------------------
+TBool CHtiSysInfoServicePlugin::CanTurnBluetoothOnL( const TBool aUseForce )
+    {
+    HTI_LOG_FUNC_IN("CHtiSysInfoServicePlugin::CanTurnBluetoothOnL");
+    TInt isInNetwork = 0;
+    CRepository* repository = CRepository::NewL( KCRUidCoreApplicationUIs );
+    repository->Get( KCoreAppUIsNetworkConnectionAllowed, isInNetwork );
+    HTI_LOG_FORMAT( "isInNetwork = %d", isInNetwork );
+    delete repository;
+
+    if ( isInNetwork )
+        {
+        return ETrue;
+        }
+
+    // Phone is offline - check if it's allowed to turn BT on.
+
+    // If the force flag was not set in command, we won't turn BT on in offline.
+    if ( !aUseForce )
+        {
+        return EFalse;
+        }
+
+    // Check if it's possible to turn BT on in offline mode.
+    TInt btOfflineEnabled = 0;
+    CRepository* repository2 = CRepository::NewL( KCRUidBluetoothEngine );
+    repository2->Get( KBTEnabledInOffline, btOfflineEnabled );
+    HTI_LOG_FORMAT( "btOfflineEnabled = %d", btOfflineEnabled );
+    delete repository2;
+
+    if ( btOfflineEnabled )
+        {
+        return ETrue;
+        }
+    HTI_LOG_FUNC_OUT("CHtiSysInfoServicePlugin::CanTurnBluetoothOnL");
+    return EFalse;
+    }
+
+
+// ----------------------------------------------------------------------------
+CAsyncWaiter* CAsyncWaiter::NewL( TInt aPriority )
+    {
+    CAsyncWaiter* self = new(ELeave) CAsyncWaiter( aPriority );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+CAsyncWaiter* CAsyncWaiter::NewLC( TInt aPriority )
+    {
+    CAsyncWaiter* self = new ( ELeave ) CAsyncWaiter( aPriority );
+    CleanupStack::PushL( self );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+CAsyncWaiter::CAsyncWaiter( TInt aPriority ) : CActive( aPriority )
+    {
+    iWait = new CActiveSchedulerWait();
+    CActiveScheduler::Add( this );
+    }
+
+// ----------------------------------------------------------------------------
+CAsyncWaiter::~CAsyncWaiter()
+    {
+    Cancel();
+    delete iWait;
+    }
+
+// ----------------------------------------------------------------------------
+void CAsyncWaiter::StartAndWait()
+    {
+    HTI_LOG_FUNC_IN( "CAsyncWaiter::StartAndWait" );
+    iStatus = KRequestPending;
+    SetActive();
+    iWait->Start();
+    HTI_LOG_FUNC_OUT( "CAsyncWaiter::StartAndWait" );
+    }
+
+// ----------------------------------------------------------------------------
+TInt CAsyncWaiter::Result() const
+    {
+    return iResult;
+    }
+
+// ----------------------------------------------------------------------------
+void CAsyncWaiter::RunL()
+    {
+    HTI_LOG_FUNC_IN( "CAsyncWaiter::RunL" );
+    iResult = iStatus.Int();
+    iWait->AsyncStop();
+    HTI_LOG_FUNC_OUT( "CAsyncWaiter::RunL" );
+    }
+
+// ----------------------------------------------------------------------------
+void CAsyncWaiter::DoCancel()
+    {
+    iResult = KErrCancel;
+    if ( iStatus == KRequestPending )
+        {
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete( status, KErrCancel );
+        }
+    iWait->AsyncStop();
+    }
+
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiServicePlugins/HtiSysInfoServicePlugin/src/proxy.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,37 @@
+/*
+* 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:  Implementation proxy for systen info service plugin dll
+*
+*/
+
+
+// INCLUDES
+#include "HtiSysInfoServicePlugin.h"
+
+#include <e32std.h>
+#include <ecom/implementationproxy.h>
+
+// Provides a key value pair table, this is used to identify
+// the correct construction function for the requested interface.
+const TImplementationProxy ImplementationTable[] =
+    {
+        IMPLEMENTATION_PROXY_ENTRY(0x10210CC7,  CHtiSysInfoServicePlugin::NewL)
+    };
+
+// Function used to return an instance of the proxy table.
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    return ImplementationTable;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiStartupWait/bwins/HtiStartupWaitu.def	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?NewStartupWait@@YAPAVCHtiStartupWait@@XZ @ 1 NONAME ; class CHtiStartupWait * NewStartupWait(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiStartupWait/eabi/HtiStartupWaitu.def	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	_Z14NewStartupWaitv @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiStartupWait/group/HtiStartupWait.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,42 @@
+/*
+* 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:  DLL implementing the MHtiStartupWaitInterface
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          HtiStartupWait.dll
+TARGETTYPE      dll
+
+UID             0x1020DEB9 0x200212DE
+
+VENDORID        0x101FB657
+
+CAPABILITY      ALL -TCB
+
+SOURCEPATH      ../src
+SOURCE          HtiStartupWait.cpp
+
+USERINCLUDE     ../inc
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY         euser.lib
+LIBRARY         hal.lib
+LIBRARY         flogger.lib
+
+SMPSAFE
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiStartupWait/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  Build information file for HtiStartupWait
+*
+*/
+
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+HtiStartupWait.mmp
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiStartupWait/inc/HtiStartupWait.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  CHtiStartupWait class declaration.
+*
+*/
+
+
+#ifndef __HTISTARTUPWAIT_H
+#define __HTISTARTUPWAIT_H
+
+//  INCLUDES
+#include <e32std.h>
+#include <HtiStartupWaitInterface.h>
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+*
+*/
+NONSHARABLE_CLASS(CHtiStartupWait) : public MHtiStartupWaitInterface
+    {
+    public: // from MHtiStartupWaitInterface
+        virtual TInt WaitForStartup( TInt aMaxWaitTime );
+    };
+
+#endif // __HTISTARTUPWAIT_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/HtiStartupWait/src/HtiStartupWait.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,88 @@
+/*
+* 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:  HtiStartupWait implementation
+*
+*/
+
+
+// INCLUDE FILES
+#include "HtiStartupWait.h"
+#include <HtiLogging.h>
+#include <e32property.h>
+#include <hal.h>
+#include <startupdomainpskeys.h>
+
+// CONSTANTS
+const TInt KStateCheckInterval  = 3000000; // microseconds
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// ----------------------------------------------------------------------------
+EXPORT_C CHtiStartupWait* NewStartupWait()
+    {
+    return new ( ELeave ) CHtiStartupWait();
+
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// ----------------------------------------------------------------------------
+TInt CHtiStartupWait::WaitForStartup( TInt aMaxWaitTime )
+    {
+    TInt err = KErrNone;
+
+    // Not relying on TTime as the time might change during OS startup.
+    // Counting the time from nano ticks.
+    TInt nTickPeriod;
+    HAL::Get( HAL::ENanoTickPeriod, nTickPeriod );
+    HTI_LOG_FORMAT( "ENanoTickPeriod = %d", nTickPeriod );
+
+    TUint32 startTime = User::NTickCount();
+    TInt secsFromStart = 0;
+
+    TInt state = ESwStateStartingUiServices; // TPSGlobalSystemState
+    RProperty::Get( KPSUidStartup, KPSGlobalSystemState, state );
+    while ( state != ESwStateNormalRfOn && state != ESwStateNormalRfOff &&
+            secsFromStart < aMaxWaitTime )
+        {
+        HTI_LOG_FORMAT(
+            "HTI waiting for device to start: TPSGlobalSystemState = %d",
+            state );
+        User::After( KStateCheckInterval );
+        secsFromStart =
+            ( User::NTickCount() - startTime ) * nTickPeriod / 1000000;
+        HTI_LOG_FORMAT( "Seconds from start %d", secsFromStart );
+        RProperty::Get( KPSUidStartup, KPSGlobalSystemState, state );
+        }
+
+    if ( secsFromStart >= aMaxWaitTime )
+        {
+        HTI_LOG_TEXT( "Max wait time exceeded" );
+        err = KErrTimedOut;
+        }
+
+    return err;
+    }
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,62 @@
+/*
+* 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:  Build information file for building
+*               HTI UI layer components.
+*                
+*
+*/
+
+#include <platform_paths.hrh>
+#include "../symbian_version.hrh"
+
+PRJ_EXPORTS
+../rom/htiui.iby        CORE_IBY_EXPORT_PATH(tools,htiui.iby)
+
+
+// Communication plugins
+#include "../HtiCommPlugins/HtiBtCommPlugin/group/bld.inf"
+
+// Service plugins
+#include "../HtiServicePlugins/HtiAppServicePlugin/group/bld.inf"
+#include "../HtiServicePlugins/HtiAudioServicePlugin/group/bld.inf"
+#include "../HtiServicePlugins/HtiKeyEventServicePlugin/group/bld.inf"
+#if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 )
+    #include "../HtiServicePlugins/HtiMessagesServicePlugin/group/bld.inf"
+    #include "../HtiServicePlugins/HtiPIMServicePlugin/group/bld.inf"
+#endif
+#include "../HtiServicePlugins/HtiScreenshotServicePlugin/group/bld.inf"
+#include "../HtiServicePlugins/HtiSysInfoServicePlugin/group/bld.inf"
+
+// Backup fake DLL used by HtiFtpServicePlugin
+#include "../HtiServicePlugins/HtiFtpBackupFake/group/bld.inf"
+
+// Device rebooter
+#include "../HtiDeviceReboot/group/bld.inf"
+
+// Startup wait DLL
+#include "../HtiStartupWait/group/bld.inf"
+
+// HTI Admin UI application
+#include "../HtiAdmin/group/bld.inf"
+
+// Build stub SIS
+PRJ_EXTENSIONS
+#ifdef MARM
+START EXTENSION app-services/buildstubsis
+OPTION SRCDIR ../sis
+OPTION SISNAME HTI_stub
+END
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/group/hti_stub_sis.mk	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,58 @@
+#
+# 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: Makefile for creating HTI stub SIS for ROM image.
+#                
+
+
+TARGETDIR=$(EPOCROOT)EPOC32\Data\Z\System\Install
+
+SISNAME=HTI_stub
+PKGNAME=HTI_stub
+
+$(TARGETDIR) :
+	@perl -S emkdir.pl "$(TARGETDIR)"
+
+do_nothing :
+	rem do_nothing
+
+SISFILE=$(TARGETDIR)\$(SISNAME).sis
+
+$(SISFILE) : ..\sis\$(PKGNAME).pkg
+	makesis -s $? $@
+
+#
+# The targets invoked by bld...
+#
+
+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 :
+	-erase $(SISFILE)
+
+RELEASABLES :
+	@echo $(SISFILE)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/rom/htiui.iby	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,56 @@
+/*
+* 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: Specifies HTI UI layer components for ROM image
+*
+*/
+
+#ifndef __HTIUI_IBY__
+#define __HTIUI_IBY__
+
+// HtiAdmin application
+S60_APP_EXE(HtiAdmin)
+#ifdef S60_UPGRADABLE_APP_REG_RSC
+  S60_UPGRADABLE_APP_REG_RSC(HtiAdmin)
+#else
+  S60_APP_AIF_RSC(HtiAdmin)
+#endif
+S60_APP_RESOURCE(HtiAdmin)
+
+// Test service plug-ins
+ECOM_PLUGIN(HtiAudioServicePlugin.dll,HtiAudioServicePlugin.rsc)
+ECOM_PLUGIN(HtiKeyEventServicePlugin.dll,HtiKeyEventServicePlugin.rsc)
+ECOM_PLUGIN(HtiMessagesServicePlugin.dll,HtiMessagesServicePlugin.rsc)
+ECOM_PLUGIN(HtiPIMServicePlugin.dll,HtiPIMServicePlugin.rsc)
+ECOM_PLUGIN(HtiScreenshotServicePlugin.dll,HtiScreenshotServicePlugin.rsc)
+ECOM_PLUGIN(HtiSysInfoServicePlugin.dll,HtiSysInfoServicePlugin.rsc)
+
+// Test service plug-in extension
+file=ABI_DIR\BUILD_DIR\HtiAppControl.dll            SHARED_LIB_DIR\HtiAppControl.dll
+
+// Backup fake DLL used by HtiFtpServicePlugin
+file=ABI_DIR\BUILD_DIR\HtiFtpBackupFake.dll         SHARED_LIB_DIR\HtiFtpBackupFake.dll
+
+// Notepad helper
+file=ABI_DIR\BUILD_DIR\HtiNpdHlp.exe                SHARED_LIB_DIR\HtiNpdHlp.exe
+
+// Device rebooter
+file=ABI_DIR\BUILD_DIR\HtiDeviceRebootUI.exe       SHARED_LIB_DIR\HtiDeviceRebootUI.exe
+
+// Startup wait DLL
+file=ABI_DIR\BUILD_DIR\HtiStartupWait.dll           SHARED_LIB_DIR\HtiStartupWait.dll
+
+// Stub SIS
+data=ZSYSTEM\Install\HTI_stub.sis                   system\install\HTI_stub.sis
+
+#endif // __HTIUI_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/sis/HTI_S60-51.pkg	Tue Feb 02 00:17:27 2010 +0200
@@ -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: Installation file for HTI
+
+
+; Languages
+&EN
+
+; Using UID of HtiFramework project
+#{"HTI"},(0x1020DEB6),2,15,0
+
+; Series60 product id for S60 5.1
+[0x10283160], 0, 0, 0, {"Series60ProductID"}
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+; Install files
+
+; HtiCfg library
+"\epoc32\release\armv5\urel\HtiCfg.dll"                          - "!:\sys\bin\HtiCfg.dll"
+
+; HtiAdmin
+"\epoc32\release\armv5\urel\HtiAdmin.exe"                        - "!:\sys\bin\HtiAdmin.exe"
+"\epoc32\data\Z\Resource\apps\HtiAdmin.rsc"                      - "!:\Resource\Apps\HtiAdmin.rsc"
+"\epoc32\data\Z\private\10003a3f\apps\HtiAdmin_reg.rsc"          - "!:\private\10003a3f\import\apps\HtiAdmin_reg.rsc"
+
+; Serial comm module
+"\epoc32\data\Z\Resource\Plugins\HtiSerialCommEcomPlugin.rsc"    - "!:\Resource\Plugins\HtiSerialCommEcomPlugin.rsc"
+"\epoc32\release\armv5\urel\HtiSerialCommEcomPlugin.dll"         - "!:\sys\bin\HtiSerialCommEcomPlugin.dll"
+
+; BtSerial comm module
+"\epoc32\release\armv5\urel\HtiBtSerialComHelper.dll"            - "!:\sys\bin\HtiBtSerialComHelper.dll"
+"\epoc32\release\armv5\urel\HtiBtCommServer.dll"                 - "!:\sys\bin\HtiBtCommServer.dll"
+"\epoc32\release\armv5\urel\HtiBtCommInterface.dll"              - "!:\sys\bin\HtiBtCommInterface.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiBtCommEcomPlugin.rsc"        - "!:\Resource\Plugins\HtiBtCommEcomPlugin.rsc"
+"\epoc32\release\armv5\urel\HtiBtCommEcomPlugin.dll"             - "!:\sys\bin\HtiBtCommEcomPlugin.dll"
+
+; IPComm module
+"\epoc32\release\armv5\urel\HtiIPCommServer.exe"                 - "!:\sys\bin\HtiIPCommServer.exe"
+"\epoc32\release\armv5\urel\HtiIPCommServerClient.dll"           - "!:\sys\bin\HtiIPCommServerClient.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiIPCommEcomPlugin.rsc"        - "!:\Resource\Plugins\HtiIPCommEcomPlugin.rsc"
+"\epoc32\release\armv5\urel\HtiIPCommEcomPlugin.dll"             - "!:\sys\bin\HtiIPCommEcomPlugin.dll"
+
+; USB serial comm module
+"\epoc32\data\Z\Resource\Plugins\HtiUsbSerialCommEcomPlugin.rsc" - "!:\Resource\Plugins\HtiUsbSerialCommEcomPlugin.rsc"
+"\epoc32\release\armv5\urel\HtiUsbSerialCommEcomPlugin.dll"      - "!:\sys\bin\HtiUsbSerialCommEcomPlugin.dll"
+
+; Test service plug-ins
+"\epoc32\release\armv5\urel\HtiEchoServicePlugin.dll"            - "!:\sys\bin\HtiEchoServicePlugin.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiEchoServicePlugin.rsc"       - "!:\Resource\Plugins\HtiEchoServicePlugin.rsc"
+"\epoc32\release\armv5\urel\HtiKeyEventServicePlugin.dll"        - "!:\sys\bin\HtiKeyEventServicePlugin.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiKeyEventServicePlugin.rsc"   - "!:\Resource\Plugins\HtiKeyEventServicePlugin.rsc"
+"\epoc32\release\armv5\urel\HtiScreenshotServicePlugin.dll"      - "!:\sys\bin\HtiScreenshotServicePlugin.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiScreenshotServicePlugin.rsc" - "!:\Resource\Plugins\HtiScreenshotServicePlugin.rsc"
+"\epoc32\release\armv5\urel\HtiFtpServicePlugin.dll"             - "!:\sys\bin\HtiFtpServicePlugin.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiFtpServicePlugin.rsc"        - "!:\Resource\Plugins\HtiFtpServicePlugin.rsc"
+"\epoc32\release\armv5\urel\HtiAppServicePlugin.dll"             - "!:\sys\bin\HtiAppServicePlugin.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiAppServicePlugin.rsc"        - "!:\Resource\Plugins\HtiAppServicePlugin.rsc"
+"\epoc32\release\armv5\urel\HtiAppControl.dll"                   - "!:\sys\bin\HtiAppControl.dll"
+"\epoc32\release\armv5\urel\HtiStifTfServicePlugin.dll"          - "!:\sys\bin\HtiStifTfServicePlugin.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiStifTfServicePlugin.rsc"     - "!:\Resource\Plugins\HtiStifTfServicePlugin.rsc"
+"\epoc32\release\armv5\urel\HtiSysInfoServicePlugin.dll"         - "!:\sys\bin\HtiSysInfoServicePlugin.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiSysInfoServicePlugin.rsc"    - "!:\Resource\Plugins\HtiSysInfoServicePlugin.rsc"
+"\epoc32\release\armv5\urel\HtiAudioServicePlugin.dll"           - "!:\sys\bin\HtiAudioServicePlugin.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiAudioServicePlugin.rsc"      - "!:\Resource\Plugins\HtiAudioServicePlugin.rsc"
+"\epoc32\release\armv5\urel\HtiMessagesServicePlugin.dll"        - "!:\sys\bin\HtiMessagesServicePlugin.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiMessagesServicePlugin.rsc"   - "!:\Resource\Plugins\HtiMessagesServicePlugin.rsc"
+"\epoc32\release\armv5\urel\HtiPIMServicePlugin.dll"             - "!:\sys\bin\HtiPIMServicePlugin.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiPIMServicePlugin.rsc"        - "!:\Resource\Plugins\HtiPIMServicePlugin.rsc"
+"\epoc32\release\armv5\urel\HtiIpProxyServicePlugin.dll"         - "!:\sys\bin\HtiIpProxyServicePlugin.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiIpProxyServicePlugin.rsc"    - "!:\Resource\Plugins\HtiIpProxyServicePlugin.rsc"
+
+; Helper to add notepad memos
+"\epoc32\release\armv5\urel\HtiNpdHlp.exe"                       - "!:\sys\bin\HtiNpdHlp.exe"
+
+; File helper with capability ALL - for file operations to TCB folders
+"\epoc32\release\armv5\urel\HtiFileHlp.exe"                      - "!:\sys\bin\HtiFileHlp.exe"
+
+; Backup fake DLL used by HtiFtpServicePlugin
+"\epoc32\release\armv5\urel\HtiFtpBackupFake.dll"                - "!:\sys\bin\HtiFtpBackupFake.dll"
+
+; HTI watchdog
+"\epoc32\release\armv5\urel\HtiWatchDog.exe"                     - "!:\sys\bin\HtiWatchDog.exe"
+
+; HTI device reboot
+"\epoc32\release\armv5\urel\HtiDeviceRebootUI.exe"               - "!:\sys\bin\HtiDeviceRebootUI.exe"
+
+; HTI Framework
+"\epoc32\release\armv5\urel\HTIFramework.exe"                    - "!:\sys\bin\HTIFramework.exe"
+
+; AutoStart recogniser plug-in
+"\epoc32\release\armv5\urel\HtiAutoStart.dll"                    - "!:\sys\bin\HtiAutoStart.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiAutoStart.rsc"               - "!:\Resource\Plugins\HtiAutoStart.rsc"
+
+; HTI startup wait
+"\epoc32\release\armv5\urel\HtiStartupWait.dll"                  - "!:\sys\bin\HtiStartupWait.dll"
+
+; Startup list resource file for starting HTIFramework.exe in device boot
+"\epoc32\data\Z\private\101f875a\import\1020deb6.rsc"            - "c:\private\101f875a\import\[1020deb6].rsc"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/sis/HTI_S60-52.pkg	Tue Feb 02 00:17:27 2010 +0200
@@ -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: Installation file for HTI
+
+
+; Languages
+&EN
+
+; Using UID of HtiFramework project
+#{"HTI"},(0x1020DEB6),2,15,0
+
+; Series60 product id for S60 5.2
+[0x20022E6D], 0, 0, 0, {"Series60ProductID"}
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+; Install files
+
+; HtiCfg library
+"\epoc32\release\armv5\urel\HtiCfg.dll"                          - "!:\sys\bin\HtiCfg.dll"
+
+; HtiAdmin
+"\epoc32\release\armv5\urel\HtiAdmin.exe"                        - "!:\sys\bin\HtiAdmin.exe"
+"\epoc32\data\Z\Resource\apps\HtiAdmin.rsc"                      - "!:\Resource\Apps\HtiAdmin.rsc"
+"\epoc32\data\Z\private\10003a3f\apps\HtiAdmin_reg.rsc"          - "!:\private\10003a3f\import\apps\HtiAdmin_reg.rsc"
+
+; Serial comm module
+"\epoc32\data\Z\Resource\Plugins\HtiSerialCommEcomPlugin.rsc"    - "!:\Resource\Plugins\HtiSerialCommEcomPlugin.rsc"
+"\epoc32\release\armv5\urel\HtiSerialCommEcomPlugin.dll"         - "!:\sys\bin\HtiSerialCommEcomPlugin.dll"
+
+; BtSerial comm module
+"\epoc32\release\armv5\urel\HtiBtSerialComHelper.dll"            - "!:\sys\bin\HtiBtSerialComHelper.dll"
+"\epoc32\release\armv5\urel\HtiBtCommServer.dll"                 - "!:\sys\bin\HtiBtCommServer.dll"
+"\epoc32\release\armv5\urel\HtiBtCommInterface.dll"              - "!:\sys\bin\HtiBtCommInterface.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiBtCommEcomPlugin.rsc"        - "!:\Resource\Plugins\HtiBtCommEcomPlugin.rsc"
+"\epoc32\release\armv5\urel\HtiBtCommEcomPlugin.dll"             - "!:\sys\bin\HtiBtCommEcomPlugin.dll"
+
+; IPComm module
+"\epoc32\release\armv5\urel\HtiIPCommServer.exe"                 - "!:\sys\bin\HtiIPCommServer.exe"
+"\epoc32\release\armv5\urel\HtiIPCommServerClient.dll"           - "!:\sys\bin\HtiIPCommServerClient.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiIPCommEcomPlugin.rsc"        - "!:\Resource\Plugins\HtiIPCommEcomPlugin.rsc"
+"\epoc32\release\armv5\urel\HtiIPCommEcomPlugin.dll"             - "!:\sys\bin\HtiIPCommEcomPlugin.dll"
+
+; USB serial comm module
+"\epoc32\data\Z\Resource\Plugins\HtiUsbSerialCommEcomPlugin.rsc" - "!:\Resource\Plugins\HtiUsbSerialCommEcomPlugin.rsc"
+"\epoc32\release\armv5\urel\HtiUsbSerialCommEcomPlugin.dll"      - "!:\sys\bin\HtiUsbSerialCommEcomPlugin.dll"
+
+; Test service plug-ins
+"\epoc32\release\armv5\urel\HtiEchoServicePlugin.dll"            - "!:\sys\bin\HtiEchoServicePlugin.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiEchoServicePlugin.rsc"       - "!:\Resource\Plugins\HtiEchoServicePlugin.rsc"
+"\epoc32\release\armv5\urel\HtiKeyEventServicePlugin.dll"        - "!:\sys\bin\HtiKeyEventServicePlugin.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiKeyEventServicePlugin.rsc"   - "!:\Resource\Plugins\HtiKeyEventServicePlugin.rsc"
+"\epoc32\release\armv5\urel\HtiScreenshotServicePlugin.dll"      - "!:\sys\bin\HtiScreenshotServicePlugin.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiScreenshotServicePlugin.rsc" - "!:\Resource\Plugins\HtiScreenshotServicePlugin.rsc"
+"\epoc32\release\armv5\urel\HtiFtpServicePlugin.dll"             - "!:\sys\bin\HtiFtpServicePlugin.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiFtpServicePlugin.rsc"        - "!:\Resource\Plugins\HtiFtpServicePlugin.rsc"
+"\epoc32\release\armv5\urel\HtiAppServicePlugin.dll"             - "!:\sys\bin\HtiAppServicePlugin.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiAppServicePlugin.rsc"        - "!:\Resource\Plugins\HtiAppServicePlugin.rsc"
+"\epoc32\release\armv5\urel\HtiAppControl.dll"                   - "!:\sys\bin\HtiAppControl.dll"
+"\epoc32\release\armv5\urel\HtiStifTfServicePlugin.dll"          - "!:\sys\bin\HtiStifTfServicePlugin.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiStifTfServicePlugin.rsc"     - "!:\Resource\Plugins\HtiStifTfServicePlugin.rsc"
+"\epoc32\release\armv5\urel\HtiSysInfoServicePlugin.dll"         - "!:\sys\bin\HtiSysInfoServicePlugin.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiSysInfoServicePlugin.rsc"    - "!:\Resource\Plugins\HtiSysInfoServicePlugin.rsc"
+"\epoc32\release\armv5\urel\HtiAudioServicePlugin.dll"           - "!:\sys\bin\HtiAudioServicePlugin.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiAudioServicePlugin.rsc"      - "!:\Resource\Plugins\HtiAudioServicePlugin.rsc"
+"\epoc32\release\armv5\urel\HtiMessagesServicePlugin.dll"        - "!:\sys\bin\HtiMessagesServicePlugin.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiMessagesServicePlugin.rsc"   - "!:\Resource\Plugins\HtiMessagesServicePlugin.rsc"
+"\epoc32\release\armv5\urel\HtiPIMServicePlugin.dll"             - "!:\sys\bin\HtiPIMServicePlugin.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiPIMServicePlugin.rsc"        - "!:\Resource\Plugins\HtiPIMServicePlugin.rsc"
+"\epoc32\release\armv5\urel\HtiIpProxyServicePlugin.dll"         - "!:\sys\bin\HtiIpProxyServicePlugin.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiIpProxyServicePlugin.rsc"    - "!:\Resource\Plugins\HtiIpProxyServicePlugin.rsc"
+
+; Helper to add notepad memos
+"\epoc32\release\armv5\urel\HtiNpdHlp.exe"                       - "!:\sys\bin\HtiNpdHlp.exe"
+
+; File helper with capability ALL - for file operations to TCB folders
+"\epoc32\release\armv5\urel\HtiFileHlp.exe"                      - "!:\sys\bin\HtiFileHlp.exe"
+
+; Backup fake DLL used by HtiFtpServicePlugin
+"\epoc32\release\armv5\urel\HtiFtpBackupFake.dll"                - "!:\sys\bin\HtiFtpBackupFake.dll"
+
+; HTI watchdog
+"\epoc32\release\armv5\urel\HtiWatchDog.exe"                     - "!:\sys\bin\HtiWatchDog.exe"
+
+; HTI device reboot
+"\epoc32\release\armv5\urel\HtiDeviceRebootUI.exe"               - "!:\sys\bin\HtiDeviceRebootUI.exe"
+
+; HTI Framework
+"\epoc32\release\armv5\urel\HTIFramework.exe"                    - "!:\sys\bin\HTIFramework.exe"
+
+; AutoStart recogniser plug-in
+"\epoc32\release\armv5\urel\HtiAutoStart.dll"                    - "!:\sys\bin\HtiAutoStart.dll"
+"\epoc32\data\Z\Resource\Plugins\HtiAutoStart.rsc"               - "!:\Resource\Plugins\HtiAutoStart.rsc"
+
+; HTI startup wait
+"\epoc32\release\armv5\urel\HtiStartupWait.dll"                  - "!:\sys\bin\HtiStartupWait.dll"
+
+; Startup list resource file for starting HTIFramework.exe in device boot
+"\epoc32\data\Z\private\101f875a\import\1020deb6.rsc"            - "c:\private\101f875a\import\[1020deb6].rsc"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/sis/HTI_stub.pkg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,108 @@
+;
+; 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: Installation file for HTI stub SIS
+
+
+; Languages
+&EN
+
+; Using UID of HtiFramework project
+#{"HTI"},(0x1020DEB6),2,15,0
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+; Install files
+
+; HtiCfg library
+""- "z:\sys\bin\HtiCfg.dll"
+
+; HtiAdmin
+""- "z:\sys\bin\HtiAdmin.exe"
+""- "z:\Resource\Apps\HtiAdmin.rsc"
+""- "z:\private\10003a3f\import\apps\HtiAdmin_reg.rsc"
+
+; Serial comm module
+""- "z:\Resource\Plugins\HtiSerialCommEcomPlugin.rsc"
+""- "z:\sys\bin\HtiSerialCommEcomPlugin.dll"
+
+; BtSerial comm module
+""- "z:\sys\bin\HtiBtSerialComHelper.dll"
+""- "z:\sys\bin\HtiBtCommServer.dll"
+""- "z:\sys\bin\HtiBtCommInterface.dll"
+""- "z:\Resource\Plugins\HtiBtCommEcomPlugin.rsc"
+""- "z:\sys\bin\HtiBtCommEcomPlugin.dll"
+
+; IPComm module
+""- "z:\sys\bin\HtiIPCommServer.exe"
+""- "z:\sys\bin\HtiIPCommServerClient.dll"
+""- "z:\Resource\Plugins\HtiIPCommEcomPlugin.rsc"
+""- "z:\sys\bin\HtiIPCommEcomPlugin.dll"
+
+; USB serial comm module
+""- "z:\Resource\Plugins\HtiUsbSerialCommEcomPlugin.rsc"
+""- "z:\sys\bin\HtiUsbSerialCommEcomPlugin.dll"
+
+; Test service plug-ins
+""- "z:\sys\bin\HtiEchoServicePlugin.dll"
+""- "z:\Resource\Plugins\HtiEchoServicePlugin.rsc"
+""- "z:\sys\bin\HtiKeyEventServicePlugin.dll"
+""- "z:\Resource\Plugins\HtiKeyEventServicePlugin.rsc"
+""- "z:\sys\bin\HtiScreenshotServicePlugin.dll"
+""- "z:\Resource\Plugins\HtiScreenshotServicePlugin.rsc"
+""- "z:\sys\bin\HtiFtpServicePlugin.dll"
+""- "z:\Resource\Plugins\HtiFtpServicePlugin.rsc"
+""- "z:\sys\bin\HtiAppServicePlugin.dll"
+""- "z:\Resource\Plugins\HtiAppServicePlugin.rsc"
+""- "z:\sys\bin\HtiAppControl.dll"
+""- "z:\sys\bin\HtiStifTfServicePlugin.dll"
+""- "z:\Resource\Plugins\HtiStifTfServicePlugin.rsc"
+""- "z:\sys\bin\HtiSysInfoServicePlugin.dll"
+""- "z:\Resource\Plugins\HtiSysInfoServicePlugin.rsc"
+""- "z:\sys\bin\HtiAudioServicePlugin.dll"
+""- "z:\Resource\Plugins\HtiAudioServicePlugin.rsc"
+""- "z:\sys\bin\HtiMessagesServicePlugin.dll"
+""- "z:\Resource\Plugins\HtiMessagesServicePlugin.rsc"
+""- "z:\sys\bin\HtiPIMServicePlugin.dll"
+""- "z:\Resource\Plugins\HtiPIMServicePlugin.rsc"
+""- "z:\sys\bin\HtiIpProxyServicePlugin.dll"
+""- "z:\Resource\Plugins\HtiIpProxyServicePlugin.rsc"
+
+; Helper to add notepad memos
+""- "z:\sys\bin\HtiNpdHlp.exe"
+
+; File helper with capability ALL - for file operations to TCB folders
+""- "z:\sys\bin\HtiFileHlp.exe"
+
+; Backup fake DLL used by HtiFtpServicePlugin
+""- "z:\sys\bin\HtiFtpBackupFake.dll"
+
+; HTI watchdog
+""- "z:\sys\bin\HtiWatchDog.exe"
+
+; HTI device reboot
+""- "z:\sys\bin\HtiDeviceRebootUI.exe"
+
+; HTI Framework
+""- "z:\sys\bin\HTIFramework.exe"
+
+; AutoStart recogniser plug-in
+""- "z:\sys\bin\HtiAutoStart.dll"
+""- "z:\Resource\Plugins\HtiAutoStart.rsc"
+
+; HTI startup wait
+""- "z:\sys\bin\HtiStartupWait.dll"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htiui/symbian_version.hrh	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,43 @@
+/*
+* 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: Symbian version configuration file 
+*
+*/
+
+#ifndef __SYMBIAN_VERSION_HRH
+#define __SYMBIAN_VERSION_HRH
+
+// S60 and Symbian version number enumeration definitions
+
+#define S60_30                                              30
+#define S60_31                                              31
+#define S60_32                                              32
+#define S60_50                                              50
+#define S60_51                                              91
+#define S60_52                                              92
+#define SYMBIAN_1                                           50
+#define SYMBIAN_2                                           91
+#define SYMBIAN_3                                           92
+#define SYMBIAN_4                                           101
+
+
+/**
+ * Defines the S60 or Symbian version used by this component. This flag can be
+ * used to variate the source code based on the SDK in use. The value of the
+ * flag should be always changed to reflect the current build environment.
+ */
+#define SYMBIAN_VERSION_SUPPORT                              SYMBIAN_3
+
+
+#endif  // __SYMBIAN_VERSION_HRH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/data/launcher.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,445 @@
+/*
+* 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 <AvkonIcons.hrh>
+
+#include "launcher.hrh"
+#include <data_caging_paths_strings.hrh>
+#include <appinfo.rh>
+#include <CommonDialogs.hrh> // Enumerations
+#include <CommonDialogs.rh> // Resource structures
+
+
+// ---------------------------------------------------------
+//   
+//    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_launcher_status_pane;
+    //menubar = r_launcher_menubar;
+    //cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
+    }
+
+
+//----------------------------------------------------
+//   
+//    r_launcher_hotkeys
+//
+//----------------------------------------------------
+//
+RESOURCE HOTKEYS r_launcher_hotkeys
+    {
+    control=
+        {
+        HOTKEY { command=EAknCmdExit; key='e'; }
+        };
+    }
+
+
+//----------------------------------------------------
+//   
+//    r_launcher_view1
+//
+//----------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_launcher_view1
+    {
+    hotkeys=r_launcher_hotkeys;
+    menubar=r_launcher_menubar_view1;  
+    cba=R_AVKON_SOFTKEYS_OPTIONS_EXIT;    
+    }
+
+//----------------------------------------------------
+//   
+//    r_launcher_menubar_view1
+//
+//----------------------------------------------------
+//
+RESOURCE MENU_BAR r_launcher_menubar_view1
+    {
+    titles=
+        {
+        MENU_TITLE { menu_pane=r_launcher_app_menu; txt="App"; },
+        MENU_TITLE { menu_pane=r_launcher_view1_menu; txt="View"; }
+        };
+    }
+
+//----------------------------------------------------
+//   
+//    r_launcher_view1_menu
+//
+//----------------------------------------------------
+//
+RESOURCE MENU_PANE r_launcher_view1_menu
+    {
+    items=
+        {
+        MENU_ITEM { command=ECmdLaunchApps; cascade=r_launcher_launchapps_submenu; txt="Launch apps"; },
+        MENU_ITEM { command=ECmdLaunchOptions; cascade=r_launcher_launchoptions_submenu; txt = "Launch options"; },
+        MENU_ITEM { command=ECmdRefreshList; txt = "Refresh list"; },
+        MENU_ITEM { command=EAknMarkAll; txt="Select all"; },
+        MENU_ITEM { command=EAknUnmarkAll; txt="Unselect all"; }
+        };
+    }
+
+RESOURCE MENU_PANE r_launcher_launchapps_submenu
+    {
+    items = 
+        {
+        MENU_ITEM { command=ECmdLaunchAppsWithAutoClose; txt="Autoclose"; },
+        MENU_ITEM { command=ECmdLaunchAppsWithoutAutoClose; txt="No autoclose"; }
+        };
+    }
+
+RESOURCE MENU_PANE r_launcher_launchoptions_submenu
+    {
+    items = 
+        {
+        MENU_ITEM { command=ECmdSkipHiddenAndEmbedOnly; txt="Skip hidden & embed"; flags = EEikMenuItemRadioStart | EEikMenuItemSymbolOn; },
+        MENU_ITEM { command=ECmdDoNotSkipAnyFiles; txt="Do not skip any entries"; flags = EEikMenuItemRadioEnd; }
+        };
+    }
+
+//----------------------------------------------------
+//   
+//    r_launcher_view2
+//
+//----------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_launcher_view2
+    {
+    hotkeys=r_launcher_hotkeys;
+    menubar=r_launcher_menubar_view2;  
+    cba=R_AVKON_SOFTKEYS_OPTIONS_EXIT; 
+    }
+
+//----------------------------------------------------
+//   
+//    r_launcher_menubar_view2
+//
+//----------------------------------------------------
+//
+RESOURCE MENU_BAR r_launcher_menubar_view2
+    {
+    titles=
+        {
+        MENU_TITLE { menu_pane=r_launcher_app_menu; txt="App"; },
+        MENU_TITLE { menu_pane=r_launcher_view2_menu; txt="View"; }
+        };
+    }
+
+//----------------------------------------------------
+//   
+//    r_launcher_view2_menu
+//    ?description
+//
+//----------------------------------------------------
+//
+RESOURCE MENU_PANE r_launcher_view2_menu
+    {
+    items=
+        {
+        MENU_ITEM { command=ECmdClearWindow; txt = "Clear window"; }
+        };
+    }
+
+//----------------------------------------------------
+//   
+//    r_launcher_view3
+//
+//----------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_launcher_view3
+    {
+    hotkeys=r_launcher_hotkeys;     
+    cba=R_AVKON_SOFTKEYS_QUIT; 
+    }
+
+
+//----------------------------------------------------
+//   
+//    r_launcher_app_menu
+//
+//----------------------------------------------------
+//
+
+RESOURCE MENU_PANE r_launcher_app_menu
+    {
+    items=
+        {
+        MENU_ITEM { command=ECmdDLLInfo; cascade=r_launcher_dllinfo_submenu; txt = "DLL info"; },
+        MENU_ITEM { command=ECmdStopLaunch; txt = "Stop launch"; },
+        MENU_ITEM { command=ECmdDeleteLog; txt = "Delete log(s)"; },
+        MENU_ITEM { command=ECmdAbout; txt = "About"; },
+        MENU_ITEM { command=EAknCmdExit; txt="Exit"; }
+        };
+    }
+
+RESOURCE MENU_PANE r_launcher_dllinfo_submenu
+    {
+    items = 
+        {        
+        MENU_ITEM { command=ECmdCompareDLLs; txt="DLL BC Analysis"; }
+        };
+    }
+        
+//----------------------------------------------------
+    
+RESOURCE STATUS_PANE_APP_MODEL r_launcher_status_pane
+    {
+	panes=
+		{
+		SPANE_PANE
+			{
+			id = EEikStatusPaneUidNavi;
+			type = EAknCtNaviPane;
+			resource = r_launcher_navi_decorator;
+			}
+		};
+    }
+
+//----------------------------------------------------
+//   
+//    r_launcher_navi_decorator
+//    ?description
+//
+//----------------------------------------------------
+//
+RESOURCE NAVI_DECORATOR r_launcher_navi_decorator
+    {
+    type = ENaviDecoratorControlTabGroup;
+    control = TAB_GROUP
+		{
+		tab_width = EAknTabWidthWithTwoTabs;
+		active = 0;
+		tabs = {
+			TAB
+				{
+                id = ELauncherView1Tab;
+                txt = "Apps";
+                },
+			TAB
+				{
+                id = ELauncherView2Tab;
+                txt = "Out";
+				}
+			};
+		};
+	}
+
+
+// ---------------------------------------------------------
+//   
+//   r_launcher_about_dialog
+//   About dialog - show version and copyright info etc.
+//
+// ---------------------------------------------------------
+//
+
+RESOURCE DIALOG r_launcher_about_dialog
+{
+    flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow;
+    buttons = R_AVKON_SOFTKEYS_OK_EMPTY;
+    items=
+    {
+        DLG_LINE
+        {
+            type = EAknCtPopupHeadingPane;
+            id = EAknMessageQueryHeaderId;
+            control = AVKON_HEADING
+            {
+                label = "About Launcher";
+                headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE;
+            };
+        },
+        DLG_LINE
+        {
+            type = EAknCtMessageQuery;
+            id = EAknMessageQueryContentId;
+            control = AVKON_MESSAGE_QUERY
+            {
+                message = "Version 3.7.0 - 29th May 2009. Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0.";
+            };
+        }
+    };
+}
+
+// ---------------------------------------------------------
+//   
+//   r_yes_no_dialog
+//   
+//
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_yes_no_dialog
+ {
+ flags = EGeneralQueryFlags;
+ buttons = R_AVKON_SOFTKEYS_YES_NO;
+ items =
+   {
+   DLG_LINE
+     {
+     type = EAknCtQuery;
+     id = EYesNoQuery;
+     control = AVKON_CONFIRMATION_QUERY
+       {
+       layout = EConfirmationQueryLayout;
+       label = "";
+       };
+     }
+   };
+ }
+
+// ---------------------------------------------------------
+//   
+//   r_general_progress_note
+//   
+//
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_general_progress_note
+    {
+    flags = EAknProgressNoteFlags;
+    buttons = R_AVKON_SOFTKEYS_CANCEL;
+    items=
+        {
+        DLG_LINE
+            {
+            type = EAknCtNote;
+            id = EProgressNote;
+            control = AVKON_NOTE
+                {
+                layout = EProgressLayout;
+                singular_label = "Analysing DLLs";
+                };
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+//   
+//   r_general_wait_note
+//   
+//
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_general_wait_note
+    {
+    flags = EAknWaitNoteFlags | EEikDialogFlagNotifyEsc;
+    buttons = R_AVKON_SOFTKEYS_CANCEL;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtNote;
+            id = EWaitNote;
+            control= AVKON_NOTE 
+                { 
+                layout = EWaitLayout;
+                animation = R_QGN_GRAF_WAIT_BAR_ANIM;
+                };
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+//   
+//   r_memory_selection_dialog
+//   
+//
+// ---------------------------------------------------------
+//
+RESOURCE MEMORYSELECTIONDIALOG r_memory_selection_dialog
+{
+title = "Choose memory:";
+}
+
+// ---------------------------------------------------------
+//   
+//   r_file_selection_dialog
+//   
+//
+// ---------------------------------------------------------
+//
+RESOURCE FILESELECTIONDIALOG r_file_selection_dialog
+{
+title = "Select input file:";
+//root_path = "C:\\Data\\";
+filters =
+{
+FILTER
+{
+filter_type = EAttributeFilter;
+filter_style = EExclusiveFilter;
+filter_data = { "SH", "R" }; // Excludes system, hidden and read-only attributes
+}
+};
+}
+
+// ---------------------------------------------------------
+//   
+//    New framework:
+//    Secure platform and scalable UI changes 
+//
+// ---------------------------------------------------------
+//
+RESOURCE LOCALISABLE_APP_INFO r_launcher_localisable_app_info
+    {
+    short_caption = "Launcher";
+    caption_and_icon = 
+    CAPTION_AND_ICON_INFO
+        {
+        caption = "Launcher";
+
+        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"\\launcher_aif.mif";
+        };
+    }
+  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/data/launcher_reg.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,35 @@
+/*
+* 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 <launcher.rsg>
+#include <appinfo.rh>
+#include <data_caging_paths_strings.hrh>
+
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0x101FB74F
+
+
+
+RESOURCE APP_REGISTRATION_INFO
+    {
+    app_file = "Launcher";
+    localisable_resource_file = APP_RESOURCE_DIR"\\Launcher";
+    localisable_resource_id = R_LAUNCHER_LOCALISABLE_APP_INFO;
+    group_name = "RnD Tools";
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/envpatcher/EnvPatcher.pl	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,544 @@
+#
+# 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;    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/envpatcher/ReadMe.txt	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,46 @@
+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".
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/group/ReleaseNotes_Launcher.txt	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,132 @@
+===============================================================================
+
+RELEASE NOTES - LAUNCHER v3.7.0
+RELEASED 29th May 2009 
+
+SUPPORTS S60 3.0+
+
+===============================================================================
+
+Product Description:
+====================
+Launcher is a testing utility application aimed to help test the launching of
+applications installed in the system, both on user side disk drives and on
+ROM. Launcher tests if an application can be launched and then, if the launch
+has failed, reports the possible reason for the failure. It is a very useful
+application when checking the build as the user can instantly see if the
+applications work. Launcher can also be used when testing binary
+compatibility issues because it can reveal any DLL files missing from the
+device.
+
+Main Features:
+==============
+- Show a list of installed applications in all drives
+- Launch selected applications and read their statuses from threads
+- In case of a failure, report thread's exit type, reason and category
+- Show missing DLL files required by the binary to be launched
+- Show problems on the UI and print all cases to a log file
+- Generate a list of DLLs in the device to a file
+- Analyse binary compatibility of system DLLs comparing them to a user
+  given reference data. Report any binary compatibility issues or missing
+  DLL files.
+
+===============================================================================
+
+What's New in v3.7.0
+====================
+- Feature: Binary compatiblity check for DLLs, which checks UID1, UID2, UID3, SID
+and capability values of system DLLs against an XML-formatted input file.
+- Fix: Launcher panics when comparing a large DLL list against system DLLs.
+- Fix: Launcher panics when application launching is cancelled.
+
+===============================================================================
+
+Installation Notes:
+===================
+Launcher is typically preinstalled on ROM. If not, it can be added to the
+ROM with the .iby file. Alternatively, a .sis file can be found under the sis-
+directory, but the user needs 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:
+  PowerMgmt
+  ReadDeviceData
+  WriteDeviceData
+  AllFiles
+  ReadUserData
+  WriteUserData
+
+When building Launcher 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:
+=============
+
+Fails in a test despite the application is working correctly
+------------------------------------------------------------
+- Some application may exit immediately after a launch. This can be
+  normal behavior and should be checked manually. Such application is, for example, 
+  irapp.exe.
+  
+Binary compatibility check support
+----------------------------------
+- Currently, only uncompressed and deflate compressed ELF binaries are
+  supported. This means that for example WINSCW is not supported.
+
+===============================================================================
+
+Version History:
+================
+
+Version 3.6.3 - 14th March 2008
+-------------------------------
+- Change: Removed unnecessary capabilities
+
+Version 3.6.2 - 6th November 2007
+--------------------------------
+- Fix: Applications can be selected/unselected on a touch UI
+- Fix: Scroll bar in the output view can be scrolled on a touch UI
+
+Version 3.6.1 - 9th October 2007
+--------------------------------
+- Fix: Layout in out tab in mirrored mode
+- Fix: Codescanner high warnings
+
+Version 3.6.0 - 25th January 2007
+---------------------------------
+- Fix: Re-fix problems when reading import section from binaries
+- Fix: Output screen for larger resolutions
+- Fix: Stopping of launching
+
+Version 3.5.0 - 4th December 2006
+---------------------------------
+- Fix: Problems when reading import section from binaries
+- Change: Marquee used for items in the application list view
+
+===============================================================================
+
+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".
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/group/backup_registration.xml	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,8 @@
+<?xml version="1.0" standalone="yes"?>
+<backup_registration>
+  <passive_backup>
+    <include_directory name="\"/>
+  </passive_backup>
+  <system_backup/>
+  <restore requires_reboot = "no"/>
+</backup_registration>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,52 @@
+/*
+* 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/101fb74f/backup_registration.xml
+../rom/Launcher.iby CORE_IBY_EXPORT_PATH(tools,Launcher.iby)
+
+
+PRJ_MMPFILES
+#if defined(__SERIES60_30__) || defined(__SERIES60_31__) || defined(__S60_32__)
+  gnumakefile launcher_icons_aif.mk
+
+  #ifdef MARM
+  gnumakefile launcher_stub_sis.mk
+  #endif
+#endif
+
+launcher.mmp
+
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)
+  PRJ_EXTENSIONS
+  START EXTENSION s60/mifconv
+  OPTION TARGETFILE launcher_aif.mif
+  OPTION SOURCEDIR ../icons
+  OPTION SOURCES -c8,8 qgn_menu_launcher
+  END
+
+  #ifdef MARM
+  START EXTENSION app-services/buildstubsis
+  OPTION SRCDIR ../sis
+  OPTION SISNAME Launcher_stub
+  END
+  #endif  
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/group/launcher.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,92 @@
+/*
+* 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            Launcher.exe
+TARGETTYPE        exe
+EPOCSTACKSIZE     0x5000
+EPOCHEAPSIZE      0x10000 0x1000000  // Min 64Kb, Max 16Mb
+
+UID               0x100039CE 0x101FB74F
+
+VENDORID          VID_DEFAULT
+CAPABILITY        ReadUserData ReadDeviceData WriteUserData WriteDeviceData PowerMgmt AllFiles
+
+SMPSAFE
+
+LANG              SC
+
+
+START RESOURCE    ../data/launcher.rss
+HEADER
+TARGETPATH        APP_RESOURCE_DIR
+END
+
+START RESOURCE    ../data/launcher_reg.rss
+DEPENDS           launcher.rsg
+TARGETPATH        /private/10003a3f/apps
+END
+
+APP_LAYER_SYSTEMINCLUDE
+USERINCLUDE       ../inc
+SOURCEPATH        ../src
+
+
+SOURCE            launcher.cpp
+SOURCE            launcherapplication.cpp 
+SOURCE            launcherdocument.cpp
+SOURCE            launcherappui.cpp
+SOURCE            launcherviewapps.cpp
+SOURCE            launcherviewoutput.cpp
+SOURCE            launchercontaineroutput.cpp
+SOURCE            launchercontainerapps.cpp
+SOURCE            launcherengine.cpp
+SOURCE            e32image.cpp 
+SOURCE			  launcherxmlparser.cpp 
+SOURCE            launcherdllelement.cpp
+SOURCE            launcherdllparser.cpp
+
+LIBRARY           euser.lib
+LIBRARY           apparc.lib
+LIBRARY           cone.lib 
+LIBRARY           eikcore.lib  
+LIBRARY           avkon.lib 
+LIBRARY           efsrv.lib
+LIBRARY           apgrfx.lib
+LIBRARY           ws32.lib
+LIBRARY           bafl.lib
+LIBRARY           eikcoctl.lib
+LIBRARY           eikctl.lib
+LIBRARY           aknnotify.lib 
+LIBRARY           sendui.lib 
+LIBRARY           egul.lib
+LIBRARY           aknicon.lib
+LIBRARY           flogger.lib
+LIBRARY           platformenv.lib
+LIBRARY           aknskins.lib
+LIBRARY           aknskinsrv.lib
+LIBRARY           aknswallpaperutils.lib
+LIBRARY           gdi.lib
+LIBRARY 	      xmlframework.lib
+LIBRARY           charconv.lib
+LIBRARY           commondialogs.lib
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/group/launcher_icons_aif.mk	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,54 @@
+#
+# 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:  
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z
+else
+ZDIR=\epoc32\data\z
+endif
+
+TARGETDIR=$(ZDIR)\resource\apps
+ICONTARGETFILENAME=$(TARGETDIR)\launcher_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_launcher.svg
+	mifconv $(ICONTARGETFILENAME) \
+		/c8,8 ..\icons\qgn_menu_launcher.svg
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/group/launcher_stub_sis.mk	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,56 @@
+#
+# 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:  
+#
+
+
+TARGETDIR=$(EPOCROOT)EPOC32\Data\Z\System\Install
+
+SISNAME=Launcher_stub
+PKGNAME=Launcher_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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/icons/qgn_menu_launcher.svg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg baseProfile="tiny" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%" viewBox="0 0 88 88">
+	<defs>
+		<linearGradient id="linearGradient17394" x1="0%" y1="0%" x2="100%"
+			y2="66.6667%" spreadMethod="pad" gradientUnits="objectBoundingBox">
+			<stop id="stop17396" style="stop-opacity:1;stop-color:rgb(242,255,86)"
+				offset="0"/>
+			<stop id="stop17398" style="stop-opacity:1;stop-color:rgb(212,230,7)"
+				offset="1"/>
+		</linearGradient>
+		<linearGradient id="linearGradient17400_1" x1="36.5869" y1="-20.085"
+			x2="117.956" y2="59.4589" xlink:href="#linearGradient17394"
+			gradientUnits="userSpaceOnUse"
+			gradientTransform="matrix(0.53761 0 0 0.926099 1.6227 25.866)">
+		</linearGradient>
+		<linearGradient x1="36.5869" y1="-20.085" x2="117.956" y2="59.4589"
+			xlink:href="#linearGradient17394" gradientUnits="userSpaceOnUse"
+			gradientTransform="matrix(0.53761 0 0 0.926099 1.6227 25.866)">
+		</linearGradient>
+	</defs>
+	<g>
+		<linearGradient id="XMLID_7_" gradientUnits="userSpaceOnUse" x1="30.5986"
+			y1="26.9722" x2="53.4647" y2="54.4606">
+			<stop offset="0" style="stop-opacity:0;stop-color:rgb(255,128,128)"/>
+			<stop offset="1" style="stop-opacity:0;stop-color:rgb(8,66,150)"/>
+		</linearGradient>
+		<linearGradient id="XMLID_8_" gradientUnits="userSpaceOnUse" x1="37.7549"
+			y1="20.2007" x2="60.648" y2="20.2007">
+			<stop offset="0" style="stop-color:rgb(0,92,254)"/>
+			<stop offset="1" style="stop-color:rgb(0,92,230)"/>
+		</linearGradient>
+		<path
+			d="M21.184 21.318 C31.419 9.612 43.98 7.844 53.009 9.984 C62.034 12.124 71.898 19.381
+				72.456 31.2 C67.843 23.4 57.101 19.847 50.403 21.056 C43.972 22.217 38.445
+				25.849 36.84 28.571 C31.699 30.642 23.047 27.536 21.184 21.318 z"
+			 style="fill:url(#XMLID_8_)"/>
+		<polygon points="59.157,31.968 66.832,43.086 78.696,41.706 70.564,31.787"
+			 style="fill:rgb(255,0,0)"/>
+		<radialGradient id="XMLID_10_" cx="-48.0791" cy="39.3374" r="10.3877"
+			fx="-48.0791" fy="39.3374"
+			gradientTransform="matrix(1.0025 0.1408 -0.2587 0.9612 82.2902 3.6922)"
+			gradientUnits="userSpaceOnUse">
+			<stop offset="0" style="stop-color:rgb(194,249,143)"/>
+			<stop offset="1" style="stop-color:rgb(23,139,0)"/>
+		</radialGradient>
+		<path
+			d="M31.926 40.793 C30.315 46.775 23.949 50.912 17.711 50.035 C11.472 49.159 7.714 43.602
+				9.325 37.62 C10.934 31.635 17.301 27.494 23.542 28.368 C29.778 29.244 33.534
+				34.808 31.926 40.793 z"
+			 style="fill:url(#XMLID_10_)"/>
+		<linearGradient id="XMLID_12_" gradientUnits="userSpaceOnUse" x1="37.165"
+			y1="24.022" x2="59.6654" y2="24.022">
+			<stop offset="0" style="stop-color:rgb(81,140,247)"/>
+			<stop offset="1" style="stop-color:rgb(51,102,204)"/>
+		</linearGradient>
+		<path
+			d="M29.906 28.778 C34.77 22.174 43.702 16.404 52.82 16.87 C61.941 17.335 70.128 24.313
+				72.456 31.2 C67.245 24.313 59.706 20.871 53.194 20.965 C47.69 21.043 40.539
+				24.128 36.84 28.571 C34.77 29.432 30.536 29.147 29.906 28.778 z"
+			 style="fill:url(#XMLID_12_)"/>
+		<path id="path19050"
+			d="M40.8495 45.7047 L45.6374 42.2346 L41.7423 36.4286 L43.6873 42.0156 z"
+			 style="stroke-opacity:1;stroke-miterlimit:4;stroke-linejoin:miter;stroke-linecap:butt;stroke-width:0;
+			fill-rule:evenodd;fill:rgb(255,0,0)"
+			transform="matrix(1 0 0 1 0 0) translate(-10.5 -11) translate(45.717 45.6311) scale(1.22417 1.22417) translate(-45.717 -45.6311) translate(40.563 41.1383) scale(0.876322 1) translate(-40.563 -41.1383) translate(46.0671 41.1383) scale(1.16936 1) translate(-46.0671 -41.1383) translate(46.0671 35.7119) scale(0.879308 0.962365) translate(-46.0671 -35.7119) translate(46.0671 46.5647) scale(1.10981 0.986965) translate(-46.0671 -46.5647) translate(40.563 41.1383) scale(0.950529 1) translate(-40.563 -41.1383)"
+			/>
+		<path id="path17526"
+			d="M47.4959 34.1139 L42.1697 41.213 L48.3432 46.4067 L44.6166 41.0903 z"
+			 style="stroke-opacity:1;stroke-miterlimit:4;stroke-linejoin:miter;stroke-linecap:butt;stroke-width:0;
+			fill-rule:evenodd;fill:rgb(255,0,0)"
+			transform="matrix(1 0 0 1 0 0) translate(5 -1) translate(48.5099 40.0936) scale(0.860598 1) translate(-48.5099 -40.0936) translate(41.3364 40.0936) scale(1.16198 1) translate(-41.3364 -40.0936)"
+			/>
+		<path id="path18288"
+			d="M45.0758 39.3423 L41.8151 46.0623 L43.0468 39.5597 L40.012 34.2418 z"
+			 style="stroke-opacity:1;stroke-miterlimit:4;stroke-linejoin:miter;stroke-linecap:butt;stroke-width:0;
+			fill-rule:evenodd;fill:rgb(255,0,0)"
+			transform="matrix(1 0 0 1 0 0) translate(-10.3333 9.83333) translate(39.1149 40.4273) scale(0.857902 1) translate(-39.1149 -40.4273) translate(46.1523 47.7134) scale(1.08282 0.908502) translate(-46.1523 -47.7134)"
+			/>
+		<path id="path16634"
+			d="M22.0745 5.81657 L37.3876 30.5355 L27.8687 39.6137 L37.3876 49.4575 L30.9727 61.5982
+				L66.2549 82.3796 L48.0447 60.0669 L56.3221 50.5512 L44.5268 40.7074 L53.6319
+				28.2386 z"
+			 style="fill-opacity:1;fill-rule:evenodd;stroke-linecap:butt;stroke-linejoin:miter;stroke-width:0.705606px;
+			stroke:rgb(0,0,0);fill:url(#linearGradient17394)"
+			transform="matrix(1 0 0 1 0 0)"/>
+		<linearGradient id="XMLID_9_" gradientUnits="userSpaceOnUse" x1="49.4912"
+			y1="61.1475" x2="28.1645" y2="61.1475">
+			<stop offset="0" style="stop-color:rgb(0,86,228)"/>
+			<stop offset="1" style="stop-color:rgb(0,67,206)"/>
+		</linearGradient>
+		<path
+			d="M11.744 50.158 C12.907 61.196 21.379 70.149 33.682 71.877 C45.074 73.476 57.106 67.547
+				64.156 58.925 L54.005 62.075 L48.376 52.774 C38.759 60.212 17.646 66.188
+				11.744 50.158 z"
+			 style="fill:url(#XMLID_9_)"/>
+		<linearGradient id="XMLID_11_" gradientUnits="userSpaceOnUse" x1="49.1025"
+			y1="59.4443" x2="20.5393" y2="59.4443">
+			<stop offset="0" style="stop-color:rgb(99,147,244)"/>
+			<stop offset="1" style="stop-color:rgb(72,133,254)"/>
+		</linearGradient>
+		<polygon points="47.515,51.789 54.005,62.075 64.156,58.925 57.456,49.496"
+			 style="fill:rgb(77,136,255)"/>
+		<path
+			d="M54.005 62.075 C42.815 72.325 14.88 74.004 11.602 49.722 C16.285 59.661 35.918 64.892
+				47.763 51.583 z"
+			 style="fill:url(#XMLID_11_)"/>
+		<polygon points="58.778,54.839 69.851,53.393 78.73,41.72 66.832,43.086"
+			 style="fill:rgb(153,0,0)"/>
+		<polygon points="58.778,54.839 51.896,44.684 59.119,31.944 67.085,43.071"
+			 style="fill:rgb(255,102,153)"/>
+	</g>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/inc/e32image.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  
+*
+*/
+
+
+
+#ifndef __LAUNCHERE32IMAGE_H__
+#define __LAUNCHERE32IMAGE_H__
+
+#include <e32base.h>
+#include <badesca.h>
+#include <eikenv.h>
+
+class E32ImageHeader;
+class E32ImportSection;
+class E32RelocSection;
+class CEikonEnv;
+
+
+NONSHARABLE_CLASS(E32ImageReader) : public CBase, public TProcessCreateInfo
+	{
+public:
+	static E32ImageReader* NewLC();
+	~E32ImageReader();
+
+public:
+    CDesCArray* ListOfDLLsL(const TDesC& aFullPathToE32Image);
+
+private:
+	E32ImageReader();
+	void ConstructL();
+    TInt LoadData();
+    static TUint8* MemoryMove(TAny* aDestination, const TAny* aSource, TInt aNumberofBytes);
+    TInt LoadFile(TUint32 aCompression);
+    TInt LoadFileNoCompress();
+    void LoadFileInflateL();
+    TInt Read(TText8* aDest, TInt aSize);
+    TInt Read(TInt aPos, TText8* aDest, TInt aSize);
+    TInt ReadImportData();
+
+private:
+	CEikonEnv*      iEnv;
+
+public:
+	E32ImageHeader* iHeader;
+	E32ImportSection* iImportSection;
+	E32RelocSection* iCodeRelocSection;
+	E32RelocSection* iDataRelocSection;
+	TUint32* iImportData;
+	TUint8* iRestOfFileData;
+	TUint32 iRestOfFileSize;
+	TUint32 iConversionOffset;
+	RFile iFile;
+	TUint32 iCodeDelta;
+	TUint32 iDataDelta;
+	TUint32 iExportDirLoad;
+	TBool isDll;
+	TBool iAlreadyLoaded;
+	TAny* iCloseCodeSeg;
+	TInt iCurrentImportCount;
+	TInt iNextImportPos;
+	TUint32* iCurrentImportList;
+	TUint8 iCurrentImportListSorted;
+	TUint8 iExportDirLoadAllocated;
+	TUint8 iPadding1;
+	TUint8 iPadding2;
+	};
+
+#endif // __LAUNCHERE32IMAGE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/inc/e32imageheaders.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,534 @@
+/*
+* 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 __LAUNCHERE32IMAGEHEADERS_H__
+#define __LAUNCHERE32IMAGEHEADERS_H__
+
+#include <e32uid.h>
+
+/** Bit output stream.
+	Good for writing bit streams for packed, compressed or huffman data algorithms.
+
+	This class must be derived from and OverflowL() reimplemented if the bitstream data
+	cannot be generated into a single memory buffer.
+*/
+class TBitOutput
+	{
+public:
+	IMPORT_C TBitOutput();
+	IMPORT_C TBitOutput(TUint8* aBuf,TInt aSize);
+	inline void Set(TUint8* aBuf,TInt aSize);
+	inline const TUint8* Ptr() const;
+	inline TInt BufferedBits() const;
+//
+	IMPORT_C void WriteL(TUint aValue, TInt aLength);
+	IMPORT_C void HuffmanL(TUint aHuffCode);
+	IMPORT_C void PadL(TUint aPadding);
+private:
+	void DoWriteL(TUint aBits, TInt aSize);
+	virtual void OverflowL();
+private:
+	TUint iCode;		// code in production
+	TInt iBits;
+	TUint8* iPtr;
+	TUint8* iEnd;
+	};
+
+/** Set the memory buffer to use for output
+
+	Data will be written to this buffer until it is full, at which point OverflowL() will
+	be called. This should handle the data and then can Set() again to reset the buffer
+	for further output.
+	
+	@param aBuf The buffer for output
+	@param aSize The size of the buffer in bytes
+*/
+inline void TBitOutput::Set(TUint8* aBuf,TInt aSize)
+	{iPtr=aBuf;iEnd=aBuf+aSize;}
+	
+/** Get the current write position in the output buffer
+
+	In conjunction with the address of the buffer, which should be known to the
+	caller, this describes the data in the bitstream.
+*/
+inline const TUint8* TBitOutput::Ptr() const
+	{return iPtr;}
+	
+/** Get the number of bits that are buffered
+
+	This reports the number of bits that have not yet been written into the
+	output buffer. It will always lie in the range 0..7. Use PadL() to
+	pad the data out to the next byte and write it to the buffer.
+*/
+inline TInt TBitOutput::BufferedBits() const
+	{return iBits+8;}
+
+
+/** Bit input stream. Good for reading bit streams for packed, compressed or huffman
+	data algorithms.
+*/
+class TBitInput
+	{
+public:
+	IMPORT_C TBitInput();
+	IMPORT_C TBitInput(const TUint8* aPtr, TInt aLength, TInt aOffset=0);
+	IMPORT_C void Set(const TUint8* aPtr, TInt aLength, TInt aOffset=0);
+//
+	IMPORT_C TUint ReadL();
+	IMPORT_C TUint ReadL(TInt aSize);
+	IMPORT_C TUint HuffmanL(const TUint32* aTree);
+private:
+	virtual void UnderflowL();
+private:
+	TInt iCount;
+	TUint iBits;
+	TInt iRemain;
+	const TUint32* iPtr;
+	};
+
+/** Huffman code toolkit.
+
+	This class builds a huffman encoding from a frequency table and builds
+	a decoding tree from a code-lengths table
+
+	The encoding generated is based on the rule that given two symbols s1 and s2, with 
+	code length l1 and l2, and huffman codes h1 and h2:
+
+		if l1<l2 then h1<h2 when compared lexicographically
+		if l1==l2 and s1<s2 then h1<h2 ditto
+
+	This allows the encoding to be stored compactly as a table of code lengths
+*/
+class Huffman
+	{
+public:
+	enum {KMaxCodeLength=27};
+	enum {KMetaCodes=KMaxCodeLength+1};
+	enum {KMaxCodes=0x8000};
+public:
+	IMPORT_C static void HuffmanL(const TUint32 aFrequency[],TInt aNumCodes,TUint32 aHuffman[]);
+	IMPORT_C static void Encoding(const TUint32 aHuffman[],TInt aNumCodes,TUint32 aEncodeTable[]);
+	IMPORT_C static void Decoding(const TUint32 aHuffman[],TInt aNumCodes,TUint32 aDecodeTree[],TInt aSymbolBase=0);
+	IMPORT_C static TBool IsValid(const TUint32 aHuffman[],TInt aNumCodes);
+//
+	IMPORT_C static void ExternalizeL(TBitOutput& aOutput,const TUint32 aHuffman[],TInt aNumCodes);
+	IMPORT_C static void InternalizeL(TBitInput& aInput,TUint32 aHuffman[],TInt aNumCodes);
+	};
+
+
+enum TCpu
+	{
+	ECpuUnknown=0, ECpuX86=0x1000, ECpuArmV4=0x2000, ECpuArmV5=0x2001, ECpuArmV6=0x2002, ECpuMCore=0x4000
+	};
+	
+const TInt KOrdinalBase=1;
+const TUint KImageDll				= 0x00000001u;
+const TUint KImageNoCallEntryPoint	= 0x00000002u;
+const TUint KImageFixedAddressExe	= 0x00000004u;
+const TUint KImageOldJFlag			= 0x00000008u;	// so we can run binaries built with pre 2.00 tools (hdrfmt=0)
+const TUint KImageOldElfFlag		= 0x00000010u;	// so we can run binaries built with pre 2.00 tools (hdrfmt=0)
+const TUint KImageABIMask			= 0x00000018u;	// only if hdr fmt not zero
+const TInt	KImageABIShift			= 3;
+const TUint	KImageABI_GCC98r2		= 0x00000000u;	// for ARM
+const TUint	KImageABI_EABI			= 0x00000008u;	// for ARM
+const TUint KImageEptMask			= 0x000000e0u;	// entry point type
+const TInt	KImageEptShift			= 5;
+const TUint KImageEpt_Eka1			= 0x00000000u;
+const TUint KImageEpt_Eka2			= 0x00000020u;
+const TUint KImageHdrFmtMask		= 0x0f000000u;
+const TInt	KImageHdrFmtShift		= 24;
+const TUint KImageHdrFmt_Original	= 0x00000000u;	// without compression support
+const TUint KImageHdrFmt_J			= 0x01000000u;	// with compression support
+const TUint KImageHdrFmt_V			= 0x02000000u;	// with versioning support
+const TUint KImageImpFmtMask		= 0xf0000000u;
+const TInt	KImageImpFmtShift		= 28;
+const TUint KImageImpFmt_PE			= 0x00000000u;	// PE-derived imports
+const TUint KImageImpFmt_ELF		= 0x10000000u;	// ELF-derived imports
+const TUint KImageImpFmt_PE2		= 0x20000000u;	// PE-derived imports without redundant copy of import ordinals
+const TUint KImageHWFloatMask		= 0x00f00000u;
+const TInt	KImageHWFloatShift		= 20;
+const TUint	KImageHWFloat_None		= EFpTypeNone << KImageHWFloatShift; // No hardware floating point used
+const TUint KImageHWFloat_VFPv2		= EFpTypeVFPv2 << KImageHWFloatShift; // ARM VFPv2 floating point used
+
+const TUint KMyFormatNotCompressed=0;
+const TUint KMyUidCompressionDeflate=0x101F7AFC;
+
+const TUint32 KImageCrcInitialiser	= 0xc90fdaa2u;
+/*
+const TUint16 KReservedRelocType        = (TUint16)0x0000;
+const TUint16 KTextRelocType            = (TUint16)0x1000;
+const TUint16 KDataRelocType            = (TUint16)0x2000;
+const TUint16 KInferredRelocType        = (TUint16)0x3000;
+*/
+class RFile;
+class E32ImageHeader
+	{
+public:
+	inline static TUint ABIFromFlags(TUint aFlags)
+		{
+		if (aFlags&KImageHdrFmtMask)
+			return aFlags & KImageABIMask;
+		if (aFlags&KImageOldElfFlag)
+			return KImageABI_EABI;
+		return KImageABI_GCC98r2;
+		}
+	inline static TUint EptFromFlags(TUint aFlags)
+		{
+		if (aFlags&KImageHdrFmtMask)
+			return aFlags & KImageEptMask;
+		if (aFlags&KImageOldJFlag)
+			return KImageEpt_Eka2;
+		return KImageEpt_Eka1;
+		}
+	inline static TUint HdrFmtFromFlags(TUint aFlags)
+		{
+		if (aFlags&KImageHdrFmtMask)
+			return aFlags & KImageHdrFmtMask;
+		if (aFlags&KImageOldJFlag)
+			return KImageHdrFmt_J;
+		return KImageHdrFmt_Original;
+		}
+	inline static TUint ImpFmtFromFlags(TUint aFlags)
+		{
+		if (aFlags&KImageHdrFmtMask)
+			return aFlags & KImageImpFmtMask;
+		if (aFlags&KImageOldElfFlag)
+			return KImageImpFmt_ELF;
+		return KImageImpFmt_PE;
+		}
+	inline TUint32 CompressionType() const
+		{
+		if (HdrFmtFromFlags(iFlags) >= KImageHdrFmt_J)
+			return iCompressionType;
+		return 0;
+		}
+	inline TUint32 ModuleVersion() const
+		{
+		if ((iFlags & KImageHdrFmtMask) >= KImageHdrFmt_V)
+			return iModuleVersion;
+		return 0x00000000u;
+		}
+	inline TInt TotalSize() const;
+	inline TInt UncompressedFileSize() const;
+	inline TUint HeaderFormat() const
+		{ return HdrFmtFromFlags(iFlags); }
+	inline TUint EntryPointFormat() const
+		{ return EptFromFlags(iFlags); }
+	inline TUint ImportFormat() const
+		{ return ImpFmtFromFlags(iFlags); }
+	inline TUint ABI() const
+		{ return ABIFromFlags(iFlags); }
+	inline void GetSecurityInfo(SSecurityInfo& aInfo) const;
+	inline TCpu CpuIdentifier() const;
+	inline TProcessPriority ProcessPriority() const;
+	inline TUint32 ExceptionDescriptor() const;
+	TInt IntegrityCheck(TInt aFileSize);
+	static TInt New(E32ImageHeader*& aHdr, RFile& aFile);
+public:
+	TUint32	iUid1;
+	TUint32	iUid2;
+	TUint32	iUid3;
+	TUint32 iUidChecksum;
+	TUint iSignature;			// 'EPOC'
+	TUint32	iHeaderCrc;			// CRC-32 of entire header
+	TUint32 iModuleVersion;		// Version number for this executable (used in link resolution)
+	TUint32 iCompressionType;	// Type of compression used (UID or 0 for none)
+	TVersion iToolsVersion;		// Version of PETRAN/ELFTRAN which generated this file
+	TUint32 iTimeLo;
+	TUint32 iTimeHi;
+	TUint iFlags;				// 0 = exe, 1 = dll, 2 = fixed address exe
+	TInt iCodeSize;				// size of code, import address table, constant data and export dir
+	TInt iDataSize;				// size of initialised data
+	TInt iHeapSizeMin;
+	TInt iHeapSizeMax;
+	TInt iStackSize;
+	TInt iBssSize;
+	TUint iEntryPoint;			// offset into code of entry point
+	TUint iCodeBase;			// where the code is linked for	
+	TUint iDataBase;			// where the data is linked for
+	TInt iDllRefTableCount;		// filling this in enables E32ROM to leave space for it
+	TUint iExportDirOffset;		// offset into the file of the export address table
+	TInt iExportDirCount;
+	TInt iTextSize;				// size of just the text section, also doubles as the offset for the iat w.r.t. the code section
+	TUint iCodeOffset;			// file offset to code section, also doubles as header size
+	TUint iDataOffset;			// file offset to data section
+	TUint iImportOffset;		// file offset to import section
+	TUint iCodeRelocOffset;		// relocations for code and const
+	TUint iDataRelocOffset;		// relocations for data
+	TUint16 iProcessPriority;	// executables priority
+	TUint16 iCpuIdentifier;		// 0x1000 = X86, 0x2000 = ARM
+	};
+
+class E32ImageHeaderComp : public E32ImageHeader
+	{
+public:
+	TUint32 iUncompressedSize;	// Uncompressed size of file
+								// For J format this is file size - sizeof(E32ImageHeader)
+								//  and this is included as part of the compressed data :-(
+								// For other formats this is file size - total header size
+	};
+
+class E32ImageHeaderV : public E32ImageHeaderComp
+	{
+public:
+	SSecurityInfo iS;
+
+	// Use iSpare1 as offset to Exception Descriptor
+	TUint32 iExceptionDescriptor;   // Offset in bytes from start of code section to Exception Descriptor, bit 0 set if valid
+	TUint32 iSpare2;
+	TUint16	iExportDescSize;	// size of bitmap section
+	TUint8	iExportDescType;	// type of description of holes in export table
+	TUint8	iExportDesc[1];		// description of holes in export table - extend
+	};
+
+// export description type
+const TUint	KImageHdr_ExpD_NoHoles			=0x00;	// no holes, all exports present
+const TUint	KImageHdr_ExpD_FullBitmap		=0x01;	// full bitmap present
+const TUint	KImageHdr_ExpD_SparseBitmap8	=0x02;	// sparse bitmap present, granularity 8
+const TUint	KImageHdr_ExpD_Xip				=0xff;	// XIP file
+
+
+inline TInt E32ImageHeader::TotalSize() const
+	{
+	if (HeaderFormat() == KImageHdrFmt_J && iCompressionType != 0)
+		return sizeof(E32ImageHeaderComp);
+	return iCodeOffset;
+	}
+
+inline TInt E32ImageHeader::UncompressedFileSize() const
+	{
+	TUint hdrfmt = HeaderFormat();
+	if (hdrfmt == KImageHdrFmt_Original || iCompressionType == 0)
+		return -1;			// not compressed
+	else if (hdrfmt == KImageHdrFmt_J)
+		return ((E32ImageHeaderComp*)this)->iUncompressedSize + sizeof(E32ImageHeader);
+	else
+		return ((E32ImageHeaderComp*)this)->iUncompressedSize + iCodeOffset;
+	}
+
+extern const SSecurityInfo KDefaultSecurityInfo;
+inline void E32ImageHeader::GetSecurityInfo(SSecurityInfo& aInfo) const
+	{
+	if (HeaderFormat() >= KImageHdrFmt_V)
+		aInfo = ((E32ImageHeaderV*)this)->iS;
+	else
+		aInfo = KDefaultSecurityInfo;
+	}
+
+inline TCpu E32ImageHeader::CpuIdentifier() const
+	{
+	if (HeaderFormat() >= KImageHdrFmt_V)
+		return (TCpu)iCpuIdentifier;
+	return (TCpu)iHeaderCrc;
+	}
+
+inline TProcessPriority E32ImageHeader::ProcessPriority() const
+	{
+	if (HeaderFormat() >= KImageHdrFmt_V)
+		return (TProcessPriority)iProcessPriority;
+	return *(const TProcessPriority*)&iProcessPriority;
+	}
+
+inline TUint32 E32ImageHeader::ExceptionDescriptor() const
+	{
+	if (HeaderFormat() >= KImageHdrFmt_V)
+		{
+		TUint32 xd = ((E32ImageHeaderV*)this)->iExceptionDescriptor;
+		if ((xd & 1) && (xd != 0xffffffffu))
+			return (xd & ~1);
+		}
+	return 0;
+	}
+
+class E32ImportBlock
+	{
+public:
+	inline const E32ImportBlock* NextBlock(TUint aImpFmt) const;
+	inline TInt Size(TUint aImpFmt) const;
+	inline const TUint* Imports() const;	// import list if present
+public:
+	TUint32	iOffsetOfDllName;	// offset of name of dll importing from
+	TInt	iNumberOfImports;	// no of imports from this dll
+//	TUint	iImport[iNumberOfImports];	// list of imported ordinals, omitted in PE2 import format
+	};
+
+inline TInt E32ImportBlock::Size(TUint aImpFmt) const
+	{
+	TInt r = sizeof(E32ImportBlock);
+	if (aImpFmt!=KImageImpFmt_PE2)
+		r += iNumberOfImports * sizeof(TUint);
+	return r;
+	}
+
+inline const E32ImportBlock* E32ImportBlock::NextBlock(TUint aImpFmt) const
+	{
+	const E32ImportBlock* next = this + 1;
+	if (aImpFmt!=KImageImpFmt_PE2)
+		next = (const E32ImportBlock*)( (TUint8*)next + iNumberOfImports * sizeof(TUint) );
+	return next;
+	}
+
+inline const TUint* E32ImportBlock::Imports() const
+	{
+	return (const TUint*)(this + 1);
+	}
+
+class E32ImportSection
+	{
+public:
+	TInt iSize;					// size of this section
+//	E32ImportBlock[iDllRefTableCount];
+	};
+
+class E32RelocSection
+	{
+public:
+	TInt iSize;					// size of this relocation section
+	TInt iNumberOfRelocs;		// number of relocations in this section
+	};
+
+
+typedef TUint8* (*TMemoryMoveFunction)(TAny* aTrg,const TAny* aSrc,TInt aLength);
+
+const TInt KDeflateLengthMag=8;
+const TInt KDeflateDistanceMag=12;
+const TInt KDeflateMinLength=3;
+const TInt KDeflateMaxLength=KDeflateMinLength-1 + (1<<KDeflateLengthMag);
+const TInt KDeflateMaxDistance=(1<<KDeflateDistanceMag);
+const TInt KDeflateDistCodeBase=0x200;
+const TUint KDeflateHashMultiplier=0xAC4B9B19u;
+const TInt KDeflateHashShift=24;
+const TInt KInflateWindowSize=0x8000;
+
+
+class TEncoding
+	{
+public:
+	enum {ELiterals=256,ELengths=(KDeflateLengthMag-1)*4,ESpecials=1,EDistances=(KDeflateDistanceMag-1)*4};
+	enum {ELitLens=ELiterals+ELengths+ESpecials};
+	enum {EEos=ELiterals+ELengths};
+public:
+	TUint32 iLitLen[ELitLens];
+	TUint32 iDistance[EDistances];
+	};
+
+const TInt KDeflationCodes=TEncoding::ELitLens+TEncoding::EDistances;
+
+NONSHARABLE_CLASS(CInflater) : public CBase
+	{
+public:
+	enum {EBufSize = 0x800, ESafetyZone=8};
+public:
+	static CInflater* NewLC(TBitInput& aInput);
+	~CInflater();
+	TInt ReadL(TUint8* aBuffer,TInt aLength, TMemoryMoveFunction aMemMovefn);
+	TInt SkipL(TInt aLength);
+private:
+	CInflater(TBitInput& aInput);
+	void ConstructL();
+	void InitL();
+	TInt InflateL();
+private:
+	TBitInput* iBits;
+	const TUint8* iRptr;			
+	TInt iLen;
+	const TUint8* iAvail;		
+	const TUint8* iLimit;
+	TEncoding* iEncoding;
+	TUint8* iOut;				
+	};
+
+void DeflateL(const TUint8* aBuf, TInt aLength, TBitOutput& aOutput);
+
+	
+NONSHARABLE_CLASS(TFileInput) : public TBitInput
+	{
+ 	enum {KBufSize=KInflateWindowSize};
+public:
+	TFileInput(RFile& aFile);
+	void Cancel();
+private:
+	void UnderflowL();
+private:
+	RFile& iFile;
+	TRequestStatus iStat;
+	TUint8* iReadBuf;
+	TPtr8 iPtr;
+	TUint8 iBuf1[KBufSize];
+	TUint8 iBuf2[KBufSize];
+	};
+
+class TFileNameInfo
+	{
+public:
+	enum
+    	{
+    	EIncludeDrive=1,
+    	EIncludePath=2,
+    	EIncludeBase=4,
+    	EIncludeVer=8,
+    	EForceVer=16,
+    	EIncludeUid=32,
+    	EForceUid=64,
+    	EIncludeExt=128,
+    	EIncludeDrivePath=EIncludeDrive|EIncludePath,
+    	EIncludeBaseExt=EIncludeBase|EIncludeExt,
+    	EIncludeDrivePathBaseExt=EIncludeDrive|EIncludePath|EIncludeBase|EIncludeExt,
+    	};
+	enum
+		{
+		EAllowUid=1,
+		EAllowPlaceholder=2,
+		EAllowDecimalVersion=4,
+		};
+public:
+	TFileNameInfo();
+	TInt Set(const TDesC8& aFileName, TUint aFlags);
+	void Dump() const;
+public:
+	inline TInt DriveLen() const {return iPathPos;}
+	inline TInt PathLen() const {return iBasePos-iPathPos;}
+	inline TInt BaseLen() const {return iVerPos-iBasePos;}
+	inline TInt VerLen() const {return iUidPos-iVerPos;}
+	inline TInt UidLen() const {return iExtPos-iUidPos;}
+	inline TInt ExtLen() const {return iLen-iExtPos;}
+	inline TPtrC8 Drive() const {return TPtrC8(iName, iPathPos);}
+	inline TPtrC8 Path() const {return TPtrC8(iName+iPathPos, iBasePos-iPathPos);}
+	inline TPtrC8 DriveAndPath() const {return TPtrC8(iName, iBasePos);}
+	inline TPtrC8 Base() const {return TPtrC8(iName+iBasePos, iVerPos-iBasePos);}
+	inline TPtrC8 VerStr() const {return TPtrC8(iName+iVerPos, iUidPos-iVerPos);}
+	inline TPtrC8 UidStr() const {return TPtrC8(iName+iUidPos, iExtPos-iUidPos);}
+	inline TPtrC8 Ext() const {return TPtrC8(iName+iExtPos, iLen-iExtPos);}
+	inline TUint32 Version() const {return iVersion;}
+	inline TUint32 Uid() const {return iUid;}
+	void GetName(TDes8& aName, TUint aFlags) const;
+public:
+	const TText8* iName;
+	TInt iPathPos;
+	TInt iBasePos;
+	TInt iVerPos;
+	TInt iUidPos;
+	TInt iExtPos;
+	TInt iLen;
+	TUint32 iVersion;
+	TUint32 iUid;
+	};
+
+
+#endif // __LAUNCHERE32IMAGEHEADERS_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/inc/launcher.hrh	Tue Feb 02 00:17:27 2010 +0200
@@ -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 __LAUNCHER_HRH__
+#define __LAUNCHER_HRH__
+
+
+enum TLauncherCommandIds
+    {
+    ECmdLaunchApps = 1,
+	ECmdLaunchAppsWithAutoClose,
+	ECmdLaunchAppsWithoutAutoClose,
+	ECmdDLLInfo,
+	ECmdSetDLLFilename,
+	ECmdCompareDLLs,
+	ECmdRefreshList,
+	ECmdClearWindow,
+	ECmdStopLaunch,
+	ECmdLaunchOptions,
+	ECmdSkipHiddenAndEmbedOnly,
+	ECmdDoNotSkipAnyFiles,
+	ECmdDeleteLog,
+	ECmdAbout,
+	ECmdSendUISystemDllFile,
+	ECmdSendUILogFile
+    };
+
+enum TLauncherTabViewId
+    {
+    ELauncherView1Tab = 1,
+    ELauncherView2Tab
+    };
+
+enum TLauncherId
+    {
+    EWaitNote = 1,
+    EProgressNote,
+    EYesNoQuery
+    };
+
+#endif // __LAUNCHER_HRH__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/inc/launcher.pan	Tue Feb 02 00:17:27 2010 +0200
@@ -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 __LAUNCHER_PAN__
+#define __LAUNCHER_PAN__
+
+
+/** Launcher application panic codes */
+enum TLauncherPanics 
+    {
+    ELauncherBasicUi = 1
+    // add further panics here
+    };
+
+#endif // __LAUNCHER_PAN__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/inc/launcherapplication.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,54 @@
+/*
+* 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 __LAUNCHER_APPLICATION_H__
+#define __LAUNCHER_APPLICATION_H__
+
+#include <aknapp.h>
+
+
+/*! 
+  @class CLauncherApplication
+  
+  @discussion An instance of CLauncherApplication is the application part of the AVKON
+  application framework for the Launcher example application
+  */
+class CLauncherApplication : public CAknApplication
+    {
+public:  // from CApaApplication
+
+/*! 
+  @function AppDllUid
+  
+  @discussion Returns the application DLL UID value
+  @result the UID of this Application/Dll
+  */
+    TUid AppDllUid() const;
+
+protected: // from CEikApplication
+/*! 
+  @function CreateDocumentL
+  
+  @discussion Create a CApaDocument object and return a pointer to it
+  @result a pointer to the created document
+  */
+    CApaDocument* CreateDocumentL();
+    };
+
+#endif // __LAUNCHER_APPLICATION_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/inc/launcherappui.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,110 @@
+/*
+* 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 LAUNCHERAPPUI_H
+#define LAUNCHERAPPUI_H
+
+// INCLUDES
+#include <eikapp.h>
+#include <eikdoc.h>
+#include <e32std.h>
+#include <coeccntx.h>
+#include <aknviewappui.h>
+#include <akntabgrp.h>
+#include <aknnavide.h>
+#include <SendUi.h>
+
+#include "LauncherEngine.h"
+
+// FORWARD DECLARATIONS
+class CLauncherContainerApps;
+class CLauncherEngine;
+
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+
+// CLASS DECLARATION
+
+/**
+* Application UI class.
+* Provides support for the following features:
+* - EIKON control architecture
+* - view architecture
+* - status pane
+* 
+*/
+class CLauncherAppUi : public CAknViewAppUi
+    {
+    public: // // Constructors and destructor
+
+        /**
+        * EPOC default constructor.
+        */      
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */      
+        ~CLauncherAppUi();
+        
+    public: // New functions
+
+    public: // Functions from base classes
+
+    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
+        CAknNavigationControlContainer* iNaviPane;
+        CAknTabGroup*                   iTabGroup;
+        CAknNavigationDecorator*        iDecoratedTabGroup;
+        CLauncherEngine*                iEngine;
+
+        #ifdef RD_SUPPORT_SENDUI_API_V2
+          CSendUi*                        iSendUi;
+        #else
+          CSendAppUi*                     iSendAppUi;
+        #endif
+
+    public:
+        CAknTabGroup* TabGroup() { return iTabGroup; }     
+    
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/inc/launchercontainerapps.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,118 @@
+/*
+* 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 LAUNCHERCONTAINERAPPS_H
+#define LAUNCHERCONTAINERAPPS_H
+
+// INCLUDES
+#include <coecntrl.h>
+#include <aknlists.h>
+#include <eiklbo.h> 
+   
+// FORWARD DECLARATIONS
+class CLauncherEngine;
+
+// CLASS DECLARATION
+
+/**
+*  CLauncherContainerApps  container control class.
+*  
+*/
+class CLauncherContainerApps : public CCoeControl, MCoeControlObserver, MEikListBoxObserver
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * EPOC default constructor.
+        * @param aRect Frame rectangle for container.
+        */
+        void ConstructL(const TRect& aRect, CLauncherEngine* aEngine);
+
+        /**
+        * Destructor.
+        */
+        ~CLauncherContainerApps();
+
+    public: // New functions
+
+    public: // Functions from base classes
+
+    public: // From MEikListBoxObserver
+        void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
+    
+    private: // Functions from base classes
+
+        /**
+        * From CoeControl.
+        */
+        void SizeChanged();  
+    
+        /**
+        * From CoeControl.
+        */
+        TInt CountComponentControls() const;
+    
+        /**
+        * From CCoeControl.
+        */
+        CCoeControl* ComponentControl(TInt aIndex) const;
+    
+        /**
+        * Event handling section, e.g Listbox events.
+        */
+        void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
+
+        /**
+        * From CCoeControl,Draw.
+        */
+        void Draw(const TRect& aRect) const;
+    
+        /**
+        * Key event handler. Handles up and down arrow keys, so that
+        * output window can be scrolled.
+        */
+        TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
+
+    public:
+        void HandleResourceChange(TInt aType);
+
+    public:    
+        const CArrayFix<TInt>* SelectedApps();
+        void UpdateFileListL();
+        void MarkCurrentItemL();
+        void UnmarkCurrentItem();
+        TInt NumberOfSelectedItems() const;
+        void MarkAllItemsL();
+        void UnmarkAllItems();
+        
+        CEikListBox* ListBox() { return iListBox; }
+        CLauncherEngine* Engine() { return iEngine; }
+
+
+            
+    private: //data
+        CDesCArray* iSelectedItems;
+        CAknSingleStyleListBox* iListBox;
+
+        CLauncherEngine* iEngine;
+    
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/inc/launchercontaineroutput.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,103 @@
+/*
+* 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 LAUNCHERCONTAINEROUTPUT_H
+#define LAUNCHERCONTAINEROUTPUT_H
+
+// INCLUDES
+#include <coecntrl.h>
+#include <eiksbobs.h>
+
+class CEikRichTextEditor;
+class CEikScrollBarFrame;
+class CLauncherEngine; 
+
+
+// FORWARD DECLARATIONS
+
+
+// CLASS DECLARATION
+
+/**
+*  CLauncherContainerOutput  container control class.
+*  
+*/
+class CLauncherContainerOutput : public CCoeControl, MCoeControlObserver, MEikScrollBarObserver
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * EPOC default constructor.
+        * @param aRect Frame rectangle for container.
+        */
+        void ConstructL(const TRect& aRect, CLauncherEngine* aEngine);
+
+        /**
+        * Destructor.
+        */
+        ~CLauncherContainerOutput();
+
+    public: // New functions
+
+        void PrintTextL(const TDesC& aDes);
+        void ClearOutputWindowL();
+
+
+    public: // Functions from base classes
+
+    private: // Functions from base classes
+
+        void Draw(const TRect& aRect) const;
+        void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
+        void HandleScrollEventL(CEikScrollBar* aScrollBar,TEikScrollEvent aEventType); // From MEikScrollBarObserver
+
+    public:
+        void HandleResourceChange(TInt aType);
+
+	private:
+		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode /*aType*/);
+    
+    private:
+        /**
+         * Updates the containers content in screen.
+         * @param aScrollToBottom If true, screen is scrolled to bottom.
+         * @param aScrollToTop If true, screen is scrolled to top. Ignored if
+         * aScrollToBottom is set true.
+         */
+        void UpdateVisualContentL(TBool aScrollToBottom, TBool aScrollToTop = EFalse);
+
+    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;
+
+        CLauncherEngine* iEngine;
+
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/inc/launcherdllelement.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,134 @@
+/*
+* 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 LAUNCHERDLLELEMENT_H_
+#define LAUNCHERDLLELEMENT_H_
+
+#include <e32base.h>
+
+typedef TBuf8<8> TDllIdValue;
+
+class CLauncherDLLElement : public CBase
+    {
+public:
+    
+    enum TDifference
+        {
+        EDifference_UID1,      // UID1 is different
+        EDifference_UID2,      // UID1 is different
+        EDifference_UID3,      // UID1 is different
+        EDifference_SID,       // SID is different
+        EDifference_Capability // Capabilities are different
+        };
+    
+    virtual ~CLauncherDLLElement();
+    static CLauncherDLLElement* NewL();
+    static CLauncherDLLElement* NewLC(); 
+    
+    /*
+     * Compares DLL elements.
+     * @return ETrue if differencies exist, EFalse otherwise.     
+     * @param aReferenceElement Reference DLL-element for comparison
+     * @param aDifferenceList Differencies are added to this list.
+     */
+    TBool CompareL(const CLauncherDLLElement& aReferenceElement, RArray<TDifference>& aDifferenceList) const;
+    
+    /*
+     * Returns DLL name
+     * @return DLL name
+     */
+    TFileName Name() const;    
+    /*
+     * Sets DLL name
+     * @param aName DLL name
+     */
+    void SetNameL(const TFileName& aName);
+    
+    /*
+     * Returns DLL UID1
+     * @return UID1 object
+     */
+    TUid UID1() const;
+    
+    /*
+     * Sets DLL UID1 
+     * @param aUID1 UID1 object
+     */
+    void SetUID1L(TUid aUID1);
+    
+    /*
+     * Returns DLL UID2
+     * @return UID2 object
+     */
+    TUid UID2() const;
+        
+    /*
+     * Sets DLL UID2 
+     * @param aUID2 UID2 object
+     */
+    void SetUID2L(TUid aUID2);
+        
+    /*
+     * Returns DLL UID3
+     * @return UID3 object
+     */
+    TUid UID3() const;
+    
+    /*
+     * Sets DLL UID3
+     * @param aUID3 UID3 object
+     */
+    void SetUID3L(TUid aUID3);
+    
+    /*
+     * Returns DLL SID
+     * @return SID object
+     */
+    TUid SID() const;
+    
+    /*
+     * Sets DLL SID
+     * @param aSID SID object
+     */
+    void SetSIDL(TUid aSID);
+    
+    /*
+     * Returns DLL capability
+     * @return capability value
+     */    
+    TUint32 Capability() const;
+    
+    /*
+     * Sets DLL capability
+     * @param aCapability capability value
+     */
+    void SetCapabilityL(TUint32 aCapability);
+    
+protected:
+    CLauncherDLLElement();
+    virtual void ConstructL();
+    
+private:
+    TFileName   iName;
+    TUid iUID1;
+    TUid iUID2;
+    TUid iUID3;
+    TUid iSID;
+    TUint32 iCapability;
+    };
+
+#endif /* LAUNCHERDLLELEMENT_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/inc/launcherdllparser.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,62 @@
+/*
+* 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 LAUNCHERDLLPARSER_H_
+#define LAUNCHERDLLPARSER_H_
+
+#include <e32base.h>
+#include <f32file.h>
+#include "launcherdllelement.h"
+
+#define UID1_OFFSET 0x00
+#define UID2_OFFSET 0x04
+#define UID3_OFFSET 0x08
+#define SID_OFFSET_ROM 0x44
+#define SID_OFFSET_ROFS 0x80
+#define CAPABILITY_OFFSET_ROM 0x4c
+#define CAPABILITY_OFFSET_ROFS 0x88
+
+class CLauncherDLLParser : public CBase
+    {
+public:
+
+    virtual ~CLauncherDLLParser();
+    static CLauncherDLLParser* NewL();
+    static CLauncherDLLParser* NewLC();
+    
+    /**
+     * Reads data from the given DLL-file and sets parsed data to given object.
+     * @param aFileSession Reference to an open file session     
+     * @param aFile Reference to the DLL file object
+     * @param aElement Reference to the element, which will contain the parsed data
+     */
+    void ParseL( RFs& aFileSession, RFile& aFile, CLauncherDLLElement& aElement );
+    
+private:
+
+    CLauncherDLLParser();
+    void ConstructL();
+    
+    /**
+     * Reads 32-bit unsigned integer from the given file.
+     * @return 32-bit unsigned integer value.
+     * @param aFile File handle.
+     */
+    TUint32 ReadUint32L( RFile& aFile );
+    };
+
+#endif /* LAUNCHERDLLPARSER_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/inc/launcherdocument.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,95 @@
+/*
+* 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 __LAUNCHER_DOCUMENT_H__
+#define __LAUNCHER_DOCUMENT_H__
+
+
+#include <akndoc.h>
+
+// Forward references
+class CLauncherAppUi;
+class CEikApplication;
+
+
+/*! 
+  @class CLauncherDocument
+  
+  @discussion An instance of class CLauncherDocument is the Document part of the AVKON
+  application framework for the Launcher example application
+  */
+class CLauncherDocument : public CAknDocument
+    {
+public:
+
+/*!
+  @function NewL
+  
+  @discussion Construct a CLauncherDocument for the AVKON application aApp 
+  using two phase construction, and return a pointer to the created object
+  @param aApp application creating this document
+  @result a pointer to the created instance of CLauncherDocument
+  */
+    static CLauncherDocument* NewL(CEikApplication& aApp);
+
+/*!
+  @function NewLC
+  
+  @discussion Construct a CLauncherDocument for the AVKON application aApp 
+  using two phase construction, and return a pointer to the created object
+  @param aApp application creating this document
+  @result a pointer to the created instance of CLauncherDocument
+  */
+    static CLauncherDocument* NewLC(CEikApplication& aApp);
+
+/*!
+  @function ~CLauncherDocument
+  
+  @discussion Destroy the object and release all memory objects
+  */
+    ~CLauncherDocument();
+
+/*!
+  @function CreateAppUiL 
+  
+  @discussion Create a CLauncherAppUi object and return a pointer to it
+  @result a pointer to the created instance of the AppUi created
+  */
+    CEikAppUi* CreateAppUiL();
+private:
+
+/*!
+  @function ConstructL
+  
+  @discussion Perform the second phase construction of a CLauncherDocument object
+  */
+    void ConstructL();
+
+/*!
+  @function CLauncherDocument
+  
+  @discussion Perform the first phase of two phase construction 
+  @param aApp application creating this document
+  */
+    CLauncherDocument(CEikApplication& aApp);
+
+    };
+
+
+#endif // __LAUNCHER_DOCUMENT_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/inc/launcherengine.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,213 @@
+/*
+* 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 __LAUNCHER_ENGINE_H__
+#define __LAUNCHER_ENGINE_H__
+
+#include "Launcher.hrh"
+#include "launcherparserobserver.h"
+
+#include <aknappui.h>
+#include <e32base.h>
+#include <apgcli.h>
+#include <SendUi.h>
+#include <aknprogressdialog.h>
+#include <maknfileselectionobserver.h>
+
+class CLauncherAppUi;
+class CLauncherContainerApps;
+class CLauncherContainerOutput;
+
+class CLauncherXMLParser;
+class CLauncherDLLParser;
+
+class CAppThreadChecker;
+class CAppRunningChecker;
+
+class CAknGlobalNote;
+
+
+class CLauncherEngine : public CActive, public MLauncherParserObserver, public MProgressDialogCallback
+	{
+public:
+	static CLauncherEngine* NewL(CLauncherAppUi* aAppUi);
+	~CLauncherEngine();
+
+public:
+    void SetContainerApps(CLauncherContainerApps* aContainerApps);
+    void SetContainerOutput(CLauncherContainerOutput* aContainerOutput);
+
+    CDesCArray* ListOfAllAppsL();
+    void StartAppLaunchingL(const CArrayFix<TInt>* aSelectedApps, TBool aAutoClose);
+    void CheckWhyThreadDiedL();
+    void CheckIfAppIsRunningL();
+    TInt DeleteLogFile();
+    TInt DeleteBCLogFile();
+    TBool LogFileExists();
+    TBool BCLogFileExists();
+    void AnalyseDLLsL();
+    void StopLaunchingL();
+    void SendLogViaSendUiL(CSendUi* aSendUi);
+    void SendListOfSystemDllsViaSendUiL(CSendUi* aSendUi);
+    TBool SelectRequiredDLLsFileL();
+        
+    // From MLauncherParserObserver
+    void ElementParsedL(const CLauncherDLLElement& aDllElement);
+    void DocumentParsedL(TInt aErrorCode);
+    void ParsingProgressedL(TInt aBytes);
+    
+    // From MProgressDialogCallback
+    void DialogDismissedL( TInt aButtonId );    
+    
+private:
+	CLauncherEngine();
+	void ConstructL(CLauncherAppUi* aAppUi);
+
+	void RunL();
+	void DoCancel();
+
+	void IssueLaunch();
+	void LaunchApplicationL();
+	void DoLaunchApplicationL();
+		
+    void CheckForMoreAppsL();
+    void WriteInitialStuffToTheLogL(const TDesC& aOwnData, RFile& aFile);
+    TInt FindFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath);
+    TInt FindFiles(const TDesC& aFileName, const TDesC& aPath);
+    TInt ReadLineFromFileL(RFile& aFile, TDes& aReadBuf);
+    void ChangeFocusToOutputView();
+    
+    /**
+     * Performs binary compatibility analysis based on reference data given
+     * in XML-file.
+     */
+    void DoBCAnalysisL();
+    
+    /**
+     * Compares given DLL list to system DLLs
+     */
+    void DoCompareDLLListsL();
+    
+    /**
+     * IsCurrentThreadOpen
+     */
+    TBool IsCurrentThreadOpen() const;
+        
+    CDesCArray* DependencyCheckForE32ImageL();
+    
+private:
+	RTimer          iTimer;
+	CEikonEnv*      iEnv;
+	RApaLsSession   iLs;
+    RWsSession      iWs;
+    HBufC8*         iLogWriteBuf;    
+    RFile           iLogFile;
+    RFile           iBCLogFile;  
+    TFileName       iLogFilePath;
+    TFileName       iBCLogFilePath;
+    TFileName       iSystemDllsFilePath;
+    TFileName       iRequiredDllsFilePath;        
+    
+    CDesCArray*     iAppsArray;
+    CDesCArray*     iAllAppsArray;
+    CDesCArray*     iSystemDllArray;
+    CDesCArray*     iRequiredDllArray;
+
+    TBool           iLaunchingIsActive;
+    TBool           iDLLAnalysisIsActive;
+    TBool           iSkipHiddenAndEmbedOnly;
+    TBool           iAutoClose;
+    TInt            iAppLaunchCounter;
+    TInt            iFailedCases;
+    TInt            iOkCases;
+    TInt            iSkippedCases;
+    TInt            iTotalNumberOfCases;
+
+    TUid            iCurrentAppUid;
+    TThreadId       iCurrentAppThreadId;
+    TBuf<128>       iCurrentAppNameAndExt;
+    RThread         iCurrentAppThread;
+
+    CAppThreadChecker*          iAppThreadChecker;
+    CAppRunningChecker*         iAppRunningChecker;
+
+    CLauncherAppUi*             iAppUi;
+    CLauncherContainerApps*     iContainerApps;
+    CLauncherContainerOutput*   iContainerOutput;
+    
+    CLauncherXMLParser*     iXMLParser;
+    CLauncherDLLParser*     iDLLParser;
+    CLauncherDLLElement*    iDLLElement;
+    
+    CEikProgressInfo*       iProgressInfo;
+    CAknProgressDialog*     iWaitDialog;
+    TInt                    iWaitDialogId;    
+    TInt                iFoundBCIssues;
+    HBufC*              iBCIssuesBigBuffer;
+
+public:
+    inline TBool LaunchingIsActive()                   { return iLaunchingIsActive; };
+    inline TBool SkipHiddenAndEmbedOnly()              { return iSkipHiddenAndEmbedOnly; };
+    inline void SetSkipHiddenAndEmbedOnly(TBool aSkip) { iSkipHiddenAndEmbedOnly = aSkip; };
+    inline CAppThreadChecker*  AppThreadChecker()      { return iAppThreadChecker; };
+    inline CAppRunningChecker* AppRunningChecker()     { return iAppRunningChecker; };
+	};
+
+
+class CAppRunningChecker : public CActive
+	{
+public:
+	static CAppRunningChecker* NewL(CLauncherEngine* aLauncherEngine);
+	~CAppRunningChecker();
+
+	void StartTesting();
+
+private:
+	CAppRunningChecker();
+	void ConstructL(CLauncherEngine* aLauncherEngine);
+
+	void RunL();
+	void DoCancel();
+
+private:
+	RTimer iTimer;
+	CEikonEnv* iEnv;
+    CLauncherEngine* iLauncherEngine;
+	};
+
+
+class CAppThreadChecker : public CActive
+	{
+public:
+	static CAppThreadChecker* NewL(CLauncherEngine* aLauncherEngine);
+	~CAppThreadChecker();
+
+	void ActivateChecking();
+
+private:
+	CAppThreadChecker();
+	void ConstructL(CLauncherEngine* aLauncherEngine);
+
+	void RunL();
+	void DoCancel();
+
+private:
+	CEikonEnv* iEnv;
+    CLauncherEngine* iLauncherEngine;
+	};
+
+#endif // __LAUNCHER_ENGINE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/inc/launcherparserobserver.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  
+*
+*/
+
+#ifndef LAUNCHERPARSEROBSERVER_H_
+#define LAUNCHERPARSEROBSERVER_H_
+
+class CLauncherDLLElement;
+
+class MLauncherParserObserver
+{
+public:
+    
+    /**
+     * This method is called when parser has parsed next DLL element     
+     * @param aDllElement Parsed DLL element.     
+     */    
+    virtual void ElementParsedL(const CLauncherDLLElement& aDllElement) = 0;
+    
+    /**
+     * This method is called when the parsing is completed. If parsing was
+     * stopped due to an error, an error code is given in parameter.
+     * @param aErrorCode KErrNone if document was parsed successfully.
+     */
+    virtual void DocumentParsedL(TInt aErrorCode) = 0;
+    
+    /**
+     * Parser calls this function during parsing to indicate the amount of
+     * bytes parsed from the given file.
+     * @param aBytes Amount of data (in bytes) parsed. Amount is incremental.
+     */
+    virtual void ParsingProgressedL(TInt aBytes) = 0;
+    
+};
+
+#endif /* LAUNCHERPARSEROBSERVER_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/inc/launchertraces.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  
+*
+*/
+
+
+
+#ifndef __LAUNCHER_TRACES_H__
+#define __LAUNCHER_TRACES_H__
+
+#include <e32def.h>
+
+
+// ---------------------------------------------------------------------------
+// You change these logging method values below! Recompile the application to take changes effect.
+
+    // logging methods
+    // 0 = No logging
+    // 1 = Flogger
+    // 2 = RDebug
+    // 3 = Flogger and RDebug
+    
+    #ifndef _DEBUG
+        
+        // Logging method for UREL builds:
+        #define LAUNCHER_LOGGING_METHOD  3
+
+    #else
+
+        // Logging method for UDEB builds:
+        #define LAUNCHER_LOGGING_METHOD  3
+
+    #endif    
+    
+
+
+// ---------------------------------------------------------------------------
+// Do not make any changes to lines below...
+
+    #if LAUNCHER_LOGGING_METHOD == 1 || LAUNCHER_LOGGING_METHOD == 3
+
+        #include <flogger.h>
+        _LIT(KLogFolder,"Launcher");
+        _LIT(KLogFile,"Launcher_Trace.txt");
+
+    #endif
+
+    #if LAUNCHER_LOGGING_METHOD == 2 || LAUNCHER_LOGGING_METHOD == 3
+
+        #include <e32debug.h>
+
+    #endif
+
+
+    #if LAUNCHER_LOGGING_METHOD == 0
+    
+        #define LOGTEXT(AAA)
+        #define LOGSTRING(AAA)
+        #define LOGSTRING2(AAA,BBB)
+        #define LOGSTRING3(AAA,BBB,CCC)
+        #define LOGSTRING4(AAA,BBB,CCC,DDD)
+    
+    
+    #elif LAUNCHER_LOGGING_METHOD == 1
+    
+        #define LOGTEXT(AAA)                RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend, AAA)
+        #define LOGSTRING(AAA)              do { _LIT(tempLogDes,AAA); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0)
+        #define LOGSTRING2(AAA,BBB)         do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB); } while (0)
+        #define LOGSTRING3(AAA,BBB,CCC)     do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB,CCC); } while (0)
+        #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB,CCC,DDD); } while (0)
+   
+    #elif LAUNCHER_LOGGING_METHOD == 2
+    
+        #define LOGTEXT(AAA)                RDebug::Print(AAA)
+        #define LOGSTRING(AAA)              do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); } while (0)
+        #define LOGSTRING2(AAA,BBB)         do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); } while (0)
+        #define LOGSTRING3(AAA,BBB,CCC)     do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); } while (0)
+        #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); } while (0)
+    
+    #elif LAUNCHER_LOGGING_METHOD == 3
+    
+        #define LOGTEXT(AAA)                RDebug::Print(AAA); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend, AAA)
+        #define LOGSTRING(AAA)              do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0)
+        #define LOGSTRING2(AAA,BBB)         do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB); } while (0)
+        #define LOGSTRING3(AAA,BBB,CCC)     do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB,CCC); } while (0)
+        #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB,CCC,DDD); } while (0)
+
+    #endif
+
+// ---------------------------------------------------------------------------
+
+#endif // __LAUNCHER_TRACES_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/inc/launcherviewapps.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,92 @@
+/*
+* 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 LAUNCHERVIEWAPPS_H
+#define LAUNCHERVIEWAPPS_H
+
+// INCLUDES
+#include <aknview.h>
+
+#include "LauncherEngine.h"
+
+// CONSTANTS
+// UID of view
+const TUid KViewId = {1};
+
+// FORWARD DECLARATIONS
+class CLauncherContainerApps;
+
+// CLASS DECLARATION
+
+/**
+*  CLauncherViewApps view class.
+* 
+*/
+class CLauncherViewApps : public CAknView
+    {
+    public: // Constructors and destructor
+
+        /**
+        * EPOC default constructor.
+        */
+        void ConstructL(CLauncherEngine* aEngine);
+
+        /**
+        * Destructor.
+        */
+        ~CLauncherViewApps();
+
+    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:
+
+        void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
+
+        /**
+        * From AknView, ?member_description
+        */
+        void DoActivateL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,
+            const TDesC8& aCustomMessage);
+
+        /**
+        * From AknView, ?member_description
+        */
+        void DoDeactivate();
+
+    private: // Data
+        CLauncherContainerApps* iContainer;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/inc/launcherviewoutput.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,92 @@
+/*
+* 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 LAUNCHERVIEWOUTPUT_H
+#define LAUNCHERVIEWOUTPUT_H
+
+// INCLUDES
+#include <aknview.h>
+
+#include "LauncherEngine.h"
+
+// CONSTANTS
+// UID of view
+const TUid KView2Id = {2};
+
+// FORWARD DECLARATIONS
+class CLauncherContainerOutput;
+
+// CLASS DECLARATION
+
+/**
+*  CLauncherViewOutput view class.
+* 
+*/
+class CLauncherViewOutput : public CAknView
+    {
+    public: // Constructors and destructor
+
+        /**
+        * EPOC default constructor.
+        */
+        void ConstructL(CLauncherEngine* aEngine);
+
+        /**
+        * Destructor.
+        */
+        ~CLauncherViewOutput();
+
+    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:
+
+        void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
+
+        /**
+        * From AknView, ?member_description
+        */
+        void DoActivateL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,
+            const TDesC8& aCustomMessage);
+
+        /**
+        * From AknView, ?member_description
+        */
+        void DoDeactivate();
+
+    private: // Data
+        CLauncherContainerOutput* iContainer;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/inc/launcherxmlparser.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  
+*
+*/
+
+#ifndef LAUNCHERXMLPARSER_H_
+#define LAUNCHERXMLPARSER_H_
+
+#include <e32base.h>
+#include <xml/contenthandler.h>
+#include <xml/parser.h>
+#include "launcherdllelement.h"
+#include "launcherparserobserver.h"
+
+using namespace Xml;
+
+const TUint KXMLBufferSize = 1024;
+
+class CLauncherDLLElement;
+
+/**
+ * Parses DLL data from the given XML-file
+ */
+class CLauncherXMLParser : public CActive, public MContentHandler
+{
+public:
+
+    virtual ~CLauncherXMLParser();
+    static CLauncherXMLParser* NewL(RFs& aFs);
+    static CLauncherXMLParser* NewLC(RFs& aFs);
+    
+    /**
+     * Parses the given XML-file and notifies the observer.
+     * @param aFilePath XML-file's path
+     * @param aObserver Pointer to the observer instance.
+     */
+    void ParseL(const TDesC& aFilePath, MLauncherParserObserver* aObserver);
+        
+protected:
+    
+    // from CActive    
+    void DoCancel();    
+    void RunL();
+    
+private:
+
+    CLauncherXMLParser(RFs& aFs);
+    void ConstructL();
+    
+    /**
+     * Tells whether the current XML element is a sub-element of the 'dll'-element.
+     * @return ETrue if the current XML-element is sub-element of the 'dll'-element.
+     */
+    TBool IsDataElement();
+
+    /**
+     * Deletes current data buffer and zeroes the pointer.
+     */
+    void ClearXMLDataBuffer();
+    
+    /**
+     * Converts 8-bit descriptor to 32-bit unsigned integer
+     * @return Converted 32-bit unsigned integer value.
+     * @param aStr 8-bit descriptor to be converted.
+     */
+    TUint32 ConvertDes8ToUint32L(const TDesC8& aStr);
+                
+public:
+    // From MContentHandler:    
+    void OnStartDocumentL(const RDocumentParameters &aDocParam, TInt aErrorCode);
+    void OnEndDocumentL(TInt aErrorCode);
+    void OnStartElementL(   const RTagInfo& aElement, 
+                            const RAttributeArray& aAttributes, 
+                            TInt aErrorCode);
+    void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode);
+    void OnContentL(const TDesC8& aBytes, TInt aErrorCode);
+    void OnStartPrefixMappingL( const RString& aPrefix, 
+                                const RString& aUri, 
+                                TInt aErrorCode);
+    void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode);
+    void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode);
+    void OnSkippedEntityL(const RString& aName, TInt aErrorCode);
+    void OnProcessingInstructionL(  const TDesC8& aTarget, 
+                                    const TDesC8& aData, 
+                                    TInt aErrorCode);
+    void OnError(TInt aErrorCode);
+    TAny* GetExtendedInterface(const TInt32 aUid);    
+    
+private:
+    CParser* iParser;  // XML parser
+    RFs& iFileSession;
+    RFile iFile; // XML file 
+    TBuf8<KXMLBufferSize> iXMLDataBuffer;
+    MLauncherParserObserver* iObserver;
+    CLauncherDLLElement* iCurrentDllElement;
+    TBuf8<KMaxFileName> iCurrentContent;
+    TBuf8<KMaxName> iCurrentElementName;
+    TBool iIgnoreError;
+    TInt  iParsedBytes;
+};
+
+#endif /* LAUNCHERXMLPARSER_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/rom/Launcher.iby	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,34 @@
+/*
+* 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 __LAUNCHER_IBY__
+#define __LAUNCHER_IBY__
+
+S60_APP_EXE(Launcher)
+S60_APP_AIF_ICONS(Launcher)
+S60_APP_RESOURCE(Launcher)
+#ifdef S60_UPGRADABLE_APP_REG_RSC
+  S60_UPGRADABLE_APP_REG_RSC(Launcher)
+#else
+  S60_APP_AIF_RSC(Launcher)
+#endif
+
+data=ZPRIVATE\101FB74F\backup_registration.xml        	private\101FB74F\backup_registration.xml
+data=ZSYSTEM\Install\Launcher_stub.sis                  \system\install\Launcher_stub.sis
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/sis/Launcher_S60-30.pkg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,37 @@
+;
+; 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:
+;
+
+; Language - standard language definitions
+&EN
+
+; Standard SIS file header
+#{"Launcher"},(0x101FB74F),3,7,0,TYPE=SA
+
+; Supports S60 v 3.0
+[0x101F7961], 0, 0, 0, {"S60ProductID"}
+
+; Non-localised vendor name
+:"Nokia Corporation"
+
+; Localised vendor names
+%{"Nokia Corporation"}
+
+; normal stuff:
+"\epoc32\RELEASE\armv5\UREL\Launcher.exe"-"!:\sys\bin\Launcher.exe"
+"\epoc32\data\z\Resource\apps\Launcher_aif.mif"-"!:\Resource\Apps\Launcher_aif.mif"
+"\epoc32\data\z\Resource\apps\Launcher.rsc"-"!:\Resource\Apps\Launcher.rsc"
+"\epoc32\data\z\PRIVATE\10003A3F\APPS\Launcher_reg.rsc"-"!:\private\10003a3f\import\apps\Launcher_reg.rsc"
+"..\group\backup_registration.xml"-"!:\private\101FB74F\backup_registration.xml"
Binary file launcher/sis/Launcher_S60-30.sis has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/sis/Launcher_stub.pkg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,34 @@
+;
+; 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:
+;
+
+; Language - standard language definitions
+&EN
+
+; Standard SIS file header
+#{"Launcher"},(0x101FB74F),1,0,0
+
+; Non-localised vendor name
+:"Nokia Corporation"
+
+; Localised vendor names
+%{"Nokia Corporation"}
+
+; normal stuff:
+""-"z:\sys\bin\Launcher.exe"
+""-"z:\Resource\Apps\Launcher_aif.mif"
+""-"z:\Resource\Apps\Launcher.rsc"
+""-"z:\private\10003a3f\import\apps\Launcher_reg.rsc"
+""-"z:\private\101FB74F\backup_registration.xml"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/src/e32image.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,846 @@
+/*
+* 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 "e32image.h"
+#include "e32imageheaders.h"
+#include "launchertraces.h"
+
+
+const TInt KMaxHeaderSize = sizeof(E32ImageHeaderV) + 65536/8;
+
+SCapabilitySet AllCapabilities;
+SCapabilitySet DisabledCapabilities;
+
+// ---------------------------------------------------------------------------
+
+E32ImageReader* E32ImageReader::NewLC()
+    {
+    E32ImageReader* self = new(ELeave) E32ImageReader;
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+
+E32ImageReader::E32ImageReader()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+
+void E32ImageReader::ConstructL()
+    {
+    LOGSTRING("Launcher: E32ImageReader::ConstructL");
+
+    iEnv = CEikonEnv::Static();
+    }
+
+// ---------------------------------------------------------------------------
+
+CDesCArray* E32ImageReader::ListOfDLLsL(const TDesC& aFullPathToE32Image)
+    {
+    LOGSTRING("Launcher: E32ImageReader::ListOfDLLsL");
+
+    // open the file for reading
+    User::LeaveIfError( iFile.Open(iEnv->FsSession(), aFullPathToE32Image, EFileRead) );
+    CleanupClosePushL(iFile);
+    
+    // get local copies of capability sets
+    TCapabilitySet caps;
+    caps.SetAllSupported();
+    AllCapabilities=*(SCapabilitySet*)&caps;
+    caps.SetDisabled();
+    DisabledCapabilities=*(SCapabilitySet*)&caps;
+
+    // read the header of the image
+    User::LeaveIfError( E32ImageHeader::New(iHeader, iFile) );
+
+    // set stuff
+    iHeapSizeMin = iHeader->iHeapSizeMin;
+    iHeapSizeMax = iHeader->iHeapSizeMax;
+    iStackSize = iHeader->iStackSize;
+    iPriority = iHeader->ProcessPriority();
+    iDepCount = iHeader->iDllRefTableCount;
+    iExportDirCount = iHeader->iExportDirCount;
+    iExportDir = iHeader->iExportDirOffset-iHeader->iCodeOffset;
+    iTextSize = iHeader->iTextSize;
+    iCodeSize = iHeader->iCodeSize;
+    iDataSize = iHeader->iDataSize;
+    iBssSize = iHeader->iBssSize;
+    iTotalDataSize = iDataSize+iBssSize;
+    iFileEntryPoint = iHeader->iEntryPoint;
+    iEntryPtVeneer = 0;
+    iExceptionDescriptor = iHeader->ExceptionDescriptor();
+    if (iHeader->iExportDirOffset)
+        iExportDirLoad=iExportDir;
+    
+    // allocate data for the code area
+    iCodeLoadAddress = (TUint32)User::Alloc(iCodeSize);
+    
+    // load data from the binary
+    User::LeaveIfError( LoadData() );
+
+    // create an array for the dll names from the import list
+    CDesCArray* dllArray = new(ELeave) CDesCArrayFlat(100);
+    CleanupStack::PushL(dllArray);
+
+    // get the dll names from the import section
+    E32ImportSection* importSection = (E32ImportSection *)iImportData;
+    E32ImportBlock* block;
+    if(importSection)
+        block = (E32ImportBlock*)(importSection+1);
+    else
+        block = NULL;
+    iNextImportPos = 0;
+
+    // loop through all import data blocks
+    for (TInt i=0; i<iDepCount; i++)
+        {
+        // get a pointer to the dll name
+        TPtrC8 dllname = (const TText8*)((TUint32)iImportData + block->iOffsetOfDllName);
+        TBuf8<KMaxKernelName> rootname;
+        if (dllname.Length() > KMaxKernelName)
+            User::Leave( KErrNotSupported );
+        
+        // parse the filename
+        TFileNameInfo fni;
+        User::LeaveIfError( fni.Set(dllname, TFileNameInfo::EAllowUid) );
+        fni.GetName(rootname, TFileNameInfo::EIncludeBaseExt);
+
+        // append the name to the dll name array
+        TFileName dllName16;
+        dllName16.Copy(rootname);
+        dllArray->AppendL(dllName16);
+
+        // get the next block
+        TUint impfmt = iHeader->ImportFormat();
+        block = (E32ImportBlock*)block->NextBlock(impfmt);
+        }
+
+    CleanupStack::Pop();  //dllArray
+    CleanupStack::PopAndDestroy(); //iFile
+
+    // free memory
+    delete iHeader;
+    iHeader = NULL;
+    delete iImportSection;
+    iImportSection = NULL;
+    delete iCodeRelocSection;
+    iCodeRelocSection = NULL;
+    delete iDataRelocSection;
+    iDataRelocSection = NULL;
+    
+    User::Free((TAny*)iCodeLoadAddress);
+    User::Free(iRestOfFileData);
+    User::Free(iCurrentImportList);
+    if (iExportDirLoadAllocated)
+        User::Free((TAny*)iExportDirLoad);
+
+    return dllArray;
+    }
+
+// ---------------------------------------------------------------------------
+
+E32ImageReader::~E32ImageReader()
+    {
+    LOGSTRING("Launcher: E32ImageReader::~E32ImageReader");
+    }
+
+
+// ---------------------------------------------------------------------------
+
+TInt FileRead(RFile& aFile, TUint8* aDest, TInt aSize)
+    {
+    TPtr8 p(aDest,aSize,aSize);
+    return aFile.Read(p,aSize);
+    }
+
+// ---------------------------------------------------------------------------
+
+TInt E32ImageHeader::New(E32ImageHeader*& aHdr, RFile& aFile)
+    {
+    LOGSTRING("Launcher: E32ImageHeader::New");
+
+    E32ImageHeader* h = NULL;
+    TInt hdrsz = 0;
+    TInt filesize;
+    TInt r = aFile.Size(filesize);
+    if (r!=KErrNone)
+        return r;
+    E32ImageHeader bh;
+    r = FileRead(aFile, (TUint8*)&bh, sizeof(E32ImageHeader));
+    if (r==KErrNone)
+        {
+        hdrsz = bh.TotalSize();
+        if ( (TUint(hdrsz) > TUint(KMaxHeaderSize)) || (TUint(hdrsz) < TUint(sizeof(bh))) )
+            return KErrCorrupt;
+        }
+    h = (E32ImageHeader*)User::Alloc(hdrsz);
+    if (!h)
+        return KErrNoMemory;
+    wordmove(h, &bh, sizeof(E32ImageHeader));
+    if (hdrsz > (TInt)sizeof(E32ImageHeader))
+        r = FileRead(aFile, (TUint8*)(h + 1), hdrsz - sizeof(E32ImageHeader));
+    if (r==KErrNone)
+        r = h->IntegrityCheck(filesize);
+    if (r==KErrNone)
+        {
+        if (h->HeaderFormat() >= KImageHdrFmt_V)
+            {
+            // Overide capabilities in image
+            for(TInt i=0; i<SCapabilitySet::ENCapW; i++)
+                {
+                ((E32ImageHeaderV*)h)->iS.iCaps[i] |= DisabledCapabilities[i];
+                ((E32ImageHeaderV*)h)->iS.iCaps[i] &= AllCapabilities[i];
+                }
+            }
+        aHdr = h;
+        }
+    else
+        {
+        delete h;
+        aHdr = NULL;
+        }
+    return r;
+    }
+
+// ---------------------------------------------------------------------------
+
+TInt E32ImageHeader::IntegrityCheck(TInt aFileSize)
+    {
+    LOGSTRING("Launcher: E32ImageHeader::IntegrityCheck");
+    
+    TInt hdrsz = TotalSize();
+    TUint hdrfmt = HeaderFormat();
+    TUidType uids = *(const TUidType*)&iUid1;
+    E32ImageHeaderV* v = NULL;
+    TCheckedUid chkuid(uids);
+    const TUint32* pChkUid = (const TUint32*)&chkuid;
+
+    if (pChkUid[3] != iUidChecksum)
+        return KErrCorrupt;    
+
+    if (hdrfmt == KImageHdrFmt_V)
+        {
+        TUint32 supplied_crc = iHeaderCrc;
+        iHeaderCrc = KImageCrcInitialiser;
+        TUint32 crc = 0;
+        Mem::Crc32(crc, this, hdrsz);
+        iHeaderCrc = supplied_crc;
+        if (crc != supplied_crc)
+            return KErrCorrupt;    
+        v = (E32ImageHeaderV*)this;
+        TUint total_eds = v->iExportDescSize + sizeof(v->iExportDescSize) + sizeof(v->iExportDescType);
+        total_eds = (total_eds + 3) &~ 3;
+        if (total_eds + (TUint)_FOFF(E32ImageHeaderV, iExportDescSize) != (TUint)hdrsz)
+            return KErrCorrupt;
+        if (TUint(v->iExportDescType) > KImageHdr_ExpD_SparseBitmap8)
+            return KErrNotSupported;
+        }
+    else if (hdrfmt >= KImageHdrFmt_V)
+        return KErrNotSupported; 
+
+    TCpu cpu = CpuIdentifier();
+    TUint abi = ABI();
+    TUint impfmt = ImportFormat();
+    TUint compression = CompressionType();
+
+    TUint uncompressed_size = compression ? UncompressedFileSize() : (TUint)aFileSize;
+
+    if (iSignature != 0x434f5045) // 'EPOC'
+        return KErrCorrupt;
+    if (iCodeSize<0)
+        return KErrCorrupt;
+    if (iDataSize<0)
+        return KErrCorrupt;
+    if (iHeapSizeMin<0)
+        return KErrCorrupt;
+    if (iHeapSizeMax<iHeapSizeMin)
+        return KErrCorrupt;
+    if (iStackSize<0)
+        return KErrCorrupt;
+    if (iBssSize<0)
+        return KErrCorrupt;
+    if (iDllRefTableCount<0)
+        return KErrCorrupt;
+    if (iExportDirOffset >= uncompressed_size)
+        return KErrCorrupt;
+    if (TUint(iExportDirCount)>65535)
+        return KErrCorrupt;
+    if (iTextSize<0)
+        return KErrCorrupt;
+    if (iCodeSize<iTextSize)
+        return KErrCorrupt;
+    if (iCodeOffset >= uncompressed_size)
+        return KErrCorrupt;
+    if (iDataOffset >= uncompressed_size)
+        return KErrCorrupt;
+    if (iImportOffset >= uncompressed_size)
+        return KErrCorrupt;
+    if (iCodeRelocOffset >= uncompressed_size)
+        return KErrCorrupt;
+    if (iDataRelocOffset >= uncompressed_size)
+        return KErrCorrupt;
+    if (TUint(iCodeSize+iDataSize) > uncompressed_size)
+        return KErrCorrupt;
+
+    if (abi>KImageABI_EABI)
+        return KErrNotSupported;
+    if (impfmt>KImageImpFmt_PE2)
+        return KErrNotSupported;
+    if (iUid1 != (TUint32)KExecutableImageUidValue && iUid1 != (TUint32)KDynamicLibraryUidValue)
+        return KErrNotSupported;
+    TUint32 mv = ModuleVersion();
+    if (mv >= 0x80000000u || (mv & 0x0000ffffu) > 0x8000u)
+        return KErrNotSupported;
+
+    return KErrNone;
+    }
+// ---------------------------------------------------------------------------
+
+TInt E32ImageReader::LoadData()
+    {
+    LOGSTRING("Launcher: E32ImageReader::LoadData");
+
+    TInt remainder;
+    iFile.Size(remainder);
+    
+    remainder -= iHeader->TotalSize();
+    TUint32 compression = iHeader->CompressionType();
+    if (compression != KMyFormatNotCompressed)
+        {
+        remainder = iHeader->UncompressedFileSize() - iHeader->iCodeOffset;
+        }
+
+    remainder -= iHeader->iCodeSize;
+    
+    if (remainder > 0)
+        {
+        iRestOfFileData = (TUint8*)User::Alloc(remainder);
+        if (iRestOfFileData)
+            iRestOfFileSize=remainder;
+        else
+            return KErrNoMemory;
+        }
+
+    iConversionOffset = iHeader->iCodeOffset + iHeader->iCodeSize;
+
+    TInt r = LoadFile(compression);
+    if (r !=KErrNone)
+        return r;
+
+
+    TUint8* source=NULL;
+    if (iHeader->iImportOffset)
+        {
+        TUint bufferOffset=iHeader->iImportOffset-iConversionOffset;
+        
+        if(bufferOffset>iRestOfFileSize || bufferOffset+sizeof(E32ImportSection)>iRestOfFileSize)
+            return KErrCorrupt;
+        
+        source=iRestOfFileData+bufferOffset;
+        
+        iImportSection = new E32ImportSection;
+        
+        if (iImportSection)
+            Mem::Move((TText8*)iImportSection, source, sizeof(E32ImportSection));
+        else
+            return KErrNoMemory;
+        }
+
+    iCodeDelta = iCodeRunAddress-iHeader->iCodeBase;
+    iDataDelta = iDataRunAddress-iHeader->iDataBase;
+
+    if (r==KErrNone)
+        r = ReadImportData();
+
+    return r;
+    }
+
+// ---------------------------------------------------------------------------
+
+TUint8* E32ImageReader::MemoryMove(TAny* aDestination, const TAny* aSource, TInt aNumberofBytes)
+    {
+    return Mem::Move(aDestination, aSource, aNumberofBytes);
+    }
+
+// ---------------------------------------------------------------------------
+
+GLDEF_C TInt svRelocateExports(TAny* aPtr)
+    {
+    E32ImageReader* pI=(E32ImageReader*)aPtr;
+    TUint32* destExport=(TUint32*)pI->iExportDirLoad;
+    TInt i=pI->iExportDirCount;
+    TUint32 codeBase=pI->iCodeRunAddress;
+    while (i-->0)
+        *destExport+++=codeBase;
+    return 0;
+    }
+
+// ---------------------------------------------------------------------------
+
+TInt E32ImageReader::LoadFile(TUint32 aCompression)
+    {
+    LOGSTRING("Launcher: E32ImageReader::LoadFile");
+
+    TInt r(KErrNone);
+
+    if (aCompression == KMyFormatNotCompressed)
+        r=LoadFileNoCompress();
+    
+    else if (aCompression == KMyUidCompressionDeflate)
+        {
+        TRAP(r, LoadFileInflateL());
+        }
+    
+    else
+        r = KErrNotSupported;
+    
+    return r;
+    }
+
+// ---------------------------------------------------------------------------
+
+TInt E32ImageReader::LoadFileNoCompress()
+    {
+    LOGSTRING("Launcher: E32ImageReader::LoadFileNoCompress");
+
+    TInt r(KErrNone);
+
+    if (iHeader->iCodeSize)
+        {
+        r = Read(iHeader->iCodeOffset, (TText8*)iCodeLoadAddress, iCodeSize);
+        }
+
+    if (r != KErrNone)
+        {
+        return r;
+        }
+
+    if (iRestOfFileSize)
+        {
+        r = Read(iConversionOffset, (TText8*)iRestOfFileData, iRestOfFileSize);
+        }
+    
+    return r;
+    }
+
+// ---------------------------------------------------------------------------
+
+void FileCleanup(TAny* aPtr)
+    {
+    TFileInput* f=(TFileInput*)aPtr;
+    f->Cancel();
+    delete f;
+    }
+
+// ---------------------------------------------------------------------------
+
+void E32ImageReader::LoadFileInflateL()
+    {
+    LOGSTRING("Launcher: E32ImageReader::LoadFileInflateL");
+
+    TInt pos = iHeader->TotalSize();
+    User::LeaveIfError(iFile.Seek(ESeekStart,pos));
+
+    TFileInput* file = new (ELeave) TFileInput(iFile);
+    CleanupStack::PushL(TCleanupItem(&FileCleanup,file));
+    CInflater* inflater = CInflater::NewLC(*file);
+    
+    if (iHeader->iCodeSize)
+        {
+        TInt count = inflater->ReadL((TUint8*)iCodeLoadAddress, iCodeSize, &MemoryMove);
+        
+        if(count!=iCodeSize)
+            User::Leave(KErrCorrupt);
+        }
+
+    if (iRestOfFileSize)
+        {
+        TUint32 count = inflater->ReadL(iRestOfFileData, iRestOfFileSize, &Mem::Move);
+        
+        if(count!=iRestOfFileSize)
+            User::Leave(KErrCorrupt);
+        }
+    
+    CleanupStack::PopAndDestroy(2,file);
+    }
+
+// ---------------------------------------------------------------------------
+
+TInt E32ImageReader::Read(TText8* aDest, TInt aSize)
+    {
+    TPtr8 p(aDest,aSize,aSize);
+    return iFile.Read(p,aSize);
+    }
+
+// ---------------------------------------------------------------------------
+
+TInt E32ImageReader::Read(TInt aPos, TText8* aDest, TInt aSize)
+    {
+    TPtr8 p(aDest,aSize,aSize);
+    if (aPos<0)
+        return KErrCorrupt;
+    return iFile.Read(aPos,p,aSize);
+    }
+
+// ---------------------------------------------------------------------------
+
+TInt E32ImageReader::ReadImportData()
+    {
+    LOGSTRING("Launcher: E32ImageReader::ReadImportData");
+
+    if (!iHeader->iImportOffset)
+        return KErrNone;
+    
+    TUint32 bufferOffset = iHeader->iImportOffset-iConversionOffset;
+    
+    if(bufferOffset>iRestOfFileSize || bufferOffset+iImportSection->iSize>iRestOfFileSize)
+        return KErrCorrupt;
+    
+    iImportData = (TUint32*)(iRestOfFileData+bufferOffset);
+    
+    E32ImportSection* s = (E32ImportSection*)iImportData;
+    E32ImportBlock* b = (E32ImportBlock*)(s + 1);
+    TUint impfmt = iHeader->ImportFormat();
+    TInt i;
+    TInt n = 0;
+    
+    for (i=0; i<iDepCount; ++i)
+        {
+        if (b->iNumberOfImports > n)
+            n = b->iNumberOfImports;
+        b = (E32ImportBlock*)b->NextBlock(impfmt);
+        }
+    
+    iCurrentImportList = (TUint32*)User::Alloc(n * sizeof(TUint32));
+    
+    if (!iCurrentImportList)
+        return KErrNoMemory;
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+
+inline CInflater::CInflater(TBitInput& aInput)
+    :iBits(&aInput),iEncoding(0),iOut(0)
+    {}
+
+// ---------------------------------------------------------------------------
+
+void CInflater::ConstructL()
+    {
+    iEncoding=new(ELeave) TEncoding;
+    InitL();
+    iLen=0;
+    iOut=new(ELeave) TUint8[KDeflateMaxDistance];
+    iAvail=iLimit=iOut;
+    }
+
+// ---------------------------------------------------------------------------
+
+CInflater* CInflater::NewLC(TBitInput& aInput)
+    {
+    CInflater* self=new(ELeave) CInflater(aInput);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+
+CInflater::~CInflater()
+    {
+    delete iEncoding;
+    delete [] iOut;
+    }
+
+// ---------------------------------------------------------------------------
+
+TInt CInflater::ReadL(TUint8* aBuffer,TInt aLength, TMemoryMoveFunction aMemMovefn)
+    {
+    TInt tfr=0;
+    for (;;)
+        {
+        TInt len=Min(aLength,iLimit-iAvail);
+        if (len && aBuffer)
+            {
+            aMemMovefn(aBuffer,iAvail,len);
+            aBuffer+=len;
+            }
+        aLength-=len;
+        iAvail+=len;
+        tfr+=len;
+        if (aLength==0)
+            return tfr;
+        len=InflateL();
+        if (len==0)
+            return tfr;
+        iAvail=iOut;
+        iLimit=iAvail+len;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+TInt CInflater::SkipL(TInt aLength)
+    {
+    return ReadL(0,aLength,Mem::Move);
+    }
+
+// ---------------------------------------------------------------------------
+
+void CInflater::InitL()
+    {
+    Huffman::InternalizeL(*iBits,iEncoding->iLitLen,KDeflationCodes);
+
+    if (!Huffman::IsValid(iEncoding->iLitLen,TEncoding::ELitLens) ||
+        !Huffman::IsValid(iEncoding->iDistance,TEncoding::EDistances))
+        User::Leave(KErrCorrupt);
+
+    Huffman::Decoding(iEncoding->iLitLen,TEncoding::ELitLens,iEncoding->iLitLen);
+    Huffman::Decoding(iEncoding->iDistance,TEncoding::EDistances,iEncoding->iDistance,KDeflateDistCodeBase);
+    }
+
+// ---------------------------------------------------------------------------
+
+TInt CInflater::InflateL()
+    {
+    TUint8* out=iOut;
+    TUint8* const end=out+KDeflateMaxDistance;
+    const TUint32* tree=iEncoding->iLitLen;
+    if (iLen<0)    // EOF
+        return 0;
+    if (iLen>0)
+        goto useHistory;
+
+    while (out<end)
+        {
+        // get a huffman code
+        {
+        TInt val=iBits->HuffmanL(tree)-TEncoding::ELiterals;
+        if (val<0)
+            {
+            *out++=TUint8(val);
+            continue;        
+            }
+        if (val==TEncoding::EEos-TEncoding::ELiterals)
+            {    
+            iLen=-1;
+            break;
+            }
+        
+        TInt code=val&0xff;
+        if (code>=8)
+            {    
+            TInt xtra=(code>>2)-1;
+            code-=xtra<<2;
+            code<<=xtra;
+            code|=iBits->ReadL(xtra);
+            }
+        if (val<KDeflateDistCodeBase-TEncoding::ELiterals)
+            {
+            iLen=code+KDeflateMinLength;
+            tree=iEncoding->iDistance;
+            continue;        
+            }
+        
+        iRptr=out-(code+1);
+        if (iRptr+KDeflateMaxDistance<end)
+            iRptr+=KDeflateMaxDistance;
+        }
+useHistory:
+        TInt tfr=Min(end-out,iLen);
+        iLen-=tfr;
+        const TUint8* from=iRptr;
+        do
+            {
+            *out++=*from++;
+            if (from==end)
+                from-=KDeflateMaxDistance;
+            } while (--tfr!=0);
+        iRptr=from;
+        tree=iEncoding->iLitLen;
+        };
+    
+    return out-iOut;
+    }
+
+// ---------------------------------------------------------------------------
+
+TFileInput::TFileInput(RFile& aFile)
+    :iFile(aFile),iReadBuf(iBuf1),iPtr(iBuf1,KBufSize)
+    {
+    aFile.Read(iPtr,iStat);
+    }
+
+// ---------------------------------------------------------------------------
+
+void TFileInput::Cancel()
+    {
+    if (iReadBuf)
+        User::WaitForRequest(iStat);
+    }
+
+// ---------------------------------------------------------------------------
+
+void TFileInput::UnderflowL()
+    {
+    TUint8* b=iReadBuf;
+    ASSERT(b!=NULL);
+    User::WaitForRequest(iStat);
+    iReadBuf=0;
+    User::LeaveIfError(iStat.Int());
+    if(iPtr.Length()==0)
+        User::Leave(KErrCorrupt);
+    Set(b,iPtr.Length()*8);
+    
+    b = b==iBuf1 ? iBuf2 : iBuf1;
+    iPtr.Set(b,0,KBufSize);
+    iFile.Read(iPtr,iStat);
+    iReadBuf=b;
+    }
+
+// ---------------------------------------------------------------------------
+
+TFileNameInfo::TFileNameInfo()
+    {
+    memclr(this, sizeof(TFileNameInfo));
+    }
+
+// ---------------------------------------------------------------------------
+
+TInt TFileNameInfo::Set(const TDesC8& aFileName, TUint aFlags)
+    {
+    iUid = 0;
+    iVersion = 0;
+    iPathPos = 0;
+    iName = aFileName.Ptr();
+    iLen = aFileName.Length();
+    iExtPos = aFileName.LocateReverse('.');
+    if (iExtPos<0)
+        iExtPos = iLen;
+    TInt osq = aFileName.LocateReverse('[');
+    TInt csq = aFileName.LocateReverse(']');
+    if (!(aFlags & EAllowUid) && (osq>=0 || csq>=0))
+        {
+        return KErrBadName;
+        }
+    if (osq>=iExtPos || csq>=iExtPos)
+        {
+        return KErrBadName;
+        }
+    TInt p = iExtPos;
+    if ((aFlags & EAllowUid) && p>=10 && iName[p-1]==']' && iName[p-10]=='[')
+        {
+        TPtrC8 uidstr(iName + p - 9, 8);
+        TLex8 uidlex(uidstr);
+        TUint32 uid = 0;
+        TInt r = uidlex.Val(uid, EHex);
+        if (r==KErrNone && uidlex.Eos())
+            iUid = uid, p -= 10;
+        }
+    iUidPos = p;
+    TInt ob = aFileName.LocateReverse('{');
+    TInt cb = aFileName.LocateReverse('}');
+    if (ob>=iUidPos || cb>=iUidPos)
+        {
+        return KErrBadName;
+        }
+    if (ob>=0 && cb>=0 && p-1==cb)
+        {
+        TPtrC8 p8(iName, p);
+        TInt d = p8.LocateReverse('.');
+        TPtrC8 verstr(iName+ob+1, p-ob-2);
+        TLex8 verlex(verstr);
+        if (ob==p-10 && d<ob)
+            {
+            TUint32 ver = 0;
+            TInt r = verlex.Val(ver, EHex);
+            if (r==KErrNone && verlex.Eos())
+                iVersion = ver, p = ob;
+            }
+        else if (d>ob && p-1>d && (aFlags & EAllowDecimalVersion))
+            {
+            TUint32 maj = 0;
+            TUint32 min = 0;
+            TInt r = verlex.Val(maj, EDecimal);
+            TUint c = (TUint)verlex.Get();
+            TInt r2 = verlex.Val(min, EDecimal);
+            if (r==KErrNone && c=='.' && r2==KErrNone && verlex.Eos() && maj<32768 && min<32768)
+                iVersion = (maj << 16) | min, p = ob;
+            }
+        }
+    iVerPos = p;
+    if (iLen>=2 && iName[1]==':')
+        {
+        TUint c = iName[0];
+        if (c!='?' || !(aFlags & EAllowPlaceholder))
+            {
+            c |= 0x20;
+            if (c<'a' || c>'z')
+                {
+                return KErrBadName;
+                }
+            }
+        iPathPos = 2;
+        }
+    TPtrC8 pathp(iName+iPathPos, iVerPos-iPathPos);
+    if (pathp.Locate('[')>=0 || pathp.Locate(']')>=0 || pathp.Locate('{')>=0 || pathp.Locate('}')>=0 || pathp.Locate(':')>=0)
+        {
+        return KErrBadName;
+        }
+    iBasePos = pathp.LocateReverse('\\') + 1 + iPathPos;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+
+void TFileNameInfo::GetName(TDes8& aName, TUint aFlags) const
+    {
+    if (aFlags & EIncludeDrive)
+        aName.Append(Drive());
+    if (aFlags & EIncludePath)
+        {
+        if (PathLen() && iName[iPathPos]!='\\')
+            aName.Append('\\');
+        aName.Append(Path());
+        }
+    if (aFlags & EIncludeBase)
+        aName.Append(Base());
+    if ((aFlags & EForceVer) || ((aFlags & EIncludeVer) && VerLen()) )
+        {
+        aName.Append('{');
+        aName.AppendNumFixedWidth(iVersion, EHex, 8);
+        aName.Append('}');        
+        }
+    if ((aFlags & EForceUid) || ((aFlags & EIncludeUid) && UidLen()) )
+        {
+        aName.Append('[');
+        aName.AppendNumFixedWidth(iUid, EHex, 8);
+        aName.Append(']');
+        }
+    if (aFlags & EIncludeExt)
+        aName.Append(Ext());
+    }
+
+// ---------------------------------------------------------------------------
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/src/launcher.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#include "LauncherApplication.h"
+#include <eikstart.h>
+    
+
+LOCAL_C CApaApplication* NewApplication()
+    {
+    return new CLauncherApplication;
+    }
+
+GLDEF_C TInt E32Main()
+    {
+    return EikStart::RunApplication(NewApplication);
+    }
+
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/src/launcherapplication.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,37 @@
+/*
+* 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 "LauncherDocument.h"
+#include "LauncherApplication.h"
+
+// local constants
+static const TUid KUidLauncherApp = {0x101FB74F}; 
+
+CApaDocument* CLauncherApplication::CreateDocumentL()
+    {  
+    // Create an Launcher document, and return a pointer to it
+    CApaDocument* document = CLauncherDocument::NewL(*this);
+    return document;
+    }
+
+TUid CLauncherApplication::AppDllUid() const
+    {
+    // Return the UID for the Launcher application
+    return KUidLauncherApp;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/src/launcherappui.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,265 @@
+/*
+* 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 "LauncherAppUi.h"
+#include "LauncherViewApps.h"
+#include "LauncherViewOutput.h"
+#include <Launcher.rsg>
+#include "launcher.hrh"
+
+#include <avkon.hrh>
+#include <aknnotewrappers.h>
+#include <eikmenup.h>
+#include <aknmessagequerydialog.h>
+
+
+// ================= MEMBER FUNCTIONS =======================
+//
+// ----------------------------------------------------------
+// CLauncherAppUi::ConstructL()
+// ?implementation_description
+// ----------------------------------------------------------
+//
+void CLauncherAppUi::ConstructL()
+    {
+    BaseConstructL(EAknEnableSkin);
+
+    iSendUi = CSendUi::NewL();
+
+    // 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();
+        }
+
+    // init the engine class
+    iEngine = CLauncherEngine::NewL(this);
+
+    // init the apps view
+    CLauncherViewApps* view1 = new (ELeave) CLauncherViewApps;
+    CleanupStack::PushL( view1 );
+    view1->ConstructL(iEngine);
+    AddViewL( view1 );      // transfer ownership to CAknViewAppUi
+    CleanupStack::Pop();    // view1
+
+    // init the output view
+    CLauncherViewOutput* view2 = new (ELeave) CLauncherViewOutput;
+    CleanupStack::PushL( view2 );
+    view2->ConstructL(iEngine);
+    AddViewL( view2 );      // transfer ownership to CAknViewAppUi
+    CleanupStack::Pop();    // view2
+
+    // set apps view as default
+    SetDefaultViewL(*view1);
+
+    }
+
+// ----------------------------------------------------
+// CLauncherAppUi::~CLauncherAppUi()
+// Destructor
+// Frees reserved resources
+// ----------------------------------------------------
+//
+CLauncherAppUi::~CLauncherAppUi()
+    {
+    delete iEngine;
+
+    delete iDecoratedTabGroup;
+
+    delete iSendUi;
+    }
+
+// ------------------------------------------------------------------------------
+// CLauncherAppUi::::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 CLauncherAppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
+    {
+    if (aResourceId == R_LAUNCHER_APP_MENU)
+        {
+        // launch stop check
+        aMenuPane->SetItemDimmed(ECmdStopLaunch, !iEngine->LaunchingIsActive());
+
+        // deleting log is possible only when the log exists
+        aMenuPane->SetItemDimmed(ECmdDeleteLog, !(iEngine->LogFileExists() || iEngine->BCLogFileExists()));
+
+        // SendUI for the log file
+        if (iEngine->LogFileExists() || iEngine->BCLogFileExists())
+            {
+            TInt index(0);
+            aMenuPane->ItemAndPos( ECmdDeleteLog, index );
+            iSendUi->AddSendMenuItemL(*aMenuPane, index-1, ECmdSendUILogFile, TSendingCapabilities(0, 0, TSendingCapabilities::ESupportsAttachments));
+            aMenuPane->SetItemTextL(ECmdSendUILogFile, _L("Send log(s)"));
+            }
+        }
+
+    else if (aResourceId == R_LAUNCHER_DLLINFO_SUBMENU)
+        {
+        //SendUI for the system dll file
+        TInt index(0);
+        aMenuPane->ItemAndPos( ECmdCompareDLLs, index );
+
+        iSendUi->AddSendMenuItemL(*aMenuPane, index, ECmdSendUISystemDllFile, TSendingCapabilities(0, 0, TSendingCapabilities::ESupportsAttachments));
+        aMenuPane->SetItemTextL(ECmdSendUISystemDllFile, _L("Send list of DLLs"));
+        aMenuPane->SetItemButtonState(ECmdSendUISystemDllFile, EEikMenuItemSymbolIndeterminate); 
+        }
+    }
+
+// ----------------------------------------------------
+// CLauncherAppUi::HandleKeyEventL(
+//     const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
+// ----------------------------------------------------
+//
+TKeyResponse CLauncherAppUi::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;
+    }
+
+// ----------------------------------------------------
+// CLauncherAppUi::HandleCommandL(TInt aCommand)
+// ----------------------------------------------------
+//
+void CLauncherAppUi::HandleCommandL(TInt aCommand)
+    {
+    switch ( aCommand )
+        {
+        case EEikCmdExit:
+        case EAknSoftkeyExit:
+            {
+            Exit();
+            break;
+            }
+        case ECmdDeleteLog:
+            {
+            TInt ret = KErrNone;
+            
+            if( iEngine->LogFileExists())
+                {
+                ret = iEngine->DeleteLogFile();
+                }
+            if (ret == KErrNone)                
+                {
+                if( iEngine->BCLogFileExists())
+                    {
+                    ret = iEngine->DeleteBCLogFile();
+                    }
+                }            
+            if( ret == KErrNone )
+                {
+                _LIT(KMessage, "Log file(s) deleted");
+                CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
+                note->ExecuteLD(KMessage);
+                }
+            else
+                {
+                _LIT(KMessage, "Unable to delete");
+                CAknErrorNote* note = new(ELeave) CAknErrorNote;
+                note->ExecuteLD(KMessage);
+                }
+            break;
+            }        
+        case ECmdCompareDLLs:
+            {
+            iEngine->AnalyseDLLsL();
+            break;
+            }
+
+        case ECmdAbout:
+            {
+	        CAknMessageQueryDialog* dialog = new(ELeave) CAknMessageQueryDialog;
+            dialog->ExecuteLD(R_LAUNCHER_ABOUT_DIALOG);
+
+            break;
+            }
+
+        case ECmdStopLaunch:
+            {
+            iEngine->StopLaunchingL();
+            break;
+            }
+
+        case ECmdSendUILogFile:
+            {
+            iEngine->SendLogViaSendUiL(iSendUi);
+            break;
+            }
+
+        case ECmdSendUISystemDllFile:
+            {
+            iEngine->SendListOfSystemDllsViaSendUiL(iSendUi);
+            break;
+            }
+        case EAknSoftkeyCancel:
+            {
+            iEngine->Cancel();
+            break;
+            }
+        default:
+            {
+            }
+            break;      
+        }
+    }
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/src/launchercontainerapps.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,295 @@
+/*
+* 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 "LauncherContainerApps.h"
+#include "LauncherEngine.h"
+
+
+#include <eikclb.h>
+#include <eikclbd.h>
+#include <aknconsts.h>
+#include <aknutils.h>
+#include <aknnotewrappers.h>
+#include <akniconarray.h> 
+#include <f32file.h>
+#include <avkon.mbg>
+#include <AknIconUtils.h>
+#include <akndef.h>
+
+
+_LIT(KTab,"\t");
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CLauncherContainerApps::ConstructL(const TRect& aRect)
+// EPOC two phased constructor
+// ---------------------------------------------------------
+//
+void CLauncherContainerApps::ConstructL(const TRect& aRect, CLauncherEngine* aEngine)
+    {
+    iEngine = aEngine;
+
+    CreateWindowL();
+    Window().SetShadowDisabled(EFalse);
+    SetRect(aRect);
+
+    iListBox = new(ELeave) CAknSingleStyleListBox;
+    iListBox->SetContainerWindowL(*this);
+    iListBox->ConstructL(this, EAknListBoxMarkableList);
+    iListBox->View()->SetListEmptyTextL(_L("No apps found"));
+
+    iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue);
+
+    CAknIconArray* iconArray = new(ELeave) CAknIconArray(1);
+    CleanupStack::PushL(iconArray);
+    CFbsBitmap* markBitmap = NULL;
+    CFbsBitmap* markBitmapMask = NULL;
+    
+    TRgb defaultColor;
+    defaultColor = CEikonEnv::Static()->Color(EColorControlText);
+
+    AknsUtils::CreateColorIconL(AknsUtils::SkinInstance(),
+            KAknsIIDQgnIndiMarkedAdd,
+            KAknsIIDQsnIconColors,
+            EAknsCIQsnIconColorsCG13,
+            markBitmap,
+            markBitmapMask,
+            AknIconUtils::AvkonIconFileName(),
+            EMbmAvkonQgn_indi_marked_add,
+            EMbmAvkonQgn_indi_marked_add_mask,
+            defaultColor
+            );
+     
+    CGulIcon* markIcon = CGulIcon::NewL(markBitmap,markBitmapMask);
+    iconArray->AppendL(markIcon);                       
+    CleanupStack::Pop(); // iconArray
+
+    iListBox->ItemDrawer()->ColumnData()->SetIconArray(iconArray);
+
+    iListBox->CreateScrollBarFrameL(ETrue);
+    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
+    iListBox->SetListBoxObserver(this);
+    
+    // set size of the listbox
+    TSize outputRectSize;
+    AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, outputRectSize);
+    TRect outputRect(outputRectSize);
+    iListBox->SetRect(outputRect);
+
+
+    iListBox->ActivateL();
+   
+    //ActivateL();  
+    }
+
+// Destructor
+CLauncherContainerApps::~CLauncherContainerApps()
+    {
+    delete iListBox;
+    iListBox = NULL;
+    }
+
+// ---------------------------------------------------------
+
+const CArrayFix<TInt>* CLauncherContainerApps::SelectedApps()
+    {
+    const CListBoxView::CSelectionIndexArray* indices = iListBox->SelectionIndexes();
+    
+    return static_cast<const CArrayFix<TInt>*>(indices);
+    }
+
+// ---------------------------------------------------------
+
+void CLauncherContainerApps::UpdateFileListL()
+    {
+    // get list of all apps from the engine
+	CDesCArray* appFullPathsArray = iEngine->ListOfAllAppsL();
+		
+    // get an instance of the listbox's item array
+	MDesCArray* tempArray = iListBox->Model()->ItemTextArray();
+	CDesCArray* listBoxArray = (CDesCArray*)tempArray;
+	listBoxArray->Reset();
+
+	for ( TInt i=0; i<appFullPathsArray->Count(); i++)
+	    {
+        // parse the filename
+        TParse nameParser;
+        TInt err = nameParser.SetNoWild((*appFullPathsArray)[i], NULL, NULL);
+        
+        if (!err)
+		    {
+            TFileName name;
+            name.Copy(KTab);
+            name.Append(nameParser.Drive());
+            name.Append(nameParser.NameAndExt());
+            name.Append(KTab);
+            name.Append(KTab);
+
+		    listBoxArray->AppendL( name );
+            }
+        else
+            {
+		    listBoxArray->AppendL( _L("\t*invalid file*\t\t") );
+            }
+        }
+
+    // updates the listbox
+    iListBox->HandleItemAdditionL();
+    }
+
+// ---------------------------------------------------------
+// CLauncherContainerApps::SizeChanged()
+// Called by framework when the view size is changed
+// ---------------------------------------------------------
+//
+void CLauncherContainerApps::SizeChanged()
+{
+    TSize outputRectSize;
+    AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, outputRectSize);
+    TRect outputRect(outputRectSize);
+    
+    if (iListBox)
+        iListBox->SetRect(outputRect);
+}
+
+
+// ---------------------------------------------------------
+// CLauncherContainerApps::CountComponentControls() const
+// ---------------------------------------------------------
+//
+TInt CLauncherContainerApps::CountComponentControls() const
+    {
+    return 1; // return nbr of controls inside this container
+    }
+
+// ---------------------------------------------------------
+// CLauncherContainerApps::ComponentControl(TInt aIndex) const
+// ---------------------------------------------------------
+//
+CCoeControl* CLauncherContainerApps::ComponentControl(TInt /*aIndex*/) const
+    {
+    return iListBox;
+    }
+
+// ---------------------------------------------------------
+// CBCAppMainContainer::Draw(const TRect& aRect) const
+// ---------------------------------------------------------
+//
+void CLauncherContainerApps::Draw(const TRect& aRect) const
+    {
+    CWindowGc& gc = SystemGc();
+    gc.Clear(aRect);
+    }
+
+// ---------------------------------------------------------
+// CLauncherContainerApps::HandleControlEventL(
+//     CCoeControl* aControl,TCoeEvent aEventType)
+// ---------------------------------------------------------
+//
+void CLauncherContainerApps::HandleControlEventL(
+    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
+    {
+    }
+
+
+// ---------------------------------------------------------
+// CLauncherContainerApps::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 CLauncherContainerApps::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
+    {
+    if(aType != EEventKey)
+        return EKeyWasNotConsumed;
+
+    // handle OK key
+    if (aKeyEvent.iCode == EKeyOK)
+        {
+        if (iListBox->View()->ItemIsSelected(iListBox->CurrentItemIndex()))
+            {
+            AknSelectionService::HandleMarkableListProcessCommandL( EAknCmdUnmark, iListBox );
+            }
+        else
+            {
+            AknSelectionService::HandleMarkableListProcessCommandL( EAknCmdMark, iListBox );
+            }
+
+        return EKeyWasNotConsumed;
+        }
+    
+    // left and right keys are needed by other class
+    else if (aKeyEvent.iCode == EKeyLeftArrow || aKeyEvent.iCode == EKeyRightArrow)
+        return EKeyWasNotConsumed;
+
+    else
+        return iListBox->OfferKeyEventL(aKeyEvent, aType);
+    }
+
+// ---------------------------------------------------------
+
+void CLauncherContainerApps::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
+    {
+    switch (aEventType)
+        {
+        case EEventEnterKeyPressed:
+        case EEventItemDoubleClicked:
+            {
+            if (iListBox->View()->ItemIsSelected(iListBox->CurrentItemIndex()))
+                {
+                AknSelectionService::HandleMarkableListProcessCommandL( EAknCmdUnmark, iListBox );
+                }
+            else
+                {
+                AknSelectionService::HandleMarkableListProcessCommandL( EAknCmdMark, iListBox );
+                }            
+            }
+            break;
+        default:
+            break;
+        }
+    }
+    
+// ---------------------------------------------------------
+//
+
+void CLauncherContainerApps::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);
+        iListBox->SetRect(outputRect);
+        }
+    else
+        {
+        CCoeControl::HandleResourceChange(aType);
+        }
+    }
+
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/src/launchercontaineroutput.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,348 @@
+/*
+* 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 "LauncherContainerOutput.h"
+#include "LauncherEngine.h"
+
+
+#include <AknBidiTextUtils.h>
+#include <aknutils.h>
+#include <aknnotewrappers.h>
+#include <eiksbfrm.h>
+#include <akndef.h>
+
+const TUint KLeftMargin = 2;
+const TUint KRightMargin = 2;
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+
+void CLauncherContainerOutput::ConstructL(const TRect& aRect, CLauncherEngine* aEngine)
+    {
+    iEngine = aEngine;
+
+    CreateWindowL();
+    Window().SetShadowDisabled(EFalse);
+    
+    SetBlank();
+
+    iText = HBufC::NewL(200000);
+    iCurrentLine = 0;
+    iLineCount = 0;
+    iNumberOfLinesFitsScreen = 0;
+    iX_factor = 1;
+    iY_factor = 1;
+    iLeftDrawingPosition = KLeftMargin;
+
+    iFont = AknLayoutUtils::FontFromId(EAknLogicalFontSecondaryFont);
+
+    iWrappedArray = new(ELeave) CArrayFixFlat<TPtrC>(500);
+
+    
+    SetRect(aRect);
+    //ActivateL(); 
+
+
+    PrintTextL(_L("Ready.\n\n"));
+
+    }
+
+CLauncherContainerOutput::~CLauncherContainerOutput()
+    {
+    if (iWrappedArray)
+        {
+        iWrappedArray->Reset();
+        delete iWrappedArray;
+        }
+
+    if (iText)
+        delete iText;
+
+    if (iScrollBarFrame)
+        delete iScrollBarFrame;
+
+    if (iWrapperString)
+        delete iWrapperString;
+    }
+
+
+// ---------------------------------------------------------
+// CLauncherContainerOutput::UpdateVisualContentL()
+// ---------------------------------------------------------
+//
+void CLauncherContainerOutput::UpdateVisualContentL(TBool aScrollToBottom, TBool aScrollToTop)
+    {
+    TSize rectSize;
+    AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, rectSize);
+    TRect rect(rectSize);
+
+    // 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 )
+        {
+        if( iCurrentLine < iLineCount - iNumberOfLinesFitsScreen)
+            {
+            iCurrentLine = iLineCount-iNumberOfLinesFitsScreen;
+            }
+        }
+    else if( aScrollToTop )
+        {
+        iCurrentLine = 0;
+        }
+
+    // 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();
+    }
+
+// ---------------------------------------------------------
+// CLauncherContainerOutput::Draw(const TRect& aRect) const
+// ---------------------------------------------------------
+//
+void CLauncherContainerOutput::Draw(const TRect& aRect) const
+    {
+    CWindowGc& gc = SystemGc();
+    gc.Clear(aRect);
+    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))));
+        }
+    }
+
+// ---------------------------------------------------------
+// CLauncherContainerOutput::HandleControlEventL(
+//     CCoeControl* aControl,TCoeEvent aEventType)
+// ---------------------------------------------------------
+//
+void CLauncherContainerOutput::HandleControlEventL(
+    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
+    {
+    }
+
+// ---------------------------------------------------------
+// CLauncherContainerOutput::PrintTextL(const TDesC& aDes)
+// Print text into output window.
+// ---------------------------------------------------------
+//
+void CLauncherContainerOutput::PrintTextL(const TDesC& aDes)
+    {
+    iText->Des().Append( aDes );
+    UpdateVisualContentL(ETrue);
+    }
+
+// ---------------------------------------------------------
+// CLauncherContainerOutput::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 CLauncherContainerOutput::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;
+    }
+
+
+// ---------------------------------------------------------
+// CLauncherContainerOutput::ClearOutputWindowL()
+// Clear the output window.
+// ---------------------------------------------------------
+//
+void CLauncherContainerOutput::ClearOutputWindowL()
+    {
+    iText->Des() = _L("");
+    UpdateVisualContentL(EFalse, ETrue);
+    }
+
+// ---------------------------------------------------------
+// CLauncherContainerOutput::HandleResourceChange(TInt aType)
+// Handle layout change of the screen
+// ---------------------------------------------------------
+//
+
+void CLauncherContainerOutput::HandleResourceChange(TInt aType)
+    {
+    if ( aType == KEikDynamicLayoutVariantSwitch )
+        {
+        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;
+            }
+        TRAP_IGNORE(UpdateVisualContentL(EFalse));
+        }
+    else
+        {
+        CCoeControl::HandleResourceChange(aType);
+        }
+    }
+
+// ---------------------------------------------------------
+// CLauncherContainerOutput::HandleScrollEventL()
+// Capture touch events on the scroll bar
+// ---------------------------------------------------------
+//
+void CLauncherContainerOutput::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  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/src/launcherdllelement.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,191 @@
+/*
+* 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 "launcherdllelement.h"
+#include "launchertraces.h"
+
+// ---------------------------------------------------------------------------
+
+CLauncherDLLElement::~CLauncherDLLElement()
+    {
+    LOGSTRING("Launcher: CLauncherDLLElement::~CLauncherDLLElement");    
+    }
+
+// ---------------------------------------------------------------------------
+
+CLauncherDLLElement::CLauncherDLLElement()
+    {    
+    }
+
+// ---------------------------------------------------------------------------
+
+CLauncherDLLElement* CLauncherDLLElement::NewL()
+    {
+    LOGSTRING("Launcher: CLauncherDLLElement::NewL");
+    CLauncherDLLElement* self = CLauncherDLLElement::NewLC();    
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+
+CLauncherDLLElement* CLauncherDLLElement::NewLC()
+    {
+    LOGSTRING("Launcher: CLauncherDLLElement::NewLC");
+    CLauncherDLLElement* self = new (ELeave) CLauncherDLLElement;
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherDLLElement::ConstructL()
+    {
+    
+    }
+
+// ---------------------------------------------------------------------------
+   
+TBool CLauncherDLLElement::CompareL(const CLauncherDLLElement& aReferenceElement, RArray<TDifference>& aDifferenceList) const
+    {
+    LOGSTRING2("Launcher: CLauncherDLLElement::CompareL - DLLName: %S", &iName);
+    if( iName != aReferenceElement.Name())
+        {
+        LOGSTRING("Launcher: CLauncherDLLElement::CompareL: ERROR - DLL names don't match.");
+        User::Leave(KErrArgument);
+        }
+    
+    TBool diff = EFalse;
+            
+    if( iUID1 != aReferenceElement.UID1()) 
+        {
+        diff = ETrue;
+        aDifferenceList.Append(this->EDifference_UID1);      
+        LOGSTRING3("Launcher: CLauncherDLLElement::CompareL - UID1s differs: %x vs. %x", iUID1, aReferenceElement.UID1());  
+        }
+    if( iUID2!= aReferenceElement.UID2()) 
+        {
+        diff = ETrue;
+        aDifferenceList.Append(this->EDifference_UID2);        
+        LOGSTRING3("Launcher: CLauncherDLLElement::CompareL - UID2s differs: %x vs. %x", iUID2, aReferenceElement.UID2());  
+        }
+    if( iUID3 != aReferenceElement.UID3()) 
+        {
+        diff = ETrue;
+        aDifferenceList.Append(this->EDifference_UID3);        
+        LOGSTRING3("Launcher: CLauncherDLLElement::CompareL - UID3s differs: %x vs. %x", iUID3, aReferenceElement.UID3());  
+        }
+    if( iSID != aReferenceElement.SID()) 
+        {
+        diff = ETrue;
+        aDifferenceList.Append(this->EDifference_SID);        
+        LOGSTRING3("Launcher: CLauncherDLLElement::CompareL - SIDs differs: %x vs. %x", iSID, aReferenceElement.SID());  
+        }
+    if( iCapability != aReferenceElement.Capability()) 
+        {
+        diff = ETrue;
+        aDifferenceList.Append(this->EDifference_Capability);        
+        LOGSTRING3("Launcher: CLauncherDLLElement::CompareL - Capabilities differs: %x vs. %x", iCapability, aReferenceElement.Capability());  
+        }
+    
+    return diff;
+    }
+
+// ---------------------------------------------------------------------------
+
+TFileName CLauncherDLLElement::Name() const
+    {
+    return iName;
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherDLLElement::SetNameL(const TFileName& aName)
+    {    
+    iName.Copy(aName); 
+    }
+
+// ---------------------------------------------------------------------------
+
+TUid CLauncherDLLElement::UID1() const
+    {
+    return iUID1;
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherDLLElement::SetUID1L(TUid aUID1)
+    {
+    iUID1.iUid = aUID1.iUid;
+    }
+
+// ---------------------------------------------------------------------------
+
+TUid CLauncherDLLElement::UID2() const
+    {
+    return iUID2;
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherDLLElement::SetUID2L(TUid aUID2)
+    {    
+    iUID2 = aUID2;
+    }
+
+// ---------------------------------------------------------------------------
+
+TUid CLauncherDLLElement::UID3() const
+    {    
+    return iUID3;
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherDLLElement::SetUID3L(TUid aUID3)
+    {    
+    iUID3 = aUID3;
+    }
+
+// ---------------------------------------------------------------------------
+
+TUid CLauncherDLLElement::SID() const
+    {   
+    return iSID;
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherDLLElement::SetSIDL(TUid aSID)
+    {    
+    iSID = aSID;
+    }
+
+// ---------------------------------------------------------------------------
+
+TUint32 CLauncherDLLElement::Capability() const
+    {
+    return iCapability;    
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherDLLElement::SetCapabilityL(TUint32 aCapability)
+    {
+    iCapability = aCapability; 
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/src/launcherdllparser.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,133 @@
+/*
+* 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 "launcherdllparser.h"
+#include "launchertraces.h"
+
+// ---------------------------------------------------------------------------
+
+CLauncherDLLParser::~CLauncherDLLParser()
+    {
+    LOGSTRING("Launcher: CLauncherDLLParser::~CLauncherDLLParser");
+    }
+
+// ---------------------------------------------------------------------------
+
+CLauncherDLLParser::CLauncherDLLParser()
+    {
+    LOGSTRING("Launcher: CLauncherDLLParser::CLauncherDLLParser");
+    }
+
+// ---------------------------------------------------------------------------
+
+CLauncherDLLParser* CLauncherDLLParser::NewL()
+    {
+    LOGSTRING("Launcher: CLauncherDLLParser::NewL");
+    CLauncherDLLParser* self = CLauncherDLLParser::NewLC();    
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+
+CLauncherDLLParser* CLauncherDLLParser::NewLC()
+    {
+    LOGSTRING("Launcher: CLauncherDLLParser::NewLC");
+    CLauncherDLLParser* self = new (ELeave) CLauncherDLLParser;
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherDLLParser::ConstructL()
+    {
+    
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherDLLParser::ParseL( RFs& aFileSession, RFile& aFile, CLauncherDLLElement& aElement )
+    {
+    TFileName dllName;
+    TFileName fullName;
+    TUid tmpUID;
+    TInt offset = 0;
+        
+    aFile.Name(dllName);
+    aFile.FullName(fullName);
+    aElement.SetNameL(dllName);
+    
+    TBool isFileInRom = aFileSession.IsFileInRom(fullName) != 0;
+    
+    /**
+     * Read UID1
+     */
+    offset = UID1_OFFSET;
+    aFile.Seek(ESeekStart, offset); // Set file position   
+    tmpUID.iUid = ReadUint32L(aFile);    
+    aElement.SetUID1L(tmpUID);    
+    
+    /**
+     * Read UID2
+     */
+    offset = UID2_OFFSET;
+    aFile.Seek(ESeekStart, offset); // Set file position
+    tmpUID.iUid = ReadUint32L(aFile);    
+    aElement.SetUID2L(tmpUID);
+        
+    /**
+     * Read UID3
+     */
+    offset = UID3_OFFSET;
+    aFile.Seek(ESeekStart, offset); // Set file position
+    tmpUID.iUid = ReadUint32L(aFile);    
+    aElement.SetUID3L(tmpUID);
+        
+    /**
+     * Read SID
+     */
+    if( isFileInRom )
+        offset = SID_OFFSET_ROM;
+    else
+        offset = SID_OFFSET_ROFS;
+    aFile.Seek(ESeekStart, offset); // Set file position
+    tmpUID.iUid = ReadUint32L(aFile);    
+    aElement.SetSIDL(tmpUID);
+    
+    /**
+     * Read Capability
+     */
+    if( isFileInRom )
+        offset = CAPABILITY_OFFSET_ROM;
+    else
+        offset = CAPABILITY_OFFSET_ROFS;
+    aFile.Seek(ESeekStart, offset); // Set file position
+    TUint32 tmpVal = ReadUint32L(aFile);
+    aElement.SetCapabilityL(tmpVal);    
+    }
+
+// ---------------------------------------------------------------------------
+
+TUint32 CLauncherDLLParser::ReadUint32L( RFile& aFile )
+    {
+    TBuf8<4> tempBuf;    
+    User::LeaveIfError(aFile.Read(tempBuf, 4));
+    const TUint8* ptr = tempBuf.Ptr();    
+    return TUint32(ptr[0] | (ptr[1]<<8) | (ptr[2]<<16) | (ptr[3]<<24));    
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/src/launcherdocument.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,61 @@
+/*
+* 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 "LauncherAppUi.h"
+#include "LauncherDocument.h"
+
+
+// Standard Symbian OS construction sequence
+CLauncherDocument* CLauncherDocument::NewL(CEikApplication& aApp)
+    {
+    CLauncherDocument* self = NewLC(aApp);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CLauncherDocument* CLauncherDocument::NewLC(CEikApplication& aApp)
+    {
+    CLauncherDocument* self = new (ELeave) CLauncherDocument(aApp);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+void CLauncherDocument::ConstructL()
+    {
+    // Add any construction that can leave here
+    }    
+
+CLauncherDocument::CLauncherDocument(CEikApplication& aApp) : CAknDocument(aApp) 
+    {
+    // Add any construction that can not leave here
+    }   
+
+CLauncherDocument::~CLauncherDocument()
+    {
+    // Any destruction code here
+    }
+
+CEikAppUi* CLauncherDocument::CreateAppUiL()
+    {
+    // Create the application user interface, and return a pointer to it
+    CEikAppUi* appUi = new (ELeave) CLauncherAppUi;
+    return appUi;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/src/launcherengine.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,1796 @@
+/*
+* 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 <aknnotewrappers.h>
+#include <avkon.hrh>
+#include <aknwaitdialog.h>
+#include <aknglobalnote.h>
+#include <coeutils.h> 
+#include <akncommondialogs.h>
+#include <eikprogi.h>
+
+#include <LAUNCHER.rsg>
+
+#include "LauncherAppUi.h"
+#include "LauncherEngine.h"
+#include "Launcher.hrh"
+#include "LauncherViewApps.h"
+#include "LauncherViewOutput.h"
+#include "LauncherContainerApps.h"
+#include "LauncherContainerOutput.h"
+#include "launcherdllparser.h"
+#include "launcherxmlparser.h"
+
+#include <CMessageData.h>
+#include <e32std.h>
+#include <w32std.h>
+#include <apgtask.h>
+#include <bautils.h>
+#include <s32file.h>
+#include <pathinfo.h> 
+#include <e32cmn.h>
+
+#include "LauncherTraces.h"
+#include "E32Image.h"
+
+_LIT(KLogFileName, "LauncherLog.txt");
+_LIT(KBCLogFileName, "LauncherBCLog.txt");
+_LIT(KSystemDllsFileName, "SystemDlls.txt");
+_LIT(KRequiredDllsFileName, "RequiredDlls.xml");
+_LIT(KDotXML,".xml");
+_LIT(KDotLauncherXML,".launcherxml");
+
+_LIT(KFileSeparator, "\t");
+_LIT(KFileNewLine, "\r\n");
+
+const TInt KMaxAppsArraySize=250;
+const TInt KMaxDllArraySize=5000;
+const TInt KLauncherLogBufferSize = 4096;
+
+// After this many issues, issues are buffered and printed 
+// in the end of analysis
+const TInt KBigBufferUsageThreshold=10;
+
+// Buffer allocation unit
+const TInt KBigBufferAllocBytes=1024;
+
+// ---------------------------------------------------------------------------
+
+CLauncherEngine* CLauncherEngine::NewL(CLauncherAppUi* aAppUi)
+    {
+    CLauncherEngine* self = new(ELeave) CLauncherEngine;
+    CleanupStack::PushL(self);
+    self->ConstructL(aAppUi);
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+
+CLauncherEngine::CLauncherEngine() : CActive(EActivePriorityIpcEventsHigh)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+
+template <typename T>
+void AppendLogBufferL(const T& aText, HBufC8*& aBuf)
+    {
+    if( aBuf == 0 )
+        {
+        aBuf = HBufC8::NewL(KLauncherLogBufferSize);
+        }
+    
+    TInt currentMaxLength = aBuf->Des().MaxLength();
+    if( aBuf->Des().Length() + aText.Length() > currentMaxLength )
+        {
+        TInt increaseSize = Max(aText.Length(), KLauncherLogBufferSize);                
+        aBuf = aBuf->ReAllocL(aBuf->Des().MaxLength() + increaseSize );
+        }
+    aBuf->Des().Append(aText);        
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::ConstructL(CLauncherAppUi* aAppUi)
+    {
+    LOGSTRING("Launcher: CLauncherEngine::ConstructL");
+
+    iAppUi = aAppUi;
+    iEnv = CEikonEnv::Static();
+    iLaunchingIsActive = EFalse;
+    iDLLAnalysisIsActive = EFalse;
+    iSkipHiddenAndEmbedOnly = ETrue;
+
+    User::LeaveIfError(iTimer.CreateLocal());
+
+    User::LeaveIfError(iLs.Connect());
+    User::LeaveIfError(iWs.Connect());
+
+    iAppThreadChecker = CAppThreadChecker::NewL(this);
+    iAppRunningChecker = CAppRunningChecker::NewL(this);
+
+    iAllAppsArray = new(ELeave) CDesCArrayFlat(KMaxAppsArraySize);
+    iAppsArray = new(ELeave) CDesCArrayFlat(KMaxAppsArraySize);
+    iSystemDllArray = new(ELeave) CDesCArrayFlat(KMaxDllArraySize);
+
+    iLogWriteBuf = HBufC8::NewL(KLauncherLogBufferSize);
+
+    iLogFilePath = PathInfo::PhoneMemoryRootPath();
+    iLogFilePath.Append( KLogFileName );
+    
+    iBCLogFilePath = PathInfo::PhoneMemoryRootPath();
+    iBCLogFilePath.Append( KBCLogFileName );
+
+    iSystemDllsFilePath = PathInfo::PhoneMemoryRootPath();
+    iSystemDllsFilePath.Append( KSystemDllsFileName );
+
+    iRequiredDllsFilePath = PathInfo::PhoneMemoryRootPath();
+    iRequiredDllsFilePath.Append( KRequiredDllsFileName );
+            
+    iDLLParser = CLauncherDLLParser::NewL();
+
+    CActiveScheduler::Add(this);
+    }
+
+// ---------------------------------------------------------------------------
+
+CLauncherEngine::~CLauncherEngine()
+    {
+    LOGSTRING("Launcher: CLauncherEngine::~CLauncherEngine");
+
+    Cancel();
+
+    // close the log
+    iLogFile.Close();
+    iBCLogFile.Close();
+    if (iLogWriteBuf)
+        delete iLogWriteBuf;
+
+    if (iAppRunningChecker)
+        delete iAppRunningChecker;
+    
+    if (iAppThreadChecker)
+        delete iAppThreadChecker;
+
+    if (iSystemDllArray)
+        {
+        iSystemDllArray->Reset();
+        delete iSystemDllArray;
+        }
+
+    if (iAppsArray)
+        {
+        iAppsArray->Reset();
+        delete iAppsArray;
+        }
+
+    if (iAllAppsArray)
+        {
+        iAllAppsArray->Reset();
+        delete iAllAppsArray;
+        }
+    
+    delete iXMLParser;
+    delete iDLLParser;
+    delete iDLLElement;
+    delete iBCIssuesBigBuffer;            
+    
+    iWs.Close();
+    iLs.Close();
+    iTimer.Close();
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::SetContainerApps(CLauncherContainerApps* aContainerApps)
+    {
+    iContainerApps = aContainerApps;
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::SetContainerOutput(CLauncherContainerOutput* aContainerOutput)
+    {
+    iContainerOutput = aContainerOutput;
+    }
+
+// ---------------------------------------------------------------------------
+
+
+TInt CLauncherEngine::FindFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath)
+    {
+    TInt err = KErrNone;
+    CDirScan* scan = CDirScan::NewLC(iEnv->FsSession());
+    scan->SetScanDataL(aPath, KEntryAttDir, ESortNone);
+    CDir* dirEntries = NULL;
+
+    for(;;)
+        {
+        TRAP(err, scan->NextL(dirEntries));
+        if (!dirEntries  || (err!=KErrNone))
+            break;
+
+        for (TInt i=0; i<dirEntries->Count(); i++) 
+            {
+            TFileName path(scan->FullPath());
+            path.Append((*dirEntries)[i].iName);
+            path.Append(_L("\\"));
+            FindFiles(aFileName, path);
+            }
+        delete(dirEntries);
+        }
+
+    CleanupStack::PopAndDestroy(scan);
+    return err;
+    }
+
+// ---------------------------------------------------------------------------
+
+TInt CLauncherEngine::FindFiles(const TDesC& aFileName, const TDesC& aPath)
+    {
+    TFindFile fileFinder(iEnv->FsSession());
+    CDir* fileList; 
+    TInt err = fileFinder.FindWildByDir(aFileName, aPath, fileList);
+
+    while (err == KErrNone)
+        {
+        for (TInt i=0; i<fileList->Count(); i++)
+            {
+            TParse fullentry;
+            fullentry.Set((*fileList)[i].iName, &fileFinder.File(), NULL);
+
+            TRAP(err, iSystemDllArray->AppendL(fullentry.NameAndExt())); 
+            }
+
+        delete fileList;
+        err = fileFinder.FindWild(fileList);
+        }
+    return err;
+    }
+
+// ---------------------------------------------------------------------------
+
+CDesCArray* CLauncherEngine::ListOfAllAppsL()
+    {
+    LOGSTRING("Launcher: CLauncherEngine::ListOfAllAppsL");
+
+    // show wait dialog
+    CAknGlobalNote* waitDialog = CAknGlobalNote::NewLC();
+    waitDialog->SetSoftkeys(R_AVKON_SOFTKEYS_EMPTY);
+    TInt dialogId = waitDialog->ShowNoteL(EAknGlobalWaitNote, _L("Initializing"));
+
+
+    // find all DLLs from the system
+    iSystemDllArray->Reset();
+    TRAP_IGNORE( FindFiles(_L("*.dll"), _L("\\sys\\bin\\")) );
+
+    // write the list of DLLs to a file
+    RFile dllFile;
+    if (dllFile.Replace(iEnv->FsSession(), iSystemDllsFilePath, EFileWrite) == KErrNone)
+        {
+        TBuf8<KMaxFileName> dllName;
+
+        for (TInt i=0; i<iSystemDllArray->MdcaCount(); i++)
+            {
+            dllName.Copy( iSystemDllArray->MdcaPoint(i) );
+            dllName.Append( KFileNewLine );
+
+            dllFile.Write( dllName );
+            }
+
+        dllFile.Close();
+        }
+
+    // reset the apps list
+    iAllAppsArray->Reset();
+
+    // search all apps
+    TApaAppInfo appInfo;
+    iLs.GetAllApps();
+
+    while (iLs.GetNextApp(appInfo) == KErrNone)
+        {
+        iAllAppsArray->AppendL(appInfo.iFullName);
+        }
+
+
+    // remove launcher.app / launcher.exe from the list
+    for (TInt i=0; i<iAllAppsArray->MdcaCount(); i++)
+        {
+        if (iAllAppsArray->MdcaPoint(i).FindF(_L("\\Launcher.")) != KErrNotFound)
+            {
+            iAllAppsArray->Delete(i);
+            iAllAppsArray->Compress();
+            break;
+            }
+        }
+
+    // sort the elements
+    iAllAppsArray->Sort();
+
+    // remove the wait dialog
+    waitDialog->CancelNoteL(dialogId);
+    CleanupStack::PopAndDestroy(); //waitDialog;
+       
+    return iAllAppsArray;
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::StartAppLaunchingL(const CArrayFix<TInt>* aSelectedApps, TBool aAutoClose)
+    {
+    LOGSTRING("Launcher: CLauncherEngine::StartAppLaunchingL");
+
+    // check that we have something to launch
+    if (aSelectedApps->Count() <= 0)
+        {
+        _LIT(message, "Nothing selected");
+        CAknErrorNote* errorNote = new(ELeave) CAknErrorNote;
+        errorNote->ExecuteLD(message);
+        }
+    else
+        {
+        // update the list of applications to be tested
+        iAppsArray->Reset();
+
+        TInt ref(0);
+        TKeyArrayFix key(0, ECmpTUint16);
+        TInt index(0);
+
+        for (TInt i=0; i<iAllAppsArray->MdcaCount(); i++)
+            {
+            ref = i;
+
+            // if the application is selected, append it to the apps array
+            if (aSelectedApps->Find(ref, key, index) == 0)  
+                {
+                iAppsArray->AppendL(iAllAppsArray->MdcaPoint(i));
+                }
+            }
+
+
+        // to make sure that our algorithm works correctly
+        if (iAppsArray->MdcaCount() != aSelectedApps->Count())
+            {
+            _LIT(message, "Something went wrong...");
+            CAknErrorNote* errorNote = new(ELeave) CAknErrorNote;
+            errorNote->ExecuteLD(message);
+            return;
+            }
+
+        
+        // init
+        Cancel();
+        iLaunchingIsActive = ETrue;
+        iAutoClose = aAutoClose;
+        iAppLaunchCounter = 0;
+        iFailedCases = 0;
+        iOkCases = 0;
+        iSkippedCases = 0;
+        iTotalNumberOfCases = iAppsArray->MdcaCount();
+        iCurrentAppUid = KNullUid;
+
+        // open the log file for writing
+        if (iLogFile.Open(iEnv->FsSession(), iLogFilePath, EFileWrite) != KErrNone)
+            {
+            iEnv->FsSession().MkDirAll(iLogFilePath);
+            iLogFile.Replace(iEnv->FsSession(), iLogFilePath, EFileWrite);
+            }
+        else
+            {
+            // file opens correctly, seek to the end
+            TInt fileSize=0;
+            iLogFile.Size(fileSize);
+            iLogFile.Seek(ESeekCurrent, fileSize);
+            }
+
+        ChangeFocusToOutputView();
+
+        iContainerOutput->PrintTextL(_L("New test started.\n"));
+
+        // start the first launch!
+        IssueLaunch();
+
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::IssueLaunch()
+    {
+    LOGSTRING("Launcher: CLauncherEngine::IssueLaunch");
+
+    __ASSERT_ALWAYS(!IsActive(), User::Panic(_L("Timing error?"), 100));
+
+    // this should keep the backlight on
+    User::ResetInactivityTime();
+
+    // some delay
+    iTimer.After(iStatus, 1000000);    
+    SetActive();
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::RunL()
+    {
+    LOGSTRING("Launcher: CLauncherEngine::RunL");  
+    TInt err = iStatus.Int();
+    User::LeaveIfError(err);
+    
+    if( iDLLAnalysisIsActive )
+        {
+        if( iWaitDialog == 0)
+            {
+            TEntry entry;
+            User::LeaveIfError(iEnv->FsSession().Entry(iRequiredDllsFilePath, entry));
+            TInt fileSize = entry.iSize;
+
+            // init progress bar
+            iWaitDialog = new(ELeave) CAknProgressDialog((reinterpret_cast<CEikDialog**>(&iWaitDialog)), ETrue);
+            iWaitDialog->SetCallback(this);
+            iWaitDialog->PrepareLC(R_GENERAL_PROGRESS_NOTE);
+            iWaitDialog->SetCurrentLabelL( EAknCtNote, _L("Analysing DLLs"));
+            iProgressInfo = iWaitDialog->GetProgressInfoL();
+            iProgressInfo->SetFinalValue( fileSize );
+            iWaitDialog->RunLD();
+            iWaitDialog->MakeVisible( ETrue );
+            }
+        
+        iBCLogFile.Write(iLogWriteBuf->Des());
+        iLogWriteBuf->Des().Zero();
+        return;
+        }
+    else
+        {
+        // write full app path to the log file
+        WriteInitialStuffToTheLogL(iAppsArray->MdcaPoint(iAppLaunchCounter), iLogFile);
+
+        // get the uid of the current app
+        iCurrentAppUid = KNullUid;
+        TApaAppInfo appInfo;
+        iLs.GetAllApps();
+        while (iLs.GetNextApp(appInfo) == KErrNone)
+            {
+            if (appInfo.iFullName.CompareF( iAppsArray->MdcaPoint(iAppLaunchCounter) ) == 0)
+                {
+                iCurrentAppUid = appInfo.iUid;
+                break;
+                }
+            }
+
+        if (iCurrentAppUid == KNullUid)
+            {        
+            iLogWriteBuf->Des().Append(_L("[WARN: App has no UID] "));
+            }
+
+        // parse the filename
+        TParse nameParser;
+        nameParser.SetNoWild(iAppsArray->MdcaPoint(iAppLaunchCounter), NULL, NULL);
+        iCurrentAppNameAndExt.Copy(nameParser.Drive());
+        iCurrentAppNameAndExt.Append(nameParser.NameAndExt());
+
+        // do not try to launch these apps
+        if (iAppsArray->MdcaPoint(iAppLaunchCounter).FindF(_L("\\Launcher.")) != KErrNotFound
+            || iAppsArray->MdcaPoint(iAppLaunchCounter).FindF(_L("\\Phone.")) != KErrNotFound
+            || iAppsArray->MdcaPoint(iAppLaunchCounter).FindF(_L("\\Startup.")) != KErrNotFound  
+            || iAppsArray->MdcaPoint(iAppLaunchCounter).FindF(_L("\\SplashScreen.")) != KErrNotFound  
+            || iAppsArray->MdcaPoint(iAppLaunchCounter).FindF(_L("\\eshell.")) != KErrNotFound)  
+            {
+            iContainerOutput->PrintTextL(iCurrentAppNameAndExt);
+            iContainerOutput->PrintTextL(_L(": SKIPPED automatically\n"));
+
+            iLogWriteBuf->Des().Append(_L("[SKIPPED automatically] "));
+            iLogWriteBuf->Des().Append(KFileNewLine);
+            iLogFile.Write(iLogWriteBuf->Des());
+
+            iSkippedCases++;
+            CheckForMoreAppsL();
+            }
+
+        else
+            {
+
+            // dependency check not needed if the app is in the ROM/ROFS, because they'll be checked automatically
+            // when the rom image is built
+            
+            if (iCurrentAppNameAndExt[0] != 'Z' && iCurrentAppNameAndExt[0] != 'z')
+                {
+
+                if (iCurrentAppNameAndExt[2] == '[')  // this is quite likely a Java application, no dependency test needed 
+                    {
+                    iLogWriteBuf->Des().Append(_L("[Dependency check not done] "));
+                    }
+                else
+                    {  // otherwise check depencies
+                
+                    #ifdef __WINS__
+                    
+                        // emulator not supported
+
+                    #else
+
+                        // ELF binaries
+
+                        CDesCArray* missingDllArray = NULL;
+
+                        TRAPD(err, missingDllArray = DependencyCheckForE32ImageL());
+
+                        // some error happened while processing the E32 image
+                        if (err != KErrNone)
+                            {
+                            iContainerOutput->PrintTextL(iCurrentAppNameAndExt);
+                            iContainerOutput->PrintTextL(_L(": unable to read import table!\n"));
+
+                            iLogWriteBuf->Des().Append(_L("[Unable to read import table!] "));
+                            }
+
+                        // print missing dependencies
+                        else if (err==KErrNone && missingDllArray)
+                            {
+                            if (missingDllArray->MdcaCount() > 0)
+                                {
+                                iContainerOutput->PrintTextL(iCurrentAppNameAndExt);
+                                iContainerOutput->PrintTextL(_L(": missing dependencies: "));
+                                iLogWriteBuf->Des().Append(_L("[Missing dependencies: "));
+
+                                for (TInt k=0; k<missingDllArray->MdcaCount(); k++)
+                                    {
+                                    iContainerOutput->PrintTextL(missingDllArray->MdcaPoint(k));
+                                    iContainerOutput->PrintTextL(_L(" "));
+
+                                    iLogWriteBuf->Des().Append(missingDllArray->MdcaPoint(k));
+                                    iLogWriteBuf->Des().Append(_L(" "));
+                                    }
+
+                                iContainerOutput->PrintTextL(_L("\n"));
+                                iLogWriteBuf->Des().Append(_L("] "));
+                                }
+                            }
+
+                        if (missingDllArray)
+                            delete missingDllArray;
+
+                    #endif
+
+                    }  // if '['
+                }  // if 'Z'
+
+
+
+            // check if the app is already running
+            TApaTaskList taskList(iWs);
+            TApaTask thisTask = taskList.FindApp(iCurrentAppUid);
+            if (thisTask.Exists())
+                {
+                iLogWriteBuf->Des().Append(_L(" [OK: App already running]"));
+                iLogWriteBuf->Des().Append(KFileNewLine);
+                iLogFile.Write(iLogWriteBuf->Des());
+
+                iOkCases++;
+                CheckForMoreAppsL();
+                }
+            
+            else
+                {
+                // check the program's capabilities
+                TApaAppCapabilityBuf buf;
+                iLs.GetAppCapability(buf, iCurrentAppUid);
+                TApaAppCapability cap = buf();
+
+                // if it's embeddable only, don't launch if setting is enabled
+                if (cap.iEmbeddability == TApaAppCapability::EEmbeddableOnly && SkipHiddenAndEmbedOnly())  
+                    {
+                    iContainerOutput->PrintTextL(iCurrentAppNameAndExt);
+                    iContainerOutput->PrintTextL(_L(": SKIPPED: embeddable only\n"));
+
+                    iLogWriteBuf->Des().Append(_L("[SKIPPED: embeddable only] "));
+                    iLogWriteBuf->Des().Append(KFileNewLine);
+                    iLogFile.Write(iLogWriteBuf->Des());
+
+                    iSkippedCases++;
+                    CheckForMoreAppsL();
+                    }
+            
+                // if it's hidden, don't launch if setting is enabled
+                else if (cap.iAppIsHidden && SkipHiddenAndEmbedOnly())  
+                    {
+                    iContainerOutput->PrintTextL(iCurrentAppNameAndExt);
+                    iContainerOutput->PrintTextL(_L(": SKIPPED: hidden\n"));
+
+                    iLogWriteBuf->Des().Append(_L("[SKIPPED: hidden] "));
+                    iLogWriteBuf->Des().Append(KFileNewLine);
+                    iLogFile.Write(iLogWriteBuf->Des());
+
+                    iSkippedCases++;
+                    CheckForMoreAppsL();
+                    }
+
+                // otherwise do the normal launch test
+                else
+                    {
+                    LaunchApplicationL();
+                    }
+                
+                } //if (thisTask.Exists())
+            
+            } //if (iAppsArray->MdcaPoint(iAppLaunchCounter).FindF
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::CheckIfAppIsRunningL()
+    {
+    LOGSTRING("Launcher: CLauncherEngine::CheckIfAppIsRunningL");
+
+    // cancel the death notifier since it isn't needed anymore
+    if( iCurrentAppThread.Handle() != 0 )
+        {
+        iCurrentAppThread.LogonCancel(iAppThreadChecker->iStatus);
+        }
+
+    // cancel checkers
+    iAppThreadChecker->Cancel();
+    iAppRunningChecker->Cancel(); 
+
+
+
+    // check from the window server if the app is running
+    TApaTaskList taskList(iWs);
+    TApaTask thisTask = taskList.FindApp(iCurrentAppUid);
+
+    if( !thisTask.Exists() ) // application not running -> FAIL
+        {
+        // check from the thread why it quit
+        CheckWhyThreadDiedL();
+
+        // --> CheckForMoreApps() and all the other stuff called from CheckWhyThreadDied() !
+
+        }
+    else
+        {
+        // app is running!
+        iOkCases++;
+
+        // close handle to the thread        
+        iCurrentAppThread.Close();
+
+
+        iLogWriteBuf->Des().Append(_L(" [OK]"));
+        iLogWriteBuf->Des().Append(KFileNewLine);        
+        iLogFile.Write(iLogWriteBuf->Des());
+
+
+        // close the running application if needed
+        if (iAutoClose)
+            {
+            // since the application is still open, let's close it
+            thisTask.EndTask();
+            //User::After(1000);
+            //thisTask.SendSystemEvent(EApaSystemEventShutdown);
+            //thisTask.KillTask();
+            //User::After(1000);
+            }
+
+        // this app is done now, move to the next one!
+        CheckForMoreAppsL();
+                
+        }    
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::CheckWhyThreadDiedL()
+    {
+    LOGSTRING("Launcher: CLauncherEngine::CheckWhyThreadDiedL");
+
+    // cancel the death notifier since it isn't needed anymore
+    if( iCurrentAppThread.Handle() != 0 )
+        {
+        iCurrentAppThread.LogonCancel(iAppThreadChecker->iStatus);
+        }
+
+    // make sure all checkers are cancelled
+    iAppRunningChecker->Cancel(); 
+    iAppThreadChecker->Cancel(); 
+
+    TBuf<256> outputText;
+    outputText.Append(_L("App.Closed. "));
+
+
+    if (iCurrentAppThread.ExitType() == EExitKill)
+        {
+        outputText.Append(_L("\"EExitKill\""));
+        }
+    else if (iCurrentAppThread.ExitType() == EExitTerminate)
+        {
+        outputText.Append(_L("\"EExitTerminate\""));
+        }
+    else if (iCurrentAppThread.ExitType() == EExitPanic)
+        {
+        outputText.Append(_L("\"EExitPanic\""));
+        }
+    else if (iCurrentAppThread.ExitType() == EExitPending)
+        {
+        outputText.Append(_L("\"EExitPending\""));
+        }
+    else // unknown reason
+        {
+        outputText.Append(_L("\"Exit_Unknown_Reason\""));
+        }        
+    
+    outputText.Append(_L(" code:"));
+    TInt exitReason = iCurrentAppThread.ExitReason();
+    outputText.AppendNum(exitReason);
+    outputText.Append(_L(" \""));
+
+    TPtrC exitCategory = iCurrentAppThread.ExitCategory();
+    outputText.Append(exitCategory);
+
+    outputText.Append(_L("\""));
+
+
+    // print to screen
+    iContainerOutput->PrintTextL(iCurrentAppNameAndExt);
+    iContainerOutput->PrintTextL(_L(": "));
+    iContainerOutput->PrintTextL(outputText);
+    iContainerOutput->PrintTextL(_L("\n"));
+
+    // write to the log also
+    iLogWriteBuf->Des().Append(_L(" [FAIL: "));
+    iLogWriteBuf->Des().Append(outputText);
+    iLogWriteBuf->Des().Append(_L("]"));
+    iLogWriteBuf->Des().Append(KFileNewLine);
+    
+    iLogFile.Write(iLogWriteBuf->Des());
+
+    // close handle to the thread
+    //iCurrentAppThread.Close();    <-- not safe the close the handle because of the "App.Closed" dialog
+    //                                  somehow takes ownership of the thread or something
+
+    // nothing to do anymore, move to the next app
+    iFailedCases++;
+    CheckForMoreAppsL();
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::CheckForMoreAppsL()
+    {
+    LOGSTRING("Launcher: CLauncherEngine::CheckForMoreAppsL");
+
+    // make sure the launcher app is in the foreground
+    TApaTaskList taskList(iWs);
+    TUid launcherAppUid;
+    launcherAppUid.iUid = 0x101FB74F;
+    TApaTask launcherTask = taskList.FindApp(launcherAppUid);
+    launcherTask.BringToForeground();
+
+
+    // check if we have more test to be executed
+    if ( iAppLaunchCounter >= iTotalNumberOfCases-1 )
+        {
+        
+        // all done, show stats
+        TBuf<200> message;
+        message.Append( _L("Done: ") );
+        message.AppendNum( iOkCases );
+        message.Append( _L(" ok, ") );
+        message.AppendNum( iFailedCases );
+        message.Append( _L(" failed, ") );
+        message.AppendNum( iSkippedCases );
+        message.Append( _L(" skipped.") );
+
+        // print the message to the output screen
+        iContainerOutput->PrintTextL(message);
+        iContainerOutput->PrintTextL(_L("\n\n"));
+
+        //write same stuff to the log
+        WriteInitialStuffToTheLogL(message, iLogFile);
+        iLogWriteBuf->Des().Copy(KFileNewLine);
+        iLogWriteBuf->Des().Append(KFileNewLine);        
+        iLogFile.Write(iLogWriteBuf->Des());
+
+        // close the log
+        iLogFile.Close();
+
+        iLaunchingIsActive = EFalse;
+
+        _LIT(KAllDoneMessage, "All apps launched");
+        CAknConfirmationNote* confirmationNote = new(ELeave) CAknConfirmationNote;
+        confirmationNote->ExecuteLD(KAllDoneMessage);
+
+        }
+    else
+        {
+        // more apps to be launched, maintain requests
+        iAppLaunchCounter++;
+        IssueLaunch();
+        }
+  
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::DoCancel()
+    {
+    LOGSTRING("Launcher: CLauncherEngine::DoCancel");
+    
+    if( iXMLParser )
+        {
+        iXMLParser->Cancel();
+        }
+    iTimer.Cancel();
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::LaunchApplicationL()
+    {
+    LOGSTRING("Launcher: CLauncherEngine::LaunchApplication");
+    LOGSTRING3("Launcher: Trying to launch %S, UID: %d", &iCurrentAppNameAndExt, iCurrentAppUid.iUid);
+
+    TRAPD(err, DoLaunchApplicationL());
+    
+    if (err!=KErrNone)
+        {
+        iLogWriteBuf->Des().Append(_L("[FAIL: Cannot launch the app] "));        
+        
+        iContainerOutput->PrintTextL(iCurrentAppNameAndExt);
+        iContainerOutput->PrintTextL(_L(": cannot launch\n"));
+
+        // write the buffer to the log
+        iLogWriteBuf->Des().Append(KFileNewLine);        
+        iLogFile.Write(iLogWriteBuf->Des());
+
+        // this application isn't even launchable, go to next one
+        iFailedCases++;
+        CheckForMoreAppsL();        
+        }
+    
+    }
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::DoLaunchApplicationL()
+    {
+    LOGSTRING("Launcher: CLauncherEngine::DoLaunchApplicationL");
+
+    // create a new handle
+    RThread newThreadHandle;
+    iCurrentAppThread = newThreadHandle;
+
+
+    // Find the task with uid3
+    TApaTaskList tasklist(iWs);
+    TApaTask task=tasklist.FindApp(iCurrentAppUid);
+
+    if (task.Exists())
+        // Task exists, bring it to foreground
+        {
+        task.BringToForeground();
+        }
+    else
+        // Task doesn't exist, launch a new instance of an application
+        {
+        TApaAppInfo appInfo;
+        User::LeaveIfError(iLs.GetAppInfo(appInfo, iCurrentAppUid));
+        TApaAppCapabilityBuf capBuf;
+        User::LeaveIfError(iLs.GetAppCapability(capBuf, iCurrentAppUid));
+        TApaAppCapability& caps = capBuf();
+
+        CApaCommandLine* cmdLine=CApaCommandLine::NewLC();
+        cmdLine->SetExecutableNameL(appInfo.iFullName);
+
+        if ( caps.iLaunchInBackground )
+            // Apps capability defines that the app is launched in background
+            {
+            cmdLine->SetCommandL(EApaCommandBackground);
+            }
+        else
+            {
+            cmdLine->SetCommandL(EApaCommandRun);
+            }
+
+        // start the app
+        User::LeaveIfError(iLs.StartApp(*cmdLine, iCurrentAppThreadId));
+
+        // activate thread checker active object
+        iAppThreadChecker->ActivateChecking();
+
+        // now open a handle to the thread and register death notifier
+        TInt err = iCurrentAppThread.Open(iCurrentAppThreadId);
+        if (err == KErrNone)
+            iCurrentAppThread.Logon(iAppThreadChecker->iStatus);
+        else
+            {
+            iCurrentAppThread.Close();
+            TRequestStatus* status = &iAppThreadChecker->iStatus;
+            User::RequestComplete(status, KErrNone);
+            iAppThreadChecker->Cancel();
+            User::Leave(err);                
+            }
+
+        CleanupStack::PopAndDestroy(); // cmdLine
+        }
+
+    // the application is now running, start a check to see if it's still alive
+    iAppRunningChecker->StartTesting(); 
+
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::StopLaunchingL()
+    {
+    LOGSTRING("Launcher: CLauncherEngine::StopLaunchingL");
+
+    //write to the log
+    WriteInitialStuffToTheLogL(_L("Cancelled by the user !!! "), iLogFile);
+    iLogWriteBuf->Des().Copy(KFileNewLine);
+    iLogWriteBuf->Des().Append(KFileNewLine);
+    iLogFile.Write(iLogWriteBuf->Des());
+
+    // close the log
+    iLogFile.Close();
+
+    // print to the screen
+    iContainerOutput->PrintTextL(_L("Launching cancelled.\n\n"));
+
+    // cancel all active objects
+    if( iCurrentAppThread.Handle() != 0 )
+        {
+        iCurrentAppThread.LogonCancel(iAppThreadChecker->iStatus);
+        }
+    Cancel();
+    iAppRunningChecker->Cancel(); 
+    iAppThreadChecker->Cancel(); 
+    
+    iLaunchingIsActive = EFalse;
+
+    _LIT(KMessage, "Launching cancelled");
+    CAknInformationNote* confirmationNote = new(ELeave) CAknInformationNote;
+    confirmationNote->ExecuteLD(KMessage);
+    }
+
+// ---------------------------------------------------------------------------
+
+CDesCArray* CLauncherEngine::DependencyCheckForE32ImageL()
+    {
+    LOGSTRING("Launcher: CLauncherEngine::DependencyCheckForE32ImageL");
+
+    // create an empty array for the missing dll names
+    CDesCArray* missingDllArray = new(ELeave) CDesCArrayFlat(100);
+    CleanupStack::PushL(missingDllArray);
+
+    // get a list of DLLs from the E32 image file
+    E32ImageReader* reader = E32ImageReader::NewLC();
+    CDesCArray* dllArray = reader->ListOfDLLsL( iAppsArray->MdcaPoint(iAppLaunchCounter) );
+    CleanupStack::PopAndDestroy(); // reader
+    CleanupStack::PushL(dllArray);
+
+    // compare system DLL and image DLL arrays
+    TInt pos(0);
+    for (TInt j=0; j<dllArray->MdcaCount(); j++)
+        {
+        if (iSystemDllArray->Find(dllArray->MdcaPoint(j), pos, ECmpFolded) != 0)  
+            {
+            // DLL not found, append the name to the list of missing DLLs
+            missingDllArray->AppendL(dllArray->MdcaPoint(j));  
+            }
+        }
+
+    CleanupStack::PopAndDestroy(); // dllArray
+    CleanupStack::Pop();  // missingDllArray
+
+    LOGSTRING("Launcher: CLauncherEngine::DependencyCheckForE32ImageL returns");
+
+    return missingDllArray;
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::WriteInitialStuffToTheLogL(const TDesC& aOwnData, RFile& aFile)
+    {
+    LOGSTRING("Launcher: CLauncherEngine::WriteInitialStuffToTheLog");
+
+    TTime time;
+    time.HomeTime();
+    TBuf<32> currentTime;
+    TBuf<32> currentDate;
+
+    // current date            
+    _LIT(KCurrentDate,"%D%M%Y%/0%1%/1%2%/2%3%/3");
+    time.FormatL(currentDate, KCurrentDate);    
+    iLogWriteBuf->Des().Copy(currentDate);    
+    AppendLogBufferL(KFileSeparator(), iLogWriteBuf);
+
+    // current time
+    _LIT(KCurrentTime,"%-B%:0%J%:1%T%:2%S%:3%+B");
+    time.FormatL(currentTime, KCurrentTime);    
+    AppendLogBufferL(currentTime, iLogWriteBuf);
+    AppendLogBufferL(KFileSeparator(), iLogWriteBuf);
+
+    // available RAM memory
+    TMemoryInfoV1Buf memory;
+    UserHal::MemoryInfo(memory);
+    iLogWriteBuf->Des().AppendNum(memory().iFreeRamInBytes);  
+    AppendLogBufferL(KFileSeparator(), iLogWriteBuf);
+
+    // own data, eg. application name
+    AppendLogBufferL(aOwnData, iLogWriteBuf);
+    AppendLogBufferL(KFileSeparator(), iLogWriteBuf);
+    AppendLogBufferL(KFileNewLine(), iLogWriteBuf);    
+
+    // write the buffer to the file
+    aFile.Write(iLogWriteBuf->Des()); 
+
+    // clear the buffer
+    iLogWriteBuf->Des().Copy(_L(""));
+    }
+
+// ---------------------------------------------------------------------------
+
+TInt CLauncherEngine::DeleteLogFile()
+    {
+    LOGSTRING("Launcher: CLauncherEngine::DeleteLogFile");
+    return BaflUtils::DeleteFile(iEnv->FsSession(), iLogFilePath);
+    }
+
+// ---------------------------------------------------------------------------
+
+TInt CLauncherEngine::DeleteBCLogFile()
+    {
+    LOGSTRING("Launcher: CLauncherEngine::DeleteBCLogFile");
+    return BaflUtils::DeleteFile(iEnv->FsSession(), iBCLogFilePath);
+    }
+
+// ---------------------------------------------------------------------------
+
+TBool CLauncherEngine::LogFileExists()
+    {
+    LOGSTRING("Launcher: CLauncherEngine::LogFileExists");
+    return BaflUtils::FileExists(iEnv->FsSession(), iLogFilePath);
+    }
+
+// ---------------------------------------------------------------------------
+
+TBool CLauncherEngine::BCLogFileExists()
+    {
+    LOGSTRING("Launcher: CLauncherEngine::BCLogFileExists");
+    return BaflUtils::FileExists(iEnv->FsSession(), iBCLogFilePath);
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::DialogDismissedL( TInt aButtonId )
+    {
+    LOGSTRING2("Launcher: CLauncherEngine::DialogDismissedL - Button id: %d", aButtonId);    
+    iWaitDialog = 0;
+    iDLLAnalysisIsActive = EFalse;
+    _LIT(KAnalysisCancelled, "DLL Analysis cancelled");
+    if( IsActive() )
+        {
+        Cancel();
+        }
+    if( iXMLParser )
+        {
+        iXMLParser->Cancel();
+        }
+    if( aButtonId == EAknSoftkeyCancel )
+        {
+        iContainerOutput->PrintTextL( KNewLine );
+        iContainerOutput->PrintTextL( KAnalysisCancelled );
+        iContainerOutput->PrintTextL( KNewLine );
+        if( iLogWriteBuf )
+            {
+            AppendLogBufferL(KFileNewLine(), iLogWriteBuf);
+            AppendLogBufferL(KAnalysisCancelled(), iLogWriteBuf);
+            AppendLogBufferL(KFileNewLine(), iLogWriteBuf);
+            if( iBCLogFile.SubSessionHandle() != 0)
+                {
+                iBCLogFile.Write(iLogWriteBuf->Des());
+                }
+            iLogWriteBuf->Des().Zero();
+            }
+        iBCLogFile.Close();
+        }        
+    }
+
+// ---------------------------------------------------------------------------
+
+TBool CLauncherEngine::SelectRequiredDLLsFileL()
+    {
+    LOGSTRING("Launcher: CLauncherEngine::SelectRequiredDLLsFile");
+    _LIT(KMessage, "Please, select input file for BC analysis");
+    CAknInformationNote* infoNote = new(ELeave) CAknInformationNote(ETrue);
+    infoNote->ExecuteLD(KMessage);    
+    return AknCommonDialogs::RunSelectDlgLD( iRequiredDllsFilePath, R_MEMORY_SELECTION_DIALOG, R_FILE_SELECTION_DIALOG);
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::DoBCAnalysisL()
+    {
+    LOGSTRING("Launcher: CLauncherEngine::DoBCAnalysisL");
+    if( iXMLParser == 0 )
+        {
+        iXMLParser = CLauncherXMLParser::NewL(iEnv->FsSession());
+        }
+    
+    delete iWaitDialog;
+    iWaitDialog = 0;    
+    iXMLParser->ParseL(iRequiredDllsFilePath,this);
+    iDLLAnalysisIsActive = ETrue;
+    
+    // some delay
+    iTimer.After(iStatus, 500000);
+    SetActive();
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::AnalyseDLLsL()
+    {
+    LOGSTRING("Launcher: CLauncherEngine::AnalyseDLLsL");
+    _LIT(KStartSeparator, "******************************");
+    _LIT(KStartingAnalysis, "Starting BC Analysis for DLLs.");    
+    _LIT(KInputFileSelected, "Input file selected: ");
+    
+    // Reset found issues counter and buffer
+    iFoundBCIssues = 0;    
+    delete iBCIssuesBigBuffer;
+    iBCIssuesBigBuffer = 0;
+    
+    // Reset log writing buffer:
+    iLogWriteBuf->Des().Zero();
+                
+    if( IsActive() )
+        {
+        Cancel();
+        }           
+   
+    if( !SelectRequiredDLLsFileL() )
+        {        
+        return; // Input file selection cancelled
+        }
+    
+    // open the log file for writing
+    if (iBCLogFile.Open(iEnv->FsSession(), iBCLogFilePath, EFileWrite) != KErrNone)
+        {
+        iEnv->FsSession().MkDirAll(iLogFilePath);
+        iBCLogFile.Replace(iEnv->FsSession(), iBCLogFilePath, EFileWrite);
+        }
+    else
+        {
+        // file opens correctly, seek to the end
+        TInt fileSize=0;
+        iBCLogFile.Size(fileSize);
+        iBCLogFile.Seek(ESeekCurrent, fileSize);
+        }
+    
+    AppendLogBufferL(KFileNewLine(), iLogWriteBuf);
+    AppendLogBufferL(KStartSeparator(), iLogWriteBuf);
+    AppendLogBufferL(KFileNewLine(), iLogWriteBuf);
+    iBCLogFile.Write(iLogWriteBuf->Des());
+    iLogWriteBuf->Des().Zero();
+    
+    // Resolve file type. Should we use XML parsing or just compare DLL list
+    TBool xmlParsing =
+        KDotXML().Compare(iRequiredDllsFilePath.Right(KDotXML().Length())) == 0 ||
+        KDotLauncherXML().Compare(iRequiredDllsFilePath.Right(KDotLauncherXML().Length())) == 0;
+    
+    // Log analysis starting time and selected input file:
+    WriteInitialStuffToTheLogL(KStartingAnalysis, iBCLogFile);    
+    AppendLogBufferL(KInputFileSelected(), iLogWriteBuf);
+    AppendLogBufferL(iRequiredDllsFilePath, iLogWriteBuf);
+    AppendLogBufferL(KFileNewLine(), iLogWriteBuf);
+    iBCLogFile.Write(iLogWriteBuf->Des());
+    iLogWriteBuf->Des().Zero();
+    
+    if( xmlParsing )
+        {
+        ChangeFocusToOutputView();
+        DoBCAnalysisL();
+        }
+    else
+        {
+        DoCompareDLLListsL();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::DoCompareDLLListsL()
+    {
+    LOGSTRING("Launcher: CLauncherEngine::DoCompareDLLListsL");
+    RFile file;
+    CleanupClosePushL(file);
+    
+    if(file.Open(iEnv->FsSession(), iRequiredDllsFilePath, EFileRead) != KErrNone)
+        {
+        ChangeFocusToOutputView();
+
+        TBuf<200> msg;
+        msg.Format(_L("Unable to open %S for reading!\n\n"), &iRequiredDllsFilePath);
+        iContainerOutput->PrintTextL( msg );
+        }
+    else
+        {
+        CDesCArray* requiredDllArray = new(ELeave) CDesCArrayFlat(KMaxDllArraySize);
+        CleanupStack::PushL(requiredDllArray);
+
+        // read all lines the text file
+        TFileName dllName;
+        TInt i(0);
+        while( ReadLineFromFileL(file, dllName) == KErrNone && i<KMaxDllArraySize )
+            {
+            dllName.TrimAll();
+
+            if (dllName.Length() > 1)
+                requiredDllArray->AppendL(dllName);
+            
+            i++;
+            }
+
+        if (requiredDllArray->MdcaCount() == 0)
+            {
+            ChangeFocusToOutputView();
+
+            TBuf<200> msg;
+            msg.Format(_L("File %S is empty!\n\n"), &iRequiredDllsFilePath);
+            iContainerOutput->PrintTextL( msg );
+            }
+        else
+            {
+            // compare the arrays and print any missing items
+            CDesCArray* missingDllArray = new(ELeave) CDesCArrayFlat(KMaxDllArraySize);
+            CleanupStack::PushL(missingDllArray);
+
+            TInt pos(0);
+            for (TInt j=0; j<requiredDllArray->MdcaCount(); j++)
+                {
+                if (iSystemDllArray->Find(requiredDllArray->MdcaPoint(j), pos, ECmpFolded) != 0)  
+                    {
+                    // DLL not found, append the name to the list of missing DLLs
+                    missingDllArray->AppendL(requiredDllArray->MdcaPoint(j));  
+                    }
+                }
+
+            if (missingDllArray->MdcaCount() == 0)
+                {
+                _LIT(KMessage, "No missing files found");
+                AppendLogBufferL(KMessage(), iLogWriteBuf);
+                CAknInformationNote* note = new(ELeave) CAknInformationNote;
+                note->ExecuteLD(KMessage);
+                }
+            else
+                {
+                ChangeFocusToOutputView();
+                _LIT(KMissingFiles, "Missing files:\n");
+
+                iContainerOutput->PrintTextL( KMissingFiles );
+                AppendLogBufferL(KMissingFiles(), iLogWriteBuf);
+                
+                for (TInt i=0; i<missingDllArray->MdcaCount(); i++)
+                    {
+                    iContainerOutput->PrintTextL( missingDllArray->MdcaPoint(i) );                    
+                    iContainerOutput->PrintTextL( _L("\n") );           
+                    AppendLogBufferL(missingDllArray->MdcaPoint(i), iLogWriteBuf);
+                    AppendLogBufferL(KFileNewLine(), iLogWriteBuf);
+                    }
+
+                iContainerOutput->PrintTextL( _L("\n") );
+                }
+
+            CleanupStack::PopAndDestroy(); // missingDllArray            
+            }
+
+        CleanupStack::PopAndDestroy(); // requiredDllArray
+        }
+
+    CleanupStack::PopAndDestroy(); //file
+    iBCLogFile.Write(iLogWriteBuf->Des());
+    iLogWriteBuf->Des().Zero();
+    iBCLogFile.Close();
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::ParsingProgressedL(TInt aBytes)
+    {
+    LOGSTRING2("Launcher: CLauncherEngine::ParsingProgressedL - Bytes: %d", aBytes);
+    if (iProgressInfo && aBytes > 0 )
+        {
+        iProgressInfo->SetAndDraw(aBytes);
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::DocumentParsedL(TInt aErrorCode)
+    {            
+    LOGSTRING2("Launcher: CLauncherEngine::DocumentParsedL (Error code: %d)", aErrorCode);
+        
+    iDLLAnalysisIsActive = EFalse;
+    _LIT(KParseError, "Parse error: ");
+    _LIT(KNoIssues, "No binary compatibility issues found");
+    
+    if( IsActive() )
+        {
+        Cancel();
+        }
+            
+    if( iWaitDialog )
+        {
+        iWaitDialog->ProcessFinishedL();
+        iWaitDialog = 0;
+        }
+        
+    if( aErrorCode != KErrNone )
+        {
+        TBuf<16> errorCodeString;
+        errorCodeString.AppendNum(aErrorCode);
+        iContainerOutput->PrintTextL( KNewLine );
+        iContainerOutput->PrintTextL( KParseError );
+        iContainerOutput->PrintTextL( errorCodeString );
+        iContainerOutput->PrintTextL( KNewLine );        
+        AppendLogBufferL(KFileNewLine(), iLogWriteBuf);
+        AppendLogBufferL(KParseError(), iLogWriteBuf);
+        AppendLogBufferL(errorCodeString, iLogWriteBuf);
+        AppendLogBufferL(KFileNewLine(), iLogWriteBuf);
+        }
+    else if(iFoundBCIssues == 0)
+        {
+        iContainerOutput->PrintTextL( KNoIssues );
+        iContainerOutput->PrintTextL( KNewLine );        
+        AppendLogBufferL(KFileNewLine(), iLogWriteBuf);
+        AppendLogBufferL(KNoIssues(), iLogWriteBuf);
+        AppendLogBufferL(KFileNewLine(), iLogWriteBuf);
+        }
+    else if( iBCIssuesBigBuffer && iBCIssuesBigBuffer->Des().Length() > 0 )
+        {
+        iContainerOutput->PrintTextL(iBCIssuesBigBuffer->Des());
+        delete iBCIssuesBigBuffer;
+        iBCIssuesBigBuffer = 0;
+        }
+    if( iLogWriteBuf->Length() > 0 && iBCLogFile.SubSessionHandle() != 0)
+        {
+        iBCLogFile.Write(iLogWriteBuf->Des());
+        }
+    WriteInitialStuffToTheLogL(_L("Analysis ready"), iBCLogFile);
+    iLogWriteBuf->Des().Zero();
+    iBCLogFile.Close();
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::ElementParsedL(const CLauncherDLLElement& aDllElement)
+    {
+    LOGSTRING("Launcher: CLauncherEngine::ElementParsedL");
+    User::ResetInactivityTime();
+    _LIT(KNewLine, "\n");
+    _LIT(KIndent, "    ");
+    _LIT(KIssuesFound, "Binary compatibility issues found:"); 
+    _LIT(KDLLMissing,"DLL is missing");
+    _LIT(KUID1Changed,"UID1 changed");
+    _LIT(KUID2Changed,"UID2 changed");
+    _LIT(KUID3Changed,"UID3 changed");
+    _LIT(KSIDChanged,"SID changed");
+    _LIT(KCapabilityChanged,"Capability changed");
+    
+    if( iDLLElement == 0 )
+        {
+        iDLLElement = CLauncherDLLElement::NewL();
+        }
+    
+    TFindFile fileFinder(iEnv->FsSession());
+    _LIT(KDLLPath, "\\sys\\bin\\");
+    TInt err = fileFinder.FindByPath(aDllElement.Name(), &KDLLPath); 
+    
+    TBuf<256> issueStr;
+    
+    if( err == KErrNotFound )
+        {
+        if( iFoundBCIssues++ == 0 )
+            {                        
+            iContainerOutput->PrintTextL( KIssuesFound );
+            iContainerOutput->PrintTextL( KNewLine );            
+            AppendLogBufferL(KFileNewLine(), iLogWriteBuf);
+            AppendLogBufferL(KIssuesFound(), iLogWriteBuf);
+            AppendLogBufferL(KFileNewLine(), iLogWriteBuf);
+            }
+        issueStr.Copy(aDllElement.Name());
+        issueStr.Append(KNewLine);
+        issueStr.Append(KIndent);
+        issueStr.Append(KDLLMissing);
+        issueStr.Append(KNewLine);
+                
+        AppendLogBufferL(issueStr, iLogWriteBuf);
+        
+        TFileName dllName = aDllElement.Name();
+        LOGSTRING2("Launcher: DLL not found: %S", &dllName);
+        if( iFoundBCIssues > KBigBufferUsageThreshold )
+            {
+            if( iBCIssuesBigBuffer == 0)
+                {
+                iBCIssuesBigBuffer = HBufC::NewL(KBigBufferAllocBytes);
+                }
+            TInt maxSize = iBCIssuesBigBuffer->Des().Length() + issueStr.Length();
+            if( maxSize >= iBCIssuesBigBuffer->Des().MaxLength())
+                {
+                iBCIssuesBigBuffer = iBCIssuesBigBuffer->ReAllocL(maxSize + KBigBufferAllocBytes );                
+                }
+            TPtr ptr(iBCIssuesBigBuffer->Des());
+            ptr += issueStr;            
+            }
+        else
+            {
+            iContainerOutput->PrintTextL( issueStr);
+            }
+        }
+    else if( err == KErrNone)
+        {
+        // File is found, so let's try to open it:
+        RFile dllFile;
+        CleanupClosePushL(dllFile);        
+        if( dllFile.Open(iEnv->FsSession(), fileFinder.File(), EFileRead) == KErrNone )
+            {
+            // Parse DLL:
+            iDLLParser->ParseL(iEnv->FsSession(), dllFile, *iDLLElement);
+            CleanupStack::PopAndDestroy(); // dllFile            
+            RArray<CLauncherDLLElement::TDifference> diffs;
+            CleanupClosePushL(diffs);
+                        
+            // Compare DLLs:              
+            if( iDLLElement->CompareL(aDllElement, diffs))
+                {                
+                if( iFoundBCIssues++ == 0 )
+                    {
+                    iContainerOutput->PrintTextL( KIssuesFound );
+                    iContainerOutput->PrintTextL( KNewLine );                   
+                    AppendLogBufferL(KFileNewLine(), iLogWriteBuf);
+                    AppendLogBufferL(KIssuesFound(), iLogWriteBuf);
+                    AppendLogBufferL(KFileNewLine(), iLogWriteBuf);
+                    }
+                // Differencies found:
+                for( TInt i = 0; i < diffs.Count(); ++i )
+                    {                
+                    // Print DLL name:
+                    if( i == 0 )
+                        {
+                        issueStr.Copy(aDllElement.Name());
+                        issueStr.Append(KNewLine);
+                        }
+                    
+                    // Print differencies:
+                    issueStr.Append(KIndent);
+                    switch(diffs[i])
+                        {
+                        case CLauncherDLLElement::EDifference_UID1:
+                            issueStr.Append(KUID1Changed);
+                            break;
+                        case CLauncherDLLElement::EDifference_UID2:
+                            issueStr.Append( KUID2Changed );
+                            break;
+                        case CLauncherDLLElement::EDifference_UID3:
+                            issueStr.Append( KUID3Changed );
+                            break;
+                        case CLauncherDLLElement::EDifference_SID:
+                            issueStr.Append( KSIDChanged );
+                            break;
+                        case CLauncherDLLElement::EDifference_Capability:
+                            issueStr.Append( KCapabilityChanged );
+                            break;
+                        }
+                    issueStr.Append( KNewLine );                    
+                    }
+                AppendLogBufferL(issueStr, iLogWriteBuf);
+                if( iFoundBCIssues > KBigBufferUsageThreshold )
+                    {
+                    // To improve performance, don't print issues to output anymore.
+                    // Instead, store the issues in buffer and print them when analysis is done.
+                    if( iBCIssuesBigBuffer == 0)
+                        {
+                        iBCIssuesBigBuffer = HBufC::NewL(KBigBufferAllocBytes);
+                        }
+                    TInt maxSize = iBCIssuesBigBuffer->Des().Length() + issueStr.Length();
+                    if( maxSize >= iBCIssuesBigBuffer->Des().MaxLength())
+                        {
+                        TInt increaseSize = Max(issueStr.Length(), KBigBufferAllocBytes);
+                        iBCIssuesBigBuffer = iBCIssuesBigBuffer->ReAllocL(maxSize + increaseSize );                            
+                        }
+                    TPtr ptr(iBCIssuesBigBuffer->Des());
+                    ptr += issueStr;
+                    }
+                else
+                    {
+                    iContainerOutput->PrintTextL( issueStr);
+                    }
+                }
+            CleanupStack::Pop(); // diffs
+            diffs.Close();            
+            }
+        else
+            {
+            CleanupStack::PopAndDestroy(); // dllFile
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+TInt CLauncherEngine::ReadLineFromFileL(RFile& aFile, TDes& aReadBuf)
+    {
+    LOGSTRING("Launcher: CLauncherEngine::ReadLineFromFile");
+
+    _LIT8(KImcvCRLF, "\r\n");
+    TInt err(KErrNone);
+
+    HBufC8* tempLine = HBufC8::NewLC(1000);
+    TPtr8 buffer = tempLine->Des();
+
+    // clear the target buffer
+    aReadBuf.Zero();
+
+    // get the current file position
+    TInt filePos(0);
+    aFile.Seek(ESeekCurrent, filePos);
+
+    // read the buffer
+    err = aFile.Read(buffer);
+
+    // check if it's the end of file
+    TInt s = buffer.Length();
+    if (s == 0)
+        err = KErrEof;
+
+    if (err == KErrNone)
+        {
+        // copy to the lfcr and then set the file pointer to the point after that
+        TInt pos = buffer.Find(KImcvCRLF);
+        if (pos != -1)
+            {
+            TFileName tempBuf;
+            buffer.SetLength(pos);
+            tempBuf.Copy(buffer);
+            aReadBuf.Justify(tempBuf, pos, ELeft, ' ');
+            filePos += (pos+2);
+
+            // set the file pointer back to after the lfcr
+            aFile.Seek(ESeekStart, filePos);
+            }
+        
+        // else fill the whole buffer
+        else
+            {
+            aReadBuf.Copy(buffer);
+            }
+        }
+
+    CleanupStack::PopAndDestroy(); // tempLine
+    return err;
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::SendLogViaSendUiL(CSendUi* aSendUi)
+    {
+    LOGSTRING("Launcher: CLauncherEngine::SendLogViaSendUiL");
+
+    CMessageData* messageData = CMessageData::NewL();
+    CleanupStack::PushL( messageData );
+    if( LogFileExists() )
+        {
+        messageData->AppendAttachmentL( iLogFilePath );
+        }
+    if( BCLogFileExists() )
+        {
+        messageData->AppendAttachmentL( iBCLogFilePath );
+        }
+    aSendUi->ShowQueryAndSendL( messageData, TSendingCapabilities(0, 0, TSendingCapabilities::ESupportsAttachments ));
+    CleanupStack::PopAndDestroy(); //messageData
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::SendListOfSystemDllsViaSendUiL(CSendUi* aSendUi)
+    {
+    LOGSTRING("Launcher: CLauncherEngine::SendListOfDllsViaSendUiL");
+
+    if (BaflUtils::FileExists(iEnv->FsSession(), iSystemDllsFilePath))
+        {
+        CMessageData* messageData = CMessageData::NewL();
+        CleanupStack::PushL( messageData );
+        messageData->AppendAttachmentL( iSystemDllsFilePath );
+        aSendUi->ShowQueryAndSendL( messageData, TSendingCapabilities(0, 0, TSendingCapabilities::ESupportsAttachments ));
+        CleanupStack::PopAndDestroy(); //messageData
+        }
+    else
+        {
+        _LIT(message, "DLL list does not exist");
+        CAknErrorNote* errorNote = new(ELeave) CAknErrorNote;
+        errorNote->ExecuteLD(message);        
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::ChangeFocusToOutputView()
+    {
+    iAppUi->TabGroup()->SetActiveTabByIndex( 1 );
+    TRAP_IGNORE(iAppUi->ActivateLocalViewL( KView2Id ));
+    }
+
+
+// ---------------------------------------------------------------------------
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+// ---------------------------------------------------------------------------
+
+CAppRunningChecker* CAppRunningChecker::NewL(CLauncherEngine* aLauncherEngine)
+    {
+    LOGSTRING("Launcher: CAppRunningChecker::NewL");
+
+    CAppRunningChecker* self = new(ELeave) CAppRunningChecker;
+    CleanupStack::PushL(self);
+    self->ConstructL(aLauncherEngine);
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+
+CAppRunningChecker::CAppRunningChecker() : CActive(EActivePriorityIpcEventsHigh)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+
+void CAppRunningChecker::ConstructL(CLauncherEngine* aLauncherEngine)
+    {
+    LOGSTRING("Launcher: CAppRunningChecker::ConstructL");
+
+    iEnv = CEikonEnv::Static();
+    User::LeaveIfError(iTimer.CreateLocal());
+
+    iLauncherEngine = aLauncherEngine;
+
+    CActiveScheduler::Add(this);
+    }
+
+// ---------------------------------------------------------------------------
+
+CAppRunningChecker::~CAppRunningChecker()
+    {
+    LOGSTRING("Launcher: CAppRunningChecker::~CAppRunningChecker");
+
+    Cancel();
+
+    iTimer.Close();
+    }
+
+// ---------------------------------------------------------------------------
+
+void CAppRunningChecker::StartTesting()
+    {
+    LOGSTRING("Launcher: CAppRunningChecker::StartTesting");
+
+    __ASSERT_ALWAYS(!IsActive(), User::Panic(_L("Running Checker"), 200));
+
+    // async delay of seven seconds
+    iTimer.After(iStatus, 7000000);    
+    SetActive();
+    }
+
+// ---------------------------------------------------------------------------
+
+void CAppRunningChecker::RunL()
+    {
+    LOGSTRING("Launcher: CAppRunningChecker::RunL");
+
+    // check if the application is running
+    iLauncherEngine->CheckIfAppIsRunningL();
+    }
+
+// ---------------------------------------------------------------------------
+
+void CAppRunningChecker::DoCancel()
+    {
+    LOGSTRING("Launcher: CAppRunningChecker::DoCancel");
+    iTimer.Cancel();
+    }
+
+// ---------------------------------------------------------------------------
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+// ---------------------------------------------------------------------------
+
+CAppThreadChecker* CAppThreadChecker::NewL(CLauncherEngine* aLauncherEngine)
+    {
+    LOGSTRING("Launcher: CAppThreadChecker::NewL");
+
+    CAppThreadChecker* self = new(ELeave) CAppThreadChecker;
+    CleanupStack::PushL(self);
+    self->ConstructL(aLauncherEngine);
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+
+CAppThreadChecker::CAppThreadChecker() : CActive(EActivePriorityIpcEventsHigh)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+
+void CAppThreadChecker::ConstructL(CLauncherEngine* aLauncherEngine)
+    {
+    LOGSTRING("Launcher: CAppThreadChecker::ConstructL");
+
+    iEnv = CEikonEnv::Static();
+
+    iLauncherEngine = aLauncherEngine;
+
+    CActiveScheduler::Add(this);
+    }
+
+// ---------------------------------------------------------------------------
+
+CAppThreadChecker::~CAppThreadChecker()
+    {
+    LOGSTRING("Launcher: CAppThreadChecker::~CAppThreadChecker");
+
+    Cancel();
+    }
+
+// ---------------------------------------------------------------------------
+
+void CAppThreadChecker::ActivateChecking()
+    {
+    LOGSTRING("Launcher: CAppThreadChecker::ActivateChecking");
+
+    __ASSERT_ALWAYS(!IsActive(), User::Panic(_L("Thread Checker"), 300));
+
+    SetActive();
+    }
+
+// ---------------------------------------------------------------------------
+
+void CAppThreadChecker::RunL()
+    {
+    LOGSTRING("Launcher: CAppThreadChecker::RunL");
+
+    // check the state of the thread
+    iLauncherEngine->CheckWhyThreadDiedL();
+    }
+
+// ---------------------------------------------------------------------------
+
+void CAppThreadChecker::DoCancel()
+    {
+    LOGSTRING("Launcher: CAppThreadChecker::DoCancel");
+    }
+
+// ---------------------------------------------------------------------------
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/src/launcherviewapps.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,208 @@
+/*
+* 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 <Launcher.rsg>
+#include <AknUtils.h>
+#include <eikmenup.h>
+
+#include "LauncherViewApps.h"
+#include "LauncherContainerApps.h" 
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CLauncherViewApps::ConstructL(const TRect& aRect)
+// EPOC two-phased constructor
+// ---------------------------------------------------------
+//
+void CLauncherViewApps::ConstructL(CLauncherEngine* aEngine)
+    {
+    BaseConstructL( R_LAUNCHER_VIEW1 );
+
+    iContainer = new (ELeave) CLauncherContainerApps;
+    iContainer->SetMopParent(this);
+    iContainer->ConstructL( ClientRect(), aEngine );
+
+    AppUi()->AddToStackL( *this, iContainer );
+
+    // add data to the listbox and as default mark all as selected
+    iContainer->UpdateFileListL();
+    AknSelectionService::HandleMarkableListProcessCommandL( EAknMarkAll, iContainer->ListBox() );
+
+    aEngine->SetContainerApps(iContainer);
+
+    }
+
+// ---------------------------------------------------------
+// CLauncherViewApps::~CLauncherViewApps()
+// ---------------------------------------------------------
+//
+CLauncherViewApps::~CLauncherViewApps()
+    {
+    AppUi()->RemoveFromViewStack( *this, iContainer );
+    delete iContainer;
+    }
+
+// ---------------------------------------------------------
+// TUid CLauncherViewApps::Id()
+// ?implementation_description
+// ---------------------------------------------------------
+//
+TUid CLauncherViewApps::Id() const
+    {
+    return KViewId;
+    }
+
+// ------------------------------------------------------------------------------
+// CLauncherViewApps::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 CLauncherViewApps::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
+    {
+    if (aResourceId == R_LAUNCHER_VIEW1_MENU)
+        {
+        // launch start check
+        aMenuPane->SetItemDimmed(ECmdLaunchApps, iContainer->Engine()->LaunchingIsActive());
+
+        // hide launch options when launching is active
+        aMenuPane->SetItemDimmed(ECmdLaunchOptions, iContainer->Engine()->LaunchingIsActive());
+
+        // EAknMarkAll
+        TBool allSelected = iContainer->ListBox()->SelectionIndexes()->Count() == iContainer->ListBox()->Model()->NumberOfItems();
+        aMenuPane->SetItemDimmed(EAknMarkAll, allSelected);
+
+        // EAknUnmarkAll
+        TBool noneSelected = iContainer->ListBox()->SelectionIndexes()->Count() == 0;
+        aMenuPane->SetItemDimmed(EAknUnmarkAll, noneSelected); 
+        }
+
+	else if (aResourceId == R_LAUNCHER_LAUNCHOPTIONS_SUBMENU)
+	    {
+	    if (iContainer->Engine()->SkipHiddenAndEmbedOnly())
+            aMenuPane->SetItemButtonState(ECmdSkipHiddenAndEmbedOnly, EEikMenuItemSymbolOn);
+	    else
+            aMenuPane->SetItemButtonState(ECmdDoNotSkipAnyFiles, EEikMenuItemSymbolOn);
+	    } 
+
+    else
+        {
+        AppUi()->DynInitMenuPaneL(aResourceId, aMenuPane);
+        }
+    }
+
+// ---------------------------------------------------------
+// CLauncherViewApps::HandleCommandL(TInt aCommand)
+// ---------------------------------------------------------
+//
+void CLauncherViewApps::HandleCommandL(TInt aCommand)
+    {  
+    switch ( aCommand )
+        {
+        case ECmdLaunchAppsWithAutoClose:
+            {
+            iContainer->Engine()->StartAppLaunchingL(iContainer->SelectedApps(), ETrue);
+            break;
+            }
+         
+        case ECmdLaunchAppsWithoutAutoClose:
+            {
+            iContainer->Engine()->StartAppLaunchingL(iContainer->SelectedApps(), EFalse);
+            break;
+            }
+
+        case ECmdSkipHiddenAndEmbedOnly:
+            {
+            iContainer->Engine()->SetSkipHiddenAndEmbedOnly(ETrue);
+            break;
+            }
+
+        case ECmdDoNotSkipAnyFiles:
+            {
+            iContainer->Engine()->SetSkipHiddenAndEmbedOnly(EFalse);
+            break;
+            }
+                        
+        case ECmdRefreshList:
+            {
+            iContainer->UpdateFileListL();
+            AknSelectionService::HandleMarkableListProcessCommandL( EAknMarkAll, iContainer->ListBox() );
+            break;
+            }
+
+        case EAknCmdMark:
+        case EAknCmdUnmark:
+        case EAknUnmarkAll:
+        case EAknMarkAll:
+            {
+            AknSelectionService::HandleMarkableListProcessCommandL( aCommand, iContainer->ListBox() );
+            break;
+            }
+        
+        default:
+            {
+            AppUi()->HandleCommandL( aCommand );
+            break;
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CLauncherViewApps::HandleClientRectChange()
+// ---------------------------------------------------------
+//
+void CLauncherViewApps::HandleClientRectChange()
+    {
+    if ( iContainer )
+        {
+        iContainer->SetRect( ClientRect() );
+        }
+    }
+
+// ---------------------------------------------------------
+// CLauncherViewApps::DoActivateL(...)
+// ---------------------------------------------------------
+//
+void CLauncherViewApps::DoActivateL(
+   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
+   const TDesC8& /*aCustomMessage*/)
+    {
+    //AppUi()->AddToStackL( *this, iContainer );
+    iContainer->ActivateL();
+    iContainer->MakeVisible(ETrue);
+    }
+
+// ---------------------------------------------------------
+// CLauncherViewApps::DoDeactivate()
+// ---------------------------------------------------------
+//
+void CLauncherViewApps::DoDeactivate()
+    {
+    iContainer->MakeVisible(EFalse);
+    //AppUi()->RemoveFromViewStack( *this, iContainer );
+    }
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/src/launcherviewoutput.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,144 @@
+/*
+* 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  <Launcher.rsg>
+#include  "LauncherViewOutput.h"
+#include  "LauncherContainerOutput.h" 
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CLauncherViewOutput::ConstructL(const TRect& aRect)
+// EPOC two-phased constructor
+// ---------------------------------------------------------
+//
+void CLauncherViewOutput::ConstructL(CLauncherEngine* aEngine)
+    {
+    BaseConstructL( R_LAUNCHER_VIEW2 );
+
+    iContainer = new (ELeave) CLauncherContainerOutput;
+    iContainer->SetMopParent(this);
+    iContainer->ConstructL( ClientRect(), aEngine );
+
+    AppUi()->AddToStackL( *this, iContainer );
+
+    aEngine->SetContainerOutput(iContainer);
+    }
+
+// ---------------------------------------------------------
+// CLauncherViewOutput::~CLauncherViewOutput()
+// ---------------------------------------------------------
+//
+CLauncherViewOutput::~CLauncherViewOutput()
+    {
+    AppUi()->RemoveFromViewStack( *this, iContainer );
+    delete iContainer;
+    }
+
+// ---------------------------------------------------------
+// TUid CLauncherViewOutput::Id()
+// ---------------------------------------------------------
+//
+TUid CLauncherViewOutput::Id() const
+    {
+    return KView2Id;
+    }
+
+// ------------------------------------------------------------------------------
+// CLauncherViewApps::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 CLauncherViewOutput::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
+    {
+    if (aResourceId == R_LAUNCHER_VIEW2_MENU)
+        {
+        // ...
+        }
+    else
+        {
+        AppUi()->DynInitMenuPaneL(aResourceId, aMenuPane);
+        }
+    }
+
+// ---------------------------------------------------------
+// CLauncherViewOutput::HandleCommandL(TInt aCommand)
+// ---------------------------------------------------------
+//
+void CLauncherViewOutput::HandleCommandL(TInt aCommand)
+    {   
+
+    switch ( aCommand )
+        {
+        case ECmdClearWindow:
+            {
+            iContainer->ClearOutputWindowL();
+            break;
+            }
+        default:
+            {
+            AppUi()->HandleCommandL( aCommand );
+            break;
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CLauncherViewOutput::HandleClientRectChange()
+// ---------------------------------------------------------
+//
+void CLauncherViewOutput::HandleClientRectChange()
+    {
+    if ( iContainer )
+        {
+        iContainer->SetRect( ClientRect() );
+        }
+    }
+
+// ---------------------------------------------------------
+// CLauncherViewOutput::DoActivateL(...)
+// ---------------------------------------------------------
+//
+void CLauncherViewOutput::DoActivateL(
+   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
+   const TDesC8& /*aCustomMessage*/)
+    {
+    //AppUi()->AddToStackL( *this, iContainer );
+    iContainer->ActivateL();
+    iContainer->MakeVisible(ETrue);
+    }
+
+// ---------------------------------------------------------
+// CLauncherViewOutput::DoDeactivate()
+// ---------------------------------------------------------
+//
+void CLauncherViewOutput::DoDeactivate()
+    {
+    iContainer->MakeVisible(EFalse);
+    //AppUi()->RemoveFromViewStack( *this, iContainer );
+    }
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/launcher/src/launcherxmlparser.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,428 @@
+/*
+* 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 <f32file.h>
+#include <xml/documentparameters.h>
+#include "launcherxmlparser.h"
+#include "launchertraces.h"
+
+_LIT8(KXmlMimeType, "text/xml");
+
+/**
+ * XML element names
+ */
+_LIT8(KDll, "dll");
+_LIT8(KDllName, "dllname");
+_LIT8(KUID1, "uid1");
+_LIT8(KUID2, "uid2");
+_LIT8(KUID3, "uid3");
+_LIT8(KSID, "sid");
+_LIT8(KCapability, "capability");
+
+// ---------------------------------------------------------------------------
+
+CLauncherXMLParser::CLauncherXMLParser(RFs& aFs)
+:
+CActive( EPriorityLow ),
+iParser(0),
+iFileSession(aFs),
+iParsedBytes(0)
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherXMLParser::ConstructL()
+    {
+    LOGSTRING("Launcher: CLauncherXMLParser::ConstructL");
+    }
+
+// ---------------------------------------------------------------------------
+
+CLauncherXMLParser* CLauncherXMLParser::NewL(RFs& aFs)
+    {
+    LOGSTRING("Launcher: CLauncherXMLParser::NewL");
+    CLauncherXMLParser* self = CLauncherXMLParser::NewLC(aFs);    
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+
+CLauncherXMLParser* CLauncherXMLParser::NewLC(RFs& aFs)
+    {
+    LOGSTRING("Launcher: CLauncherXMLParser::NewLC");
+    CLauncherXMLParser* self = new (ELeave) CLauncherXMLParser(aFs);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+
+CLauncherXMLParser::~CLauncherXMLParser()
+    {
+    LOGSTRING("Launcher: CLauncherXMLParser::~CLauncherXMLParser");
+    Cancel();
+    delete iParser;
+    delete iCurrentDllElement;    
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherXMLParser::ClearXMLDataBuffer()
+    {
+    iXMLDataBuffer.Zero();
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherXMLParser::DoCancel()
+    {
+    LOGSTRING("Launcher: CLauncherXMLParser::DoCancel");
+    iIgnoreError = ETrue;
+    if( iParser )
+        {
+        TRAP_IGNORE(iParser->ParseEndL());
+        }
+    iFile.Close();
+    ClearXMLDataBuffer();
+    }
+
+// ---------------------------------------------------------------------------
+// Gives current buffer content to parser for processing. Then reads
+// next part of the file in the buffer and waits for next scheduled run.
+
+void CLauncherXMLParser::RunL()
+    {
+    TInt err = iStatus.Int();
+    LOGSTRING2("Launcher: CLauncherXMLParser::RunL - iStatus: %d", err);
+    if( err != KErrNone )
+        {
+        iObserver->DocumentParsedL(err); // Observer should cancel parsing        
+        iFile.Close();
+        ClearXMLDataBuffer();
+        }
+    else
+        {        
+        iParsedBytes += iXMLDataBuffer.Length();
+        iObserver->ParsingProgressedL(iParsedBytes);
+        // Check if the end of the file is reached:
+        if( iXMLDataBuffer.Length() > 0)
+            {
+            // Parse the data in buffer 
+            LOGSTRING("Launcher: CLauncherXMLParser::RunL: Starting XML parsing");
+            if( iParser )
+                {
+                iParser->ParseL( iXMLDataBuffer );
+                }
+            else
+                {
+                LOGSTRING("CLauncherXMLParser::RunL - Error: NULL parser");
+                User::Leave(KErrGeneral);
+                }
+            // Read new data from XML file to buffer:
+            iFile.Read( iXMLDataBuffer, KXMLBufferSize, iStatus );
+            SetActive();
+            }
+        else
+            {
+            // End of the file reached. Stop parsing and close the file:
+            LOGSTRING("Launcher: CLauncherXMLParser::RunL: Data parsed. Stopping");
+            if( iParser )
+                {
+                iParser->ParseEndL();
+                }
+            iFile.Close();
+            ClearXMLDataBuffer();
+            }    
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherXMLParser::ParseL(const TDesC& aFilePath, MLauncherParserObserver* aObserver)
+    {
+    LOGSTRING2("Launcher: CLauncherXMLParser::ParseL: %S", &aFilePath);
+    iIgnoreError = EFalse;
+    iParsedBytes = 0;
+    if ( IsActive() )
+        {
+        Cancel();
+        }
+    
+    if( aObserver == 0 )
+        {
+        LOGSTRING("Launcher: CLauncherXMLParser::ParseL: Error: Observer is a NULL pointer.");
+        User::Leave(KErrArgument);
+        }
+    
+    // Open the XML-file
+    TInt err = iFile.Open( iFileSession, aFilePath, EFileRead );
+    User::LeaveIfError( err );
+    
+    // Create and start XML-parser:
+    delete iParser;
+    iParser = 0;
+    iParser = CParser::NewL(KXmlMimeType, *this);        
+        
+    // Set observer:
+    iObserver = aObserver;
+    
+    // Initialize the buffer and read first part of the XML-file:
+    ClearXMLDataBuffer();
+    iFile.Read( iXMLDataBuffer, KXMLBufferSize, iStatus );
+    SetActive();   
+    iParser->ParseBeginL(); // Reset the parser to xml-filetype
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherXMLParser::OnStartDocumentL(const Xml::RDocumentParameters& /*aDocParam*/, TInt aErrorCode)
+    {    
+    LOGSTRING2("Launcher: CLauncherXMLParser::OnStartDocumentL (Error code: %d)", aErrorCode);
+    if( aErrorCode != KErrNone )
+        {
+        iObserver->DocumentParsedL(aErrorCode);
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherXMLParser::OnEndDocumentL(TInt aErrorCode)
+    {    
+    LOGSTRING2("Launcher: CLauncherXMLParser::OnEndDocumentL (Error code: %d)", aErrorCode);    
+    iObserver->DocumentParsedL(aErrorCode);
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherXMLParser::OnStartPrefixMappingL( const RString& /*aPrefix*/, 
+                                                const RString& /*aUri*/, 
+                                                TInt aErrorCode)
+    {    
+    LOGSTRING2("Launcher: CLauncherXMLParser::OnStartPrefixMappingL (Error code: %d)", aErrorCode);
+    if( aErrorCode != KErrNone )
+        {
+        iObserver->DocumentParsedL(aErrorCode);
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherXMLParser::OnEndPrefixMappingL(const RString& /*aPrefix*/, TInt aErrorCode)
+    {
+    LOGSTRING2("Launcer: CLauncherXMLParser::OnEndPrefixMappingL (Error code: %d)", aErrorCode);
+    if( aErrorCode != KErrNone )
+        {
+        iObserver->DocumentParsedL(aErrorCode);
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherXMLParser::OnIgnorableWhiteSpaceL(const TDesC8& /*aBytes*/, TInt aErrorCode)
+    {
+    LOGSTRING2("Launcher: CLauncherXMLParser::OnIgnorableWhiteSpaceL (Error code: %d)", aErrorCode);
+    if( aErrorCode != KErrNone )
+        {
+        iObserver->DocumentParsedL(aErrorCode);
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherXMLParser::OnSkippedEntityL(const RString& /*aName*/, TInt aErrorCode)
+    {
+    LOGSTRING2("Launcher: CLauncherXMLParser::OnSkippedEntityL (Error code: %d)", aErrorCode);
+    if( aErrorCode != KErrNone )
+        {
+        iObserver->DocumentParsedL(aErrorCode);
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherXMLParser::OnProcessingInstructionL(  const TDesC8& /*aTarget*/, 
+                                    const TDesC8& /*aData*/, 
+                                    TInt aErrorCode)
+    {
+    LOGSTRING2("Launcher: CLauncherXMLParser::OnProcessingInstructionL (Error code: %d)", aErrorCode);
+    if( aErrorCode != KErrNone )
+        {
+        iObserver->DocumentParsedL(aErrorCode);
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherXMLParser::OnError(TInt aErrorCode)
+    {
+    LOGSTRING2("Launcher: CLauncherXMLParser::OnError: %d", aErrorCode);    
+    if( iIgnoreError == EFalse )
+        {        
+        TRAP_IGNORE(iObserver->DocumentParsedL(aErrorCode));
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+TAny* CLauncherXMLParser::GetExtendedInterface(const TInt32 aUid)
+    {
+    LOGSTRING2("Launcher: CLauncherXMLParser::GetExtendedInterface (UID: %d)", aUid);
+    return 0;
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherXMLParser::OnStartElementL(   const RTagInfo& aElement,
+                                            const RAttributeArray& /*aAttributes*/,
+                                            TInt aErrorCode)
+    {
+    LOGSTRING2("Launcher: CLauncherXMLParser::OnStartElementL (Error code: %d)", aErrorCode);
+    if( aErrorCode != KErrNone )
+        {
+        iObserver->DocumentParsedL(aErrorCode);
+        }
+    else
+        {
+        // Save XML-element name:
+        iCurrentElementName = aElement.LocalName().DesC();
+    
+        // If this is 'dll'-element, initialize new DLL element instance:
+        if( iCurrentDllElement == 0 && iCurrentElementName == KDll )
+            {
+            iCurrentDllElement = CLauncherDLLElement::NewL();
+            }
+        // Clear contents buffer:
+        iCurrentContent.Zero();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherXMLParser::OnEndElementL(const RTagInfo& aElement, TInt aErrorCode)
+    {   
+    LOGSTRING2("Launcher: CLauncherXMLParser::OnEndElementL (Error code: %d)", aErrorCode);
+    if( aErrorCode != KErrNone )
+        {
+        iObserver->DocumentParsedL(aErrorCode);
+        }
+    else
+        {
+        // Save XML-element's name:        
+        iCurrentElementName = aElement.LocalName().DesC();    
+        TUid tmpUID;
+
+        if( IsDataElement() )
+            {        
+            // Check that we have a pointer to parent DLL element
+            if( iCurrentDllElement == 0 )
+                {
+                LOGSTRING("Launcher: CLauncherXMLParser: Error in parsing xml (parent DLL element missing).");
+                User::Leave(KErrGeneral);
+                }
+            // DLL name
+            if( iCurrentElementName == KDllName )
+                {
+                TFileName dllName;
+                dllName.Copy(iCurrentContent);
+                iCurrentDllElement->SetNameL(dllName);
+                }
+            // UID1
+            else if( iCurrentElementName == KUID1 )
+                {
+                tmpUID.iUid = ConvertDes8ToUint32L(iCurrentContent);
+                iCurrentDllElement->SetUID1L(tmpUID);
+                }
+            // UID2
+            else if( iCurrentElementName == KUID2 )
+                {
+                tmpUID.iUid = ConvertDes8ToUint32L(iCurrentContent);
+                iCurrentDllElement->SetUID2L(tmpUID);
+                }
+            // UID3
+            else if( iCurrentElementName == KUID3 )
+                {
+                tmpUID.iUid = ConvertDes8ToUint32L(iCurrentContent);
+                iCurrentDllElement->SetUID3L(tmpUID);
+                }
+            // SID
+            else if( iCurrentElementName == KSID )
+                {
+                tmpUID.iUid = ConvertDes8ToUint32L(iCurrentContent);
+                iCurrentDllElement->SetSIDL(tmpUID);
+                }
+            // Capability
+            else if( iCurrentElementName == KCapability )
+                {            
+                iCurrentDllElement->SetCapabilityL(ConvertDes8ToUint32L(iCurrentContent));
+                }
+            }
+        else if( iCurrentElementName == KDll )
+            {
+            // DLL element parsed, give current DLL object to observer:
+            iObserver->ElementParsedL(*iCurrentDllElement);
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+TBool CLauncherXMLParser::IsDataElement()
+    {
+    if( iCurrentElementName == KDllName ||
+        iCurrentElementName == KUID1 ||
+        iCurrentElementName == KUID2 ||
+        iCurrentElementName == KUID3 ||
+        iCurrentElementName == KSID ||
+        iCurrentElementName == KCapability )
+        {
+        return ETrue;
+        }
+    return EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// Reads content of an xml-element.
+
+void CLauncherXMLParser::OnContentL(const TDesC8& aBytes, TInt aErrorCode)
+    {
+    LOGSTRING2("Launcher: CLauncherXMLParser::OnContentL (Error code: %d)", aErrorCode);
+    if( aErrorCode != KErrNone )
+        {
+        iObserver->DocumentParsedL(aErrorCode);
+        }
+    else if( iCurrentElementName.Length() == 0)
+        {
+        LOGSTRING("Launcher: CLauncherXMLParser: Error in parsing xml (element name missing).");
+        User::Leave(KErrGeneral);
+        }
+    iCurrentContent.Append(aBytes);
+    }
+
+// ---------------------------------------------------------------------------
+
+TUint32 CLauncherXMLParser::ConvertDes8ToUint32L(const TDesC8& aStr)
+    {
+    LOGSTRING("Launcher: CLauncherXMLParser::ConvertDes8ToUintL");
+    TUint32 uintVal = 0;
+    TLex8 lex(aStr);
+    TInt errorCode=lex.Val(uintVal, EHex);
+    User::LeaveIfError(errorCode);
+    return uintVal;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/layers.sysdef.xml	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<!DOCTYPE SystemDefinition SYSTEM "sysdef_1_4_0.dtd" [
+  <!ENTITY layer_real_source_path "sf/app/rndtools" >
+]>
+
+<SystemDefinition name="rndtools" schema="1.4.0">
+  <systemModel>
+    <layer name="app_layer">
+      <module name="rndtools">
+        <unit unitID="tools.rndtools" mrp="" bldFile="&layer_real_source_path;/group" name="rndtools" />
+      </module>
+    </layer>
+  </systemModel>
+</SystemDefinition>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/data/loadgen.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,1418 @@
+/*
+* 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 <eikon.hrh>
+#include <avkon.rh>
+#include <avkon.rsg>
+#include <avkon.mbg>
+#include <CommonDialogs.hrh>
+#include <CommonDialogs.rh>
+#include <pathconfiguration.hrh>
+#include <data_caging_paths_strings.hrh>
+#include <appinfo.rh>
+
+#include "loadgen.hrh"
+#include "loadgen_std.h"
+
+
+// ---------------------------------------------------------
+//   
+//    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_loadgen_status_pane;
+    //menubar = r_loadgen_menubar;
+    //cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
+    }
+
+    
+//----------------------------------------------------
+//   
+//    r_loadgen_hotkeys
+//
+//----------------------------------------------------
+//
+RESOURCE HOTKEYS r_loadgen_hotkeys
+    {
+    control=
+        {
+        HOTKEY { command=EAknCmdExit; key='e'; }
+        };
+    }
+
+
+//----------------------------------------------------
+//    r_loadgen_view_main
+//----------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_loadgen_view_main
+    {
+    hotkeys=r_loadgen_hotkeys;
+    menubar=r_loadgen_menubar_view_main;  
+    cba=R_AVKON_SOFTKEYS_OPTIONS_EXIT;    
+    }
+
+//----------------------------------------------------
+//    r_loadgen_menubar_view_main
+//----------------------------------------------------
+//
+RESOURCE MENU_BAR r_loadgen_menubar_view_main
+    {
+    titles=
+        {
+        MENU_TITLE { menu_pane=r_loadgen_app_menu; txt="App"; },
+        MENU_TITLE { menu_pane=r_loadgen_view_main_menu; txt="Main"; }
+        };
+    }
+
+//----------------------------------------------------
+//    r_loadgen_view_main_menu
+//----------------------------------------------------
+//
+
+RESOURCE MENU_PANE r_loadgen_view_main_menu
+    {
+    items=
+        {
+        };
+    }
+
+           
+        
+//----------------------------------------------------
+//    r_loadgen_app_menu
+//----------------------------------------------------
+//
+RESOURCE MENU_PANE r_loadgen_app_menu
+    {
+    items=
+        {
+        MENU_ITEM { command=ELoadGenCmdNewLoad; txt="New load"; cascade=r_loadgen_newload_submenu; },
+        MENU_ITEM { command=ELoadGenStopAll; txt="Stop all"; },
+        MENU_ITEM { command=ELoadGenSuspendAll; txt="Suspend all"; },
+        MENU_ITEM { command=ELoadGenResumeAll; txt="Resume all"; },
+        MENU_ITEM { command=ELoadGenCmdLaunchPerfMon; txt="Launch PerfMon"; },
+        MENU_ITEM { command=ELoadGenCmdAbout; txt="About"; },
+        MENU_ITEM { command=EAknCmdExit; txt="Exit"; }
+        };
+    }
+
+RESOURCE MENU_PANE r_loadgen_newload_submenu
+    {
+    items = 
+        {
+        MENU_ITEM { command=ELoadGenCmdNewLoadCPULoad; txt="CPU load"; },
+        MENU_ITEM { command=ELoadGenCmdNewLoadEatMemory; txt="Eat memory"; },
+        MENU_ITEM { command=ELoadGenCmdNewLoadPhoneCall; txt="Phone calls"; },
+        MENU_ITEM { command=ELoadGenCmdNewLoadMessages; txt="Messages"; },
+        MENU_ITEM { command=ELoadGenCmdNewLoadNetConn; txt="Network conn."; },
+        MENU_ITEM { command=ELoadGenCmdNewLoadKeyPress; txt="Key presses"; },        
+        MENU_ITEM { command=ELoadGenCmdNewLoadApplications; txt="Applications"; },
+        MENU_ITEM { command=ELoadGenCmdNewLoadPhotoCaptures; txt="Photo captures"; },
+        MENU_ITEM { command=ELoadGenCmdNewLoadBluetooth; txt="Bluetooth actions"; },
+        MENU_ITEM { command=ELoadGenCmdNewLoadPointerEvent; txt="Pointer events"; }
+        };
+    }
+    
+//----------------------------------------------------
+//    r_loadgen_settings_dialog
+//    Dialog for setting list
+//----------------------------------------------------
+//
+RESOURCE DIALOG r_loadgen_settings_dialog
+    {
+    flags =
+        EEikDialogFlagNoDrag | EEikDialogFlagFillAppClientRect |
+        EEikDialogFlagButtonsRight | EEikDialogFlagCbaButtons |
+        EEikDialogFlagWait | EEikDialogFlagNoTitleBar;
+    buttons = R_AVKON_SOFTKEYS_OPTIONS_BACK;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtSettingListBox;
+            id = ELoadGenSettingItemList;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = LISTBOX
+                {
+                flags = EAknListBoxSelectionList;
+                };
+            }
+        };
+    }
+
+//----------------------------------------------------
+//    r_loadgen_settings_menubar
+//----------------------------------------------------
+//
+
+RESOURCE MENU_BAR r_loadgen_settings_menubar
+    {
+    titles =
+        {
+        MENU_TITLE
+            {
+            menu_pane = r_loadgen_settings_menupane;
+            txt = " ";   // dummy
+            }
+        };
+    }
+
+RESOURCE MENU_PANE r_loadgen_settings_menupane
+    {
+    items =
+        {
+        MENU_ITEM
+            {
+            command = ELoadGenCmdSettingsChange;
+            txt = "Change";
+            },
+        MENU_ITEM
+            {
+            command = ELoadGenCmdSettingsExit;
+            txt = "Exit";
+            }
+        };
+    }
+
+
+
+  
+// ---------------------------------------------------------
+//   
+//   r_loadgen_about_dialog
+//   About dialog - show version and copyright info etc.
+//
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_loadgen_about_dialog
+    {
+    flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow;
+    buttons = R_AVKON_SOFTKEYS_OK_EMPTY;
+    items=
+        {
+        DLG_LINE
+            {
+            type = EAknCtPopupHeadingPane;
+            id = EAknMessageQueryHeaderId;
+            control = AVKON_HEADING
+                {
+                label = "About LoadGen";
+                headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE;
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtMessageQuery;
+            id = EAknMessageQueryContentId;
+            control = AVKON_MESSAGE_QUERY
+                {
+                message = "Version 1.4.0 - 30th September 2009. Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0.";
+                };
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+//   r_general_confirmation_query
+// ---------------------------------------------------------
+//
+
+RESOURCE DIALOG r_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_general_text_query
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_general_text_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items=
+        {
+        DLG_LINE
+            {
+            type = EAknCtQuery;
+            id = EGeneralQuery;
+            control = AVKON_DATA_QUERY
+                {
+                layout = EDataLayout;
+                control = EDWIN
+                    {
+                    width = 256;
+                    lines = 3;
+                    maxlength = 256;
+                    };
+                };
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+//   r_general_text_query
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_general_numeric_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtQuery;
+            id = EGeneralQuery;
+            control= AVKON_DATA_QUERY
+                {
+                layout = ENumberLayout;
+                control = AVKON_INTEGER_EDWIN
+                    {
+                    min = -999999;
+                    max = 999999;
+                    };
+                };
+            }
+        };
+    }
+
+
+// ---------------------------------------------------------
+//   r_item_action_query
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_item_action_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            control= AVKON_LIST_QUERY_CONTROL
+                {
+                listtype = EAknCtSinglePopupMenuListBox;
+                listbox = AVKON_LIST_QUERY_LIST
+                    {
+                    array_id = r_item_action_query_array;
+                    };
+                heading = "";
+                };
+            }
+        };
+    }
+
+RESOURCE ARRAY r_item_action_query_array
+    {
+    items =
+        {
+        LBUF {txt = "Stop"; },
+        LBUF {txt = "Resume/suspend"; },
+        LBUF {txt = "Edit"; }
+        };
+    }     
+
+
+// ---------------------------------------------------------
+//   r_cpuload_form_dialog
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_cpuload_form_dialog
+    {
+    flags = EAknDialogGenericFullScreen;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    form = r_cpuload_form;
+    }
+
+RESOURCE FORM r_cpuload_form
+    {
+    flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat;
+    items = 
+        {
+        DLG_LINE
+            {
+            type = EAknCtPopupFieldText;
+            prompt = "Priority";
+            id = ELoadGenCPULoadQueryPriority;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = POPUP_FIELD_TEXT
+                {
+                popupfield = POPUP_FIELD
+                    {
+                    width = 100;
+                    };
+                textarray = r_thread_priority_textarray;
+                active = 0;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtPopupFieldText;
+            prompt = "Load mode";
+            id = ELoadGenCPULoadQueryMode;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = POPUP_FIELD_TEXT
+                {
+                popupfield = POPUP_FIELD
+                    {
+                    width = 100;
+                    };
+                textarray = r_cpuloadmode_textarray;
+                active = 0;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtPopupFieldText;
+            prompt = "Type";
+            id = ELoadGenCPULoadQueryType;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = POPUP_FIELD_TEXT
+                {
+                popupfield = POPUP_FIELD
+                    {
+                    width = 100;
+                    };
+                textarray = r_cpuloadtype_textarray;
+                active = 0;    
+                };
+            }
+        };
+    }
+
+RESOURCE DLG_LINE r_cpuload_dlg_line_periodic_length
+    {
+    type = EEikCtNumberEditor;
+    prompt = "Length (ms)";
+    id = ELoadGenCPULoadQueryLength;
+    itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+    control = NUMBER_EDITOR
+        {
+        min = 0;    
+        max = 999999999;    
+        };
+    }
+
+RESOURCE DLG_LINE r_cpuload_dlg_line_periodic_idle
+    {
+    type = EEikCtNumberEditor;
+    prompt = "Idle (ms)";
+    id = ELoadGenCPULoadQueryIdle;
+    itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+    control = NUMBER_EDITOR
+        {
+        min = 0;    
+        max = 999999999;    
+        };
+    }
+
+RESOURCE DLG_LINE r_cpuload_dlg_line_periodic_variance
+    {
+    type = EEikCtNumberEditor;
+    prompt = "Random variance (%)";
+    id = ELoadGenCPULoadQueryVariance;
+    itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+    control = NUMBER_EDITOR
+        {
+        min = 0;    
+        max = 100;    
+        };
+    }
+
+RESOURCE DLG_LINE r_cpuload_dlg_line_cpu
+    {
+    type = EAknCtPopupFieldText;
+    prompt = "CPU";
+    id = ELoadGenCPULoadQueryCpu;
+    itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+    control = POPUP_FIELD_TEXT
+        {
+        popupfield = POPUP_FIELD
+            {
+            width = 100;
+            };
+        textarray = r_cpuloadcpu_textarray;
+        active = 0;    
+        };
+    }
+
+                
+// ---------------------------------------------------------
+//   r_memoryeat_form_dialog
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_memoryeat_form_dialog
+    {
+    flags = EAknDialogGenericFullScreen;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    form = r_memoryeat_form;
+    }
+
+RESOURCE FORM r_memoryeat_form
+    {
+    flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat;
+    items = 
+        {
+        DLG_LINE
+            {
+            type = EAknCtPopupFieldText;
+            prompt = "Priority";
+            id = ELoadGenMemoryEatQueryPriority;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = POPUP_FIELD_TEXT
+                {
+                popupfield = POPUP_FIELD
+                    {
+                    width = 100;
+                    };
+                textarray = r_thread_priority_textarray;
+                active = 0;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtPopupFieldText;
+            prompt = "Source";
+            id = ELoadGenMemoryEatQuerySource;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = POPUP_FIELD_TEXT
+                {
+                popupfield = POPUP_FIELD
+                    {
+                    width = 100;
+                    };
+                textarray = r_memoryeatsource_textarray;
+                active = 0;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtPopupFieldText;
+            prompt = "Type";
+            id = ELoadGenMemoryEatQueryType;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = POPUP_FIELD_TEXT
+                {
+                popupfield = POPUP_FIELD
+                    {
+                    width = 100;
+                    };
+                textarray = r_memoryeattype_textarray;
+                active = 0;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EEikCtNumberEditor;
+            prompt = "Buffer (B)";
+            id = ELoadGenMemoryEatQueryBuffer;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = NUMBER_EDITOR
+                {
+                min = 0;    
+                max = 999999999;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EEikCtNumberEditor;
+            prompt = "Idle after buffer (ms)";
+            id = ELoadGenMemoryEatQueryIdle;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = NUMBER_EDITOR
+                {
+                min = 0;    
+                max = 999999999;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EEikCtNumberEditor;
+            prompt = "Random variance (%)";
+            id = ELoadGenMemoryEatQueryVariance;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = NUMBER_EDITOR
+                {
+                min = 0;    
+                max = 100;    
+                };
+            }
+        };
+    }
+
+RESOURCE DLG_LINE r_memoryeat_dlg_line_amount
+    {
+    type = EEikCtEdwin;
+    prompt = "Amount (B)";
+    id = ELoadGenMemoryEatQueryAmount;
+    itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+    control = EDWIN
+        {
+        flags = KMultiLineExpandingEditorFlags | EEikEdwinNoLineOrParaBreaks;
+        maxlength = 14;    
+        width = 6;
+        default_input_mode = EAknEditorNumericInputMode;
+        allowed_input_modes = EAknEditorNumericInputMode;    
+        };
+    }
+    
+RESOURCE DLG_LINE r_memoryeat_dlg_line_random_min
+    {
+    type = EEikCtEdwin;
+    prompt = "Min to be left (B)";
+    id = ELoadGenMemoryEatQueryRandomMin;
+    itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+    control = EDWIN
+        {
+        flags = KMultiLineExpandingEditorFlags | EEikEdwinNoLineOrParaBreaks;
+        maxlength = 14;    
+        width = 6;
+        default_input_mode = EAknEditorNumericInputMode;
+        allowed_input_modes = EAknEditorNumericInputMode;    
+        };
+    }
+
+RESOURCE DLG_LINE r_memoryeat_dlg_line_random_max
+    {
+    type = EEikCtEdwin;
+    prompt = "Max to be left (B)";
+    id = ELoadGenMemoryEatQueryRandomMax;
+    itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+    control = EDWIN
+        {
+        flags = KMultiLineExpandingEditorFlags | EEikEdwinNoLineOrParaBreaks;
+        maxlength = 14;    
+        width = 6;
+        default_input_mode = EAknEditorNumericInputMode;
+        allowed_input_modes = EAknEditorNumericInputMode;    
+        };
+    }
+
+
+
+// ---------------------------------------------------------
+//   r_phonecall_form_dialog
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_phonecall_form_dialog
+    {
+    flags = EAknDialogGenericFullScreen;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    form = r_phonecall_form;
+    }
+
+RESOURCE FORM r_phonecall_form
+    {
+    flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat;
+    items = 
+        {
+        DLG_LINE
+            {
+            type = EAknCtPopupFieldText;
+            prompt = "Priority";
+            id = ELoadGenPhoneCallQueryPriority;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = POPUP_FIELD_TEXT
+                {
+                popupfield = POPUP_FIELD
+                    {
+                    width = 100;
+                    };
+                textarray = r_thread_priority_textarray;
+                active = 0;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EEikCtEdwin;
+            prompt = "Phone number";
+            id = ELoadGenPhoneCallQueryDestination;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = EDWIN
+                {
+                width = 255;    
+                maxlength = 255;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EEikCtNumberEditor;
+            prompt = "Length (ms)";
+            id = ELoadGenPhoneCallQueryLength;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = NUMBER_EDITOR
+                {
+                min = 0;    
+                max = 999999999;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EEikCtNumberEditor;
+            prompt = "Idle (ms)";
+            id = ELoadGenPhoneCallQueryIdle;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = NUMBER_EDITOR
+                {
+                min = 0;    
+                max = 999999999;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EEikCtNumberEditor;
+            prompt = "Random variance (%)";
+            id = ELoadGenPhoneCallQueryVariance;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = NUMBER_EDITOR
+                {
+                min = 0;    
+                max = 100;    
+                };
+            }
+        };
+    }
+
+
+// ---------------------------------------------------------
+//   r_netconn_form_dialog
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_netconn_form_dialog
+    {
+    flags = EAknDialogGenericFullScreen;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    form = r_netconn_form;
+    }
+
+RESOURCE FORM r_netconn_form
+    {
+    flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat;
+    items = 
+        {
+        DLG_LINE
+            {
+            type = EAknCtPopupFieldText;
+            prompt = "Priority";
+            id = ELoadGenNetConnQueryPriority;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = POPUP_FIELD_TEXT
+                {
+                popupfield = POPUP_FIELD
+                    {
+                    width = 100;
+                    };
+                textarray = r_thread_priority_textarray;
+                active = 0;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EEikCtEdwin;
+            prompt = "Destination URL";
+            id = ELoadGenNetConnQueryDestination;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = EDWIN
+                {
+                width = 255;    
+                maxlength = 255;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EEikCtNumberEditor;
+            prompt = "Idle (ms)";
+            id = ELoadGenNetConnQueryIdle;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = NUMBER_EDITOR
+                {
+                min = 0;    
+                max = 999999999;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EEikCtNumberEditor;
+            prompt = "Random variance (%)";
+            id = ELoadGenNetConnQueryVariance;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = NUMBER_EDITOR
+                {
+                min = 0;    
+                max = 100;    
+                };
+            }
+        };
+    }
+
+
+// ---------------------------------------------------------
+//   r_keypress_form_dialog
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_keypress_form_dialog
+    {
+    flags = EAknDialogGenericFullScreen;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    form = r_keypress_form;
+    }
+
+RESOURCE FORM r_keypress_form
+    {
+    flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat;
+    items = 
+        {
+        DLG_LINE
+            {
+            type = EAknCtPopupFieldText;
+            prompt = "Priority";
+            id = ELoadGenKeyPressQueryPriority;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = POPUP_FIELD_TEXT
+                {
+                popupfield = POPUP_FIELD
+                    {
+                    width = 100;
+                    };
+                textarray = r_thread_priority_textarray;
+                active = 0;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EEikCtNumberEditor;
+            prompt = "Heartbeat (ms)";
+            id = ELoadGenKeyPressQueryHeartBeat;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = NUMBER_EDITOR
+                {
+                min = 0;    
+                max = 999999999;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EEikCtNumberEditor;
+            prompt = "Random variance (%)";
+            id = ELoadGenKeyPressQueryVariance;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = NUMBER_EDITOR
+                {
+                min = 0;    
+                max = 100;    
+                };
+            }
+        };
+    }    
+
+// ---------------------------------------------------------
+//   r_pointerevent_form_dialog
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_pointerevent_form_dialog
+    {
+    flags = EAknDialogGenericFullScreen;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    form = r_pointerevent_form;
+    }
+
+RESOURCE FORM r_pointerevent_form
+    {
+    flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat;
+    items = 
+        {
+        DLG_LINE
+            {
+            type = EAknCtPopupFieldText;
+            prompt = "Priority";
+            id = ELoadGenPointerEventQueryPriority;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = POPUP_FIELD_TEXT
+                {
+                popupfield = POPUP_FIELD
+                    {
+                    width = 100;
+                    };
+                textarray = r_thread_priority_textarray;
+                active = 0;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EEikCtNumberEditor;
+            prompt = "Heartbeat (ms)";
+            id = ELoadGenPointerEventQueryHeartBeat;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = NUMBER_EDITOR
+                {
+                min = 0;    
+                max = 999999999;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EEikCtNumberEditor;
+            prompt = "Random variance (%)";
+            id = ELoadGenPointerEventQueryVariance;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = NUMBER_EDITOR
+                {
+                min = 0;    
+                max = 100;    
+                };
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+//   r_messages_form_dialog
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_messages_form_dialog
+    {
+    flags = EAknDialogGenericFullScreen;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    form = r_messages_form;
+    }
+
+RESOURCE FORM r_messages_form
+    {
+    flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat;
+    items = 
+        {
+        DLG_LINE
+            {
+            type = EAknCtPopupFieldText;
+            prompt = "Priority";
+            id = ELoadGenMessagesQueryPriority;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = POPUP_FIELD_TEXT
+                {
+                popupfield = POPUP_FIELD
+                    {
+                    width = 100;
+                    };
+                textarray = r_thread_priority_textarray;
+                active = 0;    
+                };
+            },
+            DLG_LINE
+                {
+                type = EAknCtPopupFieldText;
+                prompt = "Type";
+                id = ELoadGenMessagesQueryType;
+                itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+                control = POPUP_FIELD_TEXT
+                    {
+                    popupfield = POPUP_FIELD
+                        {
+                        width = 100;
+                        };
+                    textarray = r_message_type_textarray;
+                    active = 0;    
+                    };
+                },            
+        DLG_LINE
+            {
+            type = EEikCtEdwin;
+            prompt = "Phone number";
+            id = ELoadGenMessagesQueryDestination;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = EDWIN
+                {
+                width = 255;    
+                maxlength = 255;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EEikCtNumberEditor;
+            prompt = "Maximum amount of messages";
+            id = ELoadGenMessagesQueryAmount;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = NUMBER_EDITOR
+                {
+                min = 0;    
+                max = 1000;    
+                };
+            },            
+        DLG_LINE
+            {
+            type = EEikCtNumberEditor;
+            prompt = "Message length";
+            id = ELoadGenMessagesQueryLength;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = NUMBER_EDITOR
+                {
+                min = 0;    
+                max = 512;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EEikCtNumberEditor;
+            prompt = "Idle (ms)";
+            id = ELoadGenMessagesQueryIdle;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = NUMBER_EDITOR
+                {
+                min = 0;    
+                max = 999999999;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EEikCtNumberEditor;
+            prompt = "Random variance (%)";
+            id = ELoadGenMessagesQueryVariance;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = NUMBER_EDITOR
+                {
+                min = 0;    
+                max = 100;    
+                };
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+//   r_applicatios_form_dialog
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_applications_form_dialog
+    {
+    flags = EAknDialogGenericFullScreen;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    form = r_applications_form;
+    }
+
+RESOURCE FORM r_applications_form
+    {
+    flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat;
+    items = 
+        {
+        DLG_LINE
+            {
+            type = EAknCtPopupFieldText;
+            prompt = "Priority";
+            id = ELoadGenApplicationsQueryPriority;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = POPUP_FIELD_TEXT
+                {
+                popupfield = POPUP_FIELD
+                    {
+                    width = 100;
+                    };
+                textarray = r_thread_priority_textarray;
+                active = 0;    
+                };
+            },            
+        DLG_LINE
+            {
+            type = EEikCtNumberEditor;
+            prompt = "Max parallel applications";
+            id = ELoadGenApplicationsMaxOpen;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = NUMBER_EDITOR
+                {
+                min = 0;    
+                max = 100;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EEikCtNumberEditor;
+            prompt = "Launching interval (ms)";
+            id = ELoadGenApplicationsLaunchingInterval;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = NUMBER_EDITOR
+                {
+                min = 0;    
+                max = 999999999;    
+                };
+            },
+            
+        DLG_LINE
+            {
+            type = EAknCtPopupFieldText;
+            prompt = "Key press type";
+            id = ELoadGenApplicationsKeyPressType;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = POPUP_FIELD_TEXT
+                {
+                popupfield = POPUP_FIELD
+                    {
+                    width = 100;
+                    };
+                textarray = r_applications_keypress_type_textarray;
+                active = 0;    
+                };
+            },            
+        DLG_LINE
+            {
+            type = EEikCtNumberEditor;
+            prompt = "Key press interval (ms)";
+            id = ELoadGenApplicationsKeyPressQueryHeartBeat;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = NUMBER_EDITOR
+                {
+                min = 0;    
+                max = 999999999;    
+                };
+            },
+        DLG_LINE
+            {
+            type = EEikCtNumberEditor;
+            prompt = "Random variance (%)";
+            id = ELoadGenApplicationsQueryVariance;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = NUMBER_EDITOR
+                {
+                min = 0;    
+                max = 100;    
+                };
+            }
+        };
+    }    
+
+// ---------------------------------------------------------
+//   r_photocapture_form_dialog
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_photocapture_form_dialog
+    {
+    flags = EAknDialogGenericFullScreen;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    form = r_photocapture_form;
+    }
+
+RESOURCE FORM r_photocapture_form
+    {
+    flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat;
+    items = 
+        {
+                DLG_LINE
+                    {
+                    type = EAknCtPopupFieldText;
+                    prompt = "Priority";
+                    id = ELoadGenPhotoCaptureQueryPriority;
+                    itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+                    control = POPUP_FIELD_TEXT
+                        {
+                        popupfield = POPUP_FIELD
+                            {
+                            width = 100;
+                            };
+                        textarray = r_thread_priority_textarray;
+                        active = 0;    
+                        };
+                    },
+                DLG_LINE
+                    {
+                    type = EEikCtNumberEditor;
+                    prompt = "Idle (ms)";
+                    id = ELoadGenPhotoCaptureQueryIdle;
+                    itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+                    control = NUMBER_EDITOR
+                        {
+                        min = 0;    
+                        max = 999999999;    
+                        };
+                    },
+                DLG_LINE
+                    {
+                    type = EEikCtNumberEditor;
+                    prompt = "Random variance (%)";
+                    id = ELoadGenPhotoCaptureQueryVariance;
+                    itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+                    control = NUMBER_EDITOR
+                        {
+                        min = 0;    
+                        max = 100;    
+                        };
+                    }
+        };
+    }
+
+/*RESOURCE DLG_LINE r_photocapture_dlg_line_periodic_idle
+    {
+    type = EEikCtNumberEditor;
+    prompt = "Idle (ms)";
+    id = ELoadGenPhotoCaptureQueryIdle;
+    itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+    control = NUMBER_EDITOR
+        {
+        min = 0;    
+        max = 999999999;    
+        };
+    }
+
+RESOURCE DLG_LINE r_photocapture_dlg_line_periodic_variance
+    {
+    type = EEikCtNumberEditor;
+    prompt = "Random variance (%)";
+    id = ELoadGenPhotoCaptureQueryVariance;
+    itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+    control = NUMBER_EDITOR
+        {
+        min = 0;    
+        max = 100;    
+        };
+    }*/
+
+RESOURCE DLG_LINE r_photocapture_dlg_line_device
+    {
+    type = EAknCtPopupFieldText;
+    prompt = "Device";
+    id = ELoadGenPhotoCaptureQueryDevice;
+    itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+    control = POPUP_FIELD_TEXT
+        {
+        popupfield = POPUP_FIELD
+            {
+            width = 100;
+            };
+        textarray = r_photocapturedevice_textarray;
+        active = 0;    
+        };
+    }
+
+// ---------------------------------------------------------
+//   r_photocapture_form_dialog
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_bluetooth_form_dialog
+    {
+    flags = EAknDialogGenericFullScreen;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    form = r_bluetooth_form;
+    }
+
+RESOURCE FORM r_bluetooth_form
+    {
+    flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat;
+    items = 
+        {
+                DLG_LINE
+                    {
+                    type = EAknCtPopupFieldText;
+                    prompt = "Priority";
+                    id = ELoadGenBluetoothQueryPriority;
+                    itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+                    control = POPUP_FIELD_TEXT
+                        {
+                        popupfield = POPUP_FIELD
+                            {
+                            width = 100;
+                            };
+                        textarray = r_thread_priority_textarray;
+                        active = 0;    
+                        };
+                    },
+                DLG_LINE
+                    {
+                    type = EEikCtNumberEditor;
+                    prompt = "Idle (ms)";
+                    id = ELoadGenBluetoothQueryIdle;
+                    itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+                    control = NUMBER_EDITOR
+                        {
+                        min = 0;    
+                        max = 999999999;    
+                        };
+                    },
+                DLG_LINE
+                    {
+                    type = EEikCtNumberEditor;
+                    prompt = "Random variance (%)";
+                    id = ELoadGenBluetoothQueryVariance;
+                    itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+                    control = NUMBER_EDITOR
+                        {
+                        min = 0;    
+                        max = 100;    
+                        };
+                    }
+        };
+    }
+
+// ---------------------------------------------------------
+// Arrays for forms:    
+    
+RESOURCE ARRAY r_thread_priority_textarray
+    {
+    items =
+        {
+        LBUF { txt = "Much less (-20)"; },
+        LBUF { txt = "Less (-10)"; },
+        LBUF { txt = "Normal (0)"; },
+        LBUF { txt = "More (10)"; },
+        LBUF { txt = "Much more (20)"; },
+        LBUF { txt = "Real time (30)"; },
+        LBUF { txt = "Abs. very low (100)"; },
+        LBUF { txt = "Abs. low (200)"; },
+        LBUF { txt = "Abs. backgr. (300)"; },
+        LBUF { txt = "Abs. foregr. (400)"; },
+        LBUF { txt = "Abs. high (500)"; }
+        };
+    } 
+
+RESOURCE ARRAY r_cpuloadmode_textarray
+    {
+    items =
+        {
+        LBUF { txt = "Yielding"; },
+        LBUF { txt = "Blocking"; }
+        };
+    } 
+    
+RESOURCE ARRAY r_cpuloadtype_textarray
+    {
+    items =
+        {
+        LBUF { txt = "Continuous"; },
+        LBUF { txt = "Periodic"; }
+        };
+    }       
+
+RESOURCE ARRAY r_cpuloadcpu_textarray
+    {
+    items =
+        {
+        LBUF { txt = "CPU0"; }
+        };
+    }       
+
+RESOURCE ARRAY r_memoryeatsource_textarray
+    {
+    items =
+        {
+        LBUF { txt = "RAM"; },
+        LBUF { txt = "C:"; },
+        LBUF { txt = "D:"; },
+        LBUF { txt = "E:"; },
+        LBUF { txt = "F:"; },
+        LBUF { txt = "G:"; },
+        LBUF { txt = "H:"; },
+        LBUF { txt = "I:"; },
+        LBUF { txt = "J:"; },
+        LBUF { txt = "K:"; },
+        LBUF { txt = "L:"; },
+        LBUF { txt = "M:"; },
+        LBUF { txt = "N:"; }
+        };
+    }
+    
+RESOURCE ARRAY r_memoryeattype_textarray
+    {
+    items =
+        {
+        LBUF { txt = "Memory to eat"; },
+        LBUF { txt = "Memory to be left"; },
+        LBUF { txt = "Alternate min/max"; }
+        };
+    }
+    
+RESOURCE ARRAY r_message_type_textarray
+    {
+    items =
+        {
+        LBUF { txt = "SMS"; },
+        LBUF { txt = "MMS"; }
+        };
+    } 
+
+RESOURCE ARRAY r_applications_keypress_type_textarray
+    {
+    items =
+        {
+        LBUF { txt = "None"; },
+        LBUF { txt = "Arrow keys"; }
+        };
+    } 
+
+RESOURCE ARRAY r_photocapturedevice_textarray
+    {
+    items =
+        {
+        LBUF { txt = "Camera 1"; }
+        };
+    } 
+
+
+// ---------------------------------------------------------
+//   
+//    RESOURCE LOCALISABLE_APP_INFO
+//
+// ---------------------------------------------------------
+//
+RESOURCE LOCALISABLE_APP_INFO r_loadgen_localisable_app_info
+    {
+    short_caption = "LoadGen";
+    caption_and_icon = 
+    CAPTION_AND_ICON_INFO
+        {
+        caption = "Load Gener.";
+
+        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"\\loadgen_aif.mif";
+        };
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/data/loadgen_reg.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,35 @@
+/*
+* 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 <loadgen.rsg>
+#include <appinfo.rh>
+#include <data_caging_paths_strings.hrh>
+
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0x20011384
+
+
+RESOURCE APP_REGISTRATION_INFO
+    {
+    app_file = "LoadGen";
+    localisable_resource_file = APP_RESOURCE_DIR"\\LoadGen";
+    localisable_resource_id = R_LOADGEN_LOCALISABLE_APP_INFO;
+    group_name = "RnD Tools";    
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/envpatcher/EnvPatcher.pl	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,544 @@
+#
+# 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;    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/envpatcher/ReadMe.txt	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,46 @@
+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".
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/group/ReleaseNotes_LoadGen.txt	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,128 @@
+===============================================================================
+
+RELEASE NOTES - LOAD GENERATOR v1.4.0
+RELEASED 30th September 2009
+
+SUPPORTS S60 3.0+
+
+===============================================================================
+
+Product Description:
+====================
+LoadGen is an S60 UI application that provides an easy way to generate load
+into a device. You can use LoadGen to simulate the behavior and possible
+problems of a device when put under a heavy load in actual usage scenarios. 
+
+Main Features:
+==============
+- Load types: 
+  - CPU load (yielding or blocking)
+  - Memory eat (RAM and disks)
+  - Phone calls
+  - Network connection
+  - Key press
+  - SMS and MMS sending
+  - Launching applications
+  - Photo captures
+  - Bluetooth device discovery
+  - Touch UI pointer events
+- Each load type can be executed periodically (that is, idle time can be
+  applied after each round)
+- Each started load will be run in a separate thread
+- Each load type can be paused/resumed and stopped
+
+===============================================================================
+
+What's New in v1.4.0
+====================
+- Feature: New load: Photo capture.
+- Feature: New load: Bluetooth actions.
+- Feature: New load: Pointer (touch ui) events. 
+
+===============================================================================
+
+Installation Notes:
+===================
+LoadGen 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:
+  NetworkServices
+  SwEvent
+  ReadUserData
+  WriteUserData
+
+When builing LoadGen 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:
+=============
+- Launched applications are not always terminated by LoadGen. This occurs with
+  applications that are waiting for user input.
+ 
+===============================================================================
+
+Version History:
+================
+
+Version 1.3.0 - 30th June 2009
+==============================
+- Feature: SMP support: CPU can be selected for CPU load.
+
+Version 1.2.1 - 6th March 2009
+==============================
+- Fix: Messages load crashes Load Generator
+
+Version 1.2.0 - 20th February 2009
+==================================
+- Feature: New load: application launch
+- Fix: LoadGen crashes when changing the Type of CPU load
+
+Version 1.1.0 - 12th December 2008
+==================================
+- Feature: SMS and MMS messages can be sent 
+- Fix: It was not possible to eat more memory than 2GB
+
+Version 1.0.1 - 18th March 2008
+===============================
+- Fix: It was possible to edit source type for existing memory eat item
+- Fix: Thread priority was not changed when editing existing item 
+- Fix: Memory eat did not work properly or caused crash in some cases
+- Fix: Editing existing memory eat replaced values with default values
+- Fix: Memory about queries did not have any check for maximum value 
+- Fix: Stopping a crashed load crashed the whole application
+
+
+Version 1.0.0 - 6th March 2008
+------------------------------
+- Initial version
+
+===============================================================================
+
+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".
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/group/backup_registration.xml	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,8 @@
+<?xml version="1.0" standalone="yes"?>
+<backup_registration>
+  <passive_backup>
+    <include_directory name="\"/>
+  </passive_backup>
+  <system_backup/>
+  <restore requires_reboot = "no"/>
+</backup_registration>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_EXPORTS
+../group/backup_registration.xml    Z:/private/20011384/backup_registration.xml
+../rom/loadgen.iby CORE_IBY_EXPORT_PATH(tools,loadgen.iby)
+
+
+PRJ_MMPFILES
+#if defined(__SERIES60_30__) || defined(__SERIES60_31__) || defined(__S60_32__)
+  gnumakefile loadgen_icons_aif.mk
+  gnumakefile loadgen_extraicons.mk
+
+  #ifdef MARM
+  gnumakefile loadgen_stub_sis.mk
+  #endif
+#endif
+
+loadgen.mmp
+
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)
+  PRJ_EXTENSIONS
+  START EXTENSION s60/mifconv
+  OPTION TARGETFILE loadgen_aif.mif
+  OPTION SOURCEDIR ../icons
+  OPTION SOURCES -c8,8 qgn_menu_loadgen
+  END
+
+  START EXTENSION s60/mifconv
+  OPTION TARGETFILE loadgen_extraicons.mif
+  OPTION HEADERFILE loadgen_extraicons.mbg
+  OPTION SOURCEDIR ../icons
+  OPTION SOURCES -c8,8 qgn_prob_status_red -c8,8 qgn_prob_status_green
+  END
+
+  #ifdef MARM
+  START EXTENSION app-services/buildstubsis
+  OPTION SRCDIR ../sis
+  OPTION SISNAME LoadGen_stub
+  END
+  #endif  
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/group/loadgen.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,107 @@
+/*
+* 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            LoadGen.exe
+TARGETTYPE        exe
+EPOCSTACKSIZE     0x5000
+EPOCHEAPSIZE      0x10000 0x1000000  // Min 64Kb, Max 16Mb
+
+UID               0x100039CE 0x20011384
+
+VENDORID          VID_DEFAULT
+CAPABILITY        swevent ReadUserData WriteUserData NetworkServices UserEnvironment CAP_APPLICATION AllFiles
+
+LANG              SC
+
+SMPSAFE
+
+START RESOURCE    ../data/loadgen.rss
+HEADER
+TARGETPATH        APP_RESOURCE_DIR
+END
+
+START RESOURCE    ../data/loadgen_reg.rss
+DEPENDS           loadgen.rsg
+TARGETPATH        /private/10003a3f/apps
+END
+
+APP_LAYER_SYSTEMINCLUDE
+USERINCLUDE       ../inc
+SOURCEPATH        ../src
+
+
+SOURCE            loadgen_app.cpp
+SOURCE            loadgen_document.cpp 
+SOURCE            loadgen_appui.cpp
+SOURCE            loadgen_model.cpp
+SOURCE            loadgen_mainview.cpp 
+SOURCE            loadgen_maincontainer.cpp 
+SOURCE            loadgen_settingsviewdlg.cpp
+SOURCE            loadgen_editors.cpp
+SOURCE            loadgen_loadbase.cpp
+SOURCE            loadgen_cpuload.cpp
+SOURCE            loadgen_memoryeat.cpp
+SOURCE            loadgen_phonecall.cpp
+SOURCE            loadgen_netconn.cpp
+SOURCE            loadgen_keypress.cpp
+SOURCE            loadgen_messages.cpp 
+SOURCE            loadgen_applications.cpp 
+SOURCE 			  loadgen_photocapture.cpp
+SOURCE			  loadgen_bluetooth.cpp 
+SOURCE			  loadgen_pointerevent.cpp
+
+LIBRARY           euser.lib
+LIBRARY           commonengine.lib
+LIBRARY           apparc.lib
+LIBRARY           cone.lib 
+LIBRARY           eikcore.lib
+LIBRARY           eikcoctl.lib
+LIBRARY           eikctl.lib
+LIBRARY           eikdlg.lib  
+LIBRARY           avkon.lib 
+LIBRARY           ws32.lib 
+LIBRARY           apgrfx.lib
+LIBRARY           efsrv.lib
+LIBRARY           bafl.lib
+LIBRARY           gdi.lib
+LIBRARY           aknicon.lib
+LIBRARY           aknskins.lib
+LIBRARY           aknskinsrv.lib
+LIBRARY           egul.lib
+LIBRARY           etel3rdparty.lib
+LIBRARY           downloadmgr.lib
+LIBRARY           commdb.lib
+LIBRARY           flogger.lib
+LIBRARY           estor.lib 
+LIBRARY           msgs.lib
+LIBRARY           smcm.lib
+LIBRARY           gsmu.lib
+LIBRARY           etext.lib
+LIBRARY           sendas2.lib
+LIBRARY  		  ecam.lib
+LIBRARY			  featdiscovery.lib 
+LIBRARY			  centralrepository.lib
+LIBRARY           esock.lib
+LIBRARY           bluetooth.lib
+LIBRARY			  hal.lib
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/group/loadgen_extraicons.mk	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z
+else
+ZDIR=\epoc32\data\z
+endif
+
+TARGETDIR=$(ZDIR)\resource\apps
+ICONTARGETFILENAME=$(TARGETDIR)\loadgen_extraicons.mif
+
+HEADERDIR=\epoc32\include
+HEADERFILENAME=$(HEADERDIR)\loadgen_extraicons.mbg
+
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN :
+	@if exist $(ICONTARGETFILENAME) erase $(ICONTARGETFILENAME)
+	@if exist $(HEADERFILENAME) erase $(HEADERFILENAME)
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+RESOURCE : $(ICONTARGETFILENAME)
+
+$(ICONTARGETFILENAME) (HEADERFILENAME) : ..\icons\qgn_prob_status_red.svg ..\icons\qgn_prob_status_green.svg
+	mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \
+		/c8,8 ..\icons\qgn_prob_status_red.svg \
+		/c8,8 ..\icons\qgn_prob_status_green.svg
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(HEADERFILENAME) && \
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/group/loadgen_icons_aif.mk	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,54 @@
+#
+# 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:  
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z
+else
+ZDIR=\epoc32\data\z
+endif
+
+TARGETDIR=$(ZDIR)\resource\apps
+ICONTARGETFILENAME=$(TARGETDIR)\loadgen_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_loadgen.svg
+	mifconv $(ICONTARGETFILENAME) \
+		/c8,8 ..\icons\qgn_menu_loadgen.svg
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/group/loadgen_stub_sis.mk	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,56 @@
+#
+# 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:  
+#
+
+
+TARGETDIR=$(EPOCROOT)EPOC32\Data\Z\System\Install
+
+SISNAME=LoadGen_stub
+PKGNAME=LoadGen_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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/icons/qgn_menu_loadgen.svg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   version="1.0"
+   width="100%"
+   height="100%"
+   viewBox="0 0 88.000488 88.000488"
+   id="svg2384">
+  <defs
+     id="defs2568" />
+  <path
+     d="M 92.562272,40.587092 C 92.562272,40.539915 92.562272,40.492737 92.562272,40.587092 z "
+     style="fill:#deaa87;fill-opacity:1;stroke:none"
+     id="path4589" />
+  <path
+     d="M 59.869601,34.19566 C 61.463087,33.186059 64.570066,32.712826 66.883961,32.335134 C 69.325288,31.936642 71.523774,31.762664 74.044456,31.762664 C 76.43802,31.762664 78.799579,34.270637 80.620419,35.340599 C 81.649767,35.945465 82.958539,39.560266 82.958539,40.77906 C 82.958539,42.460983 81.373013,43.169098 80.620419,44.643229 C 79.961438,45.933997 76.50304,47.39368 75.213515,47.934931 C 74.872539,48.078047 74.531563,48.221165 74.190587,48.364283 C 72.224802,49.189378 70.085492,49.509222 67.90689,49.509222 C 66.640408,49.509222 65.373925,49.509222 64.107444,49.509222 C 63.147628,49.509222 62.494214,49.07987 61.477059,49.07987 C 60.498073,49.07987 59.648418,48.650517 58.554408,48.650517"
+     style="fill:#806600;fill-opacity:1;stroke:none"
+     id="path4603" />
+  <path
+     d="M 58.846672,38.05983 C 58.582814,38.214879 60.464851,36.914891 62.938384,36.914891 C 64.00489,36.914891 64.952424,36.771774 66.007167,36.771774 C 66.649872,36.771774 67.235643,36.485538 68.053021,36.485538 C 68.979759,36.485538 69.831044,36.056186 70.829539,36.056186 C 71.608914,36.056186 72.388287,36.056186 73.16766,36.056186 C 74.014376,36.056186 74.853503,36.003819 75.651913,36.199304 C 76.479983,36.402051 76.745312,36.90981 77.113238,37.630478 C 77.414129,38.219843 77.52268,38.805102 77.697768,39.491003 C 77.858235,40.11963 77.843901,40.723695 77.843901,41.494648 C 77.843901,42.010665 77.202737,42.321165 76.967105,42.782704 C 76.595804,43.509985 76.038323,43.523748 75.213515,43.927643 C 74.425127,44.313704 73.799243,44.166578 73.021527,44.356995 C 72.032407,44.599174 71.384653,44.385805 70.683407,45.072582 C 69.658456,46.076387 67.941862,46.217521 66.591696,46.217521 C 65.706564,46.217521 64.737092,46.360639 63.815178,46.360639 C 63.006586,46.360639 62.208946,46.396718 61.477059,46.217521 C 60.662477,46.018078 59.762202,46.074405 58.992806,46.074405 C 58.034351,46.074405 57.835929,45.94322 57.385348,45.501935 C 57.077939,45.200869 57.239216,43.921154 57.239216,43.355174 C 57.239216,42.651785 57.259075,41.846199 57.385348,41.351529 C 57.563388,40.65406 57.384702,39.922885 57.531481,39.347886 C 57.67107,38.801049 58.246912,38.412262 58.846672,38.05983 z "
+     style="fill:#deaa87;fill-opacity:1;stroke:none"
+     id="path4605" />
+  <path
+     d="M 28.283831,32.335134 C 26.690345,31.325532 23.583365,30.8523 21.26947,30.474608 C 18.828144,30.076116 16.629658,29.902138 14.108976,29.902138 C 11.715412,29.902138 9.353853,32.410111 7.5330128,33.480073 C 6.5036648,34.084939 5.1948929,37.699739 5.1948929,38.918533 C 5.1948929,40.600456 6.7804184,41.30857 7.5330128,42.782703 C 8.1919934,44.073471 11.650392,45.533154 12.939916,46.074405 C 13.280892,46.217521 13.621868,46.360639 13.962845,46.503755 C 15.928629,47.328851 18.06794,47.648694 20.246542,47.648694 C 21.513024,47.648694 22.779506,47.648694 24.045988,47.648694 C 25.005804,47.648694 25.659217,47.219344 26.676373,47.219344 C 27.655358,47.219344 28.505014,46.789991 29.599023,46.789991"
+     style="fill:#806600;fill-opacity:1;stroke:none"
+     id="path4587" />
+  <path
+     d="M 29.306759,36.199303 C 29.570618,36.354353 27.68858,35.054365 25.215048,35.054365 C 24.148542,35.054365 23.201007,34.911247 22.146265,34.911247 C 21.503559,34.911247 20.917788,34.625012 20.10041,34.625012 C 19.173673,34.625012 18.322388,34.19566 17.323893,34.19566 C 16.544518,34.19566 15.765145,34.19566 14.985772,34.19566 C 14.139056,34.19566 13.299929,34.143293 12.501518,34.338777 C 11.673449,34.541524 11.408119,35.049282 11.040193,35.769952 C 10.739302,36.359317 10.630752,36.944575 10.455664,37.630477 C 10.295196,38.259103 10.309531,38.863169 10.309531,39.634121 C 10.309531,40.150139 10.950695,40.460637 11.186327,40.922178 C 11.557628,41.649459 12.115109,41.663222 12.939916,42.067117 C 13.728305,42.453177 14.354188,42.306052 15.131904,42.496468 C 16.121025,42.738648 16.768778,42.525279 17.470024,43.212056 C 18.494976,44.215859 20.211569,44.356995 21.561736,44.356995 C 22.446867,44.356995 23.41634,44.500113 24.338253,44.500113 C 25.146846,44.500113 25.944486,44.536192 26.676373,44.356995 C 27.490954,44.157551 28.39123,44.213878 29.160626,44.213878 C 30.119081,44.213878 30.317502,44.082693 30.768083,43.641408 C 31.075493,43.340342 30.914216,42.060628 30.914216,41.494648 C 30.914216,40.791259 30.894357,39.985673 30.768083,39.491003 C 30.590044,38.793534 30.76873,38.062358 30.621951,37.48736 C 30.482361,36.940522 29.906519,36.551735 29.306759,36.199303 z "
+     style="fill:#deaa87;fill-opacity:1;stroke:none"
+     id="path4595" />
+  <path
+     d="M 44.212275,10.58129 C 44.2345,10.603057 41.002223,9.7502562 38.220842,10.295055 C 34.550458,11.013986 31.881682,10.928739 28.576095,12.871168 C 26.740276,13.949934 25.555975,16.067552 24.630517,17.880278 C 23.686516,19.729326 22.370775,20.941694 21.707867,22.889386 C 21.150289,24.527607 20.392675,26.352057 20.392675,28.041612 C 20.392675,29.520492 20.392675,30.999371 20.392675,32.478251 C 20.392675,33.891206 21.123337,35.160307 21.123337,36.628656 C 21.123337,38.211553 23.834473,38.982567 22.730794,40.063474 C 21.819559,40.955908 20.337894,41.852417 19.515879,42.925822 C 18.07587,44.806219 17.282954,47.030553 16.885494,49.366104 C 16.42949,52.045674 14.839639,54.130522 14.839639,56.808209 C 14.839639,59.013809 14.69247,61.382896 15.131904,63.534727 C 15.609467,65.873277 17.514459,67.94023 19.515879,69.116305 C 21.509135,70.287582 23.212938,71.785399 25.361179,72.837357 C 25.750868,73.02818 26.140553,73.219004 26.53024,73.409828 C 28.496085,74.372468 30.808323,75.745337 32.960072,76.272175 C 33.349757,76.367586 33.739444,76.462998 34.129131,76.558409 C 36.704288,77.188916 38.963263,77.76633 41.58189,78.132701 C 44.262074,78.507685 46.936842,78.663031 49.619179,78.991405 C 52.186124,79.305654 55.603781,78.325754 57.948732,77.560232 C 60.307975,76.790042 62.318179,76.286403 64.086298,74.554767 C 65.79103,72.885206 67.626803,71.516662 69.347069,69.831891 C 71.609737,67.615908 72.977226,65.051402 74.607839,62.389788 C 75.589833,60.7869 74.753972,56.685268 74.753972,54.804565 C 74.753972,52.794861 74.473592,51.536148 73.584912,49.795457 C 72.718469,48.098324 71.871975,46.114219 70.516129,44.786347 C 69.392472,43.685874 67.765549,42.951226 66.716683,41.924 C 66.119702,41.339337 65.688673,40.912225 65.401489,40.349709 C 65.06473,39.690086 67.354427,37.400497 67.73961,36.771773 C 68.601292,35.365269 68.238992,30.940018 67.73961,29.472786 C 67.011887,27.334662 65.980425,25.360955 64.81696,23.461855 C 64.601372,23.109957 64.329851,22.793974 64.086298,22.460034 C 62.633818,20.468517 61.099625,18.574327 59.117792,17.021572 C 57.510912,15.762592 55.737829,14.793991 53.857022,13.872991 C 53.564756,13.729873 53.272491,13.586755 52.980226,13.443638 C 51.89167,12.910591 50.922122,12.150783 50.203708,11.869347 C 49.436956,11.568975 48.831155,11.555024 48.303985,11.296877 C 47.534861,10.92025 46.221225,10.867524 45.381335,10.867524 C 44.816725,10.867524 44.907972,10.853827 44.212275,10.58129 z "
+     style="fill:#806600;stroke:#806600;stroke-width:1.02179408"
+     id="path2594" />
+  <path
+     d="M 43.627744,23.461855 C 43.444601,23.020581 42.753719,22.140055 42.020287,21.601329 C 41.159391,20.968979 40.313262,20.288894 39.243769,20.027038 C 39.048925,19.979332 38.854082,19.931628 38.659238,19.883921 C 37.306569,19.55273 35.96343,19.311451 34.567529,19.311451 C 33.836866,19.311451 33.106203,19.311451 32.375541,19.311451 C 31.220078,19.311451 31.005557,19.365112 30.329685,20.027038 C 29.885249,20.462304 29.167519,20.586004 28.722229,21.458213 C 28.339717,22.20745 28.317984,23.008376 28.137697,23.891208 C 27.9311,24.90289 27.845433,25.987192 27.845433,27.039791 C 27.845433,28.346937 27.6993,29.579009 27.6993,30.90396 C 27.6993,31.921753 28.203232,32.448748 28.429962,33.336955 C 28.594839,33.982851 28.756585,34.978543 29.014494,35.483717 C 29.349387,36.139685 29.401555,36.957456 29.745155,37.630478 C 30.171579,38.465729 30.329685,39.043906 30.329685,39.920357 C 30.329685,41.155941 30.90055,40.076857 29.745155,41.208412 C 29.323234,41.62163 27.743563,42.320839 27.114771,42.782704 C 26.490018,43.2416 26.054675,43.928472 25.507312,44.64323 C 24.895884,45.441646 24.510308,46.309863 24.045988,47.219343 C 23.360082,48.562851 22.983175,50.016697 22.292397,51.369749 C 21.881637,52.174319 21.931541,53.212744 21.707867,54.088979 C 21.440691,55.135636 21.707867,56.585877 21.707867,57.666913 C 21.707867,59.657175 21.770313,61.530666 22.584662,63.391609 C 22.670474,63.587706 22.779505,63.773256 22.876928,63.964079 C 23.485836,65.15677 24.157466,66.407399 25.507312,67.398895 C 26.23025,67.929912 28.464255,68.872127 29.452891,69.259422 C 30.758305,69.770814 31.985095,70.296466 33.106203,71.119949 C 34.36628,72.045507 37.001085,72.486866 38.513107,72.980475 C 40.322996,73.571324 41.842542,73.775741 43.627744,74.125414 C 45.70602,74.532493 47.772786,74.697883 49.911443,74.697883 C 51.896628,74.697883 53.627389,74.628368 55.464479,74.268531 C 57.458354,73.877984 58.506167,72.557757 60.286852,72.12177 C 62.264584,71.637539 63.176162,69.721427 64.524694,68.400718 C 65.663347,67.285559 66.306551,66.63717 67.155081,65.252135 C 68.15914,63.613231 70.07773,62.806122 70.07773,60.815496 C 70.07773,59.770434 70.184863,58.659074 69.931598,57.666913 C 69.621811,56.453331 69.454251,55.18631 69.200935,53.945861 C 68.907434,52.50863 67.892522,50.663013 67.008948,49.509222 C 66.340191,48.635944 65.694813,47.649732 64.963092,46.933108 C 64.331139,46.314194 63.850473,45.557211 63.209503,44.929465 C 62.61449,44.346731 61.282493,43.9076 60.72525,43.498292 C 60.256351,43.153874 59.877458,42.667991 59.556189,42.353353 C 58.726673,41.540951 61.357059,40.875874 62.186575,40.063474 C 62.799019,39.463665 62.401919,37.788698 62.624971,36.914892 C 63.10147,35.048227 63.063369,33.302428 63.063369,31.333313 C 63.063369,29.732748 62.784098,28.359658 62.186575,26.896673 C 62.032008,26.518228 61.894309,26.133381 61.748177,25.751734 C 61.227627,24.39224 60.718004,23.01831 60.14072,21.887564 C 59.974816,21.562604 59.848454,21.219683 59.702322,20.885743 C 59.228729,19.803494 57.880003,19.156571 56.925805,18.595864 C 55.430415,17.717144 54.066297,17.307809 52.395696,17.307809 C 51.404363,17.307809 50.627488,17.243407 49.911443,17.594043 C 49.085643,17.998424 48.661324,17.582024 47.865587,18.166512 C 46.949155,18.839655 46.734143,19.787094 46.111998,20.599508 C 45.582415,21.291051 45.198022,21.637743 44.796804,22.030682 C 44.27166,22.544992 43.849292,22.593953 43.627744,23.461855 z "
+     style="fill:#deaa87;stroke:#806600;stroke-width:1.02179408"
+     id="path2598" />
+  <path
+     d="M 28.084882,56.092622 C 27.999183,56.020034 28.499334,58.973884 28.760751,59.52744 C 29.274724,60.615798 31.180968,61.5774 32.140086,62.389788 C 33.075109,63.181765 34.00683,63.795085 35.350455,64.250314 C 36.284513,64.566777 37.377917,65.287886 38.560824,65.53837 C 40.41885,65.931814 42.104276,66.826426 43.967762,66.826426 C 45.803759,66.826426 47.706322,67.112661 49.543665,67.112661 C 50.756895,67.112661 52.803761,66.018222 53.936802,65.53837 C 55.274656,64.971779 57.295056,64.226417 58.160973,63.248491 C 58.69085,62.65007 59.755702,61.924537 60.357539,61.244849 C 60.941448,60.585408 61.533935,59.819072 62.216176,59.241205 C 62.515065,58.988041 62.435117,57.354477 62.554109,56.951326 C 62.738309,56.32724 62.554109,55.451665 62.554109,54.804565 C 62.554109,53.658453 62.152438,54.4292 61.709274,54.804565 C 61.069544,55.346427 61.346291,56.415476 60.951105,57.084934 C 60.554099,57.757475 60.20877,58.491717 59.681674,59.086993 C 59.176477,59.657538 59.426063,59.786189 58.896068,60.235103 C 58.254907,60.778176 57.269144,61.448265 56.416436,61.809393 C 55.783098,62.077616 55.173285,62.53735 54.530367,62.809631 C 53.544404,63.227194 53.061487,63.348519 52.109963,63.952985 C 51.375595,64.419502 50.722542,64.382337 49.744429,64.382337 C 48.843272,64.382337 47.659051,64.806934 46.757894,64.806934 C 45.744095,64.806934 44.447229,64.240804 43.433427,64.240804 C 42.588592,64.240804 41.74376,63.957739 40.898926,63.957739 C 39.800703,63.957739 39.180675,63.224769 38.222891,62.81914 C 37.306238,62.43093 36.570701,62.119425 35.519422,61.6742 C 34.794779,61.367309 33.683204,61.519938 33.432591,61.095391 C 33.063645,60.470385 32.335877,60.046836 31.770357,59.807335 C 30.863505,59.423276 30.427799,58.229803 29.774551,57.953148 C 29.208861,57.713574 28.957945,57.118353 28.591784,56.808209 C 28.35956,56.611513 28.253851,56.331152 28.084882,56.092622 z "
+     style="fill:#784421;stroke:none"
+     id="path4558" />
+  <path
+     d="M 54.357063,39.011125 C 54.357063,41.3525 52.622178,43.252746 50.484551,43.252746 C 48.346925,43.252746 46.61204,41.3525 46.61204,39.011125 C 46.61204,36.669751 48.346925,34.769506 50.484551,34.769506 C 52.622178,34.769506 54.357063,36.669751 54.357063,39.011125 z "
+     style="fill:#050607;fill-opacity:1;stroke:#07040b;stroke-width:1.06075895;stroke-opacity:1"
+     id="path6786" />
+  <path
+     d="M 43.218553,39.030234 C 43.218553,41.371608 41.483668,43.271854 39.346042,43.271854 C 37.208415,43.271854 35.47353,41.371608 35.47353,39.030234 C 35.47353,36.688859 37.208415,34.788615 39.346042,34.788615 C 41.483668,34.788615 43.218553,36.688859 43.218553,39.030234 z "
+     style="fill:#050607;fill-opacity:1;stroke:#07040b;stroke-width:1.06075895;stroke-opacity:1"
+     id="path7845" />
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/icons/qgn_prob_status_green.svg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg baseProfile="tiny" height="100%" preserveAspectRatio="xMidYMid meet" version="1.0" viewBox="0 0 100 100" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" zoomAndPan="magnify">
+<switch>
+<foreignObject content="structured text" height="1" requiredExtensions="http://ns.adobe.com/AdobeIllustrator/10.0/" width="1" x="0" y="0"/>
+<g>
+<g>
+<rect fill="none" height="100" width="100"/>
+<radialGradient cx="-213.9155" cy="624.8184" fx="-213.9155" fy="624.8184" gradientTransform="matrix(6.0623 0 0 -6.0623 1346.8223 3837.8408)" gradientUnits="userSpaceOnUse" id="XMLID_40_" r="8.2473">
+<stop offset="0" style="stop-color:#4FFF9B"/>
+<stop offset="1" style="stop-color:#00FF7C"/>
+</radialGradient>
+<circle cx="50" cy="50" fill="url(#XMLID_40_)" r="50"/>
+<radialGradient cx="25.0381" cy="16.4775" fx="25.0381" fy="16.4775" gradientUnits="userSpaceOnUse" id="XMLID_41_" r="18.1317">
+<stop offset="0" style="stop-color:#00FF7C"/>
+<stop offset="1" style="stop-color:#00C024"/>
+</radialGradient>
+<path d="M7.969,31.954c7.5-1.246,28.746-10.007,35-15.623c6.254-5.615-0.977-14.661-2.223-15.277       c-0.685-0.346-5.923,1.039-10.992,3.277c-4.215,1.862-8.277,4.462-9.908,5.754c-1.423,1.108-4.062,3.285-6.346,5.808       c-3.508,3.846-6.408,7.885-6.723,8.5c-0.308,0.639-2.185,4.577-2.185,4.577s0.969,1.877,1.5,2.369       C6.623,31.823,7.969,31.954,7.969,31.954z" fill="url(#XMLID_41_)"/>
+<radialGradient cx="-243.0728" cy="466.7393" fx="-243.0728" fy="466.7393" gradientTransform="matrix(7.6923 0 0 -7.6923 1911.5386 3618.3823)" gradientUnits="userSpaceOnUse" id="XMLID_42_" r="4.2652">
+<stop offset="0" style="stop-color:#00FF7C"/>
+<stop offset="1" style="stop-color:#00C024"/>
+</radialGradient>
+<path d="M52.723,99.877c0,0-0.754-14.877-6.376-16.754c-5.631-1.877-15.631,0.631-20.008-7.5       C21.969,67.5,27.385,59.777,33.746,55c2.5-1.877,11.323-2.1,13.846-1.246C51.254,55,52.861,56.746,55,57.5       c1.785,0.631,5.823,1.2,9.377,0c1.877-0.615,5-1.861,5-4.984c0-1.531-1.646-4.4-4.377-5c-5.623-1.246-5.293,5.616-8.123,5       c-3.154-0.692-9.1-6.254-10.631-6.254c-4.369,0-5.623,6.254-8.746,6.254S33.523,50.8,33.123,50       C32.5,48.754,33.746,46.262,35,45c0.623-0.615,3.246-0.361,3.746-2.492c0.554-2.393-0.077-7.454,0.623-8.746       C43.123,26.877,48.746,22.508,55.092,20c5.361-2.1,10,1.262,10-1.861c0-3.124-6.877-10.008-5.631-13.77       c1.254-3.738,22.785,8.308,25.285,10.815c2.5,2.492,9.454,11.162,10.238,12.8c0.785,1.654,3.516,8.446,4.216,13.446       c0.708,5-1.5,15.731-3.485,16.062c-1.984,0.346-3.746-4.984-5.623-5.615c-9.576-3.185-3.776,4.369-4.377,10.623       C85,70.016,77.5,82.5,75.623,86.254c-1.685,3.354-2.984,8.23-2.984,8.23s-3.746,2.416-10.547,3.984       C56.861,99.793,52.723,99.877,52.723,99.877z" fill="url(#XMLID_42_)"/>
+</g>
+</g>
+</switch>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/icons/qgn_prob_status_red.svg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg baseProfile="tiny" height="100%" preserveAspectRatio="xMidYMid meet" version="1.0" viewBox="0 0 100 100" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" zoomAndPan="magnify">
+<switch>
+<foreignObject content="structured text" height="1" requiredExtensions="http://ns.adobe.com/AdobeIllustrator/10.0/" width="1" x="0" y="0"/>
+<g>
+<g>
+<rect fill="none" height="100" width="100"/>
+<radialGradient cx="-213.9155" cy="624.8184" fx="-213.9155" fy="624.8184" gradientTransform="matrix(6.0623 0 0 -6.0623 1346.8223 3837.8408)" gradientUnits="userSpaceOnUse" id="XMLID_40_" r="8.2473">
+<stop offset="0" style="stop-color:#FF799B"/>
+<stop offset="1" style="stop-color:#FF437C"/>
+</radialGradient>
+<circle cx="50" cy="50" fill="url(#XMLID_40_)" r="50"/>
+<radialGradient cx="25.0381" cy="16.4775" fx="25.0381" fy="16.4775" gradientUnits="userSpaceOnUse" id="XMLID_41_" r="18.1317">
+<stop offset="0" style="stop-color:#FF437C"/>
+<stop offset="1" style="stop-color:#FF0232"/>
+</radialGradient>
+<path d="M7.969,31.954c7.5-1.246,28.746-10.007,35-15.623c6.254-5.615-0.977-14.661-2.223-15.277       c-0.685-0.346-5.923,1.039-10.992,3.277c-4.215,1.862-8.277,4.462-9.908,5.754c-1.423,1.108-4.062,3.285-6.346,5.808       c-3.508,3.846-6.408,7.885-6.723,8.5c-0.308,0.639-2.185,4.577-2.185,4.577s0.969,1.877,1.5,2.369       C6.623,31.823,7.969,31.954,7.969,31.954z" fill="url(#XMLID_41_)"/>
+<radialGradient cx="-243.0728" cy="466.7393" fx="-243.0728" fy="466.7393" gradientTransform="matrix(7.6923 0 0 -7.6923 1911.5386 3618.3823)" gradientUnits="userSpaceOnUse" id="XMLID_42_" r="4.2652">
+<stop offset="0" style="stop-color:#FF437C"/>
+<stop offset="1" style="stop-color:#FF0232"/>
+</radialGradient>
+<path d="M52.723,99.877c0,0-0.754-14.877-6.376-16.754c-5.631-1.877-15.631,0.631-20.008-7.5       C21.969,67.5,27.385,59.777,33.746,55c2.5-1.877,11.323-2.1,13.846-1.246C51.254,55,52.861,56.746,55,57.5       c1.785,0.631,5.823,1.2,9.377,0c1.877-0.615,5-1.861,5-4.984c0-1.531-1.646-4.4-4.377-5c-5.623-1.246-5.293,5.616-8.123,5       c-3.154-0.692-9.1-6.254-10.631-6.254c-4.369,0-5.623,6.254-8.746,6.254S33.523,50.8,33.123,50       C32.5,48.754,33.746,46.262,35,45c0.623-0.615,3.246-0.361,3.746-2.492c0.554-2.393-0.077-7.454,0.623-8.746       C43.123,26.877,48.746,22.508,55.092,20c5.361-2.1,10,1.262,10-1.861c0-3.124-6.877-10.008-5.631-13.77       c1.254-3.738,22.785,8.308,25.285,10.815c2.5,2.492,9.454,11.162,10.238,12.8c0.785,1.654,3.516,8.446,4.216,13.446       c0.708,5-1.5,15.731-3.485,16.062c-1.984,0.346-3.746-4.984-5.623-5.615c-9.576-3.185-3.776,4.369-4.377,10.623       C85,70.016,77.5,82.5,75.623,86.254c-1.685,3.354-2.984,8.23-2.984,8.23s-3.746,2.416-10.547,3.984       C56.861,99.793,52.723,99.877,52.723,99.877z" fill="url(#XMLID_42_)"/>
+</g>
+</g>
+</switch>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/inc/loadgen.hrh	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,190 @@
+/*
+* 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 LOADGEN_HRH
+#define LOADGEN_HRH
+
+enum TLoadGenCommandIds
+    {
+    ELoadGenCmdNewLoad,    
+    ELoadGenCmdNewLoadCPULoad,    
+    ELoadGenCmdNewLoadEatMemory,    
+    ELoadGenCmdNewLoadPhoneCall,    
+    ELoadGenCmdNewLoadNetConn,    
+    ELoadGenCmdNewLoadKeyPress,    
+    ELoadGenCmdNewLoadMessages,
+    ELoadGenCmdNewLoadApplications,
+    ELoadGenCmdNewLoadPhotoCaptures,
+    ELoadGenCmdNewLoadBluetooth,
+    ELoadGenCmdNewLoadPointerEvent,
+    ELoadGenStopAll,
+    ELoadGenSuspendAll,
+    ELoadGenResumeAll,
+
+    ELoadGenCmdLaunchPerfMon,
+    ELoadGenCmdAbout,
+
+    ELoadGenCmdSettingsChange,
+    ELoadGenCmdSettingsExit,
+    ELoadGenCmdSettingsBack,
+
+    ELoadGenSettingItemList
+    };
+
+enum TEditorFormItemIds
+    {
+    ELoadGenCPULoadQueryPriority = 1000,
+    ELoadGenCPULoadQueryMode,
+    ELoadGenCPULoadQueryType,
+    ELoadGenCPULoadQueryLength,
+    ELoadGenCPULoadQueryIdle,
+    ELoadGenCPULoadQueryVariance,
+    ELoadGenCPULoadQueryCpu,
+
+    ELoadGenMemoryEatQueryPriority,
+    ELoadGenMemoryEatQuerySource,
+    ELoadGenMemoryEatQueryType,
+    ELoadGenMemoryEatQueryBuffer,
+    ELoadGenMemoryEatQueryIdle,
+    ELoadGenMemoryEatQueryAmount,
+    ELoadGenMemoryEatQueryRandomMin,
+    ELoadGenMemoryEatQueryRandomMax,
+    ELoadGenMemoryEatQueryVariance,
+    
+    ELoadGenPhoneCallQueryPriority,
+    ELoadGenPhoneCallQueryDestination,
+    ELoadGenPhoneCallQueryLength,
+    ELoadGenPhoneCallQueryIdle,
+    ELoadGenPhoneCallQueryVariance,
+    
+    ELoadGenNetConnQueryPriority,
+    ELoadGenNetConnQueryDestination,
+    ELoadGenNetConnQueryIdle,
+    ELoadGenNetConnQueryVariance,
+   
+    ELoadGenKeyPressQueryPriority,
+    ELoadGenKeyPressQueryHeartBeat,
+    ELoadGenKeyPressQueryVariance,
+        
+    ELoadGenMessagesQueryPriority,        
+    ELoadGenMessagesQueryType,            // Message type
+    ELoadGenMessagesQueryDestination,     // Phone number
+    ELoadGenMessagesQueryAmount,          // Messages
+    ELoadGenMessagesQueryLength,          // Message length
+    ELoadGenMessagesQueryMessage,         // Message
+    ELoadGenMessagesQueryIdle,            // idle period 
+    ELoadGenMessagesQueryVariance,
+
+    ELoadGenApplicationsQueryPriority,
+    ELoadGenApplicationsLaunchingInterval,
+    ELoadGenApplicationsKeyPressQueryHeartBeat,
+    ELoadGenApplicationsMaxOpen,
+    ELoadGenApplicationsKeyPressType,
+    ELoadGenApplicationsQueryVariance,
+    
+    ELoadGenPhotoCaptureQueryPriority,
+    ELoadGenPhotoCaptureQueryDevice,    
+    ELoadGenPhotoCaptureQueryIdle,
+    ELoadGenPhotoCaptureQueryVariance,
+           
+    ELoadGenBluetoothQueryPriority,
+    ELoadGenBluetoothQueryIdle,
+    ELoadGenBluetoothQueryVariance,
+    
+    ELoadGenPointerEventQueryPriority,
+    ELoadGenPointerEventQueryHeartBeat,
+    ELoadGenPointerEventQueryVariance
+    };
+
+enum TItemActionMenuTypes
+    {
+    EItemActionMenuTypeStop = 0,
+    EItemActionMenuTypeSuspendResume,    
+    EItemActionMenuTypeEdit    
+    };
+
+enum TThreadPriorityTypes
+    {
+    EThreadPriorityTypeMuchLess = 0,    
+    EThreadPriorityTypeLess,    
+    EThreadPriorityTypeNormal,    
+    EThreadPriorityTypeMore,    
+    EThreadPriorityTypeMuchMore,    
+    EThreadPriorityTypeRealTime,    
+    EThreadPriorityTypeAbsoluteVeryLow,    
+    EThreadPriorityTypeAbsoluteLow,    
+    EThreadPriorityTypeAbsoluteBackground,    
+    EThreadPriorityTypeAbsoluteForeground,    
+    EThreadPriorityTypeAbsoluteHigh
+    };
+
+enum TCpuLoadMode
+    {
+    ECpuLoadModeYielding = 0,
+    ECpuLoadModeBlocking    
+    };
+                    
+enum TCpuLoadTypes
+    {
+    ECpuLoadTypeContinuous = 0,
+    ECpuLoadTypePeriodic    
+    };
+
+enum TMemoryEatTypes
+    {
+    EMemoryEatTypeMemoryToEat = 0,
+    EMemoryEatTypeMemoryToBeLeft,
+    EMemoryEatTypeWavy
+    };        
+
+enum TMemoryEatSourceTypes
+    {
+    EMemoryEatSourceTypeRAM = 0,
+    EMemoryEatSourceTypeDriveC,
+    EMemoryEatSourceTypeDriveD,
+    EMemoryEatSourceTypeDriveE,
+    EMemoryEatSourceTypeDriveF,
+    EMemoryEatSourceTypeDriveG,
+    EMemoryEatSourceTypeDriveH,
+    EMemoryEatSourceTypeDriveI,
+    EMemoryEatSourceTypeDriveJ,
+    EMemoryEatSourceTypeDriveK,
+    EMemoryEatSourceTypeDriveL,
+    EMemoryEatSourceTypeDriveM,
+    EMemoryEatSourceTypeDriveN
+    };
+
+enum TMessageTypes
+    {
+    EMessageTypeSMS = 0,
+    EMessageTypeMMS
+    };      
+
+enum TApplicationsKeyPressTypes
+    {
+    EApplicationsKeyPressTypeNone = 0,
+    EApplicationsKeyPressTypeArrows
+    };      
+
+enum TApplicationsEventTypes
+    {
+    EApplicationsCloseApplication = 0,
+    EApplicationsLaunchApplication
+    };      
+
+#endif      // LOADGEN_HRH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/inc/loadgen_app.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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 LOADGEN_APP_H
+#define LOADGEN_APP_H
+
+
+// INCLUDES
+#include <aknapp.h>
+
+// CONSTANTS
+// UID of the application
+const TUid KUidLoadGen = { 0x20011384 };
+
+// CLASS DECLARATION
+
+/**
+* CLoadGenApp application class.
+* Provides factory to create concrete document object.
+* 
+*/
+class CLoadGenApp : 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 CLoadGenDocument document object.
+        * @return A pointer to the created document object.
+        */
+        CApaDocument* CreateDocumentL();
+        
+        /**
+        * From CApaApplication, returns application's UID (KUidLoadGen).
+        * @return The value of KUidLoadGen.
+        */
+        TUid AppDllUid() const;
+    };
+
+#endif
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/inc/loadgen_applications.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,194 @@
+/*
+* 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 LOADGEN_APPLICATIONS_H
+#define LOADGEN_APPLICATIONS_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <w32std.h>
+
+#include "loadgen_loadbase.h"
+#include "loadgen_loadattributes.h"
+
+
+// FORWARD DECLARATIONS
+class CLauncherEngine;
+
+// CLASS DECLARATIONS
+
+class CAppLauncher : public CLoadBase
+    {
+public:
+    static CAppLauncher* NewL( TApplicationsAttributes& aAttributes,
+                                TInt aReferenceNumber );
+    virtual ~CAppLauncher();
+        
+private: // Constructors
+    CAppLauncher( TApplicationsAttributes& aAttributes, 
+                    TInt aReferenceNumber );
+    void ConstructL();  
+
+public:  // New methods
+    virtual void Resume();
+    virtual void Suspend();
+    virtual void SetPriority();
+    virtual void Close();
+    virtual TPtrC Description();
+    inline TApplicationsAttributes& Attributes() { return iAttributes; }
+
+public:  // New static methods
+    static TInt ThreadFunction( TAny* aThreadArg );
+
+private:  // New static methods
+    static void GenerateLoad( TApplicationsAttributes& aAttributes );
+
+private: // Data
+    TApplicationsAttributes         iAttributes;    
+    RThread                         iThread;
+    };
+
+// Class to start launching applications in given period 
+
+// CLASS DECLARATIONS
+class CAppLauncherManager : public CActive
+    {
+public:
+    static CAppLauncherManager* NewL( TApplicationsAttributes& aAttributes );
+    ~CAppLauncherManager();
+
+private:
+    CAppLauncherManager( TApplicationsAttributes& aAttributes );
+    void ConstructL();
+
+private:
+    void RunL();
+    void DoCancel();
+
+private:
+    static TInt PeriodicTimerCallBack( TAny* aAny );
+    void SimulateEventL();
+
+public:
+    inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; }
+
+private:
+    TApplicationsAttributes&    iAttributes;    
+    CPeriodic*                  iPeriodicTimer;
+    RWsSession                  iWsSession;
+    CLauncherEngine*            iLauncherEngine;
+    TInt                        iAppEventType;
+    }; 
+
+// A class where applicationg launching and ending is implemented 
+#include <aknappui.h>
+#include <apgcli.h>
+
+// FORWARD DECLARATIONS
+class CAppKeyPressManager;
+
+// CLASS DECLARATIONS
+class CLauncherEngine : public CBase
+    {
+public:
+    static CLauncherEngine* NewL( TApplicationsAttributes& aAttributes );
+    ~CLauncherEngine();
+
+public:
+    void StartAppLaunchingL();
+    void StopApplication( TBool aRandomApplication );
+    
+    
+private:
+    CLauncherEngine( TApplicationsAttributes& aAttributes );
+    void ConstructL();
+    TBool LaunchApplicationL();
+    void DoLaunchApplicationL();
+
+public:    
+    inline TInt AppLaunchCounter() { return iAppLaunchCounter; }
+    
+private:
+    RTimer          iTimer;
+    RApaLsSession   iLs;
+    RWsSession      iWs;
+    TInt            iAppLaunchCounter;
+    TUid            iCurrentAppUid;
+    TThreadId       iCurrentAppThreadId;
+    TBuf<128>       iCurrentAppNameAndExt;
+    RThread         iCurrentAppThread;
+    TInt            iParallelApplicationsCounter;
+    TApplicationsAttributes&    iAttributes;
+
+    CAppKeyPressManager* iAppKeyPressManager;
+    };
+
+
+// A class where key presses can be added to application
+#include <e32cmn.h>
+// FORWARD DECLARATIONS
+class CApplicationKeyPresses;
+// CLASS DECLARATIONS
+class CAppKeyPressManager : public CBase
+    {
+public:
+    static CAppKeyPressManager* NewL( TApplicationsAttributes& aAttributes );
+    ~CAppKeyPressManager();
+    void AddNewApplicationUidToKeyEventsL( TUid aUid );
+    TUid KillApplication( TBool aRandomApplication );
+    
+private:
+    CAppKeyPressManager( TApplicationsAttributes& aAttributes );
+    void ConstructL();
+
+private:
+    RPointerArray<CApplicationKeyPresses> iKeyPresses;
+    TApplicationsAttributes& iAttributes;    
+    }; 
+
+// A class which sends key press events to application
+// CLASS DECLARATIONS
+class CApplicationKeyPresses : public CBase
+    {
+public:
+    static CApplicationKeyPresses* NewL( TUid aUid, 
+                                            TApplicationsAttributes& aAttributes );
+    ~CApplicationKeyPresses();
+    
+private:
+    CApplicationKeyPresses( TUid aUid, TApplicationsAttributes& aAttributes );
+    void ConstructL();
+
+private:
+    static TInt PeriodicTimerCallBack( TAny* aAny );
+    void SimulateKeyEvent();
+
+public:
+    inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; }
+
+private:
+    TUid                        iUid;
+    TApplicationsAttributes&    iAttributes;
+    CPeriodic*                  iPeriodicTimer;
+    RWsSession                  iWsSession;
+public:
+    inline TUid ApplicationUid() { return iUid; };    
+    }; 
+
+#endif // LOADGEN_APPLICATIONS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/inc/loadgen_appui.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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 LOADGEN_APPUI_H
+#define LOADGEN_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 "loadgen_std.h"
+
+// FORWARD DECLARATIONS
+class CLoadGenModel;
+class CAknNavigationControlContainer;
+class CAknTabGroup;
+class CAknNavigationDecorator;
+
+
+// CLASS DECLARATIONS
+
+class CLoadGenAppUi : public CAknViewAppUi
+    {
+public: // constructors and destructor
+    void ConstructL();
+    ~CLoadGenAppUi();
+    
+private: // From MEikMenuObserver
+    void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
+
+private:
+    void HandleCommandL(TInt aCommand);
+
+    virtual TKeyResponse HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
+
+private: //Data
+    CLoadGenModel*                  iModel;
+    CAknNavigationControlContainer* iNaviPane;
+    CAknTabGroup*                   iTabGroup;
+    CAknNavigationDecorator*        iDecoratedTabGroup;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/inc/loadgen_bluetooth.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,106 @@
+/*
+* 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 LOADGEN_BLUETOOTH_H
+#define LOADGEN_BLUETOOTH_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <centralrepository.h>
+#include "loadgen_loadbase.h"
+#include "loadgen_loadattributes.h"
+#include <es_sock.h>
+#include <bt_sock.h>
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATIONS
+
+class CBluetooth : public CLoadBase
+    {
+public:
+    static CBluetooth* NewL(TBluetoothAttributes& aAttributes, TInt aReferenceNumber);
+    virtual ~CBluetooth();
+        
+private: // Constructors
+    CBluetooth(TBluetoothAttributes& aAttributes, TInt aReferenceNumber);
+    void ConstructL();  
+
+public:  // New methods
+    virtual void Resume();
+    virtual void Suspend();
+    virtual void SetPriority();
+    virtual void Close();
+    virtual TPtrC Description();
+    inline TBluetoothAttributes& Attributes() { return iAttributes; }
+    
+public:  // New static methods
+    static TInt ThreadFunction(TAny* aThreadArg);
+    
+private:  // New static methods
+    static void GenerateLoad(TBluetoothAttributes& aAttributes);    
+    void InitializeBluetoothL();
+    TBool SetBTPowerState(TBool aState);
+    
+private: // Data
+           
+    TBluetoothAttributes    iAttributes;    
+    RThread                 iThread; 
+    };
+ 
+
+
+ 
+class CBTManager : public CActive//, public MBTPowerManagerObserver
+    {
+    public:
+        
+        static CBTManager* NewL(TBluetoothAttributes& aAttrs);
+        virtual ~CBTManager();
+ 
+    private:
+        
+        CBTManager( TBluetoothAttributes& aAttrs);
+        void ConstructL();
+        TInt StartBTDeviceDiscovery();
+ 
+    private:
+            
+        static TInt PeriodicTimerCallBack(TAny* aAny);        
+    public:
+                                                        
+        /**
+         * From CActive:
+         */
+        void RunL();
+        void DoCancel();       
+
+    private:
+        
+        CPeriodic*              iPeriodicTimer;
+        TBluetoothAttributes&   iAttributes;  
+        CRepository*            iBTPowerStateCRepo;
+        RSocketServ             iSocketServerHnd;
+        RHostResolver           iHostResolver;        
+        TNameEntry              iBTNameEntry;        
+    };
+
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/inc/loadgen_cpuload.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,67 @@
+/*
+* 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 LOADGEN_CPULOAD_H
+#define LOADGEN_CPULOAD_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+
+#include "loadgen_loadbase.h"
+#include "loadgen_loadattributes.h"
+
+
+// FORWARD DECLARATIONS
+
+
+
+// CLASS DECLARATIONS
+
+class CCPULoad : public CLoadBase
+    {
+public:
+    static CCPULoad* NewL(TCPULoadAttributes& aAttributes, TInt aReferenceNumber);
+    virtual ~CCPULoad();
+        
+private: // Constructors
+    CCPULoad(TCPULoadAttributes& aAttributes, TInt aReferenceNumber);
+    void ConstructL();  
+
+public:  // New methods
+    virtual void Resume();
+    virtual void Suspend();
+    virtual void SetPriority();
+    virtual void Close();
+    virtual TPtrC Description();
+    inline TCPULoadAttributes& Attributes() { return iAttributes; }
+
+public:  // New static methods
+    static TInt ThreadFunction(TAny* aThreadArg);
+
+private:  // New static methods
+    static void GenerateLoad(TCPULoadAttributes& aAttributes);
+    static void DoHeaveStuff(TInt aMode);
+
+private: // Data
+    TCPULoadAttributes      iAttributes;    
+    RThread                 iThread;
+    };
+ 
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/inc/loadgen_document.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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 LOADGEN_DOCUMENT_H
+#define LOADGEN_DOCUMENT_H
+
+// INCLUDES
+#include <akndoc.h>
+   
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class CEikAppUi;
+class CLoadGenModel;
+
+
+// CLASS DECLARATION
+
+/**
+*  CLoadGenDocument application class.
+*/
+class CLoadGenDocument : public CAknDocument
+    {
+    public: // Constructors and destructor
+        static CLoadGenDocument* NewL(CEikApplication& aApp);
+        virtual ~CLoadGenDocument();
+
+    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.
+        */
+        CLoadGenDocument(CEikApplication& aApp);
+        void ConstructL();
+
+    private:
+
+        /**
+        * From CEikDocument, create CLoadGenAppUi "App UI" object.
+        */
+        CEikAppUi* CreateAppUiL();
+
+    public:
+        inline CLoadGenModel* Model() { return iModel; }
+
+    private:
+        CLoadGenModel* iModel;
+
+    };
+
+#endif
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/inc/loadgen_editors.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,339 @@
+/*
+* 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 LOADGEN_EDITORS_H
+#define LOADGEN_EDITORS_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <aknform.h> 
+
+#include "loadgen_loadattributes.h"
+
+
+// FORWARD DECLARATIONS
+class CAknQueryValueText;
+class CAknQueryValueTextArray;
+
+// CLASS DECLARATIONS
+
+class CLoadGenLoadTypeEditorBase : public CAknForm
+    {
+protected: // Constructors
+    CLoadGenLoadTypeEditorBase(TBool aEditingExisting);
+    void ConstructL(const TDesC& aTitleText);        
+
+protected:  // From CEikDialog
+    TBool OkToExitL(TInt aButtonId);    
+    void PreLayoutDynInitL();
+    void HandleControlStateChangeL(TInt aControlId);
+
+protected:  // New methods
+    virtual TBool DoRunQueryLD(TInt aResource);
+    
+public:  // New methods
+    virtual TBool RunQueryLD();
+
+protected:  // New methods
+    void InsertFieldAfterL(TInt aResourceId, TInt aControlId, TInt aPrevControlId);
+    void UpdateFormL();
+
+protected: // Data
+    TBool iEditingExisting;
+    };
+
+
+
+
+class CLoadGenCPULoadEditor : public CLoadGenLoadTypeEditorBase
+    {
+public:
+    static CLoadGenCPULoadEditor* NewL(TCPULoadAttributes& aAttributes, TBool aEditingExisting=EFalse);
+    virtual ~CLoadGenCPULoadEditor();
+
+private: // Constructors
+    CLoadGenCPULoadEditor(TCPULoadAttributes& aAttributes, TBool aEditingExisting=EFalse);
+    void ConstructL();        
+
+protected:  // From CEikDialog
+    TBool OkToExitL(TInt aButtonId);    
+    void PreLayoutDynInitL();
+    void HandleControlStateChangeL(TInt aControlId);
+        
+public:  // New methods
+    virtual TBool RunQueryLD();
+
+private:  // New methods
+    void UpdateVisibilitiesOfFieldsL(TBool aFormInit=EFalse);
+    void LoadCPUsL();
+    
+private: // Data
+    TCPULoadAttributes&         iAttributes;
+    CAknQueryValueText*         iCpuQueryValText;
+    CAknQueryValueTextArray*    iCpuTextArray;
+    CDesCArray*                 iCPUsArray;
+    };
+
+
+
+
+class CLoadGenMemoryEatEditor : public CLoadGenLoadTypeEditorBase
+    {
+public:
+    static CLoadGenMemoryEatEditor* NewL(TMemoryEatAttributes& aAttributes, TBool aEditingExisting=EFalse);
+    virtual ~CLoadGenMemoryEatEditor();
+
+private: // Constructors
+    CLoadGenMemoryEatEditor(TMemoryEatAttributes& aAttributes, TBool aEditingExisting=EFalse);
+    void ConstructL();        
+
+protected:  // From CEikDialog
+    TBool OkToExitL(TInt aButtonId);    
+    void PreLayoutDynInitL();
+    void HandleControlStateChangeL(TInt aControlId);
+        
+public:  // New methods
+    virtual TBool RunQueryLD();
+
+private:  // New methods
+    void UpdateVisibilitiesOfFieldsL(TBool aFormInit=EFalse);
+    void UpdateAvailableMemoryL();
+
+private: // Data
+    TMemoryEatAttributes&              iAttributes;
+    }; 
+
+
+
+class CLoadGenPhoneCallEditor : public CLoadGenLoadTypeEditorBase
+    {
+public:
+    static CLoadGenPhoneCallEditor* NewL(TPhoneCallAttributes& aAttributes, TBool aEditingExisting=EFalse);
+    virtual ~CLoadGenPhoneCallEditor();
+
+private: // Constructors
+    CLoadGenPhoneCallEditor(TPhoneCallAttributes& aAttributes, TBool aEditingExisting=EFalse);
+    void ConstructL();        
+
+protected:  // From CEikDialog
+    TBool OkToExitL(TInt aButtonId);    
+    void PreLayoutDynInitL();
+    void HandleControlStateChangeL(TInt aControlId);
+        
+public:  // New methods
+    virtual TBool RunQueryLD();
+
+private:  // New methods
+    void UpdateVisibilitiesOfFieldsL(TBool aFormInit=EFalse);
+    
+private: // Data
+    TPhoneCallAttributes&              iAttributes;
+    };
+
+
+
+class CLoadGenNetConnEditor : public CLoadGenLoadTypeEditorBase
+    {
+public:
+    static CLoadGenNetConnEditor* NewL(TNetConnAttributes& aAttributes, TBool aEditingExisting=EFalse);
+    virtual ~CLoadGenNetConnEditor();
+
+private: // Constructors
+    CLoadGenNetConnEditor(TNetConnAttributes& aAttributes, TBool aEditingExisting=EFalse);
+    void ConstructL();        
+
+protected:  // From CEikDialog
+    TBool OkToExitL(TInt aButtonId);    
+    void PreLayoutDynInitL();
+    void HandleControlStateChangeL(TInt aControlId);
+        
+public:  // New methods
+    virtual TBool RunQueryLD();
+
+private:  // New methods
+    void UpdateVisibilitiesOfFieldsL(TBool aFormInit=EFalse);
+    
+private: // Data
+    TNetConnAttributes&              iAttributes;
+    };
+    
+ 
+ 
+
+class CLoadGenKeyPressEditor : public CLoadGenLoadTypeEditorBase
+    {
+public:
+    static CLoadGenKeyPressEditor* NewL(TKeyPressAttributes& aAttributes, TBool aEditingExisting=EFalse);
+    virtual ~CLoadGenKeyPressEditor();
+
+private: // Constructors
+    CLoadGenKeyPressEditor(TKeyPressAttributes& aAttributes, TBool aEditingExisting=EFalse);
+    void ConstructL();        
+
+protected:  // From CEikDialog
+    TBool OkToExitL(TInt aButtonId);    
+    void PreLayoutDynInitL();
+    void HandleControlStateChangeL(TInt aControlId);
+        
+public:  // New methods
+    virtual TBool RunQueryLD();
+
+private:  // New methods
+    void UpdateVisibilitiesOfFieldsL(TBool aFormInit=EFalse);
+    
+private: // Data
+    TKeyPressAttributes&              iAttributes;
+    };
+
+class CLoadGenPointerEventEditor : public CLoadGenLoadTypeEditorBase
+    {
+public:
+    static CLoadGenPointerEventEditor* NewL(TPointerEventAttributes& aAttributes, TBool aEditingExisting=EFalse);
+    virtual ~CLoadGenPointerEventEditor();
+
+private: // Constructors
+    CLoadGenPointerEventEditor(TPointerEventAttributes& aAttributes, TBool aEditingExisting=EFalse);
+    void ConstructL();        
+
+protected:  // From CEikDialog
+    TBool OkToExitL(TInt aButtonId);    
+    void PreLayoutDynInitL();
+    void HandleControlStateChangeL(TInt aControlId);
+        
+public:  // New methods
+    virtual TBool RunQueryLD();
+
+private:  // New methods
+    void UpdateVisibilitiesOfFieldsL(TBool aFormInit=EFalse);
+    
+private: // Data
+    TPointerEventAttributes&              iAttributes;
+    };
+
+
+
+class CLoadGenMessagesEditor : public CLoadGenLoadTypeEditorBase
+    {
+public:
+    static CLoadGenMessagesEditor* NewL( TMessageAttributes& aAttributes, 
+                                         TBool aEditingExisting = EFalse );
+    virtual ~CLoadGenMessagesEditor();
+
+private: // Constructors
+    CLoadGenMessagesEditor( TMessageAttributes& aAttributes, 
+                            TBool aEditingExisting = EFalse );
+    void ConstructL();        
+
+protected:  // From CEikDialog
+    TBool OkToExitL( TInt aButtonId );    
+    void PreLayoutDynInitL();
+    void HandleControlStateChangeL( TInt aControlId );
+        
+public:  // New methods
+    virtual TBool RunQueryLD();
+
+private:  // New methods
+    void UpdateVisibilitiesOfFieldsL( TBool aFormInit = EFalse );
+    
+private: // Data
+    TMessageAttributes&              iAttributes;
+    };
+
+class CLoadGenApplicationsEditor : public CLoadGenLoadTypeEditorBase
+    {
+public:
+    static CLoadGenApplicationsEditor* NewL( TApplicationsAttributes& aAttributes, 
+                                         TBool aEditingExisting = EFalse );
+    virtual ~CLoadGenApplicationsEditor();
+
+private: // Constructors
+    CLoadGenApplicationsEditor( TApplicationsAttributes& aAttributes, 
+                            TBool aEditingExisting = EFalse );
+    void ConstructL();        
+
+protected:  // From CEikDialog
+    TBool OkToExitL( TInt aButtonId );    
+    void PreLayoutDynInitL();
+    void HandleControlStateChangeL( TInt aControlId );
+        
+public:  // New methods
+    virtual TBool RunQueryLD();
+
+private:  // New methods
+    void UpdateVisibilitiesOfFieldsL( TBool aFormInit = EFalse );
+    
+private: // Data
+    TApplicationsAttributes&              iAttributes;
+    };
+
+class CLoadGenPhotoCaptureEditor : public CLoadGenLoadTypeEditorBase
+    {
+public:
+    static CLoadGenPhotoCaptureEditor* NewL(TPhotoCaptureAttributes& aAttributes, TBool aEditingExisting=EFalse);
+    virtual ~CLoadGenPhotoCaptureEditor();
+
+private: // Constructors
+    CLoadGenPhotoCaptureEditor(TPhotoCaptureAttributes& aAttributes, TBool aEditingExisting=EFalse);
+    void ConstructL();        
+
+protected:  // From CEikDialog
+    TBool OkToExitL(TInt aButtonId);    
+    void PreLayoutDynInitL();
+    void HandleControlStateChangeL(TInt aControlId);
+        
+public:  // New methods
+    virtual TBool RunQueryLD();
+
+private:  // New methods
+    void UpdateVisibilitiesOfFieldsL(TBool aFormInit=EFalse);
+    void LoadCamerasL();
+    
+private: // Data
+    TPhotoCaptureAttributes&    iAttributes;
+    CAknQueryValueText*         iCameraQueryValText;
+    CAknQueryValueTextArray*    iCameraTextArray;
+    CDesCArray*                 iCamerasArray;
+    };
+
+class CLoadGenBluetoothEditor : public CLoadGenLoadTypeEditorBase
+    {
+public:
+    static CLoadGenBluetoothEditor* NewL(TBluetoothAttributes& aAttributes, TBool aEditingExisting=EFalse);
+    virtual ~CLoadGenBluetoothEditor();
+
+private: // Constructors
+    CLoadGenBluetoothEditor(TBluetoothAttributes& aAttributes, TBool aEditingExisting=EFalse);
+    void ConstructL();        
+
+protected:  // From CEikDialog
+    TBool OkToExitL(TInt aButtonId);    
+    void PreLayoutDynInitL();
+    void HandleControlStateChangeL(TInt aControlId);
+        
+public:  // New methods
+    virtual TBool RunQueryLD();
+
+private:  // New methods
+    void UpdateVisibilitiesOfFieldsL(TBool aFormInit=EFalse);
+    
+private: // Data
+    TBluetoothAttributes&              iAttributes;
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/inc/loadgen_keypress.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,94 @@
+/*
+* 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 LOADGEN_KEYPRESS_H
+#define LOADGEN_KEYPRESS_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <w32std.h>
+
+#include "loadgen_loadbase.h"
+#include "loadgen_loadattributes.h"
+
+
+// FORWARD DECLARATIONS
+
+
+
+// CLASS DECLARATIONS
+
+class CKeyPress : public CLoadBase
+    {
+public:
+    static CKeyPress* NewL(TKeyPressAttributes& aAttributes, TInt aReferenceNumber);
+    virtual ~CKeyPress();
+        
+private: // Constructors
+    CKeyPress(TKeyPressAttributes& aAttributes, TInt aReferenceNumber);
+    void ConstructL();  
+
+public:  // New methods
+    virtual void Resume();
+    virtual void Suspend();
+    virtual void SetPriority();
+    virtual void Close();
+    virtual TPtrC Description();
+    inline TKeyPressAttributes& Attributes() { return iAttributes; }
+
+public:  // New static methods
+    static TInt ThreadFunction(TAny* aThreadArg);
+
+private:  // New static methods
+    static void GenerateLoad(TKeyPressAttributes& aAttributes);
+
+private: // Data
+    TKeyPressAttributes         iAttributes;    
+    RThread                     iThread;
+    };
+
+
+class CKeyPressManager : public CActive
+    {
+public:
+    static CKeyPressManager* NewL(TKeyPressAttributes& aAttributes);
+    ~CKeyPressManager();
+
+private:
+    CKeyPressManager(TKeyPressAttributes& aAttributes);
+    void ConstructL();
+
+private:
+    void RunL();
+    void DoCancel();
+
+private:
+    static TInt PeriodicTimerCallBack(TAny* aAny);
+    void SimulateKeyEvent();
+
+public:
+    inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; }
+
+private:
+    TKeyPressAttributes&    iAttributes;    
+    CPeriodic*              iPeriodicTimer;
+    RWsSession              iWsSession;
+    }; 
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/inc/loadgen_loadattributes.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,167 @@
+/*
+* 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 LOADGEN_LOADATTRIBUTES_H
+#define LOADGEN_LOADATTRIBUTES_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <badesca.h> // CDesCArray
+
+const TInt KCPUSelection_FreeScheduling = -1;
+const TInt KCPUSelection_AllCPUs        = 999;
+
+// FORWARD DECLARATIONS
+
+
+// CLASS DECLARATIONS
+class TCPULoadAttributes
+    {
+public:
+    TUint iId;        
+    TUint iPriority;        
+    TUint iMode;        
+    TUint iType;        
+    TUint iLength;        
+    TUint iIdle;        
+    TUint iRandomVariance;
+    // iCpu defines in which CPU the load thread should be executed in 
+    // (in SMP environments). 0 = CPU0, 1 = CPU1 etc. Negative value means 
+    // that CPU is undefined. When CPU is undefined, Scheduler can schedule
+    // the load thread freely to any CPU as it pleases.
+    TInt  iCpu;
+    // Defines how many CPUs the running system has.
+    TUint iCpuCount;
+    };
+
+class TMemoryEatAttributes
+    {
+public:
+    TUint iId;        
+    TUint iPriority;        
+    TUint iSource;        
+    TUint iType;
+    TUint iBuffer;
+    TUint iIdle;
+    TInt64 iAmount;
+    TInt64 iRandomMin;
+    TInt64 iRandomMax;
+    TBuf<64> iAmountDes;
+    TBuf<64> iRandomMinDes;
+    TBuf<64> iRandomMaxDes;
+    TUint iRandomVariance;        
+    TRequestStatus* iDeathStatus;
+    }; 
+
+class TPhoneCallAttributes
+    {
+public:
+    TUint iId;        
+    TUint iPriority;        
+    TBuf<128> iDestination;
+    TUint iLength;        
+    TUint iIdle;        
+    TUint iRandomVariance;        
+    TRequestStatus* iDeathStatus;
+    };
+
+class TNetConnAttributes
+    {
+public:
+    TUint iId;        
+    TUint iPriority;        
+    TBuf<128> iDestination;
+    TUint iIdle;        
+    TUint iRandomVariance;        
+    TRequestStatus* iDeathStatus;
+    };
+
+class TKeyPressAttributes
+    {
+public:
+    TUint iId;        
+    TUint iPriority;        
+    TUint iHeartBeat;        
+    TUint iRandomVariance;        
+    TRequestStatus* iDeathStatus;
+    };
+
+class TPointerEventAttributes
+    {
+public:
+    TUint iId;        
+    TUint iPriority;        
+    TUint iHeartBeat;        
+    TUint iRandomVariance;        
+    TRequestStatus* iDeathStatus;
+    };
+
+class TMessageAttributes
+    {
+public:
+    TUint iId;
+    TInt iMessageType;
+    TBuf<128> iDestination;
+    TUint iPriority; 
+    TUint iAmount;
+    TInt iLength;    
+    TUint iIdle;    
+    TUint iRandomVariance;        
+    TRequestStatus* iDeathStatus;
+    };
+
+class TApplicationsAttributes
+    {
+public:
+    TUint iId;        
+    TUint iPriority;
+    TUint iLaunchingInterval;
+    TUint iKeyPressType;
+    TUint iMaxOpen;
+    TUint iHeartBeat;
+    TUint iRandomVariance;
+    CDesCArray* iAppsArray;
+    TRequestStatus* iDeathStatus;
+    };
+
+
+class TPhotoCaptureAttributes
+    {
+public:
+    TUint iId;    
+    TInt iPriority;
+    TInt iCameraCount;
+    TInt iCamera;
+    TUint iIdle;    
+    TUint iRandomVariance;        
+    TRequestStatus* iDeathStatus;
+    };
+
+class TBluetoothAttributes
+    {
+public:
+    TUint iId;    
+    TInt iPriority;    
+    TUint iIdle;    
+    TUint iRandomVariance;        
+    TRequestStatus* iDeathStatus;
+    TBool iBluetoothSupported;
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/inc/loadgen_loadbase.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,66 @@
+/*
+* 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 LOADGEN_LOADBASE_H
+#define LOADGEN_LOADBASE_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+
+#include "loadgen_loadbase.h"
+
+
+// FORWARD DECLARATIONS
+
+
+
+// CLASS DECLARATIONS
+
+class CLoadBase : public CBase
+    {
+public:
+    enum TLoadState
+        {
+        ELoadStateInvalid = -1,
+        ELoadStateConstructed,
+        ELoadStateRunning,
+        ELoadStateSuspended,
+        ELoadStateClosed
+        };
+        
+protected: // Constructors
+    CLoadBase();
+    void ConstructL();
+
+public:  // New methods
+    virtual void Resume();
+    virtual void Suspend();
+    virtual void SetPriority();
+    virtual void Close();
+    virtual TPtrC Description();
+    inline TInt State() { return iState; }
+    inline TInt Type() { return iType; }
+
+protected: // Data
+    TInt iState;
+    TInt iType;
+    };
+ 
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/inc/loadgen_maincontainer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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 LOADGEN_VALUESCONTAINER_H
+#define LOADGEN_VALUESCONTAINER_H
+
+// INCLUDES
+#include <coecntrl.h>
+#include <eiklbo.h> 
+#include <aknlists.h> 
+
+// FORWARD DECLARATIONS
+class CLoadGenModel;
+class CLoadGenCAknSingleGraphicStyleListBox;
+
+// CLASS DECLARATIONS
+
+class CLoadGenMainContainer : public CCoeControl, MCoeControlObserver, MEikListBoxObserver
+    {
+public:
+    void ConstructL(const TRect& aRect);
+    ~CLoadGenMainContainer();
+
+private:
+    void SizeChanged();  
+    TInt CountComponentControls() const;
+    CCoeControl* ComponentControl(TInt aIndex) const;
+    void Draw(const TRect& aRect) const;
+    void HandleResourceChange(TInt aType);
+    void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);  // From MEikListBoxObserver
+    void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);  // From MCoeControlObserver
+    TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
+
+public:
+    const CArrayFix<TInt>* ListBoxSelectionIndexes();
+    TInt ListBoxSelectionIndexesCount();
+    void SetDefaultTitlePaneTextL();
+    TInt CurrentListBoxItemIndex();
+    void SetListBoxTextArrayL(CDesCArray* aTextArray);
+    inline CLoadGenCAknSingleGraphicStyleListBox* ListBox() { return iListBox; }
+
+private:
+    CLoadGenModel*                              iModel;
+    CLoadGenCAknSingleGraphicStyleListBox*      iListBox;
+    };
+
+class CLoadGenCAknSingleGraphicStyleListBox : public CAknSingleGraphicStyleListBox
+    {
+    void SizeChanged();
+    void SizeChangedL();
+    };
+        
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/inc/loadgen_mainview.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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 LOADGEN_VALUESVIEW_H
+#define LOADGEN_VALUESVIEW_H
+
+// INCLUDES
+#include <aknview.h>
+
+#include "loadgen_std.h"
+
+
+
+// CONSTANTS
+// UID of view
+const TUid KMainViewUID = {1};
+
+
+// FORWARD DECLARATIONS
+class CLoadGenMainContainer;
+class CLoadGenModel;
+
+
+// CLASS DECLARATION
+
+/**
+*  CLoadGenMainView view class.
+* 
+*/
+class CLoadGenMainView : public CAknView
+    {
+    public: // Constructors and destructor
+        void ConstructL();
+        ~CLoadGenMainView();
+
+    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
+        CLoadGenMainContainer*        iContainer;
+        CLoadGenModel*                  iModel;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/inc/loadgen_memoryeat.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,106 @@
+/*
+* 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 LOADGEN_MEMORYEAT_H
+#define LOADGEN_MEMORYEAT_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <f32file.h>
+
+#include "loadgen_loadbase.h"
+#include "loadgen_loadattributes.h"
+
+
+// FORWARD DECLARATIONS
+
+
+
+// CLASS DECLARATIONS
+
+class CMemoryEat : public CLoadBase
+    {
+public:
+    static CMemoryEat* NewL(TMemoryEatAttributes& aAttributes, TInt aReferenceNumber);
+    virtual ~CMemoryEat();
+        
+private: // Constructors
+    CMemoryEat(TMemoryEatAttributes& aAttributes, TInt aReferenceNumber);
+    void ConstructL();  
+
+public:  // New methods
+    virtual void Resume();
+    virtual void Suspend();
+    virtual void SetPriority();
+    virtual void Close();
+    virtual TPtrC Description();
+    inline TMemoryEatAttributes& Attributes() { return iAttributes; }
+
+public:  // New static methods
+    static TInt ThreadFunction(TAny* aThreadArg);
+private:
+    static void GenerateLoad(TMemoryEatAttributes& aAttributes);
+
+private: // Data
+    TMemoryEatAttributes    iAttributes;    
+    RThread                 iThread;
+    };
+
+
+class CMemoryEatManager : public CActive
+    {
+public:
+    static CMemoryEatManager* NewL(TMemoryEatAttributes& aAttributes);
+    ~CMemoryEatManager();
+
+private:
+    CMemoryEatManager(TMemoryEatAttributes& aAttributes);
+    void ConstructL();
+
+private:
+    void RunL();
+    void DoCancel();
+
+private:
+    static TInt PeriodicTimerCallBack(TAny* aAny);
+    void InitMemoryEatL();
+    void DestroyMemoryEat();
+    void EatMemoryL();
+    void DoEatMemoryL( TInt64 aNewSize );
+    void HandleEatMemoryL( TInt64 aNewSize );
+    void AllocMemoryL( TInt64 aNewSize );
+    void FreeMemoryL( TInt64 aNewSize );
+    TInt64 ReadFreeMemory();
+    
+
+public:
+    inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; }
+
+private:
+    TMemoryEatAttributes&   iAttributes;    
+    CPeriodic*              iPeriodicTimer;
+    RChunk                  iEatChunk;
+    RFile                   iEatFile;
+    RFs                     iFs;
+    TBool                   iWavyEatMoreMemory;
+    TInt     iFilesCounter;
+    };
+     
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/inc/loadgen_messages.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,421 @@
+/*
+* 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 LOADGEN_MESSAGES_H
+#define LOADGEN_MESSAGES_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+
+#include "loadgen_loadbase.h"
+#include "loadgen_loadattributes.h"
+
+
+// FORWARD DECLARATIONS
+class CSmsHandler;
+class CMmsHandler;
+
+const TInt EMaxMessageLength = 512;
+
+// CLASS DECLARATIONS
+
+class CMessages : public CLoadBase
+    {
+public:
+    static CMessages* NewL( TMessageAttributes& aAttributes, TInt aReferenceNumber );
+    virtual ~CMessages();
+        
+private: // Constructors
+    CMessages( TMessageAttributes& aAttributes, TInt aReferenceNumber );
+    void ConstructL();  
+
+public:  // New methods
+    virtual void Resume();
+    virtual void Suspend();
+    virtual void SetPriority();
+    virtual void Close();
+    virtual TPtrC Description();
+    inline TMessageAttributes& Attributes() { return iAttributes; }
+
+public:  // New static methods
+    static TInt ThreadFunction( TAny* aThreadArg );
+
+private:  // New static methods
+    static void GenerateLoad( TMessageAttributes& aAttributes );
+
+private: // Data
+    TMessageAttributes            iAttributes;    
+    RThread                     iThread;
+
+    };
+
+
+class CMessageManager : public CActive
+    { 
+private:
+    enum TState
+        {
+        EStateIdle = 0,
+        EStateSend,
+        EStateSending        
+        };
+public:
+    static CMessageManager* NewL( TMessageAttributes& aAttributes );
+    virtual ~CMessageManager();
+
+
+private:
+    CMessageManager( TMessageAttributes& aAttributes );
+    void ConstructL();
+
+private:
+    void RunL();
+    void DoCancel();
+
+private:
+    static TInt PeriodicTimerCallBack( TAny* aAny );
+    void HandleMessageSending();
+    void DoDial();
+    void DoHangup();
+    void CreateMessage();    
+
+public:
+    inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; }
+    void HandleStatus( TInt aErr );
+
+private:
+    TMessageAttributes&                   iAttributes;
+    CPeriodic*                          iPeriodicTimer;
+    TInt                                iState;
+    CSmsHandler*                        iSmsHandler;
+    CMmsHandler*                        iMmsHandler;
+    TInt                                iMessageCounter;
+    HBufC*                                iMessage;
+    }; 
+
+//  INCLUDES
+#include <e32base.h>
+#include <msvapi.h>
+#include <mtuireg.h>
+#include <txtrich.h>
+// CONSTANTS
+const TInt KBfrLength = 20;
+const TInt KTelephoneNumberMaxLength = 100;
+ 
+// FORWARD DECLARATIONS
+class CSmsAppUi;
+class CClientMtmRegistry;
+class CSmsClientMtm;
+ 
+// CLASS DECLARATION
+/**
+* CSmsHandler application engine class.
+* Takes care of sending and receiveing SMS messages using the SMS client MTM.
+* Interacts with the application UI class.
+*/
+class CSmsHandler : public CActive, public MMsvSessionObserver
+    {
+    public: // Constructors and destructor
+ 
+        /**
+        * NewL.
+        * Two-phased constructor.
+        * @param aSmsAppUi Pointer to AppUi instance.
+        * @return Pointer to the created instance of CSmsHandler.
+        */
+        static CSmsHandler* NewL( CMessageManager& aManager );
+ 
+        /**
+        * NewLC.
+        * Two-phased constructor.
+        * @param aSmsAppUi Pointer to AppUi instance.
+        * @return Pointer to the created instance of CSmsHandler.
+        */
+        static CSmsHandler* NewLC( CMessageManager& aManager );
+ 
+        /**
+        * ~CSmsHandler
+        * Destructor.
+        */
+        virtual ~CSmsHandler();
+ 
+    public: // New functions
+        /**
+        * SendL.
+        * Starts the process of creating and sending an SMS message.
+        * @param aRecipientNumber The number of the recipent.
+        * @param aMessageText The message text.
+        * @return ETrue if successful, EFalse if not.
+        */
+       TBool SendL( const TDesC& aRecipientNumber,
+                    const TDesC& aMessageText );
+ 
+    public: // Functions from base classes
+ 
+        /**
+        * From MMsvSessionObserver, HandleSessionEventL.
+        * Handles notifications of events from the Message Server.
+        * @param aEvent The event that has taken place
+        * @param aArg1 Event type-specific argument value
+        * @param aArg2 Event type-specific argument value
+        * @param aArg3 Event type-specific argument value
+        */
+        void HandleSessionEventL( TMsvSessionEvent aEvent, TAny* aArg1,
+                                  TAny* aArg2, TAny* aArg3 );
+ 
+    protected: // Functions from base classes
+ 
+        /**
+        * From CActive, DoCancel.
+        * Cancels any outstanding requests.
+        */
+        void DoCancel();
+ 
+        /**
+        * From CActive, RunL.
+        * Handles an active object’s request completion event.
+        */
+        void RunL();
+ 
+    private: // Constructors
+ 
+        /**
+        * CSmsHandler.
+        * C++ default constructor.
+        * @param aSmsAppUi Pointer to AppUi instance.
+        */
+        CSmsHandler( CMessageManager& aManager );
+ 
+        /**
+        * ConstructL.
+        * 2nd phase constructor.
+        */
+        void ConstructL();
+ 
+    private: // New functions
+ 
+        /**
+        * AccessMtmL.
+        * Access the MTM Registry and create an SMS specific Client MTM instance.
+        */
+        void AccessMtmL();
+ 
+        /**
+        * CreateMsgL.
+        * Create an SMS message.
+        * @return ETrue if successful, EFalse is unsuccessful.
+        */
+        TBool CreateMsgL();
+ 
+        /**
+        * ScheduleL.
+        * Schedule an SMS message for sending.
+        */
+        void ScheduleL();
+ 
+        /**
+        * ValidateL.
+        * Validate an SMS message.
+        * @return ETrue if successful, EFalse is unsuccessful.
+        */
+        TBool ValidateL();
+ 
+    private: // Enumeration
+ 
+        /**
+        * TState, enumeration for the state of the handler, used by RunL().
+        */
+        enum TState
+            {
+            EWaitingForMoving = 1,
+            EWaitingForScheduling
+            };
+ 
+    private: // Data
+ 
+        /**
+        * iState, the state of the handler.
+        */
+        TState iState;
+ 
+        /**
+        * iSession, the contact database.
+        * Owned by CSmsHandler object.
+        */
+        CMsvSession* iSession;
+ 
+        /**
+        * iMtmRegistry, client MTM registry.
+        * Owned by CSmsHandler object.
+        */
+        CClientMtmRegistry* iMtmRegistry;
+ 
+        /**
+        * iSmsMtm, SMS specific Client MTM.
+        * Owned by CSmsHandler object.
+        */
+        CSmsClientMtm* iSmsMtm;
+ 
+        /**
+        * iOperation, the current message server operation.
+        * Owned by CSmsHandler object.
+        */
+        CMsvOperation* iOperation;
+ 
+        /**
+        * iRecipientNumber, telephone number of the recipient.
+        */
+        TBuf<KTelephoneNumberMaxLength> iRecipientNumber;
+ 
+        /**
+        * iMessageText, SMS message text.
+        */
+        TBuf<EMaxMessageLength> iMessageText;
+
+ 
+        /**
+        * iSmsAppUi, application UI
+        * Not owned by CSmsHandler object.
+        */
+        CSmsAppUi* iSmsAppUi;
+ 
+        /**
+        * iMtmUiRegistry, User Interface MTM Registry.
+        * Owned by CSmsHandler object.
+        */
+        CMtmUiRegistry* iMtmUiRegistry;
+        
+        CMessageManager& iManager;
+ 
+    };
+
+
+// INCLUDES
+#include <msvapi.h>                         // for MMsvSessionObserver 
+#include <mmsclient.h>                      // for CMmsClientMtm
+#include <coecntrl.h>
+
+// Forward declarations
+class CClientMtmRegistry;
+class CMsvSession;
+
+//
+// Container class to draw text on screen
+//
+class CMmsHandler : public CBase, public MMsvSessionObserver
+    {
+public: // Constructors and destructor
+
+    /**
+    * NewL.
+    * Two-phased constructor.
+    * @param aSmsAppUi Pointer to AppUi instance.
+    * @return Pointer to the created instance of CSmsHandler.
+    */
+    static CMmsHandler* NewL( CMessageManager& aManager );
+
+    /**
+    * NewLC.
+    * Two-phased constructor.
+    * @param aSmsAppUi Pointer to AppUi instance.
+    * @return Pointer to the created instance of CSmsHandler.
+    */
+    static CMmsHandler* NewLC( CMessageManager& aManager );
+
+    /**
+    * ~CSmsHandler
+    * Destructor.
+    */
+    virtual ~CMmsHandler();
+
+private: // Constructors
+
+    /**
+    * CSmsHandler.
+    * C++ default constructor.
+    * @param aSmsAppUi Pointer to AppUi instance.
+    */
+    CMmsHandler( CMessageManager& aManager );
+
+    /**
+    * ConstructL.
+    * 2nd phase constructor.
+    */
+    void ConstructL();
+
+public: // New functions
+    
+    /*
+     * Creates client MTM registry when session is ready for use. 
+     * This completes model construction and is called after 'server
+     * ready' event is received after async opening of CMsvSession.
+     */ 
+    void CompleteConstructL();
+       
+    /*
+     * CMmsHandler::CreateNewMessageL()
+     * Creates a new message server entry and set up default values.
+     * In case the attachment file does not found method return EFalse
+     * otherwise ETrue.
+     * There are differenses how to add attachment file between 2nd and 3rd edition.
+     */  
+     TBool CreateMsgL();
+
+    /**
+     * Send the message.
+     * Return values: ETrue or EFalse
+     */
+    TBool SendMessageL();
+        
+     /**
+      * SendL.
+      * Starts the process of creating and sending an SMS message.
+      * @param aRecipientNumber The number of the recipent.
+      * @param aMessageText The message text.
+      * @return ETrue if successful, EFalse if not.
+      */
+     TBool SendL( const TDesC& aRecipientNumber,
+                 const TDesC& aMessageText );     
+           
+private:    
+    // from MMsvSessionObserver
+    void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3);
+  
+    void SetMessageBodyL();
+
+private:
+
+    CMsvSession* iSession;          // Client session on the message server
+    CMmsClientMtm* iMmsMtm;         // Message Type Module (MMS)
+    CClientMtmRegistry* iMtmReg;    // Mtm client registry for creating new mtms
+
+    /**
+    * iRecipientNumber, telephone number of the recipient.
+    */
+    TBuf<KTelephoneNumberMaxLength> iRecipientNumber;
+
+    /**
+    * iMessageText, SMS message text.
+    */
+    TBuf<EMaxMessageLength> iMessageText;
+    
+    CMessageManager& iManager;
+    
+    };
+#endif // LOADGEN_MESSAGES_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/inc/loadgen_model.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,134 @@
+/*
+* 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 LOADGEN_MODEL_H
+#define LOADGEN_MODEL_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <apgcli.h>
+
+#include "loadgen_loadattributes.h"
+
+// FORWARD DECLARATIONS
+class CLoadGenMainContainer;
+class CLoadGenGraphsContainer;
+class CEikonEnv;
+class CLoadBase;
+
+
+typedef CArrayFixSeg<CLoadBase*> CLoadItemList;
+
+const TUint KMaxCPUs = 4;
+const TUint KHalFunction_EKernelHalNumLogicalCpus = 16; //EKernelHalNumLogicalCpus
+const TUint KHalFunction_EKernelHalLockThreadToCpu = 19; //EKernelHalLockThreadToCpu
+
+// CLASS DECLARATIONS
+
+class TLoadGenSettings
+    {
+public:
+    };
+
+class CLoadGenModel : public CActive
+    {
+private:
+    enum TContainerDrawState
+        {
+        EDrawStateInvalid = -1,
+        EDrawStateMain
+        };
+
+public:
+    static CLoadGenModel* NewL();
+    ~CLoadGenModel();
+    void ActivateModelL();
+    void DeActivateModelL();
+
+private:
+    void RunL();
+    void DoCancel();
+        
+private:
+    CLoadGenModel();
+    void ConstructL();
+    void LoadSettingsL();
+    void EditLoadL(CLoadBase* aItem);
+    void DoStartNewLoadL(TInt aCommand);
+    void AppendToLoadItemListL(CLoadBase* aItem);
+    void DeleteFromLoadItemListL(TInt aIndex);
+    void SuspendOrResumeFromLoadItemListL(TInt aIndex);
+    void DeleteAllLoadItems();
+    void RefreshViewL(TBool aClearSelection=ETrue);
+    CDesCArray* ListOfAllAppsL();    
+    
+public:
+    void StopAllLoadItemsL();
+    void SuspendAllLoadItemsL();
+    void ResumeAllLoadItemsL();
+            
+    TInt LoadItemCount() const;
+    void ShowItemActionMenuL();
+    void StopSelectedOrHighlightedItemsL();
+    void SuspendOrResumeSelectedOrHighlightedItemsL();
+
+    CDesCArray* GenerateListBoxItemTextArrayL();
+    void StartNewLoadL(TInt aCommand);
+    void SaveSettingsL();
+    void SetMainContainer(CLoadGenMainContainer* aContainer);
+    TInt LaunchSettingsDialogL();
+    inline TLoadGenSettings& Settings() { return iSettings; }
+    inline CEikonEnv* EikonEnv() { return iEnv; }
+    inline RApaLsSession& LsSession() { return iLs; }
+    inline CLoadGenMainContainer* MainContainer() { return iMainContainer; }
+    inline TBool LoadItemsExists() { return iLoadItemList->Count() > 0; } 
+
+
+public:
+    static TThreadPriority SettingItemToThreadPriority(TInt aIndex);
+    static void SettingItemToThreadDescription(TInt aIndex, TDes& aBuf);
+    static void SettingItemToSourceDescription(TInt aIndex, TDes& aBuf);
+    static TInt MilliSecondsToMicroSeconds(TInt aMilliSeconds, TInt aRandomVariance=0);
+    static TInt RandomNumber(TInt aMin, TInt aMax);
+    static TSize ScreenSize();
+
+private:
+    RTimer                          iTimer;
+    CLoadGenMainContainer*          iMainContainer;
+    CEikonEnv*                      iEnv;
+    TLoadGenSettings                iSettings;
+    RApaLsSession                   iLs;
+    TInt                            iDrawState;
+    CLoadItemList*                  iLoadItemList;
+    TInt                            iReferenceNumber;
+    TCPULoadAttributes              iCpuLoadAttributes;
+    TMemoryEatAttributes            iMemoryEatAttributes;
+    TPhoneCallAttributes            iPhoneCallAttributes;
+    TNetConnAttributes              iNetConnAttributes;
+    TKeyPressAttributes             iKeyPressAttributes;
+    TMessageAttributes              iMessageAttributes;
+    TApplicationsAttributes			iApplicationsAttributes;
+    TPhotoCaptureAttributes         iPhotoCaptureAttributes;
+    TBluetoothAttributes            iBluetoothAttributes;
+    TPointerEventAttributes         iPointerEventAttributes;
+    static TInt64                   iRandomNumberSeed;
+    };
+ 
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/inc/loadgen_netconn.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,96 @@
+/*
+* 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 LOADGEN_NETCONN_H
+#define LOADGEN_NETCONN_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <downloadmgrclient.h> 
+
+#include "loadgen_loadbase.h"
+#include "loadgen_loadattributes.h"
+
+
+// FORWARD DECLARATIONS
+class CNetConnManager;
+
+
+// CLASS DECLARATIONS
+
+class CNetConn : public CLoadBase
+    {
+public:
+    static CNetConn* NewL(TNetConnAttributes& aAttributes, TInt aReferenceNumber);
+    virtual ~CNetConn();
+        
+private: // Constructors
+    CNetConn(TNetConnAttributes& aAttributes, TInt aReferenceNumber);
+    void ConstructL();  
+
+public:  // New methods
+    virtual void Resume();
+    virtual void Suspend();
+    virtual void SetPriority();
+    virtual void Close();
+    virtual TPtrC Description();
+    inline TNetConnAttributes& Attributes() { return iAttributes; }
+
+public:  // New static methods
+    static TInt ThreadFunction(TAny* aThreadArg);
+
+private:  // New static methods
+    static void GenerateLoad(TNetConnAttributes& aAttributes);
+
+private: // Data
+    TNetConnAttributes          iAttributes;    
+    RThread                     iThread;
+    };
+
+
+class CNetConnManager : public CActive, public MHttpDownloadMgrObserver
+    {
+public:
+    static CNetConnManager* NewL(TNetConnAttributes& aAttributes);
+    ~CNetConnManager();
+
+private:
+    CNetConnManager(TNetConnAttributes& aAttributes);
+    void ConstructL();
+
+private:
+    void RunL();
+    void DoCancel();
+
+private:
+    static TInt PeriodicTimerCallBack(TAny* aAny);
+    void StartDownloadL();
+
+private: // MHttpDownloadMgrObserver
+    void HandleDMgrEventL(RHttpDownload& aDownload, THttpDownloadEvent aEvent); 
+public:
+    inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; }
+
+private:
+    TNetConnAttributes&     iAttributes;    
+    CPeriodic*              iPeriodicTimer;
+    RHttpDownloadMgr        iDownloadMgr;
+    }; 
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/inc/loadgen_phonecall.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,134 @@
+/*
+* 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 LOADGEN_PHONECALL_H
+#define LOADGEN_PHONECALL_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <etel3rdparty.h>
+
+
+#include "loadgen_loadbase.h"
+#include "loadgen_loadattributes.h"
+
+
+// FORWARD DECLARATIONS
+class CPhoneCallManager;
+class CDialer;
+
+
+// CLASS DECLARATIONS
+
+class CPhoneCall : public CLoadBase
+    {
+public:
+    static CPhoneCall* NewL(TPhoneCallAttributes& aAttributes, TInt aReferenceNumber);
+    virtual ~CPhoneCall();
+        
+private: // Constructors
+    CPhoneCall(TPhoneCallAttributes& aAttributes, TInt aReferenceNumber);
+    void ConstructL();  
+
+public:  // New methods
+    virtual void Resume();
+    virtual void Suspend();
+    virtual void SetPriority();
+    virtual void Close();
+    virtual TPtrC Description();
+    inline TPhoneCallAttributes& Attributes() { return iAttributes; }
+
+public:  // New static methods
+    static TInt ThreadFunction(TAny* aThreadArg);
+
+private:  // New static methods
+    static void GenerateLoad(TPhoneCallAttributes& aAttributes);
+
+private: // Data
+    TPhoneCallAttributes        iAttributes;    
+    RThread                     iThread;
+    };
+
+    
+
+class CPhoneCallManager : public CActive
+    { 
+private:
+    enum TState
+        {
+        EStateIdle = 0,
+        EStateCall
+        };
+public:
+    static CPhoneCallManager* NewL(TPhoneCallAttributes& aAttributes);
+    ~CPhoneCallManager();
+
+private:
+    CPhoneCallManager(TPhoneCallAttributes& aAttributes);
+    void ConstructL();
+
+private:
+    void RunL();
+    void DoCancel();
+
+private:
+    static TInt PeriodicTimerCallBack(TAny* aAny);
+    void HandleCalls();
+    void DoDial();
+    void DoHangup();
+
+public:
+    inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; }
+    void HandleStatus(TInt aErr);
+
+private:
+    TPhoneCallAttributes&               iAttributes;
+    CDialer*                            iDialer;   
+    CPeriodic*                          iPeriodicTimer;
+    TInt                                iState;
+    }; 
+
+
+class CDialer : public CActive
+    { 
+public:
+    static CDialer* NewL(CPhoneCallManager& aManager);
+    ~CDialer();
+
+private:
+    CDialer(CPhoneCallManager& aManager);
+    void ConstructL();
+
+private:
+    void RunL();
+    void DoCancel();
+
+public:
+    void Dial(const TDesC& aDestination);
+    void Hangup();
+
+private:
+    CPhoneCallManager&                  iManager;
+    CTelephony*                         iTelephony;
+    CTelephony::TCallId                 iCallId;
+    CTelephony::TCallParamsV1           iCallParams;
+    CTelephony::TCallParamsV1Pckg       iCallParamsPckg;
+    };
+        
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/inc/loadgen_photocapture.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,138 @@
+/*
+* 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 LOADGEN_PHOTOCAPTURE_H
+#define LOADGEN_PHOTOCAPTURE_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <ECam.h>  // CCamera, MCameraObserver
+
+#include "loadgen_loadbase.h"
+#include "loadgen_loadattributes.h"
+
+
+// FORWARD DECLARATIONS
+class CCameraManager;
+
+
+// CLASS DECLARATIONS
+
+class CPhotoCapture : public CLoadBase
+    {
+public:
+    static CPhotoCapture* NewL(TPhotoCaptureAttributes& aAttributes, TInt aReferenceNumber);
+    virtual ~CPhotoCapture();
+        
+private: // Constructors
+    CPhotoCapture(TPhotoCaptureAttributes& aAttributes, TInt aReferenceNumber);
+    void ConstructL();  
+
+public:  // New methods
+    virtual void Resume();
+    virtual void Suspend();
+    virtual void SetPriority();
+    virtual void Close();
+    virtual TPtrC Description();
+    inline TPhotoCaptureAttributes& Attributes() { return iAttributes; }
+
+public:  // New static methods
+    static TInt ThreadFunction(TAny* aThreadArg);
+    //static void SetImagesReady(TInt aImages);
+    //static TInt ImagesReady();
+
+private:  // New static methods
+    static void GenerateLoad(TPhotoCaptureAttributes& aAttributes);
+    static void DoHeaveStuff(TInt aMode);
+
+private: // Data
+    TPhotoCaptureAttributes iAttributes;    
+    RThread                 iThread;
+    //static TInt             iImagesReady;
+    };
+ 
+
+
+ 
+class CCameraManager : public CActive, public MCameraObserver
+    {
+    public:
+        
+        static CCameraManager* NewL(TPhotoCaptureAttributes& aAttrs);        
+        virtual ~CCameraManager();
+ 
+    private:
+        
+        CCameraManager(TPhotoCaptureAttributes& aAttrs);
+        void ConstructL();
+ 
+    private:
+        /**
+         * From MCameraObserver:
+         */         
+        virtual void ReserveComplete(TInt aError);
+        virtual void PowerOnComplete(TInt aError);
+        virtual void ViewFinderFrameReady(CFbsBitmap& aFrame);
+        virtual void ImageReady(CFbsBitmap* aBitmap,
+                HBufC8* aData, TInt aError);
+        virtual void FrameBufferReady(MFrameBuffer* aFrameBuffer,
+                TInt aError);
+    
+        static TInt PeriodicTimerCallBack(TAny* aAny);
+    public:
+        
+        /**
+         * Reserves the camera.
+         */
+        void ReserveCameraL();
+        
+        /**
+         * Takes a picture.
+         */
+        void CapturePhotoL();
+        
+        TInt NumberOfPictures();
+                                        
+        /**
+         * From CActive:
+         */
+        void RunL();
+        void DoCancel();
+ 
+    private:
+        
+        enum TState
+            {
+            ENotReady,
+            ECameraReserved,
+            EIdle,
+            ECapture
+            };
+
+        CPeriodic*                  iPeriodicTimer;
+        TPhotoCaptureAttributes&    iAttributes;
+        CCamera*                    iCamera;
+        TState                      iState;
+        TInt                        iNumOfPics;
+        TCameraInfo                 iCameraInfo;
+        TInt                        iCurrentCamera;
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/inc/loadgen_pointerevent.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,94 @@
+/*
+* 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 LOADGEN_POINTEREVENT_H
+#define LOADGEN_POINTEREVENT_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <w32std.h>
+
+#include "loadgen_loadbase.h"
+#include "loadgen_loadattributes.h"
+
+
+// FORWARD DECLARATIONS
+
+
+
+// CLASS DECLARATIONS
+
+class CPointerEvent : public CLoadBase
+    {
+public:
+    static CPointerEvent* NewL(TPointerEventAttributes& aAttributes, TInt aReferenceNumber);
+    virtual ~CPointerEvent();
+        
+private: // Constructors
+    CPointerEvent(TPointerEventAttributes& aAttributes, TInt aReferenceNumber);
+    void ConstructL();  
+
+public:  // New methods
+    virtual void Resume();
+    virtual void Suspend();
+    virtual void SetPriority();
+    virtual void Close();
+    virtual TPtrC Description();
+    inline TPointerEventAttributes& Attributes() { return iAttributes; }
+
+public:  // New static methods
+    static TInt ThreadFunction(TAny* aThreadArg);
+
+private:  // New static methods
+    static void GenerateLoad(TPointerEventAttributes& aAttributes);
+
+private: // Data
+    TPointerEventAttributes         iAttributes;    
+    RThread                     iThread;
+    };
+
+
+class CPointerEventManager : public CActive
+    {
+public:
+    static CPointerEventManager* NewL(TPointerEventAttributes& aAttributes);
+    ~CPointerEventManager();
+
+private:
+    CPointerEventManager(TPointerEventAttributes& aAttributes);
+    void ConstructL();
+
+private:
+    void RunL();
+    void DoCancel();
+
+private:
+    static TInt PeriodicTimerCallBack(TAny* aAny);
+    void SimulatePointerEvent();
+
+public:
+    inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; }
+
+private:
+    TPointerEventAttributes&    iAttributes;    
+    CPeriodic*                  iPeriodicTimer;
+    //RWsSession                  iWsSession;
+    }; 
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/inc/loadgen_settingsviewdlg.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  
+*
+*/
+
+
+#ifndef LOADGEN_SETTINGSVIEWDLG_H
+#define LOADGEN_SETTINGSVIEWDLG_H
+
+//  INCLUDES
+#include <akndialog.h>
+#include <eiklbo.h>
+#include <akntabobserver.h> 
+#include <akntabgrp.h>
+
+//  FORWARD DECLARATIONS
+class CAknSettingItemArray;
+class CAknSettingStyleListBox;
+class CAknNavigationControlContainer;
+class CAknNavigationDecorator;
+class CAknTabGroup; 
+class TLoadGenSettings;
+
+
+//  CLASS DEFINITIONS
+
+class CLoadGenSettingsViewDlg : public CAknDialog, public MEikListBoxObserver, public MAknTabObserver
+    {
+public:
+    static CLoadGenSettingsViewDlg* NewL(TLoadGenSettings& aSettings);
+    virtual ~CLoadGenSettingsViewDlg();
+
+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
+    CLoadGenSettingsViewDlg(TLoadGenSettings& aSettings);
+    void ConstructL();        
+
+private: // Data
+    CAknSettingItemArray*               iSettingItemArray;
+    CAknSettingStyleListBox*            iListBox;
+    CAknNavigationControlContainer*     iNaviContainer;
+    CAknNavigationDecorator*            iDecoratedTabGroup;
+    CAknTabGroup*                       iTabGroup;
+    TLoadGenSettings&               iSettings;
+    };
+
+
+#endif
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/inc/loadgen_std.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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 LOADGEN_STD_H
+#define LOADGEN_STD_H
+
+
+
+#endif
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/inc/loadgen_traces.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,106 @@
+/*
+* 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 __LOADGEN_TRACES_H__
+#define __LOADGEN_TRACES_H__
+
+#include <e32def.h>
+
+
+// ---------------------------------------------------------------------------
+// You change these logging method values below! Recompile the application to take changes effect.
+
+    // logging methods
+    // 0 = No logging
+    // 1 = Flogger
+    // 2 = RDebug
+    // 3 = Flogger and RDebug
+    
+    #ifndef _DEBUG
+        
+        // Logging method for UREL builds:
+        #define LOADGEN_LOGGING_METHOD  3
+
+    #else
+
+        // Logging method for UDEB builds:
+        #define LOADGEN_LOGGING_METHOD  3
+
+    #endif    
+    
+
+
+// ---------------------------------------------------------------------------
+// Do not make any changes to lines below...
+
+    #if LOADGEN_LOGGING_METHOD == 1 || LOADGEN_LOGGING_METHOD == 3
+
+        #include <flogger.h>
+        _LIT(KLogFolder,"loadgen");
+        _LIT(KLogFile,"loadgen_trace.txt");
+
+    #endif
+
+    #if LOADGEN_LOGGING_METHOD == 2 || LOADGEN_LOGGING_METHOD == 3
+
+        #include <e32debug.h>
+
+    #endif
+
+
+    #if LOADGEN_LOGGING_METHOD == 0
+    
+        #define LOGTEXT(AAA)
+        #define LOGSTRING(AAA)
+        #define LOGSTRING2(AAA,BBB)
+        #define LOGSTRING3(AAA,BBB,CCC)
+        #define LOGSTRING4(AAA,BBB,CCC,DDD)
+    
+    
+    #elif LOADGEN_LOGGING_METHOD == 1
+    
+        #define LOGTEXT(AAA)                RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend, AAA)
+        #define LOGSTRING(AAA)              do { _LIT(tempLogDes,AAA); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0)
+        #define LOGSTRING2(AAA,BBB)         do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB); } while (0)
+        #define LOGSTRING3(AAA,BBB,CCC)     do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB,CCC); } while (0)
+        #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB,CCC,DDD); } while (0)
+   
+    #elif LOADGEN_LOGGING_METHOD == 2
+    
+        #define LOGTEXT(AAA)                RDebug::Print(AAA)
+        #define LOGSTRING(AAA)              do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); } while (0)
+        #define LOGSTRING2(AAA,BBB)         do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); } while (0)
+        #define LOGSTRING3(AAA,BBB,CCC)     do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); } while (0)
+        #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); } while (0)
+    
+    #elif LOADGEN_LOGGING_METHOD == 3
+    
+        #define LOGTEXT(AAA)                RDebug::Print(AAA); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend, AAA)
+        #define LOGSTRING(AAA)              do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0)
+        #define LOGSTRING2(AAA,BBB)         do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB); } while (0)
+        #define LOGSTRING3(AAA,BBB,CCC)     do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB,CCC); } while (0)
+        #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB,CCC,DDD); } while (0)
+
+    #endif
+
+// ---------------------------------------------------------------------------
+
+#endif // __LOADGEN_TRACES_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/rom/loadgen.iby	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,35 @@
+/*
+* 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 __LOADGEN_IBY__
+#define __LOADGEN_IBY__
+
+S60_APP_EXE(LoadGen)
+S60_APP_AIF_ICONS(LoadGen)
+S60_APP_RESOURCE(LoadGen)
+SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,LoadGen_ExtraIcons)
+#ifdef S60_UPGRADABLE_APP_REG_RSC
+  S60_UPGRADABLE_APP_REG_RSC(LoadGen)
+#else
+  S60_APP_AIF_RSC(LoadGen)
+#endif
+
+data=ZPRIVATE\20011384\backup_registration.xml        	private\20011384\backup_registration.xml
+data=ZSYSTEM\Install\LoadGen_stub.sis                   \system\install\LoadGen_stub.sis
+
+#endif // __LOADGEN_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/sis/LoadGen_S60-30.pkg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,38 @@
+;
+; 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:
+;
+
+; Language - standard language definitions
+&EN
+
+; Standard SIS file header
+#{"LoadGen"},(0x20011384),1,4,0,TYPE=SA
+
+; Supports S60 v 3.0
+[0x101F7961], 0, 0, 0, {"S60ProductID"}
+
+; Non-localised vendor name
+:"Nokia Corporation"
+
+; Localised vendor names
+%{"Nokia Corporation"}
+
+; normal stuff:
+"\epoc32\RELEASE\armv5\UREL\LoadGen.exe"-"!:\sys\bin\LoadGen.exe"
+"\epoc32\data\z\Resource\apps\LoadGen_aif.mif"-"!:\Resource\Apps\LoadGen_aif.mif"
+"\epoc32\data\z\Resource\apps\LoadGen_ExtraIcons.mif"-"!:\Resource\Apps\LoadGen_ExtraIcons.mif"
+"\epoc32\data\z\Resource\apps\LoadGen.rsc"-"!:\Resource\Apps\LoadGen.rsc"
+"\epoc32\data\z\PRIVATE\10003A3F\APPS\LoadGen_reg.rsc"-"!:\private\10003a3f\import\apps\LoadGen_reg.rsc"
+"..\group\backup_registration.xml"-"!:\private\20011384\backup_registration.xml"
Binary file loadgen/sis/LoadGen_S60-30.sis has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/sis/LoadGen_stub.pkg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,35 @@
+;
+; 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:
+;
+
+; Language - standard language definitions
+&EN
+
+; Standard SIS file header
+#{"LoadGen"},(0x20011384),1,0,0
+
+; Non-localised vendor name
+:"Nokia Corporation"
+
+; Localised vendor names
+%{"Nokia Corporation"}
+
+; normal stuff:
+""-"z:\sys\bin\LoadGen.exe"
+""-"z:\Resource\Apps\LoadGen_aif.mif"
+""-"z:\Resource\Apps\LoadGen_ExtraIcons.mif"
+""-"z:\Resource\Apps\LoadGen.rsc"
+""-"z:\private\10003a3f\import\apps\LoadGen_reg.rsc"
+""-"z:\private\20011384\backup_registration.xml"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/src/loadgen_app.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -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 "loadgen_app.h"
+#include "loadgen_document.h"
+
+#include <eikstart.h>
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CLoadGenApp::AppDllUid()
+// Returns application UID
+// ---------------------------------------------------------
+//
+TUid CLoadGenApp::AppDllUid() const
+    {
+    return KUidLoadGen;
+    }
+
+// ---------------------------------------------------------
+// CDictionaryStore* CLoadGenApp::OpenIniFileLC(RFs& aFs) const
+// overrides CAknApplication::OpenIniFileLC to enable INI file support
+// ---------------------------------------------------------
+//
+CDictionaryStore* CLoadGenApp::OpenIniFileLC(RFs& aFs) const
+    {
+    return CEikApplication::OpenIniFileLC(aFs);
+    }
+   
+// ---------------------------------------------------------
+// CLoadGenApp::CreateDocumentL()
+// Creates CLoadGenDocument object
+// ---------------------------------------------------------
+//
+CApaDocument* CLoadGenApp::CreateDocumentL()
+    {
+    return CLoadGenDocument::NewL( *this );
+    }
+
+// ================= OTHER EXPORTED FUNCTIONS ==============
+
+LOCAL_C CApaApplication* NewApplication()
+    {
+    return new CLoadGenApp;
+    }
+
+
+GLDEF_C TInt E32Main()
+    {
+    return EikStart::RunApplication(NewApplication);
+    }
+   
+
+// End of File  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/src/loadgen_applications.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,686 @@
+/*
+* 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 "loadgen_applications.h"
+#include "loadgen_model.h"
+#include "loadgen.hrh"
+#include <loadgen.rsg>
+
+#include <e32math.h>
+#include "loadgen_traces.h"
+
+_LIT(KThreadName, "Applications %d");
+
+const TInt KDefaultStartDelay = 500;
+const TInt KThreadNameLength = 64;
+const TInt KDescriptorBufSize = 256;
+const TInt KPriorityBufSize = 16;
+const TInt KScanCodeStart = 32;
+    
+// ===================================== MEMBER FUNCTIONS =====================================
+
+CAppLauncher* CAppLauncher::NewL( TApplicationsAttributes& aAttributes, TInt aReferenceNumber )
+    {
+    CAppLauncher* self = new(ELeave) CAppLauncher( aAttributes, aReferenceNumber );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CAppLauncher::~CAppLauncher()
+    {
+    Close();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CAppLauncher::CAppLauncher(  
+           TApplicationsAttributes& aAttributes, TInt aReferenceNumber ) : 
+           iAttributes( aAttributes )
+    {
+    iAttributes.iId = aReferenceNumber;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CAppLauncher::ConstructL()
+    {
+    CLoadBase::ConstructL();
+    
+    iType = ELoadGenCmdNewLoadApplications;
+    
+    TBuf<KThreadNameLength> threadName;
+    threadName.Format( KThreadName, iAttributes.iId );
+    
+    // create a thread
+    User::LeaveIfError( iThread.Create( threadName, ThreadFunction, 
+                                        KDefaultStackSize*2, KMinHeapSize, 
+                                        KKilo * KMinHeapSize, (TAny*) &iAttributes ) );
+    
+    // set priority of the thread
+    SetPriority();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CAppLauncher::ThreadFunction( TAny* aThreadArg )
+    {
+    CTrapCleanup* pC = CTrapCleanup::New();
+    CActiveScheduler* pS = new CActiveScheduler;
+    CActiveScheduler::Install( pS );
+
+    // start generating load, pass pointer to arguments
+    GenerateLoad( *( ( TApplicationsAttributes* ) aThreadArg ) );
+
+    delete pS;
+    delete pC;
+    
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CAppLauncher::GenerateLoad( TApplicationsAttributes& aAttributes )
+    {
+    CAppLauncherManager* appLauncherManager = NULL;
+    TRAPD( err, appLauncherManager = CAppLauncherManager::NewL( aAttributes ) );
+    if ( err == KErrNone ) 
+        {
+        CActiveScheduler::Start();
+        }
+    delete appLauncherManager;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CAppLauncher::Resume()
+    {
+    CLoadBase::Resume();
+    
+    iThread.Resume();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CAppLauncher::Suspend()
+    {
+    CLoadBase::Suspend();
+    
+    iThread.Suspend();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CAppLauncher::SetPriority()
+    {
+    CLoadBase::SetPriority();
+    
+    iThread.SetPriority( CLoadGenModel::SettingItemToThreadPriority( iAttributes.iPriority ) );
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CAppLauncher::Close()
+    {
+    CLoadBase::Close();
+    
+    if ( iThread.ExitReason() == 0 ) // check if the thread is still alive
+        {
+        // signal the thread that it needs to close
+        iThread.RequestComplete( iAttributes.iDeathStatus, KErrCancel );
+
+        // wait the thread to die
+        TRequestStatus waiter;
+        iThread.Logon( waiter );
+        User::WaitForRequest( waiter );
+        iThread.Close();
+        }
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TPtrC CAppLauncher::Description()
+    {
+    TBuf<KDescriptorBufSize> buf;
+    TBuf<KPriorityBufSize> prioBuf;
+    CLoadGenModel::SettingItemToThreadDescription( iAttributes.iPriority, prioBuf );
+    
+    _LIT(KAppLauncherEntry, "[%d] Appls prio=%S max apps=%d heartbeat=%dms random=%d%%");
+    buf.Format( KAppLauncherEntry, iAttributes.iId, &prioBuf, iAttributes.iMaxOpen, 
+                iAttributes.iHeartBeat, iAttributes.iRandomVariance );
+   
+    return TPtrC( buf );
+    }               
+
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+CAppLauncherManager* CAppLauncherManager::NewL( TApplicationsAttributes& aAttributes )
+    {
+    CAppLauncherManager* self = new(ELeave) CAppLauncherManager(aAttributes);
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CAppLauncherManager::CAppLauncherManager( TApplicationsAttributes& aAttributes ) :
+            CActive( EPriorityStandard ), iAttributes( aAttributes )
+    {
+    iAppEventType = EApplicationsLaunchApplication;
+    }
+
+// --------------------------------------------------------------------------------------------
+    
+CAppLauncherManager::~CAppLauncherManager()
+    {
+    if ( iPeriodicTimer )
+        {
+        iPeriodicTimer->Cancel();
+        delete iPeriodicTimer;
+        }
+    delete iLauncherEngine;
+    Cancel();
+    
+    iWsSession.Close();
+    }
+
+// --------------------------------------------------------------------------------------------
+ 
+void CAppLauncherManager::ConstructL()
+    {
+    CActiveScheduler::Add( this );
+    
+    // create instance to application launcher
+    iLauncherEngine = CLauncherEngine::NewL( iAttributes );
+    
+    // set the status as pending
+    iStatus = KRequestPending;
+    SetActive();
+    
+    // set the death status pointer point to the request status of this ao
+    iAttributes.iDeathStatus = &iStatus;
+    
+    // init
+    User::LeaveIfError( iWsSession.Connect() );
+    
+    // start timer    
+    iPeriodicTimer = CPeriodic::NewL( CActive::EPriorityStandard );
+    iPeriodicTimer->Start( KDefaultStartDelay, 
+                           CLoadGenModel::MilliSecondsToMicroSeconds( 
+                               iAttributes.iLaunchingInterval, iAttributes.iRandomVariance ),
+                           TCallBack( PeriodicTimerCallBack, this ) );
+    }
+    
+// --------------------------------------------------------------------------------------------
+ 
+void CAppLauncherManager::RunL()
+    {
+    // request status has completed by the main thread meaning that we need to stop now
+    CActiveScheduler::Stop();
+    }
+
+// --------------------------------------------------------------------------------------------
+ 
+void CAppLauncherManager::DoCancel()
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CAppLauncherManager::PeriodicTimerCallBack( TAny* aAny )
+    {
+    CAppLauncherManager* self = static_cast<CAppLauncherManager*>( aAny );
+
+    TRAPD( err, self->SimulateEventL() );
+    if ( KErrNone != err )
+        {
+        return err;
+        }
+    return KErrNone;
+    }
+    
+// --------------------------------------------------------------------------------------------
+ 
+void CAppLauncherManager::SimulateEventL()
+    {    
+    // Randomly start new applications.
+    // After maximum applications launched stop one application.
+    // And after that start launching again.
+    if ( iAppEventType == EApplicationsLaunchApplication && 
+         iAttributes.iMaxOpen == iLauncherEngine->AppLaunchCounter() )
+        {
+        iAppEventType = EApplicationsCloseApplication;
+        }
+    if ( iAppEventType == EApplicationsCloseApplication && 
+         iAttributes.iMaxOpen -1 == iLauncherEngine->AppLaunchCounter() )
+        {
+        iAppEventType = EApplicationsLaunchApplication;
+        }
+    
+    // Launch or stop
+    if ( iAppEventType == EApplicationsLaunchApplication )
+        {
+        iLauncherEngine->StartAppLaunchingL();
+        }  
+    else
+        {
+        iLauncherEngine->StopApplication( ETrue );
+        }
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+#include <avkon.hrh>
+#include <e32std.h>
+#include <w32std.h>
+#include <apgtask.h>
+#include <bautils.h>
+#include <s32file.h>
+#include <APGWGNAM.H> 
+
+// ---------------------------------------------------------------------------
+
+CLauncherEngine* CLauncherEngine::NewL( TApplicationsAttributes& aAttributes )
+    {
+    CLauncherEngine* self = new(ELeave) CLauncherEngine( aAttributes );
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+
+CLauncherEngine::CLauncherEngine( TApplicationsAttributes& aAttributes ) : 
+                        iAttributes( aAttributes )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::ConstructL()
+    {
+    LOGSTRING("LoadGen: CLauncherEngine::ConstructL");
+    iAppKeyPressManager = CAppKeyPressManager::NewL( iAttributes );
+    iAppLaunchCounter = 0;
+    User::LeaveIfError( iTimer.CreateLocal() );
+
+    User::LeaveIfError( iLs.Connect() );
+    User::LeaveIfError( iWs.Connect() );
+
+    }
+
+// ---------------------------------------------------------------------------
+
+CLauncherEngine::~CLauncherEngine()
+    {
+    LOGSTRING("LoadGen: CLauncherEngine::~CLauncherEngine");
+    StopApplication( EFalse );
+    iWs.Close();
+    iLs.Close();
+    iTimer.Close();
+    delete iAppKeyPressManager;
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::StartAppLaunchingL()
+    {
+    LOGSTRING("LoadGen: CLauncherEngine::StartAppLaunchingL");
+    if ( iAppLaunchCounter == iAttributes.iMaxOpen )
+        {
+        return;
+        }
+
+    // start launching
+    TBool launched( EFalse );
+    while ( !launched )
+        {
+        launched = LaunchApplicationL();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+TBool CLauncherEngine::LaunchApplicationL()
+    {
+    LOGSTRING("LoadGen: CLauncherEngine::LaunchApplicationL");
+    TBool result( EFalse );
+    // get the uid of the current app
+    iCurrentAppUid = KNullUid;
+    TApaAppInfo appInfo;
+    
+    // get application list size
+    TInt appsListSize = iAttributes.iAppsArray->MdcaCount();
+    // get random application number in the list
+    TInt appTolaunch = CLoadGenModel::RandomNumber( 0,  appsListSize - 1 );
+    // get file name of the application to be launched
+    TFileName launchFileName = iAttributes.iAppsArray->MdcaPoint( appTolaunch );
+    iLs.GetAllApps();
+    while ( iLs.GetNextApp( appInfo ) == KErrNone )
+        {
+        // get file name in  current appInfo
+        TFileName appFileName = appInfo.iFullName;
+        // get AppUid
+        if ( appFileName.CompareF( launchFileName ) == 0 )
+            {
+            iCurrentAppUid = appInfo.iUid;
+            break;
+            }
+        }
+
+    if ( iCurrentAppUid != KNullUid )
+        {        
+        // parse the filename
+        TParse nameParser;
+        nameParser.SetNoWild( iAttributes.iAppsArray->MdcaPoint( appTolaunch ), NULL, NULL );
+        iCurrentAppNameAndExt.Copy( nameParser.Drive() );
+        iCurrentAppNameAndExt.Append( nameParser.NameAndExt() );
+           
+        // do not try to launch these apps
+        if ( iCurrentAppUid != KNullUid &&
+              iAttributes.iAppsArray->MdcaPoint( appTolaunch).FindF(_L("\\loadgen.")) == KErrNotFound &&
+              iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\Phone." ) ) == KErrNotFound &&
+              iAttributes.iAppsArray->MdcaPoint( appTolaunch).FindF( _L("\\Startup.") ) == KErrNotFound &&  
+              iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\SplashScreen.") ) == KErrNotFound &&  
+              iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\cameraapp.") ) == KErrNotFound &&
+              iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\eshell.") ) == KErrNotFound &&
+              iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\ConnTest.") ) == KErrNotFound &&
+              iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\Launcher.") ) == KErrNotFound &&
+              
+#ifdef __WINS__
+              iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\DebugAgent.") ) == KErrNotFound &&
+              iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\redirect.") ) == KErrNotFound &&              
+#endif              
+              iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\VoiceRecorder.") ) == KErrNotFound )            
+            {
+        
+            // check if the app is already running
+            TApaTaskList taskList( iWs );
+            TApaTask thisTask = taskList.FindApp( iCurrentAppUid );
+            if ( !thisTask.Exists( ))
+                {
+                // check the program's capabilities
+                TApaAppCapabilityBuf buf;
+                iLs.GetAppCapability( buf, iCurrentAppUid );
+                TApaAppCapability cap = buf();
+        
+                // if it's embeddable only, don't launch if setting is enabled
+                // if it's hidden, don't launch if setting is enabled
+                if ( cap.iEmbeddability != TApaAppCapability::EEmbeddableOnly &&
+                     !cap.iAppIsHidden )
+                    {
+                    LOGSTRING2("launchFileName = %S", &launchFileName);
+                    
+                    DoLaunchApplicationL();
+                    result = ETrue;
+                    }            
+                } 
+            }
+        }
+    return result;
+    }
+
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::DoLaunchApplicationL()
+    {
+    LOGSTRING("LoadGen: CLauncherEngine::DoLaunchApplicationL");
+
+    // Find the task with uid3
+    TApaTaskList tasklist( iWs );
+    TApaTask task=tasklist.FindApp( iCurrentAppUid );
+
+    if ( !task.Exists() )
+        // Task doesn't exist, launch a new instance of an application
+        {
+        TApaAppInfo appInfo;
+        User::LeaveIfError( iLs.GetAppInfo( appInfo, iCurrentAppUid ) );
+        TApaAppCapabilityBuf capBuf;
+        User::LeaveIfError( iLs.GetAppCapability( capBuf, iCurrentAppUid ) );
+        TApaAppCapability& caps = capBuf();
+
+        CApaCommandLine* cmdLine=CApaCommandLine::NewLC();
+        cmdLine->SetExecutableNameL( appInfo.iFullName );
+
+        // app is launched in background
+        cmdLine->SetCommandL( EApaCommandBackground );       
+
+        // start the app
+        User::LeaveIfError( iLs.StartApp( *cmdLine ) );
+        iAppKeyPressManager->AddNewApplicationUidToKeyEventsL( iCurrentAppUid );
+        iAppLaunchCounter++;
+
+        CleanupStack::PopAndDestroy( cmdLine );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+void CLauncherEngine::StopApplication( TBool aRandomApplication )
+    {
+    LOGSTRING("LoadGen: CLauncherEngine::StopApplication");
+
+    // remove key pressing instance
+    TUid appToDelete = iAppKeyPressManager->KillApplication( aRandomApplication );
+    if ( appToDelete != KNullUid )
+        {
+        TApaTaskList taskList( iWs );
+        TApaTask thisTask = taskList.FindApp( appToDelete );
+    
+        if ( thisTask.Exists() )
+            {
+            // since the application is still open, let's close it
+            thisTask.EndTask();
+            }
+        iAppLaunchCounter--;
+        }
+    
+    // return if only one application requested
+    if ( aRandomApplication )
+        {
+        return;
+        }
+    
+    // remove all launched applications because load is requested to be closed
+    while ( appToDelete != KNullUid )
+        {
+        appToDelete = iAppKeyPressManager->KillApplication( aRandomApplication );
+            
+        if ( appToDelete != KNullUid )
+            {
+            TApaTaskList taskList( iWs );
+            TApaTask thisTask = taskList.FindApp( appToDelete );
+        
+            if ( thisTask.Exists() )
+                {
+                // since the application is still open, let's close it
+                thisTask.EndTask();
+                }
+            iAppLaunchCounter--;
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+CAppKeyPressManager* CAppKeyPressManager::NewL( TApplicationsAttributes& aAttributes )
+    {
+    LOGSTRING("LoadGen: CAppKeyPressManager::NewL");
+    CAppKeyPressManager* self = new(ELeave) CAppKeyPressManager( aAttributes );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CAppKeyPressManager::CAppKeyPressManager( TApplicationsAttributes& aAttributes ) :
+                                            iAttributes( aAttributes )
+    {
+    LOGSTRING("LoadGen: CAppKeyPressManager::CAppKeyPressManager");
+    }
+
+// --------------------------------------------------------------------------------------------
+    
+CAppKeyPressManager::~CAppKeyPressManager()
+    {
+    LOGSTRING("LoadGen: CAppKeyPressManager::~CAppKeyPressManager");
+    if ( iKeyPresses.Count() != 0 )
+        {
+        iKeyPresses.ResetAndDestroy();
+        }
+
+    iKeyPresses.Close();
+    }
+
+// --------------------------------------------------------------------------------------------
+ 
+void CAppKeyPressManager::ConstructL()
+    {
+    LOGSTRING("LoadGen: CAppKeyPressManager::ConstructL");
+    }
+    
+   
+// --------------------------------------------------------------------------------------------
+void CAppKeyPressManager::AddNewApplicationUidToKeyEventsL( TUid aUid )
+    {
+    LOGSTRING("LoadGen: CAppKeyPressManager::AddNewApplicationUidToKeyEventsL");
+    CApplicationKeyPresses* applicationKP = CApplicationKeyPresses::NewL( aUid,
+                                                                    iAttributes );
+    CleanupStack::PushL( applicationKP );
+    User::LeaveIfError( iKeyPresses.Append( applicationKP ) );
+    CleanupStack::Pop( applicationKP );
+    }
+
+// --------------------------------------------------------------------------------------------
+TUid CAppKeyPressManager::KillApplication( TBool aRandomApplication )
+    {
+    TUid applicationUid = KNullUid;
+    TInt appToDelete = iKeyPresses.Count() - 1 ;
+    // remove the newest application if not random 
+    if ( aRandomApplication )
+        {
+         appToDelete = CLoadGenModel::RandomNumber( 0, iKeyPresses.Count() - 1 );
+        }
+    if ( iKeyPresses.Count() )
+        {
+        // get random application and delete it
+        
+        applicationUid = iKeyPresses[appToDelete]->ApplicationUid();
+        delete iKeyPresses[appToDelete];
+        iKeyPresses.Remove( appToDelete );
+        }
+    return applicationUid;
+    }
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+CApplicationKeyPresses* CApplicationKeyPresses::NewL( TUid aUid, TApplicationsAttributes&  
+        aAttributes )
+    {
+    LOGSTRING("LoadGen: CApplicationKeyPresses::NewL");
+    CApplicationKeyPresses* self = new(ELeave) CApplicationKeyPresses( aUid, aAttributes );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CApplicationKeyPresses::CApplicationKeyPresses( TUid aUid, 
+                                                        TApplicationsAttributes& aAttributes ) :
+                                                iUid( aUid ), iAttributes( aAttributes ) 
+    {
+    LOGSTRING("LoadGen: CApplicationKeyPresses::CApplicationKeyPresses");
+    }
+
+// --------------------------------------------------------------------------------------------
+    
+CApplicationKeyPresses::~CApplicationKeyPresses()
+    {
+    LOGSTRING("LoadGen: CApplicationKeyPresses::~CApplicationKeyPresses");
+    if ( iPeriodicTimer )
+        {
+        iPeriodicTimer->Cancel();
+        delete iPeriodicTimer;
+        }
+    
+    iWsSession.Close();
+    }
+
+// --------------------------------------------------------------------------------------------
+ 
+void CApplicationKeyPresses::ConstructL()
+    {
+    LOGSTRING("LoadGen: CApplicationKeyPresses::ConstructL");
+    // init
+    User::LeaveIfError( iWsSession.Connect() );
+    
+    // start timer    
+    iPeriodicTimer = CPeriodic::NewL( CActive::EPriorityStandard );
+    if ( iAttributes.iKeyPressType )
+        {
+        iPeriodicTimer->Start( KDefaultStartDelay,
+                               CLoadGenModel::MilliSecondsToMicroSeconds( 
+                                       iAttributes.iHeartBeat,
+                                       iAttributes.iRandomVariance ),
+                                TCallBack( PeriodicTimerCallBack, this ) );
+        }
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TInt CApplicationKeyPresses::PeriodicTimerCallBack( TAny* aAny )
+    {
+    CApplicationKeyPresses* self = static_cast<CApplicationKeyPresses*>( aAny );
+    self->SimulateKeyEvent();
+    return KErrNone;
+    }
+    
+// --------------------------------------------------------------------------------------------
+ 
+void CApplicationKeyPresses::SimulateKeyEvent()
+    {
+    LOGSTRING("LoadGen: CApplicationKeyPresses::SimulateKeyEvent");
+    // for arrow key events
+    
+    TInt wgId(0);
+    CApaWindowGroupName::FindByAppUid( iUid, iWsSession, wgId );
+    // generate a random arrow key event
+    TWsEvent event;
+    event.SetType( EEventKey );
+    event.Key()->iCode = CLoadGenModel::RandomNumber( EKeyLeftArrow, EKeyDownArrow );
+    event.Key()->iScanCode = event.Key()->iCode - KScanCodeStart;
+    event.Key()->iModifiers = 0;
+    event.Key()->iRepeats = 0;
+    iWsSession.SendEventToWindowGroup( wgId, event );
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/src/loadgen_appui.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,158 @@
+/*
+* 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 "loadgen_appui.h"
+#include "loadgen_mainview.h"
+#include "loadgen.hrh"
+#include "loadgen_model.h"
+#include "loadgen_document.h"
+#include <loadgen.rsg>
+
+#include <avkon.hrh>
+#include <aknquerydialog.h>
+#include <aknmessagequerydialog.h> 
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+void CLoadGenAppUi::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<CLoadGenDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model();
+
+    CLoadGenMainView* mainView = new(ELeave) CLoadGenMainView;
+    CleanupStack::PushL(mainView);
+    mainView->ConstructL();
+    AddViewL(mainView);           // transfer ownership to CAknViewAppUi
+    CleanupStack::Pop();          // mainView
+    
+    SetDefaultViewL(*mainView);
+
+    // notify the model that everything has been constructed
+    iModel->ActivateModelL();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenAppUi::~CLoadGenAppUi()
+    {
+    // notify the model that the application is closing 
+    if (iModel)   
+        TRAP_IGNORE(iModel->DeActivateModelL());
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenAppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
+    {
+    if (aResourceId == R_LOADGEN_APP_MENU)
+        {
+        aMenuPane->SetItemDimmed(ELoadGenStopAll, !iModel->LoadItemsExists());
+        aMenuPane->SetItemDimmed(ELoadGenSuspendAll, !iModel->LoadItemsExists());
+        aMenuPane->SetItemDimmed(ELoadGenResumeAll, !iModel->LoadItemsExists());
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TKeyResponse CLoadGenAppUi::HandleKeyEventL(const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/)
+    {
+    return EKeyWasNotConsumed;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenAppUi::HandleCommandL(TInt aCommand)
+    {
+    switch ( aCommand )
+        {
+        case ELoadGenCmdLaunchPerfMon:
+            {
+            // launch Performance Monitor
+            const TUid KUidPerfMon = { 0x20011385 };
+            
+            RWsSession ws;
+            User::LeaveIfError( ws.Connect() );
+            CleanupClosePushL(ws);
+            
+            RApaLsSession ls;
+            User::LeaveIfError( ls.Connect() );
+            CleanupClosePushL(ls);
+            
+            
+            // try to find the task of PerfMon
+            TApaTaskList tasklist(ws);
+            TApaTask task = tasklist.FindApp(KUidPerfMon);
+
+            if (task.Exists())
+                {
+                // task exists, bring it to foreground
+                task.BringToForeground();
+                }
+            else
+                {
+                TApaAppInfo appInfo;
+                User::LeaveIfError(ls.GetAppInfo(appInfo, KUidPerfMon));
+                
+                CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
+                cmdLine->SetExecutableNameL(appInfo.iFullName);
+                cmdLine->SetCommandL(EApaCommandBackground);
+
+                // start the app
+                User::LeaveIfError(ls.StartApp(*cmdLine));
+                
+                CleanupStack::PopAndDestroy(); //cmdLine                
+                }
+            
+            CleanupStack::PopAndDestroy(2); //ws,ls
+            }
+            break;
+            
+        case ELoadGenCmdAbout:
+            {
+            CAknMessageQueryDialog* dialog = new(ELeave) CAknMessageQueryDialog;
+            dialog->ExecuteLD(R_LOADGEN_ABOUT_DIALOG);
+            }
+            break;
+            
+        // a normal way to close an application
+        case EAknCmdExit:
+        case EEikCmdExit:
+        case EAknSoftkeyExit: 
+            {
+            Exit();
+            }
+            break;
+
+        default:
+            break;      
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/src/loadgen_bluetooth.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,339 @@
+/*
+* 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 "loadgen_bluetooth.h"
+#include "loadgen_model.h"
+#include "loadgen.hrh"
+#include "loadgen_traces.h"
+#include <loadgen.rsg>
+#include <e32hal.h>
+#include <u32hal.h>
+#include <e32math.h>
+#include <EIKENV.H>
+#include <btserversdkcrkeys.h>
+#include <BtnotifierAPI.h>
+#include <btpm.h>
+
+_LIT(KThreadName, "Bluetooth %d");
+_LIT(KBTLinkManagerStr, "BTLinkManager");
+
+const TInt KDefaultStart = 50;
+const TInt KDefaultPeriod = 5000000;
+   
+// ===================================== MEMBER FUNCTIONS =====================================
+
+CBluetooth* CBluetooth::NewL(TBluetoothAttributes& aAttributes, TInt aReferenceNumber)
+    {
+    CBluetooth* self = new(ELeave) CBluetooth(aAttributes, aReferenceNumber);
+    CleanupStack::PushL(self);
+    TRAPD(err, self->ConstructL());
+    if( err != KErrNone )
+        {
+        User::Leave(err);
+        }
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CBluetooth::~CBluetooth()
+    {
+    Close();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CBluetooth::CBluetooth(TBluetoothAttributes& aAttributes, TInt aReferenceNumber) : iAttributes(aAttributes)
+    {
+    iAttributes.iId = aReferenceNumber;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CBluetooth::ConstructL()
+    {    
+    CLoadBase::ConstructL();
+    
+    iType = ELoadGenCmdNewLoadBluetooth;
+    
+    InitializeBluetoothL();
+                        
+    TBuf<64> threadName;
+    threadName.Format(KThreadName, iAttributes.iId);
+            
+    // create a thread
+    User::LeaveIfError(iThread.Create(threadName, ThreadFunction, KDefaultStackSize*2, KMinHeapSize, 1024*KMinHeapSize, (TAny*) &iAttributes ));
+    
+    // set priority of the thread
+    SetPriority();
+    iState = ELoadStateConstructed;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CBluetooth::ThreadFunction(TAny* aThreadArg)
+    {
+    TInt err = KErrNone;
+    
+    CTrapCleanup* pC = CTrapCleanup::New();
+    CActiveScheduler* pS = new CActiveScheduler;
+    CActiveScheduler::Install(pS);
+
+    // start generating load, pass pointer to arguments
+    GenerateLoad(*((TBluetoothAttributes*) aThreadArg));
+
+    delete pS;
+    delete pC;
+    
+    return err;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CBluetooth::GenerateLoad(TBluetoothAttributes& aAttributes)
+    {    
+    CBTManager* btManager = 0;
+    TRAPD(err, btManager = CBTManager::NewL(aAttributes));
+    if (err == KErrNone) CActiveScheduler::Start();
+    delete btManager;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CBluetooth::Resume()
+    {    
+    CLoadBase::Resume();    
+    iThread.Resume();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CBluetooth::Suspend()
+    {
+    CLoadBase::Suspend();    
+    iThread.Suspend();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CBluetooth::SetPriority()
+    {
+    CLoadBase::SetPriority();    
+    iThread.SetPriority(CLoadGenModel::SettingItemToThreadPriority(iAttributes.iPriority));
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CBluetooth::Close()
+    {
+    LOGSTRING2("LoadGen: CBluetooth::~CBluetooth() - State: %d", iState);
+    if( iState != ELoadStateInvalid )
+        {
+        CLoadBase::Close();        
+        // kill the thread immediately
+        iThread.Kill(0);
+        iThread.Close();
+        }
+    }
+    
+// --------------------------------------------------------------------------------------------
+TPtrC CBluetooth::Description()
+    {
+    TBuf<256> buf;
+    TBuf<16> prioBuf;
+    CLoadGenModel::SettingItemToThreadDescription(iAttributes.iPriority, prioBuf);
+        
+    _LIT(KBluetoothEntry, "[%d] Bluetooth prio=%S idle=%dms random=%d%%");
+    buf.Format(KBluetoothEntry, iAttributes.iId, &prioBuf, iAttributes.iIdle, iAttributes.iRandomVariance);
+       
+    return TPtrC(buf);
+    }
+
+// --------------------------------------------------------------------------------------------
+void CBluetooth::InitializeBluetoothL()
+    {
+    // Create central repository for checking and setting bluetooth power state    
+    CRepository* btPowerStateCRepo = CRepository::NewL(KCRUidBluetoothPowerState);
+    
+    // Check if the BT is already turned on:    
+    TInt btPowerState = 0;
+    btPowerStateCRepo->Get(KBTPowerState, btPowerState);
+    delete btPowerStateCRepo;
+    btPowerStateCRepo = 0;
+        
+    if(btPowerState == EBTPowerOff)
+        {
+        // Switch bt power on:
+        if (SetBTPowerState(ETrue) == EFalse)
+            {
+            LOGSTRING("LoadGen: Bluetooth could not be switched on");
+            User::Leave(KErrNotReady);
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+TBool CBluetooth::SetBTPowerState(TBool aState)
+    {    
+    // Ask user to turn on the bluetooth device:
+    RNotifier btPowerNotifier;
+    TInt errCode = btPowerNotifier.Connect();
+    
+    TBool retVal = errCode == KErrNone;
+    
+    if( errCode == KErrNone )
+        {
+        TPckgBuf<TBool> powerRequest(aState);
+        TPckgBuf<TBool> powerReply(EFalse);
+        TRequestStatus powerRequestStatus;
+        btPowerNotifier.StartNotifierAndGetResponse(powerRequestStatus, 
+                                                KPowerModeSettingNotifierUid, 
+                                                powerRequest, 
+                                                powerReply);
+        User::WaitForRequest(powerRequestStatus);
+        btPowerNotifier.CancelNotifier(KPowerModeSettingNotifierUid);
+        btPowerNotifier.Close();  
+        if( powerReply() == EFalse )
+            {
+            LOGSTRING("LoadGen: Bluetooth activating cancelled.");
+            }
+        retVal = powerReply();
+        }
+    
+    return retVal; 
+    }
+
+// --------------------------------------------------------------------------------------------
+CBTManager* CBTManager::NewL(   TBluetoothAttributes& aAttrs)
+    {
+    CBTManager* self = new (ELeave) CBTManager( aAttrs);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+ 
+// --------------------------------------------------------------------------------------------
+CBTManager::~CBTManager()
+    {    
+    if (iPeriodicTimer)
+        {
+        iPeriodicTimer->Cancel();
+        delete iPeriodicTimer;
+        }    
+    iHostResolver.Close();        
+    Cancel();
+    }
+ 
+// --------------------------------------------------------------------------------------------
+CBTManager::CBTManager( TBluetoothAttributes& aAttrs) 
+: 
+CActive(EPriorityStandard),
+iAttributes(aAttrs)
+    {    
+    }
+ 
+// --------------------------------------------------------------------------------------------
+void CBTManager::ConstructL()
+    {
+    // Socket server session initiation:
+    User::LeaveIfError(iSocketServerHnd.Connect());    
+
+    CActiveScheduler::Add(this);
+    // set the status as pending
+    iStatus = KRequestPending;
+    SetActive();
+        
+    // set the death status pointer point to the request status of this ao
+    iAttributes.iDeathStatus = &iStatus;
+    
+    // start timer    
+    iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard);
+    iPeriodicTimer->Start(KDefaultStart, KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this));
+    }
+
+// --------------------------------------------------------------------------------------------
+void CBTManager::DoCancel()
+    {
+    LOGSTRING("LoadGen: CBTManager::DoCancel()");    
+    }
+
+// --------------------------------------------------------------------------------------------
+void CBTManager::RunL()
+    {    
+    // request status has completed by the main thread meaning that we need to stop now
+    CActiveScheduler::Stop();    
+    }
+
+// --------------------------------------------------------------------------------------------
+TInt CBTManager::StartBTDeviceDiscovery()
+    {
+    TInt retVal = KErrNone; 
+    RThread myThread;
+           
+    // Initialize host resolver      
+    iHostResolver.Close();        
+    TProtocolDesc protocolInfo;
+    retVal = iSocketServerHnd.FindProtocol(KBTLinkManagerStr(), protocolInfo);
+    if( retVal == KErrNone )
+        {
+        retVal = iHostResolver.Open(iSocketServerHnd, protocolInfo.iAddrFamily, protocolInfo.iProtocol);        
+        }
+    
+    if( retVal == KErrNone )
+        {
+        TInquirySockAddr socketAddress;
+        socketAddress.SetIAC( KGIAC );
+        socketAddress.SetAction(KHostResInquiry|KHostResName|KHostResIgnoreCache);
+        retVal = iHostResolver.GetByAddress(socketAddress, iBTNameEntry);        
+        // Loop all discovered devices:
+        while( retVal == KErrNone )        
+            {
+            LOGSTRING3("LoadGen: Thread %S found device: %S", &(myThread.Name()), &(iBTNameEntry().iName) );
+            // Get next device
+            retVal = iHostResolver.Next(iBTNameEntry);            
+            }
+        }
+    
+    // KErrEof is returned when no more devices to loop
+    if( retVal == KErrEof )
+        {
+        retVal = KErrNone;
+        }
+            
+    iPeriodicTimer->Start( CLoadGenModel::MilliSecondsToMicroSeconds( iAttributes.iIdle,
+                        iAttributes.iRandomVariance ), KDefaultPeriod, 
+                        TCallBack( PeriodicTimerCallBack, this ) );
+
+    return retVal;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CBTManager::PeriodicTimerCallBack(TAny* aAny)
+    {        
+    CBTManager* self = static_cast<CBTManager*>( aAny );
+    self->iPeriodicTimer->Cancel();
+    // Perform device discovery:
+    self->StartBTDeviceDiscovery();
+    return KErrNone;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/src/loadgen_cpuload.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,266 @@
+/*
+* 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 "loadgen_cpuload.h"
+#include "loadgen_model.h"
+#include "loadgen.hrh"
+#include <loadgen.rsg>
+#include <e32hal.h>
+#include <u32hal.h>
+#include <e32math.h>
+
+_LIT(KThreadName, "CPULoad %d");
+    
+// ===================================== MEMBER FUNCTIONS =====================================
+
+CCPULoad* CCPULoad::NewL(TCPULoadAttributes& aAttributes, TInt aReferenceNumber)
+    {
+    CCPULoad* self = new(ELeave) CCPULoad(aAttributes, aReferenceNumber);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CCPULoad::~CCPULoad()
+    {
+    Close();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CCPULoad::CCPULoad(TCPULoadAttributes& aAttributes, TInt aReferenceNumber) : iAttributes(aAttributes)
+    {
+    iAttributes.iId = aReferenceNumber;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CCPULoad::ConstructL()
+    {
+    CLoadBase::ConstructL();
+    
+    iType = ELoadGenCmdNewLoadCPULoad;
+    
+    TBuf<64> threadName;
+    threadName.Format(KThreadName, iAttributes.iId);
+    
+    // create a thread
+    User::LeaveIfError(iThread.Create(threadName, ThreadFunction, KDefaultStackSize*2, KMinHeapSize, 1024*KMinHeapSize, (TAny*) &iAttributes ));
+    
+    // set priority of the thread
+    SetPriority();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CCPULoad::ThreadFunction(TAny* aThreadArg)
+    {
+    TCPULoadAttributes* threadArg = (TCPULoadAttributes*)aThreadArg;
+    TInt err = KErrNone;
+
+    // if a cpu is defined, tie this thread to the given cpu (SMP environment)
+    if (threadArg->iCpu >= 0 && threadArg->iCpu != KCPUSelection_AllCPUs )
+        {
+        UserSvr::HalFunction(EHalGroupKernel, KHalFunction_EKernelHalLockThreadToCpu, (TAny*) threadArg->iCpu, 0);
+        }
+    
+    CTrapCleanup* pC = CTrapCleanup::New();
+    CActiveScheduler* pS = new CActiveScheduler;
+    CActiveScheduler::Install(pS);
+
+    // start generating load, pass pointer to arguments
+    GenerateLoad(*((TCPULoadAttributes*) aThreadArg));
+
+    delete pS;
+    delete pC;
+    
+    return err;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CCPULoad::GenerateLoad(TCPULoadAttributes& aAttributes)
+    {
+    for (;;)
+        {   
+        if (aAttributes.iType == ECpuLoadTypeContinuous)
+            {
+            // do constantly heave stuff
+            DoHeaveStuff(aAttributes.iMode);
+            }
+
+        else if (aAttributes.iType == ECpuLoadTypePeriodic)
+            {
+            // do periodically heave stuff
+            TTime startTime;
+            startTime.HomeTime(); // get start time
+
+            TTime currentTime;
+            TTimeIntervalMicroSeconds interval;
+            
+            TInt processPeriod = CLoadGenModel::MilliSecondsToMicroSeconds(aAttributes.iLength, aAttributes.iRandomVariance);
+
+            do
+                {
+                // do heave stuff
+                DoHeaveStuff(aAttributes.iMode);
+
+                currentTime.HomeTime();
+                interval = currentTime.MicroSecondsFrom(startTime);                
+                }
+            while (interval.Int64() < processPeriod);       
+
+
+            // now wait
+            User::After( CLoadGenModel::MilliSecondsToMicroSeconds(aAttributes.iIdle, aAttributes.iRandomVariance) );
+            }   
+
+        else
+            {
+            User::Panic(_L("Unk.type"), 888);
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CCPULoad::DoHeaveStuff(TInt aMode)
+    {
+    TTime now;
+    now.HomeTime();
+    TInt64 seed = now.Int64();
+    
+    TReal random = Math::FRand(seed);
+    
+    TReal target(10);
+    TReal source(10);
+    
+    target += random;
+    
+    Math::Cos(target, source);
+    
+    source = source / 1.0382873;
+    source -= 32.24343;
+    source += 132.24343;
+    source *= random;
+    
+    // yield trick
+    if (aMode == ECpuLoadModeYielding)
+        {
+        // sleep randomly
+        if (User::TickCount() % 50 == 0)
+            User::AfterHighRes(1);            
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CCPULoad::Resume()
+    {
+    CLoadBase::Resume();
+    
+    iThread.Resume();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CCPULoad::Suspend()
+    {
+    CLoadBase::Suspend();
+    
+    iThread.Suspend();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CCPULoad::SetPriority()
+    {
+    CLoadBase::SetPriority();
+    
+    iThread.SetPriority(CLoadGenModel::SettingItemToThreadPriority(iAttributes.iPriority));
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CCPULoad::Close()
+    {
+    CLoadBase::Close();
+
+    // kill the thread immediately
+    iThread.Kill(0);   
+
+    iThread.Close();
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TPtrC CCPULoad::Description()
+    {
+    TBuf<256> buf;
+    TBuf<16> prioBuf;
+    CLoadGenModel::SettingItemToThreadDescription(iAttributes.iPriority, prioBuf);
+    
+    if (iAttributes.iType == ECpuLoadTypeContinuous)
+        {
+        if (iAttributes.iMode == ECpuLoadModeYielding)
+            {
+            _LIT(KCPULoadEntryContinuous, "[%d] CPULoad prio=%S mode=yielding type=cont");
+            buf.Format(KCPULoadEntryContinuous, iAttributes.iId, &prioBuf);
+            }
+        else if (iAttributes.iMode == ECpuLoadModeBlocking)
+            {
+            _LIT(KCPULoadEntryContinuous, "[%d] CPULoad prio=%S mode=blocking type=cont");
+            buf.Format(KCPULoadEntryContinuous, iAttributes.iId, &prioBuf);
+            }
+        }
+    
+    else if (iAttributes.iType == ECpuLoadTypePeriodic)
+        {
+        if (iAttributes.iMode == ECpuLoadModeYielding)
+            {
+            _LIT(KCPULoadEntryPeriodic, "[%d] CPULoad prio=%S mode=yielding type=period peak=%dms idle=%dms random=%d%%");
+            buf.Format(KCPULoadEntryPeriodic, iAttributes.iId, &prioBuf, iAttributes.iLength, iAttributes.iIdle, iAttributes.iRandomVariance);
+            }        
+        else if (iAttributes.iMode == ECpuLoadModeBlocking)
+            {
+            _LIT(KCPULoadEntryPeriodic, "[%d] CPULoad prio=%S mode=blocking type=period peak=%dms idle=%dms random=%d%%");
+            buf.Format(KCPULoadEntryPeriodic, iAttributes.iId, &prioBuf, iAttributes.iLength, iAttributes.iIdle, iAttributes.iRandomVariance);
+            }        
+        }
+    
+    // if we are running a load in a specific cpu, add the "name" of the
+    // cpu to the description. (SMP environment)
+    if (iAttributes.iCpu >= 0 && iAttributes.iCpu != KCPUSelection_AllCPUs)
+        {
+        TBuf<15> cpu;
+        _LIT(KCPU, " CPU%d");
+        cpu.Format(KCPU, iAttributes.iCpu);
+        buf.Append(cpu);
+        }
+    
+    return TPtrC(buf);
+    }               
+
+// --------------------------------------------------------------------------------------------
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/src/loadgen_document.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -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 "loadgen_document.h"
+#include "loadgen_appui.h"
+#include "loadgen_model.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// constructor
+CLoadGenDocument::CLoadGenDocument(CEikApplication& aApp)
+: CAknDocument(aApp)    
+    {
+    }
+
+// ----------------------------------------------------
+
+// destructor
+CLoadGenDocument::~CLoadGenDocument()
+    {
+    delete iModel;
+    }
+
+// ----------------------------------------------------
+
+// EPOC default constructor can leave.
+void CLoadGenDocument::ConstructL()
+    {
+    iModel = CLoadGenModel::NewL();
+    }
+
+// ----------------------------------------------------
+
+// Two-phased constructor.
+CLoadGenDocument* CLoadGenDocument::NewL(CEikApplication& aApp)
+    {
+    CLoadGenDocument* self = new(ELeave) CLoadGenDocument(aApp);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+    
+// ----------------------------------------------------
+// CLoadGenDocument::CreateAppUiL()
+// constructs CLoadGenAppUi
+// ----------------------------------------------------
+//
+CEikAppUi* CLoadGenDocument::CreateAppUiL()
+    {
+    return new (ELeave) CLoadGenAppUi;
+    }
+
+// ----------------------------------------------------
+// CLoadGenDocument::OpenFileL
+// Overrides CAknDocument::OpenFileL to support document file
+// ----------------------------------------------------
+//
+CFileStore* CLoadGenDocument::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/loadgen/src/loadgen_editors.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,1437 @@
+/*
+* 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 "loadgen_editors.h"
+#include "loadgen_loadattributes.h"
+#include "loadgen.hrh"
+#include <loadgen.rsg>
+
+#include <aknform.h> 
+#include <eikedwin.h> 
+#include <eikmfne.h>
+#include <aknpopupfieldtext.h>
+#include <aknqueryvaluetext.h>
+#include <eikspane.h> 
+#include <akntitle.h> 
+#include <eikcapc.h>
+#include <e32hal.h> 
+
+// ===================================== MEMBER FUNCTIONS =====================================
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenLoadTypeEditorBase::CLoadGenLoadTypeEditorBase(TBool aEditingExisting):
+    iEditingExisting(aEditingExisting)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenLoadTypeEditorBase::ConstructL(const TDesC& aTitleText)
+    {
+    CAknForm::ConstructL();
+
+    // set title text
+    CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
+    CAknTitlePane* tp = static_cast<CAknTitlePane*>( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
+    tp->SetTextL( aTitleText );
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenLoadTypeEditorBase::PreLayoutDynInitL()
+    {
+    CAknForm::PreLayoutDynInitL();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TBool CLoadGenLoadTypeEditorBase::OkToExitL(TInt /*aButtonId*/)
+    {
+    return ETrue;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(TInt aControlId)
+    {
+    CAknForm::HandleControlStateChangeL(aControlId);
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TBool CLoadGenLoadTypeEditorBase::RunQueryLD()
+    {
+    User::Panic(_L("Unk.form"), 222);
+    
+    return ETrue;
+    }
+               
+// --------------------------------------------------------------------------------------------
+
+TBool CLoadGenLoadTypeEditorBase::DoRunQueryLD(TInt aResource)
+    {
+    return ExecuteLD(aResource);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenLoadTypeEditorBase::InsertFieldAfterL(TInt aResourceId, TInt aControlId, TInt aPrevControlId)
+    {
+    CCoeControl* prevControl = Control(aPrevControlId);
+    __ASSERT_DEBUG(prevControl, User::Panic(_L("Form.Ctrl.Null"), 111));
+    TInt pos = FindLineIndex(*prevControl);
+    pos = pos + 1;
+    InsertLineL(pos, aResourceId);
+    Line(aControlId)->ActivateL();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenLoadTypeEditorBase::UpdateFormL()
+    {
+    UpdatePageL(ETrue);
+    }
+               
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+CLoadGenCPULoadEditor* CLoadGenCPULoadEditor::NewL(TCPULoadAttributes& aAttributes, TBool aEditingExisting)
+    {
+    CLoadGenCPULoadEditor* self = new(ELeave) CLoadGenCPULoadEditor(aAttributes, aEditingExisting);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenCPULoadEditor::~CLoadGenCPULoadEditor()
+    {
+    delete iCpuQueryValText;
+    delete iCpuTextArray;
+    delete iCPUsArray;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenCPULoadEditor::CLoadGenCPULoadEditor(TCPULoadAttributes& aAttributes, TBool aEditingExisting) :
+    CLoadGenLoadTypeEditorBase(aEditingExisting), iAttributes(aAttributes)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenCPULoadEditor::ConstructL()
+    {
+    CLoadGenLoadTypeEditorBase::ConstructL(_L("CPU load"));
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenCPULoadEditor::PreLayoutDynInitL()
+    {
+    CLoadGenLoadTypeEditorBase::PreLayoutDynInitL();
+
+    // load values to static editors
+    CAknPopupFieldText* edPriority = static_cast<CAknPopupFieldText*>(Control(ELoadGenCPULoadQueryPriority));
+    CAknPopupFieldText* edMode = static_cast<CAknPopupFieldText*>(Control(ELoadGenCPULoadQueryMode));
+    CAknPopupFieldText* edType = static_cast<CAknPopupFieldText*>(Control(ELoadGenCPULoadQueryType));
+    edPriority->SetCurrentValueIndex(iAttributes.iPriority);
+    edMode->SetCurrentValueIndex(iAttributes.iMode);
+    edType->SetCurrentValueIndex(iAttributes.iType);
+    
+    LoadCPUsL();
+
+    UpdateVisibilitiesOfFieldsL(ETrue);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenCPULoadEditor::LoadCPUsL()
+    {
+    // if we are running in SMP environment
+    if (iAttributes.iCpuCount > 1)
+        {
+        // insert possibility to select which cpu the load is generated to
+        InsertFieldAfterL(R_CPULOAD_DLG_LINE_CPU, ELoadGenCPULoadQueryCpu, ELoadGenCPULoadQueryType);
+
+        iCPUsArray = new (ELeave) CDesCArrayFlat( 5 );
+        
+        // "Free scheduling" means that no specific cpu is selected. Scheduler desides
+        // which CPUu runs load thread at which time.
+        iCPUsArray->AppendL(_L("Free scheduling"));
+        
+        // add CPUs
+        for (int i = 0; i < iAttributes.iCpuCount; i++) 
+            {
+            TBuf<10> cpu;
+            _LIT(KCPU, "CPU%d");
+            cpu.Format(KCPU, i);
+            iCPUsArray->AppendL(cpu);
+            }
+        
+        // "All CPUs" means that one thread is started for each CPU.
+        iCPUsArray->AppendL(_L("All CPUs"));
+    
+        iCpuTextArray = CAknQueryValueTextArray::NewL();
+        iCpuTextArray->SetArray( *iCPUsArray );  
+        iCpuQueryValText = CAknQueryValueText::NewL();    
+        iCpuQueryValText->SetArrayL( iCpuTextArray );
+        // CPU is not defined, set "Free scheduling" as default selection in query list
+        if (iAttributes.iCpu < 0)
+            {
+            iCpuQueryValText->SetCurrentValueIndex(0);
+            }
+        // "All CPUs" selected. It is last choise in the selection list.
+        else if (iAttributes.iCpu == KCPUSelection_AllCPUs)
+            {
+            iCpuQueryValText->SetCurrentValueIndex(iCpuTextArray->MdcaCount()-1);
+            }
+        // CPU is defined, set the correct CPU as default selection in query list
+        else
+            {
+            // iCpu starts from zero (i.e. CPU0 is first CPU), but index zero
+            // in iCpuQueryValText is "Free scheduling", hence iCpu+1.
+            iCpuQueryValText->SetCurrentValueIndex(iAttributes.iCpu+1);
+            }
+
+        CAknPopupField* popup = static_cast<CAknPopupField*>(Control( ELoadGenCPULoadQueryCpu)); 
+        popup->SetQueryValueL( iCpuQueryValText );
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TBool CLoadGenCPULoadEditor::OkToExitL(TInt aButtonId)
+    {
+    if (aButtonId == EAknSoftkeyOk)
+        {
+        // store values from editors
+        CAknPopupFieldText* edPriority = static_cast<CAknPopupFieldText*>(Control(ELoadGenCPULoadQueryPriority));
+        CAknPopupFieldText* edMode = static_cast<CAknPopupFieldText*>(Control(ELoadGenCPULoadQueryMode));
+        CAknPopupFieldText* edType = static_cast<CAknPopupFieldText*>(Control(ELoadGenCPULoadQueryType));
+        CEikNumberEditor* edPeak = static_cast<CEikNumberEditor*>(ControlOrNull(ELoadGenCPULoadQueryLength));
+        CEikNumberEditor* edIdle = static_cast<CEikNumberEditor*>(ControlOrNull(ELoadGenCPULoadQueryIdle));
+        CEikNumberEditor* edVariance = static_cast<CEikNumberEditor*>(ControlOrNull(ELoadGenCPULoadQueryVariance));
+        
+        // we are running in SMP environment
+        if (iAttributes.iCpuCount > 1)
+            {
+            TInt currentValueIndex = iCpuQueryValText->CurrentValueIndex();
+            // user selected a specific CPU in which the load thread should be run in.
+            if (currentValueIndex == 0)
+                {
+                // User selected "Free scheduling"
+                iAttributes.iCpu = KCPUSelection_FreeScheduling;
+                }            
+            else if( currentValueIndex == iCpuTextArray->MdcaCount()-1 )
+                {
+                // User selected "All CPUs", which is the last item in the selection list
+                iAttributes.iCpu = KCPUSelection_AllCPUs;
+                }
+            else
+                {                
+                // iCpu should start from zero (CPU0 is the first cpu)
+                // but zero in currentValueIndex means "Free scheduling". CPU0 in
+                // currentValueIndex is at index 1, hence -1.
+                iAttributes.iCpu = currentValueIndex - 1;
+                }
+            }
+
+        iAttributes.iPriority = edPriority->CurrentValueIndex();
+        iAttributes.iMode = edMode->CurrentValueIndex();
+        iAttributes.iType = edType->CurrentValueIndex();
+        if (edPeak) iAttributes.iLength = edPeak->Number();
+        if (edIdle) iAttributes.iIdle = edIdle->Number();
+        if (edVariance) iAttributes.iRandomVariance = edVariance->Number();
+        }
+    
+    return ETrue;
+    }       
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenCPULoadEditor::UpdateVisibilitiesOfFieldsL(TBool aFormInit)
+    {
+    // filter based on selected cpu load type
+    CAknPopupFieldText* edType = static_cast<CAknPopupFieldText*>( Control( ELoadGenCPULoadQueryType ) );
+
+    if ( !aFormInit && edType->CurrentValueIndex() == ECpuLoadTypeContinuous )
+        {
+        // save values before deleting the items
+        CCoeControl* control = ControlOrNull( ELoadGenCPULoadQueryLength );
+        if ( control )
+            {
+            CEikNumberEditor* edPeak = static_cast<CEikNumberEditor*>( control );
+            iAttributes.iLength = edPeak->Number();
+            DeleteLine( ELoadGenCPULoadQueryLength );
+            control = NULL;
+            }
+        control = ControlOrNull( ELoadGenCPULoadQueryIdle );
+        if ( control )
+            {
+            CEikNumberEditor* edIdle = static_cast<CEikNumberEditor*>( control );
+            iAttributes.iIdle = edIdle->Number();
+            DeleteLine( ELoadGenCPULoadQueryIdle );
+            control = NULL;
+            }
+        control = ControlOrNull( ELoadGenCPULoadQueryVariance );
+        if ( control )
+            {
+            CEikNumberEditor* edVariance = static_cast<CEikNumberEditor*>( control );
+            iAttributes.iRandomVariance = edVariance->Number();
+            DeleteLine( ELoadGenCPULoadQueryVariance );
+            }
+        }
+    else if ( edType->CurrentValueIndex() == ECpuLoadTypePeriodic )
+        {
+        // insert new fields
+        InsertFieldAfterL(R_CPULOAD_DLG_LINE_PERIODIC_LENGTH, ELoadGenCPULoadQueryLength, ELoadGenCPULoadQueryType);
+        InsertFieldAfterL(R_CPULOAD_DLG_LINE_PERIODIC_IDLE, ELoadGenCPULoadQueryIdle, ELoadGenCPULoadQueryLength);
+        InsertFieldAfterL(R_CPULOAD_DLG_LINE_PERIODIC_VARIANCE, ELoadGenCPULoadQueryVariance, ELoadGenCPULoadQueryIdle);
+        
+        // load values to just created editors
+        CEikNumberEditor* edPeak = static_cast<CEikNumberEditor*>(Control(ELoadGenCPULoadQueryLength));
+        CEikNumberEditor* edIdle = static_cast<CEikNumberEditor*>(Control(ELoadGenCPULoadQueryIdle));
+        CEikNumberEditor* edVariance = static_cast<CEikNumberEditor*>(Control(ELoadGenCPULoadQueryVariance));
+        edPeak->SetNumber(iAttributes.iLength);
+        edIdle->SetNumber(iAttributes.iIdle);
+        edVariance->SetNumber(iAttributes.iRandomVariance);
+        }
+
+    UpdateFormL();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenCPULoadEditor::HandleControlStateChangeL(TInt aControlId)
+    {
+    CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(aControlId);
+
+    // update visibilities of fields    
+    if (aControlId == ELoadGenCPULoadQueryType)
+        {
+        UpdateVisibilitiesOfFieldsL();
+        }
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TBool CLoadGenCPULoadEditor::RunQueryLD()
+    {
+    return CLoadGenLoadTypeEditorBase::DoRunQueryLD(R_CPULOAD_FORM_DIALOG);
+    }
+       
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+CLoadGenMemoryEatEditor* CLoadGenMemoryEatEditor::NewL(TMemoryEatAttributes& aAttributes, TBool aEditingExisting)
+    {
+    CLoadGenMemoryEatEditor* self = new(ELeave) CLoadGenMemoryEatEditor(aAttributes, aEditingExisting);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenMemoryEatEditor::~CLoadGenMemoryEatEditor()
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenMemoryEatEditor::CLoadGenMemoryEatEditor(TMemoryEatAttributes& aAttributes, TBool aEditingExisting) :
+    CLoadGenLoadTypeEditorBase(aEditingExisting), iAttributes(aAttributes)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenMemoryEatEditor::ConstructL()
+    {
+    CLoadGenLoadTypeEditorBase::ConstructL(_L("Memory eat"));
+    
+    // convert int64 vals to descs
+    iAttributes.iAmountDes.Copy(KNullDesC);
+    iAttributes.iRandomMinDes.Copy(KNullDesC);
+    iAttributes.iRandomMaxDes.Copy(KNullDesC);
+    
+    iAttributes.iAmountDes.AppendNum(iAttributes.iAmount);
+    iAttributes.iRandomMinDes.AppendNum(iAttributes.iRandomMin);
+    iAttributes.iRandomMaxDes.AppendNum(iAttributes.iRandomMax);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenMemoryEatEditor::PreLayoutDynInitL()
+    {
+    CLoadGenLoadTypeEditorBase::PreLayoutDynInitL();
+
+    // load values to static editors
+    CAknPopupFieldText* edPriority = static_cast<CAknPopupFieldText*>(Control(ELoadGenMemoryEatQueryPriority));
+    CAknPopupFieldText* edSource = static_cast<CAknPopupFieldText*>(Control(ELoadGenMemoryEatQuerySource));
+    CAknPopupFieldText* edType = static_cast<CAknPopupFieldText*>(Control(ELoadGenMemoryEatQueryType));
+    CEikNumberEditor* edBuffer = static_cast<CEikNumberEditor*>(Control(ELoadGenMemoryEatQueryBuffer));
+    CEikNumberEditor* edIdle = static_cast<CEikNumberEditor*>(Control(ELoadGenMemoryEatQueryIdle));
+    CEikNumberEditor* edVariance = static_cast<CEikNumberEditor*>(Control(ELoadGenMemoryEatQueryVariance));
+
+    edPriority->SetCurrentValueIndex(iAttributes.iPriority);
+    edSource->SetCurrentValueIndex(iAttributes.iSource);
+    edType->SetCurrentValueIndex(iAttributes.iType);
+    edBuffer->SetNumber(iAttributes.iBuffer);
+    edIdle->SetNumber(iAttributes.iIdle);
+    edVariance->SetNumber(iAttributes.iRandomVariance);
+            
+    UpdateVisibilitiesOfFieldsL(ETrue);
+    UpdateAvailableMemoryL();
+    
+    // set source as dimmed if editing existing item
+    if (iEditingExisting)
+        {
+        SetLineDimmedNow(ELoadGenMemoryEatQuerySource, ETrue); 
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TBool CLoadGenMemoryEatEditor::OkToExitL(TInt aButtonId)
+    {
+    if (aButtonId == EAknSoftkeyOk)
+        {
+        // store values from editors
+        CAknPopupFieldText* edPriority = static_cast<CAknPopupFieldText*>(Control(ELoadGenMemoryEatQueryPriority));
+        CAknPopupFieldText* edSource = static_cast<CAknPopupFieldText*>(Control(ELoadGenMemoryEatQuerySource));
+        CAknPopupFieldText* edType = static_cast<CAknPopupFieldText*>(Control(ELoadGenMemoryEatQueryType));
+        CEikNumberEditor* edBuffer = static_cast<CEikNumberEditor*>(Control(ELoadGenMemoryEatQueryBuffer));
+        CEikNumberEditor* edIdle = static_cast<CEikNumberEditor*>(Control(ELoadGenMemoryEatQueryIdle));
+        CEikNumberEditor* edVariance = static_cast<CEikNumberEditor*>(Control(ELoadGenMemoryEatQueryVariance));
+
+        iAttributes.iPriority = edPriority->CurrentValueIndex();
+        iAttributes.iSource = edSource->CurrentValueIndex();
+        iAttributes.iType = edType->CurrentValueIndex();
+        iAttributes.iBuffer = edBuffer->Number();
+        iAttributes.iIdle = edIdle->Number();
+        iAttributes.iRandomVariance = edVariance->Number();
+
+
+        CEikEdwin* edAmount = static_cast<CEikEdwin*>(ControlOrNull(ELoadGenMemoryEatQueryAmount));
+        CEikEdwin* edRandomMin = static_cast<CEikEdwin*>(ControlOrNull(ELoadGenMemoryEatQueryRandomMin));
+        CEikEdwin* edRandomMax = static_cast<CEikEdwin*>(ControlOrNull(ELoadGenMemoryEatQueryRandomMax));
+
+        // get desc values and convert to int64
+        if (edAmount)
+            {
+            edAmount->GetText(iAttributes.iAmountDes);
+
+            TLex converter;
+            converter.Assign(iAttributes.iAmountDes);
+            User::LeaveIfError(converter.Val(iAttributes.iAmount));
+            }
+
+        if (edRandomMin)
+            {
+            edRandomMin->GetText(iAttributes.iRandomMinDes);
+
+            TLex converter;
+            converter.Assign(iAttributes.iRandomMinDes);
+            User::LeaveIfError(converter.Val(iAttributes.iRandomMin));
+            }
+
+        if (edRandomMax)
+            {
+            edRandomMax->GetText(iAttributes.iRandomMaxDes);
+
+            TLex converter;
+            converter.Assign(iAttributes.iRandomMaxDes);
+            User::LeaveIfError(converter.Val(iAttributes.iRandomMax));
+            
+            // swap min max values if they in wrong order
+            if (iAttributes.iRandomMin > iAttributes.iRandomMax)
+                {
+                TInt64 temp(iAttributes.iRandomMin);
+                iAttributes.iRandomMin = iAttributes.iRandomMax;
+                iAttributes.iRandomMax = temp; 
+                }
+            
+            }                        
+        }
+    
+    return ETrue;
+    }       
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenMemoryEatEditor::UpdateVisibilitiesOfFieldsL(TBool aFormInit)
+    {
+    // filter based on selected memory eat type
+    CAknPopupFieldText* edType = static_cast<CAknPopupFieldText*>(Control(ELoadGenMemoryEatQueryType));
+
+    if (!aFormInit && (edType->CurrentValueIndex() == EMemoryEatTypeMemoryToEat || edType->CurrentValueIndex() == EMemoryEatTypeMemoryToBeLeft))
+        {
+        // no need for changes if amount field is already active
+        CEikNumberEditor* edAmount = static_cast<CEikNumberEditor*>(ControlOrNull(ELoadGenMemoryEatQueryAmount));
+        if (edAmount) return;
+        
+        // save values before deleting the items
+        CEikEdwin* edRandomMin = static_cast<CEikEdwin*>(Control(ELoadGenMemoryEatQueryRandomMin));
+        CEikEdwin* edRandomMax = static_cast<CEikEdwin*>(Control(ELoadGenMemoryEatQueryRandomMax));
+        edRandomMin->GetText(iAttributes.iRandomMinDes);
+        edRandomMax->GetText(iAttributes.iRandomMaxDes);
+        
+        DeleteLine(ELoadGenMemoryEatQueryRandomMin);
+        DeleteLine(ELoadGenMemoryEatQueryRandomMax);
+        }
+    else if (!aFormInit && edType->CurrentValueIndex() == EMemoryEatTypeWavy)
+        {
+        // save values before deleting the items
+        CEikEdwin* edAmount = static_cast<CEikEdwin*>(Control(ELoadGenMemoryEatQueryAmount));
+        edAmount->GetText(iAttributes.iAmountDes);
+        
+        DeleteLine(ELoadGenMemoryEatQueryAmount);
+        }
+    
+    if (edType->CurrentValueIndex() == EMemoryEatTypeMemoryToEat || edType->CurrentValueIndex() == EMemoryEatTypeMemoryToBeLeft)
+        {
+        // insert new fields
+        InsertFieldAfterL(R_MEMORYEAT_DLG_LINE_AMOUNT, ELoadGenMemoryEatQueryAmount, ELoadGenMemoryEatQueryType);
+        
+        // load values to just created editors
+        CEikEdwin* edAmount = static_cast<CEikEdwin*>(Control(ELoadGenMemoryEatQueryAmount));
+        edAmount->SetTextL(&iAttributes.iAmountDes);
+        }
+    else if (edType->CurrentValueIndex() == EMemoryEatTypeWavy)
+        {
+        // insert new fields
+        InsertFieldAfterL(R_MEMORYEAT_DLG_LINE_RANDOM_MIN, ELoadGenMemoryEatQueryRandomMin, ELoadGenMemoryEatQueryType);
+        InsertFieldAfterL(R_MEMORYEAT_DLG_LINE_RANDOM_MAX, ELoadGenMemoryEatQueryRandomMax, ELoadGenMemoryEatQueryRandomMin);
+        
+        // load values to just created editors
+        CEikEdwin* edRandomMin = static_cast<CEikEdwin*>(Control(ELoadGenMemoryEatQueryRandomMin));
+        CEikEdwin* edRandomMax = static_cast<CEikEdwin*>(Control(ELoadGenMemoryEatQueryRandomMax));
+        edRandomMin->SetTextL(&iAttributes.iRandomMinDes);
+        edRandomMax->SetTextL(&iAttributes.iRandomMaxDes);
+        }
+    
+    UpdateFormL();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenMemoryEatEditor::UpdateAvailableMemoryL()
+    {
+    // this feature is used only when not editing existing load
+    if (!iEditingExisting)
+        {
+        CAknPopupFieldText* edSource = static_cast<CAknPopupFieldText*>(ControlOrNull(ELoadGenMemoryEatQuerySource));
+        CEikEdwin* edAmount = static_cast<CEikEdwin*>(ControlOrNull(ELoadGenMemoryEatQueryAmount));
+        
+        if (edAmount && edSource)
+            {
+            iAttributes.iAmountDes.Copy(KNullDesC);
+
+            if (edSource->CurrentValueIndex() == EMemoryEatSourceTypeRAM)
+                {
+                // RAM
+                TMemoryInfoV1Buf ramMemory;
+                UserHal::MemoryInfo(ramMemory);
+                
+                iAttributes.iAmountDes.AppendNum(ramMemory().iFreeRamInBytes);
+                }
+            else
+                {
+                // get drive
+                TVolumeInfo volumeInfo;
+                if (CEikonEnv::Static()->FsSession().Volume(volumeInfo, edSource->CurrentValueIndex()+1) == KErrNone)
+                    {
+                    iAttributes.iAmountDes.AppendNum(volumeInfo.iFree);
+                    }
+                else
+                    {
+                    iAttributes.iAmountDes.AppendNum(0);
+                    }
+                }
+
+            edAmount->SetTextL(&iAttributes.iAmountDes);
+            }        
+        }
+    }
+        
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenMemoryEatEditor::HandleControlStateChangeL(TInt aControlId)
+    {
+    CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(aControlId);
+    
+    // update visibilities of fields    
+    if (aControlId == ELoadGenMemoryEatQueryType)
+        {
+        UpdateVisibilitiesOfFieldsL();
+        }
+    
+    // update memory when source changes
+    else if (aControlId == ELoadGenMemoryEatQuerySource)
+        {
+        UpdateAvailableMemoryL();
+        }
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TBool CLoadGenMemoryEatEditor::RunQueryLD()
+    {
+    return CLoadGenLoadTypeEditorBase::DoRunQueryLD(R_MEMORYEAT_FORM_DIALOG);
+    }
+
+
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+CLoadGenPhoneCallEditor* CLoadGenPhoneCallEditor::NewL(TPhoneCallAttributes& aAttributes, TBool aEditingExisting)
+    {
+    CLoadGenPhoneCallEditor* self = new(ELeave) CLoadGenPhoneCallEditor(aAttributes, aEditingExisting);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenPhoneCallEditor::~CLoadGenPhoneCallEditor()
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenPhoneCallEditor::CLoadGenPhoneCallEditor(TPhoneCallAttributes& aAttributes, TBool aEditingExisting) :
+    CLoadGenLoadTypeEditorBase(aEditingExisting), iAttributes(aAttributes)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenPhoneCallEditor::ConstructL()
+    {
+    CLoadGenLoadTypeEditorBase::ConstructL(_L("Phone calls"));
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenPhoneCallEditor::PreLayoutDynInitL()
+    {
+    CLoadGenLoadTypeEditorBase::PreLayoutDynInitL();
+    
+    // load values to static editors
+    CAknPopupFieldText* edPriority = static_cast<CAknPopupFieldText*>(Control(ELoadGenPhoneCallQueryPriority));
+    CEikEdwin* edDestination = static_cast<CEikEdwin*>(Control(ELoadGenPhoneCallQueryDestination));
+    CEikNumberEditor* edLength = static_cast<CEikNumberEditor*>(Control(ELoadGenPhoneCallQueryLength));
+    CEikNumberEditor* edIdle = static_cast<CEikNumberEditor*>(Control(ELoadGenPhoneCallQueryIdle));
+    CEikNumberEditor* edVariance = static_cast<CEikNumberEditor*>(Control(ELoadGenPhoneCallQueryVariance));
+
+    edPriority->SetCurrentValueIndex(iAttributes.iPriority);
+    edDestination->SetTextL(&iAttributes.iDestination);   
+    edLength->SetNumber(iAttributes.iLength);   
+    edIdle->SetNumber(iAttributes.iIdle);   
+    edVariance->SetNumber(iAttributes.iRandomVariance);   
+    
+    UpdateVisibilitiesOfFieldsL(ETrue);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TBool CLoadGenPhoneCallEditor::OkToExitL(TInt aButtonId)
+    {
+    if (aButtonId == EAknSoftkeyOk)
+        {
+        // store values from editors
+        CAknPopupFieldText* edPriority = static_cast<CAknPopupFieldText*>(Control(ELoadGenPhoneCallQueryPriority));
+        CEikEdwin* edDestination = static_cast<CEikEdwin*>(Control(ELoadGenPhoneCallQueryDestination));
+        CEikNumberEditor* edLength = static_cast<CEikNumberEditor*>(Control(ELoadGenPhoneCallQueryLength));
+        CEikNumberEditor* edIdle = static_cast<CEikNumberEditor*>(Control(ELoadGenPhoneCallQueryIdle));
+        CEikNumberEditor* edVariance = static_cast<CEikNumberEditor*>(Control(ELoadGenPhoneCallQueryVariance));
+
+        iAttributes.iPriority = edPriority->CurrentValueIndex();
+        edDestination->GetText(iAttributes.iDestination);
+        iAttributes.iLength = edLength->Number();
+        iAttributes.iIdle = edIdle->Number();
+        iAttributes.iRandomVariance = edVariance->Number();
+        }
+    
+    return ETrue;
+    }       
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenPhoneCallEditor::UpdateVisibilitiesOfFieldsL(TBool /*aFormInit*/)
+    {
+    UpdateFormL();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenPhoneCallEditor::HandleControlStateChangeL(TInt aControlId)
+    {
+    CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(aControlId);
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TBool CLoadGenPhoneCallEditor::RunQueryLD()
+    {
+    return CLoadGenLoadTypeEditorBase::DoRunQueryLD(R_PHONECALL_FORM_DIALOG);
+    }
+
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+CLoadGenNetConnEditor* CLoadGenNetConnEditor::NewL(TNetConnAttributes& aAttributes, TBool aEditingExisting)
+    {
+    CLoadGenNetConnEditor* self = new(ELeave) CLoadGenNetConnEditor(aAttributes, aEditingExisting);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenNetConnEditor::~CLoadGenNetConnEditor()
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenNetConnEditor::CLoadGenNetConnEditor(TNetConnAttributes& aAttributes, TBool aEditingExisting) :
+    CLoadGenLoadTypeEditorBase(aEditingExisting), iAttributes(aAttributes)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenNetConnEditor::ConstructL()
+    {
+    CLoadGenLoadTypeEditorBase::ConstructL(_L("Network conn."));
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenNetConnEditor::PreLayoutDynInitL()
+    {
+    CLoadGenLoadTypeEditorBase::PreLayoutDynInitL();
+    
+    // load values to static editors
+    CAknPopupFieldText* edPriority = static_cast<CAknPopupFieldText*>(Control(ELoadGenNetConnQueryPriority));
+    CEikEdwin* edDestination = static_cast<CEikEdwin*>(Control(ELoadGenNetConnQueryDestination));
+    CEikNumberEditor* edIdle = static_cast<CEikNumberEditor*>(Control(ELoadGenNetConnQueryIdle));
+    CEikNumberEditor* edVariance = static_cast<CEikNumberEditor*>(Control(ELoadGenNetConnQueryVariance));
+
+    edPriority->SetCurrentValueIndex(iAttributes.iPriority);
+    edDestination->SetTextL(&iAttributes.iDestination);   
+    edIdle->SetNumber(iAttributes.iIdle);   
+    edVariance->SetNumber(iAttributes.iRandomVariance);
+       
+    UpdateVisibilitiesOfFieldsL(ETrue);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TBool CLoadGenNetConnEditor::OkToExitL(TInt aButtonId)
+    {
+    if (aButtonId == EAknSoftkeyOk)
+        {
+        // store values from editors
+        CAknPopupFieldText* edPriority = static_cast<CAknPopupFieldText*>(Control(ELoadGenNetConnQueryPriority));
+        CEikEdwin* edDestination = static_cast<CEikEdwin*>(Control(ELoadGenNetConnQueryDestination));
+        CEikNumberEditor* edIdle = static_cast<CEikNumberEditor*>(Control(ELoadGenNetConnQueryIdle));
+        CEikNumberEditor* edVariance = static_cast<CEikNumberEditor*>(Control(ELoadGenNetConnQueryVariance));
+
+        iAttributes.iPriority = edPriority->CurrentValueIndex();
+        edDestination->GetText(iAttributes.iDestination);
+        iAttributes.iIdle = edIdle->Number();
+        iAttributes.iRandomVariance = edVariance->Number();
+        }
+    
+    return ETrue;
+    }       
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenNetConnEditor::UpdateVisibilitiesOfFieldsL(TBool /*aFormInit*/)
+    {
+    UpdateFormL();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenNetConnEditor::HandleControlStateChangeL(TInt aControlId)
+    {
+    CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(aControlId);
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TBool CLoadGenNetConnEditor::RunQueryLD()
+    {
+    return CLoadGenLoadTypeEditorBase::DoRunQueryLD(R_NETCONN_FORM_DIALOG);
+    }
+
+// --------------------------------------------------------------------------------------------
+       
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+CLoadGenKeyPressEditor* CLoadGenKeyPressEditor::NewL(TKeyPressAttributes& aAttributes, TBool aEditingExisting)
+    {
+    CLoadGenKeyPressEditor* self = new(ELeave) CLoadGenKeyPressEditor(aAttributes, aEditingExisting);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenKeyPressEditor::~CLoadGenKeyPressEditor()
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenKeyPressEditor::CLoadGenKeyPressEditor(TKeyPressAttributes& aAttributes, TBool aEditingExisting) :
+    CLoadGenLoadTypeEditorBase(aEditingExisting), iAttributes(aAttributes)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenKeyPressEditor::ConstructL()
+    {
+    CLoadGenLoadTypeEditorBase::ConstructL(_L("Key presses"));
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenKeyPressEditor::PreLayoutDynInitL()
+    {
+    CLoadGenLoadTypeEditorBase::PreLayoutDynInitL();
+
+    // load values to static editors
+    CAknPopupFieldText* edPriority = static_cast<CAknPopupFieldText*>(Control(ELoadGenKeyPressQueryPriority));
+    CEikNumberEditor* edHeartBeat = static_cast<CEikNumberEditor*>(Control(ELoadGenKeyPressQueryHeartBeat));
+    CEikNumberEditor* edVariance = static_cast<CEikNumberEditor*>(Control(ELoadGenKeyPressQueryVariance));
+
+    edPriority->SetCurrentValueIndex(iAttributes.iPriority);
+    edHeartBeat->SetNumber(iAttributes.iHeartBeat);
+    edVariance->SetNumber(iAttributes.iRandomVariance);
+
+    UpdateVisibilitiesOfFieldsL(ETrue);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TBool CLoadGenKeyPressEditor::OkToExitL(TInt aButtonId)
+    {
+    if (aButtonId == EAknSoftkeyOk)
+        {
+        // store values from editors
+        CAknPopupFieldText* edPriority = static_cast<CAknPopupFieldText*>(Control(ELoadGenKeyPressQueryPriority));
+        CEikNumberEditor* edHeartBeat = static_cast<CEikNumberEditor*>(Control(ELoadGenKeyPressQueryHeartBeat));
+        CEikNumberEditor* edVariance = static_cast<CEikNumberEditor*>(Control(ELoadGenKeyPressQueryVariance));
+
+        iAttributes.iPriority = edPriority->CurrentValueIndex();
+        iAttributes.iHeartBeat = edHeartBeat->Number();
+        iAttributes.iRandomVariance = edVariance->Number();
+        }
+    
+    return ETrue;
+    }       
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenKeyPressEditor::UpdateVisibilitiesOfFieldsL(TBool /*aFormInit*/)
+    {
+    UpdateFormL();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenKeyPressEditor::HandleControlStateChangeL(TInt aControlId)
+    {
+    CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(aControlId);
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TBool CLoadGenKeyPressEditor::RunQueryLD()
+    {
+    return CLoadGenLoadTypeEditorBase::DoRunQueryLD(R_KEYPRESS_FORM_DIALOG);
+    }
+
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+CLoadGenMessagesEditor* CLoadGenMessagesEditor::NewL( TMessageAttributes& aAttributes, 
+                                                      TBool aEditingExisting )
+    {
+    CLoadGenMessagesEditor* self = new(ELeave) CLoadGenMessagesEditor( aAttributes, 
+                                                                        aEditingExisting );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenMessagesEditor::~CLoadGenMessagesEditor()
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenMessagesEditor::CLoadGenMessagesEditor( TMessageAttributes& aAttributes, 
+                                                TBool aEditingExisting ) :
+                                            CLoadGenLoadTypeEditorBase( aEditingExisting ), 
+                                            iAttributes( aAttributes )
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenMessagesEditor::ConstructL()
+    {
+    CLoadGenLoadTypeEditorBase::ConstructL( _L("Messages") );
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenMessagesEditor::PreLayoutDynInitL()
+    {
+    CLoadGenLoadTypeEditorBase::PreLayoutDynInitL();
+    
+    // load values to static editors
+    CAknPopupFieldText* edPriority = 
+                    static_cast<CAknPopupFieldText*>( Control( ELoadGenMessagesQueryPriority ) );
+    CAknPopupFieldText* edType = 
+                    static_cast<CAknPopupFieldText*>( Control( ELoadGenMessagesQueryType ) );                    
+    CEikEdwin* edDestination = 
+                    static_cast<CEikEdwin*>( Control( ELoadGenMessagesQueryDestination ) );
+    CEikNumberEditor* edAmount = 
+                    static_cast<CEikNumberEditor*>( Control( ELoadGenMessagesQueryAmount ) );                
+    CEikNumberEditor* edLength = 
+                    static_cast<CEikNumberEditor*>( Control( ELoadGenMessagesQueryLength ) );
+    CEikNumberEditor* edIdle = 
+                    static_cast<CEikNumberEditor*>( Control( ELoadGenMessagesQueryIdle ) );
+    CEikNumberEditor* edVariance = 
+                    static_cast<CEikNumberEditor*>( Control( ELoadGenMessagesQueryVariance ) );
+
+    edPriority->SetCurrentValueIndex( iAttributes.iPriority );
+    edType->SetCurrentValueIndex( iAttributes.iMessageType );
+    edDestination->SetTextL( &iAttributes.iDestination );
+    edAmount->SetNumber( iAttributes.iAmount );
+    edLength->SetNumber( iAttributes.iLength );   
+    edIdle->SetNumber( iAttributes.iIdle );   
+    edVariance->SetNumber( iAttributes.iRandomVariance );   
+       
+    UpdateVisibilitiesOfFieldsL( ETrue );
+    // set type selection as dimmed if editing existing item
+    if (iEditingExisting)
+        {
+        SetLineDimmedNow(ELoadGenMessagesQueryType, ETrue); 
+        }
+    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TBool CLoadGenMessagesEditor::OkToExitL( TInt aButtonId )
+    {
+    if ( aButtonId == EAknSoftkeyOk )
+        {
+        // store values from editors
+        CAknPopupFieldText* edPriority = 
+                static_cast<CAknPopupFieldText*>( Control( ELoadGenMessagesQueryPriority ) );
+        CAknPopupFieldText* edType = 
+                static_cast<CAknPopupFieldText*>( Control( ELoadGenMessagesQueryType ) );                
+        CEikEdwin* edDestination = 
+                static_cast<CEikEdwin*>( Control( ELoadGenMessagesQueryDestination ) );
+        CEikNumberEditor* edLength = 
+                static_cast<CEikNumberEditor*>( Control( ELoadGenMessagesQueryLength ) );
+        CEikNumberEditor* edAmount = 
+                static_cast<CEikNumberEditor*>( Control( ELoadGenMessagesQueryAmount ) );                
+        CEikNumberEditor* edIdle = 
+                static_cast<CEikNumberEditor*>( Control( ELoadGenMessagesQueryIdle ) );
+        CEikNumberEditor* edVariance =
+                static_cast<CEikNumberEditor*>( Control( ELoadGenMessagesQueryVariance ) );
+
+        iAttributes.iPriority = edPriority->CurrentValueIndex();
+        iAttributes.iMessageType = edType->CurrentValueIndex();
+        edDestination->GetText( iAttributes.iDestination );
+        iAttributes.iAmount = edAmount->Number();
+        iAttributes.iLength = edLength->Number();
+        iAttributes.iIdle = edIdle->Number();
+        iAttributes.iRandomVariance = edVariance->Number();
+        }
+    
+    return ETrue;
+    }       
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenMessagesEditor::UpdateVisibilitiesOfFieldsL( TBool /*aFormInit*/ )
+    {
+    UpdateFormL();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenMessagesEditor::HandleControlStateChangeL( TInt aControlId )
+    {
+    CLoadGenLoadTypeEditorBase::HandleControlStateChangeL( aControlId );
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TBool CLoadGenMessagesEditor::RunQueryLD()
+    {
+    return CLoadGenLoadTypeEditorBase::DoRunQueryLD( R_MESSAGES_FORM_DIALOG );
+    }
+
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+CLoadGenApplicationsEditor* CLoadGenApplicationsEditor::NewL( TApplicationsAttributes& aAttributes, 
+                                                      TBool aEditingExisting )
+    {
+    CLoadGenApplicationsEditor* self = new(ELeave) CLoadGenApplicationsEditor( aAttributes, 
+                                                                        aEditingExisting );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenApplicationsEditor::~CLoadGenApplicationsEditor()
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenApplicationsEditor::CLoadGenApplicationsEditor( TApplicationsAttributes& aAttributes, 
+                                                TBool aEditingExisting ) :
+                                            CLoadGenLoadTypeEditorBase( aEditingExisting ), 
+                                            iAttributes( aAttributes )
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenApplicationsEditor::ConstructL()
+    {
+    CLoadGenLoadTypeEditorBase::ConstructL( _L("Applications") );
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenApplicationsEditor::PreLayoutDynInitL()
+    {
+    CLoadGenLoadTypeEditorBase::PreLayoutDynInitL();
+
+    // load values to static editors
+    CAknPopupFieldText* edPriority = static_cast<CAknPopupFieldText*>(Control(ELoadGenApplicationsQueryPriority));
+    CEikNumberEditor* edLaunchingInterval = static_cast<CEikNumberEditor*>(Control(ELoadGenApplicationsLaunchingInterval));
+    CAknPopupFieldText* edKeyPressType = static_cast<CAknPopupFieldText*>(Control(ELoadGenApplicationsKeyPressType));
+    CEikNumberEditor* edMaxOpen = static_cast<CEikNumberEditor*>(Control(ELoadGenApplicationsMaxOpen));
+    CEikNumberEditor* edHeartBeat = static_cast<CEikNumberEditor*>(Control(ELoadGenApplicationsKeyPressQueryHeartBeat));
+    CEikNumberEditor* edVariance = static_cast<CEikNumberEditor*>(Control(ELoadGenApplicationsQueryVariance));
+
+    edPriority->SetCurrentValueIndex( iAttributes.iPriority );
+    edLaunchingInterval->SetNumber( iAttributes.iLaunchingInterval );
+    edKeyPressType->SetCurrentValueIndex( iAttributes.iKeyPressType );
+    edMaxOpen->SetNumber( iAttributes.iMaxOpen );
+    edHeartBeat->SetNumber( iAttributes.iHeartBeat );
+    edVariance->SetNumber( iAttributes.iRandomVariance );
+
+    UpdateVisibilitiesOfFieldsL(ETrue);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TBool CLoadGenApplicationsEditor::OkToExitL(TInt aButtonId)
+    {
+    if (aButtonId == EAknSoftkeyOk)
+        {
+        // store values from editors
+        CAknPopupFieldText* edPriority = static_cast<CAknPopupFieldText*>(Control(ELoadGenApplicationsQueryPriority));
+        CEikNumberEditor* edLaunchingInterval = static_cast<CEikNumberEditor*>(Control(ELoadGenApplicationsLaunchingInterval));
+        CAknPopupFieldText* edKeyPressType = static_cast<CAknPopupFieldText*>(Control(ELoadGenApplicationsKeyPressType));
+        CEikNumberEditor* edMaxOpen = static_cast<CEikNumberEditor*>(Control(ELoadGenApplicationsMaxOpen));
+        CEikNumberEditor* edHeartBeat = static_cast<CEikNumberEditor*>(Control(ELoadGenApplicationsKeyPressQueryHeartBeat));
+        CEikNumberEditor* edVariance = static_cast<CEikNumberEditor*>(Control(ELoadGenApplicationsQueryVariance));
+
+        iAttributes.iPriority = edPriority->CurrentValueIndex();
+        iAttributes.iLaunchingInterval = edLaunchingInterval->Number();
+        iAttributes.iKeyPressType = edKeyPressType->CurrentValueIndex();
+        iAttributes.iMaxOpen = edMaxOpen->Number();
+        iAttributes.iHeartBeat = edHeartBeat->Number();
+        iAttributes.iRandomVariance = edVariance->Number();
+        }
+    
+    return ETrue;
+    }       
+    
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenApplicationsEditor::UpdateVisibilitiesOfFieldsL( TBool /*aFormInit*/ )
+    {
+    UpdateFormL();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenApplicationsEditor::HandleControlStateChangeL( TInt aControlId )
+    {
+    CLoadGenLoadTypeEditorBase::HandleControlStateChangeL( aControlId );
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TBool CLoadGenApplicationsEditor::RunQueryLD()
+    {
+    return CLoadGenLoadTypeEditorBase::DoRunQueryLD( R_APPLICATIONS_FORM_DIALOG );
+    }
+
+// --------------------------------------------------------------------------------------------
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenPhotoCaptureEditor* CLoadGenPhotoCaptureEditor::NewL(TPhotoCaptureAttributes& aAttributes, TBool aEditingExisting)
+    {
+    CLoadGenPhotoCaptureEditor* self = new(ELeave) CLoadGenPhotoCaptureEditor(aAttributes, aEditingExisting);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenPhotoCaptureEditor::~CLoadGenPhotoCaptureEditor()
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenPhotoCaptureEditor::CLoadGenPhotoCaptureEditor(TPhotoCaptureAttributes& aAttributes, TBool aEditingExisting) :
+    CLoadGenLoadTypeEditorBase(aEditingExisting), iAttributes(aAttributes)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenPhotoCaptureEditor::ConstructL()
+    {
+    CLoadGenLoadTypeEditorBase::ConstructL(_L("Photo captures"));
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenPhotoCaptureEditor::PreLayoutDynInitL()
+    {
+    CLoadGenLoadTypeEditorBase::PreLayoutDynInitL();
+    
+    // load values to static editors
+    CAknPopupFieldText* edPriority = static_cast<CAknPopupFieldText*>(Control(ELoadGenPhotoCaptureQueryPriority));
+    //CAknPopupFieldText* edDevice = static_cast<CAknPopupFieldText*>(Control(ELoadGenPhotoCaptureQueryDevice));    
+    CEikNumberEditor* edIdle = static_cast<CEikNumberEditor*>(Control(ELoadGenPhotoCaptureQueryIdle));
+    CEikNumberEditor* edVariance = static_cast<CEikNumberEditor*>(Control(ELoadGenPhotoCaptureQueryVariance));
+
+    edPriority->SetCurrentValueIndex(iAttributes.iPriority);
+    //edDevice->SetCurrentValueIndex(0);
+    edIdle->SetNumber(iAttributes.iIdle);   
+    edVariance->SetNumber(iAttributes.iRandomVariance);
+    
+    LoadCamerasL();
+    
+    UpdateVisibilitiesOfFieldsL(ETrue);
+    }
+
+void CLoadGenPhotoCaptureEditor::LoadCamerasL()
+    {    
+    if (iAttributes.iCameraCount > 0)
+        {
+        // insert possibility to select which cpu the load is generated to
+        InsertFieldAfterL(R_PHOTOCAPTURE_DLG_LINE_DEVICE, ELoadGenPhotoCaptureQueryDevice, ELoadGenPhotoCaptureQueryPriority);
+        
+        iCamerasArray = new (ELeave) CDesCArrayFlat( iAttributes.iCameraCount );   
+        
+        // add Cameras
+        for (int i = 0; i < iAttributes.iCameraCount; i++) 
+            {
+            TBuf<16> cam;
+            _LIT(KCam, "Camera %d");
+            cam.Format(KCam, i);
+            iCamerasArray->AppendL(cam);
+            }    
+       
+        iCameraTextArray = CAknQueryValueTextArray::NewL();
+        iCameraTextArray->SetArray( *iCamerasArray );  
+        iCameraQueryValText = CAknQueryValueText::NewL();    
+        iCameraQueryValText->SetArrayL( iCameraTextArray );
+        if( iAttributes.iCameraCount > 0 )
+            {
+            iCameraQueryValText->SetCurrentValueIndex(iAttributes.iCamera);
+            }
+        CAknPopupField* popup = static_cast<CAknPopupField*>(Control( ELoadGenPhotoCaptureQueryDevice)); 
+        popup->SetQueryValueL( iCameraQueryValText );        
+        }    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TBool CLoadGenPhotoCaptureEditor::OkToExitL(TInt aButtonId)
+    {
+    if (aButtonId == EAknSoftkeyOk)
+        {
+        // store values from editors
+        CAknPopupFieldText* edPriority = static_cast<CAknPopupFieldText*>(Control(ELoadGenPhotoCaptureQueryPriority));        
+        CEikNumberEditor* edIdle = static_cast<CEikNumberEditor*>(Control(ELoadGenPhotoCaptureQueryIdle));
+        CEikNumberEditor* edVariance = static_cast<CEikNumberEditor*>(Control(ELoadGenPhotoCaptureQueryVariance));
+
+        iAttributes.iPriority = edPriority->CurrentValueIndex();        
+        iAttributes.iIdle = edIdle->Number();
+        iAttributes.iRandomVariance = edVariance->Number();
+        
+        if (iAttributes.iCameraCount > 1)
+            {
+            iAttributes.iCamera = iCameraQueryValText->CurrentValueIndex();
+            }
+        }
+    
+    return ETrue;
+    }       
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenPhotoCaptureEditor::UpdateVisibilitiesOfFieldsL(TBool /*aFormInit*/)
+    {
+    UpdateFormL();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenPhotoCaptureEditor::HandleControlStateChangeL(TInt aControlId)
+    {
+    CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(aControlId);
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TBool CLoadGenPhotoCaptureEditor::RunQueryLD()
+    {
+    return CLoadGenLoadTypeEditorBase::DoRunQueryLD(R_PHOTOCAPTURE_FORM_DIALOG);
+    }
+
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenBluetoothEditor* CLoadGenBluetoothEditor::NewL(TBluetoothAttributes& aAttributes, TBool aEditingExisting)
+    {
+    CLoadGenBluetoothEditor* self = new(ELeave) CLoadGenBluetoothEditor(aAttributes, aEditingExisting);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenBluetoothEditor::~CLoadGenBluetoothEditor()
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenBluetoothEditor::CLoadGenBluetoothEditor(TBluetoothAttributes& aAttributes, TBool aEditingExisting) :
+    CLoadGenLoadTypeEditorBase(aEditingExisting), iAttributes(aAttributes)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenBluetoothEditor::ConstructL()
+    {
+    CLoadGenLoadTypeEditorBase::ConstructL(_L("Bluetooth"));
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenBluetoothEditor::PreLayoutDynInitL()
+    {
+    CLoadGenLoadTypeEditorBase::PreLayoutDynInitL();
+    
+    // load values to static editors
+    CAknPopupFieldText* edPriority = static_cast<CAknPopupFieldText*>(Control(ELoadGenBluetoothQueryPriority));        
+    CEikNumberEditor* edIdle = static_cast<CEikNumberEditor*>(Control(ELoadGenBluetoothQueryIdle));
+    CEikNumberEditor* edVariance = static_cast<CEikNumberEditor*>(Control(ELoadGenBluetoothQueryVariance));
+
+    edPriority->SetCurrentValueIndex(iAttributes.iPriority);    
+    edIdle->SetNumber(iAttributes.iIdle);   
+    edVariance->SetNumber(iAttributes.iRandomVariance);
+        
+    UpdateVisibilitiesOfFieldsL(ETrue);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TBool CLoadGenBluetoothEditor::OkToExitL(TInt aButtonId)
+    {
+    if (aButtonId == EAknSoftkeyOk)
+        {
+        // store values from editors
+        CAknPopupFieldText* edPriority = static_cast<CAknPopupFieldText*>(Control(ELoadGenBluetoothQueryPriority));        
+        CEikNumberEditor* edIdle = static_cast<CEikNumberEditor*>(Control(ELoadGenBluetoothQueryIdle));
+        CEikNumberEditor* edVariance = static_cast<CEikNumberEditor*>(Control(ELoadGenBluetoothQueryVariance));
+
+        iAttributes.iPriority = edPriority->CurrentValueIndex();        
+        iAttributes.iIdle = edIdle->Number();
+        iAttributes.iRandomVariance = edVariance->Number();                
+        }
+    
+    return ETrue;
+    }       
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenBluetoothEditor::UpdateVisibilitiesOfFieldsL(TBool /*aFormInit*/)
+    {
+    UpdateFormL();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenBluetoothEditor::HandleControlStateChangeL(TInt aControlId)
+    {
+    CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(aControlId);
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TBool CLoadGenBluetoothEditor::RunQueryLD()
+    {
+    return CLoadGenLoadTypeEditorBase::DoRunQueryLD(R_BLUETOOTH_FORM_DIALOG);
+    }
+
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+CLoadGenPointerEventEditor* CLoadGenPointerEventEditor::NewL(TPointerEventAttributes& aAttributes, TBool aEditingExisting)
+    {
+    CLoadGenPointerEventEditor* self = new(ELeave) CLoadGenPointerEventEditor(aAttributes, aEditingExisting);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenPointerEventEditor::~CLoadGenPointerEventEditor()
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenPointerEventEditor::CLoadGenPointerEventEditor(TPointerEventAttributes& aAttributes, TBool aEditingExisting) :
+    CLoadGenLoadTypeEditorBase(aEditingExisting), iAttributes(aAttributes)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenPointerEventEditor::ConstructL()
+    {
+    CLoadGenLoadTypeEditorBase::ConstructL(_L("Pointer events"));
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenPointerEventEditor::PreLayoutDynInitL()
+    {
+    CLoadGenLoadTypeEditorBase::PreLayoutDynInitL();
+
+    // load values to static editors
+    CAknPopupFieldText* edPriority = static_cast<CAknPopupFieldText*>(Control(ELoadGenPointerEventQueryPriority));
+    CEikNumberEditor* edHeartBeat = static_cast<CEikNumberEditor*>(Control(ELoadGenPointerEventQueryHeartBeat));
+    CEikNumberEditor* edVariance = static_cast<CEikNumberEditor*>(Control(ELoadGenPointerEventQueryVariance));
+
+    edPriority->SetCurrentValueIndex(iAttributes.iPriority);
+    edHeartBeat->SetNumber(iAttributes.iHeartBeat);
+    edVariance->SetNumber(iAttributes.iRandomVariance);
+
+    UpdateVisibilitiesOfFieldsL(ETrue);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TBool CLoadGenPointerEventEditor::OkToExitL(TInt aButtonId)
+    {
+    if (aButtonId == EAknSoftkeyOk)
+        {
+        // store values from editors
+        CAknPopupFieldText* edPriority = static_cast<CAknPopupFieldText*>(Control(ELoadGenPointerEventQueryPriority));
+        CEikNumberEditor* edHeartBeat = static_cast<CEikNumberEditor*>(Control(ELoadGenPointerEventQueryHeartBeat));
+        CEikNumberEditor* edVariance = static_cast<CEikNumberEditor*>(Control(ELoadGenPointerEventQueryVariance));
+
+        iAttributes.iPriority = edPriority->CurrentValueIndex();
+        iAttributes.iHeartBeat = edHeartBeat->Number();
+        iAttributes.iRandomVariance = edVariance->Number();
+        }
+    
+    return ETrue;
+    }       
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenPointerEventEditor::UpdateVisibilitiesOfFieldsL(TBool /*aFormInit*/)
+    {
+    UpdateFormL();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenPointerEventEditor::HandleControlStateChangeL(TInt aControlId)
+    {
+    CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(aControlId);
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TBool CLoadGenPointerEventEditor::RunQueryLD()
+    {
+    return CLoadGenLoadTypeEditorBase::DoRunQueryLD(R_POINTEREVENT_FORM_DIALOG);
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/src/loadgen_keypress.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,257 @@
+/*
+* 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 "loadgen_keypress.h"
+#include "loadgen_model.h"
+#include "loadgen.hrh"
+#include <loadgen.rsg>
+
+#include <e32math.h>
+
+_LIT(KThreadName, "KeyPress %d");
+
+const TInt KDefaultStart = 50;
+const TInt KDefaultPeriod = 5000000;
+    
+// ===================================== MEMBER FUNCTIONS =====================================
+
+CKeyPress* CKeyPress::NewL(TKeyPressAttributes& aAttributes, TInt aReferenceNumber)
+    {
+    CKeyPress* self = new(ELeave) CKeyPress(aAttributes, aReferenceNumber);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CKeyPress::~CKeyPress()
+    {
+    Close();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CKeyPress::CKeyPress(TKeyPressAttributes& aAttributes, TInt aReferenceNumber) : iAttributes(aAttributes)
+    {
+    iAttributes.iId = aReferenceNumber;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CKeyPress::ConstructL()
+    {
+    CLoadBase::ConstructL();
+    
+    iType = ELoadGenCmdNewLoadKeyPress;
+    
+    TBuf<64> threadName;
+    threadName.Format(KThreadName, iAttributes.iId);
+    
+    // create a thread
+    User::LeaveIfError(iThread.Create(threadName, ThreadFunction, KDefaultStackSize*2, KMinHeapSize, 1024*KMinHeapSize, (TAny*) &iAttributes ));
+    
+    // set priority of the thread
+    SetPriority();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CKeyPress::ThreadFunction(TAny* aThreadArg)
+    {
+    CTrapCleanup* pC = CTrapCleanup::New();
+    CActiveScheduler* pS = new CActiveScheduler;
+    CActiveScheduler::Install(pS);
+
+    // start generating load, pass pointer to arguments
+    GenerateLoad(*((TKeyPressAttributes*) aThreadArg));
+
+    delete pS;
+    delete pC;
+    
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CKeyPress::GenerateLoad(TKeyPressAttributes& aAttributes)
+    {
+    CKeyPressManager* keyPressManager = NULL;
+    TRAPD(err, keyPressManager = CKeyPressManager::NewL(aAttributes));
+    if (err == KErrNone) CActiveScheduler::Start();
+    delete keyPressManager;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CKeyPress::Resume()
+    {
+    CLoadBase::Resume();
+    
+    iThread.Resume();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CKeyPress::Suspend()
+    {
+    CLoadBase::Suspend();
+    
+    iThread.Suspend();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CKeyPress::SetPriority()
+    {
+    CLoadBase::SetPriority();
+    
+    iThread.SetPriority(CLoadGenModel::SettingItemToThreadPriority(iAttributes.iPriority));
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CKeyPress::Close()
+    {
+    CLoadBase::Close();
+    
+    if (iThread.ExitReason() == 0) // check if the thread is still alive
+        {
+        // signal the thread that it needs to close
+        iThread.RequestComplete(iAttributes.iDeathStatus, KErrCancel);
+
+        // wait the thread to die
+        TRequestStatus waiter;
+        iThread.Logon(waiter);
+        User::WaitForRequest(waiter);
+        iThread.Close();
+        }
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TPtrC CKeyPress::Description()
+    {
+    TBuf<256> buf;
+    TBuf<16> prioBuf;
+    CLoadGenModel::SettingItemToThreadDescription(iAttributes.iPriority, prioBuf);
+    
+    _LIT(KKeyPressEntry, "[%d] KeyPress prio=%S heartbeat=%dms random=%d%%");
+    buf.Format(KKeyPressEntry, iAttributes.iId, &prioBuf, iAttributes.iHeartBeat, iAttributes.iRandomVariance);
+   
+    return TPtrC(buf);
+    }               
+
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+CKeyPressManager* CKeyPressManager::NewL(TKeyPressAttributes& aAttributes)
+    {
+    CKeyPressManager* self = new(ELeave) CKeyPressManager(aAttributes);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CKeyPressManager::CKeyPressManager(TKeyPressAttributes& aAttributes) :
+    CActive(EPriorityStandard), iAttributes(aAttributes)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+    
+CKeyPressManager::~CKeyPressManager()
+    {
+    Cancel();
+    
+    iWsSession.Close();
+    }
+
+// --------------------------------------------------------------------------------------------
+ 
+void CKeyPressManager::ConstructL()
+    {
+    CActiveScheduler::Add(this);
+    
+    // set the status as pending
+    iStatus = KRequestPending;
+    SetActive();
+    
+    // set the death status pointer point to the request status of this ao
+    iAttributes.iDeathStatus = &iStatus;
+    
+    // init
+    User::LeaveIfError( iWsSession.Connect() );
+    
+    // start timer    
+    iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard);
+    iPeriodicTimer->Start(KDefaultStart, KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this));
+    }
+    
+// --------------------------------------------------------------------------------------------
+ 
+void CKeyPressManager::RunL()
+    {
+    // request status has completed by the main thread meaning that we need to stop now
+    CActiveScheduler::Stop();
+    }
+
+// --------------------------------------------------------------------------------------------
+ 
+void CKeyPressManager::DoCancel()
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CKeyPressManager::PeriodicTimerCallBack(TAny* aAny)
+    {
+    CKeyPressManager* self = static_cast<CKeyPressManager*>( aAny );
+
+    self->iPeriodicTimer->Cancel();
+    self->SimulateKeyEvent();
+
+    return KErrNone;
+    }
+    
+// --------------------------------------------------------------------------------------------
+ 
+void CKeyPressManager::SimulateKeyEvent()
+    {
+    // generate a random key event from a to z
+    TKeyEvent keyEvent;
+    keyEvent.iCode = CLoadGenModel::RandomNumber('a','z');
+    keyEvent.iScanCode = keyEvent.iCode - 32;
+    keyEvent.iModifiers = 0;
+    keyEvent.iRepeats = 0;
+    
+    iWsSession.SimulateKeyEvent(keyEvent);
+    iWsSession.Flush();
+    
+    // call timer
+    iPeriodicTimer->Start(CLoadGenModel::MilliSecondsToMicroSeconds(iAttributes.iHeartBeat, iAttributes.iRandomVariance), KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this));
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/src/loadgen_loadbase.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -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 "loadgen_loadbase.h"
+#include "loadgen.hrh"
+#include <loadgen.rsg>
+
+// ===================================== MEMBER FUNCTIONS =====================================
+
+CLoadBase::CLoadBase()
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadBase::ConstructL()
+    {
+    iState = ELoadStateInvalid;
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CLoadBase::Resume()
+    {
+    iState = ELoadStateRunning;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadBase::Suspend()
+    {
+    iState = ELoadStateSuspended;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadBase::SetPriority()
+    {
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CLoadBase::Close()
+    {
+    iState = ELoadStateClosed;
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TPtrC CLoadBase::Description()
+    {
+    return TPtrC(KNullDesC);
+    }               
+               
+// --------------------------------------------------------------------------------------------
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/src/loadgen_maincontainer.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,457 @@
+/*
+* 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 "loadgen_maincontainer.h"
+#include "loadgen.hrh"
+#include "loadgen_document.h"
+#include "loadgen_appui.h"
+#include "loadgen_model.h"
+#include <loadgen_extraicons.mbg>
+
+#include <aknlists.h>
+#include <eikclb.h>
+#include <eikclbd.h>
+#include <aknconsts.h>
+#include <aknutils.h>
+#include <aknnotewrappers.h>
+#include <akniconarray.h> 
+#include <f32file.h>
+#include <AknIconUtils.h>
+#include <akndef.h>
+#include <akntitle.h>
+#include <eikspane.h> 
+
+_LIT(KExtraIconsPath, "\\resource\\apps\\loadgen_extraicons.mif");
+
+// ===================================== MEMBER FUNCTIONS =====================================
+
+void CLoadGenMainContainer::ConstructL(const TRect& aRect)
+    {
+    iModel = static_cast<CLoadGenDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model();
+    iModel->SetMainContainer(this);
+
+    CreateWindowL();
+    SetRect(aRect);
+    SetBlank();
+    
+    // init listbox
+    iListBox = new(ELeave) CLoadGenCAknSingleGraphicStyleListBox;
+    iListBox->SetContainerWindowL(*this);
+    iListBox->ConstructL(this, EAknListBoxMarkableList);
+    iListBox->View()->SetListEmptyTextL(_L("No loads activated\n(Select new load from Options to generate new load)"));
+
+    // create icon array and add marking indicator to it
+    CAknIconArray* iconArray = new(ELeave) CAknIconArray(1);
+    CleanupStack::PushL(iconArray);
+    CFbsBitmap* markBitmap = NULL;
+    CFbsBitmap* markBitmapMask = NULL;
+    
+    TRgb defaultColor;
+    defaultColor = iEikonEnv->Color(EColorControlText);
+
+    AknsUtils::CreateColorIconL(AknsUtils::SkinInstance(),
+            KAknsIIDQgnIndiMarkedAdd,
+            KAknsIIDQsnIconColors,
+            EAknsCIQsnIconColorsCG13,
+            markBitmap,
+            markBitmapMask,
+            AknIconUtils::AvkonIconFileName(),
+            EMbmAvkonQgn_indi_marked_add,
+            EMbmAvkonQgn_indi_marked_add_mask,
+            defaultColor
+            );
+     
+    CGulIcon* markIcon = CGulIcon::NewL(markBitmap, markBitmapMask);
+    iconArray->AppendL(markIcon);                       
+    
+    // append icons from loadgen_extraicons.mif
+    TFileName extraIconsPath;
+    extraIconsPath.Copy(KExtraIconsPath);
+    TParsePtrC parse((CEikonEnv::Static()->EikAppUi()->Application())->AppFullName()); // get path where this app is installed
+    extraIconsPath.Insert(0, parse.Drive()); // drive letter
+    
+    CFbsBitmap* redBitmap = NULL;
+    CFbsBitmap* redBitmapMask = NULL;
+    CFbsBitmap* greenBitmap = NULL;
+    CFbsBitmap* greenBitmapMask = NULL;
+    
+    AknIconUtils::CreateIconL(redBitmap, redBitmapMask, extraIconsPath, EMbmLoadgen_extraiconsQgn_prob_status_red, EMbmLoadgen_extraiconsQgn_prob_status_red_mask);
+    AknIconUtils::CreateIconL(greenBitmap, greenBitmapMask, extraIconsPath, EMbmLoadgen_extraiconsQgn_prob_status_green, EMbmLoadgen_extraiconsQgn_prob_status_green_mask);
+
+    CGulIcon* redIcon = CGulIcon::NewL(redBitmap, redBitmapMask);
+    iconArray->AppendL(redIcon);  
+    
+    CGulIcon* greenIcon = CGulIcon::NewL(greenBitmap, greenBitmapMask);
+    iconArray->AppendL(greenIcon);  
+
+    // set icon array
+    CleanupStack::Pop(); // iconArray
+    iListBox->ItemDrawer()->ColumnData()->SetIconArray(iconArray);
+
+    iListBox->CreateScrollBarFrameL(ETrue);
+    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
+    iListBox->SetListBoxObserver(this);
+    
+    // set size of the listbox
+    TSize outputRectSize;
+    AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, outputRectSize);
+    TRect outputRect(outputRectSize);
+    iListBox->SetRect(outputRect);
+
+    iListBox->ActivateL();    
+    
+    ActivateL();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenMainContainer::~CLoadGenMainContainer()
+    {
+    if (iListBox)
+        delete iListBox;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenMainContainer::SizeChanged()
+{
+    TSize outputRectSize;
+    AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, outputRectSize);
+    TRect outputRect(outputRectSize);
+    
+    if (iListBox)
+        iListBox->SetRect(outputRect);
+}
+
+// --------------------------------------------------------------------------------------------
+
+TInt CLoadGenMainContainer::CountComponentControls() const
+    {
+    if (iListBox)
+        return 1;
+    else
+        return 0;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CCoeControl* CLoadGenMainContainer::ComponentControl(TInt /*aIndex*/) const
+    {
+    if (iListBox)
+        return iListBox;
+    else
+        return NULL;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CLoadGenMainContainer::CurrentListBoxItemIndex()
+    {
+    if (iListBox)
+        {
+        return iListBox->CurrentItemIndex();
+        }
+    else
+        return KErrNotFound;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenMainContainer::SetListBoxTextArrayL(CDesCArray* aTextArray)
+    {
+    if (iListBox)
+        {    
+        iListBox->Model()->SetItemTextArray(aTextArray);
+        iListBox->Model()->SetOwnershipType(ELbmOwnsItemArray);
+        iListBox->HandleItemAdditionL();
+        iListBox->UpdateScrollBarsL();
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+const CArrayFix<TInt>* CLoadGenMainContainer::ListBoxSelectionIndexes()
+    {
+    if (iListBox)
+        {
+        const CListBoxView::CSelectionIndexArray* indices = iListBox->SelectionIndexes();
+        return static_cast<const CArrayFix<TInt>*>(indices);
+        }
+    else
+        return NULL;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CLoadGenMainContainer::ListBoxSelectionIndexesCount()
+    {
+    if (iListBox)
+        {
+        return iListBox->SelectionIndexes()->Count();
+        }
+    else
+        return KErrNotFound;
+    }
+                        
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenMainContainer::Draw(const TRect& aRect) const
+    {
+    CWindowGc& gc = SystemGc();
+    gc.Clear(aRect);
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenMainContainer::HandleControlEventL(CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenMainContainer::SetDefaultTitlePaneTextL()
+    {
+    _LIT(KTitleText, "Load Gener.");
+
+    CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
+    CAknTitlePane* tp = static_cast<CAknTitlePane*>( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
+    tp->SetTextL( KTitleText );
+    }
+        
+// --------------------------------------------------------------------------------------------
+
+TKeyResponse CLoadGenMainContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
+    {
+    if(aType != EEventKey)
+        return EKeyWasNotConsumed;
+    
+    if (iListBox && iListBox->Model()->NumberOfItems() > 0)
+        {
+        /*
+        if (aKeyEvent.iCode == EKeyBackspace || aKeyEvent.iCode == EKeyDelete)
+            {
+            iModel->StopSelectedOrHighlightedItemsL();
+            return EKeyWasConsumed;
+            }
+        else    
+            {
+            return iListBox->OfferKeyEventL(aKeyEvent, aType);
+            }
+        */
+        TBool shiftKeyPressed = (aKeyEvent.iModifiers & EModifierShift) ||
+                                (aKeyEvent.iModifiers & EModifierLeftShift) ||
+                                (aKeyEvent.iModifiers & EModifierRightShift);
+        TBool controlKeyPressed = (aKeyEvent.iModifiers & EModifierCtrl) || 
+                                  (aKeyEvent.iModifiers & EModifierRightCtrl); 
+                                  
+        
+        // handle OK/Enter keys
+        if ((aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter) && (shiftKeyPressed || controlKeyPressed))
+            {
+            return iListBox->OfferKeyEventL(aKeyEvent, aType); //send to listbox if modifiers
+            }
+
+        // handle OK/Enter keys
+        else if (aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter)
+            {
+            iModel->ShowItemActionMenuL();
+            }
+
+        // handle delete key
+        else if (aKeyEvent.iCode == EKeyBackspace || aKeyEvent.iCode == EKeyDelete)
+            {
+            iModel->StopSelectedOrHighlightedItemsL();
+            }
+
+        else
+            return iListBox->OfferKeyEventL(aKeyEvent, aType);
+        }
+    
+    return EKeyWasNotConsumed;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenMainContainer::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
+    {
+    switch (aEventType)
+        {
+        case EEventEnterKeyPressed:
+        case EEventItemDoubleClicked:
+            {
+            iModel->ShowItemActionMenuL();
+            }
+            break;
+        default:
+            break;
+        }
+    }
+            
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenMainContainer::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);
+        iListBox->SetRect(outputRect);
+        }
+    else
+        {
+        CCoeControl::HandleResourceChange(aType);
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenCAknSingleGraphicStyleListBox::SizeChanged()
+    {
+    // call the base class function first
+    CAknSingleGraphicStyleListBox::SizeChanged();
+
+    // customize the list box
+    TRAP_IGNORE(SizeChangedL());
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenCAknSingleGraphicStyleListBox::SizeChangedL()
+    {
+    const TInt KEmptySize = 2;
+    
+    // disable separator line
+    ItemDrawer()->ColumnData()->SetSeparatorLinePosition(ENoLine);
+    
+    // enable marquee
+    ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue);
+    
+    // set fonts
+    const CFont* font = AknLayoutUtils::FontFromId(EAknLogicalFontPrimarySmallFont);
+    ItemDrawer()->ColumnData()->SetColumnFontL(0, font);
+    ItemDrawer()->ColumnData()->SetColumnFontL(1, font);
+    ItemDrawer()->ColumnData()->SetColumnFontL(2, font);
+    ItemDrawer()->ColumnData()->SetColumnFontL(3, font);
+
+    // set row height
+    TInt rowHeight = font->HeightInPixels()+5;    
+    TSize itemCellSize = View()->ItemDrawer()->ItemCellSize();
+    itemCellSize.iHeight = rowHeight; 
+    SetItemHeightL(rowHeight);
+    View()->ItemDrawer()->SetItemCellSize(itemCellSize);
+    
+    // set icon sizes
+    TInt normalIconSize = rowHeight * 0.7;
+    TInt markingIconSize = rowHeight * 0.8;
+    ItemDrawer()->ColumnData()->SetSubCellIconSize(0, TSize(normalIconSize,normalIconSize));
+    ItemDrawer()->ColumnData()->SetSubCellIconSize(2, TSize(markingIconSize,markingIconSize));
+    ItemDrawer()->ColumnData()->SetSubCellIconSize(3, TSize(KEmptySize,KEmptySize));
+
+    // set column widths
+    ItemDrawer()->ColumnData()->SetColumnWidthPixelL(0, normalIconSize + 2*normalIconSize * 0.15);
+    ItemDrawer()->ColumnData()->SetColumnWidthPixelL(1, itemCellSize.iWidth-KEmptySize-markingIconSize);
+    ItemDrawer()->ColumnData()->SetColumnWidthPixelL(2, markingIconSize);
+    ItemDrawer()->ColumnData()->SetColumnWidthPixelL(3, KEmptySize);
+
+    // set baseline for the text
+    ItemDrawer()->ColumnData()->SetColumnBaselinePosL(1, font->HeightInPixels()-font->BaselineOffsetInPixels());
+
+    // set margins
+    TMargins iconMargins;
+    iconMargins.iBottom = 0;
+    iconMargins.iLeft = normalIconSize * 0.15;
+    iconMargins.iRight = normalIconSize * 0.15;
+    iconMargins.iTop = 0;
+
+    TMargins textMargins;
+    textMargins.iBottom = 0;
+    textMargins.iLeft = markingIconSize * 0.15;
+    textMargins.iRight = markingIconSize * 0.15;
+    textMargins.iTop = 0;
+
+    ItemDrawer()->ColumnData()->SetColumnMarginsL(0, iconMargins);
+    ItemDrawer()->ColumnData()->SetColumnMarginsL(1, textMargins);
+    ItemDrawer()->ColumnData()->SetColumnMarginsL(2, iconMargins);
+    ItemDrawer()->ColumnData()->SetColumnMarginsL(3, iconMargins);
+    
+/*
+    const TInt KEmptySize = 2;
+    
+    // enable marquee
+    ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue);
+    
+    // set fonts
+    const CFont* font = AknLayoutUtils::FontFromId(EAknLogicalFontPrimarySmallFont);
+    ItemDrawer()->ColumnData()->SetColumnFontL(0, font);
+    ItemDrawer()->ColumnData()->SetColumnFontL(1, font);
+    ItemDrawer()->ColumnData()->SetColumnFontL(2, font);
+    ItemDrawer()->ColumnData()->SetColumnFontL(3, font);
+
+    // set row height
+    TInt rowHeight = font->HeightInPixels()+7;    
+    TSize itemCellSize = View()->ItemDrawer()->ItemCellSize();
+    itemCellSize.iHeight = rowHeight; 
+    SetItemHeightL(rowHeight);
+    View()->ItemDrawer()->SetItemCellSize(itemCellSize);
+
+    // set icon sizes
+    TInt normalIconSize = rowHeight * 0.6;
+    TInt markingIconSize = rowHeight * 0.8;
+    ItemDrawer()->ColumnData()->SetSubCellIconSize(0, TSize(normalIconSize,normalIconSize));
+    ItemDrawer()->ColumnData()->SetSubCellIconSize(2, TSize(markingIconSize,markingIconSize));
+    ItemDrawer()->ColumnData()->SetSubCellIconSize(3, TSize(KEmptySize,KEmptySize));
+
+    // set column widths
+    ItemDrawer()->ColumnData()->SetColumnWidthPixelL(0, normalIconSize);
+    ItemDrawer()->ColumnData()->SetColumnWidthPixelL(1, itemCellSize.iWidth-KEmptySize-markingIconSize);
+    ItemDrawer()->ColumnData()->SetColumnWidthPixelL(2, markingIconSize);
+    ItemDrawer()->ColumnData()->SetColumnWidthPixelL(3, KEmptySize);
+
+    // set baseline for the text
+    ItemDrawer()->ColumnData()->SetColumnBaselinePosL(1, font->HeightInPixels()-font->BaselineOffsetInPixels());
+
+    // set margins
+    TMargins iconMargins;
+    iconMargins.iBottom = 0;
+    iconMargins.iLeft = 0;
+    iconMargins.iRight = 0;
+    iconMargins.iTop = 0;
+
+    TMargins textMargins;
+    textMargins.iBottom = 0;
+    textMargins.iLeft = markingIconSize * 0.15;
+    textMargins.iRight = markingIconSize * 0.15;
+    textMargins.iTop = 0;
+
+    ItemDrawer()->ColumnData()->SetColumnMarginsL(0, iconMargins);
+    ItemDrawer()->ColumnData()->SetColumnMarginsL(1, textMargins);
+    ItemDrawer()->ColumnData()->SetColumnMarginsL(2, iconMargins);
+    ItemDrawer()->ColumnData()->SetColumnMarginsL(3, iconMargins);
+*/
+    }
+
+// --------------------------------------------------------------------------------------------
+        
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/src/loadgen_mainview.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,175 @@
+/*
+* 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 "loadgen.hrh"
+#include "loadgen_mainview.h"
+#include "loadgen_maincontainer.h"
+#include "loadgen_document.h" 
+#include "loadgen_model.h"
+#include "loadgen_traces.h"
+#include <loadgen.rsg>
+
+#include <eikenv.h>
+#include <aknviewappui.h> 
+#include <aknnotewrappers.h>
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CLoadGenMainView::ConstructL(const TRect& aRect)
+// EPOC two-phased constructor
+// ---------------------------------------------------------
+//
+void CLoadGenMainView::ConstructL()
+    {
+    BaseConstructL( R_LOADGEN_VIEW_MAIN );
+    iModel = static_cast<CLoadGenDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model();
+    }
+
+// ---------------------------------------------------------
+// CLoadGenMainView::~CLoadGenMainView()
+// ---------------------------------------------------------
+//
+CLoadGenMainView::~CLoadGenMainView()
+    {
+    if (iContainer)
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        iContainer = NULL;
+        }
+    }
+
+// ---------------------------------------------------------
+// TUid CLoadGenMainView::Id()
+// ---------------------------------------------------------
+//
+TUid CLoadGenMainView::Id() const
+    {
+    return KMainViewUID;
+    }
+
+// ---------------------------------------------------------
+// TUid CLoadGenMainView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
+// ---------------------------------------------------------
+//
+void CLoadGenMainView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
+    {
+    AppUi()->DynInitMenuPaneL(aResourceId, aMenuPane);
+    }
+
+  
+// ---------------------------------------------------------
+// CLoadGenMainView::HandleCommandL(TInt aCommand)
+// ---------------------------------------------------------
+//
+void CLoadGenMainView::HandleCommandL(TInt aCommand)
+    {   
+    switch ( aCommand )
+        {
+        case ELoadGenCmdNewLoadCPULoad:
+        case ELoadGenCmdNewLoadEatMemory:
+        case ELoadGenCmdNewLoadPhoneCall:
+        case ELoadGenCmdNewLoadNetConn:
+        case ELoadGenCmdNewLoadKeyPress:
+        case ELoadGenCmdNewLoadMessages:
+        case ELoadGenCmdNewLoadApplications:
+        case ELoadGenCmdNewLoadPhotoCaptures:
+        case ELoadGenCmdNewLoadBluetooth:
+        case ELoadGenCmdNewLoadPointerEvent:
+            {            
+            TRAPD(err, iModel->StartNewLoadL(aCommand));
+            if( err != KErrNone )
+                {
+                LOGSTRING2("LoadGen: Load (command: %d) start failed!", aCommand);
+                _LIT(message, "Load start failed!");
+                CAknErrorNote* errorNote = new(ELeave) CAknErrorNote;
+                errorNote->ExecuteLD(message);                
+                }
+            break;
+            }
+        case ELoadGenStopAll:
+            {
+            iModel->StopAllLoadItemsL();
+            break;
+            }
+        case ELoadGenSuspendAll:
+            {
+            iModel->SuspendAllLoadItemsL();
+            break;
+            }
+        case ELoadGenResumeAll:
+            {
+            iModel->ResumeAllLoadItemsL();
+            break;
+            }            
+        default:
+            {
+            AppUi()->HandleCommandL(aCommand);
+            break;
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CLoadGenMainView::HandleClientRectChange()
+// ---------------------------------------------------------
+//
+void CLoadGenMainView::HandleClientRectChange()
+    {
+    if ( iContainer )
+        {
+        iContainer->SetRect( ClientRect() );
+        }
+    }
+
+// ---------------------------------------------------------
+// CLoadGenMainView::DoActivateL(...)
+// ---------------------------------------------------------
+//
+void CLoadGenMainView::DoActivateL(
+   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
+   const TDesC8& /*aCustomMessage*/)
+    {
+    if (!iContainer)
+        {
+        iContainer = new (ELeave) CLoadGenMainContainer;
+        iModel->SetMainContainer(iContainer);
+        iContainer->SetMopParent(this);
+        iContainer->ConstructL( ClientRect() );
+        AppUi()->AddToStackL( *this, iContainer );
+        } 
+   }
+
+// ---------------------------------------------------------
+// CLoadGenMainView::DoDeactivate()
+// ---------------------------------------------------------
+//
+void CLoadGenMainView::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/loadgen/src/loadgen_memoryeat.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,603 @@
+/*
+* 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 "loadgen_memoryeat.h"
+#include "loadgen_model.h"
+#include "loadgen.hrh"
+#include "loadgen_traces.h"
+#include <loadgen.rsg>
+
+#include <e32math.h>
+
+_LIT(KThreadName, "MemEat %d");
+_LIT(KChunkName, "LoadGen %d");
+_LIT(KFilePath, "%c:\\system\\temp\\LoadGen-%d_%d.$$$");
+
+// currently can only handle 2GB
+const TInt64 KMaxEatSize = 2147483647;
+
+const TInt KDefaultStart = 50;
+const TInt KDefaultPeriod = 5000000;
+    
+// ===================================== MEMBER FUNCTIONS =====================================
+
+CMemoryEat* CMemoryEat::NewL(TMemoryEatAttributes& aAttributes, TInt aReferenceNumber)
+    {
+    CMemoryEat* self = new(ELeave) CMemoryEat(aAttributes, aReferenceNumber);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CMemoryEat::~CMemoryEat()
+    {
+    Close();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CMemoryEat::CMemoryEat(TMemoryEatAttributes& aAttributes, TInt aReferenceNumber) : iAttributes(aAttributes)
+    {
+    iAttributes.iId = aReferenceNumber;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CMemoryEat::ConstructL()
+    {
+    CLoadBase::ConstructL();
+    
+    iType = ELoadGenCmdNewLoadEatMemory;
+    
+    TBuf<64> threadName;
+    threadName.Format(KThreadName, iAttributes.iId);
+    
+    // create a thread
+    User::LeaveIfError(iThread.Create(threadName, ThreadFunction, KDefaultStackSize*2, KMinHeapSize, 32*1024*KMinHeapSize, (TAny*) &iAttributes ));
+    
+    // set priority of the thread
+    SetPriority();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CMemoryEat::ThreadFunction(TAny* aThreadArg)
+    {
+    CTrapCleanup* pC = CTrapCleanup::New();
+    CActiveScheduler* pS = new CActiveScheduler;
+    CActiveScheduler::Install(pS);
+
+    // start memory eat, pass pointer to arguments
+    GenerateLoad(*((TMemoryEatAttributes*) aThreadArg));
+
+    delete pS;
+    delete pC;
+
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CMemoryEat::GenerateLoad(TMemoryEatAttributes& aAttributes)
+    {
+    CMemoryEatManager* memoryEatManager = NULL;
+    TRAPD(err, memoryEatManager = CMemoryEatManager::NewL(aAttributes));
+    if (err == KErrNone) CActiveScheduler::Start();
+    delete memoryEatManager;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CMemoryEat::Resume()
+    {
+    CLoadBase::Resume();
+    
+    iThread.Resume();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CMemoryEat::Suspend()
+    {
+    CLoadBase::Suspend();
+    
+    iThread.Suspend();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CMemoryEat::SetPriority()
+    {
+    CLoadBase::SetPriority();
+    
+    iThread.SetPriority(CLoadGenModel::SettingItemToThreadPriority(iAttributes.iPriority));
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CMemoryEat::Close()
+    {
+    CLoadBase::Close();
+    
+    if (iThread.ExitReason() == 0) // check if the thread is still alive
+        {
+        // signal the thread that it needs to close
+        iThread.RequestComplete(iAttributes.iDeathStatus, KErrCancel);
+
+        // wait the thread to die
+        TRequestStatus waiter;
+        iThread.Logon(waiter);
+        User::WaitForRequest(waiter);
+        iThread.Close();
+        }
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TPtrC CMemoryEat::Description()
+    {
+    TBuf<256> buf;
+    TBuf<16> prioBuf;
+    CLoadGenModel::SettingItemToThreadDescription(iAttributes.iPriority, prioBuf);
+    TBuf<16> srcBuf;
+    CLoadGenModel::SettingItemToSourceDescription(iAttributes.iSource, srcBuf);
+    
+    if (iAttributes.iType == EMemoryEatTypeMemoryToEat)
+        {
+        _LIT(KMemoryEatEntryMemoryToEat, "[%d] MemEat src=%S prio=%S type=MemToEat amount=%LDB buf=%dB idle=%dms");
+        
+        buf.Format(KMemoryEatEntryMemoryToEat, iAttributes.iId, &srcBuf, &prioBuf, iAttributes.iAmount, iAttributes.iBuffer, iAttributes.iIdle);
+        }
+    else if (iAttributes.iType == EMemoryEatTypeMemoryToBeLeft)
+        {
+        _LIT(KMemoryEatEntryMemoryToBeLeft, "[%d] MemEat src=%S prio=%S type=MemToBeLeft amount=%LDB buf=%dB idle=%dms");
+        
+        buf.Format(KMemoryEatEntryMemoryToBeLeft, iAttributes.iId, &srcBuf, &prioBuf, iAttributes.iAmount, iAttributes.iBuffer, iAttributes.iIdle);
+        }        
+
+    else if (iAttributes.iType == EMemoryEatTypeWavy)
+        {
+        _LIT(KMemoryEatEntryRandom, "[%d] MemEat src=%S prio=%S type=Random min=%LDB max=%LDB buf=%dB idle=%dms");
+        
+        buf.Format(KMemoryEatEntryRandom, iAttributes.iId, &srcBuf, &prioBuf, iAttributes.iRandomMin, iAttributes.iRandomMax, iAttributes.iBuffer, iAttributes.iIdle);
+        } 
+            
+    return TPtrC(buf);
+    }               
+
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+CMemoryEatManager* CMemoryEatManager::NewL(TMemoryEatAttributes& aAttributes)
+    {
+    CMemoryEatManager* self = new(ELeave) CMemoryEatManager(aAttributes);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CMemoryEatManager::CMemoryEatManager(TMemoryEatAttributes& aAttributes) :
+    CActive(EPriorityStandard), iAttributes(aAttributes)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+    
+CMemoryEatManager::~CMemoryEatManager()
+    {
+    Cancel();
+    DestroyMemoryEat();
+    }
+
+// --------------------------------------------------------------------------------------------
+ 
+void CMemoryEatManager::ConstructL()
+    {
+    CActiveScheduler::Add(this);
+    
+    // set the status as pending
+    iStatus = KRequestPending;
+    SetActive();
+    
+    // set the death status pointer point to the request status of this ao
+    iAttributes.iDeathStatus = &iStatus;
+    
+    // init
+    InitMemoryEatL();
+    
+    // start timer    
+    iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard);
+    iPeriodicTimer->Start(KDefaultStart, KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this));
+    }
+    
+// --------------------------------------------------------------------------------------------
+ 
+void CMemoryEatManager::RunL()
+    {
+    // request status has completed by the main thread meaning that we need to stop now
+    CActiveScheduler::Stop();
+    }
+
+// --------------------------------------------------------------------------------------------
+ 
+void CMemoryEatManager::DoCancel()
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CMemoryEatManager::PeriodicTimerCallBack(TAny* aAny)
+    {
+    TInt result = KErrNone;
+    CMemoryEatManager* self = static_cast<CMemoryEatManager*>( aAny );
+
+    self->iPeriodicTimer->Cancel();
+    TRAP( result, self->EatMemoryL() );
+
+    return result;
+    }
+    
+// --------------------------------------------------------------------------------------------
+ 
+void CMemoryEatManager::InitMemoryEatL()
+    {
+    // create a chunk for RAM
+    if (iAttributes.iSource == EMemoryEatSourceTypeRAM)
+        {
+        TBuf<64> chunkName;
+        chunkName.Format(KChunkName, iAttributes.iId);
+        
+        // set max size of the chunk to be size of the RAM memory
+        TMemoryInfoV1Buf ramMemory;
+        UserHal::MemoryInfo(ramMemory);
+    
+        User::LeaveIfError( iEatChunk.CreateGlobal(chunkName, 0, ramMemory().iMaxFreeRamInBytes-1, EOwnerThread) );
+        }
+    
+    // create a temporary file to disk
+    else
+        {
+        // connect to RFs
+        User::LeaveIfError( iFs.Connect() );
+        
+        iFilesCounter = 0;
+        
+        TFileName eatFileName;
+        eatFileName.Format( KFilePath, 'B'+iAttributes.iSource, iAttributes.iId, 1 );
+
+        iFs.MkDirAll( eatFileName );
+        User::LeaveIfError( iEatFile.Replace( iFs, eatFileName, EFileWrite ) );
+        iFilesCounter++;        
+        } 
+    
+    iWavyEatMoreMemory = ETrue;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CMemoryEatManager::DestroyMemoryEat()
+    {
+    if (iAttributes.iSource == EMemoryEatSourceTypeRAM)
+        {
+        iEatChunk.Adjust(0);
+        iEatChunk.Close();
+        }
+    else
+        {
+        // close current file
+        
+        iEatFile.Flush();
+        iEatFile.Close();
+
+        // delete created files
+        for ( TInt k = 1; k <= iFilesCounter; k++ )
+            {            
+            TFileName eatFileName;
+            eatFileName.Format( KFilePath, 'B'+iAttributes.iSource, iAttributes.iId, k );
+            iFs.Delete( eatFileName );
+            }
+        iFs.Close();
+        } 
+    }
+    
+// --------------------------------------------------------------------------------------------
+ 
+void CMemoryEatManager::EatMemoryL()
+    {
+    // get current sizes
+    TInt64 eatSizeNow(0);
+    TInt sizeNow(0);
+    TInt64 freeSystemMemory(0);
+
+    if (iAttributes.iSource == EMemoryEatSourceTypeRAM)
+        {
+        eatSizeNow = iEatChunk.Size(); // get current chunk size
+        }
+    else
+        {
+        User::LeaveIfError( iEatFile.Size( sizeNow ) );
+        if ( iFilesCounter > 1)
+            {
+            eatSizeNow += sizeNow + ( ( iFilesCounter - 1 ) * KMaxEatSize );
+        	}
+        else
+            { 
+            eatSizeNow = sizeNow ; 
+            }
+        }
+    LOGSTRING2("Loadgen:EatMemoryL eatSizeNow = %d", eatSizeNow );
+    
+    freeSystemMemory = ReadFreeMemory();
+    
+    // eat until specific amount of memory at most amount of buffer at a time  
+    if (iAttributes.iType == EMemoryEatTypeMemoryToEat)
+        {
+        // grow partial buffer to match exact amount 
+        if ( ( iAttributes.iAmount - eatSizeNow >= 0 && 
+               iAttributes.iAmount - eatSizeNow < iAttributes.iBuffer ) )
+            {
+               DoEatMemoryL( eatSizeNow + ( iAttributes.iAmount - eatSizeNow ) );
+            }
+        
+        // grow full buffer
+        else if ( eatSizeNow < iAttributes.iAmount )
+            {
+            DoEatMemoryL( eatSizeNow + iAttributes.iBuffer );
+            }
+        // shrink partial buffer to match exact amount
+        else if (eatSizeNow - iAttributes.iAmount >= 0 && eatSizeNow - iAttributes.iAmount < iAttributes.iBuffer)
+            {
+            DoEatMemoryL(eatSizeNow - (eatSizeNow - iAttributes.iAmount));
+            }                
+        
+        // shrink full buffer
+        else if (eatSizeNow > iAttributes.iAmount)
+            {
+            DoEatMemoryL(eatSizeNow - iAttributes.iBuffer);
+            }                
+        }
+
+    
+    // eat until specific amount of free memory has been reached at most amount of buffer at a time
+    else if (iAttributes.iType == EMemoryEatTypeMemoryToBeLeft)
+        {
+        // grow partial buffer to match exact amount
+        if (freeSystemMemory - iAttributes.iAmount >= 0 && freeSystemMemory - iAttributes.iAmount < iAttributes.iBuffer)
+            {
+            DoEatMemoryL(eatSizeNow + (freeSystemMemory - iAttributes.iAmount));
+            }
+
+        // grow full buffer
+        else if (freeSystemMemory > iAttributes.iAmount)
+            {
+            DoEatMemoryL(eatSizeNow + iAttributes.iBuffer);
+            }
+
+        // shrink partial buffer to match exact amount
+        if (iAttributes.iAmount - freeSystemMemory >= 0 && iAttributes.iAmount - freeSystemMemory < iAttributes.iBuffer)
+            {
+            DoEatMemoryL(eatSizeNow - (iAttributes.iAmount - freeSystemMemory));
+            }
+
+        // shrink full buffer
+        else if (freeSystemMemory < iAttributes.iAmount)
+            {
+            DoEatMemoryL(eatSizeNow - iAttributes.iBuffer);
+            }
+        }        
+        
+    // wavy memory eat
+    else if (iAttributes.iType == EMemoryEatTypeWavy)
+        {
+        // grow to max value if not under it
+        if (freeSystemMemory > iAttributes.iRandomMax)
+            {
+            DoEatMemoryL(eatSizeNow + (freeSystemMemory - iAttributes.iRandomMax) + iAttributes.iBuffer);
+            iWavyEatMoreMemory = ETrue; // change direction
+            }
+        
+        // shrink to min value if not below it
+        else if (freeSystemMemory < iAttributes.iRandomMin)
+            {
+            DoEatMemoryL(eatSizeNow - (iAttributes.iRandomMin - freeSystemMemory) - iAttributes.iBuffer);
+            iWavyEatMoreMemory = EFalse; // change direction
+            }                
+        
+        // grow or shrink
+        else
+            {
+            if (iWavyEatMoreMemory)
+                {
+                // grow partial buffer to match exact amount
+                if (freeSystemMemory - iAttributes.iRandomMin >= 0 && freeSystemMemory - iAttributes.iRandomMin < iAttributes.iBuffer)
+                    {
+                    DoEatMemoryL(eatSizeNow + (freeSystemMemory - iAttributes.iRandomMin));
+                    iWavyEatMoreMemory = EFalse; // change direction since limit reached
+                    }
+                
+                // grow full buffer
+                else
+                    {
+                    DoEatMemoryL(eatSizeNow + iAttributes.iBuffer);
+                    }
+                }
+
+            else // shrink
+                {
+                // shrink partial buffer to match exact amount
+                if (iAttributes.iRandomMax - freeSystemMemory >= 0 && iAttributes.iRandomMax - freeSystemMemory < iAttributes.iBuffer)
+                    {
+                    DoEatMemoryL(eatSizeNow - (iAttributes.iRandomMax - freeSystemMemory));
+                    iWavyEatMoreMemory = ETrue; // change direction since limit reached
+                    }                
+                
+                // shrink full buffer
+                else
+                    {
+                    DoEatMemoryL(eatSizeNow - iAttributes.iBuffer);
+                    }                 
+                }
+            }
+        }
+        
+
+    // call timer
+    iPeriodicTimer->Start(CLoadGenModel::MilliSecondsToMicroSeconds(iAttributes.iIdle, iAttributes.iRandomVariance), KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this));
+    }
+    
+// --------------------------------------------------------------------------------------------
+ 
+void CMemoryEatManager::DoEatMemoryL( TInt64 aNewSize )
+    {
+    // check that new size is in valid range
+    if (aNewSize < 0)
+        {
+        aNewSize = 0;
+        }
+    LOGSTRING2("Loadgen::DoEatMemoryL aNewSize = %d", aNewSize );
+    // set new size
+    if (iAttributes.iSource == EMemoryEatSourceTypeRAM)
+        {
+        TInt err = iEatChunk.Adjust( aNewSize );
+        }
+    else
+        {
+        HandleEatMemoryL( aNewSize );
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CMemoryEatManager::HandleEatMemoryL( TInt64 aNewSize )
+    {
+    // current size = open file size + full files sizes
+    TInt currentFileSize = 0;        
+    User::LeaveIfError( iEatFile.Size( currentFileSize ) );    
+    TInt64 currentSize = currentFileSize + ( ( iFilesCounter - 1 ) * KMaxEatSize );
+    
+    if ( aNewSize > currentSize ) // increasing
+        {
+        AllocMemoryL( aNewSize );
+        }
+    else if ( aNewSize < currentSize )//decreasing
+        {
+        FreeMemoryL( aNewSize );
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+void CMemoryEatManager::AllocMemoryL( TInt64 aNewSize )
+    {
+    LOGSTRING("Loadgen: CMemoryEatManager::AllocMemoryL =>");
+    // size of the file that remains open
+    TInt64 sizeLeft = aNewSize % KMaxEatSize;
+    // amount of the files that is needed
+    TInt64 filesNeeded = aNewSize / KMaxEatSize; 
+    if ( sizeLeft > 0 )
+        {
+        filesNeeded++;
+        }
+
+    if ( filesNeeded > iFilesCounter )
+        {
+        // update current file size to 2 GB
+        User::LeaveIfError( iEatFile.SetSize( KMaxEatSize ) );
+        // close current file
+        iEatFile.Flush();
+        iEatFile.Close();
+        
+        // open new file
+        TFileName eatFileName;
+        eatFileName.Format( KFilePath, 'B'+iAttributes.iSource, iAttributes.iId, ++iFilesCounter );
+        
+        iFs.MkDirAll( eatFileName );
+        User::LeaveIfError( iEatFile.Replace( iFs, eatFileName, EFileWrite ) );
+        
+        }
+    User::LeaveIfError( iEatFile.SetSize( sizeLeft ) );
+    LOGSTRING("Loadgen: CMemoryEatManager::AllocMemoryL <=");
+    }
+
+// --------------------------------------------------------------------------------------------
+void CMemoryEatManager::FreeMemoryL( TInt64 aNewSize )    
+    {
+    LOGSTRING("Loadgen: CMemoryEatManager::FreeMemoryL =>");
+    // size of the file that remains open
+    TInt sizeLeft = aNewSize % KMaxEatSize;
+        
+    LOGSTRING2("Loadgen: sizeLeft = %d ",  sizeLeft );
+    // amount of the files that is needed
+    TInt filesNeeded = aNewSize / KMaxEatSize; 
+  
+    if ( filesNeeded == 0 )
+            {
+            filesNeeded = 1;
+            }
+
+    if ( iFilesCounter > 1 && filesNeeded < iFilesCounter )
+        {
+        TFileName eatFileName;
+
+        // close current open file 
+        iEatFile.Flush();
+        iEatFile.Close();
+        // remove file
+        eatFileName.Format( KFilePath, 'B'+iAttributes.iSource, iAttributes.iId, iFilesCounter-- );
+        iFs.Delete( eatFileName );
+        
+        // remove files not needed
+        while ( iFilesCounter > filesNeeded )
+            {
+            eatFileName.Format( KFilePath, 'B'+iAttributes.iSource, iAttributes.iId, iFilesCounter-- );
+            iFs.Delete( eatFileName );
+            }
+
+        // open new file
+        eatFileName.Format( KFilePath, 'B'+iAttributes.iSource, iAttributes.iId, iFilesCounter );
+        User::LeaveIfError( iEatFile.Open( iFs, eatFileName, EFileWrite ) );
+        }
+    User::LeaveIfError( iEatFile.SetSize( sizeLeft ) );
+    LOGSTRING("Loadgen: CMemoryEatManager::FreeMemoryL <=");
+    }
+
+// --------------------------------------------------------------------------------------------
+TInt64 CMemoryEatManager::ReadFreeMemory()    
+    {
+    if ( iAttributes.iSource == EMemoryEatSourceTypeRAM )
+        {   
+        TMemoryInfoV1Buf ramMemory;
+        UserHal::MemoryInfo( ramMemory ); // get available RAM
+        return (TInt64)ramMemory().iFreeRamInBytes;
+        }
+    else
+        {   
+        TVolumeInfo volumeInfo;
+        iFs.Volume( volumeInfo, iAttributes.iSource + 1 ); // get available disk      
+        return volumeInfo.iFree;
+        }
+    }
+// --------------------------------------------------------------------------------------------
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/src/loadgen_messages.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,978 @@
+/*
+* 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 "loadgen_messages.h"
+#include "loadgen_model.h"
+#include "loadgen.hrh"
+#include <loadgen.rsg>
+#include <e32math.h>
+
+_LIT(KThreadName, "Messages %d");
+_LIT(KMessageSMS, "A test message from LoadGen S60 RnD tool. ");
+_LIT( KMessageSMSType, "SMS" );
+_LIT( KMessageMMSType, "MMS" );
+
+const TInt KTestMessageLength = 42;
+const TInt KDefaultStart = 50;
+const TInt KDefaultPeriod = 5000000;
+
+// ===================================== MEMBER FUNCTIONS =====================================
+
+CMessages* CMessages::NewL( TMessageAttributes& aAttributes, TInt aReferenceNumber )
+    {
+    CMessages* self = new(ELeave) CMessages( aAttributes, aReferenceNumber );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CMessages::~CMessages()
+    {
+    Close();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CMessages::CMessages( TMessageAttributes& aAttributes, 
+                       TInt aReferenceNumber ) 
+                            : iAttributes( aAttributes )
+    {
+    iAttributes.iId = aReferenceNumber;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CMessages::ConstructL()
+    {
+    CLoadBase::ConstructL();
+    
+    iType = ELoadGenCmdNewLoadMessages;
+    
+    TBuf<64> threadName;
+    threadName.Format( KThreadName, iAttributes.iId );
+    
+    // create a thread
+    User::LeaveIfError( iThread.Create( threadName, 
+                                        ThreadFunction, 
+                                        KDefaultStackSize * 2, 
+                                        KMinHeapSize, 
+                                        1024 * KMinHeapSize, 
+                                        (TAny*) &iAttributes ) );
+    
+    // set priority of the thread
+    SetPriority();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CMessages::ThreadFunction(TAny* aThreadArg)
+    {
+    CTrapCleanup* pC = CTrapCleanup::New();
+    CActiveScheduler* pS = new CActiveScheduler;
+    CActiveScheduler::Install( pS );
+
+    // start generating load, pass pointer to arguments
+    GenerateLoad( *( ( TMessageAttributes* ) aThreadArg ) );
+
+    delete pS;
+    delete pC;
+    
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CMessages::GenerateLoad( TMessageAttributes& aAttributes )
+    {
+    CMessageManager* messagesManager = NULL;
+    TRAPD( err, messagesManager = CMessageManager::NewL( aAttributes ) );
+
+    if ( err == KErrNone )
+        {
+        CActiveScheduler::Start();
+        }
+    delete messagesManager;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CMessages::Resume()
+    {
+    CLoadBase::Resume();
+    
+    iThread.Resume();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CMessages::Suspend()
+    {
+    CLoadBase::Suspend();
+    
+    iThread.Suspend();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CMessages::SetPriority()
+    {
+    CLoadBase::SetPriority();
+    
+    iThread.SetPriority( CLoadGenModel::SettingItemToThreadPriority( iAttributes.iPriority ) );
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CMessages::Close()
+    {
+    CLoadBase::Close();
+
+    if ( iThread.ExitReason() == 0 ) // check if the thread is still alive
+        {
+        // signal the thread that it needs to close
+        iThread.RequestComplete( iAttributes.iDeathStatus, KErrCancel );
+
+        // wait the thread to die
+        TRequestStatus waiter;
+        iThread.Logon( waiter );
+        User::WaitForRequest( waiter );
+        iThread.Close();
+        }
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TPtrC CMessages::Description()
+    {
+    TBuf<256> buf;
+    TBuf<16> prioBuf;
+    TBuf<3> typeBuf;
+    CLoadGenModel::SettingItemToThreadDescription( iAttributes.iPriority, prioBuf );
+    if ( iAttributes.iMessageType == EMessageTypeSMS )
+        {
+        typeBuf.Copy( KMessageSMSType );
+        }
+    else
+        {
+        typeBuf.Copy( KMessageMMSType );
+        }
+    _LIT(KMessagesEntry, "[%d] Type=%S prio=%S dest=%S idle=%dms random=%d%%");
+    buf.Format( KMessagesEntry,  iAttributes.iId, &typeBuf, &prioBuf, &iAttributes.iDestination, 
+                iAttributes.iIdle, iAttributes.iRandomVariance );
+    
+    return TPtrC( buf );
+    }               
+// --------------------------------------------------------------------------------------------
+
+CMessageManager* CMessageManager::NewL( TMessageAttributes& aAttributes )
+    {
+    CMessageManager* self = new(ELeave) CMessageManager( aAttributes );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------------------------
+CMessageManager::CMessageManager( TMessageAttributes& aAttributes ) :
+    CActive( EPriorityStandard ), iAttributes( aAttributes ), iState( EStateIdle )
+    {
+    iMessageCounter = 0;
+    }
+
+// --------------------------------------------------------------------------------------------
+    
+CMessageManager::~CMessageManager()
+    {
+    Cancel();
+    delete iMessage;
+    if ( iPeriodicTimer )
+        {
+        iPeriodicTimer->Cancel();
+        delete iPeriodicTimer;
+        }
+    if ( iAttributes.iMessageType == EMessageTypeSMS && iSmsHandler )
+        {
+        delete iSmsHandler;
+        }
+    else if ( iMmsHandler )
+        {
+        delete iMmsHandler;
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+ 
+void CMessageManager::ConstructL()
+    {
+    CActiveScheduler::Add( this );
+    
+    // set the status as pending
+    iStatus = KRequestPending;
+    SetActive();
+    
+    // set the death status pointer point to the request status of this ao
+    iAttributes.iDeathStatus = &iStatus;
+    if ( iAttributes.iAmount > 0 )
+        {
+        iState = EStateSend;
+        }
+    iMessage = HBufC::NewL( iAttributes.iLength );
+    CreateMessage();
+
+    // init SMS sender ao
+    if ( iAttributes.iMessageType == EMessageTypeSMS )
+        {
+        iSmsHandler = CSmsHandler::NewL( *this );
+        }
+    else
+        {
+        iMmsHandler = CMmsHandler::NewL( *this );
+        }
+    // start timer    
+    iPeriodicTimer = CPeriodic::NewL( CActive::EPriorityStandard );
+    iPeriodicTimer->Start( KDefaultStart, KDefaultPeriod, 
+                        TCallBack( PeriodicTimerCallBack, this ) );
+    }
+
+// --------------------------------------------------------------------------------------------
+ 
+void CMessageManager::RunL()
+    {
+    // request status has completed by the main thread meaning that we need to stop now
+    CActiveScheduler::Stop();
+    }
+
+// --------------------------------------------------------------------------------------------
+ 
+void CMessageManager::DoCancel()
+    {
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TInt CMessageManager::PeriodicTimerCallBack(TAny* aAny)
+    {
+    CMessageManager* self = static_cast<CMessageManager*>( aAny );
+
+    self->iPeriodicTimer->Cancel();
+    self->HandleMessageSending();
+
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CMessageManager::CreateMessage()
+    {
+    // Message body
+    TBuf<KTestMessageLength> mToYou( KMessageSMS );
+    TPtr ptr = iMessage->Des();
+
+    // Take as many characters as user requested to create the message
+    for ( TInt j = 0; j < iAttributes.iLength; j++ )
+          {
+           for ( TInt k = 0; k < KTestMessageLength;  k++ )
+               {
+               ptr.Append( mToYou[k] );
+               j++;
+               if ( j == iAttributes.iLength )
+                   {
+                   break;
+                   }
+               }        
+           }
+    }
+
+
+// --------------------------------------------------------------------------------------------
+
+void CMessageManager::HandleMessageSending()
+    {
+    if ( iState == EStateSend && iAttributes.iDestination.Length() <= KTelephoneNumberMaxLength )
+        {
+        TBool err( KErrNone );        
+
+        // make a new call
+        iState = EStateSending;
+ 
+        iMessageCounter++;
+        if ( iAttributes.iMessageType == EMessageTypeSMS )
+            {
+            TRAP( err, iSmsHandler->SendL( iAttributes.iDestination, *iMessage ) );
+            if ( !err )
+                {
+                iState = EStateIdle;
+                iPeriodicTimer->Start( CLoadGenModel::MilliSecondsToMicroSeconds( iAttributes.iIdle,
+                            iAttributes.iRandomVariance ), KDefaultPeriod, 
+                            TCallBack( PeriodicTimerCallBack, this ) );
+
+                }
+            }
+        else
+            {
+            TRAP( err, iMmsHandler->SendL( iAttributes.iDestination, *iMessage ) );            
+            if ( err )
+                {
+                HandleStatus( EStateIdle );
+                }
+            }
+        }
+    else
+        {
+        iState = EStateIdle;
+        iPeriodicTimer->Start( CLoadGenModel::MilliSecondsToMicroSeconds( iAttributes.iIdle,
+                    iAttributes.iRandomVariance ), KDefaultPeriod, 
+                    TCallBack( PeriodicTimerCallBack, this ) );
+
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CMessageManager::HandleStatus( TInt /*aErr*/ )
+    {
+    // timer after wait
+    if ( iMessageCounter < iAttributes.iAmount )
+        {
+        iState = EStateSend;
+        iPeriodicTimer->Cancel();
+        iPeriodicTimer->Start( CLoadGenModel::MilliSecondsToMicroSeconds( iAttributes.iIdle,
+                    iAttributes.iRandomVariance ), KDefaultPeriod, 
+                    TCallBack( PeriodicTimerCallBack, this ) );
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+// INCLUDE FILES
+#include <eikenv.h>
+#include <coemain.h>
+#include <e32std.h>
+#include <msvids.h>
+#include <msvstd.h>
+#include <smsclnt.h>
+#include <smut.h>
+#include <mtclreg.h>
+#include <txtrich.h>
+#include <smscmds.h>
+#include <mtmuibas.h>
+#include <mtmdef.h>
+#include <stringloader.h>
+#include "smutset.h"
+#include "smuthdr.h"
+ 
+ 
+ 
+// ============================ MEMBER FUNCTIONS ===============================
+// -----------------------------------------------------------------------------
+// CSmsHandler::CSmsHandler()
+// C++ default constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+//
+CSmsHandler::CSmsHandler( CMessageManager& aManager )
+    : CActive( CActive::EPriorityStandard ), iManager( aManager )
+    {
+    CActiveScheduler::Add( this );
+    }
+ 
+// -----------------------------------------------------------------------------
+// CSmsHandler::ConstructL()
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CSmsHandler::ConstructL()
+    {
+    // Session to message server is opened asynchronously.
+    iSession = CMsvSession::OpenAsyncL( *this );
+ 
+    }
+ 
+// -----------------------------------------------------------------------------
+// CSmsHandler::NewL()
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CSmsHandler* CSmsHandler::NewL( CMessageManager& aManager  )
+    {
+    CSmsHandler* self = NewLC( aManager );
+    CleanupStack::Pop( self );
+    return self;
+    }
+ 
+// -----------------------------------------------------------------------------
+// CSmsHandler::NewLC()
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CSmsHandler* CSmsHandler::NewLC(  CMessageManager& aManager )
+    {
+    CSmsHandler* self = new ( ELeave ) CSmsHandler( aManager );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+ 
+// ----------------------------------------------------------
+// CSmsHandler::~CSmsHandler()
+// Destructor.
+// ----------------------------------------------------------
+//
+CSmsHandler::~CSmsHandler()
+    {
+    Cancel();           // cancel any outstanding request
+ 
+    delete iOperation;
+    delete iMtmUiRegistry;
+    delete iSmsMtm;
+    delete iMtmRegistry;
+    delete iSession;    // session must be deleted last
+    }
+ 
+// -----------------------------------------------------------------------------
+// CSmsHandler::DoCancel()
+// Cancels a request.
+// -----------------------------------------------------------------------------
+//
+void CSmsHandler::DoCancel()
+    {
+    if ( iOperation )
+        {
+        iOperation->Cancel();
+        }
+    }
+ 
+// -----------------------------------------------------------------------------
+// CSmsHandler::RunL()
+// Handles request completion events.
+// -----------------------------------------------------------------------------
+//
+void CSmsHandler::RunL()
+    {
+    User::LeaveIfError( iStatus != KErrNone );
+ 
+    // Determine the current operations progress.
+    // ProgressL returns an 8 bit descriptor.
+    TBufC8<KMsvProgressBufferLength> progress( iOperation->ProgressL() );
+    _LIT8( KCompare, "KErrNone" );
+    User::LeaveIfError( !progress.Compare( KCompare ) );
+ 
+    // The pointer to the current CMsvOperation object is no longer needed.
+    delete iOperation;
+    iOperation = NULL;
+ 
+    // Determine which request has finished.
+    switch ( iState )
+        {
+        case EWaitingForMoving:
+            // Once a message is moved to Outbox it is scheduled for sending.
+            ScheduleL();
+            break;
+ 
+        case EWaitingForScheduling:
+            {
+            TMsvEntry entry( iSmsMtm->Entry().Entry() );
+            TInt state( entry.SendingState() );
+ 
+            if ( state == KMsvSendStateWaiting || state == KMsvSendStateScheduled)
+                {
+                // notify the observer that status has changed
+                iManager.HandleStatus( iStatus.Int() );
+                }
+            break;
+            }
+ 
+        default:
+            break;
+        }
+    }
+ 
+// -----------------------------------------------------------------------------
+// CSmsHandler::HandleSessionEventL()
+// Handles notifications of events from the Message Server.
+// -----------------------------------------------------------------------------
+//
+void CSmsHandler::HandleSessionEventL( TMsvSessionEvent aEvent,
+                                      TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/)
+    {
+    switch ( aEvent )
+        {
+        // Session to server established
+        case EMsvServerReady:
+            {
+            TMsvId serviceId( KUidMsgTypeSMS.iUid ); // SMS service id
+ 
+            // Determine if the event was succesful.
+            // ServiceProgress inserts TBuf8 value in progress.
+            TBuf8<KBfrLength> progress;
+            iSession->ServiceProgress( serviceId, progress );
+            _LIT8( KCompare, "KErrNone" );
+ 
+            if ( progress.Compare( KCompare ) )
+                {
+                // Check that MtmRegistry has not already been accessed.
+                if ( !iMtmRegistry )
+                    {
+                    AccessMtmL();
+                    }
+                }
+            break;
+            }
+ 
+        // All other events are ignored.
+        default:
+            break;
+        }
+    }
+ 
+// -----------------------------------------------------------------------------
+// CSmsHandler::AccessMtmL()
+// Access the MTM Registry and create a SMS specific Client MTM instance.
+// -----------------------------------------------------------------------------
+//
+void CSmsHandler::AccessMtmL()
+    {
+    // Create an MTM Registry object.
+    iMtmRegistry = CClientMtmRegistry::NewL( *iSession );
+ 
+    // Create an SMS Client MTM object.
+    iSmsMtm = STATIC_CAST( CSmsClientMtm*, iMtmRegistry->NewMtmL( KUidMsgTypeSMS ) );
+    }
+ 
+// -----------------------------------------------------------------------------
+// CSmsHandler::SendL()
+// Starts the process of creating and sending an SMS message.
+// -----------------------------------------------------------------------------
+//
+TBool CSmsHandler::SendL( const TDesC& aRecipientNumber,
+                            const TDesC& aMessageText )
+    {
+    iRecipientNumber = aRecipientNumber;
+    iMessageText = aMessageText;
+ 
+    if ( CreateMsgL() )
+        {
+        return ETrue;
+        }
+ 
+    return EFalse;
+    }
+ 
+// -----------------------------------------------------------------------------
+// CSmsHandler::CreateMsgL()
+// Create an SMS message.
+// -----------------------------------------------------------------------------
+//
+TBool CSmsHandler::CreateMsgL()
+    {
+    // Current entry is the Draft folder.
+    iSmsMtm->SwitchCurrentEntryL( KMsvDraftEntryId );
+ 
+    // Create a new SMS message entry as a child of the current context.
+    iSmsMtm->CreateMessageL( KUidMsgTypeSMS.iUid );
+ 
+    CMsvEntry& serverEntry = iSmsMtm->Entry();
+    TMsvEntry entry( serverEntry.Entry() );
+ 
+    CRichText& body = iSmsMtm->Body();   // the body of the message
+    body.Reset();
+    // Insert the message text gotten as input from user.
+    body.InsertL( 0, iMessageText );
+ 
+    // Message will be sent immediately.
+    entry.SetSendingState( KMsvSendStateWaiting );
+ 
+    entry.iDate.UniversalTime(); // insert current time //Solution for HomeTime()
+
+    // Set the SMS message settings for the message.
+    CSmsHeader& header = iSmsMtm->SmsHeader();
+    CSmsSettings* settings = CSmsSettings::NewL();
+    CleanupStack::PushL( settings );
+ 
+    settings->CopyL( iSmsMtm->ServiceSettings() );    // restore settings
+    settings->SetDelivery( ESmsDeliveryImmediately ); // to be delivered immediately
+    settings->SetDeliveryReport(ETrue);
+    header.SetSmsSettingsL( *settings );              // new settings
+ 
+    // Let's check if there is a service center address.
+    if ( header.Message().ServiceCenterAddress().Length() == 0 )
+        {
+        // No, there isn't. We assume there is at least one service center
+        // number set and use the default service center number.
+        CSmsSettings* serviceSettings = &( iSmsMtm->ServiceSettings() );
+ 
+        // Check if number of service center addresses in the list is null.
+ 
+        //Changed for 3rd Edition specially
+        if ( !serviceSettings->ServiceCenterCount() )
+            {
+            CleanupStack::PopAndDestroy( settings ); 
+            return EFalse;     // quit creating the message
+            }
+ 
+        else
+            {
+            //Changed for 3rd Edition specially            
+            CSmsNumber* smsCenter= CSmsNumber::NewL();
+            CleanupStack::PushL(smsCenter);
+            smsCenter->SetAddressL((serviceSettings->GetServiceCenter( 
+                            serviceSettings->DefaultServiceCenter())).Address());
+            header.Message().SetServiceCenterAddressL( smsCenter->Address() );
+            CleanupStack::PopAndDestroy(smsCenter);
+            }
+        }
+ 
+    CleanupStack::PopAndDestroy( settings );
+ 
+    // Recipient number is displayed also as the recipient alias.
+    entry.iDetails.Set( iRecipientNumber );
+    // Add addressee.
+    iSmsMtm->AddAddresseeL( iRecipientNumber, entry.iDetails );
+ 
+    // Validate message.
+    if ( !ValidateL() )
+        {
+        return EFalse;
+        }
+ 
+    entry.SetVisible( ETrue );          // set message as visible
+    entry.SetInPreparation( EFalse );   // set together with the visibility flag
+    serverEntry.ChangeL( entry );       // commit changes        
+    iSmsMtm->SaveMessageL();            // save message
+ 
+    TMsvSelectionOrdering selection;
+    CMsvEntry* parentEntry = CMsvEntry::NewL( iSmsMtm->Session(), KMsvDraftEntryId, selection );
+    CleanupStack::PushL( parentEntry );
+ 
+    // Move message to Outbox.
+    iOperation =parentEntry->MoveL( entry.Id(), KMsvGlobalOutBoxIndexEntryId, iStatus );
+ 
+    CleanupStack::PopAndDestroy( parentEntry );
+ 
+    iState = EWaitingForMoving;
+    SetActive();
+ 
+    return ETrue;
+  }
+ 
+// -----------------------------------------------------------------------------
+// CSmsHandler::ValidateL()
+// Validate an SMS message.
+// -----------------------------------------------------------------------------
+//
+TBool CSmsHandler::ValidateL()
+    {
+    // Empty part list to hold the result.
+    TMsvPartList result( KMsvMessagePartNone );
+ 
+    // Validate message body.
+    result = iSmsMtm->ValidateMessage( KMsvMessagePartBody );
+ 
+    if ( result != KMsvMessagePartNone )
+        {
+        return EFalse;
+        }
+ 
+    // Validate recipient.
+    result = iSmsMtm->ValidateMessage( KMsvMessagePartRecipient );
+ 
+    if ( result != KMsvMessagePartNone )
+        {
+        return EFalse;
+        }
+ 
+    return ETrue;
+    }
+ 
+// -----------------------------------------------------------------------------
+// CSmsHandler::ScheduleL()
+// Schedule an SMS message for sending.
+// -----------------------------------------------------------------------------
+//
+void CSmsHandler::ScheduleL()
+    {
+    CMsvEntrySelection* selection = new ( ELeave ) CMsvEntrySelection;
+    CleanupStack::PushL( selection );
+    selection->AppendL( iSmsMtm->Entry().EntryId() ); // add message to selection
+ 
+    // Add entry to task scheduler.
+    TBuf8<1> dummyParams;   // dummy parameters needed for InvokeAsyncFunctionL
+    iOperation = iSmsMtm->InvokeAsyncFunctionL( ESmsMtmCommandScheduleCopy,
+                          *selection, dummyParams, iStatus );
+ 
+    CleanupStack::PopAndDestroy( selection );
+ 
+    iState = EWaitingForScheduling;
+    SetActive();
+    }
+ 
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+
+
+// INCLUDE FILES
+#include <mtclreg.h>                  // for CClientMtmRegistry 
+#include <msvids.h>                   // for Message type IDs
+#include <mmsclient.h>                // for CMmsClientMtm
+#include <AknQueryDialog.h>           // for CAknTextQueryDialog
+#include <f32file.h>                
+#include <coeutils.h>                  // Check the file exist
+
+#include <CMsvMimeHeaders.h>        //Attachemt mimeheader
+#include <MMsvAttachmentManager.h>    //Attachment manager
+
+// -----------------------------------------------------------------------------
+// CMmsHandler::CSmsHandler()
+// C++ default constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+//
+CMmsHandler::CMmsHandler( CMessageManager& aManager ) : iManager( aManager )
+    {
+    }
+ 
+// -----------------------------------------------------------------------------
+// CMmsHandler::ConstructL()
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CMmsHandler::ConstructL()
+    {
+    // Session to message server is opened asynchronously.
+    iSession = CMsvSession::OpenAsyncL( *this );
+ 
+    }
+ 
+// -----------------------------------------------------------------------------
+// CMmsHandler::NewL()
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CMmsHandler* CMmsHandler::NewL( CMessageManager& aManager  )
+    {
+    CMmsHandler* self = NewLC( aManager );
+    CleanupStack::Pop( self );
+    return self;
+    }
+ 
+// -----------------------------------------------------------------------------
+// CMmsHandler::NewLC()
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CMmsHandler* CMmsHandler::NewLC(  CMessageManager& aManager )
+    {
+    CMmsHandler* self = new ( ELeave ) CMmsHandler( aManager );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+ 
+// ----------------------------------------------------------
+// CMmsHandler::~CSmsHandler()
+// Destructor.
+// ----------------------------------------------------------
+//
+CMmsHandler::~CMmsHandler()
+    {
+    delete iMmsMtm;
+    delete iMtmReg;
+    delete iSession;    // session must be deleted last (and constructed first)
+    }
+
+/*
+-----------------------------------------------------------------------------
+    CMmsHandler::CompleteConstructL()
+    Creates client MTM registry when session is ready for use. 
+    This completes model construction and is called after 'server
+    ready' event is received after async opening of CMsvSession.
+-----------------------------------------------------------------------------
+*/
+void CMmsHandler::CompleteConstructL()
+    {
+    // We get a MtmClientRegistry from our session
+    // this registry is used to instantiate new mtms.
+    iMtmReg = CClientMtmRegistry::NewL( *iSession );
+    iMmsMtm = (CMmsClientMtm*)iMtmReg->NewMtmL( KUidMsgTypeMultimedia );
+    }
+   
+/*
+-----------------------------------------------------------------------------
+    CMmsHandler::HandleSessionEventL()
+
+    Receives session events from observer and calls event handling functions. 
+    Note that if additional session event handlers are defined 
+    in the session, they are called before this function (as this is the
+    main session observer).
+    The type of event is indicated by the value of aEvent. The 
+    interpretation of the TAny arguments depends on this type. 
+-----------------------------------------------------------------------------
+*/
+void CMmsHandler::HandleSessionEventL(TMsvSessionEvent aEvent, 
+                                        TAny* /*aArg1*/, 
+                                        TAny* /*aArg2*/, 
+                                        TAny* /*aArg3*/)
+    {
+    switch ( aEvent )
+        {
+        // This event tells us that the session has been opened
+        case EMsvServerReady:
+            {
+            CompleteConstructL();       // Construct the mtm registry & MMS mtm
+            break;
+            }
+        default:
+            {
+            break;
+            }
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSmsHandler::SendL()
+// Starts the process of creating and sending an SMS message.
+// -----------------------------------------------------------------------------
+//
+TBool CMmsHandler::SendL( const TDesC& aRecipientNumber,
+                            const TDesC& aMessageText )
+    {
+    TInt result( EFalse );
+    
+    iRecipientNumber = aRecipientNumber;
+    iMessageText = aMessageText;
+ 
+    if ( CreateMsgL() )
+        {
+        if ( SendMessageL() )
+            {
+            result = ETrue;
+            }
+        }
+ 
+    return result;
+    }
+
+/*
+-----------------------------------------------------------------------------
+    CMmsHandler::CreateMsgL()
+    Creates a new message server entry and set up default values.
+    In case the attachment file does not found method return EFalse
+    otherwise ETrue.
+    There are differenses how to add attachment file between 2nd and 3rd edition. 
+-----------------------------------------------------------------------------
+*/
+TBool CMmsHandler::CreateMsgL()
+    {
+
+    // - CMsvEntry accesses and acts upon a particular Message Server entry.
+    // - NewL() does not create a new entry, but simply a new object to access an existing entry.
+    // - It takes in as parameters the client's message server session,
+    //   ID of the entry to access and initial sorting order of the children of the entry. 
+    CMsvEntry* entry = CMsvEntry::NewL( *iSession, 
+                                        KMsvGlobalOutBoxIndexEntryId, 
+                                        TMsvSelectionOrdering() );
+    CleanupStack::PushL( entry );
+
+    // Set context to the parent folder (Outbox)
+    iMmsMtm->SwitchCurrentEntryL( entry->EntryId() );
+    
+    // Create new message in the parent folder (Outbox) and set it as the current context.
+    iMmsMtm->CreateMessageL( iMmsMtm->DefaultServiceL() );
+
+    CleanupStack::PopAndDestroy( entry ); 
+    
+    // Setting recipients
+    // use this to add the "To" recipients.
+    iMmsMtm->AddAddresseeL( iRecipientNumber );
+    
+    //Setting message subject
+    _LIT(KMessageSubject, "MMS Message");
+    iMmsMtm->SetSubjectL( KMessageSubject );
+    
+    // add message text
+    SetMessageBodyL();
+   
+    TMsvEntry ent = iMmsMtm->Entry().Entry();
+    // Set InPreparation to false
+    ent.SetInPreparation( EFalse );
+    ent.SetVisible( ETrue );            // mark as visible, after this the message can be seen in Outbox and, after sending, in Sent folder.
+  
+    iMmsMtm->Entry().ChangeL( ent );    // Commit changes
+    
+    //Save the changes
+    iMmsMtm->SaveMessageL();
+    
+    return ETrue;
+    }
+
+//---------------------------------------------------------------------------------
+void CMmsHandler::SetMessageBodyL()
+    {
+    _LIT (KFilenameText, "msg.txt");
+    CMsvStore* store = iMmsMtm->Entry().EditStoreL();
+    CleanupStack::PushL( store );
+
+    TMsvAttachmentId attachmentId = KMsvNullIndexEntryId;
+
+    iMmsMtm->CreateTextAttachmentL ( *store,
+                                     attachmentId,
+                                     iMessageText,
+                                     KFilenameText );
+
+    store->CommitL();
+
+    CleanupStack::PopAndDestroy( store );
+    }
+
+/* 
+-----------------------------------------------------------------------------
+    CMmsHandler::SendMessageL()
+    Sends the message.
+    Return values: ETrue or EFalse
+-----------------------------------------------------------------------------
+*/
+TBool CMmsHandler::SendMessageL()
+    {
+
+    // Start sending the message via the Server MTM to the MMS server
+    CMsvOperationWait* wait = CMsvOperationWait::NewLC();
+    wait->iStatus = KRequestPending;
+    CMsvOperation* op = NULL;
+       op = iMmsMtm->SendL( wait->iStatus );
+    wait->Start();
+    CleanupStack::PushL( op );
+    CActiveScheduler::Start();
+
+    // The following is to ignore the completion of other active objects. It is not
+    // needed if the app has a command absorbing control.
+    while( wait->iStatus == KRequestPending )
+        {
+        CActiveScheduler::Start();
+        }
+
+    iManager.HandleStatus( wait->iStatus.Int() );
+    CleanupStack::PopAndDestroy(2); // op, wait
+    
+    return ETrue;
+    }
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/src/loadgen_model.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,1140 @@
+/*
+* 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 "loadgen_cpuload.h"
+#include "loadgen_memoryeat.h"
+#include "loadgen_phonecall.h"
+#include "loadgen_netconn.h"
+#include "loadgen_keypress.h"
+#include "loadgen_pointerevent.h"
+#include "loadgen_messages.h"
+#include "loadgen_applications.h"
+#include "loadgen_photocapture.h"
+#include "loadgen_bluetooth.h"
+
+#include "loadgen_traces.h"
+#include "loadgen_editors.h"
+#include "loadgen_loadattributes.h"
+#include "loadgen_model.h"
+#include "loadgen_app.h"
+#include "loadgen_settingsviewdlg.h"
+#include "loadgen_maincontainer.h"
+#include "loadgen.hrh"
+#include <loadgen.rsg>
+
+#include <coeutils.h>
+#include <bautils.h>
+#include <eikenv.h>
+#include <aknquerydialog.h>
+#include <e32math.h> 
+#include <u32hal.h>
+#include <hal.h> 
+#include <hal_data.h>
+
+#include <ECam.h>
+#include <aknnotewrappers.h>
+#include <featdiscovery.h>
+
+inline TInt64 INIT_SEED()
+{
+    TTime now; 
+    now.HomeTime(); 
+    return now.Int64();
+}
+
+TInt64 CLoadGenModel::iRandomNumberSeed = INIT_SEED();
+
+// ===================================== MEMBER FUNCTIONS =====================================
+
+CLoadGenModel* CLoadGenModel::NewL()
+    {
+    CLoadGenModel* self = new(ELeave) CLoadGenModel;
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenModel::CLoadGenModel() : CActive(EPriorityStandard)
+    {
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenModel::ConstructL()
+    {
+    iDrawState = EDrawStateInvalid;
+    iReferenceNumber = 0;
+    
+    iEnv = CEikonEnv::Static();
+    User::LeaveIfError(iLs.Connect());
+    
+    iLoadItemList = new(ELeave) CLoadItemList(64);
+
+    User::LeaveIfError(iTimer.CreateLocal());
+    CActiveScheduler::Add(this);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenModel::ActivateModelL()
+    {
+    // load settings
+    //TRAP_IGNORE(LoadSettingsL());
+
+    // set defaults to attributes
+    iCpuLoadAttributes.iId = 0;
+    iCpuLoadAttributes.iPriority = EThreadPriorityTypeNormal;
+    iCpuLoadAttributes.iMode = ECpuLoadModeYielding;
+    iCpuLoadAttributes.iType = ECpuLoadTypePeriodic;
+    iCpuLoadAttributes.iLength = 4000;
+    iCpuLoadAttributes.iIdle = 2000;
+    iCpuLoadAttributes.iRandomVariance = 0;
+    iCpuLoadAttributes.iCpu = KCPUSelection_FreeScheduling; // set CPU as "undefined" (can be >= 0 only in SMP environments)
+    iCpuLoadAttributes.iCpuCount = UserSvr::HalFunction(EHalGroupKernel, KHalFunction_EKernelHalNumLogicalCpus, 0, 0);
+    if( iCpuLoadAttributes.iCpuCount < 1 || iCpuLoadAttributes.iCpuCount > KMaxCPUs )
+        {
+        // HAL may not support this function, so let's use CPU count 1:
+        iCpuLoadAttributes.iCpuCount = 1;
+        }
+    iMemoryEatAttributes.iId = 0;
+    iMemoryEatAttributes.iPriority = EThreadPriorityTypeNormal;
+    iMemoryEatAttributes.iSource = 0;
+    iMemoryEatAttributes.iType = EMemoryEatTypeMemoryToBeLeft;
+    iMemoryEatAttributes.iBuffer = 16*1024;
+    iMemoryEatAttributes.iIdle = 0;
+    iMemoryEatAttributes.iAmount = 0;
+    iMemoryEatAttributes.iRandomMin = 1000000;
+    iMemoryEatAttributes.iRandomMax = 1500000;
+    iMemoryEatAttributes.iAmountDes.Copy(KNullDesC);
+    iMemoryEatAttributes.iRandomMinDes.Copy(KNullDesC);
+    iMemoryEatAttributes.iRandomMaxDes.Copy(KNullDesC);
+    iMemoryEatAttributes.iRandomVariance = 0;
+
+    iPhoneCallAttributes.iId = 0;
+    iPhoneCallAttributes.iPriority = EThreadPriorityTypeNormal;
+    iPhoneCallAttributes.iDestination.Copy(_L("+358"));
+    iPhoneCallAttributes.iLength = 60000;
+    iPhoneCallAttributes.iIdle = 10000;
+    iPhoneCallAttributes.iRandomVariance = 0;
+
+    iNetConnAttributes.iId = 0;
+    iNetConnAttributes.iPriority = EThreadPriorityTypeNormal;
+    iNetConnAttributes.iDestination.Copy(_L("http://www.nokia.com"));
+    iNetConnAttributes.iIdle = 10000;
+    iNetConnAttributes.iRandomVariance = 0;
+
+    iKeyPressAttributes.iId = 0;
+    iKeyPressAttributes.iPriority = EThreadPriorityTypeNormal;
+    iKeyPressAttributes.iHeartBeat = 100;
+    iKeyPressAttributes.iRandomVariance = 0;
+    
+    iPointerEventAttributes.iId = 0;
+    iPointerEventAttributes.iPriority = EThreadPriorityTypeNormal;
+    iPointerEventAttributes.iHeartBeat = 1000;
+    iPointerEventAttributes.iRandomVariance = 0;
+
+    iMessageAttributes.iId = 0;
+    iMessageAttributes.iPriority = EThreadPriorityTypeNormal;
+    iMessageAttributes.iMessageType = EMessageTypeSMS;
+    iMessageAttributes.iDestination.Copy(_L("+358"));
+    iMessageAttributes.iAmount = 5;
+    iMessageAttributes.iLength = 160;
+    iMessageAttributes.iIdle = 15000;
+    iMessageAttributes.iRandomVariance = 0;
+    
+    iApplicationsAttributes.iId = 0;
+    iApplicationsAttributes.iLaunchingInterval = 2000;
+    iApplicationsAttributes.iPriority = EThreadPriorityTypeNormal;
+    iApplicationsAttributes.iKeyPressType = EApplicationsKeyPressTypeNone;
+    iApplicationsAttributes.iMaxOpen = 20;
+    iApplicationsAttributes.iHeartBeat = 50;
+    iApplicationsAttributes.iRandomVariance = 0;
+    
+    iPhotoCaptureAttributes.iId = 0;
+    iPhotoCaptureAttributes.iPriority = EThreadPriorityTypeNormal;
+    iPhotoCaptureAttributes.iIdle = 10000;
+    iPhotoCaptureAttributes.iRandomVariance = 0;        
+    iPhotoCaptureAttributes.iCameraCount = CCamera::CamerasAvailable();
+    if(iPhotoCaptureAttributes.iCameraCount > 0)
+        {
+        iPhotoCaptureAttributes.iCamera = 0; // Main camera
+        }
+    else
+        {
+        iPhotoCaptureAttributes.iCamera = -1;
+        }
+    
+    iBluetoothAttributes.iId = 0;
+    iBluetoothAttributes.iPriority = EThreadPriorityTypeNormal;
+    iBluetoothAttributes.iIdle = 10000;
+    iBluetoothAttributes.iRandomVariance = 0;
+    iBluetoothAttributes.iBluetoothSupported = CFeatureDiscovery::IsFeatureSupportedL(KFeatureIdBt);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenModel::DeActivateModelL()
+    {
+    Cancel();
+    
+    // for a faster exit, send the application to background
+    TApaTask selfTask(iEnv->WsSession());
+    selfTask.SetWgId(iEnv->RootWin().Identifier());
+    selfTask.SendToBackground();
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+CLoadGenModel::~CLoadGenModel()
+    {
+    if (iLoadItemList)
+        {
+        DeleteAllLoadItems();
+        delete iLoadItemList;
+        }
+    if ( iApplicationsAttributes.iAppsArray )
+        {
+        delete iApplicationsAttributes.iAppsArray;
+        }
+    iTimer.Close();
+    iLs.Close();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenModel::DoCancel()
+    {
+    iTimer.Cancel();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenModel::RunL()
+    {
+    // continue    
+    //iTimer.After(iStatus, 400000);
+    //SetActive();
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenModel::SetMainContainer(CLoadGenMainContainer* aContainer)
+    {
+    iMainContainer = aContainer;
+    iDrawState = EDrawStateMain;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenModel::StartNewLoadL(TInt aCommand)
+    {
+    // show new load query
+    CLoadGenLoadTypeEditorBase* dlg = NULL;
+
+    switch ( aCommand )
+        {
+        case ELoadGenCmdNewLoadCPULoad:
+            {
+            dlg = CLoadGenCPULoadEditor::NewL(iCpuLoadAttributes);
+            break;
+            }
+        case ELoadGenCmdNewLoadEatMemory:
+            {
+            dlg = CLoadGenMemoryEatEditor::NewL(iMemoryEatAttributes);
+            break;
+            }
+        case ELoadGenCmdNewLoadPhoneCall:
+            {
+            dlg = CLoadGenPhoneCallEditor::NewL(iPhoneCallAttributes);
+            break;
+            }
+        case ELoadGenCmdNewLoadNetConn:
+            {
+            dlg = CLoadGenNetConnEditor::NewL(iNetConnAttributes);
+            break;
+            }
+        case ELoadGenCmdNewLoadKeyPress:
+            {
+            dlg = CLoadGenKeyPressEditor::NewL(iKeyPressAttributes);
+            break;
+            }               
+        case ELoadGenCmdNewLoadMessages:
+            {
+            dlg = CLoadGenMessagesEditor::NewL( iMessageAttributes );
+            break;
+            }
+        case ELoadGenCmdNewLoadApplications:
+            {
+            dlg = CLoadGenApplicationsEditor::NewL( iApplicationsAttributes );
+            break;
+            }
+        case ELoadGenCmdNewLoadPhotoCaptures:
+            {
+            if( iPhotoCaptureAttributes.iCameraCount > 0 )
+                {
+                dlg = CLoadGenPhotoCaptureEditor::NewL( iPhotoCaptureAttributes );
+                }
+            else
+                {
+                _LIT(message, "Cameras not available");
+                CAknErrorNote* errorNote = new(ELeave) CAknErrorNote;
+                errorNote->ExecuteLD(message);
+                return;
+                }
+            break;
+            }
+        case ELoadGenCmdNewLoadBluetooth:
+            {
+            if( iBluetoothAttributes.iBluetoothSupported )
+                {
+                dlg = CLoadGenBluetoothEditor::NewL(iBluetoothAttributes);                
+                }
+            else
+                {
+                _LIT(message, "Bluetooth device not available");
+                CAknErrorNote* errorNote = new(ELeave) CAknErrorNote;
+                errorNote->ExecuteLD(message);
+                return;
+                }
+            break;
+            }
+        case ELoadGenCmdNewLoadPointerEvent:
+            {
+            dlg = CLoadGenPointerEventEditor::NewL(iPointerEventAttributes);
+            break;
+            } 
+
+        default:
+            {
+            User::Panic(_L("Wrong new load"), 111);
+            break;
+            }
+        }
+
+    TBool dlgResult = dlg->RunQueryLD();
+
+    // set back title
+    if (iMainContainer)
+        iMainContainer->SetDefaultTitlePaneTextL();
+
+    // start creating new load if dialog accepted
+    if (dlgResult)
+        {
+        DoStartNewLoadL(aCommand);
+        }
+
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenModel::EditLoadL(CLoadBase* aItem)
+    {
+    // suspend current
+    aItem->Suspend();
+    
+    // show new load query
+    CLoadGenLoadTypeEditorBase* dlg = NULL;
+
+    switch ( aItem->Type() )
+        {
+        case ELoadGenCmdNewLoadCPULoad:
+            {
+            dlg = CLoadGenCPULoadEditor::NewL(static_cast<CCPULoad*>(aItem)->Attributes(), ETrue);
+            break;
+            }
+        case ELoadGenCmdNewLoadEatMemory:
+            {
+            dlg = CLoadGenMemoryEatEditor::NewL(static_cast<CMemoryEat*>(aItem)->Attributes(), ETrue);
+            break;
+            }
+        case ELoadGenCmdNewLoadPhoneCall:
+            {
+            dlg = CLoadGenPhoneCallEditor::NewL(static_cast<CPhoneCall*>(aItem)->Attributes(), ETrue);
+            break;
+            }
+        case ELoadGenCmdNewLoadNetConn:
+            {
+            dlg = CLoadGenNetConnEditor::NewL(static_cast<CNetConn*>(aItem)->Attributes(), ETrue);
+            break;
+            }
+        case ELoadGenCmdNewLoadKeyPress:
+            {
+            dlg = CLoadGenKeyPressEditor::NewL(static_cast<CKeyPress*>(aItem)->Attributes(), ETrue);
+            break;
+            }       
+        case ELoadGenCmdNewLoadMessages:
+            {
+            dlg = CLoadGenMessagesEditor::NewL(static_cast<CMessages*>(aItem)->Attributes(), ETrue);
+            break;
+            }
+        case ELoadGenCmdNewLoadApplications:
+            {
+            dlg = CLoadGenApplicationsEditor::NewL( static_cast<CAppLauncher*>(aItem)->Attributes(), ETrue );
+            break;
+            }
+        case ELoadGenCmdNewLoadPhotoCaptures:
+            {
+            dlg = CLoadGenPhotoCaptureEditor::NewL( static_cast<CPhotoCapture*>(aItem)->Attributes(), ETrue );
+            break;
+            }
+        case ELoadGenCmdNewLoadBluetooth:
+            {
+            dlg = CLoadGenBluetoothEditor::NewL( static_cast<CBluetooth*>(aItem)->Attributes(), ETrue );
+            break;
+            }
+        case ELoadGenCmdNewLoadPointerEvent:
+            {
+            dlg = CLoadGenPointerEventEditor::NewL(static_cast<CPointerEvent*>(aItem)->Attributes(), ETrue);
+            break;
+            }
+        default:
+            {
+            User::Panic(_L("Wrong edit load"), 114);
+            break;
+            }
+        }
+
+    TBool dlgResult = dlg->RunQueryLD();
+
+    // set back title
+    if (iMainContainer)
+        iMainContainer->SetDefaultTitlePaneTextL();
+    
+    // change priority of the load item
+    aItem->SetPriority();
+
+    // resume execution the item
+    aItem->Resume();
+    
+    if (dlgResult)
+        RefreshViewL(EFalse);
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenModel::DoStartNewLoadL(TInt aCommand)
+    {
+    CLoadBase* item = NULL;
+    
+    switch ( aCommand )
+        {
+        case ELoadGenCmdNewLoadCPULoad:
+            {
+            if( iCpuLoadAttributes.iCpu == KCPUSelection_AllCPUs )
+                {
+                // Call this function recursively for all CPUs:
+                for( TUint i = 0; i < iCpuLoadAttributes.iCpuCount; ++i )
+                    {                    
+                    iCpuLoadAttributes.iCpu = i;
+                    DoStartNewLoadL(aCommand);
+                    }
+                // And finally set user selection back to "All CPUs"
+                iCpuLoadAttributes.iCpu = KCPUSelection_AllCPUs;
+                return;
+                }
+            else
+                {
+                item = CCPULoad::NewL(iCpuLoadAttributes, iReferenceNumber);
+                }
+            break;
+            }
+        case ELoadGenCmdNewLoadEatMemory:
+            {
+            item = CMemoryEat::NewL(iMemoryEatAttributes, iReferenceNumber);
+            break;
+            }
+        case ELoadGenCmdNewLoadPhoneCall:
+            {
+            item = CPhoneCall::NewL(iPhoneCallAttributes, iReferenceNumber);
+            break;
+            }
+        case ELoadGenCmdNewLoadNetConn:
+            {
+            item = CNetConn::NewL(iNetConnAttributes, iReferenceNumber);
+            break;
+            }
+        case ELoadGenCmdNewLoadKeyPress:
+            {
+            item = CKeyPress::NewL(iKeyPressAttributes, iReferenceNumber);
+            break;
+            }        
+        case ELoadGenCmdNewLoadMessages:
+            {
+            item = CMessages::NewL( iMessageAttributes, iReferenceNumber );
+            break;
+            }
+        case ELoadGenCmdNewLoadApplications:
+            {
+            iApplicationsAttributes.iAppsArray = ListOfAllAppsL();
+            item = CAppLauncher::NewL( iApplicationsAttributes, iReferenceNumber );            
+            break;
+            }
+        case ELoadGenCmdNewLoadPhotoCaptures:
+            {
+            item = CPhotoCapture::NewL( iPhotoCaptureAttributes, iReferenceNumber);
+            break;
+            }
+        case ELoadGenCmdNewLoadBluetooth:
+            {
+            item = CBluetooth::NewL( iBluetoothAttributes, iReferenceNumber);            
+            break;
+            }
+        case ELoadGenCmdNewLoadPointerEvent:
+            {
+            item = CPointerEvent::NewL(iPointerEventAttributes, iReferenceNumber);
+            break;
+            }
+            
+        default:
+            {
+            User::Panic(_L("Wrong new load"), 112);
+            break;
+            }
+        }
+    
+    iReferenceNumber++;
+
+    // add item to the array
+    AppendToLoadItemListL(item);
+
+    // update the listbox
+    RefreshViewL(EFalse);
+
+    // set item index to the end
+    iMainContainer->ListBox()->SetCurrentItemIndexAndDraw( iMainContainer->ListBox()->Model()->NumberOfItems()-1 );
+
+    // start the load
+    item->Resume();
+        
+    // refresh again
+    RefreshViewL(EFalse);    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+
+void CLoadGenModel::StopAllLoadItemsL()
+    {
+    DeleteAllLoadItems();
+    
+    RefreshViewL();
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenModel::SuspendAllLoadItemsL()
+    {
+    for (TInt i=0; i<LoadItemCount(); i++)
+        {
+        if ( iLoadItemList->At(i) )
+            {
+            iLoadItemList->At(i)->Suspend();
+            }
+        }
+        
+    RefreshViewL();    
+    }
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenModel::ResumeAllLoadItemsL()
+    {
+    for (TInt i=0; i<LoadItemCount(); i++)
+        {
+        if ( iLoadItemList->At(i) )
+            {
+            iLoadItemList->At(i)->Resume();
+            }
+        }
+
+    RefreshViewL();    
+    }    
+    
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenModel::RefreshViewL(TBool aClearSelection)
+    {
+    if (iMainContainer && iDrawState == EDrawStateMain && iMainContainer->ListBox())
+        {
+        // clear selections if any
+        iMainContainer->ListBox()->ClearSelection();
+        
+        // set item index to 0
+        if (aClearSelection)
+            iMainContainer->ListBox()->SetCurrentItemIndex(0); 
+        
+        // set text items
+        iMainContainer->SetListBoxTextArrayL(GenerateListBoxItemTextArrayL());
+        }
+    }
+        
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenModel::AppendToLoadItemListL(CLoadBase* aItem)
+    {
+    if (iLoadItemList)
+        iLoadItemList->AppendL( aItem );
+    else
+        User::Leave(KErrNotReady);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenModel::DeleteFromLoadItemListL(TInt aIndex)
+    {
+    if (iLoadItemList)
+        {
+        if (iLoadItemList->Count() > aIndex && aIndex >= 0)
+            {
+            // first call delete on the item
+            if (iLoadItemList->At(aIndex))
+                {                                
+                delete iLoadItemList->At(aIndex);
+                iLoadItemList->At(aIndex) = NULL;
+                }
+            
+            // and them remove the array entry
+            iLoadItemList->Delete(aIndex);
+            iLoadItemList->Compress();
+            }
+        else
+            User::Leave(KErrNotFound);
+        }
+    else
+        User::Leave(KErrNotReady);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenModel::SuspendOrResumeFromLoadItemListL(TInt aIndex)
+    {
+    if (iLoadItemList)
+        {
+        if (iLoadItemList->Count() > aIndex && aIndex >= 0)
+            {
+            if (iLoadItemList->At(aIndex))
+                {
+                if (iLoadItemList->At(aIndex)->State() == CLoadBase::ELoadStateRunning)
+                    {
+                    iLoadItemList->At(aIndex)->Suspend();
+                    }
+                else if (iLoadItemList->At(aIndex)->State() == CLoadBase::ELoadStateSuspended)
+                    {
+                    iLoadItemList->At(aIndex)->Resume();
+                    }
+                }
+            }
+        else
+            User::Leave(KErrNotFound);
+        }
+    else
+        User::Leave(KErrNotReady);
+    }
+            
+// --------------------------------------------------------------------------------------------
+
+TInt CLoadGenModel::LoadItemCount() const
+    {
+    TInt count(0);
+    
+    if (iLoadItemList)
+        count = iLoadItemList->Count();
+    
+    return count;
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenModel::DeleteAllLoadItems()
+    {
+    // call delete for each entry and free memory allocated for the array
+    for (TInt i=0; i<LoadItemCount(); i++)
+        {
+        if ( iLoadItemList->At(i) )
+            {            
+            delete iLoadItemList->At(i);
+            iLoadItemList->At(i) = NULL;
+            }
+        }
+        
+    iLoadItemList->Reset();    
+    }  
+          
+// --------------------------------------------------------------------------------------------
+
+CDesCArray* CLoadGenModel::GenerateListBoxItemTextArrayL()
+    {
+    CDesCArray* textArray = new(ELeave) CDesCArrayFlat(64);
+    CleanupStack::PushL(textArray);
+
+    _LIT(KEntryTemplateRedIcon,   "1\t%S\t\t");
+    _LIT(KEntryTemplateGreenIcon, "2\t%S\t\t");
+    
+    for (TInt i=0; i<LoadItemCount(); i++)
+        {
+        // add description from each entry
+        TBuf<256> textEntry;
+        TBuf<256> description = iLoadItemList->At(i)->Description();
+        
+        if (iLoadItemList->At(i)->State() == CLoadBase::ELoadStateRunning)
+            textEntry.Format(KEntryTemplateGreenIcon, &description);
+        else
+            textEntry.Format(KEntryTemplateRedIcon, &description);
+        
+        textArray->AppendL(textEntry);
+        }    
+    
+    CleanupStack::Pop(); //textArray
+    return textArray;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenModel::ShowItemActionMenuL()
+    {
+    TInt currentItemIndex = iMainContainer->CurrentListBoxItemIndex();
+    
+    if (LoadItemCount() > currentItemIndex && currentItemIndex >= 0)
+        {
+        // show a query dialog    
+        TInt queryIndex(0);
+        CAknListQueryDialog* listQueryDlg = new(ELeave) CAknListQueryDialog(&queryIndex);
+
+        if (listQueryDlg->ExecuteLD(R_ITEM_ACTION_QUERY))
+            {
+            // stop
+            if (queryIndex == EItemActionMenuTypeStop)
+                {
+                StopSelectedOrHighlightedItemsL();
+                }
+            
+            // suspend or resume
+            else if (queryIndex == EItemActionMenuTypeSuspendResume)
+                {
+                SuspendOrResumeSelectedOrHighlightedItemsL();
+                }
+                           
+            // edit
+            else if (queryIndex == EItemActionMenuTypeEdit)
+                {
+                EditLoadL(iLoadItemList->At(currentItemIndex));
+                }
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenModel::StopSelectedOrHighlightedItemsL()
+    {
+    const CArrayFix<TInt>* selectionIndexes = iMainContainer->ListBoxSelectionIndexes();
+
+    TInt err(KErrNone);
+
+    // by default use selected items
+    if (selectionIndexes && selectionIndexes->Count() > 0)
+        {
+        CAknQueryDialog* query = CAknQueryDialog::NewL();
+        _LIT(KQueryMessage, "Stop %d selections?");
+        TFileName queryMsg;
+        queryMsg.Format(KQueryMessage, selectionIndexes->Count());
+        
+
+        if (query->ExecuteLD(R_GENERAL_CONFIRMATION_QUERY, queryMsg))
+            {
+            TInt deleteIndexCounter(0);
+            TInt ref(0);
+            TKeyArrayFix key(0, ECmpTUint16);
+            TInt index(0);
+            
+            TInt loadCount = LoadItemCount();
+
+            for (TInt i=0; i<loadCount; i++)
+                {
+                ref = i;
+
+                if (selectionIndexes->Find(ref, key, index) == 0)  
+                    {
+                    TRAP(err, DeleteFromLoadItemListL(i-deleteIndexCounter));
+                    deleteIndexCounter++; // amount of indexes decreases after each delete
+                    }
+                }
+            
+            RefreshViewL();
+            User::LeaveIfError(err);
+            }
+        }
+    
+    // or if none selected, use the current item index
+    else
+        {
+        TInt currentItemIndex = iMainContainer->CurrentListBoxItemIndex();
+        
+        if (LoadItemCount() > currentItemIndex && currentItemIndex >= 0)
+            {
+            CAknQueryDialog* query = CAknQueryDialog::NewL();
+           _LIT(KQueryMessage, "Stop hightlighted item?");
+
+            if (query->ExecuteLD(R_GENERAL_CONFIRMATION_QUERY, KQueryMessage))
+                {
+                TRAP(err, DeleteFromLoadItemListL(currentItemIndex));
+                
+                RefreshViewL();
+                User::LeaveIfError(err);
+                }
+            }
+        }  
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenModel::SuspendOrResumeSelectedOrHighlightedItemsL()
+    {
+    const CArrayFix<TInt>* selectionIndexes = iMainContainer->ListBoxSelectionIndexes();
+
+    // by default use selected items
+    if (selectionIndexes && selectionIndexes->Count() > 0)
+        {
+        TInt ref(0);
+        TKeyArrayFix key(0, ECmpTUint16);
+        TInt index(0);
+
+        for (TInt i=0; i<LoadItemCount(); i++)
+            {
+            ref = i;
+
+            if (selectionIndexes->Find(ref, key, index) == 0)  
+                {
+                SuspendOrResumeFromLoadItemListL(i);
+                }
+            }
+        
+        RefreshViewL(EFalse);
+        }
+    
+    // or if none selected, use the current item index
+    else
+        {
+        TInt currentItemIndex = iMainContainer->CurrentListBoxItemIndex();
+        
+        if (LoadItemCount() > currentItemIndex && currentItemIndex >= 0)
+            {
+            SuspendOrResumeFromLoadItemListL(currentItemIndex);
+            
+            RefreshViewL(EFalse);
+            }
+        }  
+    }                                
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenModel::LoadSettingsL()
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenModel::SaveSettingsL()
+    {
+    }
+        
+// --------------------------------------------------------------------------------------------
+
+TInt CLoadGenModel::LaunchSettingsDialogL()
+    {
+    return 0;
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TThreadPriority CLoadGenModel::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 CLoadGenModel::SettingItemToThreadDescription(TInt aIndex, TDes& aBuf)
+    {
+    switch ( aIndex )
+        {
+        case EThreadPriorityTypeMuchLess:
+            {
+            aBuf.Append(_L("ML(-20)")); break;
+            }
+        case EThreadPriorityTypeLess:
+            {
+            aBuf.Append(_L("L(-10)")); break;
+            }
+        case EThreadPriorityTypeNormal:
+            {
+            aBuf.Append(_L("NO(0)")); break;
+            }
+        case EThreadPriorityTypeMore:
+            {
+            aBuf.Append(_L("M(10)")); break;
+            }
+        case EThreadPriorityTypeMuchMore:
+            {
+            aBuf.Append(_L("MM(20)")); break;
+            }
+        case EThreadPriorityTypeRealTime:
+            {
+            aBuf.Append(_L("RL(30)")); break;
+            }
+        case EThreadPriorityTypeAbsoluteVeryLow:
+            {
+            aBuf.Append(_L("AVL(100)")); break;
+            }
+        case EThreadPriorityTypeAbsoluteLow:
+            {
+            aBuf.Append(_L("AL(200)")); break;
+            }
+        case EThreadPriorityTypeAbsoluteBackground:
+            {
+            aBuf.Append(_L("ABG(300)")); break;
+            }
+        case EThreadPriorityTypeAbsoluteForeground:
+            {
+            aBuf.Append(_L("AFG(400)")); break;
+            }
+        case EThreadPriorityTypeAbsoluteHigh:
+            {
+            aBuf.Append(_L("AH(500)")); break;
+            }
+
+        default:
+            {
+            User::Panic(_L("Wrong td index"), 277);
+            break;
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenModel::SettingItemToSourceDescription(TInt aIndex, TDes& aBuf)
+    {
+    switch ( aIndex )
+        {
+        case EMemoryEatSourceTypeRAM:
+            {
+            aBuf.Append(_L("RAM")); break;
+            }
+        case EMemoryEatSourceTypeDriveC:
+            {
+            aBuf.Append(_L("C:")); break;
+            }
+        case EMemoryEatSourceTypeDriveD:
+            {
+            aBuf.Append(_L("D:")); break;
+            }            
+        case EMemoryEatSourceTypeDriveE:
+            {
+            aBuf.Append(_L("E:")); break;
+            }            
+        case EMemoryEatSourceTypeDriveF:
+            {
+            aBuf.Append(_L("F:")); break;
+            }            
+        case EMemoryEatSourceTypeDriveG:
+            {
+            aBuf.Append(_L("G:")); break;
+            }            
+        case EMemoryEatSourceTypeDriveH:
+            {
+            aBuf.Append(_L("H:")); break;
+            }            
+        case EMemoryEatSourceTypeDriveI:
+            {
+            aBuf.Append(_L("I:")); break;
+            }            
+        case EMemoryEatSourceTypeDriveJ:
+            {
+            aBuf.Append(_L("J:")); break;
+            }            
+        case EMemoryEatSourceTypeDriveK:
+            {
+            aBuf.Append(_L("K:")); break;
+            }            
+        case EMemoryEatSourceTypeDriveL:
+            {
+            aBuf.Append(_L("L:")); break;
+            }            
+        case EMemoryEatSourceTypeDriveM:
+            {
+            aBuf.Append(_L("M:")); break;
+            }            
+        case EMemoryEatSourceTypeDriveN:
+            {
+            aBuf.Append(_L("N:")); break;
+            }            
+
+        default:
+            {
+            User::Panic(_L("Wrong src index"), 278);
+            break;
+            }
+        }
+    }
+        
+// --------------------------------------------------------------------------------------------
+
+TInt CLoadGenModel::MilliSecondsToMicroSeconds(TInt aMilliSeconds, TInt aRandomVariance)
+    {
+    __ASSERT_ALWAYS(aRandomVariance >= 0 && aRandomVariance <= 100, User::Panic(_L("Inv.var."), 180));
+    __ASSERT_ALWAYS(aMilliSeconds >=0, User::Panic(_L("Inv.ms."), 181));
+    
+    // if no variance defined, just do a quick conversion
+    if (aRandomVariance == 0 || aMilliSeconds == 0)
+        return aMilliSeconds * 1000;
+    
+    // otherwise calculate difference
+    TInt diff = 1000 * aMilliSeconds / 2 * aRandomVariance / 100;  
+    
+    return RandomNumber(aMilliSeconds*1000-diff, aMilliSeconds*1000+diff);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CLoadGenModel::RandomNumber(TInt aMin, TInt aMax)
+    {
+    TInt range = (aMax > aMin ? aMax - aMin : aMin - aMax) + 1;
+    TInt random = (TInt) (range * Math::FRand(iRandomNumberSeed));
+    
+    random = (random % range) + aMin;
+
+    if (random > aMax)
+        random = aMax;
+    else if (random < aMin)
+        random = aMin;
+    
+    return random;
+    }
+
+// --------------------------------------------------------------------------------------------
+CDesCArray* CLoadGenModel::ListOfAllAppsL()
+    {
+    const TInt KMaxAppsArraySize=250;
+    RApaLsSession ls;
+    CleanupClosePushL(ls);
+
+    User::LeaveIfError( ls.Connect() );
+    CDesCArray* allAppsArray = new(ELeave) CDesCArrayFlat( KMaxAppsArraySize );
+    CleanupStack::PushL( allAppsArray );
+    // reset the apps list
+    allAppsArray->Reset();
+
+    // search all apps
+    TApaAppInfo appInfo;
+    User::LeaveIfError(ls.GetAllApps());
+
+
+    while ( ls.GetNextApp( appInfo ) == KErrNone )
+        {
+        allAppsArray->AppendL( appInfo.iFullName );      
+        }
+    CleanupStack::Pop( allAppsArray );
+    CleanupStack::PopAndDestroy( &ls );
+   
+
+    // remove loadgen.* from the list
+    for ( TInt i = 0; i < allAppsArray->MdcaCount(); i++ )
+        {
+        if ( allAppsArray->MdcaPoint(i).FindF( _L("\\loadgen.") ) != KErrNotFound )
+            {
+            allAppsArray->Delete(i);
+            allAppsArray->Compress();
+            break;
+            }
+        }
+
+    // sort the elements
+    allAppsArray->Sort();
+
+    return allAppsArray; // ownership transferred
+    }
+
+TSize CLoadGenModel::ScreenSize()
+    {    
+    TInt x = 0;
+    TInt y = 0;
+    HAL::Get(HALData::EDisplayXPixels, x);
+    HAL::Get(HALData::EDisplayYPixels, y);
+    return TSize(x, y);
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/src/loadgen_netconn.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,293 @@
+/*
+* 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 "loadgen_netconn.h"
+#include "loadgen_model.h"
+#include "loadgen.hrh"
+#include <loadgen.rsg>
+
+#include <e32math.h>
+#include <commdb.h>
+
+_LIT(KThreadName, "NetConn %d");
+
+const TInt KDefaultStart = 50;
+const TInt KDefaultPeriod = 5000000;
+    
+// ===================================== MEMBER FUNCTIONS =====================================
+
+CNetConn* CNetConn::NewL(TNetConnAttributes& aAttributes, TInt aReferenceNumber)
+    {
+    CNetConn* self = new(ELeave) CNetConn(aAttributes, aReferenceNumber);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CNetConn::~CNetConn()
+    {
+    Close();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CNetConn::CNetConn(TNetConnAttributes& aAttributes, TInt aReferenceNumber) : iAttributes(aAttributes)
+    {
+    iAttributes.iId = aReferenceNumber;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CNetConn::ConstructL()
+    {
+    CLoadBase::ConstructL();
+    
+    iType = ELoadGenCmdNewLoadNetConn;
+
+    TBuf<64> threadName;
+    threadName.Format(KThreadName, iAttributes.iId);
+    
+    // create a thread
+    User::LeaveIfError(iThread.Create(threadName, ThreadFunction, KDefaultStackSize*2, 1024*KMinHeapSize, 16*1024*KMinHeapSize, (TAny*) &iAttributes ));
+    
+    // set priority of the thread
+    SetPriority();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CNetConn::ThreadFunction(TAny* aThreadArg)
+    {
+    CTrapCleanup* pC = CTrapCleanup::New();
+    CActiveScheduler* pS = new CActiveScheduler;
+    CActiveScheduler::Install(pS);
+
+    // start generating load, pass pointer to arguments
+    GenerateLoad(*((TNetConnAttributes*) aThreadArg));
+
+    delete pS;
+    delete pC;
+    
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CNetConn::GenerateLoad(TNetConnAttributes& aAttributes)
+    {
+    CNetConnManager* netConnManager = NULL;
+    TRAPD(err, netConnManager = CNetConnManager::NewL(aAttributes));
+    if (err == KErrNone) CActiveScheduler::Start();
+    delete netConnManager;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CNetConn::Resume()
+    {
+    CLoadBase::Resume();
+    
+    iThread.Resume();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CNetConn::Suspend()
+    {
+    CLoadBase::Suspend();
+    
+    iThread.Suspend();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CNetConn::SetPriority()
+    {
+    CLoadBase::SetPriority();
+    
+    iThread.SetPriority(CLoadGenModel::SettingItemToThreadPriority(iAttributes.iPriority));
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CNetConn::Close()
+    {
+    CLoadBase::Close();
+
+    if (iThread.ExitReason() == 0) // check if the thread is still alive
+        {
+        // signal the thread that it needs to close
+        iThread.RequestComplete(iAttributes.iDeathStatus, KErrCancel);
+
+        // wait the thread to die
+        TRequestStatus waiter;
+        iThread.Logon(waiter);
+        User::WaitForRequest(waiter);
+        iThread.Close();
+        }
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TPtrC CNetConn::Description()
+    {
+    TBuf<256> buf;
+    TBuf<16> prioBuf;
+    CLoadGenModel::SettingItemToThreadDescription(iAttributes.iPriority, prioBuf);
+    
+    _LIT(KNetConnEntry, "[%d] NetConn prio=%S dest=%S idle=%dms random=%d%%");
+    buf.Format(KNetConnEntry, iAttributes.iId, &prioBuf, &iAttributes.iDestination, iAttributes.iIdle, iAttributes.iRandomVariance);
+   
+    return TPtrC(buf);
+    }
+                   
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+CNetConnManager* CNetConnManager::NewL(TNetConnAttributes& aAttributes)
+    {
+    CNetConnManager* self = new(ELeave) CNetConnManager(aAttributes);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CNetConnManager::CNetConnManager(TNetConnAttributes& aAttributes) :
+    CActive(EPriorityStandard), iAttributes(aAttributes)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+    
+CNetConnManager::~CNetConnManager()
+    {
+    Cancel();
+    
+    iDownloadMgr.Close();
+    }
+
+// --------------------------------------------------------------------------------------------
+ 
+void CNetConnManager::ConstructL()
+    {
+    CActiveScheduler::Add(this);
+    
+    // set the status as pending
+    iStatus = KRequestPending;
+    SetActive();
+    
+    // set the death status pointer point to the request status of this ao
+    iAttributes.iDeathStatus = &iStatus;
+    
+    // init
+    TUid dlUid;
+    dlUid.iUid = 0x00011100 + iAttributes.iId; // generate unique identifier instead of using the LoadGen uid for all instances
+    iDownloadMgr.ConnectL(dlUid, *this, ETrue);
+    
+    // start timer    
+    iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard);
+    iPeriodicTimer->Start(KDefaultStart, KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this));
+    }
+    
+// --------------------------------------------------------------------------------------------
+ 
+void CNetConnManager::RunL()
+    {
+    // request status has completed by the main thread meaning that we need to stop now
+    CActiveScheduler::Stop();
+    }
+
+// --------------------------------------------------------------------------------------------
+ 
+void CNetConnManager::DoCancel()
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CNetConnManager::PeriodicTimerCallBack(TAny* aAny)
+    {
+    CNetConnManager* self = static_cast<CNetConnManager*>( aAny );
+
+    self->iPeriodicTimer->Cancel();
+    TRAPD(err,self->StartDownloadL());
+
+    return err;
+    }
+    
+// --------------------------------------------------------------------------------------------
+ 
+void CNetConnManager::StartDownloadL()
+    {
+    iDownloadMgr.SetIntAttribute(EDlMgrExitAction, EExitPause);
+    iDownloadMgr.DeleteAll();
+
+    // create new download    
+    TBuf8<256> url;
+    url.Copy(iAttributes.iDestination);
+
+    RHttpDownload& download = iDownloadMgr.CreateDownloadL( url );
+    
+    download.SetIntAttribute(EDlAttrAction, EDoNothing);            // do nothing when download has finished
+    download.SetBoolAttribute(EDlAttrHidden, ETrue);                // download is hidden
+    download.SetIntAttribute(EDlAttrRestartAction, ERestartForced); // force to download always ignoring cache
+
+    // start the download
+    download.Start();         
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CNetConnManager::HandleDMgrEventL(RHttpDownload& aDownload, THttpDownloadEvent aEvent)
+    {
+    if (aEvent.iProgressState == EHttpContentTypeReceived)
+        {
+        // need to start the download if already not started
+        aDownload.Start();
+        }
+    
+    switch ( aEvent.iDownloadState )
+        {
+        case EHttpDlPaused:
+        case EHttpDlCompleted:
+        case EHttpDlFailed:
+            {
+            // assume that the download has finished in this stage
+            // delete download and restart
+            aDownload.Delete();
+            iPeriodicTimer->Start(CLoadGenModel::MilliSecondsToMicroSeconds(iAttributes.iIdle, iAttributes.iRandomVariance), KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this));
+            break;
+            }
+
+        default:
+            {
+            break;
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/src/loadgen_phonecall.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,353 @@
+/*
+* 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 "loadgen_phonecall.h"
+#include "loadgen_model.h"
+#include "loadgen.hrh"
+#include <loadgen.rsg>
+
+#include <e32math.h>
+
+_LIT(KThreadName, "PhoneCall %d");
+
+const TInt KDefaultStart = 50;
+const TInt KDefaultPeriod = 5000000;
+    
+// ===================================== MEMBER FUNCTIONS =====================================
+
+CPhoneCall* CPhoneCall::NewL(TPhoneCallAttributes& aAttributes, TInt aReferenceNumber)
+    {
+    CPhoneCall* self = new(ELeave) CPhoneCall(aAttributes, aReferenceNumber);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CPhoneCall::~CPhoneCall()
+    {
+    Close();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CPhoneCall::CPhoneCall(TPhoneCallAttributes& aAttributes, TInt aReferenceNumber) : iAttributes(aAttributes)
+    {
+    iAttributes.iId = aReferenceNumber;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPhoneCall::ConstructL()
+    {
+    CLoadBase::ConstructL();
+    
+    iType = ELoadGenCmdNewLoadPhoneCall;
+    
+    TBuf<64> threadName;
+    threadName.Format(KThreadName, iAttributes.iId);
+    
+    // create a thread
+    User::LeaveIfError(iThread.Create(threadName, ThreadFunction, KDefaultStackSize*2, KMinHeapSize, 1024*KMinHeapSize, (TAny*) &iAttributes ));
+    
+    // set priority of the thread
+    SetPriority();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CPhoneCall::ThreadFunction(TAny* aThreadArg)
+    {
+    CTrapCleanup* pC = CTrapCleanup::New();
+    CActiveScheduler* pS = new CActiveScheduler;
+    CActiveScheduler::Install(pS);
+
+    // start generating load, pass pointer to arguments
+    GenerateLoad(*((TPhoneCallAttributes*) aThreadArg));
+
+    delete pS;
+    delete pC;
+    
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPhoneCall::GenerateLoad(TPhoneCallAttributes& aAttributes)
+    {
+    CPhoneCallManager* phoneCallManager = NULL;
+    TRAPD(err, phoneCallManager = CPhoneCallManager::NewL(aAttributes));
+    if (err == KErrNone) CActiveScheduler::Start();
+    delete phoneCallManager;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPhoneCall::Resume()
+    {
+    CLoadBase::Resume();
+    
+    iThread.Resume();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPhoneCall::Suspend()
+    {
+    CLoadBase::Suspend();
+    
+    iThread.Suspend();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPhoneCall::SetPriority()
+    {
+    CLoadBase::SetPriority();
+    
+    iThread.SetPriority(CLoadGenModel::SettingItemToThreadPriority(iAttributes.iPriority));
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CPhoneCall::Close()
+    {
+    CLoadBase::Close();
+
+    if (iThread.ExitReason() == 0) // check if the thread is still alive
+        {
+        // signal the thread that it needs to close
+        iThread.RequestComplete(iAttributes.iDeathStatus, KErrCancel);
+
+        // wait the thread to die
+        TRequestStatus waiter;
+        iThread.Logon(waiter);
+        User::WaitForRequest(waiter);
+        iThread.Close();
+        }
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TPtrC CPhoneCall::Description()
+    {
+    TBuf<256> buf;
+    TBuf<16> prioBuf;
+    CLoadGenModel::SettingItemToThreadDescription(iAttributes.iPriority, prioBuf);
+    
+    _LIT(KPhoneCallEntry, "[%d] PhoneCall prio=%S dest=%S length=%dms idle=%dms random=%d%%");
+    buf.Format(KPhoneCallEntry, iAttributes.iId, &prioBuf, &iAttributes.iDestination, iAttributes.iLength, iAttributes.iIdle, iAttributes.iRandomVariance);
+   
+    return TPtrC(buf);
+    }               
+
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+CPhoneCallManager* CPhoneCallManager::NewL(TPhoneCallAttributes& aAttributes)
+    {
+    CPhoneCallManager* self = new(ELeave) CPhoneCallManager(aAttributes);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CPhoneCallManager::CPhoneCallManager(TPhoneCallAttributes& aAttributes) :
+    CActive(EPriorityStandard), iAttributes(aAttributes), iState(EStateIdle)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+    
+CPhoneCallManager::~CPhoneCallManager()
+    {
+    Cancel();
+    
+    if (iPeriodicTimer)
+        {
+        iPeriodicTimer->Cancel();
+        delete iPeriodicTimer;
+        }
+        
+    delete iDialer;
+    }
+
+// --------------------------------------------------------------------------------------------
+ 
+void CPhoneCallManager::ConstructL()
+    {
+    CActiveScheduler::Add(this);
+    
+    // set the status as pending
+    iStatus = KRequestPending;
+    SetActive();
+    
+    // set the death status pointer point to the request status of this ao
+    iAttributes.iDeathStatus = &iStatus;
+
+    // init dialer ao
+    iDialer = CDialer::NewL(*this);
+    
+    // start timer    
+    iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard);
+    iPeriodicTimer->Start(KDefaultStart, KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this));
+    }
+
+// --------------------------------------------------------------------------------------------
+ 
+void CPhoneCallManager::RunL()
+    {
+    // request status has completed by the main thread meaning that we need to stop now
+    CActiveScheduler::Stop();
+    }
+
+// --------------------------------------------------------------------------------------------
+ 
+void CPhoneCallManager::DoCancel()
+    {
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TInt CPhoneCallManager::PeriodicTimerCallBack(TAny* aAny)
+    {
+    CPhoneCallManager* self = static_cast<CPhoneCallManager*>( aAny );
+
+    self->iPeriodicTimer->Cancel();
+    self->HandleCalls();
+
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPhoneCallManager::HandleCalls()
+    {
+    if (iState == EStateIdle)
+        {
+        // make a new call
+        iState = EStateCall;
+        iDialer->Dial(iAttributes.iDestination);
+        }
+    
+    else if (iState == EStateCall)
+        {
+        // hangup existing call
+        iState = EStateIdle;
+        iDialer->Hangup();
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPhoneCallManager::HandleStatus(TInt /*aErr*/)
+    {
+    // call timer after wait
+    if (iState == EStateCall)
+        {
+        iPeriodicTimer->Start(CLoadGenModel::MilliSecondsToMicroSeconds(iAttributes.iLength, iAttributes.iRandomVariance), KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this));
+        }
+
+    else if (iState == EStateIdle)
+        {
+        iPeriodicTimer->Start(CLoadGenModel::MilliSecondsToMicroSeconds(iAttributes.iIdle, iAttributes.iRandomVariance), KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this));
+        }        
+    }
+
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+CDialer* CDialer::NewL(CPhoneCallManager& aManager)
+    {
+    CDialer* self = new(ELeave) CDialer(aManager);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CDialer::CDialer(CPhoneCallManager& aManager) :
+    CActive(EPriorityStandard), iManager(aManager), iCallParamsPckg(iCallParams)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+    
+CDialer::~CDialer()
+    {
+    Cancel();
+    delete iTelephony;
+    }
+
+// --------------------------------------------------------------------------------------------
+ 
+void CDialer::ConstructL()
+    {
+    CActiveScheduler::Add(this);
+    
+    // init telephony object
+    iTelephony = CTelephony::NewL();
+    }
+
+// --------------------------------------------------------------------------------------------
+ 
+void CDialer::RunL()
+    {
+    // notify the observer that status has changed
+    iManager.HandleStatus(iStatus.Int());
+    }
+    
+// --------------------------------------------------------------------------------------------
+ 
+void CDialer::DoCancel()
+    {
+    iTelephony->CancelAsync(CTelephony::EDialNewCallCancel);
+    iTelephony->CancelAsync(CTelephony::EHangupCancel);
+    }
+
+// --------------------------------------------------------------------------------------------
+    
+void CDialer::Dial(const TDesC& aDestination)
+    {
+    CTelephony::TTelNumber telNumber(aDestination);
+    iCallParams.iIdRestrict = CTelephony::ESendMyId;
+    iTelephony->DialNewCall(iStatus, iCallParamsPckg, telNumber, iCallId);
+    SetActive();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CDialer::Hangup()
+    {
+    iTelephony->Hangup(iStatus, iCallId);
+    SetActive();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+    
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/src/loadgen_photocapture.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,389 @@
+/*
+* 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 "loadgen_photocapture.h"
+#include "loadgen_model.h"
+#include "loadgen.hrh"
+#include "loadgen_traces.h"
+#include <loadgen.rsg>
+#include <e32hal.h>
+#include <u32hal.h>
+#include <e32math.h>
+#include <EIKENV.H>
+
+_LIT(KThreadName, "PhotoCapture %d");
+
+const TInt KDefaultStart = 50;
+const TInt KDefaultPeriod = 5000000;
+
+//TInt CPhotoCapture::iImagesReady = 0;
+    
+// ===================================== MEMBER FUNCTIONS =====================================
+
+CPhotoCapture* CPhotoCapture::NewL(TPhotoCaptureAttributes& aAttributes, TInt aReferenceNumber)
+    {
+    CPhotoCapture* self = new(ELeave) CPhotoCapture(aAttributes, aReferenceNumber);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CPhotoCapture::~CPhotoCapture()
+    {    
+    Close();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CPhotoCapture::CPhotoCapture(TPhotoCaptureAttributes& aAttributes, TInt aReferenceNumber) : iAttributes(aAttributes)
+    {    
+    iAttributes.iId = aReferenceNumber;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPhotoCapture::ConstructL()
+    {    
+    CLoadBase::ConstructL();
+    
+    iType = ELoadGenCmdNewLoadPhotoCaptures;
+    
+    TBuf<64> threadName;
+    threadName.Format(KThreadName, iAttributes.iId);
+    
+    // create a thread
+    User::LeaveIfError(iThread.Create(threadName, ThreadFunction, KDefaultStackSize*2, KMinHeapSize, 1024*KMinHeapSize, (TAny*) &iAttributes ));
+    
+    // set priority of the thread
+    SetPriority();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CPhotoCapture::ThreadFunction(TAny* aThreadArg)
+    {
+    TInt err = KErrNone;
+    
+    CTrapCleanup* pC = CTrapCleanup::New();
+    CActiveScheduler* pS = new CActiveScheduler;
+    CActiveScheduler::Install(pS);
+
+    // start generating load, pass pointer to arguments
+    GenerateLoad(*((TPhotoCaptureAttributes*) aThreadArg));
+
+    delete pS;
+    delete pC;
+    
+    return err;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPhotoCapture::GenerateLoad(TPhotoCaptureAttributes& aAttributes)
+    {    
+    CCameraManager* cameraManager = 0;
+    TRAPD(err, cameraManager = CCameraManager::NewL(aAttributes));
+    if (err == KErrNone) CActiveScheduler::Start();
+    delete cameraManager;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPhotoCapture::Resume()
+    {    
+    CLoadBase::Resume();    
+    iThread.Resume();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPhotoCapture::Suspend()
+    {    
+    CLoadBase::Suspend();    
+    iThread.Suspend();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPhotoCapture::SetPriority()
+    {    
+    CLoadBase::SetPriority();    
+    iThread.SetPriority(CLoadGenModel::SettingItemToThreadPriority(iAttributes.iPriority));
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CPhotoCapture::Close()
+    {    
+    CLoadBase::Close();
+
+    // kill the thread immediately
+    iThread.Kill(0);   
+
+    iThread.Close();
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TPtrC CPhotoCapture::Description()
+    {    
+    TBuf<256> buf;
+    TBuf<16> prioBuf;
+    CLoadGenModel::SettingItemToThreadDescription(iAttributes.iPriority, prioBuf);
+        
+    _LIT(KPhotoCaptureEntry, "[%d] PhotoCapture camera=%d prio=%S idle=%dms random=%d%%");
+    buf.Format(KPhotoCaptureEntry, iAttributes.iId, iAttributes.iCamera, &prioBuf, iAttributes.iIdle, iAttributes.iRandomVariance);
+       
+    return TPtrC(buf);
+    }               
+
+// --------------------------------------------------------------------------------------------
+
+
+// --------------------------------------------------------------------------------------------
+CCameraManager* CCameraManager::NewL(TPhotoCaptureAttributes& aAttrs)
+    {
+    CCameraManager* self = new (ELeave) CCameraManager(aAttrs);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+ 
+// --------------------------------------------------------------------------------------------
+CCameraManager::~CCameraManager()
+    {    
+    delete iCamera;
+    if (iPeriodicTimer)
+        {
+        iPeriodicTimer->Cancel();
+        delete iPeriodicTimer;
+        }
+    }
+ 
+// --------------------------------------------------------------------------------------------
+CCameraManager::CCameraManager(TPhotoCaptureAttributes& aAttrs) 
+: 
+CActive(EPriorityStandard),
+iAttributes(aAttrs)
+    {        
+    iState = ENotReady;
+    iNumOfPics = 0;
+    }
+ 
+// --------------------------------------------------------------------------------------------
+void CCameraManager::ConstructL()
+    {   
+    CActiveScheduler::Add(this);    
+    // set the status as pending
+    iStatus = KRequestPending;
+    SetActive();
+        
+    // set the death status pointer point to the request status of this ao
+    iAttributes.iDeathStatus = &iStatus;
+    
+    // start timer    
+    iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard);
+    iPeriodicTimer->Start(KDefaultStart, KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this));
+    }
+
+// --------------------------------------------------------------------------------------------
+void CCameraManager::DoCancel()
+    {    
+    }
+
+// --------------------------------------------------------------------------------------------
+void CCameraManager::RunL()
+    {    
+    // request status has completed by the main thread meaning that we need to stop now
+    CActiveScheduler::Stop();
+    }
+ 
+// --------------------------------------------------------------------------------------------
+void CCameraManager::ReserveCameraL()
+    {
+    LOGSTRING2("LoadGen: CCameraManager::ReserveCameraL() - Using Camera %d", iAttributes.iCamera);
+    if( iCamera )
+        {
+        iCamera->Release();
+        }
+    delete iCamera;
+    iCamera = 0;
+    TRAPD( err, iCamera = CCamera::NewL(*this, iAttributes.iCamera));
+    iCurrentCamera = iAttributes.iCamera;
+    if(err != KErrNone)
+        {
+        LOGSTRING2("LoadGen: CCamera::NewL leaves with error: %d", err);
+        User::Leave(err);
+        }
+    iCamera->CameraInfo(iCameraInfo);
+    iCamera->Reserve();    
+    }
+ 
+// --------------------------------------------------------------------------------------------
+void CCameraManager::ReserveComplete(TInt aError)
+    {
+    if( aError != KErrNone )
+        LOGSTRING2("LoadGen: CCameraManager::ReserveComplete() - Error: %d", aError);
+    
+    if( aError == KErrNone )
+        {
+        iState = ECameraReserved;
+        iCamera->PowerOn();
+        }
+    }
+ 
+// --------------------------------------------------------------------------------------------
+void CCameraManager::PowerOnComplete(TInt aError)
+    {
+    if( aError != KErrNone )
+        {
+        LOGSTRING2("LoadGen: CCameraManager::PowerOnComplete() - Error: %d", aError);
+        return;
+        }
+
+    // Define image format, try JPEG images first:
+    CCamera::TFormat format = CCamera::EFormatExif;
+
+    if(iCameraInfo.iImageFormatsSupported & CCamera::EFormatExif)
+        {
+        LOGSTRING("LoadGen: CCameraManager::PowerOnComplete() - EXIF JPEG supported");
+        format = CCamera::EFormatExif;
+        }
+    else if( iCameraInfo.iImageFormatsSupported & CCamera::EFormatJpeg )
+        {
+        LOGSTRING("LoadGen: CCameraManager::PowerOnComplete() - JFIF JPEG supported");
+        format = CCamera::EFormatJpeg;
+        }
+    else if( iCameraInfo.iImageFormatsSupported & CCamera::EFormatFbsBitmapColor4K )
+        {
+        LOGSTRING("LoadGen: CCameraManager::PowerOnComplete() - Bitmap 4K Color supported");
+        format = CCamera::EFormatFbsBitmapColor4K;
+        }
+    else if( iCameraInfo.iImageFormatsSupported & CCamera::EFormatFbsBitmapColor64K )
+        {
+        LOGSTRING("LoadGen: CCameraManager::PowerOnComplete() - Bitmap 64K Color supported");
+        format = CCamera::EFormatFbsBitmapColor64K;
+        }
+    else if( iCameraInfo.iImageFormatsSupported & CCamera::EFormatFbsBitmapColor16M )
+        {
+        LOGSTRING("LoadGen: CCameraManager::PowerOnComplete() - Bitmap 16M Color supported");
+        format = CCamera::EFormatFbsBitmapColor16M;
+        }
+    else
+        {
+        LOGSTRING2("LoadGen: CCameraManager::PowerOnComplete() - JPEGs not supported, trying \"User defined\" (Supported formats: %d)", iCameraInfo.iImageFormatsSupported);
+        format = CCamera::EFormatUserDefined;
+        }
+    const TInt KImageSizeIndex = 0;  // Largest image size
+    TRAPD( err, iCamera->PrepareImageCaptureL(format, KImageSizeIndex));
+    if( err != KErrNone )
+        {
+        LOGSTRING2("LoadGen: CCameraManager::PowerOnComplete() - Error while preparing camera: %d", err);        
+        }
+    // Camera ready:
+    iState = EIdle;
+    // Take photo:
+    TRAP(err, CapturePhotoL());
+    if( err != KErrNone )
+        {
+        LOGSTRING2("LoadGen: CCameraManager::PowerOnComplete() - Photo capture error: %d", err);
+        }
+    }
+ 
+// --------------------------------------------------------------------------------------------
+void CCameraManager::ViewFinderFrameReady(CFbsBitmap& /*aFrame*/)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+void CCameraManager::ImageReady(CFbsBitmap* aBitmap, HBufC8* aData, TInt aError)
+    {    
+    if( aError != KErrNone )
+        {
+        LOGSTRING2("LoadGen: CCameraManager::ImageReady() - Error: %d", aError);
+        }    
+    else
+        {
+        iNumOfPics++;    
+        LOGSTRING2("LoadGen: CCameraManager::ImageReady() - Images successfully captured: %d", iNumOfPics);
+        }
+    delete aBitmap;
+    delete aData;
+    iState = EIdle;
+    }
+ 
+// --------------------------------------------------------------------------------------------
+void CCameraManager::FrameBufferReady(MFrameBuffer* /*aFrameBuffer*/, TInt aError)
+    {
+    if( aError != KErrNone )
+        LOGSTRING2("LoadGen: CCameraManager::FrameBufferReady() - Error: %d", aError);
+    }
+ 
+// --------------------------------------------------------------------------------------------
+void CCameraManager::CapturePhotoL()
+    {    
+    // Camera Manager must be in idle state when taking a photo
+    if( iState == ENotReady )
+        {
+        // Not ready, camera must be reserved:
+        ReserveCameraL();
+        }
+    else if (iState == EIdle)
+        {
+        if( iCurrentCamera != iAttributes.iCamera )
+            {
+            LOGSTRING3("LoadGen: CCameraManager::CapturePhotoL() - Switching from Camera %d to Camera %d", iCurrentCamera, iAttributes.iCamera);
+            ReserveCameraL();
+            }
+        else
+            {
+            iState = ECapture;
+            if( iCameraInfo.iFlashModesSupported & CCamera::EFlashForced)
+                {
+                iCamera->SetFlashL(CCamera::EFlashForced);
+                }
+            iCamera->CaptureImage();
+            iPeriodicTimer->Start( CLoadGenModel::MilliSecondsToMicroSeconds( iAttributes.iIdle,
+                iAttributes.iRandomVariance ), KDefaultPeriod, 
+                TCallBack( PeriodicTimerCallBack, this ) );
+            }
+        }
+    else
+        {
+        iPeriodicTimer->Start( CLoadGenModel::MilliSecondsToMicroSeconds( iAttributes.iIdle,
+                                    iAttributes.iRandomVariance ), KDefaultPeriod, 
+                                    TCallBack( PeriodicTimerCallBack, this ) );
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CCameraManager::PeriodicTimerCallBack(TAny* aAny)
+    {
+    CCameraManager* self = static_cast<CCameraManager*>( aAny );
+    self->iPeriodicTimer->Cancel();
+    TRAP_IGNORE(self->CapturePhotoL());   
+    return KErrNone;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/src/loadgen_pointerevent.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,271 @@
+/*
+* 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 "loadgen_pointerevent.h"
+#include "loadgen_model.h"
+#include "loadgen.hrh"
+#include <loadgen.rsg>
+
+#include <e32math.h>
+
+_LIT(KThreadName, "PointerEvent %d");
+
+const TInt KDefaultStart = 50;
+const TInt KDefaultPeriod = 5000000;
+    
+// ===================================== MEMBER FUNCTIONS =====================================
+
+CPointerEvent* CPointerEvent::NewL(TPointerEventAttributes& aAttributes, TInt aReferenceNumber)
+    {
+    CPointerEvent* self = new(ELeave) CPointerEvent(aAttributes, aReferenceNumber);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CPointerEvent::~CPointerEvent()
+    {
+    Close();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CPointerEvent::CPointerEvent(TPointerEventAttributes& aAttributes, TInt aReferenceNumber) : iAttributes(aAttributes)
+    {
+    iAttributes.iId = aReferenceNumber;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPointerEvent::ConstructL()
+    {
+    CLoadBase::ConstructL();
+    
+    iType = ELoadGenCmdNewLoadPointerEvent;
+    
+    TBuf<64> threadName;
+    threadName.Format(KThreadName, iAttributes.iId);
+    
+    // create a thread
+    User::LeaveIfError(iThread.Create(threadName, ThreadFunction, KDefaultStackSize*2, KMinHeapSize, 1024*KMinHeapSize, (TAny*) &iAttributes ));
+    
+    // set priority of the thread
+    SetPriority();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CPointerEvent::ThreadFunction(TAny* aThreadArg)
+    {
+    CTrapCleanup* pC = CTrapCleanup::New();
+    CActiveScheduler* pS = new CActiveScheduler;
+    CActiveScheduler::Install(pS);
+
+    // start generating load, pass pointer to arguments
+    GenerateLoad(*((TPointerEventAttributes*) aThreadArg));
+
+    delete pS;
+    delete pC;
+    
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPointerEvent::GenerateLoad(TPointerEventAttributes& aAttributes)
+    {
+    CPointerEventManager* pointerEventManager = NULL;
+    TRAPD(err, pointerEventManager = CPointerEventManager::NewL(aAttributes));
+    if (err == KErrNone) CActiveScheduler::Start();
+    delete pointerEventManager;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPointerEvent::Resume()
+    {
+    CLoadBase::Resume();
+    
+    iThread.Resume();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPointerEvent::Suspend()
+    {
+    CLoadBase::Suspend();
+    
+    iThread.Suspend();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPointerEvent::SetPriority()
+    {
+    CLoadBase::SetPriority();
+    
+    iThread.SetPriority(CLoadGenModel::SettingItemToThreadPriority(iAttributes.iPriority));
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CPointerEvent::Close()
+    {
+    CLoadBase::Close();
+    
+    if (iThread.ExitReason() == 0) // check if the thread is still alive
+        {
+        // signal the thread that it needs to close
+        iThread.RequestComplete(iAttributes.iDeathStatus, KErrCancel);
+
+        // wait the thread to die
+        TRequestStatus waiter;
+        iThread.Logon(waiter);
+        User::WaitForRequest(waiter);
+        iThread.Close();
+        }
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+TPtrC CPointerEvent::Description()
+    {
+    TBuf<256> buf;
+    TBuf<16> prioBuf;
+    CLoadGenModel::SettingItemToThreadDescription(iAttributes.iPriority, prioBuf);
+    
+    _LIT(KPointerEventEntry, "[%d] PointerEvent prio=%S heartbeat=%dms random=%d%%");
+    buf.Format(KPointerEventEntry, iAttributes.iId, &prioBuf, iAttributes.iHeartBeat, iAttributes.iRandomVariance);
+   
+    return TPtrC(buf);
+    }               
+
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+CPointerEventManager* CPointerEventManager::NewL(TPointerEventAttributes& aAttributes)
+    {
+    CPointerEventManager* self = new(ELeave) CPointerEventManager(aAttributes);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CPointerEventManager::CPointerEventManager(TPointerEventAttributes& aAttributes) :
+    CActive(EPriorityStandard), iAttributes(aAttributes)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+    
+CPointerEventManager::~CPointerEventManager()
+    {
+    Cancel();    
+    }
+
+// --------------------------------------------------------------------------------------------
+ 
+void CPointerEventManager::ConstructL()
+    {
+    CActiveScheduler::Add(this);
+    
+    // set the status as pending
+    iStatus = KRequestPending;
+    SetActive();
+    
+    // set the death status pointer point to the request status of this ao
+    iAttributes.iDeathStatus = &iStatus;
+    
+    // init    
+    
+    // start timer    
+    iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard);
+    iPeriodicTimer->Start(KDefaultStart, KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this));
+    }
+    
+// --------------------------------------------------------------------------------------------
+ 
+void CPointerEventManager::RunL()
+    {
+    // request status has completed by the main thread meaning that we need to stop now
+    CActiveScheduler::Stop();
+    }
+
+// --------------------------------------------------------------------------------------------
+ 
+void CPointerEventManager::DoCancel()
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TInt CPointerEventManager::PeriodicTimerCallBack(TAny* aAny)
+    {
+    CPointerEventManager* self = static_cast<CPointerEventManager*>( aAny );
+
+    self->iPeriodicTimer->Cancel();
+    self->SimulatePointerEvent();
+
+    return KErrNone;
+    }
+    
+// --------------------------------------------------------------------------------------------
+ 
+void CPointerEventManager::SimulatePointerEvent()
+    {
+    // Check the screen size and select pointer event position
+    // randomly
+    TSize screenSize = CLoadGenModel::ScreenSize();
+        
+    TInt x1 = CLoadGenModel::RandomNumber(0, screenSize.iWidth);
+    TInt y1 = CLoadGenModel::RandomNumber(0, screenSize.iHeight);
+    
+    // Generate "Pointer down" event:
+    TRawEvent eventPointerDown;    
+    eventPointerDown.Set(TRawEvent::EButton1Down, x1, y1);
+    UserSvr::AddEvent(eventPointerDown);
+    
+    // Get new random position for "Move pointer" and 
+    // "Pointer up" events
+    TInt x2 = CLoadGenModel::RandomNumber(0, screenSize.iWidth);
+    TInt y2 = CLoadGenModel::RandomNumber(0, screenSize.iHeight);
+    
+    // Generate "Move pointer" event:
+    TRawEvent eventMovePointer;
+    eventMovePointer.Set(TRawEvent::EPointerMove, x2, y2);
+    UserSvr::AddEvent(eventMovePointer);
+    
+    // Generate "Pointer up" event:
+    TRawEvent eventPointerUp;
+    eventPointerUp.Set(TRawEvent::EButton1Up, x2, y2);
+    UserSvr::AddEvent(eventPointerUp);
+    
+    // call timer
+    iPeriodicTimer->Start(CLoadGenModel::MilliSecondsToMicroSeconds(iAttributes.iHeartBeat, iAttributes.iRandomVariance), KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this));
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadgen/src/loadgen_settingsviewdlg.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,323 @@
+/*
+* 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 "loadgen_settingsviewdlg.h"
+#include "loadgen_model.h"
+#include "loadgen.hrh"
+#include "loadgen_std.h"
+#include <loadgen.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 =====================================
+
+CLoadGenSettingsViewDlg* CLoadGenSettingsViewDlg::NewL(TLoadGenSettings& aSettings)
+    {
+    CLoadGenSettingsViewDlg* self = new(ELeave) CLoadGenSettingsViewDlg(aSettings);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenSettingsViewDlg::~CLoadGenSettingsViewDlg()
+    {
+    // restore default navi pane
+    if (iNaviContainer)
+        iNaviContainer->Pop();
+    
+    if (iSettingItemArray)
+        {
+        iSettingItemArray->ResetAndDestroy();
+        delete iSettingItemArray; 
+        }
+    
+    delete iDecoratedTabGroup;   
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CLoadGenSettingsViewDlg::CLoadGenSettingsViewDlg(TLoadGenSettings& aSettings) : iSettings(aSettings)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenSettingsViewDlg::ConstructL()
+    {
+    // construct a menu bar
+    CAknDialog::ConstructL(R_LOADGEN_SETTINGS_MENUBAR);
+   
+    CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
+    
+    // set empty navi pane label
+    iNaviContainer = static_cast<CAknNavigationControlContainer*>(sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi)));
+    //iNaviContainer->PushDefaultL();
+    
+    // set title text
+    CAknTitlePane* tp = static_cast<CAknTitlePane*>( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
+    tp->SetTextL( _L("Settings") );
+    
+    // create a tab group
+    iDecoratedTabGroup = iNaviContainer->CreateTabGroupL(this);
+    iTabGroup = static_cast<CAknTabGroup*>(iDecoratedTabGroup->DecoratedControl());
+    iTabGroup->SetTabFixedWidthL(KTabWidthWithTwoLongTabs); 
+    
+    // add tabs
+    //iTabGroup->AddTabL(ETabGeneral, _L("General"));
+    //iTabGroup->AddTabL(ETabScreenShot, _L("Screen shot"));
+    //iTabGroup->SetActiveTabByIndex(ETabGeneral);
+    
+    iNaviContainer->PushL( *iDecoratedTabGroup );
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenSettingsViewDlg::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
+    {
+    switch (aEventType)
+        {
+        case EEventEnterKeyPressed:
+        case EEventItemDoubleClicked:
+            ShowSettingPageL(EFalse);
+            break;
+        default:
+            break;
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenSettingsViewDlg::TabChangedL(TInt /*aIndex*/)
+    {
+    iListBox->SetCurrentItemIndex(0);
+
+    SetVisibilitiesOfSettingItemsL();   
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenSettingsViewDlg::ProcessCommandL(TInt aCommandId)
+    {
+    CAknDialog::ProcessCommandL(aCommandId);
+
+    switch (aCommandId)
+        {
+        case ELoadGenCmdSettingsChange:
+            ShowSettingPageL(ETrue);
+            break;
+        case ELoadGenCmdSettingsExit:
+            TryExitL(EAknCmdExit);
+            break;
+        default:
+            break;
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TKeyResponse CLoadGenSettingsViewDlg::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 CLoadGenSettingsViewDlg::PreLayoutDynInitL()
+    {
+    iListBox = static_cast<CAknSettingStyleListBox*>( Control(ELoadGenSettingItemList) );
+    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 CLoadGenSettingsViewDlg::OkToExitL(TInt aButtonId)
+    {
+    return CAknDialog::OkToExitL(aButtonId);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenSettingsViewDlg::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 CLoadGenSettingsViewDlg::SetVisibilitiesOfSettingItemsL()
+    {
+    if (iSettingItemArray->Count() > 0)
+        {
+/*
+        switch (iTabGroup->ActiveTabIndex())
+            {
+
+            case ETabGeneral:
+                {
+                ((*iSettingItemArray)[ESettingListDisplayModeSelection])->SetHidden(EFalse);
+                ((*iSettingItemArray)[ESettingListFileViewModeSelection])->SetHidden(EFalse);
+                break;
+                }
+            
+            case ETabScreenShot:
+                {
+                ((*iSettingItemArray)[ESettingListDisplayModeSelection])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListFileViewModeSelection])->SetHidden(ETrue);
+                break;            
+                }
+
+            default:
+                User::Panic(_L("TabIOOB"), 50);
+                break;
+            }
+*/
+        iSettingItemArray->RecalculateVisibleIndicesL();
+        iListBox->HandleItemAdditionL();
+        iListBox->UpdateScrollBarsL();
+        }
+    }   
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenSettingsViewDlg::UpdateListBoxL()
+    {
+    iSettingItemArray->ResetAndDestroy();
+
+/* 
+    // create items
+    TInt ordinal(0);
+
+    AddSettingItemL(ESettingListDisplayModeSelection,
+                    R_DISPLAYMODESELECTION_SETTING_TITLE,
+                    R_DISPLAYMODESELECTION_SETTING_PAGE,
+                    R_DISPLAYMODESELECTION_SETTING_TEXTS,
+                    ordinal++);
+                    
+    AddSettingItemL(ESettingListFileViewModeSelection,
+                    R_FILEVIEWMODESELECTION_SETTING_TITLE,
+                    R_FILEVIEWMODESELECTION_SETTING_PAGE,
+                    R_FILEVIEWMODESELECTION_SETTING_TEXTS,
+                    ordinal++); 
+*/                                                              
+    SetVisibilitiesOfSettingItemsL(); 
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CLoadGenSettingsViewDlg::AddSettingItemL(TInt aId,
+                                                 TInt aTitleResource,
+                                                 TInt aSettingPageResource,
+                                                 TInt aAssociatedResource,
+                                                 TInt aOrdinal)
+    {
+    // create a setting item
+    CAknSettingItem* settingItem = NULL;
+    
+    switch (aId)
+        {
+/*
+        case ESettingListDisplayModeSelection:
+            settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iDisplayMode);
+            break;
+            
+        case ESettingListFileViewModeSelection:
+            settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iFileViewMode);
+            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
+    }
+
+// --------------------------------------------------------------------------------------------
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/data/Example_MemSpyProcessMemoryTrackingAutoStartConfig.xml	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,7 @@
+<?xml version="1.0" standalone="yes"?>
+<memspy_process_memory_tracking>
+
+    <process sid="0x100058EC"/>
+	<process sid="0x1000484B"/>
+
+</memspy_process_memory_tracking>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/data/MemSpyEComInterfaceIds.xml	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,18 @@
+<?xml version="1.0" standalone="yes"?>
+<memspy_ecom_sections>
+
+    <category name="Messaging">
+		<interface uid="0xABCD1234" name="Watchers" />
+    </category>
+
+    <category name="App-Protocols">
+		<interface uid="0x101F446D" name="HTTP Filters" />
+		<interface uid="0x1000A449" name="HTTP Protocol" />
+    </category>
+
+    <category name="S60 AIW">
+		<interface uid="0x101F8650" name="AIW Class Base" />
+		<interface uid="0x101F8652" name="AIW Class Menu" />
+    </category>
+
+</memspy_ecom_sections>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/data/MemSpyProcessMemoryTrackingAutoStartConfig.xml	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,4 @@
+<?xml version="1.0" standalone="yes"?>
+<memspy_process_memory_tracking>
+
+</memspy_process_memory_tracking>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/data/backup_registration.xml	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,17 @@
+<?xml version="1.0" standalone="yes"?>
+<backup_registration>
+
+    <passive_backup>
+        <include_directory name="\"/>
+        <exclude name="MemSpy_Passive_Excluded.txt"/>
+    </passive_backup>
+
+    <system_backup/>
+
+    <public_backup>
+        <include_directory name="C:\Data\Others\MemSpy\"/>
+    </public_backup>
+
+    <restore requires_reboot = "no"/>
+
+</backup_registration>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/data/memspyui.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,1133 @@
+/*
+* 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:
+*
+*/
+
+
+// Resource Identifier
+NAME MEMS
+
+// System includes
+#include <data_caging_paths_strings.hrh>
+#include <appinfo.rh>
+#include <eikon.rh>
+#include <eikcore.rsg>
+#include <eikon.rsg>
+#include <avkon.rh>
+#include <eikon.rsg>
+#include <avkon.rsg>
+#include <avkon.mbg>
+#include <avkon.loc>
+#include <AvkonIcons.hrh>
+#include <bldvariant.hrh>
+
+
+// User includes
+#include "MemSpy.hrh"
+
+
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE TBUF { buf="MemSpy"; }
+
+RESOURCE EIK_APP_INFO
+    {
+    hotkeys = r_memspy_hotkeys;
+    menubar = r_memspy_menubar;
+    cba     = R_AVKON_SOFTKEYS_OPTIONS_EXIT;     
+    }
+
+
+
+
+
+
+RESOURCE HOTKEYS r_memspy_hotkeys
+    {
+    control=
+        {
+        HOTKEY { command=EAknCmdExit; key='e'; }
+        };
+    }
+
+
+RESOURCE MENU_BAR r_memspy_menubar
+    {
+    titles=
+        {
+        MENU_TITLE { menu_pane=r_memspy_menupane;                   txt = "Main Menu"; }
+        };
+    }
+
+
+
+
+RESOURCE MENU_PANE r_memspy_menupane_stack
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdStackInfoThread;            txt = "Info"; }
+#ifndef __WINS__
+		,
+		MENU_ITEM { command = EMemSpyCmdStackData;                  cascade = r_memspy_menupane_stack_data; txt = "Data"; }
+#endif
+        };
+    }
+
+
+RESOURCE MENU_PANE r_memspy_menupane_stack_data
+    {
+    items=
+        {
+		MENU_ITEM { command=EMemSpyCmdStackDataUser;                txt = "User stack data"; },
+		MENU_ITEM { command=EMemSpyCmdStackDataKernel;              txt = "Kernel stack data"; }
+        };
+    }
+
+
+
+
+
+
+RESOURCE MENU_PANE r_memspy_menupane_heap
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdHeapInfoThread;             txt = "Info"; },
+		MENU_ITEM { command = EMemSpyCmdHeapData;                   cascade = r_memspy_menupane_heap_data; txt = "Data"; }
+        };
+    }
+
+
+RESOURCE MENU_PANE r_memspy_menupane_heap_data
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdHeapCellListing;            txt = "Cell list"; }
+#ifndef __WINS__
+		,
+		MENU_ITEM { command = EMemSpyCmdHeapDataDump;               txt = "Heap data"; }
+#endif
+        };
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+RESOURCE MENU_PANE r_memspy_menupane_auto_capture
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdAutoCaptureToggle;          txt = "Enable/Disable"; },
+		MENU_ITEM { command = EMemSpyCmdAutoCaptureRetryTime;       txt = "Timer period"; },
+		MENU_ITEM { command = EMemSpyCmdAutoCaptureOperationType;   txt = "Operation type"; }
+        };
+    }
+
+
+RESOURCE TBUF r_memspy_auto_capture_enable
+    {
+    buf = "Enable";
+    }
+
+
+RESOURCE TBUF r_memspy_auto_capture_disable
+    {
+    buf = "Disable";
+    }
+
+
+RESOURCE LISTBOX r_memspy_auto_capture_operation_listbox
+    {
+    flags = 0; //EEikListBoxMultipleSelection;
+    }
+
+
+RESOURCE AVKON_SETTING_PAGE r_memspy_auto_capture_operation_types_settings_page
+    { 
+    number              = EAknSettingPageNoOrdinalDisplayed;
+    label               = "Operation type";
+    softkey_resource    = R_AVKON_SOFTKEYS_OK_CANCEL;
+    type                = EAknSetListBox;
+    editor_resource_id  = r_memspy_auto_capture_operation_listbox;
+    }
+
+
+RESOURCE ARRAY r_memspy_auto_capture_operation_types
+    {
+    items =
+        {
+		LBUF { txt = "General Info (Text)"; },
+		LBUF { txt = "General Info (Detailed)"; },
+		//
+		LBUF { txt = "User Heap Info (Text)"; },
+		LBUF { txt = "User Heap Info (CSV)"; },
+		//
+		LBUF { txt = "User Heap Cell List (Text)"; },
+		//
+		LBUF { txt = "User Heap Data (Binary)"; },
+		LBUF { txt = "Kernel Heap Data (Binary)"; },
+		//
+		LBUF { txt = "User Stack Info (Text)"; },
+		LBUF { txt = "User Stack Info (CSV)"; },
+		//
+		LBUF { txt = "User Stack Data (Binary)"; },
+		LBUF { txt = "Kernel Stack Data (Binary)"; }
+        };
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+RESOURCE MENU_PANE r_memspy_menupane_phone_info_general
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdPhoneInfoGeneralSummary;			txt = "Summary"; },
+		MENU_ITEM { command = EMemSpyCmdPhoneInfoGeneralDetailed;			txt = "Detailed Info"; },
+		MENU_ITEM { command = EMemSpyCmdPhoneInfoGeneralHandles;			txt = "Handle Info"; },
+		MENU_ITEM { command = EMemSpyCmdPhoneInfoGeneralKernelContainers;	txt = "Kernel Containers"; }
+        };
+    }
+
+
+RESOURCE MENU_PANE r_memspy_menupane_phone_info_heap
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdPhoneInfoHeapInfoSummary;       txt = "Detailed Summary"; },
+		MENU_ITEM { command = EMemSpyCmdPhoneInfoHeapInfoCompact;		txt = "Compact Summary"; },
+		MENU_ITEM { command = EMemSpyCmdPhoneInfoHeapCellListing;       txt = "Cell Listing"; },
+		MENU_ITEM { command = EMemSpyCmdPhoneInfoHeapDump;			    txt = "Data (Binary)"; }
+        };
+    }
+
+
+RESOURCE MENU_PANE r_memspy_menupane_phone_info_stack
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdPhoneInfoStackInfo;             txt = "Detailed Summary"; },
+		MENU_ITEM { command = EMemSpyCmdPhoneInfoStackInfoCompact;      txt = "Compact Summary"; },
+		MENU_ITEM { command = EMemSpyCmdPhoneInfoStackDumpUser;         txt = "User Stacks (Binary)"; },
+		MENU_ITEM { command = EMemSpyCmdPhoneInfoStackDumpKernel;       txt = "Kernel Stacks (Binary)"; }
+        };
+    }
+
+
+RESOURCE MENU_PANE r_memspy_menupane_phone_info
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdPhoneInfoGeneral;           txt = "General";        cascade = r_memspy_menupane_phone_info_general; },
+		MENU_ITEM { command = EMemSpyCmdPhoneInfoHeap;              txt = "Heap";           cascade = r_memspy_menupane_phone_info_heap; },
+		MENU_ITEM { command = EMemSpyCmdPhoneInfoStack;             txt = "Stack";          cascade = r_memspy_menupane_phone_info_stack; }
+        };
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+RESOURCE MENU_PANE r_memspy_menupane_process_sort
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdProcessSortById;            txt = "By Id"; },
+		MENU_ITEM { command = EMemSpyCmdProcessSortByName;          txt = "By Name"; },
+		MENU_ITEM { command = EMemSpyCmdProcessSortByThreadCount;   txt = "By Number of Threads"; },
+		MENU_ITEM { command = EMemSpyCmdProcessSortByCodeSegs;      txt = "By Code Segments"; },
+		MENU_ITEM { command = EMemSpyCmdProcessSortByHeapUsage;     txt = "By Heap Usage"; },
+		MENU_ITEM { command = EMemSpyCmdProcessSortByStackUsage;    txt = "By Stack Usage"; }
+        };
+    }
+
+
+RESOURCE MENU_PANE r_memspy_menupane_process_info
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdProcessInfoSummary;         txt = "Summary"; },
+		MENU_ITEM { command = EMemSpyCmdProcessInfoHandles;			txt = "Handles"; }
+        };
+    }
+
+
+RESOURCE MENU_PANE r_memspy_menupane_process_end
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdProcessEndKill;				txt = "Kill"; },
+		MENU_ITEM { command = EMemSpyCmdProcessEndPanic;			txt = "Panic"; },
+		MENU_ITEM { command = EMemSpyCmdProcessEndTerminate;        txt = "Terminate"; }
+        };
+    }
+
+
+RESOURCE MENU_PANE r_memspy_menupane_process
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdProcessInfo;                txt = "Info";       cascade = r_memspy_menupane_process_info; },
+		MENU_ITEM { command = EMemSpyCmdProcessSort;                txt = "Sort";       cascade = r_memspy_menupane_process_sort; },
+		MENU_ITEM { command = EMemSpyCmdProcessEnd;                 txt = "End";       cascade = r_memspy_menupane_process_end; }
+        };
+    }
+
+
+
+
+
+
+
+RESOURCE MENU_PANE r_memspy_menupane_thread_priority
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdThreadSetPriorityAbsoluteVeryLow;           txt = "Abs. Very Low"; },
+		MENU_ITEM { command = EMemSpyCmdThreadSetPriorityAbsoluteLowNormal;         txt = "Abs. Low Normal"; },
+		MENU_ITEM { command = EMemSpyCmdThreadSetPriorityAbsoluteLow;				txt = "Abs. Low"; },
+		MENU_ITEM { command = EMemSpyCmdThreadSetPriorityAbsoluteBackgroundNormal;	txt = "Abs. Background Normal"; },
+		MENU_ITEM { command = EMemSpyCmdThreadSetPriorityAbsoluteBackground;        txt = "Abs. Background "; },
+		MENU_ITEM { command = EMemSpyCmdThreadSetPriorityAbsoluteForegroundNormal;  txt = "Abs. Foreground Normal"; },
+		MENU_ITEM { command = EMemSpyCmdThreadSetPriorityAbsoluteForeground;        txt = "Abs. Foreground"; },
+		MENU_ITEM { command = EMemSpyCmdThreadSetPriorityAbsoluteHighNormal;        txt = "Abs. High Normal"; },
+		MENU_ITEM { command = EMemSpyCmdThreadSetPriorityAbsoluteHigh;				txt = "Abs. High"; },
+		MENU_ITEM { command = EMemSpyCmdThreadSetPriorityAbsoluteRealTime1;         txt = "Abs. Real Time 1"; },
+		MENU_ITEM { command = EMemSpyCmdThreadSetPriorityAbsoluteRealTime2;         txt = "Abs. Real Time 2"; },
+		MENU_ITEM { command = EMemSpyCmdThreadSetPriorityAbsoluteRealTime3;         txt = "Abs. Real Time 3"; },
+		MENU_ITEM { command = EMemSpyCmdThreadSetPriorityAbsoluteRealTime4;         txt = "Abs. Real Time 4"; },
+		MENU_ITEM { command = EMemSpyCmdThreadSetPriorityAbsoluteRealTime5;         txt = "Abs. Real Time 5"; },
+		MENU_ITEM { command = EMemSpyCmdThreadSetPriorityAbsoluteRealTime6;         txt = "Abs. Real Time 6"; },
+		MENU_ITEM { command = EMemSpyCmdThreadSetPriorityAbsoluteRealTime7;         txt = "Abs. Real Time 7"; },
+		MENU_ITEM { command = EMemSpyCmdThreadSetPriorityAbsoluteRealTime8;         txt = "Abs. Real Time 8"; }
+        };
+    }
+
+
+RESOURCE MENU_PANE r_memspy_menupane_thread_info
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdThreadInfoHandles;			txt = "Handles"; }
+        };
+    }
+
+
+RESOURCE MENU_PANE r_memspy_menupane_thread_end
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdThreadEndKill;				txt = "Kill"; },
+		MENU_ITEM { command = EMemSpyCmdThreadEndPanic;				txt = "Panic"; },
+		MENU_ITEM { command = EMemSpyCmdThreadEndTerminate;			txt = "Terminate"; }
+        };
+    }
+
+
+RESOURCE MENU_PANE r_memspy_menupane_thread
+    {
+    items=
+        {
+ 		MENU_ITEM { command = EMemSpyCmdThreadInfo;					txt = "Info";				cascade = r_memspy_menupane_thread_info; },
+		MENU_ITEM { command = EMemSpyCmdThreadSetPriority;          txt = "Change Priority";	cascade = r_memspy_menupane_thread_priority; },
+		MENU_ITEM { command = EMemSpyCmdThreadEnd;					txt = "End";				cascade = r_memspy_menupane_thread_end; }
+        };
+    }
+
+
+
+
+
+
+
+
+
+RESOURCE MENU_PANE r_memspy_menupane_output
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdOutputToDebug;              txt = "Switch to Debug output"; },
+		MENU_ITEM { command = EMemSpyCmdOutputToFile;               txt = "Switch to File output"; }
+        };
+    }
+
+
+RESOURCE MENU_PANE r_memspy_menupane_tools
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdToolsListOpenFiles;         txt = "List open files"; },
+		MENU_ITEM { command = EMemSpyCmdOutput;                     txt = "Change output mode";       cascade = r_memspy_menupane_output; }
+        };
+    }
+
+
+RESOURCE MENU_PANE r_memspy_menupane_view
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdViewRefresh;                txt = "Refresh"; },
+		MENU_ITEM { command = EMemSpyCmdViewOutputToSink;           txt = "Output Contents"; }
+        };
+    }
+
+
+RESOURCE MENU_PANE r_memspy_menupane_images
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdImagesListing;              txt = "Output Listing"; },
+		MENU_ITEM { command = EMemSpyCmdImagesSlideshow;            txt = "Slideshow"; }
+#ifndef __WINS__
+		,
+		MENU_ITEM { command = EMemSpyCmdImagesSaveAllToMemoryCard;  txt = "Save All to Memory Card"; }
+#endif
+        };
+    }
+
+
+
+RESOURCE MENU_PANE r_memspy_menupane_server_list_output
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdServerListOutputListCSV;      txt = "Listing"; },
+		MENU_ITEM { command = EMemSpyCmdServerListOutputListDetailed; txt = "Detailed Listing"; }
+        };
+    }
+
+
+RESOURCE MENU_PANE r_memspy_menupane_server_list_sort
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdServerListSortByName;           txt = "By Name"; },
+		MENU_ITEM { command = EMemSpyCmdServerListSortBySessionCount;   txt = "By Number of Sessions"; }
+        };
+    }
+
+
+RESOURCE MENU_PANE r_memspy_menupane_server_list
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdServerListOutput;               txt = "Output";       cascade = r_memspy_menupane_server_list_output; },
+		MENU_ITEM { command = EMemSpyCmdServerListSort;                 txt = "Sort";         cascade = r_memspy_menupane_server_list_sort; }
+        };
+    }
+
+
+
+RESOURCE MENU_PANE r_memspy_menupane_chunk_list_sort
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdChunkSortByName;                txt = "By Name"; },
+		MENU_ITEM { command = EMemSpyCmdChunkSortBySize;                txt = "By Size"; }
+        };
+    }
+
+
+RESOURCE MENU_PANE r_memspy_menupane_chunk_list
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdChunkListing;                   txt = "Output Listing"; },
+		MENU_ITEM { command = EMemSpyCmdChunkSort;                      txt = "Sort";         cascade = r_memspy_menupane_chunk_list_sort; }
+        };
+    }
+
+
+RESOURCE MENU_PANE r_memspy_menupane_codeseg_list_filter_by_capability
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithTCBProcess;              txt = "TCB (Exe)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithTCBAll;                  txt = "TCB (All)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithCommDDProcess;           txt = "Comm DD (Exe)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithCommDDAll;               txt = "Comm DD (All)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithPowerMgmtProcess;        txt = "Power Mgmt (Exe)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithPowerMgmtAll;            txt = "Power Mgmt (All)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithMultimediaDDProcess;     txt = "Multimedia DD (Exe)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithMultimediaDDAll;         txt = "Multimedia DD (All)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithReadDeviceDataProcess;   txt = "Read Device Data (Exe)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithReadDeviceDataAll;       txt = "Read Device Data (All)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithWriteDeviceDataProcess;  txt = "Write Device Data (Exe)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithWriteDeviceDataAll;      txt = "Write Device Data (All)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithDRMProcess;              txt = "DRM (Exe)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithDRMAll;                  txt = "DRM (All)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithTrustedUIProcess;        txt = "Trusted UI (Exe)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithTrustedUIAll;            txt = "Trusted UI (All)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithProtServProcess;         txt = "Prot Serv (Exe)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithProtServAll;             txt = "Prot Serv (All)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithDiskAdminProcess;        txt = "Disk Admin (Exe)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithDiskAdminAll;            txt = "Disk Admin (All)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithNetworkControlProcess;   txt = "Network Ctrl (Exe)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithNetworkControlAll;       txt = "Network Ctrl (All)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithAllFilesProcess;         txt = "All Files (Exe)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithAllFilesAll;             txt = "All Files (All)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithSwEventProcess;          txt = "SW Event (Exe)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithSwEventAll;              txt = "SW Event (All)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithNetworkServicesProcess;  txt = "Network Serv (Exe)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithNetworkServicesAll;      txt = "Network Serv (All)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithLocalServicesProcess;    txt = "Local Serv (Exe)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithLocalServicesAll;        txt = "Local Serv (All)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithReadUserDataProcess;     txt = "Read User Data (Exe)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithReadUserDataAll;         txt = "Read User Data (All)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithWriteUserDataProcess;    txt = "Write User Data (Exe)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithWriteUserDataAll;        txt = "Write User Data (All)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithLocationProcess;         txt = "Location (Exe)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithLocationAll;             txt = "Location (All)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithSurroundingsDDProcess;   txt = "Surroundings DD (Exe)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithSurroundingsDDAll;       txt = "Surroundings DD (All)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithUserEnvProcess;          txt = "User Env (Exe)"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCapsWithUserEnvAll;              txt = "User Env (All)"; }
+        };
+    }
+
+
+
+RESOURCE MENU_PANE r_memspy_menupane_codeseg_list_filter
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowItemsAll;                    txt = "None"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowItemsGlobalData;             txt = "By Global Data"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShowCaps;                        txt = "By Capability";         cascade = r_memspy_menupane_codeseg_list_filter_by_capability; }
+        };
+    }
+
+
+RESOURCE MENU_PANE r_memspy_menupane_codeseg_list_sort
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdCodeSegSortByName;               txt = "By Name"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegSortByCodeSize;           txt = "By Code Size"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegSortByDataSize;           txt = "By Total Data Size"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegSortByUid;                txt = "By Uid"; }
+        };
+    }
+
+
+RESOURCE MENU_PANE r_memspy_menupane_codeseg_list
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdCodeSegListing;                 txt = "Output Listing"; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegShow;                    txt = "Filter";       cascade = r_memspy_menupane_codeseg_list_filter; },
+		MENU_ITEM { command = EMemSpyCmdCodeSegSort;                    txt = "Sort";         cascade = r_memspy_menupane_codeseg_list_sort; }
+        };
+    }
+
+
+
+
+
+RESOURCE MENU_PANE r_memspy_menupane_active_objects
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdActiveObjectListing;            txt = "Output Listing"; }
+        };
+    }
+
+
+
+
+RESOURCE MENU_PANE r_memspy_menupane_ram
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdRAMAvkonIconCacheDisabled;      txt = "Disable Icon Cache"; },
+		MENU_ITEM { command = EMemSpyCmdRAMAvkonIconCacheEnabled;       txt = "Enable Icon Cache"; }
+        };
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+RESOURCE MENU_PANE r_memspy_menupane_kernel_containers
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdKernelContainersOutput;                     txt = "Output list"; }
+        };
+    }
+
+
+RESOURCE MENU_PANE r_memspy_menupane_kernel_objects
+    {
+    items=
+        {
+        MENU_ITEM { command = EMemSpyCmdKernelObjectTerminate;                     txt = "Terminate"; },
+        MENU_ITEM { command = EMemSpyCmdKernelObjectSwitchTo;                      txt = "Switch to"; },
+        MENU_ITEM { command = EMemSpyCmdKernelObjectEnd;                           txt = "End"; },
+        MENU_ITEM { command = EMemSpyCmdKernelObjectPanic;                         txt = "Panic"; }
+        };
+    }
+
+
+RESOURCE MENU_PANE r_memspy_menupane_kernel_heap
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdKernelHeapDump;                             txt = "Dump Heap"; }
+        };
+    }
+
+
+
+RESOURCE MENU_PANE r_memspy_menupane_memory_tracking
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdMemoryTrackingStart;						txt = "Start"; },
+		MENU_ITEM { command = EMemSpyCmdMemoryTrackingStop;							txt = "Stop"; },
+		MENU_ITEM { command = EMemSpyCmdMemoryTrackingTotalWithSharedMem;			txt = "Include shared memory in Total"; },
+		MENU_ITEM { command = EMemSpyCmdMemoryTrackingTotalWithoutSharedMem;		txt = "Exclude shared memory from Total"; },
+		MENU_ITEM { command = EMemSpyCmdMemoryTrackingHWMReset;						txt = "Reset HWM"; }
+        };
+    }
+
+
+
+RESOURCE MENU_PANE r_memspy_menupane_memory_tracking_hwm
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdMemoryTrackingHWMReset;						txt = "Reset"; }
+        };
+    }
+
+
+
+RESOURCE MENU_PANE r_memspy_menupane_memory_tracking_autostart
+    {
+    items=
+        {
+		MENU_ITEM { command = EMemSpyCmdMemoryTrackingAutoStartItemAdd;				txt = "Add"; },
+		MENU_ITEM { command = EMemSpyCmdMemoryTrackingAutoStartItemEdit;			txt = "Edit"; },
+		MENU_ITEM { command = EMemSpyCmdMemoryTrackingAutoStartItemDelete;			txt = "Remove"; },
+		MENU_ITEM { command = EMemSpyCmdMemoryTrackingAutoStartItemDeleteAll;		txt = "Remove All"; },
+		MENU_ITEM { command = EMemSpyCmdMemoryTrackingAutoStartItemImport;			txt = "Import"; }
+        };
+    }
+
+
+
+
+RESOURCE MENU_PANE r_memspy_menupane_window_groups
+    {
+    items=
+        {
+        MENU_ITEM { command = EMemSpyCmdWindowGroupTerminate;                     txt = "Terminate"; },
+        MENU_ITEM { command = EMemSpyCmdWindowGroupSwitchTo;                      txt = "Switch to"; },
+        MENU_ITEM { command = EMemSpyCmdWindowGroupEnd;                           txt = "End"; },
+        MENU_ITEM { command = EMemSpyCmdWindowGroupPanic;                         txt = "Panic"; }
+        };
+    }
+
+
+
+
+
+
+
+RESOURCE MENU_PANE r_memspy_menupane
+    {
+    items=
+        {
+		// This item is visible if the view supports child views
+		MENU_ITEM { command = EMemSpyCmdOpen;						txt = "Open"; },
+		
+		// These are view-specific menu cascades that are not shown unless a specific view is open
+		MENU_ITEM { command = EMemSpyCmdServerList;						txt = "Server List";        cascade = r_memspy_menupane_server_list; },
+		MENU_ITEM { command = EMemSpyCmdChunk;							txt = "Chunk";              cascade = r_memspy_menupane_chunk_list; },
+		MENU_ITEM { command = EMemSpyCmdCodeSeg;						txt = "Code Segment";       cascade = r_memspy_menupane_codeseg_list; },
+		MENU_ITEM { command = EMemSpyCmdImages;							txt = "Images";             cascade = r_memspy_menupane_images; },
+		MENU_ITEM { command = EMemSpyCmdActiveObject;					txt = "Active Object";      cascade = r_memspy_menupane_active_objects; },
+		MENU_ITEM { command = EMemSpyCmdHeap;							txt = "Heap";               cascade = r_memspy_menupane_heap; },
+		MENU_ITEM { command = EMemSpyCmdStack;							txt = "Stack";              cascade = r_memspy_menupane_stack; },
+		MENU_ITEM { command = EMemSpyCmdRAM;							txt = "RAM";                cascade = r_memspy_menupane_ram; },
+		MENU_ITEM { command = EMemSpyCmdProcess;						txt = "Process";            cascade = r_memspy_menupane_process; },
+		MENU_ITEM { command = EMemSpyCmdThread;							txt = "Thread";             cascade = r_memspy_menupane_thread; },
+		MENU_ITEM { command = EMemSpyCmdKernelContainers;				txt = "Kernel Objects";     cascade = r_memspy_menupane_kernel_containers; },
+		MENU_ITEM { command = EMemSpyCmdKernelObjects;                  txt = "Kernel Object";      cascade = r_memspy_menupane_kernel_objects; },
+		MENU_ITEM { command = EMemSpyCmdKernelHeap;						txt = "Kernel Heap";        cascade = r_memspy_menupane_kernel_heap; },
+		MENU_ITEM { command = EMemSpyCmdMemoryTracking;					txt = "Memory Tracking";    cascade = r_memspy_menupane_memory_tracking; },
+		MENU_ITEM { command = EMemSpyCmdMemoryTrackingHWM;				txt = "Memory HWM";			cascade = r_memspy_menupane_memory_tracking_hwm; },
+		MENU_ITEM { command = EMemSpyCmdMemoryTrackingAutoStart;		txt = "Auto-Start Items";   cascade = r_memspy_menupane_memory_tracking_autostart; },
+		MENU_ITEM { command = EMemSpyCmdWindowGroups;                   txt = "Window Group";       cascade = r_memspy_menupane_window_groups; },
+		
+		// These are standard menu items that are always visible
+		MENU_ITEM { command = EMemSpyCmdView;							txt = "View";               cascade = r_memspy_menupane_view; },
+		MENU_ITEM { command = EMemSpyCmdTools;							txt = "Tools";              cascade = r_memspy_menupane_tools; },
+		MENU_ITEM { command = EMemSpyCmdPhoneInfo;						txt = "Phone Information";  cascade = r_memspy_menupane_phone_info; },
+		MENU_ITEM { command = EMemSpyCmdAutoCapture;					txt = "Automatic Capture";  cascade = r_memspy_menupane_auto_capture; },
+
+		// About
+        MENU_ITEM { command = EMemSpyCmdToolsAbout;						txt = "About"; },
+		
+		// One or other is visible, depending on whether it is a top level menu item
+		MENU_ITEM { command = EAknSoftkeyBack;							txt = "Back"; },
+		MENU_ITEM { command = EAknCmdExit;								txt = "Exit"; }
+        };
+    }
+
+
+RESOURCE DIALOG r_memspy_device_wide_operation_progress_dialog
+    {
+    title   = "Performing operation..";
+    flags   = EAknProgressNoteFlags | EEikDialogFlagWait;
+    buttons = R_AVKON_SOFTKEYS_CANCEL;
+    items   =
+        {
+        DLG_LINE
+            {
+            type    = EAknCtNote;
+            id      = EMemSpyCtrlIdProgressNote;
+            control = AVKON_NOTE 
+                { 
+                layout      = EProgressLayout;
+                imagefile   = AVKON_ICON_FILE;
+                imageid     = EMbmAvkonQgn_note_progress;
+                imagemask   = EMbmAvkonQgn_note_progress_mask;
+                };
+            }
+        };
+    }
+
+
+RESOURCE DIALOG r_memspy_export_to_memorycard_dialog
+    {
+    title   = "Save Bitmaps to Memory Card";
+    flags   = EAknProgressNoteFlags | EEikDialogFlagWait;
+    buttons = R_AVKON_SOFTKEYS_CANCEL;
+    items   =
+        {
+        DLG_LINE
+            {
+            type    = EAknCtNote;
+            id      = EMemSpyCtrlIdProgressNote;
+            control = AVKON_NOTE 
+                { 
+                layout      = EProgressLayout;
+                imagefile   = AVKON_ICON_FILE;
+                imageid     = EMbmAvkonQgn_note_progress;
+                imagemask   = EMbmAvkonQgn_note_progress_mask;
+                };
+            }
+        };
+    }
+
+
+RESOURCE DIALOG r_memspy_device_wide_settings
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        DLG_LINE
+            {
+            type    = EAknCtQuery;
+            id      = EGeneralQuery;
+            control = AVKON_DATA_QUERY 
+                { 
+                layout  = ENumberLayout;
+                label   = "Frequency (seconds)";
+                control = AVKON_INTEGER_EDWIN
+                    {
+                    min         =    5;
+                    max         = 3600;
+                    maxlength   =    4;
+                    };
+                };
+            }
+        };
+    }
+
+
+RESOURCE DIALOG r_memspy_preparing_info_item_container_wait_note
+    {
+    flags   = EAknWaitNoteFlags | EEikDialogFlagWait;
+    buttons = R_AVKON_SOFTKEYS_EMPTY;
+    items   =
+        {
+        DLG_LINE
+            {
+            type    = EAknCtNote;
+            id      = EMemSpyCtrlIdWaitNote;
+            control = AVKON_NOTE 
+                { 
+                layout          = EWaitLayout;
+                singular_label  = "Preparing items...";
+                imagefile       = AVKON_ICON_FILE;
+                imageid         = EMbmAvkonQgn_note_progress;
+                imagemask       = EMbmAvkonQgn_note_progress_mask;
+                animation       = R_QGN_GRAF_WAIT_BAR_ANIM;
+                };
+            }
+        };
+    }
+
+
+
+
+
+RESOURCE DIALOG r_memspy_image_slideshow
+    {
+    title   = "Image Slideshow...";
+    flags   = EEikDialogFlagNoDrag | EEikDialogFlagCbaButtons | EEikDialogFlagWait;
+    buttons = R_AVKON_SOFTKEYS_CANCEL;
+    items   =
+        {
+        DLG_LINE
+            {
+            type    = EEikCtImage;
+            id      = EMemSpyCtrlIdSlideShowImage;
+            control = IMAGE
+                {
+                };
+            }
+        };
+    }
+
+
+
+
+
+
+RESOURCE DIALOG r_memspy_heap_tracker_timer_period
+    {
+    flags   = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items   =
+        {
+        DLG_LINE
+            {
+            type    = EAknCtQuery;
+            id      = EGeneralQuery;
+            control = AVKON_DATA_QUERY 
+                { 
+                layout  = ENumberLayout;
+                label   = "Frequency (seconds)";
+                control = AVKON_INTEGER_EDWIN
+                    {
+                    min         =   30;
+                    max         = 3600;
+                    maxlength   =    4;
+                    };
+                };
+            }
+        };
+    }
+
+
+RESOURCE DIALOG r_memspy_heap_tracker_name_filter
+    {
+    flags   = EAknDialogGenericQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items   =
+        {
+        DLG_LINE
+            {
+            type    = EAknCtQuery;
+            id      = EGeneralQuery;
+            control = AVKON_DATA_QUERY 
+                { 
+                layout  = EDataLayout;
+                label   = "Thread Name Filter";
+                control = EDWIN
+                    {
+                    flags               = 0;
+                    width               = 8;
+                    lines               = 1;
+                    maxlength           = 16;
+                    avkon_flags         = EAknEditorFlagNoT9 | EAknEditorFlagLatinInputModesOnly;
+                    allowed_input_modes = EAknEditorTextInputMode | EAknEditorNumericInputMode;
+                    default_input_mode  = EAknEditorTextInputMode;
+                    };
+                };
+            }
+        };
+    }
+
+RESOURCE DIALOG r_memspy_memory_tracking_process_uid_dialog
+    {
+    flags	= EAknDialogGenericQueryFlags;
+    buttons	= R_AVKON_SOFTKEYS_OK_CANCEL;
+    items	=
+        {
+        DLG_LINE
+            {
+            type    = EAknCtQuery;
+            id      = EGeneralQuery;
+            control = AVKON_DATA_QUERY 
+                { 
+                layout	= EDataLayout;
+                label	= "Process Uid (Hex)";
+                control = EDWIN
+                    {
+                    flags				= 0;
+                    width				= 8;
+                    lines				= 1;
+                    maxlength			= 8;
+                    avkon_flags			= EAknEditorFlagNoT9 | EAknEditorFlagLatinInputModesOnly;
+                    allowed_input_modes = EAknEditorTextInputMode | EAknEditorNumericInputMode;
+                    default_input_mode	= EAknEditorNumericInputMode;
+                    };
+                };
+            }
+        };
+    }
+
+
+RESOURCE DIALOG r_memspy_memory_tracking_import_from_installed_xml_dialog
+	{
+	flags	= EGeneralQueryFlags;
+	buttons	= R_AVKON_SOFTKEYS_YES_NO;
+	items	=
+		{
+        DLG_LINE
+            {
+            type    = EAknCtQuery;
+            id      = EGeneralQuery;
+            control = AVKON_CONFIRMATION_QUERY 
+                { 
+		        layout		= EConfirmationLayout;
+			    label		= "Import auto-start items\nfrom installed XML file?";
+				animation	= R_QGN_NOTE_QUERY_ANIM;
+				};
+			}
+		};
+	}
+
+
+RESOURCE DIALOG r_memspy_memory_tracking_import_from_userdefined_xml_dialog
+	{
+	flags	= EGeneralQueryFlags;
+	buttons	= R_AVKON_SOFTKEYS_YES_NO;
+	items	=
+		{
+        DLG_LINE
+            {
+            type    = EAknCtQuery;
+            id      = EGeneralQuery;
+            control = AVKON_CONFIRMATION_QUERY 
+                { 
+		        layout		= EConfirmationLayout;
+			    label		= "Import auto-start items\nfrom custom XML file?";
+				animation	= R_QGN_NOTE_QUERY_ANIM;
+				};
+			}
+		};
+	}
+
+    
+RESOURCE DIALOG r_memspyui_about_dialog
+	{
+    flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow;
+    buttons = R_AVKON_SOFTKEYS_OK_EMPTY;
+    items=
+		{
+        DLG_LINE
+			{
+            type = EAknCtPopupHeadingPane;
+            id = EAknMessageQueryHeaderId;
+            control = AVKON_HEADING
+				{
+                label = "About MemSpy";
+                headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE;
+				};
+			},
+        DLG_LINE
+			{
+            type = EAknCtMessageQuery;
+            id = EAknMessageQueryContentId;
+            control = AVKON_MESSAGE_QUERY
+				{
+                message = "Version 1.2.0 - 27th October 2009. Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0.";
+				};
+			}
+		};
+	}
+
+
+
+RESOURCE DIALOG r_memspy_ram_memory_delta_dialog
+    {
+	flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_EMPTY__OK;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtNote;
+		    id = EGeneralNote;
+            control = AVKON_NOTE 
+                { 
+                layout = EGeneralLayout;
+                singular_label = "Memory Delta";
+                animation = R_QGN_NOTE_INFO_ANIM;
+                };
+            }
+        };
+    }
+
+
+RESOURCE DIALOG r_memspy_panic_system_critical_thread_or_process
+	{
+	flags	= EGeneralQueryFlags;
+	buttons	= R_AVKON_SOFTKEYS_YES_NO;
+	items	=
+		{
+        DLG_LINE
+            {
+            type    = EAknCtQuery;
+            id      = EGeneralQuery;
+            control = AVKON_CONFIRMATION_QUERY 
+                { 
+		        layout		= EConfirmationLayout;
+			    label		= "Terminating/killing/panicking item will cause a reboot.\nContinue?";
+				animation	= R_QGN_NOTE_QUERY_ANIM;
+				};
+			}
+		};
+	}
+
+RESOURCE DIALOG r_memspy_kernel_object_details_dialog
+    {
+    flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow;
+
+    buttons = R_AVKON_SOFTKEYS_OK_EMPTY;
+    items=
+        {
+        DLG_LINE
+            {
+            type = EAknCtPopupHeadingPane;
+            id = EAknMessageQueryHeaderId;
+            control = AVKON_HEADING
+                {
+                label = "Object details";
+                headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE;
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtMessageQuery;
+            id = EAknMessageQueryContentId;
+            control = AVKON_MESSAGE_QUERY
+                {
+                message = ".";
+                };
+            }
+        };
+    }
+
+RESOURCE AVKON_SETTING_PAGE r_memspyui_swmt_categories_setting_page
+    {
+    type = EAknSetListBox;
+    editor_resource_id = r_memspyui_swmt_categories_items_listbox;
+    label = "SWMT Categories";
+    }   
+
+RESOURCE LISTBOX r_memspyui_swmt_categories_items_listbox
+    {
+    flags = EAknListBoxMultipleSelection;
+    }
+
+// ---------------------------------------------------------
+//   
+//    RESOURCE LOCALISABLE_APP_INFO
+//
+// ---------------------------------------------------------
+//
+RESOURCE LOCALISABLE_APP_INFO r_memspyui_localisable_app_info
+    {
+    short_caption = "MemSpy";
+    caption_and_icon = 
+    CAPTION_AND_ICON_INFO
+        {
+        caption = "MemSpy";
+
+        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"\\memspyui_aif.mif";
+        };
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/data/memspyui_reg.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,37 @@
+/*
+* 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:
+*
+*/
+
+
+// System includes
+#include <memspyui.rsg>
+#include <appinfo.rh>
+#include <data_caging_paths_strings.hrh>
+
+
+
+UID2 KUidAppRegistrationResourceFile
+
+UID3 0x2002129F
+
+
+RESOURCE APP_REGISTRATION_INFO
+    {
+    app_file                    = "MemSpyUI";
+    localisable_resource_file   = APP_RESOURCE_DIR"\\MemSpyUI";
+    localisable_resource_id     = R_MEMSPYUI_LOCALISABLE_APP_INFO;
+    group_name					= "RnD Tools";
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/group/MemSpyCapabilities.mmh	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,19 @@
+/*
+* 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:
+*
+*/
+
+
+CAPABILITY      ReadUserData WriteUserData ReadDeviceData WriteDeviceData SwEvent PowerMgmt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,54 @@
+/*
+* 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>
+#include "../memspywindowserverhelper/group/bld.inf"
+
+PRJ_EXPORTS
+../data/MemSpyEComInterfaceIds.xml                      z:/private/2002129F/memspyecominterfaceids.xml
+../data/MemSpyProcessMemoryTrackingAutoStartConfig.xml	z:/private/2002129F/memspyprocessmemorytrackingautostartconfig.xml
+../data/backup_registration.xml							z:/private/2002129F/backup_registration.xml
+../rom/memspyui.iby                                     CORE_IBY_EXPORT_PATH(tools,memspyui.iby)
+
+
+PRJ_MMPFILES
+memspyui.mmp
+
+#ifndef SBSV2
+  gnumakefile memspyui_icons_aif.mk
+
+  #ifdef MARM
+  gnumakefile memspyui_stub_sis.mk
+  #endif
+#endif
+
+#ifdef SBSV2
+  PRJ_EXTENSIONS
+  START EXTENSION s60/mifconv
+  OPTION TARGETFILE memspyui_aif.mif
+  OPTION SOURCEDIR ../icons
+  OPTION SOURCES -c8,8 qgn_menu_memspyui
+  END
+
+  #ifdef MARM
+  START EXTENSION app-services/buildstubsis
+  OPTION SRCDIR ../sis
+  OPTION SISNAME MemSpy_stub
+  END
+  #endif 
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/group/memspyui.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,104 @@
+/*
+* 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 <bldvariant.hrh>
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          memspyui.exe
+TARGETTYPE      exe
+UID             0x100039CE 0x2002129F
+VENDORID		VID_DEFAULT
+SMPSAFE
+
+EPOCSTACKSIZE	0x4000
+EPOCHEAPSIZE	0x100000 0x4000000
+
+#include		"MemSpyCapabilities.mmh"
+
+SOURCEPATH      ../source
+source          MemSpyApp.cpp 
+source          MemSpyAppUi.cpp
+source          MemSpyDocument.cpp
+source          MemSpyContainer.cpp
+source          MemSpyDeviceWideOperationDialog.cpp
+source          MemSpyExportBitmapsToMemoryCardDialog.cpp
+source          MemSpyUiUtils.cpp
+source          MemSpySettings.cpp
+//
+source          MemSpyViewBase.cpp
+source          MemSpyViewMainMenu.cpp
+source          MemSpyViewType.cpp
+source          MemSpyViewProcesses.cpp
+source          MemSpyViewServerList.cpp
+source          MemSpyViewOpenFiles.cpp
+source          MemSpyViewRAMInfo.cpp
+source          MemSpyViewROMInfo.cpp
+source          MemSpyViewFBServBitmaps.cpp
+source          MemSpyViewSystemConfig.cpp
+source          MemSpyViewCodeSegList.cpp
+source          MemSpyViewChunkList.cpp
+source          MemSpyViewKernel.cpp
+source          MemSpyViewKernelContainers.cpp
+source          MemSpyViewKernelHeap.cpp
+source			MemSpyViewDriveInfo.cpp
+source			MemSpyViewECom.cpp
+source          MemSpyViewThreads.cpp
+source          MemSpyViewThreadInfoItemList.cpp
+source          MemSpyViewThreadInfoItemGeneric.cpp
+source          MemSpyViewThreadInfoItemHeap.cpp
+source          MemSpyViewThreadInfoItemStack.cpp
+source          MemSpyViewThreadInfoItemCodeSeg.cpp
+source          MemSpyViewThreadInfoItemChunk.cpp
+source          MemSpyViewThreadInfoItemServer.cpp
+source          MemSpyViewThreadInfoItemActiveObject.cpp
+source          MemSpyViewThreadInfoItemGeneralInfo.cpp
+source          MemSpyViewHeapTracking.cpp
+source          MemSpyViewHeapTrackingResults.cpp
+source          MemSpyViewHeapTrackingSettings.cpp
+source			MemSpyViewThreadInfoItemMemoryTracking.cpp
+source			MemSpyViewMemoryTrackingAutoStartConfig.cpp
+source			MemSpyViewWindowGroups.cpp
+source          MemSpyViewKernelObjects.cpp
+
+USERINCLUDE		../include
+
+APP_LAYER_SYSTEMINCLUDE
+
+
+START RESOURCE    ../data/memspyui.rss
+HEADER
+TARGETPATH        APP_RESOURCE_DIR
+END
+
+START RESOURCE    ../data/memspyui_reg.rss
+DEPENDS           memspyui.rsg
+TARGETPATH        /private/10003a3f/apps
+END
+
+
+LIBRARY			fbscli.lib				imageconversion.lib		estor.lib		apgrfx.lib
+LIBRARY			euser.lib				apparc.lib				cone.lib		eikcore.lib 
+LIBRARY			eikcoctl.lib			avkon.lib				etext.lib		eikctl.lib		
+LIBRARY			efsrv.lib				bafl.lib				egul.lib		hal.lib
+LIBRARY			cdlengine.lib			xmlframework.lib		charconv.lib	viewcli.lib
+LIBRARY			eikdlg.lib				ws32.lib				bitgdi.lib
+
+LIBRARY			memspydriverclient.lib
+LIBRARY			memspyengine.lib 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/group/memspyui_icons_aif.mk	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,54 @@
+#
+# 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:  
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z
+else
+ZDIR=\epoc32\data\z
+endif
+
+TARGETDIR=$(ZDIR)\resource\apps
+ICONTARGETFILENAME=$(TARGETDIR)\memspyui_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_memspyui.svg
+	mifconv $(ICONTARGETFILENAME) \
+		/c8,8 ..\icons\qgn_menu_memspyui.svg
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/group/memspyui_stub_sis.mk	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,56 @@
+#
+# 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:  
+#
+
+
+TARGETDIR=$(EPOCROOT)EPOC32\Data\Z\System\Install
+
+SISNAME=MemSpy_stub
+PKGNAME=MemSpy_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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/icons/qgn_menu_memspyui.svg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,363 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+   xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   version="1.0"
+   width="100%"
+   height="100%"
+   viewBox="0 0 87.999512 88.000488"
+   id="svg76799">
+  <defs
+     id="defs76881">
+    <radialGradient
+       cx="16.93359"
+       cy="17.94434"
+       r="10.21466"
+       fx="16.93359"
+       fy="17.94434"
+       id="XMLID_12_"
+       gradientUnits="userSpaceOnUse">
+      <stop
+         style="stop-color:#bdcede;stop-opacity:1"
+         offset="0"
+         id="stop2443" />
+      <stop
+         style="stop-color:#b3b6ed;stop-opacity:1"
+         offset="1"
+         id="stop2445" />
+      <a:midPointStop
+         style="stop-color:#BDCEDE"
+         offset="0" />
+      <a:midPointStop
+         style="stop-color:#BDCEDE"
+         offset="0.5" />
+      <a:midPointStop
+         style="stop-color:#B3B6ED"
+         offset="1" />
+    </radialGradient>
+    <linearGradient
+       x1="7.6855502"
+       y1="33.568359"
+       x2="9.2402296"
+       y2="35.123051"
+       id="XMLID_11_"
+       gradientUnits="userSpaceOnUse">
+      <stop
+         style="stop-color:#647490;stop-opacity:1"
+         offset="0"
+         id="stop2374" />
+      <stop
+         style="stop-color:#3b5375;stop-opacity:1"
+         offset="1"
+         id="stop2376" />
+      <a:midPointStop
+         style="stop-color:#647490"
+         offset="0" />
+      <a:midPointStop
+         style="stop-color:#647490"
+         offset="0.5" />
+      <a:midPointStop
+         style="stop-color:#3B5375"
+         offset="1" />
+    </linearGradient>
+    <linearGradient
+       x1="-87.874023"
+       y1="86.413094"
+       x2="-68.792519"
+       y2="59.91861"
+       id="XMLID_10_"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(1,0,0,-1,106.50049,93.23242)">
+      <stop
+         style="stop-color:#ffffff;stop-opacity:1"
+         offset="0"
+         id="stop2363" />
+      <stop
+         style="stop-color:#f5f5f5;stop-opacity:1"
+         offset="0.12323"
+         id="stop2365" />
+      <stop
+         style="stop-color:#dcdcdc;stop-opacity:1"
+         offset="0.62667"
+         id="stop2367" />
+      <stop
+         style="stop-color:#b2b2b2;stop-opacity:1"
+         offset="1"
+         id="stop2369" />
+      <a:midPointStop
+         style="stop-color:#FFFFFF"
+         offset="0" />
+      <a:midPointStop
+         style="stop-color:#FFFFFF"
+         offset="0.5" />
+      <a:midPointStop
+         style="stop-color:#F5F5F5"
+         offset="0.12323" />
+      <a:midPointStop
+         style="stop-color:#F5F5F5"
+         offset="0.5" />
+      <a:midPointStop
+         style="stop-color:#DCDCDC"
+         offset="0.62667" />
+      <a:midPointStop
+         style="stop-color:#DCDCDC"
+         offset="0.5" />
+      <a:midPointStop
+         style="stop-color:#B2B2B2"
+         offset="1" />
+    </linearGradient>
+    <linearGradient
+       x1="-354.65088"
+       y1="-320.31396"
+       x2="-346.3559"
+       y2="-290.57343"
+       id="XMLID_9_"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="translate(381.50049,321.26758)">
+      <stop
+         style="stop-color:#5e5f5f;stop-opacity:1"
+         offset="0"
+         id="stop2332" />
+      <stop
+         style="stop-color:#7b7c7c;stop-opacity:1"
+         offset="0.0454"
+         id="stop2334" />
+      <stop
+         style="stop-color:#bfbfc0;stop-opacity:1"
+         offset="0.13559"
+         id="stop2336" />
+      <stop
+         style="stop-color:#c8c8c9;stop-opacity:1"
+         offset="0.16057999"
+         id="stop2338" />
+      <stop
+         style="stop-color:#e2e2e2;stop-opacity:1"
+         offset="0.20213"
+         id="stop2340" />
+      <stop
+         style="stop-color:#ffffff;stop-opacity:1"
+         offset="0.24011"
+         id="stop2342" />
+      <stop
+         style="stop-color:#ffffff;stop-opacity:1"
+         offset="0.28248999"
+         id="stop2344" />
+      <stop
+         style="stop-color:#e9e9e9;stop-opacity:1"
+         offset="0.34463"
+         id="stop2346" />
+      <stop
+         style="stop-color:#919191;stop-opacity:1"
+         offset="0.639"
+         id="stop2348" />
+      <stop
+         style="stop-color:#4a4a4a;stop-opacity:1"
+         offset="0.81300002"
+         id="stop2350" />
+      <stop
+         style="stop-color:#1e1e1e;stop-opacity:1"
+         offset="0.93730003"
+         id="stop2352" />
+      <stop
+         style="stop-color:#0d0d0d;stop-opacity:1"
+         offset="1"
+         id="stop2354" />
+      <a:midPointStop
+         style="stop-color:#5E5F5F"
+         offset="0" />
+      <a:midPointStop
+         style="stop-color:#5E5F5F"
+         offset="0.5" />
+      <a:midPointStop
+         style="stop-color:#7B7C7C"
+         offset="0.0454" />
+      <a:midPointStop
+         style="stop-color:#7B7C7C"
+         offset="0.5" />
+      <a:midPointStop
+         style="stop-color:#BFBFC0"
+         offset="0.13559" />
+      <a:midPointStop
+         style="stop-color:#BFBFC0"
+         offset="0.5" />
+      <a:midPointStop
+         style="stop-color:#C8C8C9"
+         offset="0.16058" />
+      <a:midPointStop
+         style="stop-color:#C8C8C9"
+         offset="0.5" />
+      <a:midPointStop
+         style="stop-color:#E2E2E2"
+         offset="0.20213" />
+      <a:midPointStop
+         style="stop-color:#E2E2E2"
+         offset="0.5" />
+      <a:midPointStop
+         style="stop-color:#FFFFFF"
+         offset="0.24011" />
+      <a:midPointStop
+         style="stop-color:#FFFFFF"
+         offset="0.5" />
+      <a:midPointStop
+         style="stop-color:#FFFFFF"
+         offset="0.28249" />
+      <a:midPointStop
+         style="stop-color:#FFFFFF"
+         offset="0.5" />
+      <a:midPointStop
+         style="stop-color:#E9E9E9"
+         offset="0.34463" />
+      <a:midPointStop
+         style="stop-color:#E9E9E9"
+         offset="0.5" />
+      <a:midPointStop
+         style="stop-color:#919191"
+         offset="0.639" />
+      <a:midPointStop
+         style="stop-color:#919191"
+         offset="0.5" />
+      <a:midPointStop
+         style="stop-color:#4A4A4A"
+         offset="0.813" />
+      <a:midPointStop
+         style="stop-color:#4A4A4A"
+         offset="0.5" />
+      <a:midPointStop
+         style="stop-color:#1E1E1E"
+         offset="0.9373" />
+      <a:midPointStop
+         style="stop-color:#1E1E1E"
+         offset="0.5" />
+      <a:midPointStop
+         style="stop-color:#0D0D0D"
+         offset="1" />
+    </linearGradient>
+  </defs>
+  <g
+     transform="matrix(2.0830394,0,0,2.0830394,-2.7158205,-1.6551108)"
+     id="g2735">
+    <path
+       d="M 38.8125,4.88574 C 34.00684,3.94433 18.62012,2.92529 18.03369,2.92529 C 17.44531,2.92529 15.28808,3.38379 14.93457,3.72607 C 14.8291,3.8291 14.81787,3.8291 14.82666,3.80273 L 14.84229,3.81884 C 15.94922,3.68505 34.9375,5.16064 37.96583,6.06396 C 38.61817,6.61084 38.69044,8.49218 38.74708,9.29345 C 38.89845,11.35302 38.59474,28.32031 38.46388,29.6621 C 38.3379,30.95702 38.4131,31.27929 37.8213,32.16796 C 37.62013,32.46484 37.45607,32.63671 37.11232,32.74413 C 37.12013,32.74022 37.23146,32.73241 37.23634,32.73046 C 37.93751,32.58983 40.54493,30.97069 40.78029,30.22265 C 41.29982,28.34179 41.70607,10.79247 41.46584,8.16992 C 41.48438,5.16064 39.57227,5.03418 38.8125,4.88574 z "
+       style="fill:url(#XMLID_9_)"
+       id="path2356" />
+    <path
+       d="M 37.82031,32.16797 C 38.41211,31.28125 38.33789,30.95899 38.46386,29.66211 C 38.59472,28.32422 38.93652,11.7793 38.82909,9.86133 C 38.72069,7.94385 38.708,6.57862 38.00975,6.1001 C 36.80176,5.3623 16.21094,3.75537 14.84131,3.81885 C 13.47217,3.8833 13.29639,26.92383 14.1211,27.20508 C 14.67237,28.03125 35.43848,32.70508 36.86719,32.74414 C 37.32813,32.7832 37.60938,32.48438 37.82031,32.16797 z "
+       style="fill:#ffffff"
+       id="path2358" />
+    <path
+       d="M 37.67578,10.2373 C 37.62598,8.34619 37.70117,7.6372 37.0664,7.16308 C 36.52051,6.604 17.74316,4.69287 16.24512,4.88672 C 16.13379,4.89942 15.62403,5.13428 15.5625,5.16211 C 16.45996,4.77881 36.09863,6.8208 36.64648,7.37891 C 37.32519,7.87012 37.20507,8.56006 37.25586,10.45215 C 37.32813,13.60108 37.24414,27.40235 37.12793,28.65235 C 37.03613,30.91016 36.35645,31.37501 35.68652,31.45508 C 35.76367,31.44922 35.83886,31.44336 35.90136,31.43164 C 36.73534,31.24609 37.46093,30.61133 37.54687,28.43945 C 37.66504,27.1875 37.74805,13.38574 37.67578,10.2373 z "
+       style="fill:#464646"
+       id="path2360" />
+    <path
+       d="M 37.12695,28.68359 C 37.25,27.46875 37.34765,13.40722 37.27148,10.3413 C 37.21875,8.4995 37.34277,7.82665 36.63085,7.34862 C 36.05858,6.80516 16.6494,4.791 15.70995,5.16405 C 14.76855,5.5376 14.6792,7.93262 14.6665,15.2085 C 14.66015,18.84766 14.62109,21.4668 14.6499,23.27344 C 14.67822,25.07813 14.77295,26.06836 15.03515,26.45117 C 15.70214,27.38086 33.5039,31.45508 35.22167,31.42187 C 35.35546,31.42578 35.5664,31.42382 35.75097,31.4121 C 36.45313,31.33594 37.03027,30.88477 37.12695,28.68359 z "
+       style="fill:url(#XMLID_10_)"
+       id="path2371" />
+    <path
+       d="M 13.88525,26.61621 C 14.35742,26.95703 14.54834,27.49902 14.31298,27.82519 L 4.11621,41.89746 C 3.87988,42.22363 3.30566,42.20996 2.83301,41.86914 L 2.83301,41.86914 C 2.36231,41.52637 2.1709,40.98535 2.40723,40.6582 L 12.60303,26.58691 C 12.83936,26.26074 13.41357,26.27344 13.88525,26.61621 L 13.88525,26.61621 z "
+       style="fill:url(#XMLID_11_)"
+       id="path2378" />
+    <path
+       d="M 19.96289,20.87451 L 19.0415,20.7124 C 18.20654,20.56592 17.53418,21.12256 17.54052,21.95801 L 17.56249,25.24707 C 17.56835,26.08008 18.24755,26.88477 19.08007,27.04102 L 19.9995,27.2129 C 20.83348,27.3711 21.50389,26.81446 21.4995,25.97462 L 21.48095,22.6631 C 21.47559,21.82031 20.79688,21.021 19.96289,20.87451 z M 21.12646,25.59375 C 21.13037,26.27344 20.58593,26.72559 19.91015,26.60059 L 19.16259,26.46094 C 18.48779,26.33301 17.93505,25.68067 17.93114,25.00489 L 17.91356,22.33448 C 17.90917,21.65626 18.45458,21.20362 19.13036,21.32276 L 19.87938,21.45557 C 20.55663,21.57422 21.1079,22.22608 21.1118,22.90625 L 21.12646,25.59375 z "
+       id="path2380" />
+    <path
+       d="M 28.68457,23.13477 L 28.04687,23.02247 C 27.46875,22.9209 27,23.31738 27.00195,23.9082 L 27.00976,26.2334 C 27.01171,26.82422 27.48242,27.3916 28.05956,27.5 L 28.69628,27.61914 C 29.27441,27.72852 29.74023,27.33301 29.73925,26.73828 L 29.73339,24.39453 C 29.73242,23.80078 29.26367,23.23633 28.68457,23.13477 z M 29.48047,26.4707 C 29.48145,26.95312 29.10449,27.27343 28.63477,27.18652 L 28.11719,27.08886 C 27.65039,27.00292 27.26758,26.54198 27.26563,26.06249 L 27.25977,24.17089 C 27.25879,23.69335 27.63868,23.37109 28.10645,23.45409 L 28.625,23.54589 C 29.0957,23.6289 29.47461,24.08788 29.47559,24.56835 L 29.48047,26.4707 z "
+       id="path2382" />
+    <polygon
+       points="15.91357,26.36426 15.12744,26.21777 15.08936,21.15137 15.87598,21.29004 15.91357,26.36426 "
+       id="polygon2384" />
+    <polygon
+       points="15.21777,22.12402 13.8667,21.88379 15.21045,21.19824 15.21777,22.12402 "
+       id="polygon2386" />
+    <polygon
+       points="24.64063,27.96387 23.85449,27.81738 23.81641,22.75098 24.60352,22.88965 24.64063,27.96387 "
+       id="polygon2388" />
+    <polygon
+       points="23.94434,23.72363 22.59375,23.48242 23.9375,22.79785 23.94434,23.72363 "
+       id="polygon2390" />
+    <polygon
+       points="32.44043,28.25 31.7959,28.12988 31.79004,23.80859 32.43555,23.92285 32.44043,28.25 "
+       id="polygon2392" />
+    <polygon
+       points="31.88867,24.6377 30.78223,24.44043 31.8877,23.84766 31.88867,24.6377 "
+       id="polygon2394" />
+    <polygon
+       points="35.36426,28.73633 34.71973,28.61523 34.71875,24.26465 35.36426,24.37793 35.36426,28.73633 "
+       id="polygon2396" />
+    <polygon
+       points="34.81641,25.09863 33.70996,24.90137 34.81641,24.30371 34.81641,25.09863 "
+       id="polygon2398" />
+    <path
+       d="M 20.7041,8.17773 L 20.0625,8.08886 C 19.48047,8.00878 19.0127,8.4121 19.01611,8.99072 L 19.03174,11.26806 C 19.03565,11.84667 19.50928,12.38574 20.08936,12.47314 L 20.72999,12.56933 C 21.31104,12.65673 21.77833,12.25488 21.77491,11.67236 L 21.76221,9.37793 C 21.75879,8.79492 21.28564,8.25781 20.7041,8.17773 z M 21.51514,11.41895 C 21.51758,11.89063 21.13868,12.21778 20.66748,12.14747 L 20.14697,12.06983 C 19.67627,11.99903 19.2915,11.56104 19.28857,11.0918 L 19.27636,9.24121 C 19.27343,8.77197 19.65331,8.44433 20.1245,8.50976 L 20.646,8.58252 C 21.11768,8.64844 21.50196,9.08496 21.50489,9.55713 L 21.51514,11.41895 z "
+       id="path2400" />
+    <path
+       d="M 24.59961,8.75439 L 23.95703,8.66601 C 23.37695,8.58544 22.90723,8.99365 22.91015,9.5791 L 22.92187,11.87988 C 22.9248,12.46484 23.39843,13.00927 23.97851,13.09619 L 24.61914,13.19287 C 25.20117,13.28027 25.66797,12.87353 25.66602,12.28467 L 25.65723,9.96631 C 25.65527,9.37744 25.18262,8.83496 24.59961,8.75439 z M 25.40625,12.02881 C 25.4082,12.50537 25.0293,12.83692 24.55664,12.76611 L 24.03516,12.68798 C 23.56641,12.61816 23.18164,12.17577 23.17969,11.70165 L 23.16992,9.83202 C 23.16699,9.35741 23.54883,9.02587 24.01953,9.0913 L 24.54101,9.16454 C 25.01464,9.22997 25.3955,9.67089 25.39746,10.14745 L 25.40625,12.02881 z "
+       id="path2402" />
+    <path
+       d="M 28.64648,9.25537 L 28.00586,9.1665 C 27.42383,9.08642 26.95313,9.5 26.95508,10.09082 L 26.96289,12.41748 C 26.96484,13.0083 27.43848,13.55762 28.01855,13.64502 L 28.65918,13.74121 C 29.24121,13.82861 29.70898,13.4165 29.70801,12.82178 L 29.70313,10.47852 C 29.70117,9.8833 29.23047,9.33594 28.64648,9.25537 z M 29.44824,12.56348 C 29.44922,13.04493 29.07031,13.38037 28.59765,13.30957 L 28.07617,13.23242 C 27.60644,13.16211 27.22265,12.71582 27.2207,12.23681 L 27.21484,10.34618 C 27.21289,9.86669 27.5957,9.53124 28.06543,9.59667 L 28.58789,9.66942 C 29.06152,9.73534 29.44141,10.17967 29.44238,10.6621 L 29.44824,12.56348 z "
+       id="path2404" />
+    <polygon
+       points="17.6748,11.98242 17.02686,11.88525 16.99512,7.73242 17.64453,7.82227 17.6748,11.98242 "
+       id="polygon2406" />
+    <polygon
+       points="17.10156,8.52637 15.98779,8.36963 17.0957,7.76709 17.10156,8.52637 "
+       id="polygon2408" />
+    <polygon
+       points="32.4248,14.23389 31.77637,14.13623 31.76953,9.81738 32.41992,9.90723 32.4248,14.23389 "
+       id="polygon2410" />
+    <polygon
+       points="31.87012,10.64258 30.75684,10.48584 31.86914,9.85303 31.87012,10.64258 "
+       id="polygon2412" />
+    <polygon
+       points="35.36426,14.61377 34.71582,14.5166 34.71484,10.16455 35.36426,10.25439 35.36426,14.61377 "
+       id="polygon2414" />
+    <polygon
+       points="34.81348,10.99561 33.7002,10.83887 34.81348,10.19971 34.81348,10.99561 "
+       id="polygon2416" />
+    <path
+       d="M 24.27832,14.48389 L 23.49707,14.36133 C 22.78906,14.25049 22.21875,14.73779 22.22266,15.45069 L 22.23682,18.25782 C 22.24024,18.97071 22.81641,19.64552 23.52051,19.76563 L 24.30078,19.89698 C 25.00683,20.0171 25.57617,19.53126 25.57422,18.81348 L 25.56348,15.98535 C 25.55957,15.26709 24.98535,14.59521 24.27832,14.48389 z M 25.25781,18.49561 C 25.25976,19.07764 24.79883,19.47217 24.22461,19.37598 L 23.59082,19.26856 C 23.02051,19.17286 22.55273,18.62501 22.54883,18.0459 L 22.53809,15.76563 C 22.53613,15.1875 23,14.79102 23.57227,14.88184 L 24.20606,14.98243 C 24.78126,15.07374 25.24708,15.61915 25.24805,16.20118 L 25.25781,18.49561 z "
+       id="path2418" />
+    <path
+       d="M 28.66602,16.29541 L 28.02637,16.19482 C 27.44629,16.104 26.97657,16.50878 26.97852,17.09961 L 26.98731,19.42627 C 26.98926,20.0166 27.45997,20.5752 28.04004,20.67334 L 28.67774,20.78125 C 29.25782,20.87939 29.72462,20.47607 29.72364,19.88135 L 29.71876,17.5376 C 29.7168,16.94287 29.24707,16.38672 28.66602,16.29541 z M 29.46484,19.61768 C 29.46582,20.09961 29.08789,20.42774 28.61621,20.34864 L 28.09668,20.26124 C 27.62891,20.18263 27.24609,19.72901 27.24414,19.24952 L 27.23828,17.35938 C 27.23633,16.88038 27.61719,16.55127 28.08594,16.62549 L 28.60645,16.70752 C 29.07813,16.78272 29.45899,17.23438 29.45997,17.7168 L 29.46484,19.61768 z "
+       id="path2420" />
+    <polygon
+       points="15.85449,18.26416 15.06592,18.13037 15.02881,13.06592 15.81787,13.19043 15.85449,18.26416 "
+       id="polygon2422" />
+    <polygon
+       points="15.15674,14.03613 13.80176,13.82031 15.1499,13.10986 15.15674,14.03613 "
+       id="polygon2424" />
+    <polygon
+       points="20.29785,20.33643 19.2832,20.16504 19.23535,13.64795 20.25049,13.80811 20.29785,20.33643 "
+       id="polygon2426" />
+    <polygon
+       points="19.3999,14.89648 17.65625,14.61865 19.39111,13.70459 19.3999,14.89648 "
+       id="polygon2428" />
+    <polygon
+       points="32.43262,21.34326 31.78613,21.23438 31.78027,16.91504 32.42773,17.01709 32.43262,21.34326 "
+       id="polygon2430" />
+    <polygon
+       points="31.87988,17.7417 30.76953,17.56494 31.87891,16.95215 31.87988,17.7417 "
+       id="polygon2432" />
+    <polygon
+       points="35.36426,21.77783 34.71777,21.66895 34.7168,17.31641 35.36426,17.41846 35.36426,21.77783 "
+       id="polygon2434" />
+    <polygon
+       points="34.81543,18.14941 33.70508,17.97217 34.81543,17.35352 34.81543,18.14941 "
+       id="polygon2436" />
+    <path
+       d="M 19.2666,10.71484 C 14.11426,10.71484 9.9375,14.8916 9.9375,20.04394 C 9.9375,25.19531 14.11426,29.37207 19.2666,29.37207 C 24.41797,29.37207 28.59375,25.19531 28.59375,20.04394 C 28.59375,14.8916 24.41797,10.71484 19.2666,10.71484 z M 19.22803,28.43945 C 14.56983,28.43945 10.79297,24.66308 10.79297,20.00537 C 10.79297,15.34717 14.56983,11.57031 19.22803,11.57031 C 23.88574,11.57031 27.66114,15.34717 27.66114,20.00537 C 27.66113,24.66309 23.88574,28.43945 19.22803,28.43945 z "
+       style="fill:#3b5375"
+       id="path2438" />
+    <path
+       d="M 19.22803,11.57031 C 14.56983,11.57031 10.79297,15.34717 10.79297,20.00537 C 10.79297,24.66308 14.56983,28.43945 19.22803,28.43945 C 23.88574,28.43945 27.66114,24.66308 27.66114,20.00537 C 27.66113,15.34717 23.88574,11.57031 19.22803,11.57031 z M 19.30566,27.66211 C 15.12011,27.66211 11.72607,24.26856 11.72607,20.08301 C 11.72607,15.89746 15.12011,12.50342 19.30566,12.50342 C 23.49121,12.50342 26.88379,15.89746 26.88379,20.08301 C 26.88379,24.26856 23.49121,27.66211 19.30566,27.66211 z "
+       style="fill:#f8f1df"
+       id="path2440" />
+    <circle
+       cx="19.30566"
+       cy="20.08276"
+       r="7.57935"
+       style="opacity:0.35;fill:url(#XMLID_12_)"
+       id="circle2447" />
+  </g>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpy.hrh	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,246 @@
+/*
+* 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 MEMSPY_HRH
+#define MEMSPY_HRH
+
+#define KMemSpyMenuCommandBase 50000
+#define KMemSpyMenuCommandViewSpecific (KMemSpyMenuCommandBase + 10000)
+
+enum TMemSpyCommandIds
+    {
+	////////////////////////////////
+	// GENERIC MENU COMMANDS
+	////////////////////////////////
+	EMemSpyCmdOpen = KMemSpyMenuCommandBase,
+    //
+    EMemSpyCmdView,
+	EMemSpyCmdViewRefresh,
+	EMemSpyCmdViewOutputToSink,
+    //
+    EMemSpyCmdTools,
+    EMemSpyCmdToolsListOpenFiles,
+	EMemSpyCmdToolsAbout,
+    //
+    EMemSpyCmdPhoneInfo,
+	EMemSpyCmdPhoneInfoGeneral,
+    EMemSpyCmdPhoneInfoGeneralSummary,
+	EMemSpyCmdPhoneInfoGeneralDetailed,
+	EMemSpyCmdPhoneInfoGeneralHandles,
+	EMemSpyCmdPhoneInfoGeneralKernelContainers,
+	EMemSpyCmdPhoneInfoHeap,
+	EMemSpyCmdPhoneInfoHeapInfoSummary,
+    EMemSpyCmdPhoneInfoHeapInfoCompact,
+	EMemSpyCmdPhoneInfoHeapCellListing,
+	EMemSpyCmdPhoneInfoHeapDump,
+    EMemSpyCmdPhoneInfoStack,
+	EMemSpyCmdPhoneInfoStackInfo,
+    EMemSpyCmdPhoneInfoStackInfoCompact,
+	EMemSpyCmdPhoneInfoStackDumpUser,
+	EMemSpyCmdPhoneInfoStackDumpKernel,
+    //
+    EMemSpyCmdAutoCapture,
+    EMemSpyCmdAutoCaptureToggle,
+    EMemSpyCmdAutoCaptureRetryTime,
+    EMemSpyCmdAutoCaptureOperationType,
+	
+	////////////////////////////////
+	// VIEW SPECIFIC MENU COMMANDS
+	////////////////////////////////
+    EMemSpyCmdProcess = KMemSpyMenuCommandViewSpecific,
+	EMemSpyCmdProcessInfo,
+	EMemSpyCmdProcessInfoSummary,
+	EMemSpyCmdProcessInfoHandles,
+    EMemSpyCmdProcessSort,
+    EMemSpyCmdProcessSortById,
+    EMemSpyCmdProcessSortByName,
+    EMemSpyCmdProcessSortByThreadCount,
+    EMemSpyCmdProcessSortByCodeSegs,
+    EMemSpyCmdProcessSortByHeapUsage,
+    EMemSpyCmdProcessSortByStackUsage,
+    EMemSpyCmdProcessEnd,
+    EMemSpyCmdProcessEndKill,
+    EMemSpyCmdProcessEndPanic,
+    EMemSpyCmdProcessEndTerminate,
+    //
+    EMemSpyCmdThread,
+    EMemSpyCmdThreadEnd,
+    EMemSpyCmdThreadEndKill,
+    EMemSpyCmdThreadEndPanic,
+    EMemSpyCmdThreadEndTerminate,
+    EMemSpyCmdThreadSetPriority,
+	EMemSpyCmdThreadSetPriorityAbsoluteVeryLow,
+	EMemSpyCmdThreadSetPriorityAbsoluteLowNormal,
+	EMemSpyCmdThreadSetPriorityAbsoluteLow,
+	EMemSpyCmdThreadSetPriorityAbsoluteBackgroundNormal,
+	EMemSpyCmdThreadSetPriorityAbsoluteBackground,
+	EMemSpyCmdThreadSetPriorityAbsoluteForegroundNormal,
+	EMemSpyCmdThreadSetPriorityAbsoluteForeground,
+	EMemSpyCmdThreadSetPriorityAbsoluteHighNormal,
+	EMemSpyCmdThreadSetPriorityAbsoluteHigh,
+	EMemSpyCmdThreadSetPriorityAbsoluteRealTime1,
+	EMemSpyCmdThreadSetPriorityAbsoluteRealTime2,
+	EMemSpyCmdThreadSetPriorityAbsoluteRealTime3,
+	EMemSpyCmdThreadSetPriorityAbsoluteRealTime4,
+	EMemSpyCmdThreadSetPriorityAbsoluteRealTime5,
+	EMemSpyCmdThreadSetPriorityAbsoluteRealTime6,
+	EMemSpyCmdThreadSetPriorityAbsoluteRealTime7, 
+	EMemSpyCmdThreadSetPriorityAbsoluteRealTime8,
+	EMemSpyCmdThreadInfo,
+	EMemSpyCmdThreadInfoHandles,
+    //
+    EMemSpyCmdOutput,
+    EMemSpyCmdOutputToDebug,
+    EMemSpyCmdOutputToFile,
+    //
+    EMemSpyCmdHeap,
+    EMemSpyCmdHeapInfoThread,
+    EMemSpyCmdHeapData,
+    EMemSpyCmdHeapCellListing,
+    EMemSpyCmdHeapDataDump,
+    //
+    EMemSpyCmdStack,
+    EMemSpyCmdStackInfoThread,
+    EMemSpyCmdStackData,
+    EMemSpyCmdStackDataUser,
+    EMemSpyCmdStackDataKernel,
+    //
+    EMemSpyCmdChunk,
+    EMemSpyCmdChunkSort,
+    EMemSpyCmdChunkSortByName,
+    EMemSpyCmdChunkSortBySize,
+    EMemSpyCmdChunkListing,
+    //
+    EMemSpyCmdCodeSeg,
+    EMemSpyCmdCodeSegShow,
+    EMemSpyCmdCodeSegShowItemsAll,
+    EMemSpyCmdCodeSegShowItemsGlobalData,
+    EMemSpyCmdCodeSegShowCaps,
+    EMemSpyCmdCodeSegShowCapsWithTCBProcess,              
+    EMemSpyCmdCodeSegShowCapsWithTCBAll,                  
+    EMemSpyCmdCodeSegShowCapsWithCommDDProcess,           
+    EMemSpyCmdCodeSegShowCapsWithCommDDAll,               
+    EMemSpyCmdCodeSegShowCapsWithPowerMgmtProcess,        
+    EMemSpyCmdCodeSegShowCapsWithPowerMgmtAll,            
+    EMemSpyCmdCodeSegShowCapsWithMultimediaDDProcess,     
+    EMemSpyCmdCodeSegShowCapsWithMultimediaDDAll,         
+    EMemSpyCmdCodeSegShowCapsWithReadDeviceDataProcess,   
+    EMemSpyCmdCodeSegShowCapsWithReadDeviceDataAll,       
+    EMemSpyCmdCodeSegShowCapsWithWriteDeviceDataProcess,  
+    EMemSpyCmdCodeSegShowCapsWithWriteDeviceDataAll,      
+    EMemSpyCmdCodeSegShowCapsWithDRMProcess,              
+    EMemSpyCmdCodeSegShowCapsWithDRMAll,                  
+    EMemSpyCmdCodeSegShowCapsWithTrustedUIProcess,        
+    EMemSpyCmdCodeSegShowCapsWithTrustedUIAll,            
+    EMemSpyCmdCodeSegShowCapsWithProtServProcess,         
+    EMemSpyCmdCodeSegShowCapsWithProtServAll,             
+    EMemSpyCmdCodeSegShowCapsWithDiskAdminProcess,        
+    EMemSpyCmdCodeSegShowCapsWithDiskAdminAll,            
+    EMemSpyCmdCodeSegShowCapsWithNetworkControlProcess,   
+    EMemSpyCmdCodeSegShowCapsWithNetworkControlAll,       
+    EMemSpyCmdCodeSegShowCapsWithAllFilesProcess,         
+    EMemSpyCmdCodeSegShowCapsWithAllFilesAll,             
+    EMemSpyCmdCodeSegShowCapsWithSwEventProcess,          
+    EMemSpyCmdCodeSegShowCapsWithSwEventAll,              
+    EMemSpyCmdCodeSegShowCapsWithNetworkServicesProcess,  
+    EMemSpyCmdCodeSegShowCapsWithNetworkServicesAll,      
+    EMemSpyCmdCodeSegShowCapsWithLocalServicesProcess,    
+    EMemSpyCmdCodeSegShowCapsWithLocalServicesAll,        
+    EMemSpyCmdCodeSegShowCapsWithReadUserDataProcess,     
+    EMemSpyCmdCodeSegShowCapsWithReadUserDataAll,         
+    EMemSpyCmdCodeSegShowCapsWithWriteUserDataProcess,    
+    EMemSpyCmdCodeSegShowCapsWithWriteUserDataAll,        
+    EMemSpyCmdCodeSegShowCapsWithLocationProcess,         
+    EMemSpyCmdCodeSegShowCapsWithLocationAll,             
+    EMemSpyCmdCodeSegShowCapsWithSurroundingsDDProcess,   
+    EMemSpyCmdCodeSegShowCapsWithSurroundingsDDAll,       
+    EMemSpyCmdCodeSegShowCapsWithUserEnvProcess,          
+    EMemSpyCmdCodeSegShowCapsWithUserEnvAll,              
+    EMemSpyCmdCodeSegSort,
+    EMemSpyCmdCodeSegSortByName,
+    EMemSpyCmdCodeSegSortByCodeSize,
+    EMemSpyCmdCodeSegSortByDataSize,
+    EMemSpyCmdCodeSegSortByUid,
+    EMemSpyCmdCodeSegListing,
+    //
+    EMemSpyCmdImages,
+    EMemSpyCmdImagesSlideshow,
+    EMemSpyCmdImagesSaveAllToMemoryCard,
+    EMemSpyCmdImagesListing,
+    //
+    EMemSpyCmdActiveObject,
+    EMemSpyCmdActiveObjectListing,
+    //
+    EMemSpyCmdServerList,
+    EMemSpyCmdServerListOutput,
+    EMemSpyCmdServerListOutputListCSV,
+    EMemSpyCmdServerListOutputListDetailed,
+    EMemSpyCmdServerListSort,
+    EMemSpyCmdServerListSortByName,
+    EMemSpyCmdServerListSortBySessionCount,
+    //
+    EMemSpyCmdKernelContainers,
+    EMemSpyCmdKernelContainersOutput,
+    EMemSpyCmdKernelObjects,
+    EMemSpyCmdKernelObjectTerminate,
+    EMemSpyCmdKernelObjectSwitchTo,
+    EMemSpyCmdKernelObjectEnd,
+    EMemSpyCmdKernelObjectPanic,
+    
+    //
+    EMemSpyCmdKernelHeap,
+    EMemSpyCmdKernelHeapDump,
+    //
+    EMemSpyCmdRAM,
+    EMemSpyCmdRAMAvkonIconCacheDisabled,
+    EMemSpyCmdRAMAvkonIconCacheEnabled,
+    //
+    EMemSpyCmdBTrace,
+    EMemSpyCmdBTraceCaptureToggle,
+    //
+    EMemSpyCmdMemoryTracking,
+    EMemSpyCmdMemoryTrackingStart,
+    EMemSpyCmdMemoryTrackingStop,
+    EMemSpyCmdMemoryTrackingAutoStart,
+    EMemSpyCmdMemoryTrackingAutoStartItemAdd,
+    EMemSpyCmdMemoryTrackingAutoStartItemEdit,
+    EMemSpyCmdMemoryTrackingAutoStartItemDelete,
+    EMemSpyCmdMemoryTrackingAutoStartItemDeleteAll,
+    EMemSpyCmdMemoryTrackingAutoStartItemImport,
+    EMemSpyCmdMemoryTrackingHWM,
+    EMemSpyCmdMemoryTrackingHWMReset,
+    EMemSpyCmdMemoryTrackingTotalWithSharedMem,
+    EMemSpyCmdMemoryTrackingTotalWithoutSharedMem,
+
+    //
+    EMemSpyCmdWindowGroups,
+    EMemSpyCmdWindowGroupTerminate,
+    EMemSpyCmdWindowGroupSwitchTo,
+    EMemSpyCmdWindowGroupEnd,
+    EMemSpyCmdWindowGroupPanic
+    };
+
+enum TMemSpyControlIds
+    {
+    EMemSpyCtrlIdProgressNote = 1000,
+    EMemSpyCtrlIdSlideShowImage,
+    EMemSpyCtrlIdWaitNote
+    };
+
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyApp.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,37 @@
+/*
+* 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 MEMSPYAPP_H
+#define MEMSPYAPP_H
+
+// System includes
+#include <aknapp.h>
+
+// Constants
+const TUid KUidMemSpy = { 0x2002129F };
+
+
+class CMemSpyApp : public CAknApplication
+    {
+private: // From CApaApplication
+    CApaDocument* CreateDocumentL();
+    TUid AppDllUid() const;
+    };
+
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyAppUi.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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 MEMSPYAPPUI_H
+#define MEMSPYAPPUI_H
+
+// System includes
+#include <eikapp.h>
+#include <eikdoc.h>
+#include <e32std.h>
+#include <coeccntx.h>
+#include <aknappui.h>
+#include <coecobs.h>
+
+// User includes
+#include "MemSpyDeviceWideOperationDialog.h"
+#include "MemSpyContainerObserver.h"
+#include <memspy/engine/memspyengineobserver.h>
+
+// Classes referenced
+class CEikMenuBar;
+class CMemSpyEngine;
+class CMemSpyContainer;
+class CMemSpyDocument;
+
+
+class CMemSpyAppUi : public CAknAppUi, public MMemSpyContainerObserver, public MCoeControlObserver, public MMemSpyEngineObserver, public MMemSpyDeviceWideOperationDialogObserver
+    {
+public:
+    CMemSpyAppUi( CMemSpyEngine& aEngine );
+    ~CMemSpyAppUi();
+    void ConstructL();
+
+public: // API
+    CMemSpyDocument& MemSpyDocument();
+    const CMemSpyDocument& MemSpyDocument() const;
+    inline CMemSpyContainer& Container() { return *iAppContainer; }
+
+private: // From Avkon
+    void HandleStatusPaneSizeChange();
+
+private: // From MCoeControlObserver
+    void HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType);
+
+private: // From MEikMenuObserver
+    void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
+
+private: // From CEikAppUi
+	void HandleForegroundEventL(TBool aForeground);
+    void HandleCommandL(TInt aCommand);
+    TKeyResponse HandleKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
+
+private: // From MMemSpyContainerObserver
+    void HandleThreadSelectedL( const CMemSpyThread& aThread );
+
+private: // From MMemSpyEngineObserver
+    void HandleMemSpyEngineEventL( MMemSpyEngineObserver::TEvent aEvent, TAny* aContext );
+
+private: // From MMemSpyDeviceWideOperationDialogObserver
+    void DWOperationStarted();
+    void DWOperationCancelled();
+    void DWOperationCompleted();
+
+private: // Internal methods
+    void UpdateCBAL();
+    void InitiateMemSpyClientServerOperationL( TInt aOpCode );
+    void SetViewServerTimeOutStatus( TBool aEnabled );
+    
+private: // Command handlers
+    void OnCmdBackL();
+    void OnCmdExitL();
+    void OnCmdOpenL();
+    void OnCmdAboutL();
+
+    // Output
+    void OnCmdOutputToDebugL();
+    void OnCmdOutputToFileL();
+ 
+    // Phone-information
+    void OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::TOperation aOp );
+    void OnCmdPhoneInformationOperationKernelContainersL();
+    
+    // Automatic capture
+    void OnCmdAutoCaptureToggleL();
+    void OnCmdAutoCaptureRetryTimeL();
+    void OnCmdAutoCaptureOperationTypeL();
+
+    // Misc
+    void OnCmdToolsBitmapsSaveToMemoryCardL();
+    void OnCmdToolsSendToBackgroundL();
+    void OnCmdToolsBringToForegroundL();
+
+private: // Auto capture related
+    static TInt AutoCaptureCallBack( TAny* aSelf );
+    void AutoCaptureCallBackL();
+
+private: // Member data
+    CMemSpyEngine& iEngine;
+    CMemSpyContainer* iAppContainer;
+    
+    // For phone information dialog
+    TBool iRunningDeviceWideOperation;
+    
+    // For auto-capture
+    TInt iAutoCaptureTimerPeriod;
+    CMemSpyDeviceWideOperations::TOperation iAutoCaptureOperationType;
+    CPeriodic* iAutoCaptureTimer;
+    };
+
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyContainer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,79 @@
+/*
+* 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 MEMSPYCONTAINER_H
+#define MEMSPYCONTAINER_H
+
+// System includes
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// User includes
+#include "MemSpyViewBase.h"
+#include "MemSpyViewObserver.h"
+
+// Classes referenced
+class CMemSpyEngine;
+class CMemSpyProcess;
+class CMemSpyThread;
+class CMemSpyThreadInfoItemBase;
+class CMemSpyEngineObjectContainer;
+class MMemSpyContainerObserver;
+
+
+class CMemSpyContainer : public CCoeControl, public MMemSpyViewObserver
+    {
+public:
+    CMemSpyContainer( CMemSpyEngine& aEngine, MMemSpyContainerObserver& aObserver );
+    ~CMemSpyContainer();
+    void ConstructL( const TRect& aRect );
+
+public: // API
+    inline TMemSpyViewType ActiveViewType() const { return iActiveView->ViewType(); }
+    inline CMemSpyViewBase& ActiveView() const { return *iActiveView; }
+
+public: // API
+    void NavigateToParentViewL();
+    void NavigateToChildViewL();
+    void HandleCommandL( TInt aCommand );
+    void SetNewActiveViewL( CMemSpyViewBase* aNewView );
+
+public: // Command handlers
+    void OnCmdViewRefreshL();
+
+private: // From CCoeControl
+    void SizeChanged();
+    TInt CountComponentControls() const;
+    CCoeControl* ComponentControl(TInt aIndex) const;
+    void Draw(const TRect& aRect) const;
+	TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
+
+private: // From MMemSpyViewObserver
+    void HandleMemSpyViewEventL( TViewEventType aEvent, TMemSpyViewType aViewType, CMemSpyViewBase& aReportingView, TAny* aContext );
+
+private: // Internal methods
+    CMemSpyViewBase* PrepareTopLevelViewL();
+
+private: // Member data
+    CMemSpyEngine& iEngine;
+    MMemSpyContainerObserver& iObserver;
+    CMemSpyViewBase* iActiveView;
+    CMemSpyViewBase* iPreviousView;
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyContainerObserver.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,32 @@
+/*
+* 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 MEMSPYCONTAINEROBSERVER_H
+#define MEMSPYCONTAINEROBSERVER_H
+
+// Classes referenced
+class CMemSpyThread;
+
+
+class MMemSpyContainerObserver
+    {
+public:
+    virtual void HandleThreadSelectedL( const CMemSpyThread& aThread ) = 0;
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyDeviceWideOperationDialog.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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 MEMSPYDEVICEWIDEOPERATIONDIALOG_H
+#define MEMSPYDEVICEWIDEOPERATIONDIALOG_H
+
+// System includes
+#include <AknProgressDialog.h>
+#include <AknWaitDialog.h>
+
+// Engine includes
+#include <memspy/engine/memspydevicewideoperations.h>
+
+// Classes referenced
+class CMemSpyEngine;
+
+class MMemSpyDeviceWideOperationDialogObserver
+    {
+public:
+    virtual void DWOperationStarted() = 0;
+    virtual void DWOperationCancelled() = 0;
+    virtual void DWOperationCompleted() = 0;
+    };
+
+
+class CMemSpyDeviceWideOperationDialog : public CBase, public MProgressDialogCallback, public MMemSpyDeviceWideOperationsObserver
+    {
+public:
+    static void ExecuteLD( CMemSpyEngine& aEngine, MMemSpyDeviceWideOperationDialogObserver& aObserver, CMemSpyDeviceWideOperations::TOperation aOperation );
+    ~CMemSpyDeviceWideOperationDialog();
+
+private:
+    CMemSpyDeviceWideOperationDialog( CMemSpyEngine& aEngine, MMemSpyDeviceWideOperationDialogObserver& aObserver );
+    void ExecuteL( CMemSpyDeviceWideOperations::TOperation aOperation );
+
+public: // API
+    void Cancel();
+
+private: // From MProgressDialogCallback
+    void DialogDismissedL( TInt aButtonId );
+
+private: // From MMemSpyDeviceWideOperationsObserver
+    void HandleDeviceWideOperationEvent( TEvent aEvent, TInt aParam1, const TDesC& aParam2 );
+
+private: // Internal methods
+    void SetDialogCaptionL( const TDesC& aText );
+
+private: // Member data
+    CMemSpyEngine& iEngine;
+    MMemSpyDeviceWideOperationDialogObserver& iObserver;
+    TBool iForcedCancel;
+    CEikProgressInfo* iProgressInfo;
+    CAknProgressDialog* iProgressDialog;
+    CMemSpyDeviceWideOperations* iOperation;
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyDocument.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,55 @@
+/*
+* 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 MEMSPYDOCUMENT_H
+#define MEMSPYDOCUMENT_H
+
+// System includes
+#include <AknDoc.h>
+   
+// Classes referenced
+class CMemSpyEngine;
+class CEikAppUi;
+class CMemSpySettings;
+
+
+class CMemSpyDocument : public CAknDocument
+    {
+public: // Constructors and destructor
+    static CMemSpyDocument* NewL(CEikApplication& aApp);
+    ~CMemSpyDocument();
+
+private:
+    CMemSpyDocument(CEikApplication& aApp);
+    void ConstructL();
+
+public:
+    CMemSpyEngine& Engine();
+    const CMemSpyEngine& Engine() const;
+    CMemSpySettings& Settings();
+    const CMemSpySettings& Settings() const;
+
+private: // Framework
+    CEikAppUi* CreateAppUiL();
+
+private: // Data members
+    CMemSpyEngine* iEngine;
+    CMemSpySettings* iSettings;
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyExportBitmapsToMemoryCardDialog.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,76 @@
+/*
+* 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 MEMSPYEXPORTBITMAPSTOMEMORYCARDDIALOG_H
+#define MEMSPYEXPORTBITMAPSTOMEMORYCARDDIALOG_H
+
+// System includes
+#include <AknProgressDialog.h>
+#include <AknWaitDialog.h>
+#include <imageconversion.h>
+
+// Classes referenced
+class CMemSpyEngineFbServBitmap;
+class CMemSpyEngineFbServBitmapArray;
+
+
+
+class CMemSpyExportBitmapsToMemoryCardDialog : public CActive, public MProgressDialogCallback
+    {
+public:
+    static CMemSpyExportBitmapsToMemoryCardDialog* NewL( RFs& aFsSession, const CMemSpyEngineFbServBitmapArray& aBitmaps );
+    ~CMemSpyExportBitmapsToMemoryCardDialog();
+
+private:
+    CMemSpyExportBitmapsToMemoryCardDialog( RFs& aFsSession, const CMemSpyEngineFbServBitmapArray& aBitmaps );
+    void ConstructL();
+
+public: // API
+    void Cancel();
+    static TBool CheckMemoryCardAvailableL( RFs& aFsSession );
+
+private: // From CActive
+    void RunL();
+    void DoCancel();
+    TInt RunError(TInt aError);
+
+private: // From MProgressDialogCallback
+    void DialogDismissedL( TInt aButtonId );
+
+private: // Internal methods
+    void CompleteSelf( TInt aError );
+    void ExportBitmapL( const CMemSpyEngineFbServBitmap& aBitmap );
+    void IdentifyBmpMimeTypeL();
+    void PruneExistingBitmapFilesL();
+    void PrepareFolderNameSpecL();
+    TBool TryToExportSingleBitmapL();
+
+private: // Member data
+    RFs& iFsSession;
+    const CMemSpyEngineFbServBitmapArray& iBitmaps;
+    TInt iBitmapIndex;
+    TBool iDialogDismissed;
+    CEikProgressInfo* iProgressInfo;
+    CAknProgressDialog* iProgressDialog;
+    CImageEncoder* iEncoder;
+    HBufC8* iBmpMimeType;
+    HBufC* iFolderName;
+    RFileExtensionMIMETypeArray iMimeTypeArray;
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpySettings.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,59 @@
+/*
+* 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 MEMSPYSETTINGS_H
+#define MEMSPYSETTINGS_H
+
+// System includes
+#include <e32base.h>
+#include <badesca.h>
+#include <f32file.h>
+
+// Engine includes
+#include <memspy/engine/memspyengineoutputsink.h>
+
+// Classes referenced
+class CMemSpyEngine;
+
+
+class CMemSpySettings : public CBase
+    {
+public:
+    static CMemSpySettings* NewL( RFs& aFsSession, CMemSpyEngine& aEngine );
+    ~CMemSpySettings();
+
+private:
+    CMemSpySettings( RFs& aFsSession, CMemSpyEngine& aEngine );
+    void ConstructL();
+
+public: // API
+    inline RFs& FsSession() { return iFsSession; }
+    void StoreSettingsL();
+
+private: // Settings methods
+    void RestoreSettingsL();
+    void GetSettingsFileNameL( TDes& aFileName );
+    void GetSettingsPathL( TDes& aPath );
+    RFile SettingsFileLC( TBool aReplace = EFalse );
+
+private: // Data members
+    RFs& iFsSession;
+    CMemSpyEngine& iEngine;
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyUiUtils.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,38 @@
+/*
+* 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 MEMSPYUIUTILS_H
+#define MEMSPYUIUTILS_H
+
+// System includes
+#include <e32std.h>
+
+// Engine includes
+#include <memspy/engine/memspyengineutils.h>
+
+
+class MemSpyUiUtils : public MemSpyEngineUtils
+    {
+public:
+    static void Format( TDes& aBuf, TInt aResourceId, ...);
+    static void GetErrorText( TDes& aBuf, TInt aError );
+    };
+
+
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewBase.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,106 @@
+/*
+* 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 MEMSPYVIEWBASE_H
+#define MEMSPYVIEWBASE_H
+
+// System includes
+#include <coecntrl.h>
+#include <aknlists.h>
+#include <memspyui.rsg>
+
+// User includes
+#include "MemSpy.hrh"
+#include "MemSpyViewType.h"
+#include "MemSpyViewObserver.h"
+#include "MemSpySettings.h"
+
+// Classes referenced
+class CMemSpyEngine;
+class CMemSpyContainer;
+class MMemSpyViewObserver;
+
+
+class CMemSpyViewBase : public CCoeControl, public MCoeControlObserver, public MEikListBoxObserver
+    {
+public:
+    CMemSpyViewBase( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver );
+    ~CMemSpyViewBase();
+    virtual void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // API
+    virtual TMemSpyViewType ViewType() const = 0;
+    virtual CMemSpyViewBase* PrepareParentViewL();
+    virtual CMemSpyViewBase* PrepareChildViewL();
+    virtual void RefreshL();
+    virtual TBool HandleCommandL( TInt aCommand );
+
+public: // Menu framework
+    virtual void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
+    virtual TUint MenuCascadeResourceId() const;
+    virtual TInt MenuCascadeCommandId() const;
+
+private: // Command handlers
+    virtual void OnCmdViewOutputToSinkL();
+
+protected: // Construction support
+    void SetTitleL( const TDesC& aText );
+    TPtrC TitleL() const;
+    virtual CEikListBox* ConstructListBoxL();
+    virtual void SetListBoxModelL() = 0;
+
+protected: // Internal framework
+    virtual void HandleListBoxItemActionedL( TInt aIndex );
+    virtual void HandleListBoxItemSelectedL( TInt aIndex );
+ 
+protected: // Event reporting
+    void ReportEventL( MMemSpyViewObserver::TViewEventType aEvent, TAny* aContext = NULL );
+    void SetListBoxCurrentItemIndexL( TInt aIndex );
+
+protected: // Utility methods
+    CMemSpyContainer& Container();
+    CMemSpySettings& Settings();
+    const CMemSpySettings& Settings() const;
+
+public: // From CCoeControl
+	TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
+
+protected: // From CCoeControl
+    void Draw( const TRect& aRect ) const;
+    void SizeChanged();
+    void FocusChanged( TDrawNow aDrawNow );
+    TInt CountComponentControls() const;
+    CCoeControl* ComponentControl( TInt aIndex ) const;
+
+protected: // From MCoeControlObserver
+    void HandleControlEventL( CCoeControl* aControl,TCoeEvent aEventType );
+
+protected: // From MEikListBoxObserver
+    void HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType);
+
+protected: // Member data
+    CMemSpyEngine& iEngine;
+    MMemSpyViewObserver& iObserver;
+    //
+    CEikListBox* iListBox;
+
+private:
+    CMemSpySettings* iSettings;
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewChunkList.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,101 @@
+/*
+* 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 MEMSPYVIEWCHUNKLIST_H
+#define MEMSPYVIEWCHUNKLIST_H
+
+// System includes
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// User includes
+#include "MemSpyViewBase.h"
+
+// Classes referenced
+class CMemSpyEngineChunkList;
+class CMemSpyEngineChunkEntry;
+
+
+
+
+class CMemSpyViewChunkBase : public CMemSpyViewBase
+    {
+public:
+    CMemSpyViewChunkBase( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineChunkList* aList );
+    ~CMemSpyViewChunkBase();
+
+public: // From CMemSpyViewBase
+    TBool HandleCommandL( TInt aCommand );
+
+public: // Menu framework
+    TUint MenuCascadeResourceId() const { return R_MEMSPY_MENUPANE_CHUNK_LIST; }
+    TInt MenuCascadeCommandId() const { return EMemSpyCmdChunk; }
+
+protected: // Command handlers
+    void OnCmdListingL();
+
+protected: // Data members
+    CMemSpyEngineChunkList* iList;
+    };
+
+
+
+
+class CMemSpyViewChunkList : public CMemSpyViewChunkBase
+    {
+public:
+    CMemSpyViewChunkList( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver );
+    CMemSpyViewChunkList( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineChunkList& aList );
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    CMemSpyViewBase* PrepareChildViewL();
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+    void HandleListBoxItemActionedL( TInt aIndex );
+    void HandleListBoxItemSelectedL( TInt aIndex );
+
+private: // Data members
+    CMemSpyEngineChunkEntry* iCurrentChunk;
+    };
+
+
+
+class CMemSpyViewChunkDetails : public CMemSpyViewChunkBase
+    {
+public:
+    CMemSpyViewChunkDetails( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineChunkList& aList, CMemSpyEngineChunkEntry& aSelectedChunk );
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+
+private: // Data members
+    CMemSpyEngineChunkEntry& iChunk;
+    };
+
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewCodeSegList.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,125 @@
+/*
+* 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 MEMSPYVIEWCODESEGLIST_H
+#define MEMSPYVIEWCODESEGLIST_H
+
+// System includes
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// User includes
+#include "MemSpyViewBase.h"
+
+// Classes referenced
+class CMemSpyEngineCodeSegList;
+class CMemSpyEngineCodeSegEntry;
+
+
+class CMemSpyViewCodeSegBase : public CMemSpyViewBase
+    {
+public:
+    CMemSpyViewCodeSegBase( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineCodeSegList* aList );
+    ~CMemSpyViewCodeSegBase();
+
+public: // From CMemSpyViewBase
+    TBool HandleCommandL( TInt aCommand );
+    void RefreshL();
+
+public: // Menu framework
+    TUint MenuCascadeResourceId() const { return R_MEMSPY_MENUPANE_CODESEG_LIST; }
+    TInt MenuCascadeCommandId() const { return EMemSpyCmdCodeSeg; }
+
+protected: // Command handlers
+    void OnCmdCodeSegmentListingL();
+    void OnCmdShowItemsAllL();
+    void OnCmdShowItemsGlobalDataL();
+    void OnCmdFilterByCapabilityL( TCapability aCapability, TBool aAllBinaries );
+
+protected: // Data members
+    CMemSpyEngineCodeSegList* iList;
+    };
+
+
+
+
+class CMemSpyViewCodeSegList : public CMemSpyViewCodeSegBase
+    {
+public:
+    CMemSpyViewCodeSegList( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver );
+    CMemSpyViewCodeSegList( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineCodeSegList& aList );
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    CMemSpyViewBase* PrepareChildViewL();
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+    void HandleListBoxItemActionedL( TInt aIndex );
+    void HandleListBoxItemSelectedL( TInt aIndex );
+
+private: // Data members
+    CMemSpyEngineCodeSegEntry* iCurrentCodeSegment;
+    };
+
+
+
+class CMemSpyViewCodeSegDetails : public CMemSpyViewCodeSegBase
+    {
+public:
+    CMemSpyViewCodeSegDetails( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineCodeSegList& aList, CMemSpyEngineCodeSegEntry& aSelectedCodeSegment );
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+
+private: // Data members
+    CMemSpyEngineCodeSegEntry& iCodeSegment;
+    };
+
+
+
+
+
+
+class TMemSpyViewCodeSegFilter
+    {
+public:
+    inline TMemSpyViewCodeSegFilter( TCapability aCapability, TBool aAllBinaries = ETrue )
+    :   iCapability( aCapability ), iAllBinaries( aAllBinaries )
+        {
+        }
+
+public:
+    static TBool FilterItem( const CMemSpyEngineCodeSegEntry*& aItem, TAny* aRune );
+
+private:
+    TCapability iCapability;
+    TBool iAllBinaries;
+    };
+
+
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewDriveInfo.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,106 @@
+/*
+* 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 MEMSPYVIEWDRIVEINFO_H
+#define MEMSPYVIEWDRIVEINFO_H
+
+// System includes
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// Engine includes
+#include <memspy/engine/memspyenginehelperfilesystem.h>
+
+// User includes
+#include "MemSpyViewBase.h"
+
+// Classes referenced
+
+
+
+
+class CMemSpyViewDriveInfoBase : public CMemSpyViewBase
+    {
+public:
+    CMemSpyViewDriveInfoBase( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver );
+    ~CMemSpyViewDriveInfoBase();
+    void BaseConstructL();
+
+public: // From CMemSpyViewBase
+    TBool HandleCommandL( TInt aCommand );
+
+protected: // Data members
+    CMemSpyEngineDriveList* iList;
+    };
+
+
+
+
+class CMemSpyViewDriveList : public CMemSpyViewDriveInfoBase, public MMemSpyEngineDriveListObserver
+    {
+public:
+    CMemSpyViewDriveList( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver );
+    CMemSpyViewDriveList( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, TDriveNumber aDriveNumber );
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    CMemSpyViewBase* PrepareChildViewL();
+
+private: // From CMemSpyViewBase
+    void RefreshL();
+    void SetListBoxModelL();
+    void HandleListBoxItemActionedL( TInt aIndex );
+    void HandleListBoxItemSelectedL( TInt aIndex );
+
+private: // From MMemSpyEngineDriveListObserver
+    void HandleDriveListChangedL( const CMemSpyEngineDriveList& aList );
+
+private: // Data members
+    TBool iUseDriveNumber;
+    TDriveNumber iDriveNumber;
+    CMemSpyEngineDriveEntry* iCurrentDrive;
+    };
+
+
+
+class CMemSpyViewDriveInfo : public CMemSpyViewDriveInfoBase, public MMemSpyEngineDriveEntryObserver
+    {
+public:
+    CMemSpyViewDriveInfo( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, TDriveNumber aDriveNumber );
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+
+private: // From MMemSpyEngineDriveEntryObserver
+    void HandleDriveEntryChangedL( const CMemSpyEngineDriveEntry& aEntry );
+
+private: // Data members
+    const TDriveNumber iDriveNumber;
+    CMemSpyEngineDriveEntry* iDriveInfo;
+    };
+
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewECom.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,131 @@
+/*
+* 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 MEMSPYVIEWECOM_H
+#define MEMSPYVIEWECOM_H
+
+// System includes
+#include <coecntrl.h>
+#include <aknlists.h>
+#include <eikimage.h>
+#include <AknDialog.h>
+
+// User includes
+#include "MemSpyViewBase.h"
+
+// Engine includes
+#include <memspy/engine/memspyenginehelperecom.h>
+
+
+class CMemSpyViewECom : public CMemSpyViewBase
+    {
+public:
+    CMemSpyViewECom( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver );
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    CMemSpyViewBase* PrepareChildViewL();
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+    void HandleListBoxItemActionedL( TInt aIndex );
+    void HandleListBoxItemSelectedL( TInt aIndex );
+
+private: // Data members
+    CMemSpyEngineEComCategory* iCurrent;
+    };
+
+
+
+class CMemSpyViewEComCategory : public CMemSpyViewBase
+    {
+public:
+    CMemSpyViewEComCategory( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineEComCategory& aCategory );
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    CMemSpyViewBase* PrepareChildViewL();
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+    void HandleListBoxItemActionedL( TInt aIndex );
+    void HandleListBoxItemSelectedL( TInt aIndex );
+
+private: // Data members
+    CMemSpyEngineEComCategory& iCategory;
+    CMemSpyEngineEComInterface* iCurrent;
+    };
+
+
+
+
+class CMemSpyViewEComInterface : public CMemSpyViewBase
+    {
+public:
+    CMemSpyViewEComInterface( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineEComInterface& aInterface );
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    CMemSpyViewBase* PrepareChildViewL();
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+    void HandleListBoxItemActionedL( TInt aIndex );
+    void HandleListBoxItemSelectedL( TInt aIndex );
+
+private: // Data members
+    CMemSpyEngineEComInterface& iInterface;
+    CMemSpyEngineEComImplementation* iCurrent;
+    };
+
+
+
+
+
+
+class CMemSpyViewEComImplementation : public CMemSpyViewBase
+    {
+public:
+    CMemSpyViewEComImplementation( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineEComImplementation& aImplementation );
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+
+private: // Data members
+    CMemSpyEngineEComImplementation& iImplementation;
+    };
+
+
+
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewFBServBitmaps.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,177 @@
+/*
+* 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 MEMSPYVIEWFBSERVBITMAPS_H
+#define MEMSPYVIEWFBSERVBITMAPS_H
+
+// System includes
+#include <coecntrl.h>
+#include <aknlists.h>
+#include <eikimage.h>
+#include <AknDialog.h>
+
+// User includes
+#include "MemSpyViewBase.h"
+
+// Engine includes
+#include <memspy/engine/memspyenginehelperfbserv.h>
+
+
+
+class CMemSpyViewFBServBase : public CMemSpyViewBase
+    {
+public:
+    CMemSpyViewFBServBase( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineFbServBitmapArray* aBitmaps );
+    ~CMemSpyViewFBServBase();
+
+public: // From CMemSpyViewBase
+    TBool HandleCommandL( TInt aCommand );
+
+public: // Menu framework
+    TUint MenuCascadeResourceId() const { return R_MEMSPY_MENUPANE_IMAGES; }
+    TInt MenuCascadeCommandId() const { return EMemSpyCmdImages; }
+
+protected: // Command handlers
+    void OnCmdSlideShowL();
+    void OnCmdExportToMemoryCardL();
+    void OnCmdImageListingL();
+
+protected: // Data members
+    CMemSpyEngineFbServBitmapArray* iBitmaps;
+    };
+
+
+
+
+
+class CMemSpyViewFBServBitmaps : public CMemSpyViewFBServBase, public MMemSpyEngineFbSerbBitmapArrayObserver
+    {
+public:
+    CMemSpyViewFBServBitmaps( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver );
+    CMemSpyViewFBServBitmaps( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineFbServBitmapArray* aBitmaps );
+    ~CMemSpyViewFBServBitmaps();
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    CMemSpyViewBase* PrepareChildViewL();
+
+private: // From MMemSpyEngineFbSerbBitmapArrayObserver
+    void HandleFbServBitmapArrayEventL( TEvent aEvent );
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+    void HandleListBoxItemActionedL( TInt aIndex );
+    void HandleListBoxItemSelectedL( TInt aIndex );
+
+private: // Idle timer update
+    static TInt IdleUpdateListBoxModel( TAny* aSelf );
+    void DoIdleUpdateListBoxModelL();
+
+private: // Data members
+    RArray<TInt> iBitmapHandles;
+    CMemSpyEngineFbServBitmap* iCurrentBitmap;
+    CPeriodic* iIdleResetListboxTimer;
+    };
+
+
+
+class CMemSpyViewFBServBitmapInfo : public CMemSpyViewFBServBase
+    {
+public:
+    CMemSpyViewFBServBitmapInfo( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineFbServBitmapArray* aBitmaps, CMemSpyEngineFbServBitmap& aSelectedBitmap );
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    CMemSpyViewBase* PrepareChildViewL();
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+    void HandleListBoxItemActionedL( TInt aIndex );
+
+private: // Data members
+    CMemSpyEngineFbServBitmap& iBitmapObject;
+    };
+
+
+
+
+class CMemSpyViewFBServBitmapViewer : public CMemSpyViewFBServBase
+    {
+public:
+    CMemSpyViewFBServBitmapViewer( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineFbServBitmapArray* aBitmaps, CMemSpyEngineFbServBitmap& aSelectedBitmap );
+    ~CMemSpyViewFBServBitmapViewer();
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+    CEikListBox* ConstructListBoxL();
+
+private: // From CCoeControl
+    void Draw(const TRect& aRect) const;
+    void SizeChanged();
+    TInt CountComponentControls() const;
+    CCoeControl* ComponentControl( TInt aIndex ) const;
+
+private: // Data members
+    CMemSpyEngineFbServBitmap& iBitmapObject;
+    CEikImage* iImage;
+    TRect iBorderRect;
+    };
+
+
+
+
+
+class CMemSpyViewFBServSlideshow : public CAknDialog
+    {
+public:
+    static void NewLD( CMemSpyEngineFbServBitmapArray& aBitmaps, TInt& aIndex );
+    ~CMemSpyViewFBServSlideshow();
+
+private:
+    CMemSpyViewFBServSlideshow( CMemSpyEngineFbServBitmapArray& aBitmaps, TInt& aIndex );
+    void ConstructL();
+
+private:
+    void PreLayoutDynInitL();
+	TBool OkToExitL(TInt aButtonId);
+
+private: // Idle timer update
+    static TInt IdleUpdate( TAny* aSelf );
+    void ShowNextImageL();
+
+private: // Data members
+    CMemSpyEngineFbServBitmapArray& iBitmaps;
+    TInt& iIndex;
+    CPeriodic* iTimer;
+    };
+
+
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewHeapTracking.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,80 @@
+/*
+* 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 MEMSPYVIEWHEAPTRACKING_H
+#define MEMSPYVIEWHEAPTRACKING_H
+
+// System includes
+#include <hal.h>
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// Engine includes
+#include <memspy/engine/memspyenginehelpersysmemtrackerconfig.h>
+#include <memspy/engine/memspyenginehelpersysmemtrackerobserver.h>
+
+// User includes
+#include "MemSpyViewBase.h"
+
+// Classes referenced
+
+
+class CMemSpyViewHeapTracking : public CMemSpyViewBase, public MMemSpyEngineHelperSysMemTrackerObserver
+    {
+public:
+    CMemSpyViewHeapTracking( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver );
+    ~CMemSpyViewHeapTracking();
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    CMemSpyViewBase* PrepareChildViewL();
+
+public:
+    static TInt AsyncStopTimerCallback( TAny* aParam );
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+
+private: // From MMemSpyEngineHelperSysMemTrackerObserver
+    void HandleCyclesResetL();
+    void HandleCycleStartedL( const CMemSpyEngineHelperSysMemTrackerCycle& aCycle );
+    void HandleCycleFinishedL( const CMemSpyEngineHelperSysMemTrackerCycle& aCycle );
+    
+private: // Internal methods
+    TInt IndexByViewType( TMemSpyViewType aType );
+    void SetConfigByModeL( TMemSpyEngineHelperSysMemTrackerConfig::TMemSpyEngineSysMemTrackerMode aMode, TMemSpyEngineHelperSysMemTrackerConfig& aConfig );
+    TInt AsyncStopTimerCallback();
+
+private: // Enum
+    enum TMemSpyViewHeapTrackingState
+        {
+        EMemSpyViewHeapTrackingStateIdle = 0,
+        EMemSpyViewHeapTrackingStateTimerOn,
+        EMemSpyViewHeapTrackingStateSingleOn        
+        };
+
+private: // Data
+    TMemSpyEngineHelperSysMemTrackerConfig iOriginalConfig;
+    TMemSpyViewHeapTrackingState iState;
+    CAsyncCallBack* iStopTimerCallBack;
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewHeapTrackingResults.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,127 @@
+/*
+* 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 MEMSPYVIEWHEAPTRACKINGRESULTS_H
+#define MEMSPYVIEWHEAPTRACKINGRESULTS_H
+
+// System includes
+#include <hal.h>
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// Engine includes
+#include <memspy/engine/memspyenginehelpersysmemtrackerobserver.h>
+
+// Driver includes
+#include <memspy/driver/memspydriverobjectsshared.h>
+
+// User includes
+#include "MemSpyViewBase.h"
+
+// Classes referenced
+class CMemSpyEngineHelperSysMemTrackerCycle;
+class CMemSpyEngineHelperSysMemTrackerCycleChange;
+
+
+class CMemSpyViewHeapTrackingResults : public CMemSpyViewBase, public MMemSpyEngineHelperSysMemTrackerObserver
+    {
+public:
+    CMemSpyViewHeapTrackingResults( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver );
+    ~CMemSpyViewHeapTrackingResults();
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    CMemSpyViewBase* PrepareChildViewL();
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+
+private: // From MMemSpyEngineHelperSysMemTrackerObserver
+    void HandleCyclesResetL();
+    void HandleCycleStartedL( const CMemSpyEngineHelperSysMemTrackerCycle& aCycle );
+    void HandleCycleFinishedL( const CMemSpyEngineHelperSysMemTrackerCycle& aCycle );
+    };
+
+
+
+
+
+
+
+class CMemSpyViewHeapTrackingResultsCycleInfo : public CMemSpyViewBase, public MMemSpyEngineHelperSysMemTrackerObserver
+    {
+public:
+    CMemSpyViewHeapTrackingResultsCycleInfo( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, const CMemSpyEngineHelperSysMemTrackerCycle& aCycle );
+    ~CMemSpyViewHeapTrackingResultsCycleInfo();
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+
+private: // From MMemSpyEngineHelperSysMemTrackerObserver
+    void HandleCyclesResetL();
+    void HandleCycleStartedL( const CMemSpyEngineHelperSysMemTrackerCycle& aCycle );
+    void HandleCycleFinishedL( const CMemSpyEngineHelperSysMemTrackerCycle& aCycle );
+
+private: // Data members
+    const CMemSpyEngineHelperSysMemTrackerCycle& iCycle;
+    };
+
+
+
+
+
+/*
+class CMemSpyViewHeapTrackingResultsChangeDescriptor : public CMemSpyViewBase, public MMemSpyEngineHelperSysMemTrackerObserver
+    {
+public:
+    CMemSpyViewHeapTrackingResultsChangeDescriptor( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, const CMemSpyEngineHelperSysMemTrackerCycle& aCycle, const CMemSpyEngineHelperSysMemTrackerCycleChange& aChangeDescriptor, TInt aIndex );
+    ~CMemSpyViewHeapTrackingResultsChangeDescriptor();
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+
+private: // From MMemSpyEngineHelperSysMemTrackerObserver
+    void HandleCyclesResetL();
+    void HandleCycleStartedL( const CMemSpyEngineHelperSysMemTrackerCycle& aCycle );
+    void HandleCycleFinishedL( const CMemSpyEngineHelperSysMemTrackerCycle& aCycle );
+
+private: // Data members
+    const CMemSpyEngineHelperSysMemTrackerCycle& iCycle;
+    const CMemSpyEngineHelperSysMemTrackerCycleChange& iChangeDescriptor;
+    TInt iIndex; // For selection rune when moving to parent view
+    };
+*/
+
+
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewHeapTrackingSettings.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,109 @@
+/*
+* 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 MEMSPYVIEWHEAPTRACKINGSETTINGS_H
+#define MEMSPYVIEWHEAPTRACKINGSETTINGS_H
+
+// System includes
+#include <hal.h>
+#include <coecntrl.h>
+#include <aknlists.h>
+#include <aknsettingitemlist.h> 
+#include <akncheckboxsettingpage.h>
+#include <AknQueryDialog.h> 
+
+
+// User includes
+#include "MemSpyViewBase.h"
+
+// Classes referenced
+
+
+class CMemSpyViewHeapTrackingSettings : public CMemSpyViewBase
+    {
+public:
+    CMemSpyViewHeapTrackingSettings( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver );
+    ~CMemSpyViewHeapTrackingSettings();
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    CMemSpyViewBase* PrepareChildViewL();
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+
+private: // Internal methods
+    static void PrepareItemBufL( TDes& aBuf, const TDesC& aCaption, TBool aStatus, TBool aHeapCategorySelected );
+    };
+
+
+
+
+class CSWMTCategorySelectionCheckBoxSettingItem : public CAknSettingItem
+    {
+public:
+    CSWMTCategorySelectionCheckBoxSettingItem( TInt aIdentifier, TInt& aCategories );
+    virtual ~CSWMTCategorySelectionCheckBoxSettingItem();
+
+public:
+    CSelectionItemList* ItemArray() const;
+    
+protected:
+    void CompleteConstructionL();
+    void StoreL();
+    void LoadL();
+    void HandleSettingPageEventL( CAknSettingPage* aSettingPage, TAknSettingPageEvent aEventType );
+
+private:
+    void AddNewItemToArrayL(const TDesC& aLabel); 
+    
+private:
+    CSelectionItemList*     iItemArray;
+    HBufC*                  iSettingText;
+    TInt&                   iExtCategories;
+    };
+
+
+
+
+
+
+class CMemSpySWMTCategorySelectionCheckBoxSettingPage : public CAknCheckBoxSettingPage
+    {
+    public:
+        CMemSpySWMTCategorySelectionCheckBoxSettingPage( TInt aResourceID, CSelectionItemList* aItemArray );
+    public:     // New functions
+        void UpdateCba();
+    };
+    
+
+
+
+
+
+class CMemSpyAllowEmptyDataDialog : public CAknTextQueryDialog
+    {
+    public:
+        CMemSpyAllowEmptyDataDialog( TDes& aText, const TTone& aTone = ENoTone );
+    protected: // from CAknTextQueryDialog
+        void UpdateLeftSoftKeyL();
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewKernel.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,55 @@
+/*
+* 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 MEMSPYVIEWKERNEL_H
+#define MEMSPYVIEWKERNEL_H
+
+// System includes
+#include <hal.h>
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// User includes
+#include "MemSpyViewBase.h"
+
+// Classes referenced
+
+
+class CMemSpyViewKernel : public CMemSpyViewBase
+    {
+public:
+    CMemSpyViewKernel( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver );
+    ~CMemSpyViewKernel();
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    CMemSpyViewBase* PrepareChildViewL();
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+
+private: // Internal methods
+    static TInt IndexByViewType( TMemSpyViewType aType );
+
+private: // Data members
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewKernelContainers.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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 MEMSPYVIEWKERNELCONTAINERS_H
+#define MEMSPYVIEWKERNELCONTAINERS_H
+
+// System includes
+#include <hal.h>
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// User includes
+#include "MemSpyViewBase.h"
+
+// Classes referenced
+class CMemSpyEngineGenericKernelObjectContainer;
+
+
+class CMemSpyViewKernelContainers : public CMemSpyViewBase
+    {
+public:
+    CMemSpyViewKernelContainers( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver );
+    ~CMemSpyViewKernelContainers();
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    CMemSpyViewBase* PrepareChildViewL();
+
+public: // Menu framework
+    TUint MenuCascadeResourceId() const { return R_MEMSPY_MENUPANE_KERNEL_CONTAINERS; }
+    TInt MenuCascadeCommandId() const { return EMemSpyCmdKernelContainers; }
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+    TBool HandleCommandL( TInt aCommand );
+
+private: // Command handlers
+    void OnCmdOutputAllContainerContentsL();
+
+private: // Internal methods
+
+private: // Data members
+    CMemSpyEngineGenericKernelObjectContainer* iModel;
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewKernelHeap.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,63 @@
+/*
+* 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 MEMSPYVIEWKERNELHEAP_H
+#define MEMSPYVIEWKERNELHEAP_H
+
+// System includes
+#include <hal.h>
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// User includes
+#include "MemSpyViewBase.h"
+
+// Classes referenced
+class CMemSpyEngineGenericKernelObjectContainer;
+
+
+class CMemSpyViewKernelHeap : public CMemSpyViewBase
+    {
+public:
+    CMemSpyViewKernelHeap( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver );
+    ~CMemSpyViewKernelHeap();
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    CMemSpyViewBase* PrepareChildViewL();
+
+public: // Menu framework
+    TUint MenuCascadeResourceId() const { return R_MEMSPY_MENUPANE_KERNEL_HEAP; }
+    TInt MenuCascadeCommandId() const { return EMemSpyCmdKernelHeap; }
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+    TBool HandleCommandL( TInt aCommand );
+
+private: // Command handlers
+    void OnCmdDumpKernelHeapL();
+
+private: // Internal methods
+
+private: // Data members
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewKernelObjects.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,90 @@
+/*
+* 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 MEMSPYVIEWKERNELOBJECTS_H
+#define MEMSPYVIEWKERNELOBJECTS_H
+
+// System includes
+#include <hal.h>
+#include <coecntrl.h>
+#include <aknlists.h>
+#include <AknTabObserver.h> 
+
+// User includes
+#include "MemSpyViewBase.h"
+#include <memspy/driver/memspydriverenumerationsshared.h>
+
+// Classes referenced
+class CMemSpyEngineGenericKernelObjectContainer;
+class CMemSpyEngineGenericKernelObjectList;
+class CAknNavigationDecorator;
+class CAknNavigationControlContainer;
+class CAknTabGroup;
+
+
+class CMemSpyViewKernelObjects : public CMemSpyViewBase, public MAknTabObserver
+    {
+public:
+    CMemSpyViewKernelObjects( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, TMemSpyDriverContainerType aObjectType );
+    ~CMemSpyViewKernelObjects();
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    CEikListBox* ConstructListBoxL();
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    CMemSpyViewBase* PrepareChildViewL();
+
+public: // Menu framework
+    TUint MenuCascadeResourceId() const { return R_MEMSPY_MENUPANE_KERNEL_OBJECTS; }
+    TInt MenuCascadeCommandId() const { return EMemSpyCmdKernelObjects; }
+    void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+    TBool HandleCommandL( TInt aCommand );
+
+private: // From CCoeControl
+    TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
+
+private: // From MAknTabObserver
+    void TabChangedL( TInt aIndex ); 
+    
+private: // Command handlers
+    void OnCmdTerminateL();
+    void OnCmdSwitchToL();
+    void OnCmdEndL();
+    void OnCmdPanicL();
+
+private: // Internal methods
+    void CreateTabsL();
+    void DetailsL();
+    void AppendFormatString( TPtr& aPtr, TRefByValue<const TDesC> aFmt, ... );
+
+private: // Data members
+    CMemSpyEngineGenericKernelObjectContainer* iModel;
+    CDesCArrayFlat* iItems;
+    TMemSpyDriverContainerType iObjectType;
+    CMemSpyEngineGenericKernelObjectList* iObjectList;
+    CAknNavigationDecorator* iNavDecorator;
+    CAknNavigationControlContainer* iNavContainer;
+    CAknTabGroup* iTabs;
+    TInt iCurrItemIndex;
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewMainMenu.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,55 @@
+/*
+* 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 MEMSPYVIEWMAINMENU_H
+#define MEMSPYVIEWMAINMENU_H
+
+// System includes
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// User includes
+#include "MemSpyViewBase.h"
+
+// Classes referenced
+class CMemSpyProcess;
+
+
+class CMemSpyViewMainMenu : public CMemSpyViewBase
+    {
+public:
+    CMemSpyViewMainMenu( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver );
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareChildViewL();
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+
+private: // Internal methods
+    static TInt IndexByViewType( TMemSpyViewType aType );
+
+private: // Data members
+    };
+
+
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewMemoryTrackingAutoStartConfig.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,110 @@
+/*
+* 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 MEMSPYVIEWMEMORYTRACKINGAUTOSTARTCONFIG_H
+#define MEMSPYVIEWMEMORYTRACKINGAUTOSTARTCONFIG_H
+
+// System includes
+#include <coecntrl.h>
+#include <aknlists.h>
+#include <ecom/ecom.h>
+#include <xml/contenthandler.h> // MContentHandler mix in class
+#include <xml/parser.h>
+
+// User includes
+#include "MemSpyViewBase.h"
+
+// Literal constants
+_LIT( KMemSpyProcessMemoryTrackingAutoStartConfigSearchPath, "E:\\MemSpy\\" );
+_LIT( KMemSpyProcessMemoryTrackingAutoStartConfigFileName, "MemSpyProcessMemoryTrackingAutoStartConfig.xml" );
+
+// Classes referenced
+class CCnvCharacterSetConverter;
+
+// Namespaces referenced
+using namespace Xml;
+
+
+class CMemSpyViewMemoryTrackingAutoStartConfig : public CMemSpyViewBase, public MContentHandler
+    {
+public:
+    CMemSpyViewMemoryTrackingAutoStartConfig( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver );
+    ~CMemSpyViewMemoryTrackingAutoStartConfig();
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    TBool HandleCommandL( TInt aCommand );
+    void HandleListBoxItemActionedL( TInt aIndex );
+    void SetListBoxModelL();
+    void RefreshL();
+
+public: // Menu framework
+    void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
+    TUint MenuCascadeResourceId() const;
+    TInt MenuCascadeCommandId() const;
+
+private: // Command handlers
+    void OnCmdItemAddL();
+    void OnCmdItemEditL();
+    void OnCmdItemDeleteL();
+    void OnCmdItemDeleteAllL();
+    void OnCmdItemImportL();
+
+private: // Internal methods
+    TUid ShowDialogL( TUid aUid );
+    void SaveChangesL();
+    static TUid ValidateProcessUid( const TDesC& aUid );
+
+private: // Internal XML methods
+    void FindXmlInstallTimeL();
+    void FindXmlUserSuppliedL();
+    HBufC* FindEComXmlFileNameLC();
+    void ConvertL( const TDesC8& aInput, TDes16& aOutput );
+    void ParseL( const TDesC& aFileName );
+
+private: // XML helper functions
+    void OnSectionProcessL( const RAttributeArray& aAttributes );
+
+private: // From MContentHandler
+	void OnStartDocumentL( const RDocumentParameters& aDocParam, TInt aErrorCode );
+	void OnEndDocumentL( TInt aErrorCode );
+	void OnStartElementL( const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aErrorCode );
+	void OnEndElementL( const RTagInfo& aElement, TInt aErrorCode );
+	void OnContentL( const TDesC8& aBytes, TInt aErrorCode );
+	void OnStartPrefixMappingL( const RString& aPrefix, const RString& aUri, TInt aErrorCode );
+	void OnEndPrefixMappingL( const RString& aPrefix, TInt aErrorCode );
+	void OnIgnorableWhiteSpaceL( const TDesC8& aBytes, TInt aErrorCode );
+	void OnSkippedEntityL( const RString& aName, TInt aErrorCode );
+	void OnProcessingInstructionL( const TDesC8& aTarget, const TDesC8& aData, TInt aErrorCode );
+	void OnError( TInt aErrorCode );
+	TAny* GetExtendedInterface( const TInt32 aUid );
+
+private: // Data members
+    RArray< TUid > iProcessUids;
+    TInt iParserErrorCode;
+    TInt iCharconvConverterState;
+    TBool iSeenMasterSection;
+    CParser* iParser;
+    CCnvCharacterSetConverter* iConverter;
+    HBufC* iXMLFileNameInstallTime;
+    HBufC* iXMLFileNameUserSupplied;
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewObserver.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef MEMSPYVIEWOBSERVER_H
+#define MEMSPYVIEWOBSERVER_H
+
+// User includes
+#include "MemSpyViewType.h"
+
+// Classes referenced
+class CMemSpyViewBase;
+
+class MMemSpyViewObserver
+    {
+public: // Enumerations
+    enum TViewEventType
+        {
+        EEventItemActioned = 0,
+        EEventItemSelected
+        };
+
+public: // From MMemSpyViewObserver
+    virtual void HandleMemSpyViewEventL( TViewEventType aEvent, TMemSpyViewType aViewType, CMemSpyViewBase& aReportingView, TAny* aContext ) = 0;
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewOpenFiles.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,63 @@
+/*
+* 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 MEMSPYVIEWOPENFILES_H
+#define MEMSPYVIEWOPENFILES_H
+
+// System includes
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// User includes
+#include "MemSpyViewBase.h"
+
+// Classes referenced
+
+
+class CMemSpyViewOpenFiles : public CMemSpyViewBase
+    {
+public:
+    CMemSpyViewOpenFiles( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver );
+    ~CMemSpyViewOpenFiles();
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    CEikListBox* ConstructListBoxL();
+    void RefreshL();
+    TBool HandleCommandL( TInt aCommand );
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    CMemSpyViewBase* PrepareChildViewL();
+
+private: // Command handlers
+    void OnCmdListOpenFilesL();
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+    void HandleListBoxItemActionedL( TInt aCurrentIndex );
+
+private: // Internal
+    static TBool CompareTEntryObjects( const TEntry& aLeft, const TEntry& aRight );
+
+private: // Data members
+    RArray<TThreadId> iThreadIds;
+    const TThreadId* iActionedThreadId;
+    RArray<TEntry> iFileNames;
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewProcesses.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,100 @@
+/*
+* 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 MEMSPYVIEWPROCESSES_H
+#define MEMSPYVIEWPROCESSES_H
+
+// System includes
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// User includes
+#include "MemSpyViewBase.h"
+
+// Classes referenced
+class CMemSpyProcess;
+class CAknSearchField;
+
+
+class CMemSpyViewProcesses : public CMemSpyViewBase
+    {
+public:
+    CMemSpyViewProcesses( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver );
+    CMemSpyViewProcesses( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyProcess& aProcess );
+    ~CMemSpyViewProcesses();
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // API
+    CMemSpyProcess& CurrentProcess() const;
+
+public: // From CMemSpyViewBase
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    CMemSpyViewBase* PrepareChildViewL();
+    TBool HandleCommandL( TInt aCommand );
+
+public: // Menu framework
+    TUint MenuCascadeResourceId() const { return R_MEMSPY_MENUPANE_PROCESS; }
+    TInt MenuCascadeCommandId() const { return EMemSpyCmdProcess; }
+    void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
+
+private: // Command handlers
+
+    // Sorting
+    void OnCmdSortByIdL();
+    void OnCmdSortByNameL();
+    void OnCmdSortByThreadCountL();
+    void OnCmdSortByCodeSegsL();
+    void OnCmdSortByHeapUsageL();
+    void OnCmdSortByStackUsageL();
+
+    // Info
+    void OnCmdInfoSummaryL();
+    void OnCmdInfoHandlesL();
+
+    // Ending
+    void OnCmdEndTerminateL();
+    void OnCmdEndPanicL();
+    void OnCmdEndKillL();
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+    void HandleListBoxItemActionedL( TInt aIndex );
+    void HandleListBoxItemSelectedL( TInt aIndex );
+    
+private: // From CCoeControl
+    void SizeChanged();
+    TInt CountComponentControls() const;
+    CCoeControl* ComponentControl( TInt aIndex ) const;
+	TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
+    void FocusChanged( TDrawNow /*aDrawNow*/ );
+
+private: // From MCoeControlObserver
+    void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType );
+
+private: // Internal methods
+    void SelectListBoxItemByFindTextL();
+
+private: // Data members
+    CMemSpyProcess* iCurrentProcess;
+    CAknSearchField* iSearchField;
+    HBufC* iMatcherBuffer;
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewRAMInfo.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,58 @@
+/*
+* 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 MEMSPYVIEWRAMINFO_H
+#define MEMSPYVIEWRAMINFO_H
+
+// System includes
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// User includes
+#include "MemSpyViewBase.h"
+
+// Classes referenced
+
+
+class CMemSpyViewRAMInfo : public CMemSpyViewBase
+    {
+public:
+    CMemSpyViewRAMInfo( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver );
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    CMemSpyViewBase* PrepareChildViewL();
+    TBool HandleCommandL( TInt aCommand );
+
+public: // Menu framework
+    TUint MenuCascadeResourceId() const { return R_MEMSPY_MENUPANE_RAM; }
+    TInt MenuCascadeCommandId() const { return EMemSpyCmdRAM; }
+
+private: // Command handlers
+    void OnCmdSetIconCacheStatusL( TBool aEnabled );
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+
+private: // Data members
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewROMInfo.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,51 @@
+/*
+* 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 MEMSPYVIEWROMINFO_H
+#define MEMSPYVIEWROMINFO_H
+
+// System includes
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// User includes
+#include "MemSpyViewBase.h"
+
+// Classes referenced
+
+
+class CMemSpyViewROMInfo : public CMemSpyViewBase
+    {
+public:
+    CMemSpyViewROMInfo( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver );
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    CMemSpyViewBase* PrepareChildViewL();
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+
+private: // Data members
+    };
+
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewServerList.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,68 @@
+/*
+* 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 MEMSPYVIEWSERVERLIST_H
+#define MEMSPYVIEWSERVERLIST_H
+
+// System includes
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// User includes
+#include "MemSpyViewBase.h"
+
+// Classes referenced
+class CMemSpyEngineServerList;
+class CMemSpyEngineServerEntry;
+
+
+class CMemSpyViewServerList : public CMemSpyViewBase
+    {
+public:
+    CMemSpyViewServerList( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver );
+    ~CMemSpyViewServerList();
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    TBool HandleCommandL( TInt aCommand );
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    CMemSpyViewBase* PrepareChildViewL();
+
+public: // Menu framework
+    TUint MenuCascadeResourceId() const { return R_MEMSPY_MENUPANE_SERVER_LIST; }
+    TInt MenuCascadeCommandId() const { return EMemSpyCmdServerList; }
+
+private: // Command handlers
+    void OnCmdServerListSortByNameL();
+    void OnCmdServerListSortBySessionCountL();
+    void OnCmdServerListOutputSummaryL();
+    void OnCmdServerListOutputDetailedL();
+    void OnCmdServerListOutputGenericL( TBool aDetailed );
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+    void HandleListBoxItemActionedL( TInt aCurrentIndex );
+
+private: // Data members
+    CMemSpyEngineServerList* iList;
+    const CMemSpyEngineServerEntry* iActionedItem;
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewSystemConfig.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,97 @@
+/*
+* 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 MEMSPYVIEWSYSTEMCONFIG_H
+#define MEMSPYVIEWSYSTEMCONFIG_H
+
+// System includes
+#include <hal.h>
+#include <f32file.h>
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// User includes
+#include "MemSpyViewBase.h"
+
+// Classes referenced
+
+
+class CMemSpyViewSystemConfig : public CMemSpyViewBase
+    {
+public:
+    CMemSpyViewSystemConfig( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver );
+    ~CMemSpyViewSystemConfig();
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    CMemSpyViewBase* PrepareChildViewL();
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+
+private: // Internal enumerations 
+
+    enum TMemSpyDisplayMode
+	    {
+	    ENone,
+	    EGray2,
+	    EGray4,
+	    EGray16,
+	    EGray256,
+	    EColor16,
+	    EColor256,
+	    EColor64K,
+	    EColor16M,
+	    ERgb,
+	    EColor4K,
+	    EColor16MU,
+	    EColor16MA,
+	    EColor16MAP,
+	    EColorLast
+	    };
+
+private: // Internal methods
+    static void GetManufacturer( TDes& aBuf );
+    static void GetDeviceFamily( TDes& aBuf );
+    static void GetCPU( TDes& aBuf );
+    static void GetCPUABI( TDes& aBuf );
+    static void GetStartupReason( TDes& aBuf );
+    static void GetKeyboard( TDes& aBuf );
+    static void GetMachineUid( TDes& aBuf );
+    static void GetDisplayType( TDes& aBuf );
+    static void GetDisplayMode( TDes& aBuf, TMemSpyDisplayMode aMode );
+    //
+    static TInt GetHALValue( HALData::TAttribute aAttribute, TInt& aValue );
+    TInt GetHALValueAsStringL( HALData::TAttribute aAttribute, const TDesC& aCaption, const TDesC* aSuffix = NULL );
+    TInt GetHALValueAsNumericL( HALData::TAttribute aAttribute, const TDesC& aCaption, const TDesC* aSuffix = NULL, TInt aWidth = -1 );
+    TInt GetHALValueAsHexL( HALData::TAttribute aAttribute, const TDesC& aCaption, const TDesC* aSuffix = NULL );
+    TInt GetHALValueAsYesNoL( HALData::TAttribute aAttribute, const TDesC& aCaption, const TDesC* aSuffix = NULL );
+    TInt GetHALValueAsDriveLetterL( HALData::TAttribute aAttribute, const TDesC& aCaption, const TDesC* aSuffix = NULL );
+
+private:
+    void AddItemL( const TDesC& aCaption, const TDesC& aValue, const TDesC* aSuffix = NULL );
+    void AddItemL( TDriveNumber aDrive, const TDesC& aCaption, const TDesC* aSuffix = NULL );
+
+private: // Data members
+    CDesCArrayFlat* iModel;
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewThreadInfoItemActiveObject.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,89 @@
+/*
+* 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 MEMSPYVIEWTHREADINFOITEMACTIVEOBJECT_H
+#define MEMSPYVIEWTHREADINFOITEMACTIVEOBJECT_H
+
+// System includes
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// User includes
+#include "MemSpyViewThreadInfoItemGeneric.h"
+
+// Classes referenced
+class CMemSpyEngineActiveObjectArray;
+
+
+
+class CMemSpyViewThreadInfoItemActiveObjectBase : public CMemSpyViewThreadInfoItemGeneric
+    {
+public:
+    CMemSpyViewThreadInfoItemActiveObjectBase( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer );
+
+public: // From CMemSpyViewBase
+    TBool HandleCommandL( TInt aCommand );
+
+public: // Menu framework
+    TUint MenuCascadeResourceId() const { return R_MEMSPY_MENUPANE_ACTIVE_OBJECTS; }
+    TInt MenuCascadeCommandId() const { return EMemSpyCmdActiveObject; }
+    void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
+
+protected:
+    CMemSpyEngineActiveObjectArray& ActiveObjectArray() const;
+
+private: // Command handlers
+    void OnCmdWriteAOListingL();
+    };
+
+
+
+class CMemSpyViewThreadInfoItemActiveObject : public CMemSpyViewThreadInfoItemActiveObjectBase
+    {
+public:
+    CMemSpyViewThreadInfoItemActiveObject( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer );
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareChildViewL();
+    };
+
+
+
+
+class CMemSpyViewThreadInfoItemActiveObjectDetails : public CMemSpyViewThreadInfoItemActiveObjectBase
+    {
+public:
+    CMemSpyViewThreadInfoItemActiveObjectDetails( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer, TAny* aObjectAddress );
+
+public: // From CMemSpyViewBase
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+    
+private: // Data members
+    TAny* iObjectAddress;
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewThreadInfoItemChunk.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef MEMSPYVIEWTHREADINFOITEMCHUNK_H
+#define MEMSPYVIEWTHREADINFOITEMCHUNK_H
+
+// System includes
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// User includes
+#include "MemSpyViewThreadInfoItemGeneric.h"
+
+
+class CMemSpyViewThreadInfoItemChunk : public CMemSpyViewThreadInfoItemGeneric
+    {
+public:
+    CMemSpyViewThreadInfoItemChunk( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer );
+
+private: // From CMemSpyViewBase
+    CMemSpyViewBase* PrepareChildViewL();
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewThreadInfoItemCodeSeg.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,42 @@
+/*
+* 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 MEMSPYVIEWTHREADINFOITEMCODESEG_H
+#define MEMSPYVIEWTHREADINFOITEMCODESEG_H
+
+// System includes
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// User includes
+#include "MemSpyViewThreadInfoItemGeneric.h"
+
+
+class CMemSpyViewThreadInfoItemCodeSeg : public CMemSpyViewThreadInfoItemGeneric
+    {
+public:
+    CMemSpyViewThreadInfoItemCodeSeg( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer );
+
+public: // From CMemSpyViewBase
+    TBool HandleCommandL( TInt aCommand );
+
+private: // From CMemSpyViewBase
+    CMemSpyViewBase* PrepareChildViewL();
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewThreadInfoItemGeneralInfo.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,43 @@
+/*
+* 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 MEMSPYVIEWTHREADINFOITEMGENERALINFO_H
+#define MEMSPYVIEWTHREADINFOITEMGENERALINFO_H
+
+// System includes
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// User includes
+#include "MemSpyViewThreadInfoItemGeneric.h"
+
+
+class CMemSpyViewThreadInfoItemGeneralInfo : public CMemSpyViewThreadInfoItemGeneric
+    {
+public:
+    CMemSpyViewThreadInfoItemGeneralInfo( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer );
+
+public: // From CMemSpyViewBase
+    TBool HandleCommandL( TInt aCommand );
+    void HandleListBoxItemActionedL( TInt aCurrentIndex );
+
+private: // Command handlers
+    void OnCmdToggleKernelEventHooksL();
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewThreadInfoItemGeneric.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,81 @@
+/*
+* 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 MEMSPYVIEWTHREADINFOITEMGENERIC_H
+#define MEMSPYVIEWTHREADINFOITEMGENERIC_H
+
+// System includes
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// Engine includes
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+
+// User includes
+#include "MemSpyViewBase.h"
+
+// Classes referenced
+class CAknWaitDialog;
+class CMemSpyProcess;
+class CMemSpyThread;
+class CMemSpyThreadInfoContainer;
+class CMemSpyThreadInfoItemBase;
+
+
+class CMemSpyViewThreadInfoItemGeneric : public CMemSpyViewBase
+    {
+public:
+    CMemSpyViewThreadInfoItemGeneric( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aInfoContainer, TMemSpyThreadInfoItemType aType );
+    ~CMemSpyViewThreadInfoItemGeneric();
+
+public: // From CMemSpyViewBase
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // API
+    CMemSpyProcess& Process() const;
+    CMemSpyThread& Thread() const;
+    CMemSpyThreadInfoContainer& Container() const;
+    CMemSpyThreadInfoItemBase& InfoItem() const;
+
+public: // From CMemSpyViewBase
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    CMemSpyViewBase* PrepareChildViewL();
+    TBool HandleCommandL( TInt aCommand );
+
+protected: // From CMemSpyViewBase
+    void SetListBoxModelL();
+    void HandleListBoxItemActionedL( TInt aCurrentIndex );
+    void HandleListBoxItemSelectedL( TInt aCurrentIndex );
+
+private: // Internal methods
+    void ShowWaitNoteL();
+    void DestroyWaitNote();
+    static TInt CheckForItemConstructionComplete( TAny* aSelf );
+
+protected: // Member data
+    CMemSpyThreadInfoContainer& iContainer;
+    CMemSpyThreadInfoItemBase* iInfoItem;
+
+private: // Member data
+    CAknWaitDialog* iWaitNote;
+    CPeriodic* iWaitConstructionChecker;
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewThreadInfoItemHeap.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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:
+*
+*/
+
+#ifndef MEMSPYVIEWTHREADINFOITEMHEAP_H
+#define MEMSPYVIEWTHREADINFOITEMHEAP_H
+
+// System includes
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// User includes
+#include "MemSpyViewThreadInfoItemGeneric.h"
+
+
+class CMemSpyViewThreadInfoItemHeap : public CMemSpyViewThreadInfoItemGeneric
+    {
+public:
+    CMemSpyViewThreadInfoItemHeap( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer );
+
+public: // From CMemSpyViewBase
+    TBool HandleCommandL( TInt aCommand );
+
+public: // Menu framework
+    TUint MenuCascadeResourceId() const { return R_MEMSPY_MENUPANE_HEAP; }
+    TInt MenuCascadeCommandId() const { return EMemSpyCmdHeap; }
+    void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
+
+private: // Command handlers
+    void OnCmdHeapDataL();
+    void OnCmdHeapCellListingL();
+    void OnCmdHeapInfoL();
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewThreadInfoItemList.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,79 @@
+/*
+* 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 MEMSPYVIEWTHREADINFOITEMLIST_H
+#define MEMSPYVIEWTHREADINFOITEMLIST_H
+
+// System includes
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// User includes
+#include "MemSpyViewBase.h"
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+
+// Classes referenced
+class CMemSpyProcess;
+class CMemSpyThread;
+class CMemSpyThreadInfoItemBase;
+
+
+class CMemSpyViewThreadInfoItemList : public CMemSpyViewBase, public MMemSpyThreadInfoContainerObserver
+    {
+public:
+    CMemSpyViewThreadInfoItemList( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThread& aThread );
+    ~CMemSpyViewThreadInfoItemList();
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // API
+    const CMemSpyProcess& Process() const;
+    const CMemSpyThread& Thread() const;
+    const CMemSpyThreadInfoItemBase& CurrentInfoItem() const;
+
+public: // From CMemSpyViewBase
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    CMemSpyViewBase* PrepareChildViewL();
+    TBool HandleCommandL( TInt aCommand );
+
+public: // Menu framework
+    TUint MenuCascadeResourceId() const { return R_MEMSPY_MENUPANE_THREAD; }
+    TInt MenuCascadeCommandId() const { return EMemSpyCmdThread; }
+    void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
+
+private: // Command handlers
+    void OnCmdInfoHandlesL();
+
+private: // From MMemSpyThreadInfoContainerObserver
+    void HandleMemSpyEngineInfoContainerEventL( TEvent aEvent, TMemSpyThreadInfoItemType aType );
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+    void HandleListBoxItemActionedL( TInt aCurrentIndex );
+    void HandleListBoxItemSelectedL( TInt aCurrentIndex );
+    static TInt IdleUpdateListBoxModel( TAny* aSelf );
+    void DoIdleUpdateListBoxModelL();
+
+private: // Member data
+    CMemSpyThread& iThread;
+    CMemSpyThreadInfoItemBase* iCurrentInfoItem;
+    CPeriodic* iIdleResetListboxTimer;
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewThreadInfoItemMemoryTracking.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,137 @@
+/*
+* 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 MEMSPYVIEWTHREADINFOITEMMEMORYTRACKING_H
+#define MEMSPYVIEWTHREADINFOITEMMEMORYTRACKING_H
+
+// System includes
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// Engine includes
+#include <memspy/engine/memspyengineprocessmemorytracker.h>
+
+// User includes
+#include "MemSpyViewThreadInfoItemGeneric.h"
+
+// Classes referenced
+class CMemSpyEngineProcessMemoryTracker;
+
+
+class CMemSpyViewThreadInfoItemMemoryTracking : public CMemSpyViewThreadInfoItemGeneric, public MMemSpyEngineProcessMemoryTrackerObserver
+    {
+public:
+    CMemSpyViewThreadInfoItemMemoryTracking( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer );
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    CMemSpyViewBase* PrepareChildViewL();
+    TBool HandleCommandL( TInt aCommand );
+    TInt IndexByViewType( TMemSpyViewType aType );
+    void HandleListBoxItemActionedL( TInt aIndex );
+    void RefreshL();
+    void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
+
+public: // Menu framework
+    TUint MenuCascadeResourceId() const { return R_MEMSPY_MENUPANE_MEMORY_TRACKING; }
+    TInt MenuCascadeCommandId() const { return EMemSpyCmdMemoryTracking; }
+
+private: // From MMemSpyEngineProcessMemoryTrackerObserver
+    void HandleMemoryTrackingStartedL();
+    void HandleMemoryTrackingStoppedL();
+    void HandleMemoryChangedL( const TProcessId& aPid, const TMemSpyDriverProcessInspectionInfo& aCurrentInfo, const TMemSpyDriverProcessInspectionInfo& aHWMInfoIncShared, const TMemSpyDriverProcessInspectionInfo& aHWMInfoExcShared );
+
+private: // Command handlers
+    void OnCmdTrackingStartL();
+    void OnCmdTrackingStopL();
+    void OnCmdHWMResetL();
+    void OnCmdTotalWithSharedMemL();
+    void OnCmdTotalWithoutSharedMemL();
+    };
+
+
+class CMemSpyViewThreadInfoItemMemoryTrackingCurrent : public CMemSpyViewThreadInfoItemGeneric, public MMemSpyEngineProcessMemoryTrackerObserver
+    {
+public:
+    CMemSpyViewThreadInfoItemMemoryTrackingCurrent( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer );
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    void RefreshL();
+    void SetListBoxModelL();
+
+private: // From MMemSpyEngineProcessMemoryTrackerObserver
+    void HandleMemoryTrackingStartedL() { }
+    void HandleMemoryTrackingStoppedL() { }
+    void HandleMemoryChangedL( const TProcessId& aPid, const TMemSpyDriverProcessInspectionInfo& aCurrentInfo, const TMemSpyDriverProcessInspectionInfo& aHWMInfoIncShared, const TMemSpyDriverProcessInspectionInfo& aHWMInfoExcShared );
+    };
+
+
+
+class CMemSpyViewThreadInfoItemMemoryTrackingHWM : public CMemSpyViewThreadInfoItemGeneric, public MMemSpyEngineProcessMemoryTrackerObserver
+    {
+public:
+    CMemSpyViewThreadInfoItemMemoryTrackingHWM( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer );
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    TBool HandleCommandL( TInt aCommand );
+    void RefreshL();
+    void SetListBoxModelL();
+
+private: // From MMemSpyEngineProcessMemoryTrackerObserver
+    void HandleMemoryTrackingStartedL() { }
+    void HandleMemoryTrackingStoppedL() { }
+    void HandleMemoryChangedL( const TProcessId& aPid, const TMemSpyDriverProcessInspectionInfo& aCurrentInfo, const TMemSpyDriverProcessInspectionInfo& aHWMInfoIncShared, const TMemSpyDriverProcessInspectionInfo& aHWMInfoExcShared );
+
+public: // Menu framework
+    TUint MenuCascadeResourceId() const { return R_MEMSPY_MENUPANE_MEMORY_TRACKING_HWM; }
+    TInt MenuCascadeCommandId() const { return EMemSpyCmdMemoryTrackingHWM; }
+
+private: // Command handlers
+    void OnCmdHWMResetL();
+    };
+    
+
+
+
+class CMemSpyViewThreadInfoItemMemoryTrackingPeak : public CMemSpyViewThreadInfoItemGeneric, public MMemSpyEngineProcessMemoryTrackerObserver
+    {
+public:
+    CMemSpyViewThreadInfoItemMemoryTrackingPeak( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer );
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    TBool HandleCommandL( TInt aCommand );
+    void RefreshL();
+    void SetListBoxModelL();
+
+private: // From MMemSpyEngineProcessMemoryTrackerObserver
+    void HandleMemoryTrackingStartedL() { }
+    void HandleMemoryTrackingStoppedL() { }
+    void HandleMemoryChangedL( const TProcessId& aPid, const TMemSpyDriverProcessInspectionInfo& aCurrentInfo, const TMemSpyDriverProcessInspectionInfo& aHWMInfoIncShared, const TMemSpyDriverProcessInspectionInfo& aHWMInfoExcShared );
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewThreadInfoItemServer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,104 @@
+/*
+* 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 MEMSPYVIEWTHREADINFOITEMSERVER_H
+#define MEMSPYVIEWTHREADINFOITEMSERVER_H
+
+// System includes
+#include <coecntrl.h>
+#include <aknlists.h>
+#include <badesca.h>
+
+// User includes
+#include "MemSpyViewThreadInfoItemGeneric.h"
+
+// Classes referenced
+class TMemSpyDriverHandleInfoGeneric;
+
+
+
+class CMemSpyViewThreadInfoItemServer : public CMemSpyViewThreadInfoItemGeneric
+    {
+public:
+    CMemSpyViewThreadInfoItemServer( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer );
+
+public: // From CMemSpyViewBase
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    TBool HandleCommandL( TInt aCommand );
+    void HandleListBoxItemSelectedL( TInt aCurrentIndex );
+
+public: // From CMemSpyViewBase
+    CMemSpyViewBase* PrepareChildViewL();
+
+private: // Data members
+    TMemSpyDriverHandleInfoGeneric iCurrentInfoItemDetails;
+    };
+
+
+
+class CMemSpyViewThreadInfoItemServerDetails : public CMemSpyViewThreadInfoItemGeneric
+    {
+public:
+    CMemSpyViewThreadInfoItemServerDetails( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer, const TMemSpyDriverHandleInfoGeneric& aInfoItemDetails );
+
+public: // From CMemSpyViewBase
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    TBool HandleCommandL( TInt aCommand );
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareChildViewL();
+    CMemSpyViewBase* PrepareParentViewL();
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+    void HandleListBoxItemActionedL( TInt aCurrentIndex );
+    void HandleListBoxItemSelectedL( TInt aCurrentIndex );
+
+private: // Internal methods
+
+private: // Member data
+    const TMemSpyDriverHandleInfoGeneric iInfoItemDetails;
+    };
+
+
+
+class CMemSpyViewThreadInfoItemServerSessions : public CMemSpyViewThreadInfoItemGeneric
+    {
+public:
+    CMemSpyViewThreadInfoItemServerSessions( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer, const TMemSpyDriverHandleInfoGeneric& aInfoItemDetails );
+
+public: // From CMemSpyViewBase
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    TBool HandleCommandL( TInt aCommand );
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+
+private: // Member data
+    const TMemSpyDriverHandleInfoGeneric iInfoItemDetails;
+    };
+
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewThreadInfoItemStack.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,53 @@
+/*
+* 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 MEMSPYVIEWTHREADINFOITEMSTACK_H
+#define MEMSPYVIEWTHREADINFOITEMSTACK_H
+
+// System includes
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// User includes
+#include "MemSpyViewThreadInfoItemGeneric.h"
+
+
+class CMemSpyViewThreadInfoItemStack : public CMemSpyViewThreadInfoItemGeneric
+    {
+public:
+    CMemSpyViewThreadInfoItemStack( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer );
+
+public: // From CMemSpyViewBase
+    TBool HandleCommandL( TInt aCommand );
+
+public: // Menu framework
+    TUint MenuCascadeResourceId() const { return R_MEMSPY_MENUPANE_STACK; }
+    TInt MenuCascadeCommandId() const { return EMemSpyCmdStack; }
+    void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
+
+private: // Command handlers
+    void OnCmdDeviceStackSummaryL();
+    void OnCmdStackInfoL();
+    void OnCmdStackDataUserL();
+    void OnCmdStackDataKernelL();
+    void OnCmdStackDataUserAllThreadsL();
+    void OnCmdStackDataKernelAllThreadsL();
+    void OnCmdStackWatchForHighWatermarkL();
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewThreads.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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 MEMSPYVIEWTHREADS_H
+#define MEMSPYVIEWTHREADS_H
+
+// System includes
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// User includes
+#include "MemSpyViewBase.h"
+
+// Classes referenced
+class CMemSpyProcess;
+class CMemSpyThread;
+
+
+class CMemSpyViewThreads : public CMemSpyViewBase
+    {
+public:
+    CMemSpyViewThreads( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyProcess& aProcess );
+    ~CMemSpyViewThreads();
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // API
+    const CMemSpyProcess& Process() const;
+    CMemSpyThread& CurrentThread();
+
+public: // Menu framework
+    TUint MenuCascadeResourceId() const { return R_MEMSPY_MENUPANE_THREAD; }
+    TInt MenuCascadeCommandId() const { return EMemSpyCmdThread; }
+    void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
+
+public: // From CMemSpyViewBase
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    CMemSpyViewBase* PrepareChildViewL();
+    TBool HandleCommandL( TInt aCommand );
+
+private: // Command handlers
+    void OnCmdEndKillL();
+    void OnCmdEndTerminateL();
+    void OnCmdEndPanicL();
+    void OnCmdSetPriorityL( TInt aCommand );
+    void OnCmdInfoHandlesL();
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+    void HandleListBoxItemActionedL( TInt aCurrentIndex );
+    void HandleListBoxItemSelectedL( TInt aCurrentIndex );
+
+private: // Member data
+    CMemSpyProcess& iParentProcess;
+    CMemSpyThread* iCurrentThread;
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewType.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,104 @@
+/*
+* 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 MEMSPYVIEWTYPE_H
+#define MEMSPYVIEWTYPE_H
+
+// System includes
+#include <e32std.h>
+
+// Enumerations
+enum TMemSpyViewType
+    {
+    EMemSpyViewTypeNone = -1,
+    EMemSpyViewTypeMainMenu = 0,
+    EMemSpyViewTypeProcesses,
+    EMemSpyViewTypeRAMInfo,
+    EMemSpyViewTypeROMInfo,
+    EMemSpyViewTypeServerList,
+    EMemSpyViewTypeOpenFiles,
+    EMemSpyViewTypeFBServBitmaps,
+    EMemSpyViewTypeFBServBitmapInfo,
+    EMemSpyViewTypeFBServBitmapViewer,
+    EMemSpyViewTypeCodeSegmentList,
+    EMemSpyViewTypeCodeSegmentDetails,
+    EMemSpyViewTypeChunkList,
+    EMemSpyViewTypeChunkDetails,
+    EMemSpyViewTypeSystemConfig,
+    EMemSpyViewTypeKernel,
+    EMemSpyViewTypeKernelContainers,
+    EMemSpyViewTypeKernelObjects,
+    EMemSpyViewTypeKernelHeap,
+    EMemSpyViewTypeDriveSummary,
+    EMemSpyViewTypeDriveInfo,
+    EMemSpyViewTypeECom,
+    EMemSpyViewTypeEComCategory,
+    EMemSpyViewTypeEComInterface,
+    EMemSpyViewTypeEComImplementation,
+    EMemSpyViewTypeThreads,
+    EMemSpyViewTypeThreadInfoItemList,
+    EMemSpyViewTypeThreadInfoItemHeap,
+    EMemSpyViewTypeThreadInfoItemStack,
+    EMemSpyViewTypeThreadInfoItemChunk,
+    EMemSpyViewTypeThreadInfoItemCodeSeg,
+    EMemSpyViewTypeThreadInfoItemServer,
+    EMemSpyViewTypeThreadInfoItemServerDetails,
+    EMemSpyViewTypeThreadInfoItemServerSessions,
+    EMemSpyViewTypeThreadInfoItemSession,
+    EMemSpyViewTypeThreadInfoItemSemaphore,
+    EMemSpyViewTypeThreadInfoItemMutex,
+    EMemSpyViewTypeThreadInfoItemTimer,
+    EMemSpyViewTypeThreadInfoItemLDD,
+    EMemSpyViewTypeThreadInfoItemPDD,
+    EMemSpyViewTypeThreadInfoItemLogicalChannel,
+    EMemSpyViewTypeThreadInfoItemChangeNotifier,
+    EMemSpyViewTypeThreadInfoItemUndertaker,
+    EMemSpyViewTypeThreadInfoItemMessageQueue,
+    EMemSpyViewTypeThreadInfoItemConditionalVariable,
+    EMemSpyViewTypeThreadInfoItemOpenFiles,
+    EMemSpyViewTypeThreadInfoItemActiveObject,
+    EMemSpyViewTypeThreadInfoItemActiveObjectDetails,
+    EMemSpyViewTypeThreadInfoItemGeneralInfo,
+    EMemSpyViewTypeThreadInfoItemOtherThreads,
+    EMemSpyViewTypeThreadInfoItemOtherProcesses,
+    EMemSpyViewTypeThreadInfoItemOwnedThreadHandles,
+    EMemSpyViewTypeThreadInfoItemOwnedProcessHandles,
+    EMemSpyViewTypeHeapTracking,
+    EMemSpyViewTypeHeapTrackingSettings,
+    EMemSpyViewTypeHeapTrackingResults,
+    EMemSpyViewTypeHeapTrackingResultsCycleInfo,
+    EMemSpyViewTypeHeapTrackingResultsCycleChangeDescriptor,
+    EMemSpyViewTypeThreadInfoItemMemoryTracking,
+    EMemSpyViewTypeThreadInfoItemMemoryTrackingAutoStartConfig,
+    EMemSpyViewTypeThreadInfoItemMemoryTrackingStatistics,
+    EMemSpyViewTypeThreadInfoItemMemoryTrackingStatisticsCurrent,
+    EMemSpyViewTypeThreadInfoItemMemoryTrackingStatisticsHWM,
+    EMemSpyViewTypeThreadInfoItemMemoryTrackingStatisticsPeak,
+    EMemSpyViewTypeWindowGroups
+    };
+
+
+class MemSpyViewTypeUtils
+    {
+public:
+    static TBool IsOpenableItem( TMemSpyViewType aType );
+    static TBool IsThreadInfoItem( TMemSpyViewType aType );
+    static TBool IsExitableView( TMemSpyViewType aType );
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/MemSpyViewWindowGroups.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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 MEMSPYVIEWWINDOWGROUPS_H
+#define MEMSPYVIEWWINDOWGROUPS_H
+
+// System includes
+#include <hal.h>
+#include <coecntrl.h>
+#include <aknlists.h>
+
+// Engine includes
+#include <memspy/engine/memspyenginehelperwindowserver.h>
+
+// User includes
+#include "MemSpyViewBase.h"
+
+// Classes referenced
+
+
+class CMemSpyViewWindowGroups : public CMemSpyViewBase
+    {
+public:
+    CMemSpyViewWindowGroups( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver );
+    ~CMemSpyViewWindowGroups();
+    void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL );
+
+public: // From CMemSpyViewBase
+    CEikListBox* ConstructListBoxL();
+    void RefreshL();
+    TMemSpyViewType ViewType() const;
+    CMemSpyViewBase* PrepareParentViewL();
+    CMemSpyViewBase* PrepareChildViewL();
+
+public: // Menu framework
+    TUint MenuCascadeResourceId() const { return R_MEMSPY_MENUPANE_WINDOW_GROUPS; }
+    TInt MenuCascadeCommandId() const { return EMemSpyCmdWindowGroups; }
+
+private: // From CMemSpyViewBase
+    void SetListBoxModelL();
+    TBool HandleCommandL( TInt aCommand );
+
+private: // Command handlers
+    void OnCmdSwitchToL();
+    void OnCmdEndL( TInt aCommand );
+
+private: // Internal methods
+    void DetailsL();
+    void AppendFormatString( TPtr& aPtr, TRefByValue<const TDesC> aFmt, ... );
+
+private: // Data members
+    MMemSpyEngineWindowGroupList* iWindowGroupList;
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/include/viewcli.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,166 @@
+// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __VIEWCLI_H__
+#define __VIEWCLI_H__
+
+#include <e32base.h>
+#include <gdi.h>
+#include <vwsdef.h>
+
+//
+// Forward declarations.
+//
+
+class RVwsSession;
+class CVwsSessionEventHandler;
+class MVwsAppStarter;
+
+class MVwsSessionWrapperObserver
+/**
+The MVwsSessionObserver specifies an interface through which server events to be handled by the owner of
+a client session are notified
+
+@publishedAll 
+@deprecated
+*/
+//@internalTechnology @released
+
+	{
+public:	
+
+	/**
+	 * Handles the view event aEvent for a view added through the client session being observed.
+	 * Handles events for all the views added by the client.
+	 */
+	virtual void HandleViewEventL(const TVwsViewEvent& aEvent)=0;
+	};
+
+
+class CVwsSessionWrapper : public CBase
+/**
+The CVwsSessionWrapper class mediates access to the view server client session which it creates, and wraps in
+support for notification of server events. A session observer will be called back with server events if
+it maintains an outstanding request for asynchronous event notification.
+
+@publishedPartner 
+@released 
+*/
+//@internalTechnology @released
+
+	{
+public:	
+	IMPORT_C static CVwsSessionWrapper* NewL();
+	IMPORT_C static CVwsSessionWrapper* NewLC();
+	IMPORT_C static CVwsSessionWrapper* NewL(MVwsSessionWrapperObserver& aObserver);
+	IMPORT_C static CVwsSessionWrapper* NewLC(MVwsSessionWrapperObserver& aObserver);
+	IMPORT_C ~CVwsSessionWrapper();
+	IMPORT_C static TInt StartViewServer(MVwsAppStarter& aAppStarter);
+	IMPORT_C TInt ShutdownViewServer();
+	IMPORT_C TInt AddView(const TVwsViewId& aViewId);
+	IMPORT_C TInt RemoveView(const TVwsViewId& aViewId) const;
+	IMPORT_C TInt SetSystemDefaultView(const TVwsViewId& aViewId,TInt aMode);
+	IMPORT_C TInt SetSystemDefaultView(const TVwsViewId& aViewId);
+	IMPORT_C TInt ActivateView(const TVwsViewId& aViewId,TUid aCustomMessageId,const TDesC8& aCustomMessage);
+	IMPORT_C TInt ActivateViewViaViewEvent(const TVwsViewIdAndMessage& aViewIdAndMessage);
+	IMPORT_C TInt RequestCustomMessage(TDes8& aMessageBufPtr) const;
+	IMPORT_C void QueueAsyncRequest();
+	IMPORT_C TInt StartApp(TUid aAppToStart);
+	IMPORT_C TInt DeactivateActiveView();
+	IMPORT_C TInt DeactivateActiveViewIfOwnerMatch();
+	IMPORT_C TInt NotifyNextDeactivation(const TVwsViewId& aViewId);
+	IMPORT_C TInt NotifyNextDeactivation();
+	IMPORT_C TInt NotifyNextActivation(const TVwsViewId& aViewId);
+	IMPORT_C TInt NotifyNextActivation();
+	IMPORT_C TInt SetDefaultView(const TVwsViewId& aViewId,TInt aMode) const;
+	IMPORT_C TInt SetDefaultView(const TVwsViewId& aViewId) const;
+	IMPORT_C TInt GetSystemDefaultView(TVwsViewId& aViewId);
+	IMPORT_C TInt CreateActivateViewEvent(const TVwsViewId& aViewId,TUid aCustomMessageId,const TDesC8& aCustomMessage);
+	IMPORT_C TInt SetClientRequestTimeOut(TTimeIntervalMicroSeconds32 aDuration);
+	IMPORT_C TInt SetServerEventTimeOut(TTimeIntervalMicroSeconds32 aDuration);
+	IMPORT_C TInt EnableServerEventTimeOut(TBool aEnable);
+	IMPORT_C TInt CheckSourceOfViewSwitch(TBool& aResult,const TSecurityPolicy& aSecurityPolicy,const char* aDiagnostic);
+	IMPORT_C TInt EnableServerBlankScreen(TBool aEnable);
+	IMPORT_C TInt EnableExternalViewSwitches(TBool aEnable);
+	IMPORT_C void ActivateView(const TVwsViewId& aViewId,TUid aCustomMessageId,const TDesC8& aCustomMessage, TRequestStatus& aStatus);
+	IMPORT_C TInt SetCrossCheckUid(const TUid& aCrossCheckUid);
+	IMPORT_C TInt SetWindowBackgroundColor(const TRgb& aBgColor);
+public:	
+	/**
+	@internalComponent
+	@released
+	*/
+	IMPORT_C TInt ActivateView(const TVwsViewId& aViewId,TUid aCustomMessageId,const TDesC8& aCustomMessage, TInt aCustomControl);
+	/**
+	@internalComponent
+	@released
+	*/
+	IMPORT_C void ActivateView(const TVwsViewId& aViewId,TUid aCustomMessageId,const TDesC8& aCustomMessage, TRequestStatus& aStatus, TInt aCustomControl);
+	/**
+	@internalComponent
+	@released
+	*/IMPORT_C TInt CreateActivateViewEvent(const TVwsViewId& aViewId,TUid aCustomMessageId,const TDesC8& aCustomMessage, TInt aCustomControl);
+	/**
+	@internalComponent
+	@released
+	*/
+	IMPORT_C TInt GetCurrentActiveViewInSystem(TVwsViewId& aActiveViewId);
+private:
+	CVwsSessionWrapper();
+	CVwsSessionWrapper(MVwsSessionWrapperObserver& aObserver);
+	void ConstructL();
+	TInt CheckCreateViewServerSession();
+	TBool IsSchedulerRunning();
+private:
+	RVwsSession* iVwsSession;
+	CVwsSessionEventHandler* iViewEventHandler;
+	MVwsSessionWrapperObserver* iObserver;
+	};
+
+
+//
+// Panic.
+//
+/**
+@internalComponent
+*/
+enum TVwsPanic
+	{
+	EVwsCreateScheduler=1,
+	EVwsThreadRename
+	};
+
+/**
+@internalComponent
+*/
+GLREF_C void Panic(TVwsPanic aPanic);
+
+/**
+Server thread start.
+
+@internalComponent
+*/
+GLDEF_C TInt ViewServerThreadStart(TAny* aPtr);
+
+/**
+@internalComponent
+*/
+struct SVwsCommandLine
+	{
+	MVwsAppStarter* iAppStarter;
+	};
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/memspywindowserverhelper/bwins/memspywindowserverhelperu.def	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,13 @@
+EXPORTS
+	?WindowGroupListL@CMemSpyEngineHelperWindowServerImpl@@UAEPAVMMemSpyEngineWindowGroupList@@XZ @ 1 NONAME ; class MMemSpyEngineWindowGroupList * CMemSpyEngineHelperWindowServerImpl::WindowGroupListL(void)
+	?ItemIndex@CMemSpyEngineWindowGroupListImpl@@UBEHABVTMemSpyEngineWindowGroupBasicInfo@@@Z @ 2 NONAME ; int CMemSpyEngineWindowGroupListImpl::ItemIndex(class TMemSpyEngineWindowGroupBasicInfo const &) const
+	?NewMemSpyEngineHelperWindowServerImplL@@YAPAVMMemSpyEngineHelperWindowServer@@XZ @ 3 NONAME ; class MMemSpyEngineHelperWindowServer * NewMemSpyEngineHelperWindowServerImplL(void)
+	?MdcaPoint@CMemSpyEngineWindowGroupListImpl@@UBE?AVTPtrC16@@H@Z @ 4 NONAME ; class TPtrC16 CMemSpyEngineWindowGroupListImpl::MdcaPoint(int) const
+	?At@CMemSpyEngineWindowGroupListImpl@@UBEABVTMemSpyEngineWindowGroupBasicInfo@@H@Z @ 5 NONAME ; class TMemSpyEngineWindowGroupBasicInfo const & CMemSpyEngineWindowGroupListImpl::At(int) const
+	?GetWindowGroupListL@CMemSpyEngineHelperWindowServerImpl@@UAEXAAV?$RArray@VTMemSpyEngineWindowGroupBasicInfo@@@@@Z @ 6 NONAME ; void CMemSpyEngineHelperWindowServerImpl::GetWindowGroupListL(class RArray<class TMemSpyEngineWindowGroupBasicInfo> &)
+	?Count@CMemSpyEngineWindowGroupListImpl@@UBEHXZ @ 7 NONAME ; int CMemSpyEngineWindowGroupListImpl::Count(void) const
+	?SwitchToL@CMemSpyEngineHelperWindowServerImpl@@UAEXH@Z @ 8 NONAME ; void CMemSpyEngineHelperWindowServerImpl::SwitchToL(int)
+	?GetWindowGroupDetailsL@CMemSpyEngineHelperWindowServerImpl@@UAEXHAAVTMemSpyEngineWindowGroupDetails@@@Z @ 9 NONAME ; void CMemSpyEngineHelperWindowServerImpl::GetWindowGroupDetailsL(int, class TMemSpyEngineWindowGroupDetails &)
+	?NewL@CMemSpyEngineHelperWindowServerImpl@@SAPAV1@XZ @ 10 NONAME ; class CMemSpyEngineHelperWindowServerImpl * CMemSpyEngineHelperWindowServerImpl::NewL(void)
+	?MdcaCount@CMemSpyEngineWindowGroupListImpl@@UBEHXZ @ 11 NONAME ; int CMemSpyEngineWindowGroupListImpl::MdcaCount(void) const
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/memspywindowserverhelper/eabi/memspywindowserverhelperu.def	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,22 @@
+EXPORTS
+	_Z38NewMemSpyEngineHelperWindowServerImplLv @ 1 NONAME
+	_ZN35CMemSpyEngineHelperWindowServerImpl16WindowGroupListLEv @ 2 NONAME
+	_ZN35CMemSpyEngineHelperWindowServerImpl19GetWindowGroupListLER6RArrayI33TMemSpyEngineWindowGroupBasicInfoE @ 3 NONAME
+	_ZN35CMemSpyEngineHelperWindowServerImpl22GetWindowGroupDetailsLEiR31TMemSpyEngineWindowGroupDetails @ 4 NONAME
+	_ZN35CMemSpyEngineHelperWindowServerImpl4NewLEv @ 5 NONAME
+	_ZN35CMemSpyEngineHelperWindowServerImpl9SwitchToLEi @ 6 NONAME
+	_ZNK32CMemSpyEngineWindowGroupListImpl2AtEi @ 7 NONAME
+	_ZNK32CMemSpyEngineWindowGroupListImpl5CountEv @ 8 NONAME
+	_ZNK32CMemSpyEngineWindowGroupListImpl9ItemIndexERK33TMemSpyEngineWindowGroupBasicInfo @ 9 NONAME
+	_ZNK32CMemSpyEngineWindowGroupListImpl9MdcaCountEv @ 10 NONAME
+	_ZNK32CMemSpyEngineWindowGroupListImpl9MdcaPointEi @ 11 NONAME
+	_ZThn4_N35CMemSpyEngineHelperWindowServerImpl16WindowGroupListLEv @ 12 NONAME
+	_ZThn4_N35CMemSpyEngineHelperWindowServerImpl19GetWindowGroupListLER6RArrayI33TMemSpyEngineWindowGroupBasicInfoE @ 13 NONAME
+	_ZThn4_N35CMemSpyEngineHelperWindowServerImpl22GetWindowGroupDetailsLEiR31TMemSpyEngineWindowGroupDetails @ 14 NONAME
+	_ZThn4_N35CMemSpyEngineHelperWindowServerImpl9SwitchToLEi @ 15 NONAME
+	_ZThn4_NK32CMemSpyEngineWindowGroupListImpl2AtEi @ 16 NONAME
+	_ZThn4_NK32CMemSpyEngineWindowGroupListImpl5CountEv @ 17 NONAME
+	_ZThn4_NK32CMemSpyEngineWindowGroupListImpl9ItemIndexERK33TMemSpyEngineWindowGroupBasicInfo @ 18 NONAME
+	_ZThn4_NK32CMemSpyEngineWindowGroupListImpl9MdcaCountEv @ 19 NONAME
+	_ZThn4_NK32CMemSpyEngineWindowGroupListImpl9MdcaPointEi @ 20 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/memspywindowserverhelper/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  Build information file for MemSpyWindowServerHelper
+*
+*/
+
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+memspywindowserverhelper.mmp
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/memspywindowserverhelper/group/memspywindowserverhelper.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DLL implementing the MMemSpyEngineHelperWindowServer Interface
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          memspywindowserverhelper.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x20028783
+VENDORID        VID_DEFAULT
+SMPSAFE
+
+CAPABILITY      ALL -TCB
+
+SOURCEPATH      ../src
+SOURCE          MemSpyEngineHelperWindowServerImpl.cpp
+
+USERINCLUDE     ../inc
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY         euser.lib
+LIBRARY			ws32.lib apgrfx.lib
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/memspywindowserverhelper/inc/MemSpyEngineHelperWindowServerImpl.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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:
+*
+*/
+
+#ifndef MEMSPYENGINEHELPERWINDOWSERVERIMPL_H
+#define MEMSPYENGINEHELPERWINDOWSERVERIMPL_H
+
+// System includes
+#include <e32base.h>
+#include <w32std.h>
+
+
+// User includes
+#include <memspy/engine/memspyenginehelperwindowserver.h>
+
+
+// Classes referenced
+
+
+NONSHARABLE_CLASS( CMemSpyEngineHelperWindowServerImpl ) : public CBase, public MMemSpyEngineHelperWindowServer
+    {
+public:
+    IMPORT_C static CMemSpyEngineHelperWindowServerImpl* NewL();
+    virtual ~CMemSpyEngineHelperWindowServerImpl();
+
+private:
+    CMemSpyEngineHelperWindowServerImpl();
+    void ConstructL();
+
+public: // API
+    IMPORT_C MMemSpyEngineWindowGroupList* WindowGroupListL();
+    IMPORT_C void GetWindowGroupListL( RArray<TMemSpyEngineWindowGroupBasicInfo>& aWindowGroups );
+    IMPORT_C void GetWindowGroupDetailsL( TInt aWindowGroupId, TMemSpyEngineWindowGroupDetails& aWindowGroupDetails );
+    IMPORT_C void SwitchToL( TInt aWindowGroupId );
+
+private:
+    RWsSession iWsSession;
+    };
+
+
+
+
+NONSHARABLE_CLASS( CMemSpyEngineWindowGroupListImpl ) : public CBase, public MMemSpyEngineWindowGroupList
+    {
+public:
+    static CMemSpyEngineWindowGroupListImpl* NewLC();
+    virtual ~CMemSpyEngineWindowGroupListImpl();
+    
+private:
+    CMemSpyEngineWindowGroupListImpl();
+    void ConstructL();
+
+public: // API
+    IMPORT_C TInt Count() const;
+    IMPORT_C const TMemSpyEngineWindowGroupBasicInfo& At( TInt aIndex ) const;
+    IMPORT_C TInt ItemIndex( const TMemSpyEngineWindowGroupBasicInfo& aEntry ) const;
+
+public: // But not exported
+    void AddItemL( TMemSpyEngineWindowGroupBasicInfo& aItem );
+
+public: // From MDesCArray
+    IMPORT_C TInt MdcaCount() const;
+    IMPORT_C TPtrC MdcaPoint( TInt aIndex ) const;
+
+private: // Data members
+    RArray<TMemSpyEngineWindowGroupBasicInfo> iItems;
+    };
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/memspywindowserverhelper/src/MemSpyEngineHelperWindowServerImpl.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,232 @@
+/*
+* 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 "MemSpyEngineHelperWindowServerImpl.h"
+
+// System includes
+#include <apgwgnam.h>
+#include <apgtask.h>
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+EXPORT_C MMemSpyEngineHelperWindowServer* NewMemSpyEngineHelperWindowServerImplL()
+    {
+    return CMemSpyEngineHelperWindowServerImpl::NewL();
+    }
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+CMemSpyEngineHelperWindowServerImpl::CMemSpyEngineHelperWindowServerImpl()
+    {
+    }
+
+    
+CMemSpyEngineHelperWindowServerImpl::~CMemSpyEngineHelperWindowServerImpl()
+    {
+    iWsSession.Close();
+    }
+
+
+void CMemSpyEngineHelperWindowServerImpl::ConstructL()
+    {
+    User::LeaveIfError( iWsSession.Connect() );
+    }
+
+
+EXPORT_C CMemSpyEngineHelperWindowServerImpl* CMemSpyEngineHelperWindowServerImpl::NewL()
+    {
+    CMemSpyEngineHelperWindowServerImpl* self = new(ELeave) CMemSpyEngineHelperWindowServerImpl();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+EXPORT_C MMemSpyEngineWindowGroupList* CMemSpyEngineHelperWindowServerImpl::WindowGroupListL()
+    {
+    CMemSpyEngineWindowGroupListImpl* list = CMemSpyEngineWindowGroupListImpl::NewLC();
+    //
+    RArray<TMemSpyEngineWindowGroupBasicInfo> groups;
+    CleanupClosePushL( groups );
+    //
+    GetWindowGroupListL( groups );
+    //
+    const TInt count = groups.Count();
+    for( TInt i = 0; i < count; i++ )
+        {
+        list->AddItemL( groups[ i ] );
+        }
+    //
+    CleanupStack::PopAndDestroy( &groups );
+
+    // Done
+    CleanupStack::Pop( list );
+    return list;
+    }
+
+
+EXPORT_C void CMemSpyEngineHelperWindowServerImpl::GetWindowGroupListL( RArray<TMemSpyEngineWindowGroupBasicInfo>& aWindowGroups )
+    {
+    TInt count;
+    User::LeaveIfError( count = iWsSession.NumWindowGroups() );
+    RArray<RWsSession::TWindowGroupChainInfo> array;
+    CleanupClosePushL( array );
+    User::LeaveIfError( iWsSession.WindowGroupList( &array ) );
+    for (TInt i =0; i < count; i++ )
+        {
+        TMemSpyEngineWindowGroupBasicInfo group;
+        group.iId = array[i].iId;
+        TThreadId threadId;
+        RThread thread;
+        iWsSession.GetWindowGroupClientThreadId( array[i].iId, threadId );
+        group.iThreadId = threadId;
+        group.iOrdinalPosition = i;
+        if ( !thread.Open( threadId ) )
+            {
+            _LIT( KLineFormatSpec, "%d\t%S" );
+            group.iFullName.Format( KLineFormatSpec, group.iId, &thread.Name() );
+            }
+        else
+            {
+            _LIT( KLineFormatSpec, "%d\t<Unresolved name>" );
+            group.iFullName.Format( KLineFormatSpec, group.iId );
+            }
+        thread.Close();        
+        aWindowGroups.AppendL( group );
+        }
+    CleanupStack::PopAndDestroy( &array );
+    }
+
+
+EXPORT_C void CMemSpyEngineHelperWindowServerImpl::GetWindowGroupDetailsL( TInt aWindowGroupId, TMemSpyEngineWindowGroupDetails& aWindowGroupDetails )
+    {
+    TThreadId threadId;
+    RThread thread;
+    iWsSession.GetWindowGroupClientThreadId( aWindowGroupId, threadId );
+    aWindowGroupDetails.iThreadId = threadId;
+    aWindowGroupDetails.iId = aWindowGroupId;
+    if ( !thread.Open( threadId ) )
+        {
+        aWindowGroupDetails.iFullName.Copy( thread.Name() );
+        }
+    else
+        {
+        aWindowGroupDetails.iFullName.Copy( _L("<Unresolved name>") );
+        }
+    thread.Close();
+    aWindowGroupDetails.iPriority = iWsSession.GetWindowGroupOrdinalPriority( aWindowGroupId );
+    aWindowGroupDetails.iWindowGroupHandle = iWsSession.GetWindowGroupHandle( aWindowGroupId );
+    CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC( iWsSession, aWindowGroupId );
+    aWindowGroupDetails.iUID = wgName->AppUid();
+    aWindowGroupDetails.iIsBusy = wgName->IsBusy();
+    aWindowGroupDetails.iIsSystem = wgName->IsSystem();
+    aWindowGroupDetails.iIsHidden = wgName->Hidden();
+    aWindowGroupDetails.iCaption = wgName->Caption();
+    aWindowGroupDetails.iDocName = wgName->DocName();
+    CleanupStack::PopAndDestroy( wgName );
+    }
+        
+
+EXPORT_C void CMemSpyEngineHelperWindowServerImpl::SwitchToL( TInt aWindowGroupId )
+    {
+    TApaTask task( iWsSession );
+    CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC( iWsSession, aWindowGroupId );
+    task.SetWgId( aWindowGroupId );
+    if ( wgName->Hidden() )
+        {
+        User::Leave( KErrGeneral );
+        }
+    if ( !task.Exists() )
+        {
+        User::Leave( KErrNotFound );
+        }
+    task.BringToForeground();                     
+    CleanupStack::PopAndDestroy( wgName );
+    }
+
+
+
+
+
+
+
+
+        
+CMemSpyEngineWindowGroupListImpl::CMemSpyEngineWindowGroupListImpl()
+    {
+    }
+
+
+CMemSpyEngineWindowGroupListImpl::~CMemSpyEngineWindowGroupListImpl()
+    {
+    iItems.Close();
+    }
+
+
+void CMemSpyEngineWindowGroupListImpl::ConstructL()
+    {
+    }
+
+
+CMemSpyEngineWindowGroupListImpl* CMemSpyEngineWindowGroupListImpl::NewLC()
+    {
+    CMemSpyEngineWindowGroupListImpl* self = new(ELeave) CMemSpyEngineWindowGroupListImpl();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+EXPORT_C TInt CMemSpyEngineWindowGroupListImpl::Count() const
+    {
+    return iItems.Count();
+    }
+
+
+EXPORT_C const TMemSpyEngineWindowGroupBasicInfo& CMemSpyEngineWindowGroupListImpl::At( TInt aIndex ) const
+    {
+    return iItems[ aIndex ];
+    }
+
+
+EXPORT_C TInt CMemSpyEngineWindowGroupListImpl::ItemIndex( const TMemSpyEngineWindowGroupBasicInfo& /*aEntry*/ ) const
+    {
+    TInt ret = KErrNotFound;
+    return ret;
+    }
+
+
+void CMemSpyEngineWindowGroupListImpl::AddItemL( TMemSpyEngineWindowGroupBasicInfo& aItem )
+    {
+    iItems.AppendL( aItem );
+    }
+
+
+EXPORT_C TInt CMemSpyEngineWindowGroupListImpl::MdcaCount() const
+    {
+    return Count();
+    }
+
+
+EXPORT_C TPtrC CMemSpyEngineWindowGroupListImpl::MdcaPoint( TInt aIndex ) const
+    {
+    return TPtrC( At( aIndex ).iFullName );
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/rom/memspyui.iby	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef MEMSPYUI_IBY
+#define MEMSPYUI_IBY
+
+
+S60_APP_EXE(MemSpyUI)
+S60_APP_AIF_ICONS(MemSpyUI)
+S60_APP_RESOURCE(MemSpyUI)
+#ifdef S60_UPGRADABLE_APP_REG_RSC
+  S60_UPGRADABLE_APP_REG_RSC(MemSpyUI)
+#else
+  S60_APP_AIF_RSC(MemSpyUI)
+#endif
+
+
+data=ZPRIVATE\2002129F\MemSpyEComInterfaceIds.xml							\private\2002129F\MemSpyEComInterfaceIds.xml
+data=ZPRIVATE\2002129F\MemSpyProcessMemoryTrackingAutoStartConfig.xml		\private\2002129F\MemSpyProcessMemoryTrackingAutoStartConfig.xml
+
+// Stub SIS
+data=ZSYSTEM\Install\MemSpy_stub.sis                                        \system\install\MemSpy_stub.sis
+
+// MemSpyWindowServerHelper
+file=ABI_DIR\BUILD_DIR\memspywindowserverhelper.dll							SHARED_LIB_DIR\memspywindowserverhelper.dll
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/sis/MemSpy_S60-50.pkg	Tue Feb 02 00:17:27 2010 +0200
@@ -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:
+;
+
+
+; Language - standard language definitions
+&EN
+
+; Standard SIS file header
+#{"MemSpy"},(0x2002129F),1,2,0,TYPE=SA
+
+; Supports S60 v 5.0
+[0x1028315F], 0, 0, 0, {"S60ProductID"}
+
+; Non-localised vendor name
+:"Nokia Corporation"
+
+; Localised vendor names
+%{"Nokia Corporation"}
+
+; Engine:
+"\epoc32\release\armv5\urel\MemSpyDriver.ldd"-"!:\sys\bin\MemSpyDriver.ldd"
+"\epoc32\release\armv5\urel\MemSpyDriverClient.dll"-"!:\sys\bin\MemSpyDriverClient.dll"
+"\epoc32\release\armv5\urel\MemSpyEngine.dll"-"!:\sys\bin\MemSpyEngine.dll"
+"\epoc32\release\armv5\urel\MemSpy.exe"-"!:\sys\bin\MemSpy.exe"
+"\epoc32\release\armv5\urel\MemSpyConsole.exe"-"!:\sys\bin\MemSpyConsole.exe"
+"\epoc32\data\z\private\2002129E\MemSpyEComInterfaceIds.xml"-"c:\private\2002129E\MemSpyEComInterfaceIds.xml"
+"\epoc32\data\z\private\2002129E\MemSpyProcessMemoryTrackingAutoStartConfig.xml"-"c:\private\2002129E\MemSpyProcessMemoryTrackingAutoStartConfig.xml"
+
+; UI:
+"\epoc32\release\armv5\urel\MemSpyUI.exe"-"!:\sys\bin\MemSpyUI.exe"
+"\epoc32\data\z\Resource\apps\MemSpyUI_aif.mif"-"!:\Resource\Apps\MemSpyUI_aif.mif"
+"\epoc32\data\z\Resource\apps\MemSpyUI.rsc"-"!:\Resource\Apps\MemSpyUI.rsc"
+"\epoc32\data\z\private\10003A3F\apps\MemSpyUI_reg.rsc"-"!:\private\10003a3f\import\apps\MemSpyUI_reg.rsc"
+"\epoc32\data\z\private\2002129F\MemSpyEComInterfaceIds.xml"-"c:\private\2002129F\MemSpyEComInterfaceIds.xml"
+"\epoc32\data\z\private\2002129F\MemSpyProcessMemoryTrackingAutoStartConfig.xml"-"c:\private\2002129F\MemSpyProcessMemoryTrackingAutoStartConfig.xml"
+"\epoc32\release\armv5\urel\memspywindowserverhelper.dll"-"!:\sys\bin\memspywindowserverhelper.dll"
Binary file memspyui/sis/MemSpy_S60-50.sis has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/sis/MemSpy_S60-52.pkg	Tue Feb 02 00:17:27 2010 +0200
@@ -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:
+;
+
+
+; Language - standard language definitions
+&EN
+
+; Standard SIS file header
+#{"MemSpy"},(0x2002129F),1,2,0,TYPE=SA
+
+; Supports S60 v 5.2
+[0x20022E6D], 0, 0, 0, {"S60ProductID"}
+
+; Non-localised vendor name
+:"Nokia Corporation"
+
+; Localised vendor names
+%{"Nokia Corporation"}
+
+; Engine:
+"\epoc32\release\armv5\urel\MemSpyDriver.ldd"-"!:\sys\bin\MemSpyDriver.ldd"
+"\epoc32\release\armv5\urel\MemSpyDriverClient.dll"-"!:\sys\bin\MemSpyDriverClient.dll"
+"\epoc32\release\armv5\urel\MemSpyEngine.dll"-"!:\sys\bin\MemSpyEngine.dll"
+"\epoc32\release\armv5\urel\MemSpy.exe"-"!:\sys\bin\MemSpy.exe"
+"\epoc32\release\armv5\urel\MemSpyConsole.exe"-"!:\sys\bin\MemSpyConsole.exe"
+"\epoc32\data\z\private\2002129E\MemSpyEComInterfaceIds.xml"-"c:\private\2002129E\MemSpyEComInterfaceIds.xml"
+"\epoc32\data\z\private\2002129E\MemSpyProcessMemoryTrackingAutoStartConfig.xml"-"c:\private\2002129E\MemSpyProcessMemoryTrackingAutoStartConfig.xml"
+
+; UI:
+"\epoc32\release\armv5\urel\MemSpyUI.exe"-"!:\sys\bin\MemSpyUI.exe"
+"\epoc32\data\z\Resource\apps\MemSpyUI_aif.mif"-"!:\Resource\Apps\MemSpyUI_aif.mif"
+"\epoc32\data\z\Resource\apps\MemSpyUI.rsc"-"!:\Resource\Apps\MemSpyUI.rsc"
+"\epoc32\data\z\private\10003A3F\apps\MemSpyUI_reg.rsc"-"!:\private\10003a3f\import\apps\MemSpyUI_reg.rsc"
+"\epoc32\data\z\private\2002129F\MemSpyEComInterfaceIds.xml"-"c:\private\2002129F\MemSpyEComInterfaceIds.xml"
+"\epoc32\data\z\private\2002129F\MemSpyProcessMemoryTrackingAutoStartConfig.xml"-"c:\private\2002129F\MemSpyProcessMemoryTrackingAutoStartConfig.xml"
+"\epoc32\release\armv5\urel\memspywindowserverhelper.dll"-"!:\sys\bin\memspywindowserverhelper.dll"
Binary file memspyui/sis/MemSpy_S60-52.sis has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/sis/MemSpy_stub.pkg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,46 @@
+;
+; 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:
+;
+
+
+; Language - standard language definitions
+&EN
+
+; Standard SIS file header
+#{"MemSpyUI"},(0x2002129F),1,0,0
+
+; Non-localised vendor name
+:"Nokia Corporation"
+
+; Localised vendor names
+%{"Nokia Corporation"}
+
+; Engine:
+""-"z:\sys\bin\MemSpyDriver.ldd"
+""-"z:\sys\bin\MemSpyDriverClient.dll"
+""-"z:\sys\bin\MemSpyEngine.dll"
+""-"z:\sys\bin\MemSpy.exe"
+""-"z:\sys\bin\MemSpyConsole.exe"
+""-"z:\private\2002129E\MemSpyEComInterfaceIds.xml"
+""-"z:\private\2002129E\MemSpyProcessMemoryTrackingAutoStartConfig.xml"
+
+; UI:
+""-"z:\sys\bin\MemSpyUI.exe"
+""-"z:\Resource\Apps\MemSpyUI_aif.mif"
+""-"z:\Resource\Apps\MemSpyUI.rsc"
+""-"z:\private\10003a3f\import\apps\MemSpyUI_reg.rsc"
+""-"z:\private\2002129F\MemSpyEComInterfaceIds.xml"
+""-"z:\private\2002129F\MemSpyProcessMemoryTrackingAutoStartConfig.xml"
+""-"z:\sys\bin\memspywindowserverhelper.dll"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyApp.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,50 @@
+/*
+* 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 "MemSpyApp.h"
+
+// System includes
+#include <eikstart.h>
+
+// User includes
+#include "MemSpyDocument.h"
+
+
+
+TUid CMemSpyApp::AppDllUid() const
+    {
+    return KUidMemSpy;
+    }
+
+
+CApaDocument* CMemSpyApp::CreateDocumentL()
+    {
+    return CMemSpyDocument::NewL( *this );
+    }
+
+
+EXPORT_C CApaApplication* NewApplication()
+    {
+    return new CMemSpyApp;
+    }
+
+
+GLDEF_C TInt E32Main()
+    {
+    return EikStart::RunApplication(NewApplication);
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyAppUi.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,721 @@
+/*
+* 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 "MemSpyAppUi.h"
+
+// System includes
+#include <AknQueryDialog.h>
+#include <aknmessagequerydialog.h> 
+#include <aknradiobuttonsettingpage.h>
+#include <eikaufty.h>
+#include <eikmenub.h>
+#include <avkon.hrh>
+#include <barsread.h>
+#include <f32file.h>
+#include <apgtask.h>
+#include <memspyui.rsg>
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineoutputsink.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyenginehelperchunk.h>
+#include <memspy/engine/memspyenginehelperthread.h>
+#include <memspy/engine/memspyenginehelperprocess.h>
+#include <memspy/engine/memspyenginehelperkernelcontainers.h>
+#include <memspy/engine/memspyenginehelperfbserv.h>
+#include <memspyengineclientinterface.h>
+#include <memspy/driver/memspydriverenumerationsshared.h>
+#include <memspy/engine/memspyenginehelperkernelcontainers.h>
+
+// User includes
+#include "MemSpyContainer.h"
+#include "MemSpyDocument.h"
+#include "MemSpySettings.h"
+#include "MemSpyDeviceWideOperationDialog.h"
+#include "MemSpyViewRAMInfo.h" // for aknicon config check
+#include "MemSpyExportBitmapsToMemoryCardDialog.h"
+#include "MemSpy.hrh"
+#include "viewcli.h"
+
+// Constants
+const TInt KMemSpyDefaultAutoCaptureTimerPeriod = 60;
+const TUint32 KMemSpyEikSrvSID = 0x10003a4a;
+
+
+CMemSpyAppUi::CMemSpyAppUi( CMemSpyEngine& aEngine )
+:   iEngine( aEngine ), iAutoCaptureTimerPeriod( KMemSpyDefaultAutoCaptureTimerPeriod ), iAutoCaptureOperationType( CMemSpyDeviceWideOperations::EPerEntityHeapInfo )
+    {
+    iEngine.SetObserver( this );
+    }
+
+
+CMemSpyAppUi::~CMemSpyAppUi()
+    {
+    RDebug::Printf( "[MemSpy] MemSpy is now closing." );
+    //
+    delete iAutoCaptureTimer;
+    //
+    if (iAppContainer)
+        {
+        RemoveFromStack( iAppContainer );
+        delete iAppContainer;
+        }
+    //
+    iEngine.SetObserver( NULL );
+    SetViewServerTimeOutStatus( ETrue );
+    }
+
+
+void CMemSpyAppUi::ConstructL()
+    {
+    BaseConstructL( EAknEnableSkin );
+    //
+    iAppContainer = new (ELeave) CMemSpyContainer( iEngine, *this );
+    iAppContainer->SetMopParent(this);
+    iAppContainer->ConstructL( ClientRect() );
+    iAppContainer->SetObserver( this );
+    iAppContainer->SetFocus( ETrue );
+    AddToStackL( iAppContainer );
+    //
+    iAutoCaptureTimer = CPeriodic::NewL( CActive::EPriorityIdle );
+	//
+	iEikonEnv->SetSystem( ETrue );
+    //
+    SetViewServerTimeOutStatus( EFalse );
+    }
+
+
+CMemSpyDocument& CMemSpyAppUi::MemSpyDocument()
+    {
+	CMemSpyDocument* doc = static_cast< CMemSpyDocument* >( Document() );
+    return *doc;
+    }
+
+
+const CMemSpyDocument& CMemSpyAppUi::MemSpyDocument() const
+    {
+	const CMemSpyDocument* doc = static_cast< const CMemSpyDocument* >( Document() );
+    return *doc;
+    }
+
+
+void CMemSpyAppUi::HandleStatusPaneSizeChange()
+	{
+	iAppContainer->SetRect( ClientRect() );
+	} 
+
+
+void CMemSpyAppUi::HandleControlEventL( CCoeControl* aControl, TCoeEvent /*aEventType*/ )
+    {
+    if  ( aControl == iAppContainer )
+        {
+        UpdateCBAL();
+        }
+    }
+
+
+void CMemSpyAppUi::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
+    {
+    CMemSpyViewBase& view = iAppContainer->ActiveView();
+    const TMemSpyViewType viewType = iAppContainer->ActiveViewType();
+    //
+    const TBool openableView = MemSpyViewTypeUtils::IsOpenableItem( viewType );
+    const TBool exitable = MemSpyViewTypeUtils::IsExitableView( viewType );
+    //
+#ifdef _DEBUG
+    RDebug::Printf( "[MemSpy] CMemSpyAppUi::DynInitMenuPaneL() - START - aResourceId: 0x%08x (%8d), iAutoCaptureOperationType: %d, iAutoCaptureTimer is active: %d, viewType: %d, openableView: %d, exitable: %d", aResourceId, aResourceId, iAutoCaptureOperationType, iAutoCaptureTimer->IsActive(), viewType, openableView, exitable );
+#endif
+    //
+    if  ( aResourceId == R_MEMSPY_MENUPANE )
+        {
+        const TInt count = aMenuPane->NumberOfItemsInPane();
+        for( TInt i=0; i<count; i++ )
+            {
+            TBool dimItem = EFalse;
+            CEikMenuPaneItem::SData& menuPaneMetaData = aMenuPane->ItemDataByIndexL( i );
+
+            // If the command is inside the view-specific range then we'll hide it
+            // unless the view and command id matches.
+            const TBool isViewSpecific = ( menuPaneMetaData.iCommandId >= KMemSpyMenuCommandViewSpecific );
+            if  ( isViewSpecific )
+                {
+                // Check whether this view requires this command item.
+                dimItem = ( view.MenuCascadeCommandId() != menuPaneMetaData.iCommandId );
+                }
+
+            aMenuPane->SetItemDimmed( menuPaneMetaData.iCommandId, dimItem );
+            }
+
+        aMenuPane->SetItemDimmed( EMemSpyCmdOpen, !openableView );
+        aMenuPane->SetItemDimmed( EAknSoftkeyBack, exitable );
+        aMenuPane->SetItemDimmed( EAknCmdExit, !exitable );
+        }
+    else if ( aResourceId == R_MEMSPY_MENUPANE_TOOLS )
+        {
+        const TBool inOpenFilesView = ( viewType == EMemSpyViewTypeOpenFiles );
+        aMenuPane->SetItemDimmed( EMemSpyCmdToolsListOpenFiles, !inOpenFilesView );
+        }
+    else if ( aResourceId == R_MEMSPY_MENUPANE_VIEW )
+        {
+        // Hide the refresh item when in the thread info container view
+        aMenuPane->SetItemDimmed( EMemSpyCmdViewRefresh, viewType == EMemSpyViewTypeThreadInfoItemList );
+        aMenuPane->SetItemDimmed( EMemSpyCmdViewOutputToSink, viewType == EMemSpyViewTypeThreadInfoItemList );
+        }
+    else if ( aResourceId == R_MEMSPY_MENUPANE_OUTPUT )
+        {
+        const TMemSpySinkType currentSink = iEngine.SinkType();
+        aMenuPane->SetItemDimmed( EMemSpyCmdOutputToDebug, currentSink == ESinkTypeDebug );
+        aMenuPane->SetItemDimmed( EMemSpyCmdOutputToFile, currentSink == ESinkTypeFile );
+        }
+    else if ( aResourceId == R_MEMSPY_MENUPANE_AUTO_CAPTURE )
+        {
+        // Change the auto-capture toggle caption appropriately...
+        TInt resId = R_MEMSPY_AUTO_CAPTURE_ENABLE;
+        if  ( iAutoCaptureTimer->IsActive() )
+            {
+            resId = R_MEMSPY_AUTO_CAPTURE_DISABLE;
+            }
+        aMenuPane->SetItemTextL( EMemSpyCmdAutoCaptureToggle, resId );
+        }
+
+#ifdef _DEBUG
+    RDebug::Printf( "[MemSpy] CMemSpyAppUi::DynInitMenuPaneL() - sending to view..." );
+#endif
+
+    view.DynInitMenuPaneL( aResourceId, aMenuPane );
+
+#ifdef _DEBUG
+    RDebug::Printf( "[MemSpy] CMemSpyAppUi::DynInitMenuPaneL() - END - aResourceId: 0x%08x (%8d), iAutoCaptureOperationType: %d, iAutoCaptureTimer is active: %d, viewType: %d, openableView: %d, exitable: %d", aResourceId, aResourceId, iAutoCaptureOperationType, iAutoCaptureTimer->IsActive(), viewType, openableView, exitable );
+#endif
+    }
+
+
+TKeyResponse CMemSpyAppUi::HandleKeyEventL( const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/ )
+    {
+    return EKeyWasNotConsumed;
+    }
+
+
+void CMemSpyAppUi::HandleCommandL( TInt aCommand )
+    {
+#ifdef _DEBUG
+    RDebug::Printf( "[MemSpy] CMemSpyAppUi::HandleCommandL() - START - aCommand: %8d, iAutoCaptureOperationType: %d, iAutoCaptureTimer is active: %d", aCommand, iAutoCaptureOperationType, iAutoCaptureTimer->IsActive() );
+#endif
+
+    switch ( aCommand )
+        {
+    case EAknSoftkeyBack:
+        OnCmdBackL();
+        break;
+
+    case EEikCmdExit:
+    case EAknCmdExit:
+    case EAknSoftkeyExit:
+        OnCmdExitL();
+        break;
+
+    case EMemSpyCmdOpen:
+        OnCmdOpenL();
+        break;
+
+    case EMemSpyCmdOutputToDebug:
+        OnCmdOutputToDebugL();
+		break;
+    case EMemSpyCmdOutputToFile:
+        OnCmdOutputToFileL();
+		break;
+
+    case EMemSpyCmdToolsAbout:
+        OnCmdAboutL();
+        break;
+    //
+    case EMemSpyCmdPhoneInfoGeneralSummary:
+        OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityGeneralSummary );
+        break;
+    case EMemSpyCmdPhoneInfoGeneralDetailed:
+        OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityGeneralDetailed );
+        break;
+    case EMemSpyCmdPhoneInfoGeneralHandles:
+        OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityGeneralHandles );
+        break;
+    case EMemSpyCmdPhoneInfoGeneralKernelContainers:
+        OnCmdPhoneInformationOperationKernelContainersL();
+        break;
+    //
+    case EMemSpyCmdPhoneInfoHeapInfoSummary:
+        OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityHeapInfo );
+        break;
+    case EMemSpyCmdPhoneInfoHeapInfoCompact:
+        OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EEntireDeviceHeapInfoCompact );
+        break;
+    case EMemSpyCmdPhoneInfoHeapCellListing:
+        OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityHeapCellListing );
+        break;
+    case EMemSpyCmdPhoneInfoHeapDump:
+        OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityHeapData );
+        break;
+    //
+    case EMemSpyCmdPhoneInfoStackInfo:
+        OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityStackInfo );
+        break;
+    case EMemSpyCmdPhoneInfoStackInfoCompact:
+        OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EEntireDeviceStackInfoCompact );
+        break;
+    case EMemSpyCmdPhoneInfoStackDumpUser:
+        OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityStackDataUser );
+        break;
+    case EMemSpyCmdPhoneInfoStackDumpKernel:
+        OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityStackDataKernel );
+        break;
+
+    case EMemSpyCmdAutoCaptureToggle:
+        OnCmdAutoCaptureToggleL();
+        break;
+    case EMemSpyCmdAutoCaptureRetryTime:
+        OnCmdAutoCaptureRetryTimeL();
+        break;
+    case EMemSpyCmdAutoCaptureOperationType:
+        OnCmdAutoCaptureOperationTypeL();
+        break;
+
+    default:
+        iAppContainer->HandleCommandL( aCommand );
+        break;
+        }
+
+#ifdef _DEBUG
+    RDebug::Printf( "[MemSpy] CMemSpyAppUi::HandleCommandL() - END - aCommand: %8d, iAutoCaptureOperationType: %d, iAutoCaptureTimer is active: %d", aCommand, iAutoCaptureOperationType, iAutoCaptureTimer->IsActive() );
+#endif
+    }
+
+
+void CMemSpyAppUi::HandleForegroundEventL( TBool aForeground)
+    {
+    // Refresh the container when coming to the foreground
+    if  ( aForeground )
+        {
+        iAppContainer->OnCmdViewRefreshL();
+        }
+    }
+
+
+void CMemSpyAppUi::HandleThreadSelectedL( const CMemSpyThread& /*aThread*/ )
+    {
+	MEikAppUiFactory* appUiFactory = (iEikonEnv)->AppUiFactory();
+    appUiFactory->MenuBar()->TryDisplayMenuBarL();
+    }
+
+
+void CMemSpyAppUi::HandleMemSpyEngineEventL( MMemSpyEngineObserver::TEvent aEvent, TAny* aContext )
+    {
+    if  ( aEvent == MMemSpyEngineObserver::EHandleThreadsOrProcessesChanged )
+        {
+        // Get the original container
+        const CMemSpyEngineObjectContainer& oldContainer = *reinterpret_cast< CMemSpyEngineObjectContainer* >( aContext );
+        (void) oldContainer;
+
+        // Refresh the container
+        iAppContainer->OnCmdViewRefreshL();
+        }
+    else if ( aEvent == MMemSpyEngineObserver::EHandleClientServerOperationRequest )
+        {
+        const TInt function = reinterpret_cast<TInt>( aContext );
+        InitiateMemSpyClientServerOperationL( function );
+        }
+    }
+
+
+void CMemSpyAppUi::DWOperationStarted()
+    {
+#ifdef _DEBUG
+    RDebug::Printf( "[MemSpy] CMemSpyAppUi::DWOperationStarted() - START - iRunningDeviceWideOperation: %d, iAutoCaptureTimer is active: %d", iRunningDeviceWideOperation, iAutoCaptureTimer->IsActive() );
+#endif
+
+    iRunningDeviceWideOperation = ETrue;
+
+#ifdef _DEBUG
+    RDebug::Printf( "[MemSpy] CMemSpyAppUi::DWOperationStarted() - END - iRunningDeviceWideOperation: %d, iAutoCaptureTimer is active: %d", iRunningDeviceWideOperation, iAutoCaptureTimer->IsActive() );
+#endif
+    }
+
+
+void CMemSpyAppUi::DWOperationCancelled()
+    {
+#ifdef _DEBUG
+    RDebug::Printf( "[MemSpy] CMemSpyAppUi::DWOperationCancelled() - START - iRunningDeviceWideOperation: %d, iAutoCaptureTimer is active: %d", iRunningDeviceWideOperation, iAutoCaptureTimer->IsActive() );
+#endif
+
+    iAutoCaptureTimer->Cancel();
+
+#ifdef _DEBUG
+    RDebug::Printf( "[MemSpy] CMemSpyAppUi::DWOperationCancelled() - END - iRunningDeviceWideOperation: %d, iAutoCaptureTimer is active: %d", iRunningDeviceWideOperation, iAutoCaptureTimer->IsActive() );
+#endif
+    }
+
+
+void CMemSpyAppUi::DWOperationCompleted()
+    {
+#ifdef _DEBUG
+    RDebug::Printf( "[MemSpy] CMemSpyAppUi::DWOperationCompleted() - START - iRunningDeviceWideOperation: %d, iAutoCaptureTimer is active: %d", iRunningDeviceWideOperation, iAutoCaptureTimer->IsActive() );
+#endif
+
+    iRunningDeviceWideOperation = EFalse;
+
+#ifdef _DEBUG
+    RDebug::Printf( "[MemSpy] CMemSpyAppUi::DWOperationCompleted() - END - iAutoCaptureTimer is active: %d", iAutoCaptureTimer->IsActive() );
+#endif
+    }
+
+
+void CMemSpyAppUi::UpdateCBAL()
+    {
+    CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
+    const TMemSpyViewType viewType = iAppContainer->ActiveViewType();
+    //
+    if  ( MemSpyViewTypeUtils::IsExitableView( viewType ) )
+        {
+        cba->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_EXIT );
+        }
+    else
+        {
+        cba->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK );
+        }
+
+    cba->MakeVisible( ETrue );
+    cba->DrawNow();
+    }
+
+
+void CMemSpyAppUi::InitiateMemSpyClientServerOperationL( TInt aOpCode )
+    {
+#ifdef _DEBUG
+    RDebug::Printf( "[MemSpy] CMemSpyAppUi::InitiateMemSpyClientServerOperationL() - START - aOpCode: %d", aOpCode );
+#endif
+
+    switch( aOpCode )
+        {
+    case EMemSpyClientServerOpSummaryInfo:
+        HandleCommandL( EMemSpyCmdPhoneInfoGeneralSummary );
+        break;
+    case EMemSpyClientServerOpSummaryInfoDetailed:
+        HandleCommandL( EMemSpyCmdPhoneInfoGeneralDetailed );
+        break;
+    //
+    case EMemSpyClientServerOpHeapInfo:
+        HandleCommandL( EMemSpyCmdPhoneInfoHeapInfoSummary );
+        break;
+    case EMemSpyClientServerOpHeapCellListing:
+        HandleCommandL( EMemSpyCmdPhoneInfoHeapCellListing );
+        break;
+    case EMemSpyClientServerOpHeapData:
+        HandleCommandL( EMemSpyCmdPhoneInfoHeapDump );
+        break;
+    //
+    case EMemSpyClientServerOpStackInfo:
+        HandleCommandL( EMemSpyCmdPhoneInfoStackInfo );
+        break;
+    case EMemSpyClientServerOpStackDataUser:
+        HandleCommandL( EMemSpyCmdPhoneInfoStackDumpUser );
+        break;
+    case EMemSpyClientServerOpStackDataKernel:
+        HandleCommandL( EMemSpyCmdPhoneInfoStackDumpKernel );
+        break;
+    //
+    case EMemSpyClientServerOpBitmapsSave:
+        OnCmdToolsBitmapsSaveToMemoryCardL();
+        break;
+    case EMemSpyClientServerOpSendToBackground:
+        OnCmdToolsSendToBackgroundL();
+        break;
+    case EMemSpyClientServerOpBringToForeground:
+        OnCmdToolsBringToForegroundL();
+        break;
+    case EMemSpyClientServerOpExit:
+        OnCmdExitL();
+        break;
+    //
+    default:
+        User::Leave( KErrNotSupported );
+        break;
+        }
+
+#ifdef _DEBUG
+    RDebug::Printf( "[MemSpy] CMemSpyAppUi::InitiateMemSpyClientServerOperationL() - END - aOpCode: %d", aOpCode );
+#endif
+    }
+
+
+void CMemSpyAppUi::SetViewServerTimeOutStatus( TBool aEnabled )
+    {
+    TRAP_IGNORE(
+        iEngine.HelperProcess().ImpersonateL( KMemSpyEikSrvSID );
+        //
+        CVwsSessionWrapper* ses = CVwsSessionWrapper::NewLC();
+        ses->EnableServerEventTimeOut( aEnabled );
+        CleanupStack::PopAndDestroy( ses );
+        //
+        iEngine.HelperProcess().ImpersonateL( 0 );
+        );
+    }
+
+
+void CMemSpyAppUi::OnCmdBackL()
+    {
+    const TMemSpyViewType viewType = iAppContainer->ActiveViewType();
+    //
+    if  ( !MemSpyViewTypeUtils::IsExitableView( viewType ) )
+        {
+        // Should go back one view
+        iAppContainer->NavigateToParentViewL();
+        }
+    }
+
+
+void CMemSpyAppUi::OnCmdExitL()
+    {
+    Exit();
+    }
+
+
+void CMemSpyAppUi::OnCmdOpenL()
+    {
+    const TMemSpyViewType viewType = iAppContainer->ActiveViewType();
+    //
+    if  ( !MemSpyViewTypeUtils::IsOpenableItem( viewType ) )
+        {
+        // Should go back one view
+        iAppContainer->NavigateToChildViewL();
+        }
+    }
+
+
+void CMemSpyAppUi::OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::TOperation aOp )
+    {
+#ifdef _DEBUG
+    RDebug::Printf( "[MemSpy] CMemSpyAppUi::OnCmdPhoneInformationOperationL() - START - aOp: %d, iRunningDeviceWideOperation: %d, iAutoCaptureTimer is active: %d", aOp, iRunningDeviceWideOperation, iAutoCaptureTimer->IsActive() );
+#endif
+
+    if  ( !iRunningDeviceWideOperation )
+        {
+        CMemSpyDeviceWideOperationDialog::ExecuteLD( iEngine, *this, aOp );
+        }
+
+#ifdef _DEBUG
+    RDebug::Printf( "[MemSpy] CMemSpyAppUi::OnCmdPhoneInformationOperationL() - END - aOp: %d, iRunningDeviceWideOperation: %d, iAutoCaptureTimer is active: %d", aOp, iRunningDeviceWideOperation, iAutoCaptureTimer->IsActive() );
+#endif
+    }
+
+
+void CMemSpyAppUi::OnCmdPhoneInformationOperationKernelContainersL()
+    {
+    CMemSpyEngineGenericKernelObjectContainer* list = iEngine.HelperKernelContainers().ObjectsAllL();
+    CleanupStack::PushL( list );
+    iEngine.HelperKernelContainers().OutputL( *list );
+    CleanupStack::PopAndDestroy( list );
+    }
+
+
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+
+
+void CMemSpyAppUi::OnCmdAutoCaptureToggleL()
+    {
+#ifdef _DEBUG
+    RDebug::Printf( "[MemSpy] CMemSpyAppUi::OnCmdAutoCaptureToggleL() - START - iAutoCaptureOperationType: %d, iAutoCaptureTimer is active: %d", iAutoCaptureOperationType, iAutoCaptureTimer->IsActive() );
+#endif
+
+    if  ( iAutoCaptureTimer->IsActive() )
+        {
+        iAutoCaptureTimer->Cancel();
+        }
+    else
+        {
+        iAutoCaptureTimer->Cancel();
+        //
+        const TTimeIntervalMicroSeconds32 interval( iAutoCaptureTimerPeriod * 1000000 );
+        iAutoCaptureTimer->Start( 0, interval, TCallBack(AutoCaptureCallBack, this) );
+        }
+
+#ifdef _DEBUG
+    RDebug::Printf( "[MemSpy] CMemSpyAppUi::OnCmdAutoCaptureToggleL() - START - iAutoCaptureOperationType: %d, iAutoCaptureTimer is active: %d", iAutoCaptureOperationType, iAutoCaptureTimer->IsActive() );
+#endif
+    }
+
+
+void CMemSpyAppUi::OnCmdAutoCaptureRetryTimeL()
+    {
+    CAknNumberQueryDialog* dialog = new(ELeave) CAknNumberQueryDialog( iAutoCaptureTimerPeriod );
+    dialog->ExecuteLD( R_MEMSPY_DEVICE_WIDE_SETTINGS );
+    }
+
+
+void CMemSpyAppUi::OnCmdAutoCaptureOperationTypeL()
+    {
+    CDesCArrayFlat* items = iCoeEnv->ReadDesC16ArrayResourceL( R_MEMSPY_AUTO_CAPTURE_OPERATION_TYPES );
+    CleanupStack::PushL(items);
+    //
+    TInt currentItem = iAutoCaptureOperationType;
+    //
+    CAknRadioButtonSettingPage* dialog = new(ELeave) CAknRadioButtonSettingPage( R_MEMSPY_AUTO_CAPTURE_OPERATION_TYPES_SETTINGS_PAGE, currentItem, items );
+    if  ( dialog->ExecuteLD( CAknSettingPage::EUpdateWhenAccepted ) )
+        {
+        iAutoCaptureOperationType = static_cast< CMemSpyDeviceWideOperations::TOperation >( currentItem );
+        }
+    //
+    CleanupStack::PopAndDestroy( items ); 
+    }
+
+
+TInt CMemSpyAppUi::AutoCaptureCallBack( TAny* aSelf )
+    {
+    CMemSpyAppUi* self = reinterpret_cast< CMemSpyAppUi* >( aSelf );
+    TRAPD( err, self->AutoCaptureCallBackL() );
+    //
+    const TBool callMeBackAgain = ( err == KErrNone );
+    return callMeBackAgain;
+    }
+
+
+void CMemSpyAppUi::AutoCaptureCallBackL()
+    {
+#ifdef _DEBUG
+    RDebug::Printf( "[MemSpy] CMemSpyAppUi::AutoCaptureCallBackL() - START - iAutoCaptureOperationType: %d, iAutoCaptureTimer is active: %d", iAutoCaptureOperationType, iAutoCaptureTimer->IsActive() );
+#endif
+
+    OnCmdPhoneInformationOperationL( iAutoCaptureOperationType );
+
+#ifdef _DEBUG
+    RDebug::Printf( "[MemSpy] CMemSpyAppUi::AutoCaptureCallBackL() - END - iAutoCaptureOperationType: %d, iAutoCaptureTimer is active: %d", iAutoCaptureOperationType, iAutoCaptureTimer->IsActive() );
+#endif
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+void CMemSpyAppUi::OnCmdOutputToDebugL()
+    {
+    iEngine.InstallSinkL( ESinkTypeDebug );
+    MemSpyDocument().Settings().StoreSettingsL();
+    }
+
+
+void CMemSpyAppUi::OnCmdOutputToFileL()
+    {
+    iEngine.InstallSinkL( ESinkTypeFile );
+    MemSpyDocument().Settings().StoreSettingsL();
+    }
+
+
+
+
+
+
+
+
+
+
+
+void CMemSpyAppUi::OnCmdAboutL()
+    {
+    CAknMessageQueryDialog* dialog = new(ELeave) CAknMessageQueryDialog;
+    dialog->ExecuteLD( R_MEMSPYUI_ABOUT_DIALOG );
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+void CMemSpyAppUi::OnCmdToolsBitmapsSaveToMemoryCardL()
+    {
+    // Get bitmap handles
+    RArray<TInt> handles;
+    CleanupClosePushL( handles );
+    iEngine.HelperFbServ().GetArrayOfBitmapHandlesL( handles );
+
+    // Build bitmap list
+    CMemSpyEngineFbServBitmapArray* array = CMemSpyEngineFbServBitmapArray::NewL( handles );
+    CleanupStack::PopAndDestroy( &handles );
+    CleanupStack::PushL( array );
+
+    // Export...
+    CMemSpyExportBitmapsToMemoryCardDialog* dialog = CMemSpyExportBitmapsToMemoryCardDialog::NewL( iCoeEnv->FsSession(), *array );
+    
+    // All done
+    CleanupStack::PopAndDestroy( array );
+    }
+
+
+void CMemSpyAppUi::OnCmdToolsSendToBackgroundL()
+    {
+    TApaTask task( iCoeEnv->WsSession() );
+    task.SendToBackground();
+    }
+
+
+void CMemSpyAppUi::OnCmdToolsBringToForegroundL()
+    {
+    iCoeEnv->BringOwnerToFront();
+    }
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyContainer.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,222 @@
+/*
+* 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 "MemSpyContainer.h"
+
+// System includes
+#include <eikrted.h>  // for example label control
+#include <txtrich.h>
+#include <apgtask.h>
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+
+// User includes
+#include "MemSpyViewMainMenu.h"
+#include "MemSpyContainerObserver.h"
+
+
+
+
+CMemSpyContainer::CMemSpyContainer( CMemSpyEngine& aEngine, MMemSpyContainerObserver& aObserver  )
+:   iEngine( aEngine ), iObserver( aObserver )
+    {
+    }
+
+
+CMemSpyContainer::~CMemSpyContainer()
+    {
+    delete iPreviousView;
+    delete iActiveView;
+    }
+
+
+void CMemSpyContainer::ConstructL(const TRect& aRect)
+    {
+    CreateWindowL();
+    SetRect(aRect);
+    PrepareTopLevelViewL();
+    ActivateL();
+    }
+
+
+void CMemSpyContainer::NavigateToParentViewL()
+    {
+    CMemSpyViewBase* parentView = iActiveView->PrepareParentViewL();
+    //
+    if  ( parentView == NULL )
+        {
+        // Parent can be null, in which case, revert to top-level view
+        PrepareTopLevelViewL();
+        }
+    else
+        {
+        SetNewActiveViewL( parentView );
+        }
+    }
+
+
+void CMemSpyContainer::NavigateToChildViewL()
+    {
+    CMemSpyViewBase* childView = iActiveView->PrepareChildViewL();
+    //
+    if  ( childView != NULL )
+        {
+        SetNewActiveViewL( childView );
+        }
+    }
+
+
+void CMemSpyContainer::HandleCommandL( TInt aCommand )
+    {
+    switch( aCommand )
+        {
+	case EMemSpyCmdViewRefresh:
+        OnCmdViewRefreshL();
+        break;
+    default:
+        if  ( iActiveView )
+            {
+            iActiveView->HandleCommandL( aCommand );
+            }
+        break;
+        }
+    }
+
+
+void CMemSpyContainer::OnCmdViewRefreshL()
+    {
+    if  ( iActiveView )
+        {
+        TRAPD(err, iActiveView->RefreshL());
+        if  ( err != KErrNone )
+            {
+            // Error during view refreshing (perhaps the thread doesn't exist anymore).
+            // Try to replace the active view with its parent...
+            NavigateToParentViewL();
+            }
+        }
+    }
+
+
+void CMemSpyContainer::SizeChanged()
+    {
+    if  ( iActiveView )
+        {
+        iActiveView->SetRect( Rect() );
+        }
+    }
+
+
+TInt CMemSpyContainer::CountComponentControls() const
+    {
+    return 1;
+    }
+
+
+CCoeControl* CMemSpyContainer::ComponentControl(TInt /*aIndex*/) const
+    {
+    return iActiveView;
+    }
+
+
+void CMemSpyContainer::Draw(const TRect& aRect) const
+    {
+    CWindowGc& gc = SystemGc();
+    //
+    gc.SetPenStyle(CGraphicsContext::ENullPen);
+    gc.SetBrushColor(KRgbGray);
+    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
+    gc.DrawRect(aRect);
+    }
+
+
+TKeyResponse CMemSpyContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
+    {
+    TKeyResponse response = EKeyWasNotConsumed;
+    //
+    if  ( iActiveView )
+        {
+        response = iActiveView->OfferKeyEventL( aKeyEvent, aType );
+        }
+    //
+    return response;
+    }
+
+
+void CMemSpyContainer::HandleMemSpyViewEventL( TViewEventType aEvent, TMemSpyViewType /*aViewType*/, CMemSpyViewBase& aReportingView, TAny* /*aContext*/ )
+    {
+    if  ( aEvent == EEventItemActioned )
+        {
+        // Get the view to generate a child
+        CMemSpyViewBase* child = aReportingView.PrepareChildViewL();
+        if  ( child == NULL )
+            {
+            // View doesn't have a child - treat it as item activation and
+            // report event to observer.
+
+            }
+        else
+            {
+            // Child view becomes the active one
+            SetNewActiveViewL( child );
+            }
+        }
+    }
+
+
+CMemSpyViewBase* CMemSpyContainer::PrepareTopLevelViewL()
+    {
+    CMemSpyViewMainMenu* view = new(ELeave) CMemSpyViewMainMenu( iEngine, *this );
+    CleanupStack::PushL( view );
+    view->ConstructL( Rect(), *this );
+    SetNewActiveViewL( view );
+    CleanupStack::Pop( view );
+    return view;
+    }
+
+
+void CMemSpyContainer::SetNewActiveViewL( CMemSpyViewBase* aNewView )
+    {
+    delete iPreviousView;
+    //
+    iPreviousView = iActiveView;
+    if  ( iPreviousView )
+        {
+        iPreviousView->MakeVisible( EFalse );
+        iPreviousView->SetFocus( EFalse );
+        }
+    //
+    iActiveView = aNewView;
+    iActiveView->RefreshL();
+    iActiveView->SetFocus( ETrue );
+    //
+    ReportEventL( MCoeControlObserver::EEventStateChanged );
+    }
+
+
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyDeviceWideOperationDialog.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,197 @@
+/*
+* 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 "MemSpyDeviceWideOperationDialog.h"
+
+// System includes
+#include <eikprogi.h>
+#include <AknWaitDialog.h>
+#include <AknQueryDialog.h>
+#include <coemain.h>
+#include <eikenv.h>
+#include <avkon.hrh>
+#include <memspyui.rsg>
+
+
+CMemSpyDeviceWideOperationDialog::CMemSpyDeviceWideOperationDialog( CMemSpyEngine& aEngine, MMemSpyDeviceWideOperationDialogObserver& aObserver )
+:   iEngine( aEngine ), iObserver( aObserver )
+    {
+    }
+
+
+CMemSpyDeviceWideOperationDialog::~CMemSpyDeviceWideOperationDialog()
+    {
+#ifdef _DEBUG
+    RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::~CMemSpyDeviceWideOperationDialog() - START - iForcedCancel: %d", iForcedCancel );
+#endif
+
+#ifdef _DEBUG
+    RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::~CMemSpyDeviceWideOperationDialog() - deleting operation...: 0x%08x", iOperation );
+#endif
+    delete iOperation;
+
+#ifdef _DEBUG
+    RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::~CMemSpyDeviceWideOperationDialog() - deleting dialog...: 0x%08x", iProgressDialog );
+#endif
+    iProgressInfo = NULL;
+    delete iProgressDialog;
+
+#ifdef _DEBUG
+    RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::~CMemSpyDeviceWideOperationDialog() - sending EDialogDismissed to observer..." );
+#endif
+
+    iObserver.DWOperationCompleted();
+
+#ifdef _DEBUG
+    RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::~CMemSpyDeviceWideOperationDialog() - END" );
+#endif
+    }
+
+
+void CMemSpyDeviceWideOperationDialog::ExecuteL( CMemSpyDeviceWideOperations::TOperation aOperation )
+    {
+#ifdef _DEBUG
+    RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::ExecuteL() - START" );
+#endif
+
+    iOperation = CMemSpyDeviceWideOperations::NewL( iEngine, *this, aOperation );
+
+#ifdef _DEBUG
+    RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::ExecuteL() - constructed operation..." );
+#endif
+
+    ASSERT( iProgressDialog == NULL );
+    iProgressDialog = new( ELeave ) CAknProgressDialog( reinterpret_cast< CEikDialog** >( &iProgressDialog ), ETrue );
+    iProgressDialog->PrepareLC( R_MEMSPY_DEVICE_WIDE_OPERATION_PROGRESS_DIALOG );
+    iProgressDialog->SetCallback( this );
+    iProgressDialog->SetGloballyCapturing( ETrue );
+    //
+    iProgressInfo = iProgressDialog->GetProgressInfoL();
+    iProgressInfo->SetFinalValue( iOperation->TotalOperationSize() );
+    //
+    iProgressDialog->RunLD();
+
+#ifdef _DEBUG
+    RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::ExecuteL() - END" );
+#endif
+    }
+
+void CMemSpyDeviceWideOperationDialog::ExecuteLD( CMemSpyEngine& aEngine, MMemSpyDeviceWideOperationDialogObserver& aObserver, CMemSpyDeviceWideOperations::TOperation aOperation )
+    {
+    CMemSpyDeviceWideOperationDialog* self = new(ELeave) CMemSpyDeviceWideOperationDialog( aEngine, aObserver );
+    CleanupStack::PushL( self );
+    self->ExecuteL( aOperation );
+    CleanupStack::PopAndDestroy( self );
+    }
+
+
+void CMemSpyDeviceWideOperationDialog::Cancel()
+    {
+#ifdef _DEBUG
+    RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::Cancel() - START - iOperation: 0x%08x, iForcedCancel: %d", iOperation, iForcedCancel );
+#endif
+
+    iForcedCancel = ETrue;
+    //
+    if  ( iOperation )
+        {
+        iOperation->Cancel();
+        }
+    //
+    iObserver.DWOperationCancelled();
+
+#ifdef _DEBUG
+    RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::Cancel() - END" );
+#endif
+    }
+
+
+void CMemSpyDeviceWideOperationDialog::DialogDismissedL( TInt aButtonId )
+    {
+#ifdef _DEBUG
+    RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::DialogDismissedL() - START - aButtonId: %d, iForcedCancel: %d", aButtonId, iForcedCancel );
+#else
+    (void) aButtonId;
+#endif
+
+    Cancel();
+
+#ifdef _DEBUG
+    RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::DialogDismissedL() - END - aButtonId: %d, iForcedCancel: %d", aButtonId, iForcedCancel );
+#endif
+    }
+
+
+void CMemSpyDeviceWideOperationDialog::HandleDeviceWideOperationEvent( TEvent aEvent, TInt aParam1, const TDesC& aParam2 )
+    {
+#ifdef _DEBUG
+    RDebug::Print( _L("[MemSpy] CMemSpyDeviceWideOperationDialog::HandleDeviceWideOperationEvent() - START - aEvent: %d, iProgressDialog: 0x%08x, aParam1: %d, aParam2: %S"), aEvent, iProgressDialog, aParam1, &aParam2 );
+#endif
+
+    switch( aEvent )
+        {
+    case MMemSpyDeviceWideOperationsObserver::EOperationSized:
+        break;
+    case MMemSpyDeviceWideOperationsObserver::EOperationStarting:
+        iObserver.DWOperationStarted();
+        break;
+    case MMemSpyDeviceWideOperationsObserver::EOperationProgressStart:
+        ASSERT( iProgressDialog != NULL );
+        SetDialogCaptionL( aParam2 );
+        break;
+    case MMemSpyDeviceWideOperationsObserver::EOperationProgressEnd:
+        ASSERT( iProgressDialog != NULL );
+        iProgressInfo->IncrementAndDraw( aParam1 );
+        break;
+    case MMemSpyDeviceWideOperationsObserver::EOperationCancelled:
+        break;
+    case MMemSpyDeviceWideOperationsObserver::EOperationCompleting:
+        {
+        ASSERT( iProgressDialog != NULL );
+        const TInt finalValue = iProgressInfo->Info().iFinalValue;
+        iProgressInfo->SetAndDraw( finalValue );
+        break;
+        }
+    case MMemSpyDeviceWideOperationsObserver::EOperationCompleted:
+        if  ( iProgressDialog )
+            {
+            iProgressDialog->ProcessFinishedL();
+            }
+        break;
+    default:
+        break;
+        }
+
+#ifdef _DEBUG
+    RDebug::Print( _L("[MemSpy] CMemSpyDeviceWideOperationDialog::HandleDeviceWideOperationEvent() - END - aEvent: %d, aParam1: %d, aParam2: %S"), aEvent, aParam1, &aParam2 );
+#endif
+    }
+
+
+void CMemSpyDeviceWideOperationDialog::SetDialogCaptionL( const TDesC& aText )
+    {
+    if  ( aText.Length() )
+        {
+        iProgressDialog->SetTextL( aText );
+        iProgressDialog->DrawNow();
+        }
+    }
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyDocument.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,89 @@
+/*
+* 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 "MemSpyDocument.h"
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+
+// User includes
+#include "MemSpyAppUi.h"
+#include "MemSpySettings.h"
+
+
+CMemSpyDocument::CMemSpyDocument(CEikApplication& aApp)
+:   CAknDocument(aApp)    
+    {
+    }
+
+
+CMemSpyDocument::~CMemSpyDocument()
+    {
+    delete iSettings;
+    delete iEngine;
+    }
+
+
+void CMemSpyDocument::ConstructL()
+    {
+    RFs& fsSession = CCoeEnv::Static()->FsSession();
+    //
+    iEngine = CMemSpyEngine::NewL( fsSession );
+    iSettings = CMemSpySettings::NewL( fsSession, *iEngine );
+    }
+
+
+CMemSpyDocument* CMemSpyDocument::NewL(CEikApplication& aApp)
+    {
+    CMemSpyDocument* self = new (ELeave) CMemSpyDocument( aApp );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+
+CMemSpyEngine& CMemSpyDocument::Engine()
+    {
+    return *iEngine;
+    }
+
+
+const CMemSpyEngine& CMemSpyDocument::Engine() const
+    {
+    return *iEngine;
+    }
+
+
+CMemSpySettings& CMemSpyDocument::Settings()
+    {
+    return *iSettings;
+    }
+
+
+const CMemSpySettings& CMemSpyDocument::Settings() const
+    {
+    return *iSettings;
+    }
+
+
+CEikAppUi* CMemSpyDocument::CreateAppUiL()
+    {
+    return new (ELeave) CMemSpyAppUi( *iEngine );
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyExportBitmapsToMemoryCardDialog.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,328 @@
+/*
+* 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 "MemSpyExportBitmapsToMemoryCardDialog.h"
+
+// System includes
+#include <eikprogi.h>
+#include <AknWaitDialog.h>
+#include <AknQueryDialog.h>
+#include <coemain.h>
+#include <eikenv.h>
+#include <avkon.hrh>
+#include <memspyui.rsg>
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyenginehelperchunk.h>
+#include <memspy/engine/memspyenginehelpercodesegment.h>
+#include <memspy/engine/memspyenginehelperheap.h>
+#include <memspy/engine/memspyenginehelperstack.h>
+#include <memspy/engine/memspyenginehelperthread.h>
+#include <memspy/engine/memspyenginehelperprocess.h>
+#include <memspy/engine/memspyenginehelperfbserv.h>
+
+// Driver includes
+#include <memspy/driver/memspydriverenumerationsshared.h>
+
+// Literal constants
+_LIT( KMemSpyBitmapExportFolderAndFileName, "e:\\MemSpy\\Images\\%04d%02d%02d_%02d.%02d.%02d\\");
+
+
+CMemSpyExportBitmapsToMemoryCardDialog::CMemSpyExportBitmapsToMemoryCardDialog( RFs& aFsSession, const CMemSpyEngineFbServBitmapArray& aBitmaps )
+:   CActive(EPriorityIdle), iFsSession(aFsSession), iBitmaps(aBitmaps)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+
+CMemSpyExportBitmapsToMemoryCardDialog::~CMemSpyExportBitmapsToMemoryCardDialog()
+    {
+    Cancel();
+    //
+    delete iProgressDialog;
+    //
+    iMimeTypeArray.ResetAndDestroy();
+    iMimeTypeArray.Close();
+    //
+    if ( iEncoder )
+        {
+        iEncoder->Cancel();
+        }
+    delete iEncoder;
+    delete iFolderName;
+    delete iBmpMimeType;
+    }
+
+
+void CMemSpyExportBitmapsToMemoryCardDialog::ConstructL()
+    {
+    // Check card is ready
+    if  ( CheckMemoryCardAvailableL( iFsSession ) == EFalse )
+        {
+        User::Leave( KErrNotReady );
+        }
+
+    // Get mime type for BMP file
+    IdentifyBmpMimeTypeL();
+
+    // Prepare unique empty folder
+    PrepareFolderNameSpecL();
+
+    // Prepare UI stuff
+    iProgressDialog = new( ELeave ) CAknProgressDialog( reinterpret_cast< CEikDialog** >( &iProgressDialog ) );
+    iProgressDialog->SetCallback( this );
+    iProgressDialog->SetGloballyCapturing( ETrue );
+    iProgressDialog->PrepareLC( R_MEMSPY_EXPORT_TO_MEMORYCARD_DIALOG );
+    //
+    iProgressInfo = iProgressDialog->GetProgressInfoL( );
+    iProgressInfo->SetFinalValue( iBitmaps.Count() );
+    //
+    iProgressDialog->MakeVisible( ETrue ); // Visible right away
+    //
+    iDialogDismissed = EFalse;
+    iProgressInfo->SetAndDraw( 0 );
+
+    // Start the process rolling...
+    CompleteSelf(KErrNone);
+
+    //
+    iProgressDialog->RunLD( );
+    }
+
+
+CMemSpyExportBitmapsToMemoryCardDialog* CMemSpyExportBitmapsToMemoryCardDialog::NewL( RFs& aFsSession, const CMemSpyEngineFbServBitmapArray& aBitmaps )
+    {
+    CMemSpyExportBitmapsToMemoryCardDialog* self = new(ELeave) CMemSpyExportBitmapsToMemoryCardDialog( aFsSession, aBitmaps );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+void CMemSpyExportBitmapsToMemoryCardDialog::Cancel()
+    {
+    CActive::Cancel();
+    }
+
+
+TBool CMemSpyExportBitmapsToMemoryCardDialog::CheckMemoryCardAvailableL( RFs& aFsSession )
+    {
+    TBool available = EFalse;
+    //
+    TDriveInfo driveInfo;
+    if  ( aFsSession.Drive( driveInfo, EDriveE ) == KErrNone )
+        {
+        // Other checks needed?
+        available = ETrue;
+        }
+    //
+    return available;
+    }
+
+
+void CMemSpyExportBitmapsToMemoryCardDialog::RunL()
+    {
+    const TInt error = iStatus.Int();
+    User::LeaveIfError( error );
+ 
+    if  ( !iDialogDismissed )
+        {
+        // Do we have more items to process?
+        if  ( TryToExportSingleBitmapL() )
+            {
+            _LIT(KTextFormat, "Saving image\n%d/%d");
+            TBuf<128> buf;
+            buf.Format( KTextFormat, iBitmapIndex, iBitmaps.Count() );
+            //
+            iProgressDialog->SetTextL( buf );
+            iProgressInfo->SetAndDraw( iBitmapIndex );
+            iProgressDialog->DrawDeferred();
+            }
+        else
+            {
+            // We're done - RunL will not be called again
+            if  (iProgressInfo)
+                {
+                const TInt finalValue = iProgressInfo->Info().iFinalValue;
+                iProgressInfo->SetAndDraw( finalValue );
+                //
+                delete iProgressDialog;
+                iProgressDialog = NULL;
+                //
+                delete this;
+                }
+            }
+
+        User::ResetInactivityTime();
+        }
+    else
+        {
+        delete iProgressDialog;
+        iProgressDialog = NULL;
+        //
+        delete this;
+        }
+    }
+
+
+void CMemSpyExportBitmapsToMemoryCardDialog::DoCancel()
+    {
+    if  ( iEncoder )
+        {
+        iEncoder->Cancel();
+        }
+
+    iDialogDismissed = ETrue;
+    }
+
+
+TInt CMemSpyExportBitmapsToMemoryCardDialog::RunError( TInt /*aError*/ )
+    {
+    TRAP_IGNORE(
+
+        // Try the next image
+        if  ( TryToExportSingleBitmapL() == EFalse )
+            {
+            iDialogDismissed = ETrue;
+            delete this;
+            }
+    );
+    //
+    return KErrNone;
+    }
+
+
+void CMemSpyExportBitmapsToMemoryCardDialog::DialogDismissedL( TInt /*aButtonId*/ )
+    {
+    iDialogDismissed = ETrue;
+    iProgressDialog = NULL;
+    }
+
+
+void CMemSpyExportBitmapsToMemoryCardDialog::CompleteSelf( TInt aError )
+    {
+    TRequestStatus* status = &iStatus;
+    User::RequestComplete( status, aError );
+    SetActive();
+    }
+
+
+void CMemSpyExportBitmapsToMemoryCardDialog::ExportBitmapL( const CMemSpyEngineFbServBitmap& aBitmap )
+    {
+    // Create a filename
+    TFileName fileName( *iFolderName );
+    aBitmap.GetExportableFileNameL( fileName );
+
+    // Create encoder object...
+    CImageEncoder* encoder = CImageEncoder::FileNewL( iFsSession, fileName, *iBmpMimeType );
+    delete iEncoder;
+    iEncoder = encoder;
+
+    // Start operation
+    iEncoder->Convert( &iStatus, aBitmap.Bitmap() );
+    SetActive();
+    }
+
+
+void CMemSpyExportBitmapsToMemoryCardDialog::IdentifyBmpMimeTypeL()
+    {
+    _LIT(KBmpExtension, ".bmp");
+    CImageEncoder::GetFileTypesL( iMimeTypeArray );
+    //
+    const TInt count = iMimeTypeArray.Count();
+    //
+    for( TInt i=0; i<count; i++ )
+        {
+        CFileExtensionMIMEType* extension = iMimeTypeArray[ i ];
+        if  ( extension->FileExtension().FindF( KBmpExtension ) >= 0 )
+            {
+            // Found it - save mime type info
+            iBmpMimeType = extension->MIMEType().AllocL();
+            iMimeTypeArray.ResetAndDestroy();
+            iMimeTypeArray.Close();
+            return;
+            }
+        }
+    //
+    User::Leave( KErrNotFound );    
+    }
+
+
+void CMemSpyExportBitmapsToMemoryCardDialog::PrepareFolderNameSpecL()
+    {
+    delete iFolderName;
+    iFolderName = NULL;
+    
+    // Make a unique filename format specifier.
+    TTime now;
+    now.HomeTime();
+    const TDateTime dt( now.DateTime() );
+
+    // Build it up...
+    iFolderName = HBufC::NewL( KMaxFileName );
+    TPtr pName( iFolderName->Des() );
+    pName.Format( KMemSpyBitmapExportFolderAndFileName, dt.Year(), dt.Month()+1, dt.Day()+1, dt.Hour(), dt.Minute(), dt.Second());
+    
+    // Create directory
+    const TInt error = iFsSession.MkDirAll( pName );
+    User::LeaveIfError( error );
+    }
+
+
+TBool CMemSpyExportBitmapsToMemoryCardDialog::TryToExportSingleBitmapL()
+    {
+    TBool startedExport = EFalse;
+    
+    const TInt count = iBitmaps.Count();
+    for( ; ( iBitmapIndex < count ) && ( startedExport == EFalse ); iBitmapIndex++ )
+        {
+        const CMemSpyEngineFbServBitmap& memSpyBitmap = iBitmaps.At( iBitmapIndex );
+        const CFbsBitmap& fbsBitmap = memSpyBitmap.Bitmap();
+        const TSize size( fbsBitmap.SizeInPixels() );
+
+        // We don't want to export bitmaps which have a zero-pixel dimension.
+        if  ( size.iHeight > 0 && size.iWidth > 0 )
+            {
+            // This completes the object's request status and will therefore
+            // result in a further call to RunL() when the export to BMP
+            // is completed.
+            ExportBitmapL( memSpyBitmap );
+
+            // And indicate we managed to start an operation...
+            startedExport = ETrue;
+            }
+        }
+    //
+    return startedExport;
+    }
+
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpySettings.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,273 @@
+/*
+* 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 "MemSpySettings.h"
+
+// System includes
+#include <e32svr.h>
+#include <s32file.h>
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyenginelogger.h>
+#include <memspy/engine/memspyenginehelperprocess.h>
+#include <memspy/engine/memspyenginehelpersysmemtracker.h>
+#include <memspy/engine/memspyenginehelpersysmemtrackerconfig.h>
+
+// Constants
+_LIT( KMemSpySettingsFileName, "settings.dat" );
+
+// Version 03 dumped some of the system wide memory tracker settings
+const TInt KMemSpySettingsFileFormatVersion = 6;
+
+
+CMemSpySettings::CMemSpySettings( RFs& aFsSession, CMemSpyEngine& aEngine )
+:   iFsSession( aFsSession ), iEngine( aEngine )
+    {
+    }
+
+
+CMemSpySettings::~CMemSpySettings()
+    {
+    TRACE( RDebug::Printf( "CMemSpySettings::~CMemSpySettings() - START" ) );
+    TRAP_IGNORE( StoreSettingsL() );
+    TRACE( RDebug::Printf( "CMemSpySettings::~CMemSpySettings() - END" ) );
+    }
+
+
+void CMemSpySettings::ConstructL()
+    {
+    TRACE( RDebug::Print( _L("CMemSpySettings::ConstructL() - START") ) );
+
+    TRAP_IGNORE( RestoreSettingsL() );
+
+    TRACE( RDebug::Print( _L("CMemSpySettings::ConstructL() - END") ) );
+    }
+
+
+CMemSpySettings* CMemSpySettings::NewL( RFs& aFsSession, CMemSpyEngine& aEngine )
+    {
+    CMemSpySettings* self = new(ELeave) CMemSpySettings( aFsSession, aEngine );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+void CMemSpySettings::GetSettingsFileNameL( TDes& aFileName )
+    {
+    GetSettingsPathL( aFileName );
+    aFileName.Append( KMemSpySettingsFileName );
+    TRACE( RDebug::Print( _L("CMemSpySettings::GetSettingsFileNameL() - aFileName: %S"), &aFileName ) );
+    }
+
+
+void CMemSpySettings::GetSettingsPathL( TDes& aPath )
+    {
+    TRACE( RDebug::Print( _L("CMemSpySettings::GetSettingsPathL() - START") ) );
+    aPath.Zero();
+
+    // Get private data cage path
+    TInt err = iFsSession.PrivatePath( aPath );
+    TRACE( RDebug::Print( _L("CMemSpySettings::GetSettingsPathL() - priv path err: %d"), err ) );
+    User::LeaveIfError( err );
+
+    // Combine with C: drive
+    const TDriveUnit cDrive( EDriveC );
+    const TDriveName cDriveName( cDrive.Name() );
+    aPath.Insert( 0, cDriveName );
+
+    iFsSession.MkDirAll( aPath );
+    TRACE( RDebug::Print( _L("CMemSpySettings::GetSettingsPathL() - END - %S"), &aPath ) );
+    }
+
+
+RFile CMemSpySettings::SettingsFileLC( TBool aReplace )
+    {
+    TRACE( RDebug::Print( _L("CMemSpySettings::SettingsFileLC() - START - aReplace: %d"), aReplace ) );
+
+    TFileName* fileName = new(ELeave) TFileName();
+    CleanupStack::PushL( fileName );
+    GetSettingsFileNameL( *fileName );
+    TRACE( RDebug::Print( _L("CMemSpySettings::SettingsFileLC() - fileName: %S"), fileName ) );
+
+    RFile file;
+    TInt error = KErrNone;
+    //
+    if  ( aReplace )
+        {
+        error = file.Replace( iFsSession, *fileName, EFileWrite );
+        TRACE( RDebug::Print( _L("CMemSpySettings::SettingsFileLC() - replace err: %d"), error ) );
+        }
+    else
+        {
+        error = file.Open( iFsSession, *fileName, EFileWrite );
+        TRACE( RDebug::Print( _L("CMemSpySettings::SettingsFileLC() - open err: %d"), error ) );
+        //
+        if  ( error == KErrNotFound )
+            {
+            error = file.Create( iFsSession, *fileName, EFileWrite );
+            }
+        }
+    //
+    User::LeaveIfError( error );
+    CleanupStack::PopAndDestroy( fileName );
+    CleanupClosePushL( file );
+    //
+    TRACE( RDebug::Print( _L("CMemSpySettings::SettingsFileLC() - END") ) );
+    return file;
+    }
+
+
+void CMemSpySettings::StoreSettingsL()
+    {
+    TRACE( RDebug::Printf( "CMemSpySettings::StoreSettingsL() - START" ) );
+
+    RFile file = SettingsFileLC( ETrue );
+    RFileWriteStream stream( file );
+    CleanupStack::Pop(); // file
+    CleanupClosePushL( stream );
+    
+    // Verion info
+    stream.WriteInt32L( KMemSpySettingsFileFormatVersion );
+    
+    // Engine settings
+    TRACE( RDebug::Printf( "CMemSpySettings::StoreSettingsL() - sinkType: %d", iEngine.SinkType() ) );
+    stream.WriteUint8L( iEngine.SinkType() );
+
+    // Get SWMT config
+    CMemSpyEngineHelperSysMemTracker& swmt = iEngine.HelperSysMemTracker();
+    TMemSpyEngineHelperSysMemTrackerConfig swmtConfig;
+    swmt.GetConfig( swmtConfig );
+
+    // Write SWMT settings
+    stream.WriteInt32L( swmtConfig.TimerPeriod().Int() );
+    stream.WriteUint8L( swmtConfig.DumpData() );
+    
+    // Write memory tracking auto-start process list
+    const RArray<TUid>& processUidList = iEngine.HelperProcess().MemoryTrackingAutoStartProcessList();
+    stream.WriteInt32L( processUidList.Count() );
+    for( TInt i=0; i<processUidList.Count(); i++ )
+        {
+        const TUid uid = processUidList[ i ];
+        TRACE( RDebug::Printf( "CMemSpySettings::StoreSettingsL() - process tracker uid[%02d]: 0x%08x", i, uid.iUid ) );
+        stream << uid;
+        }
+
+    // Write memory tracking categories
+    stream.WriteInt32L( swmtConfig.iEnabledCategories );
+    
+    // Write heap tracking thread name filter
+    stream.WriteInt32L( swmtConfig.iThreadNameFilter.Length() );
+    if ( swmtConfig.iThreadNameFilter.Length() > 0 )
+        {
+        stream.WriteL( swmtConfig.iThreadNameFilter, swmtConfig.iThreadNameFilter.Length() );
+        }
+    
+    // Write mode
+    stream.WriteInt32L( swmtConfig.iMode );
+    
+    stream.CommitL();
+    CleanupStack::PopAndDestroy( &stream ); // Closes file
+    TRACE( RDebug::Printf( "CMemSpySettings::StoreSettingsL() - END - sinkType: %d", iEngine.SinkType() ) );
+    }
+
+
+void CMemSpySettings::RestoreSettingsL()
+    {
+    TRACE( RDebug::Printf( "CMemSpySettings::RestoreSettingsL() - START - current engine sinkType: %d", iEngine.SinkType() ) );
+
+    RFile file = SettingsFileLC();
+    RFileReadStream stream( file );
+    CleanupStack::Pop(); // file
+    CleanupClosePushL( stream );
+    
+    // Version info
+    const TInt version = stream.ReadInt32L(); // discarded for now
+    TRACE( RDebug::Printf( "CMemSpySettings::RestoreSettingsL() - version: %d", version ) );
+
+    // Engine settings
+    TMemSpySinkType type = static_cast< TMemSpySinkType >( stream.ReadUint8L() );
+    TRACE( RDebug::Printf( "CMemSpySettings::RestoreSettingsL() - read sinkType: %d", type ) );
+    iEngine.InstallSinkL( type );
+    
+    // Set SWMT config
+    TMemSpyEngineHelperSysMemTrackerConfig swmtConfig;
+    swmtConfig.iTimerPeriod = TTimeIntervalMicroSeconds32( stream.ReadInt32L() );
+    swmtConfig.iDumpData = static_cast< TBool >( stream.ReadUint8L() );
+
+    if  ( version < 3 )
+        {
+        // Restore but ignore old delta tracker settings which aren't used anymore
+        //
+        /* iHeapDeltaTrackerIncludeKernel =*/ static_cast< TBool >( stream.ReadUint8L() );
+        /* iHeapDeltaTrackerCheckAllocCellCounts =*/ static_cast< TBool >( stream.ReadUint8L() );
+        /* iHeapDeltaTrackerCheckFreeCellCounts =*/ static_cast< TBool >( stream.ReadUint8L() );
+        }
+    
+    // Restore memory tracking auto-start process uids if file format supports it...
+    if ( version >= 2 )
+        {
+        RArray<TUid> list;
+        CleanupClosePushL( list );
+        //
+        const TInt count = stream.ReadInt32L();
+        for( TInt i=0; i<count; i++ )
+            {
+            TUid processUid;
+            stream >> processUid;
+            //
+            TRACE( RDebug::Printf( "CMemSpySettings::RestoreSettingsL() - process tracker uid[%02d]: 0x%08x", i, processUid.iUid ) );
+            User::LeaveIfError( list.Append( processUid ) );
+            }
+        //
+        CMemSpyEngineHelperProcess& processHelper = iEngine.HelperProcess();
+        processHelper.SetMemoryTrackingAutoStartProcessListL( list );
+        CleanupStack::PopAndDestroy( &list );
+        }
+    
+    // Restore memory tracking categories 
+    if ( version > 3 )
+        {
+        swmtConfig.iEnabledCategories = stream.ReadInt32L();
+        }
+    
+    // Write heap tracking thread name filter 
+    if ( version > 4 )
+        {
+        TInt len = stream.ReadInt32L();
+        if ( len > 0 )
+            {
+            stream.ReadL( swmtConfig.iThreadNameFilter, len );
+            }
+        }
+
+    // Write mode
+    if ( version > 5 )
+        {
+        swmtConfig.iMode = (TMemSpyEngineHelperSysMemTrackerConfig::TMemSpyEngineSysMemTrackerMode)stream.ReadInt32L();
+        }
+    
+    CMemSpyEngineHelperSysMemTracker& swmt = iEngine.HelperSysMemTracker();
+    swmt.SetConfigL( swmtConfig );
+
+    CleanupStack::PopAndDestroy( &stream ); // Closes file
+    TRACE( RDebug::Printf( "CMemSpySettings::RestoreSettingsL() - END - engine sink type: %d", iEngine.SinkType() ) );
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyUiUtils.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,65 @@
+/*
+* 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 "MemSpyUiUtils.h"
+
+// System includes
+#include <coemain.h>
+#include <memspyui.rsg>
+
+
+
+
+void MemSpyUiUtils::Format( TDes& aBuf, TInt aResourceId, ...)
+    {
+	VA_LIST list;
+    VA_START(list,aResourceId);
+	TBuf<128> format;
+	CCoeEnv::Static()->ReadResource( format, aResourceId );
+	aBuf.FormatList( format, list );
+    }
+
+
+void MemSpyUiUtils::GetErrorText( TDes& aBuf, TInt aError )
+    {
+    if  ( aError == KErrNotSupported )
+        {
+        _LIT( KMemSpyErrorText, "Not Supported" );
+        aBuf = KMemSpyErrorText;
+        }
+    else if ( aError == KErrNotReady )
+        {
+        _LIT( KMemSpyErrorText, "Not Ready" );
+        aBuf = KMemSpyErrorText;
+        }
+    else if ( aError == KErrNotFound )
+        {
+        _LIT( KMemSpyErrorText, "Missing" );
+        aBuf = KMemSpyErrorText;
+        }
+    else if ( aError == KErrGeneral )
+        {
+        _LIT( KMemSpyErrorText, "General Error" );
+        aBuf = KMemSpyErrorText;
+        }
+    else
+        {
+        _LIT( KMemSpyItemValueError, "Error: %d" );
+        aBuf.Format( KMemSpyItemValueError, aError );
+        }
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewBase.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,413 @@
+/*
+* 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 "MemSpyViewBase.h"
+
+// System includes
+#include <eikrted.h>  // for example label control
+#include <txtrich.h>
+#include <apgtask.h>
+#include <akntitle.h>
+#include <akncontext.h>
+#include <aknnavi.h>
+#include <eiklbx.h>
+#include <eiklbm.h>
+#include <avkon.hrh>
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineutils.h>
+#include <memspy/engine/memspyengineoutputsink.h>
+
+// User includes
+#include "MemSpyAppUi.h"
+#include "MemSpyDocument.h"
+#include "MemSpyContainer.h"
+#include "MemSpyContainerObserver.h"
+
+
+
+
+CMemSpyViewBase::CMemSpyViewBase( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
+:   iEngine( aEngine ), iObserver( aObserver )
+    {
+    }
+
+
+CMemSpyViewBase::~CMemSpyViewBase()
+    {
+    delete iListBox;
+    }
+ 
+
+void CMemSpyViewBase::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* /*aSelectionRune*/ )
+    {
+    iSettings = &static_cast< CMemSpyAppUi* >( iEikonEnv->EikAppUi() )->MemSpyDocument().Settings();
+    //
+    User::LeaveIfError( SetParent( &aContainer ) );
+    SetContainerWindowL( aContainer );
+    
+    SetComponentsToInheritVisibility( ETrue );
+
+    iListBox = ConstructListBoxL();
+    if  ( iListBox )
+        {
+        iListBox->SetFocus( ETrue );
+        }
+
+    SetRect( aRect );
+    ActivateL();
+    }
+
+
+void CMemSpyViewBase::SetTitleL( const TDesC& aText )
+    {
+    CEikStatusPane* statusPane = static_cast<CAknAppUi*> ( iEikonEnv->EikAppUi() )->StatusPane();
+    CAknTitlePane* title = static_cast<CAknTitlePane*> ( statusPane->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
+    title->SetTextL( aText );
+    }
+
+
+TPtrC CMemSpyViewBase::TitleL() const
+    {
+    TPtrC ret( KNullDesC );
+    //
+    CEikStatusPane* statusPane = static_cast<CAknAppUi*> ( iEikonEnv->EikAppUi() )->StatusPane();
+    CAknTitlePane* title = static_cast<CAknTitlePane*> ( statusPane->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
+    if  ( title->Text() )
+        {
+        ret.Set( *title->Text() );
+        }
+    //
+    return ret;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewBase::PrepareParentViewL()
+    {
+    return NULL;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewBase::PrepareChildViewL()
+    {
+    return NULL;
+    }
+    
+    
+void CMemSpyViewBase::RefreshL()
+    {
+    if  ( iListBox )
+        {
+        iListBox->UpdateScrollBarsL();
+        }
+
+    DrawDeferred();
+    }
+
+
+TBool CMemSpyViewBase::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = ETrue;
+    //
+    switch( aCommand )
+        {
+	case EMemSpyCmdViewOutputToSink:
+        OnCmdViewOutputToSinkL();
+        break;
+    default:
+        handled = EFalse;
+        break;
+        }
+    //
+    return handled;
+    }
+
+
+void CMemSpyViewBase::DynInitMenuPaneL( TInt /*aResourceId*/, CEikMenuPane* /*aMenuPane*/ )
+    {
+    }
+
+
+TUint CMemSpyViewBase::MenuCascadeResourceId() const
+    {
+    return 0;
+    }
+
+
+TInt CMemSpyViewBase::MenuCascadeCommandId() const
+    {
+    return 0;
+    }
+
+
+void CMemSpyViewBase::OnCmdViewOutputToSinkL()
+    {
+    if  ( iListBox )
+        {
+        // Prepare sink
+        CMemSpyEngineOutputSink& sink = iEngine.Sink();
+        HBufC* name = MemSpyEngineUtils::CleanupTextLC( TitleL() );
+        sink.OutputSectionHeadingL( *name, TChar('-') );
+        CleanupStack::PopAndDestroy( name );
+        sink.OutputPrefixSetLC( _L("  ") ); // Slight insertion
+        
+        // Get text from underlying listbox model...
+        MTextListBoxModel* model = static_cast< MTextListBoxModel* >( iListBox->Model() );
+        const TInt count = model->NumberOfItems();
+
+        // First pass to get max lengths
+        TInt maxLengthCaption = 0;
+        TInt maxLengthValue = 0;
+
+        for( TInt j=0; j<count; j++ )
+            {
+            const TPtrC pItem( model->ItemText( j ) );
+            const TInt length = pItem.Length();
+    
+            // Check if its split or not?
+            const TInt splitPos = pItem.FindF( _L("\t\t") );
+            if  ( splitPos > 0 )
+                {
+                maxLengthCaption = Max( maxLengthCaption, splitPos );
+                maxLengthValue = Max( maxLengthValue, length - splitPos + 1 );
+                }
+            else
+                {
+                maxLengthCaption = Max( maxLengthCaption, length );
+                }
+            }
+
+        // Second pass - real this time - to print the values
+        HBufC* line = HBufC::NewLC( ( maxLengthCaption + maxLengthValue ) + 20 );
+        TPtr pLine( line->Des() );
+        //
+        for( TInt i=0; i<count; i++ )
+            {
+            const TPtrC pItem( model->ItemText( i ) );
+            const TInt length = pItem.Length();
+            //
+            TPtrC pCaption( KNullDesC );
+            TPtrC pValue( KNullDesC );
+            //
+            const TInt splitPos = pItem.FindF( _L("\t\t") );
+            if  ( splitPos > 0 )
+                {
+                pCaption.Set( pItem.Left( splitPos ) );
+                pValue.Set( pItem.Mid( splitPos + 1 ) );
+                }
+            else
+                {
+                pCaption.Set( pItem );
+                }
+
+            // Remove initial tabs in caption
+            HBufC* caption = MemSpyEngineUtils::CleanupTextLC( pCaption );
+        
+            // Create value item & replace any further tabs
+            HBufC* value = MemSpyEngineUtils::CleanupTextLC( pValue );
+
+            // Now format the final line, with padding.
+            pLine.Justify( *caption, maxLengthCaption + 3, ELeft, TChar(' ') );
+            pLine.Append( *value );
+            CleanupStack::PopAndDestroy( 2, caption );
+
+            // Sink output
+            sink.OutputLineL( pLine );
+            }
+
+        // Remove prefix & tidy up
+        CleanupStack::PopAndDestroy( line );
+        sink.OutputBlankLineL();
+        CleanupStack::PopAndDestroy(); // clear prefix
+        }
+    }
+
+
+CEikListBox* CMemSpyViewBase::ConstructListBoxL()
+    {
+    delete iListBox;
+    iListBox = NULL;
+    CAknSettingStyleListBox* listbox = new(ELeave) CAknSettingStyleListBox();
+    iListBox = listbox;
+    //
+    listbox->ConstructL( this, EAknListBoxSelectionList | EAknListBoxLoopScrolling );
+    listbox->SetContainerWindowL( *this );
+    listbox->CreateScrollBarFrameL( ETrue );
+    SetListBoxModelL();
+    listbox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
+    listbox->SetListBoxObserver( this );
+    listbox->SetObserver( this );
+    listbox->SetComponentsToInheritVisibility( ETrue );
+    //
+    return listbox;
+    }
+
+
+void CMemSpyViewBase::HandleListBoxItemActionedL( TInt /*aIndex*/ )
+    {
+    ReportEventL( MMemSpyViewObserver::EEventItemActioned );
+    }
+
+
+void CMemSpyViewBase::HandleListBoxItemSelectedL( TInt /*aIndex*/ )
+    {
+    ReportEventL( MMemSpyViewObserver::EEventItemSelected );
+    }
+
+
+void CMemSpyViewBase::ReportEventL( MMemSpyViewObserver::TViewEventType aEvent, TAny* aContext )
+    {
+    iObserver.HandleMemSpyViewEventL( aEvent, ViewType(), *this, aContext );
+    }
+
+
+void CMemSpyViewBase::SetListBoxCurrentItemIndexL( TInt aIndex )
+    {
+    if  ( iListBox )
+        {
+        iListBox->SetCurrentItemIndex( aIndex );
+        HandleListBoxItemSelectedL( aIndex );
+        }
+    }
+
+
+CMemSpyContainer& CMemSpyViewBase::Container()
+    {
+    CMemSpyAppUi* appUi = static_cast< CMemSpyAppUi* >( iEikonEnv->EikAppUi() );
+    return appUi->Container();
+    }
+
+
+CMemSpySettings& CMemSpyViewBase::Settings()
+    {
+    return *iSettings;
+    }
+
+
+const CMemSpySettings& CMemSpyViewBase::Settings() const
+    {
+    return *iSettings;
+    }
+
+    
+void CMemSpyViewBase::Draw( const TRect& aRect ) const
+    {
+    CWindowGc& gc = SystemGc();
+    //
+    gc.SetPenStyle( CGraphicsContext::ENullPen );
+    gc.SetBrushColor( KRgbWhite );
+    gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
+    gc.DrawRect( aRect );
+    }
+
+
+void CMemSpyViewBase::SizeChanged()
+    {
+    if  ( iListBox )
+        {
+        iListBox->SetRect( Rect() );
+        }
+    }
+
+
+void CMemSpyViewBase::FocusChanged(TDrawNow /*aDrawNow*/)
+    {
+    if  ( iListBox )
+        {
+        iListBox->SetFocus( IsFocused() );
+        }
+    }
+
+
+TInt CMemSpyViewBase::CountComponentControls() const
+    {
+    TInt count = 0;
+    if  ( iListBox )
+        {
+        ++count;
+        }
+    //
+    return count;
+    }
+
+
+CCoeControl* CMemSpyViewBase::ComponentControl(TInt aIndex) const
+    {
+    switch ( aIndex )
+        {
+    case 0:
+        return iListBox;
+    default:
+        return NULL;
+        }
+    }
+
+
+TKeyResponse CMemSpyViewBase::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
+	{
+    TKeyResponse resp = EKeyWasNotConsumed;
+    if  ( iListBox )
+        {
+        resp = iListBox->OfferKeyEventL( aKeyEvent, aType );
+        }
+    //
+    if ( resp == EKeyWasNotConsumed && aType == EEventKeyDown && aKeyEvent.iCode == EKeyBackspace )
+        {
+        // When backspace is pushed, go to the parent view
+        CMemSpyAppUi* appUi = static_cast< CMemSpyAppUi* >( iEikonEnv->EikAppUi() );
+        appUi->Container().NavigateToParentViewL();
+        resp = EKeyWasConsumed;
+        }
+    //
+	return resp;
+	}
+
+
+void CMemSpyViewBase::HandleControlEventL( CCoeControl* aControl,TCoeEvent aEventType )
+    {
+    if  ( aControl == iListBox )
+        {
+        if  ( aEventType == MCoeControlObserver::EEventStateChanged )
+            {
+            const TInt index = iListBox->CurrentItemIndex();
+            HandleListBoxItemSelectedL( index );
+            }
+        }
+    }
+
+
+void CMemSpyViewBase::HandleListBoxEventL( CEikListBox* /*aListBox*/, TListBoxEvent aEventType )
+    {
+    const TInt index = iListBox->CurrentItemIndex();
+    //
+    switch (aEventType)
+        {
+    case EEventItemActioned:
+    case EEventEnterKeyPressed:
+    case EEventItemDoubleClicked:
+        HandleListBoxItemActionedL( index );
+        break;
+
+    default:
+        break;
+        }
+    }
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewChunkList.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,346 @@
+/*
+* 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 "MemSpyViewChunkList.h"
+
+// System includes
+#include <memspyui.rsg>
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyenginehelperprocess.h>
+#include <memspy/engine/memspyenginehelperchunk.h>
+
+// User includes
+#include "MemSpyUiUtils.h"
+#include "MemSpyViewMainMenu.h"
+
+
+
+CMemSpyViewChunkBase::CMemSpyViewChunkBase( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineChunkList* aList )
+:   CMemSpyViewBase( aEngine, aObserver ), iList( aList )
+    {
+    }
+
+
+CMemSpyViewChunkBase::~CMemSpyViewChunkBase()
+    {
+    delete iList;
+    }
+
+
+TBool CMemSpyViewChunkBase::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = ETrue;
+    //
+    switch ( aCommand )
+        {
+    case EMemSpyCmdChunkSortByName:
+        iList->SortByNameL();
+        CMemSpyViewBase::RefreshL();
+        break;
+    case EMemSpyCmdChunkSortBySize:
+        iList->SortBySizeL();
+        CMemSpyViewBase::RefreshL();
+        break;
+    case EMemSpyCmdChunkListing:
+        OnCmdListingL();
+        break;
+    default:
+        handled = CMemSpyViewBase::HandleCommandL( aCommand );
+        break;
+        }
+    //
+    return handled;
+    }
+
+
+void CMemSpyViewChunkBase::OnCmdListingL()
+    {
+    // Begin a new data stream
+    _LIT( KMemSpyContext, "Chunk List" );
+    _LIT( KMemSpyFolder, "Chunks" );
+    iEngine.Sink().DataStreamBeginL( KMemSpyContext, KMemSpyFolder );
+
+    // Set prefix for overall listing
+    _LIT( KOverallPrefix, "Chunk List - " );
+    iEngine.Sink().OutputPrefixSetLC( KOverallPrefix );
+
+    // Create header
+    CMemSpyEngineChunkList::OutputDataColumnsL( iEngine );
+    
+    // List items
+    const TInt count = iList->Count();
+    for(TInt i=0; i<count; i++)
+        {
+        const CMemSpyEngineChunkEntry& entry = iList->At( i );
+        //
+        entry.OutputDataL( iEngine.HelperChunk() );
+        }
+
+    // Tidy up
+    CleanupStack::PopAndDestroy(); // prefix
+
+    // End data stream
+    iEngine.Sink().DataStreamEndL();
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+CMemSpyViewChunkList::CMemSpyViewChunkList( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
+:   CMemSpyViewChunkBase( aEngine, aObserver, NULL )
+    {
+    }
+
+
+CMemSpyViewChunkList::CMemSpyViewChunkList( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineChunkList& aList )
+:   CMemSpyViewChunkBase( aEngine, aObserver, &aList )
+    {
+    }
+
+
+void CMemSpyViewChunkList::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    _LIT( KTitle, "Chunks" );
+    SetTitleL( KTitle );
+
+    if  ( iList == NULL )
+        {
+        // Prepare code segment list
+        iList = iEngine.HelperChunk().ListL();
+        }
+
+    // Finish construction
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+
+    if  ( aSelectionRune != NULL )
+        {
+        iCurrentChunk = reinterpret_cast< CMemSpyEngineChunkEntry* >( aSelectionRune );
+        const TInt index = iList->ItemIndex( *iCurrentChunk );
+        iListBox->SetCurrentItemIndex( index );
+        HandleListBoxItemSelectedL( index );
+        }
+
+    iListBox->DrawDeferred();
+    }
+
+
+TMemSpyViewType CMemSpyViewChunkList::ViewType() const
+    {
+    return EMemSpyViewTypeChunkList;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewChunkList::PrepareParentViewL()
+    {
+    CMemSpyViewMainMenu* parent = new(ELeave) CMemSpyViewMainMenu( iEngine, iObserver );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewChunkList::PrepareChildViewL()
+    {
+    CMemSpyViewBase* child = new(ELeave) CMemSpyViewChunkDetails( iEngine, iObserver, *iList, *iCurrentChunk );
+
+    // Ownership is transferred to child. Cleanupstack guarantees it will be destroyed now.
+    // This object is about to die in any case.
+    iList = NULL;
+
+    CleanupStack::PushL( child );
+    child->ConstructL( Rect(), *Parent() );
+    CleanupStack::Pop( child );
+    return child;
+    }
+
+
+void CMemSpyViewChunkList::SetListBoxModelL()
+    {
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( iList );
+    listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+
+
+void CMemSpyViewChunkList::HandleListBoxItemActionedL( TInt aIndex )
+    {
+    const TInt count = iList->Count();
+    if  ( aIndex >= 0 && aIndex < count )
+        {
+        CMemSpyEngineChunkEntry& chunk = iList->At( aIndex );
+        iCurrentChunk = &chunk;
+        }
+    else
+        {
+        iCurrentChunk = NULL;
+        }
+
+    // Notify observer about item selection
+    ReportEventL( MMemSpyViewObserver::EEventItemActioned );
+    }
+
+
+void CMemSpyViewChunkList::HandleListBoxItemSelectedL( TInt aIndex )
+    {
+    const TInt count = iList->Count();
+    if  ( aIndex >= 0 && aIndex < count )
+        {
+        CMemSpyEngineChunkEntry& chunk = iList->At( aIndex );
+        iCurrentChunk = &chunk;
+        }
+    else
+        {
+        iCurrentChunk = NULL;
+        }
+
+    // Notify observer about item selection
+    ReportEventL( MMemSpyViewObserver::EEventItemSelected );
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+CMemSpyViewChunkDetails::CMemSpyViewChunkDetails( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineChunkList& aList, CMemSpyEngineChunkEntry& aSelectedChunk )
+:   CMemSpyViewChunkBase( aEngine, aObserver, &aList ), iChunk( aSelectedChunk )
+    {
+    }
+
+
+void CMemSpyViewChunkDetails::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    _LIT( KTitle, "Chunk Details" );
+    SetTitleL( KTitle );
+
+    // Finish construction
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+    }
+
+
+void CMemSpyViewChunkDetails::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewChunkDetails::ViewType() const
+    {
+    return EMemSpyViewTypeChunkDetails;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewChunkDetails::PrepareParentViewL()
+    {
+    CMemSpyViewChunkList* parent = new(ELeave) CMemSpyViewChunkList( iEngine, iObserver, *iList );
+
+    // Ownership is transferred to child. Cleanupstack guarantees it will be destroyed now.
+    // This object is about to die in any case.
+    iList = NULL;
+
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), &iChunk );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+void CMemSpyViewChunkDetails::SetListBoxModelL()
+    {
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( &iChunk );
+    listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewCodeSegList.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,500 @@
+/*
+* 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 "MemSpyViewCodeSegList.h"
+
+// System includes
+#include <memspyui.rsg>
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyenginehelperprocess.h>
+#include <memspy/engine/memspyenginehelpercodesegment.h>
+
+// User includes
+#include "MemSpyUiUtils.h"
+#include "MemSpyViewMainMenu.h"
+#include "MemSpyViewThreads.h"
+#include "MemSpyContainerObserver.h"
+#include "MemSpyExportBitmapsToMemoryCardDialog.h"
+
+
+
+CMemSpyViewCodeSegBase::CMemSpyViewCodeSegBase( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineCodeSegList* aList )
+:   CMemSpyViewBase( aEngine, aObserver ), iList( aList )
+    {
+    }
+
+
+CMemSpyViewCodeSegBase::~CMemSpyViewCodeSegBase()
+    {
+    delete iList;
+    }
+
+
+TBool CMemSpyViewCodeSegBase::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = ETrue;
+    //
+    switch ( aCommand )
+        {
+    case EMemSpyCmdCodeSegSortByName:
+        iList->SortByFileNameL();
+        CMemSpyViewBase::RefreshL();
+        break;
+    case EMemSpyCmdCodeSegSortByCodeSize:
+        iList->SortByCodeSizeL();
+        CMemSpyViewBase::RefreshL();
+        break;
+    case EMemSpyCmdCodeSegSortByDataSize:
+        iList->SortByDataSizeL();
+        CMemSpyViewBase::RefreshL();
+        break;
+    case EMemSpyCmdCodeSegSortByUid:
+        iList->SortByUidsL();
+        CMemSpyViewBase::RefreshL();
+        break;
+    case EMemSpyCmdCodeSegListing:
+        OnCmdCodeSegmentListingL();
+        break;
+    case EMemSpyCmdCodeSegShowItemsAll:
+        OnCmdShowItemsAllL();
+        break;
+    case EMemSpyCmdCodeSegShowItemsGlobalData:
+        OnCmdShowItemsGlobalDataL();
+        break;
+
+    case EMemSpyCmdCodeSegShowCapsWithTCBProcess:
+    case EMemSpyCmdCodeSegShowCapsWithTCBAll:              
+        OnCmdFilterByCapabilityL( ECapabilityTCB, aCommand == EMemSpyCmdCodeSegShowCapsWithTCBAll );
+        break;
+    case EMemSpyCmdCodeSegShowCapsWithCommDDProcess:
+    case EMemSpyCmdCodeSegShowCapsWithCommDDAll:
+        OnCmdFilterByCapabilityL( ECapabilityCommDD, aCommand == EMemSpyCmdCodeSegShowCapsWithCommDDAll );
+        break;
+    case EMemSpyCmdCodeSegShowCapsWithPowerMgmtProcess:
+    case EMemSpyCmdCodeSegShowCapsWithPowerMgmtAll:
+        OnCmdFilterByCapabilityL( ECapabilityPowerMgmt, aCommand == EMemSpyCmdCodeSegShowCapsWithPowerMgmtAll );
+        break;
+    case EMemSpyCmdCodeSegShowCapsWithMultimediaDDProcess:
+    case EMemSpyCmdCodeSegShowCapsWithMultimediaDDAll:
+        OnCmdFilterByCapabilityL( ECapabilityMultimediaDD, aCommand == EMemSpyCmdCodeSegShowCapsWithMultimediaDDAll );
+        break;
+    case EMemSpyCmdCodeSegShowCapsWithReadDeviceDataProcess:
+    case EMemSpyCmdCodeSegShowCapsWithReadDeviceDataAll:
+        OnCmdFilterByCapabilityL( ECapabilityReadDeviceData, aCommand == EMemSpyCmdCodeSegShowCapsWithReadDeviceDataAll );
+        break;
+    case EMemSpyCmdCodeSegShowCapsWithWriteDeviceDataProcess:
+    case EMemSpyCmdCodeSegShowCapsWithWriteDeviceDataAll:
+        OnCmdFilterByCapabilityL( ECapabilityWriteDeviceData, aCommand == EMemSpyCmdCodeSegShowCapsWithWriteDeviceDataAll );
+        break;
+    case EMemSpyCmdCodeSegShowCapsWithDRMProcess:
+    case EMemSpyCmdCodeSegShowCapsWithDRMAll:
+        OnCmdFilterByCapabilityL( ECapabilityDRM, aCommand == EMemSpyCmdCodeSegShowCapsWithDRMAll );
+        break;
+    case EMemSpyCmdCodeSegShowCapsWithTrustedUIProcess:
+    case EMemSpyCmdCodeSegShowCapsWithTrustedUIAll:
+        OnCmdFilterByCapabilityL( ECapabilityTrustedUI, aCommand == EMemSpyCmdCodeSegShowCapsWithTrustedUIAll );
+        break;
+    case EMemSpyCmdCodeSegShowCapsWithProtServProcess:
+    case EMemSpyCmdCodeSegShowCapsWithProtServAll:
+        OnCmdFilterByCapabilityL( ECapabilityProtServ, aCommand == EMemSpyCmdCodeSegShowCapsWithProtServAll );
+        break;
+    case EMemSpyCmdCodeSegShowCapsWithDiskAdminProcess:
+    case EMemSpyCmdCodeSegShowCapsWithDiskAdminAll:
+        OnCmdFilterByCapabilityL( ECapabilityDiskAdmin, aCommand == EMemSpyCmdCodeSegShowCapsWithDiskAdminAll );
+        break;
+    case EMemSpyCmdCodeSegShowCapsWithNetworkControlProcess:
+    case EMemSpyCmdCodeSegShowCapsWithNetworkControlAll:
+        OnCmdFilterByCapabilityL( ECapabilityNetworkControl, aCommand == EMemSpyCmdCodeSegShowCapsWithNetworkControlAll );
+        break;
+    case EMemSpyCmdCodeSegShowCapsWithAllFilesProcess:
+    case EMemSpyCmdCodeSegShowCapsWithAllFilesAll:
+        OnCmdFilterByCapabilityL( ECapabilityAllFiles, aCommand == EMemSpyCmdCodeSegShowCapsWithAllFilesAll );
+        break;
+    case EMemSpyCmdCodeSegShowCapsWithSwEventProcess:
+    case EMemSpyCmdCodeSegShowCapsWithSwEventAll:
+        OnCmdFilterByCapabilityL( ECapabilitySwEvent, aCommand == EMemSpyCmdCodeSegShowCapsWithSwEventAll );
+        break;
+    case EMemSpyCmdCodeSegShowCapsWithNetworkServicesProcess:
+    case EMemSpyCmdCodeSegShowCapsWithNetworkServicesAll:
+        OnCmdFilterByCapabilityL( ECapabilityNetworkServices, aCommand == EMemSpyCmdCodeSegShowCapsWithNetworkServicesAll );
+        break;
+    case EMemSpyCmdCodeSegShowCapsWithLocalServicesProcess:
+    case EMemSpyCmdCodeSegShowCapsWithLocalServicesAll:
+        OnCmdFilterByCapabilityL( ECapabilityLocalServices, aCommand == EMemSpyCmdCodeSegShowCapsWithLocalServicesAll );
+        break;
+    case EMemSpyCmdCodeSegShowCapsWithReadUserDataProcess:
+    case EMemSpyCmdCodeSegShowCapsWithReadUserDataAll:
+        OnCmdFilterByCapabilityL( ECapabilityReadUserData, aCommand == EMemSpyCmdCodeSegShowCapsWithReadUserDataAll );
+        break;
+    case EMemSpyCmdCodeSegShowCapsWithWriteUserDataProcess:
+    case EMemSpyCmdCodeSegShowCapsWithWriteUserDataAll:
+        OnCmdFilterByCapabilityL( ECapabilityWriteUserData, aCommand == EMemSpyCmdCodeSegShowCapsWithWriteUserDataAll );
+        break;
+    case EMemSpyCmdCodeSegShowCapsWithLocationProcess:
+    case EMemSpyCmdCodeSegShowCapsWithLocationAll:
+        OnCmdFilterByCapabilityL( ECapabilityLocation, aCommand == EMemSpyCmdCodeSegShowCapsWithLocationAll );
+        break;
+    case EMemSpyCmdCodeSegShowCapsWithSurroundingsDDProcess:
+    case EMemSpyCmdCodeSegShowCapsWithSurroundingsDDAll:
+        OnCmdFilterByCapabilityL( ECapabilitySurroundingsDD, aCommand == EMemSpyCmdCodeSegShowCapsWithSurroundingsDDAll );
+        break;
+    case EMemSpyCmdCodeSegShowCapsWithUserEnvProcess:
+    case EMemSpyCmdCodeSegShowCapsWithUserEnvAll:
+        OnCmdFilterByCapabilityL( ECapabilityUserEnvironment, aCommand == EMemSpyCmdCodeSegShowCapsWithUserEnvAll );
+        break;
+    default:
+        handled = CMemSpyViewBase::HandleCommandL( aCommand );
+        break;
+        }
+    //
+    return handled;
+    }
+
+
+void CMemSpyViewCodeSegBase::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+void CMemSpyViewCodeSegBase::OnCmdCodeSegmentListingL()
+    {
+    // Begin a new data stream
+    _LIT( KMemSpyContext, "CodeSeg List - " );
+    _LIT( KMemSpyFolder, "CodeSegs" );
+    iEngine.Sink().DataStreamBeginL( KMemSpyContext, KMemSpyFolder );
+
+    // Set prefix for overall listing
+    _LIT(KOverallPrefix, "CodeSeg List - ");
+    iEngine.Sink().OutputPrefixSetLC( KOverallPrefix );
+
+    // Create header
+    CMemSpyEngineCodeSegList::OutputDataColumnsL( iEngine );
+    
+    // List items
+    const TInt count = iList->Count();
+    for(TInt i=0; i<count; i++)
+        {
+        const CMemSpyEngineCodeSegEntry& entry = iList->At( i );
+        //
+        entry.OutputDataL( iEngine.HelperCodeSegment() );
+        }
+
+    // Tidy up
+    CleanupStack::PopAndDestroy(); // prefix
+
+    // End data stream
+    iEngine.Sink().DataStreamEndL();
+    }
+
+
+void CMemSpyViewCodeSegBase::OnCmdShowItemsAllL()
+    {
+    iList->ShowAllL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+void CMemSpyViewCodeSegBase::OnCmdShowItemsGlobalDataL()
+    {
+    iList->ShowOnlyEntriesWithGlobalDataL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+void CMemSpyViewCodeSegBase::OnCmdFilterByCapabilityL( TCapability aCapability, TBool aAllBinaries )
+    {
+    TMemSpyViewCodeSegFilter filterLogic( aCapability, aAllBinaries );
+    TMemSpyEngineVisibiltyFunction<CMemSpyEngineCodeSegEntry> filterFunction( TMemSpyViewCodeSegFilter::FilterItem, &filterLogic );
+    iList->ShowL( filterFunction );
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+CMemSpyViewCodeSegList::CMemSpyViewCodeSegList( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
+:   CMemSpyViewCodeSegBase( aEngine, aObserver, NULL )
+    {
+    }
+
+
+CMemSpyViewCodeSegList::CMemSpyViewCodeSegList( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineCodeSegList& aList )
+:   CMemSpyViewCodeSegBase( aEngine, aObserver, &aList )
+    {
+    }
+
+
+void CMemSpyViewCodeSegList::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    _LIT( KTitle, "Code Segments" );
+    SetTitleL( KTitle );
+
+    if  ( iList == NULL )
+        {
+        // Prepare code segment list
+        iList = iEngine.HelperCodeSegment().CodeSegmentListL();
+        iList->SortByCodeSizeL();
+        }
+
+    // Finish construction
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+
+    if  ( aSelectionRune != NULL )
+        {
+        iCurrentCodeSegment = reinterpret_cast< CMemSpyEngineCodeSegEntry* >( aSelectionRune );
+        const TInt index = iList->ItemIndex( *iCurrentCodeSegment );
+        iListBox->SetCurrentItemIndex( index );
+        HandleListBoxItemSelectedL( index );
+        }
+
+    iListBox->DrawDeferred();
+    }
+
+
+TMemSpyViewType CMemSpyViewCodeSegList::ViewType() const
+    {
+    return EMemSpyViewTypeCodeSegmentList;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewCodeSegList::PrepareParentViewL()
+    {
+    CMemSpyViewMainMenu* parent = new(ELeave) CMemSpyViewMainMenu( iEngine, iObserver );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewCodeSegList::PrepareChildViewL()
+    {
+    CMemSpyViewBase* child = new(ELeave) CMemSpyViewCodeSegDetails( iEngine, iObserver, *iList, *iCurrentCodeSegment );
+
+    // Ownership is transferred to child. Cleanupstack guarantees it will be destroyed now.
+    // This object is about to die in any case.
+    iList = NULL;
+
+    CleanupStack::PushL( child );
+    child->ConstructL( Rect(), *Parent() );
+    CleanupStack::Pop( child );
+    return child;
+    }
+
+
+void CMemSpyViewCodeSegList::SetListBoxModelL()
+    {
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( iList );
+    listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+
+
+void CMemSpyViewCodeSegList::HandleListBoxItemActionedL( TInt aIndex )
+    {
+    const TInt count = iList->Count();
+    if  ( aIndex >= 0 && aIndex < count )
+        {
+        CMemSpyEngineCodeSegEntry& codeSeg = iList->At( aIndex );
+        iCurrentCodeSegment = &codeSeg;
+        }
+    else
+        {
+        iCurrentCodeSegment = NULL;
+        }
+
+    // Notify observer about item selection
+    ReportEventL( MMemSpyViewObserver::EEventItemActioned );
+    }
+
+
+void CMemSpyViewCodeSegList::HandleListBoxItemSelectedL( TInt aIndex )
+    {
+    const TInt count = iList->Count();
+    if  ( aIndex >= 0 && aIndex < count )
+        {
+        CMemSpyEngineCodeSegEntry& codeSeg = iList->At( aIndex );
+        iCurrentCodeSegment = &codeSeg;
+        }
+    else
+        {
+        iCurrentCodeSegment = NULL;
+        }
+
+    // Notify observer about item selection
+    ReportEventL( MMemSpyViewObserver::EEventItemSelected );
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+CMemSpyViewCodeSegDetails::CMemSpyViewCodeSegDetails( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineCodeSegList& aList, CMemSpyEngineCodeSegEntry& aSelectedCodeSegment )
+:   CMemSpyViewCodeSegBase( aEngine, aObserver, &aList ), iCodeSegment( aSelectedCodeSegment )
+    {
+    }
+
+
+void CMemSpyViewCodeSegDetails::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    _LIT( KTitle, "Code Segment Details" );
+    SetTitleL( KTitle );
+
+    // Finish construction
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+    }
+
+
+void CMemSpyViewCodeSegDetails::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewCodeSegDetails::ViewType() const
+    {
+    return EMemSpyViewTypeCodeSegmentDetails;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewCodeSegDetails::PrepareParentViewL()
+    {
+    CMemSpyViewCodeSegList* parent = new(ELeave) CMemSpyViewCodeSegList( iEngine, iObserver, *iList );
+
+    // Ownership is transferred to child. Cleanupstack guarantees it will be destroyed now.
+    // This object is about to die in any case.
+    iList = NULL;
+
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), &iCodeSegment );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+void CMemSpyViewCodeSegDetails::SetListBoxModelL()
+    {
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( &iCodeSegment );
+    listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+TBool TMemSpyViewCodeSegFilter::FilterItem( const CMemSpyEngineCodeSegEntry*& aItem, TAny* aRune )
+    {
+    TMemSpyViewCodeSegFilter* self = reinterpret_cast< TMemSpyViewCodeSegFilter* >( aRune );
+
+    TBool match = aItem->HasCapability( self->iCapability );
+    if  ( match && self->iAllBinaries == EFalse )
+        {
+        // We're only looking for EXE's...
+        TParsePtrC parser( aItem->FileName() );
+        const TPtrC pExtension( parser.Ext() );
+        _LIT(KProcessExtension, ".exe");
+        //
+        match = ( pExtension.CompareF( KProcessExtension ) == 0 );
+        }
+    //
+    return match;
+    }
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewDriveInfo.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,381 @@
+/*
+* 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 "MemSpyViewDriveInfo.h"
+
+// System includes
+#include <memspyui.rsg>
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyenginehelperprocess.h>
+#include <memspy/engine/memspyenginehelperfilesystem.h>
+
+// User includes
+#include "MemSpyUiUtils.h"
+#include "MemSpyViewMainMenu.h"
+
+
+
+CMemSpyViewDriveInfoBase::CMemSpyViewDriveInfoBase( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
+:   CMemSpyViewBase( aEngine, aObserver )
+    {
+    }
+
+
+CMemSpyViewDriveInfoBase::~CMemSpyViewDriveInfoBase()
+    {
+    if  ( iList )
+        {
+        iList->SetObserver( NULL );
+        }
+    //
+    delete iList;
+    }
+
+
+void CMemSpyViewDriveInfoBase::BaseConstructL()
+    {
+    iList = iEngine.HelperFileSystem().DriveListL();
+    }
+
+
+TBool CMemSpyViewDriveInfoBase::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = ETrue;
+    //
+    switch ( aCommand )
+        {
+    default:
+        handled = CMemSpyViewBase::HandleCommandL( aCommand );
+        break;
+        }
+    //
+    return handled;
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+CMemSpyViewDriveList::CMemSpyViewDriveList( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
+:   CMemSpyViewDriveInfoBase( aEngine, aObserver ), iUseDriveNumber( EFalse ), iDriveNumber( EDriveA )
+    {
+    }
+
+
+CMemSpyViewDriveList::CMemSpyViewDriveList( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, TDriveNumber aDriveNumber )
+:   CMemSpyViewDriveInfoBase( aEngine, aObserver ), iUseDriveNumber( ETrue ), iDriveNumber( aDriveNumber )
+    {
+    }
+
+
+void CMemSpyViewDriveList::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    BaseConstructL();
+
+    _LIT( KTitle, "Drive Summary" );
+    SetTitleL( KTitle );
+
+    // Start watching list
+    iList->SetObserver( this );
+
+    // Finish construction
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+
+    if  ( iUseDriveNumber )
+        {
+#ifdef _DEBUG
+        RDebug::Printf( "CMemSpyViewDriveList::ConstructL() - iDriveNumber: %c:", iDriveNumber + 'A' );
+#endif
+        iCurrentDrive = iList->EntryByDriveNumber( iDriveNumber );
+
+#ifdef _DEBUG
+        RDebug::Printf( "CMemSpyViewDriveList::ConstructL() - iCurrentDrive: 0x%08x", iCurrentDrive );
+#endif
+        if  ( iCurrentDrive )
+            {
+            const TInt index = iList->ItemIndex( *iCurrentDrive );
+#ifdef _DEBUG
+            RDebug::Printf( "CMemSpyViewDriveList::ConstructL() - index: %d", index );
+#endif
+            iListBox->SetCurrentItemIndex( index );
+            HandleListBoxItemSelectedL( index );
+            }
+        }
+    
+    iListBox->DrawDeferred();
+    }
+
+
+TMemSpyViewType CMemSpyViewDriveList::ViewType() const
+    {
+    return EMemSpyViewTypeDriveSummary;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewDriveList::PrepareParentViewL()
+    {
+    CMemSpyViewMainMenu* parent = new(ELeave) CMemSpyViewMainMenu( iEngine, iObserver );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
+    CleanupStack::Pop( parent );
+    //
+    if  ( parent )
+        {
+        iList->SetObserver( NULL );
+        }
+    //
+    return parent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewDriveList::PrepareChildViewL()
+    {
+    ASSERT( iCurrentDrive );
+    CMemSpyViewBase* child = new(ELeave) CMemSpyViewDriveInfo( iEngine, iObserver, iCurrentDrive->DriveNumber() );
+
+    // Stop watching list
+    if  ( child )
+        {
+        iList->SetObserver( NULL );
+        }
+
+    // Ownership is transferred to child. Cleanupstack guarantees it will be destroyed now.
+    // This object is about to die in any case.
+    iList = NULL;
+
+    CleanupStack::PushL( child );
+    child->ConstructL( Rect(), *Parent() );
+    CleanupStack::Pop( child );
+    return child;
+    }
+
+
+void CMemSpyViewDriveList::RefreshL()
+    {
+    if  ( iList )
+        {
+        iList->SetObserver( NULL );
+        }
+    //
+    CMemSpyEngineDriveList* list = iEngine.HelperFileSystem().DriveListL();
+    delete iList;
+    iList = list;
+    iList->SetObserver( this );
+    //
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+void CMemSpyViewDriveList::SetListBoxModelL()
+    {
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( iList );
+    listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+
+
+void CMemSpyViewDriveList::HandleListBoxItemActionedL( TInt aIndex )
+    {
+    const TInt count = iList->Count();
+    if  ( aIndex >= 0 && aIndex < count )
+        {
+        CMemSpyEngineDriveEntry& entry = iList->At( aIndex );
+        iCurrentDrive = &entry;
+        }
+    else
+        {
+        iCurrentDrive = NULL;
+        }
+
+    // Notify observer about item selection
+    ReportEventL( MMemSpyViewObserver::EEventItemActioned );
+    }
+
+
+void CMemSpyViewDriveList::HandleListBoxItemSelectedL( TInt aIndex )
+    {
+    const TInt count = iList->Count();
+    if  ( aIndex >= 0 && aIndex < count )
+        {
+        CMemSpyEngineDriveEntry& entry = iList->At( aIndex );
+        iCurrentDrive = &entry;
+        }
+    else
+        {
+        iCurrentDrive = NULL;
+        }
+
+    // Notify observer about item selection
+    ReportEventL( MMemSpyViewObserver::EEventItemSelected );
+    }
+
+
+void CMemSpyViewDriveList::HandleDriveListChangedL( const CMemSpyEngineDriveList& /*aList*/ )
+    {
+    RefreshL();
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+CMemSpyViewDriveInfo::CMemSpyViewDriveInfo( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, TDriveNumber aDriveNumber )
+:   CMemSpyViewDriveInfoBase( aEngine, aObserver ), iDriveNumber( aDriveNumber )
+    {
+    }
+
+
+void CMemSpyViewDriveInfo::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    BaseConstructL();
+    //
+    iDriveInfo = iList->EntryByDriveNumber( iDriveNumber );
+    if  ( !iDriveInfo )
+        {
+        User::Leave( KErrNotFound );
+        }
+    iDriveInfo->SetObserver( this );
+
+    _LIT( KTitleFormat, "Drive %S Info" );
+    const TDriveName name( iDriveInfo->DriveUnit().Name() );
+    TName title;
+    title.Format( KTitleFormat, &name );
+    SetTitleL( title );
+
+    // Finish construction
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+    }
+
+
+void CMemSpyViewDriveInfo::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewDriveInfo::ViewType() const
+    {
+    return EMemSpyViewTypeDriveInfo;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewDriveInfo::PrepareParentViewL()
+    {
+    ASSERT( iDriveInfo );
+    CMemSpyViewDriveList* parent = new(ELeave) CMemSpyViewDriveList( iEngine, iObserver, iDriveInfo->DriveNumber() );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent() );
+    CleanupStack::Pop( parent );
+    //
+    if  ( parent )
+        {
+        iDriveInfo->SetObserver( NULL );
+        }
+    //
+    return parent;
+    }
+
+
+void CMemSpyViewDriveInfo::SetListBoxModelL()
+    {
+    if  ( iDriveInfo )
+        {
+        CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+        listbox->Model()->SetItemTextArray( iDriveInfo );
+        listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+        }
+    }
+
+
+void CMemSpyViewDriveInfo::HandleDriveEntryChangedL( const CMemSpyEngineDriveEntry& /*aEntry*/ )
+    {
+    RefreshL();
+    }
+
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewECom.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,475 @@
+/*
+* 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 "MemSpyViewECom.h"
+
+// System includes
+#include <memspyui.rsg>
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyenginehelperecom.h>
+
+// User includes
+#include "MemSpyViewMainMenu.h"
+#include "MemSpyContainerObserver.h"
+
+
+
+CMemSpyViewECom::CMemSpyViewECom( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
+:   CMemSpyViewBase( aEngine, aObserver )
+    {
+    }
+
+
+void CMemSpyViewECom::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    _LIT( KTitle, "ECom" );
+    SetTitleL( KTitle );
+
+    // Finish construction
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+
+    // Select first item
+    TInt index = KErrNotFound;
+    if  ( aSelectionRune != NULL )
+        {
+        iCurrent = reinterpret_cast< CMemSpyEngineEComCategory* >( aSelectionRune );
+        index = iEngine.HelperECom().IndexOf( *iCurrent );
+        }
+
+    if  ( index >= 0 && index < iEngine.HelperECom().Count() )
+        {
+        iListBox->SetCurrentItemIndex( index );
+        HandleListBoxItemSelectedL( index );
+        iListBox->DrawDeferred();
+        }
+    }
+
+
+void CMemSpyViewECom::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewECom::ViewType() const
+    {
+    return EMemSpyViewTypeECom;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewECom::PrepareParentViewL()
+    {
+    CMemSpyViewMainMenu* parent = new(ELeave) CMemSpyViewMainMenu( iEngine, iObserver );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewECom::PrepareChildViewL()
+    {
+    CMemSpyViewBase* child = new(ELeave) CMemSpyViewEComCategory( iEngine, iObserver, *iCurrent );
+    CleanupStack::PushL( child );
+    child->ConstructL( Rect(), *Parent() );
+    CleanupStack::Pop( child );
+    return child;
+    }
+
+
+void CMemSpyViewECom::SetListBoxModelL()
+    {
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( &iEngine.HelperECom() );
+    listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+
+
+void CMemSpyViewECom::HandleListBoxItemActionedL( TInt aIndex )
+    {
+    const TInt count = iEngine.HelperECom().Count();
+    if  ( aIndex >= 0 && aIndex < count )
+        {
+        CMemSpyEngineEComCategory& category = iEngine.HelperECom().At( aIndex );
+        iCurrent = &category;
+        }
+    else
+        {
+        iCurrent = NULL;
+        }
+
+    // Notify observer about item selection
+    ReportEventL( MMemSpyViewObserver::EEventItemActioned );
+    }
+
+
+void CMemSpyViewECom::HandleListBoxItemSelectedL( TInt aIndex )
+    {
+    const TInt count = iEngine.HelperECom().Count();
+    if  ( aIndex >= 0 && aIndex < count )
+        {
+        CMemSpyEngineEComCategory& category = iEngine.HelperECom().At( aIndex );
+        iCurrent = &category;
+        }
+    else
+        {
+        iCurrent = NULL;
+        }
+
+    // Notify observer about item selection
+    ReportEventL( MMemSpyViewObserver::EEventItemSelected );
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+CMemSpyViewEComCategory::CMemSpyViewEComCategory( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineEComCategory& aCategory )
+:   CMemSpyViewBase( aEngine, aObserver ), iCategory( aCategory )
+    {
+    }
+
+
+void CMemSpyViewEComCategory::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    SetTitleL( iCategory.Name() );
+
+    // Finish construction
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+
+    // Select first item
+    TInt index = KErrNotFound;
+    if  ( aSelectionRune != NULL )
+        {
+        iCurrent = reinterpret_cast< CMemSpyEngineEComInterface* >( aSelectionRune );
+        index = iCategory.IndexOf( *iCurrent );
+        }
+
+    if  ( index >= 0 && index < iCategory.Count() )
+        {
+        iListBox->SetCurrentItemIndex( index );
+        HandleListBoxItemSelectedL( index );
+        iListBox->DrawDeferred();
+        }
+    }
+
+
+void CMemSpyViewEComCategory::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewEComCategory::ViewType() const
+    {
+    return EMemSpyViewTypeEComCategory;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewEComCategory::PrepareParentViewL()
+    {
+    CMemSpyViewECom* parent = new(ELeave) CMemSpyViewECom( iEngine, iObserver );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), &iCategory );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewEComCategory::PrepareChildViewL()
+    {
+    CMemSpyViewBase* child = new(ELeave) CMemSpyViewEComInterface( iEngine, iObserver, *iCurrent );
+    CleanupStack::PushL( child );
+    child->ConstructL( Rect(), *Parent() );
+    CleanupStack::Pop( child );
+    return child;
+    }
+
+
+void CMemSpyViewEComCategory::SetListBoxModelL()
+    {
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( &iCategory );
+    listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+
+
+void CMemSpyViewEComCategory::HandleListBoxItemActionedL( TInt aIndex )
+    {
+    const TInt count = iCategory.Count();
+    if  ( aIndex >= 0 && aIndex < count )
+        {
+        CMemSpyEngineEComInterface& entry = iCategory.At( aIndex );
+        iCurrent = &entry;
+        }
+    else
+        {
+        iCurrent = NULL;
+        }
+
+    // Notify observer about item selection
+    ReportEventL( MMemSpyViewObserver::EEventItemActioned );
+    }
+
+
+void CMemSpyViewEComCategory::HandleListBoxItemSelectedL( TInt aIndex )
+    {
+    const TInt count = iCategory.Count();
+    if  ( aIndex >= 0 && aIndex < count )
+        {
+        CMemSpyEngineEComInterface& entry = iCategory.At( aIndex );
+        iCurrent = &entry;
+        }
+    else
+        {
+        iCurrent = NULL;
+        }
+
+    // Notify observer about item selection
+    ReportEventL( MMemSpyViewObserver::EEventItemSelected );
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+CMemSpyViewEComInterface::CMemSpyViewEComInterface( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineEComInterface& aInterface )
+:   CMemSpyViewBase( aEngine, aObserver ), iInterface( aInterface )
+    {
+    }
+
+
+void CMemSpyViewEComInterface::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    SetTitleL( iInterface.Name() );
+
+    // Finish construction
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+
+    // Select first item
+    TInt index = KErrNotFound;
+    if  ( aSelectionRune != NULL )
+        {
+        iCurrent = reinterpret_cast< CMemSpyEngineEComImplementation* >( aSelectionRune );
+        index = iInterface.IndexOf( *iCurrent );
+        }
+
+    if  ( index >= 0 && index < iInterface.Count() )
+        {
+        iListBox->SetCurrentItemIndex( index );
+        HandleListBoxItemSelectedL( index );
+        iListBox->DrawDeferred();
+        }
+    }
+
+
+void CMemSpyViewEComInterface::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewEComInterface::ViewType() const
+    {
+    return EMemSpyViewTypeEComInterface;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewEComInterface::PrepareParentViewL()
+    {
+    CMemSpyViewEComCategory* parent = new(ELeave) CMemSpyViewEComCategory( iEngine, iObserver, iInterface.Category() );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), &iInterface );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewEComInterface::PrepareChildViewL()
+    {
+    CMemSpyViewBase* child = new(ELeave) CMemSpyViewEComImplementation( iEngine, iObserver, *iCurrent );
+    CleanupStack::PushL( child );
+    child->ConstructL( Rect(), *Parent() );
+    CleanupStack::Pop( child );
+    return child;
+    }
+
+
+void CMemSpyViewEComInterface::SetListBoxModelL()
+    {
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( &iInterface );
+    listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+
+
+void CMemSpyViewEComInterface::HandleListBoxItemActionedL( TInt aIndex )
+    {
+    const TInt count = iInterface.Count();
+    if  ( aIndex >= 0 && aIndex < count )
+        {
+        CMemSpyEngineEComImplementation& entry = iInterface.At( aIndex );
+        iCurrent = &entry;
+        }
+    else
+        {
+        iCurrent = NULL;
+        }
+
+    // Notify observer about item selection
+    ReportEventL( MMemSpyViewObserver::EEventItemActioned );
+    }
+
+
+void CMemSpyViewEComInterface::HandleListBoxItemSelectedL( TInt aIndex )
+    {
+    const TInt count = iInterface.Count();
+    if  ( aIndex >= 0 && aIndex < count )
+        {
+        CMemSpyEngineEComImplementation& entry = iInterface.At( aIndex );
+        iCurrent = &entry;
+        }
+    else
+        {
+        iCurrent = NULL;
+        }
+
+    // Notify observer about item selection
+    ReportEventL( MMemSpyViewObserver::EEventItemSelected );
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+CMemSpyViewEComImplementation::CMemSpyViewEComImplementation( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineEComImplementation& aImplementation )
+:   CMemSpyViewBase( aEngine, aObserver ), iImplementation( aImplementation )
+    {
+    }
+
+
+void CMemSpyViewEComImplementation::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    SetTitleL( iImplementation.Name() );
+
+    // Finish construction
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+
+    // Select first item
+    if  ( iImplementation.MdcaCount() )
+        {
+        iListBox->SetCurrentItemIndex( 0 );
+        HandleListBoxItemSelectedL( 0 );
+        iListBox->DrawDeferred();
+        }
+    }
+
+
+void CMemSpyViewEComImplementation::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewEComImplementation::ViewType() const
+    {
+    return EMemSpyViewTypeEComImplementation;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewEComImplementation::PrepareParentViewL()
+    {
+    CMemSpyViewEComInterface* parent = new(ELeave) CMemSpyViewEComInterface( iEngine, iObserver, iImplementation.Interface() );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), &iImplementation );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+void CMemSpyViewEComImplementation::SetListBoxModelL()
+    {
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( &iImplementation );
+    listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewFBServBitmaps.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,746 @@
+/*
+* 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 "MemSpyViewFBServBitmaps.h"
+
+// System includes
+#include <memspyui.rsg>
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyenginehelperprocess.h>
+#include <memspy/engine/memspyenginehelperheap.h>
+
+// User includes
+#include "MemSpyUiUtils.h"
+#include "MemSpyViewMainMenu.h"
+#include "MemSpyViewThreads.h"
+#include "MemSpyContainerObserver.h"
+#include "MemSpyExportBitmapsToMemoryCardDialog.h"
+
+// Constants
+const TInt KMemSpyIdleResetListboxTimerPeriod = 500000;
+const TInt KMemSpyImageSlideshowPeriod = 1000000;
+
+
+
+CMemSpyViewFBServBase::CMemSpyViewFBServBase( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineFbServBitmapArray* aBitmaps )
+:   CMemSpyViewBase( aEngine, aObserver ), iBitmaps( aBitmaps )
+    {
+    }
+
+
+CMemSpyViewFBServBase::~CMemSpyViewFBServBase()
+    {
+#ifdef _DEBUG
+    RDebug::Printf("CMemSpyViewFBServBase::~CMemSpyViewFBServBase() - deleting bitmaps: 0x%08x", iBitmaps );
+#endif
+    delete iBitmaps;
+    }
+
+
+TBool CMemSpyViewFBServBase::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = ETrue;
+    //
+    switch ( aCommand )
+        {
+	case EMemSpyCmdImagesSlideshow:
+    	OnCmdSlideShowL();
+        break;
+#ifndef __WINS__
+	case EMemSpyCmdImagesSaveAllToMemoryCard:
+        OnCmdExportToMemoryCardL();
+        break;
+#endif
+	case EMemSpyCmdImagesListing:
+        OnCmdImageListingL();
+        break;
+
+    default:
+        handled = CMemSpyViewBase::HandleCommandL( aCommand );
+        break;
+        }
+    //
+    return handled;
+    }
+
+
+void CMemSpyViewFBServBase::OnCmdSlideShowL()
+    {
+    TInt index = 0;
+    CMemSpyViewFBServSlideshow::NewLD( *iBitmaps, index );
+    
+    // Select the item that was last displayed
+    const TInt count = iBitmaps->Count();
+    if  ( iListBox && index >= 0 && index < count )
+        {
+        iListBox->SetCurrentItemIndex( index );
+        HandleListBoxItemSelectedL( index );
+        DrawDeferred();
+        }
+    }
+
+
+void CMemSpyViewFBServBase::OnCmdExportToMemoryCardL()
+    {
+    // Deletes itself
+    CMemSpyExportBitmapsToMemoryCardDialog::NewL( iCoeEnv->FsSession(), *iBitmaps );
+    }
+
+
+void CMemSpyViewFBServBase::OnCmdImageListingL()
+    {
+    // Begin a new data stream
+    _LIT( KMemSpyContext, "Bitmap List - " );
+    _LIT( KMemSpyFolder, "Bitmaps" );
+    iEngine.Sink().DataStreamBeginL( KMemSpyContext, KMemSpyFolder );
+
+    // Set prefix for overall listing
+    _LIT(KOverallPrefix, "Bitmap List - ");
+    iEngine.Sink().OutputPrefixSetLC( KOverallPrefix );
+
+    // Create header
+    CMemSpyEngineFbServBitmap::OutputDataColumnsL( iEngine );
+    
+    // List items
+    const TInt count = iBitmaps->Count();
+    for(TInt i=0; i<count; i++)
+        {
+        const CMemSpyEngineFbServBitmap& bitmap = iBitmaps->At( i );
+        //
+        bitmap.OutputDataL( iEngine );
+        }
+
+    // Tidy up
+    CleanupStack::PopAndDestroy(); // prefix
+
+    // End data stream
+    iEngine.Sink().DataStreamEndL();
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+CMemSpyViewFBServBitmaps::CMemSpyViewFBServBitmaps( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
+:   CMemSpyViewFBServBase( aEngine, aObserver, NULL )
+    {
+#ifdef _DEBUG
+    RDebug::Printf("CMemSpyViewFBServBitmaps::CMemSpyViewFBServBitmaps(1) - iBitmaps is: 0x%08x", iBitmaps );
+#endif
+    }
+
+
+CMemSpyViewFBServBitmaps::CMemSpyViewFBServBitmaps( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineFbServBitmapArray* aBitmaps )
+:   CMemSpyViewFBServBase( aEngine, aObserver, aBitmaps )
+    {
+#ifdef _DEBUG
+    RDebug::Printf("CMemSpyViewFBServBitmaps::CMemSpyViewFBServBitmaps(2) - iBitmaps is: 0x%08x", iBitmaps );
+#endif
+    }
+
+
+CMemSpyViewFBServBitmaps::~CMemSpyViewFBServBitmaps()
+    {
+    delete iIdleResetListboxTimer;
+    iBitmapHandles.Close();
+    }
+
+
+void CMemSpyViewFBServBitmaps::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    _LIT( KTitle, "Font & Bitmap Server" );
+    SetTitleL( KTitle );
+
+    if  ( iBitmaps == NULL )
+        {
+        // Prepare bitmap handles
+        iEngine.HelperFbServ().GetArrayOfBitmapHandlesL( iBitmapHandles );
+
+        // Create bitmap array - construction occurs asynchronously
+        iBitmaps = CMemSpyEngineFbServBitmapArray::NewL( CActive::EPriorityIdle, iBitmapHandles, *this );
+        }
+
+    // Finish construction
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+
+    // Create idle listbox refresh timer
+    if  ( iBitmaps->Count() == 0 )
+        {
+        iIdleResetListboxTimer = CPeriodic::NewL( CActive::EPriorityLow );
+        }
+    else
+        {
+        if  ( aSelectionRune != NULL )
+            {
+            iCurrentBitmap = reinterpret_cast< CMemSpyEngineFbServBitmap* >( aSelectionRune );
+            const TInt index = iBitmaps->BitmapIndexByHandle( iCurrentBitmap->Handle() );
+            iListBox->SetCurrentItemIndex( index );
+            HandleListBoxItemSelectedL( index );
+            }
+
+        iListBox->DrawDeferred();
+        }
+    }
+
+
+void CMemSpyViewFBServBitmaps::RefreshL()
+    {
+#ifdef _DEBUG
+    RDebug::Printf("CMemSpyViewFBServBitmaps::RefreshL() - iBitmaps->Count(): %d", iBitmaps->Count());
+#endif
+
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewFBServBitmaps::ViewType() const
+    {
+    return EMemSpyViewTypeFBServBitmaps;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewFBServBitmaps::PrepareParentViewL()
+    {
+    CMemSpyViewMainMenu* parent = new(ELeave) CMemSpyViewMainMenu( iEngine, iObserver );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewFBServBitmaps::PrepareChildViewL()
+    {
+    CMemSpyViewBase* child = new(ELeave) CMemSpyViewFBServBitmapInfo( iEngine, iObserver, iBitmaps, *iCurrentBitmap );
+
+    // Ownership is transferred to child. Cleanupstack guarantees it will be destroyed now.
+    // This object is about to die in any case.
+    iBitmaps = NULL;
+
+    CleanupStack::PushL( child );
+    child->ConstructL( Rect(), *Parent() );
+    CleanupStack::Pop( child );
+    return child;
+    }
+
+
+void CMemSpyViewFBServBitmaps::HandleFbServBitmapArrayEventL( TEvent aEvent )
+    {
+    if  ( aEvent == EBitmapItemsCreated )
+        {
+        }
+    else if ( aEvent == EBitmapArrayConstructionComplete )
+        {
+        }
+    //
+    iIdleResetListboxTimer->Cancel();
+    iIdleResetListboxTimer->Start( KMemSpyIdleResetListboxTimerPeriod/2, KMemSpyIdleResetListboxTimerPeriod, TCallBack( IdleUpdateListBoxModel, this ) );
+    }
+
+
+void CMemSpyViewFBServBitmaps::SetListBoxModelL()
+    {
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( iBitmaps );
+    listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+
+
+void CMemSpyViewFBServBitmaps::HandleListBoxItemActionedL( TInt aIndex )
+    {
+    const TInt count = iBitmaps->Count();
+    if  ( aIndex >= 0 && aIndex < count )
+        {
+        CMemSpyEngineFbServBitmap& bitmap = iBitmaps->At( aIndex );
+        iCurrentBitmap = &bitmap;
+        }
+    else
+        {
+        iCurrentBitmap = NULL;
+        }
+
+    // Notify observer about item selection
+    ReportEventL( MMemSpyViewObserver::EEventItemActioned );
+    }
+
+
+void CMemSpyViewFBServBitmaps::HandleListBoxItemSelectedL( TInt aIndex )
+    {
+    const TInt count = iBitmaps->Count();
+    if  ( aIndex >= 0 && aIndex < count )
+        {
+        CMemSpyEngineFbServBitmap& bitmap = iBitmaps->At( aIndex );
+        iCurrentBitmap = &bitmap;
+        }
+    else
+        {
+        iCurrentBitmap = NULL;
+        }
+
+    // Notify observer about item selection
+    ReportEventL( MMemSpyViewObserver::EEventItemSelected );
+    }
+
+
+TInt CMemSpyViewFBServBitmaps::IdleUpdateListBoxModel( TAny* aSelf )
+    {
+    CMemSpyViewFBServBitmaps* self = reinterpret_cast< CMemSpyViewFBServBitmaps* >( aSelf );
+    TRAP_IGNORE( self->DoIdleUpdateListBoxModelL() );
+    return EFalse;
+    }
+
+
+void CMemSpyViewFBServBitmaps::DoIdleUpdateListBoxModelL()
+    {
+    // Try to maintain current item selection if at all possible.
+    TInt handle = 0;
+    if  ( iCurrentBitmap )
+        {
+        handle = iCurrentBitmap->Handle();
+        iCurrentBitmap = NULL;
+        }
+   
+    // Update list box & model
+    iListBox->HandleItemAdditionL();
+    iListBox->DrawDeferred();
+    
+    // Try to select previous item if it is still available
+    const TInt index = iBitmaps->BitmapIndexByHandle( handle );
+    if  ( index >= 0 && index < iBitmaps->Count() )
+        {
+        iListBox->SetCurrentItemIndex( index );
+        HandleListBoxItemSelectedL( index );
+        }
+
+    iIdleResetListboxTimer->Cancel();
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+CMemSpyViewFBServBitmapInfo::CMemSpyViewFBServBitmapInfo( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineFbServBitmapArray* aBitmaps, CMemSpyEngineFbServBitmap& aSelectedBitmap )
+:   CMemSpyViewFBServBase( aEngine, aObserver, aBitmaps ), iBitmapObject( aSelectedBitmap )
+    {
+#ifdef _DEBUG
+    RDebug::Printf("CMemSpyViewFBServBitmapInfo::CMemSpyViewFBServBitmapInfo() - iBitmaps is: 0x%08x", iBitmaps );
+#endif
+    }
+
+
+void CMemSpyViewFBServBitmapInfo::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    _LIT( KTitle, "Bitmap Details" );
+    SetTitleL( KTitle );
+
+    // Finish construction
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+    
+    if  ( iBitmaps->Count() )
+        {
+        iListBox->SetCurrentItemIndex( 0 );
+        HandleListBoxItemSelectedL( 0 );
+        }
+    }
+
+
+void CMemSpyViewFBServBitmapInfo::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewFBServBitmapInfo::ViewType() const
+    {
+    return EMemSpyViewTypeFBServBitmapInfo;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewFBServBitmapInfo::PrepareParentViewL()
+    {
+    CMemSpyViewFBServBitmaps* parent = new(ELeave) CMemSpyViewFBServBitmaps( iEngine, iObserver, iBitmaps );
+
+    // Ownership is transferred to child. Cleanupstack guarantees it will be destroyed now.
+    // This object is about to die in any case.
+    iBitmaps = NULL;
+
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), &iBitmapObject );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewFBServBitmapInfo::PrepareChildViewL()
+    {
+    CMemSpyViewFBServBitmapViewer* child = new(ELeave) CMemSpyViewFBServBitmapViewer( iEngine, iObserver, iBitmaps, iBitmapObject );
+
+    // Ownership is transferred to child. Cleanupstack guarantees it will be destroyed now.
+    // This object is about to die in any case.
+    iBitmaps = NULL;
+
+    CleanupStack::PushL( child );
+    CEikAppUi* appUi = static_cast< CEikAppUi* >( iEikonEnv->AppUi() );
+    const TRect rect( TPoint( 0, 0 ), appUi->ClientRect().Size() );
+    child->ConstructL( rect, *Parent() );
+    CleanupStack::Pop( child );
+    return child;
+    }
+
+
+void CMemSpyViewFBServBitmapInfo::SetListBoxModelL()
+    {
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( &iBitmapObject );
+    listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+
+
+void CMemSpyViewFBServBitmapInfo::HandleListBoxItemActionedL( TInt aIndex )
+    {
+    // Only report the event if its the first item that was actioned
+    if  ( aIndex == 0 )
+        {
+        ReportEventL( MMemSpyViewObserver::EEventItemActioned );
+        }
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+CMemSpyViewFBServBitmapViewer::CMemSpyViewFBServBitmapViewer( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineFbServBitmapArray* aBitmaps, CMemSpyEngineFbServBitmap& aSelectedBitmap )
+:   CMemSpyViewFBServBase( aEngine, aObserver, aBitmaps ), iBitmapObject( aSelectedBitmap )
+    {
+#ifdef _DEBUG
+    RDebug::Printf("CMemSpyViewFBServBitmapViewer::CMemSpyViewFBServBitmapViewer() - iBitmaps is: 0x%08x", iBitmaps );
+#endif
+    }
+
+
+CMemSpyViewFBServBitmapViewer::~CMemSpyViewFBServBitmapViewer()
+    {
+    delete iImage;
+    }
+
+
+void CMemSpyViewFBServBitmapViewer::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    _LIT( KTitle, "Bitmap Preview" );
+    SetTitleL( KTitle );
+
+    // Finish construction
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+
+    // Prepare image
+    iImage = new(ELeave) CEikImage();
+    iImage->SetContainerWindowL( *this );
+    iImage->SetPicture( &iBitmapObject.Bitmap(), NULL );
+    iImage->SetPictureOwnedExternally( ETrue );
+    SizeChanged();
+    }
+
+
+void CMemSpyViewFBServBitmapViewer::RefreshL()
+    {
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewFBServBitmapViewer::ViewType() const
+    {
+    return EMemSpyViewTypeFBServBitmapViewer;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewFBServBitmapViewer::PrepareParentViewL()
+    {
+    CMemSpyViewFBServBitmapInfo* parent = new(ELeave) CMemSpyViewFBServBitmapInfo( iEngine, iObserver, iBitmaps, iBitmapObject );
+
+    // Ownership is transferred to child. Cleanupstack guarantees it will be destroyed now.
+    // This object is about to die in any case.
+    iBitmaps = NULL;
+
+    CleanupStack::PushL( parent );
+    CEikAppUi* appUi = static_cast< CEikAppUi* >( iEikonEnv->AppUi() );
+    const TRect rect( TPoint( 0, 0 ), appUi->ClientRect().Size() );
+    parent->ConstructL( rect, *Parent() );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+void CMemSpyViewFBServBitmapViewer::SetListBoxModelL()
+    {
+    }
+
+
+CEikListBox* CMemSpyViewFBServBitmapViewer::ConstructListBoxL()
+    {
+    return NULL;
+    }
+
+
+void CMemSpyViewFBServBitmapViewer::Draw( const TRect& /*aRect*/ ) const
+    {
+    CWindowGc& gc = SystemGc();
+    //
+    gc.SetPenStyle( CGraphicsContext::ENullPen );
+    gc.SetBrushColor( KRgbWhite );
+    gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
+    gc.DrawRect( Rect() );
+    //
+    gc.SetBrushColor( KRgbBlack );
+    gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
+    gc.DrawRect( iBorderRect );
+    }
+    
+
+void CMemSpyViewFBServBitmapViewer::SizeChanged()
+    {
+    TRect rect( Rect() );
+    TSize size( rect.Size() );
+    //
+    TSize bitmapSize( iBitmapObject.Bitmap().SizeInPixels() );
+
+    // Try to center image, if possible.
+    if  ( bitmapSize.iWidth < size.iWidth )
+        {
+        const TInt offset = ( size.iWidth - bitmapSize.iWidth) / 2;
+        rect.Move( offset, 0 );
+        size.iWidth = bitmapSize.iWidth;
+        }
+    if  ( bitmapSize.iHeight < size.iHeight )
+        {
+        const TInt offset = ( size.iHeight - bitmapSize.iHeight) / 2;
+        rect.Move( 0, offset );
+        size.iHeight = bitmapSize.iHeight;
+        }
+    //
+    rect.SetSize( size );
+    if  ( iImage )
+        {
+        iImage->SetRect( rect );
+        }
+    iBorderRect = rect;
+    iBorderRect.Grow( 2, 2 );
+    }
+
+
+TInt CMemSpyViewFBServBitmapViewer::CountComponentControls() const
+    {
+    TInt count = 0;
+    //
+    if  ( iImage )
+        {
+        ++count;
+        }
+    //
+    return count;
+    }
+
+
+CCoeControl* CMemSpyViewFBServBitmapViewer::ComponentControl( TInt /*aIndex*/ ) const
+    {
+    return iImage;
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+CMemSpyViewFBServSlideshow::CMemSpyViewFBServSlideshow( CMemSpyEngineFbServBitmapArray& aBitmaps, TInt& aIndex )
+:   iBitmaps( aBitmaps ), iIndex( aIndex )
+    {
+    }
+
+
+CMemSpyViewFBServSlideshow::~CMemSpyViewFBServSlideshow()
+    {
+    delete iTimer;
+    }
+
+
+void CMemSpyViewFBServSlideshow::ConstructL()
+    {
+    iTimer = CPeriodic::NewL( CActive::EPriorityLow );
+    iTimer->Start( KMemSpyImageSlideshowPeriod, KMemSpyImageSlideshowPeriod, TCallBack( IdleUpdate, this ) );
+    }
+
+
+void CMemSpyViewFBServSlideshow::NewLD( CMemSpyEngineFbServBitmapArray& aBitmaps, TInt& aIndex )
+    {
+    CMemSpyViewFBServSlideshow* self = new(ELeave) CMemSpyViewFBServSlideshow( aBitmaps, aIndex );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    //
+    self->ExecuteLD( R_MEMSPY_IMAGE_SLIDESHOW );
+    }
+
+
+void CMemSpyViewFBServSlideshow::PreLayoutDynInitL()
+    {
+    ShowNextImageL();
+    }
+
+
+TBool CMemSpyViewFBServSlideshow::OkToExitL( TInt /*aButtonId*/ )
+    {
+    return ETrue;
+    }
+
+
+TInt CMemSpyViewFBServSlideshow::IdleUpdate( TAny* aSelf )
+    {
+    CMemSpyViewFBServSlideshow* self = reinterpret_cast< CMemSpyViewFBServSlideshow* >( aSelf );
+    TRAP_IGNORE( self->ShowNextImageL() );
+    return EFalse;
+    }
+
+
+void CMemSpyViewFBServSlideshow::ShowNextImageL()
+    {
+	CEikImage* imageControl = static_cast< CEikImage* >( Control(EMemSpyCtrlIdSlideShowImage) );
+
+    // Get the right image
+    const TInt imageCount = iBitmaps.Count();
+    if  ( iIndex < imageCount )
+        {
+        CMemSpyEngineFbServBitmap& bitmap = iBitmaps.At( iIndex );
+        imageControl->SetPicture( &bitmap.Bitmap(), NULL );
+        imageControl->SetPictureOwnedExternally( ETrue );
+        
+        // Prepare title
+        const TSize size( bitmap.Bitmap().SizeInPixels() );
+        _LIT(KTitleFormat, "%3d x %3d");
+        TBuf<128> title;
+        title.Format( KTitleFormat, size.iWidth, size.iHeight );
+        SetTitleL( title );
+        //
+        User::ResetInactivityTime();
+        //
+        Layout();
+        //
+        ++iIndex;
+        }
+    else
+        {
+        // Dismiss myself.
+        delete this;
+        }
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewHeapTracking.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,435 @@
+/*
+* 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 "MemSpyViewHeapTracking.h"
+
+// System includes
+#include <hal.h>
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyenginehelpersysmemtracker.h>
+
+// User includes
+#include "MemSpyUiUtils.h"
+#include "MemSpyViewMainMenu.h"
+#include "MemSpyContainerObserver.h"
+#include "MemSpyViewHeapTrackingSettings.h"
+#include "MemSpyViewHeapTrackingResults.h"
+
+
+CMemSpyViewHeapTracking::CMemSpyViewHeapTracking( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
+:   CMemSpyViewBase( aEngine, aObserver ),
+    iState( EMemSpyViewHeapTrackingStateIdle )
+    {
+    if ( iEngine.HelperSysMemTracker().IsActive() )
+        {
+        iState = EMemSpyViewHeapTrackingStateTimerOn;
+        }
+    }
+
+
+CMemSpyViewHeapTracking::~CMemSpyViewHeapTracking()
+    {
+    delete iStopTimerCallBack;
+    iEngine.HelperSysMemTracker().RemoveObserver( this );
+    }
+
+
+void CMemSpyViewHeapTracking::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    _LIT( KTitle, "System-Wide Memory Tracking" );
+    SetTitleL( KTitle );
+    //
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+    
+    // Backup current config because it may be overwritten with Basic/Full mode settings.
+    CMemSpyEngineHelperSysMemTracker& swmt = iEngine.HelperSysMemTracker();
+    TMemSpyEngineHelperSysMemTrackerConfig config;
+    swmt.GetConfig( config );
+    iOriginalConfig = config;
+    
+    if ( config.iMode != TMemSpyEngineHelperSysMemTrackerConfig::MemSpyEngineSysMemTrackerModeCustom )
+        {
+        // Set config. Needed for updating config for Basic or Full mode.
+        SetConfigByModeL( config.iMode, config );        
+        }
+        
+    // Make sure the correct item is selected
+    TInt index = 0;
+    if  ( aSelectionRune != NULL )
+        {
+        const TMemSpyViewType viewType = (TMemSpyViewType) ((TInt) aSelectionRune);
+        index = IndexByViewType( viewType );
+        }
+    iListBox->SetCurrentItemIndex( index );
+    HandleListBoxItemSelectedL( index );
+    }
+
+
+void CMemSpyViewHeapTracking::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewHeapTracking::ViewType() const
+    {
+    return EMemSpyViewTypeHeapTracking;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewHeapTracking::PrepareParentViewL()
+    {
+    
+    // Save custom settings even if mode is Basic or Full
+    TRAP_IGNORE(
+        CMemSpyEngineHelperSysMemTracker& swmt = iEngine.HelperSysMemTracker();
+        TMemSpyEngineHelperSysMemTrackerConfig config;
+        swmt.GetConfig( config );
+        config.iEnabledCategories = iOriginalConfig.iEnabledCategories;
+        config.iThreadNameFilter = iOriginalConfig.iThreadNameFilter;
+        config.iDumpData = iOriginalConfig.iDumpData;
+        swmt.SetConfigL( config );
+        Settings().StoreSettingsL();
+        );
+    
+    CMemSpyViewMainMenu* parent = new(ELeave) CMemSpyViewMainMenu( iEngine, iObserver );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewHeapTracking::PrepareChildViewL()
+    {
+    CMemSpyViewBase* child = NULL;
+    const TInt index = iListBox->CurrentItemIndex();
+    
+    // Get current config
+    CMemSpyEngineHelperSysMemTracker& swmt = iEngine.HelperSysMemTracker();
+    TMemSpyEngineHelperSysMemTrackerConfig config;
+    swmt.GetConfig( config );
+    
+    //
+    if  ( index == 0 )
+        {
+        // This is the start/stop toggle so we don't make a child view
+        child = NULL; 
+
+        // ... instead we either start or stop the tracker
+        if  ( !iEngine.HelperSysMemTracker().IsActive() )
+            {
+            iState = EMemSpyViewHeapTrackingStateSingleOn;
+            // Setting observer to be able to stop SWMT after first cycle is completed
+            iEngine.HelperSysMemTracker().SetObserver( this );
+            iEngine.HelperSysMemTracker().StartL();
+            }
+
+        // Redraw listbox 
+        RefreshL();
+        }
+    else if  ( index == 1 )
+        {
+        // This is the start/stop toggle so we don't make a child view
+        child = NULL; 
+
+        // ... instead we either start or stop the tracker
+        if  ( iEngine.HelperSysMemTracker().IsActive() && iState == EMemSpyViewHeapTrackingStateTimerOn )
+            {
+            iState = EMemSpyViewHeapTrackingStateIdle;
+            iEngine.HelperSysMemTracker().StopL();
+            }
+        else if ( iState == EMemSpyViewHeapTrackingStateIdle )
+            {
+            iState = EMemSpyViewHeapTrackingStateTimerOn;
+            iEngine.HelperSysMemTracker().StartL();
+            }
+
+        // Redraw listbox 
+        RefreshL();
+        }
+    else if ( index == 2 )
+        {
+        switch ( config.iMode )
+            {
+            case TMemSpyEngineHelperSysMemTrackerConfig::MemSpyEngineSysMemTrackerModeBasic:
+                {
+                // Set Full mode
+                SetConfigByModeL( TMemSpyEngineHelperSysMemTrackerConfig::MemSpyEngineSysMemTrackerModeFull, config );
+                break;
+                }
+            case TMemSpyEngineHelperSysMemTrackerConfig::MemSpyEngineSysMemTrackerModeFull:
+                {
+                // Set Custom mode
+                SetConfigByModeL( TMemSpyEngineHelperSysMemTrackerConfig::MemSpyEngineSysMemTrackerModeCustom, config );
+                break;
+                }
+            case TMemSpyEngineHelperSysMemTrackerConfig::MemSpyEngineSysMemTrackerModeCustom:
+                {
+                // Set Basic mode
+                SetConfigByModeL( TMemSpyEngineHelperSysMemTrackerConfig::MemSpyEngineSysMemTrackerModeBasic, config );
+                break;
+                }
+            default: break;
+            }
+                
+        // Redraw listbox 
+        RefreshL();
+        }
+    else if ( index == 3 )
+        {        
+        if ( config.iMode == TMemSpyEngineHelperSysMemTrackerConfig::MemSpyEngineSysMemTrackerModeCustom )
+            {
+            child = new(ELeave) CMemSpyViewHeapTrackingSettings( iEngine, iObserver );
+            }
+        else
+            {
+            child = new(ELeave) CMemSpyViewHeapTrackingResults( iEngine, iObserver );
+            }
+        }
+    else if ( index == 4 )
+        {
+        child = new(ELeave) CMemSpyViewHeapTrackingResults( iEngine, iObserver );
+        }
+    if  ( child )
+        {
+        CleanupStack::PushL( child );
+        child->ConstructL( Rect(), *Parent() );
+        CleanupStack::Pop( child );
+        }
+    
+    //
+    return child;
+    }
+
+
+void CMemSpyViewHeapTracking::SetListBoxModelL()
+    {
+    CDesCArrayFlat* model = new(ELeave) CDesCArrayFlat(5);
+    CleanupStack::PushL( model );
+
+    TBuf<KMaxFullName + 1> item;
+    
+    // Get current config
+    CMemSpyEngineHelperSysMemTracker& swmt = iEngine.HelperSysMemTracker();
+    TMemSpyEngineHelperSysMemTrackerConfig config;
+    swmt.GetConfig( config );
+
+    // 1st item
+    _LIT( KItem1FormatEnable, "\tGet dump now" );
+    model->AppendL( KItem1FormatEnable );
+
+    
+    // 1st item
+    if  ( iEngine.HelperSysMemTracker().IsActive() && iState == EMemSpyViewHeapTrackingStateTimerOn )
+        {
+        _LIT( KItem1FormatEnable, "\tStop timer\t\t%d (sec)" );
+        TName item;
+        item.Format( KItem1FormatEnable, config.iTimerPeriod.Int() / 1000000 );
+        model->AppendL( item );
+        }
+    else
+        {
+        _LIT( KItem1FormatEnable, "\tStart timer\t\t%d (sec)" );
+        TName item;
+        item.Format( KItem1FormatEnable, config.iTimerPeriod.Int() / 1000000 );
+        model->AppendL( item );
+        }
+    
+    // 2nd item
+    switch ( config.iMode )
+        {
+        case TMemSpyEngineHelperSysMemTrackerConfig::MemSpyEngineSysMemTrackerModeBasic:
+            {
+            _LIT( KItem2Format, "\tTracking mode\t\tBasic" );
+            model->AppendL( KItem2Format );        
+            break;
+            }
+        case TMemSpyEngineHelperSysMemTrackerConfig::MemSpyEngineSysMemTrackerModeFull:
+            {
+            _LIT( KItem2Format, "\tTracking mode\t\tFull" );
+            model->AppendL( KItem2Format );        
+            break;
+            }
+        case TMemSpyEngineHelperSysMemTrackerConfig::MemSpyEngineSysMemTrackerModeCustom:
+            {
+            _LIT( KItem2Format, "\tTracking mode\t\tCustom" );
+            model->AppendL( KItem2Format );
+            
+            // 3rd item
+            TFullName item;
+            if ( config.DumpData() && 
+                config.iEnabledCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryUserHeap )
+                {
+                _LIT( KItem3Format, "\tSettings\t\t%d categ., dump" );
+                item.Format( KItem3Format, config.EnabledCategoryCount() );
+                }
+            else
+                {
+                _LIT( KItem3Format, "\tSettings\t\t%d categories" );
+                item.Format( KItem3Format, config.EnabledCategoryCount() );
+                }
+            model->AppendL( item );            
+            break;
+            }
+        default: break;
+        }
+    
+    // 4th item    
+    const TInt cycleCount = iEngine.HelperSysMemTracker().MdcaCount();
+    if ( cycleCount )
+        {
+        _LIT( KItem2Format, "\tResults\t\t%d cycles" );
+        TFullName item;
+        item.Format( KItem2Format, cycleCount );
+        model->AppendL( item );
+        }
+    else
+        {
+        _LIT( KItem2Format, "\tResults\t\tNo results" );
+        model->AppendL( KItem2Format );
+        }
+
+    // Set up list box
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( model );
+    listbox->Model()->SetOwnershipType( ELbmOwnsItemArray );
+    CleanupStack::Pop( model );
+    }
+
+
+void CMemSpyViewHeapTracking::HandleCyclesResetL()
+    {
+    }
+
+
+void CMemSpyViewHeapTracking::HandleCycleStartedL( const CMemSpyEngineHelperSysMemTrackerCycle& /*aCycle*/ )
+    {
+    }
+
+
+void CMemSpyViewHeapTracking::HandleCycleFinishedL( const CMemSpyEngineHelperSysMemTrackerCycle& /*aCycle*/ )
+    {
+    // Stopping SWMT does not work directly from this function.
+    // It has to be made asynchronously.
+    iStopTimerCallBack = new (ELeave) CAsyncCallBack( TCallBack( CMemSpyViewHeapTracking::AsyncStopTimerCallback, this ), CActive::EPriorityStandard );
+    iStopTimerCallBack->CallBack();
+    }
+
+
+TInt CMemSpyViewHeapTracking::IndexByViewType( TMemSpyViewType aType )
+    {
+    // Get current config
+    CMemSpyEngineHelperSysMemTracker& swmt = iEngine.HelperSysMemTracker();
+    TMemSpyEngineHelperSysMemTrackerConfig config;
+    swmt.GetConfig( config );
+    
+    TInt index = 0;
+    //
+    switch( aType )
+        {
+    default:
+    case EMemSpyViewTypeHeapTrackingResults:
+        {
+        if ( config.iMode == TMemSpyEngineHelperSysMemTrackerConfig::MemSpyEngineSysMemTrackerModeCustom )
+            {
+            index = 4;
+            }
+        else
+            {
+            index = 3;
+            }
+        break;
+        }
+    case EMemSpyViewTypeHeapTrackingSettings:
+        index = 3;
+        break;
+        }
+    //
+    return index;
+    }
+
+
+void CMemSpyViewHeapTracking::SetConfigByModeL( TMemSpyEngineHelperSysMemTrackerConfig::TMemSpyEngineSysMemTrackerMode aMode, TMemSpyEngineHelperSysMemTrackerConfig& aConfig )
+    {
+    switch ( aMode )
+        {
+        case TMemSpyEngineHelperSysMemTrackerConfig::MemSpyEngineSysMemTrackerModeBasic:
+            {
+            aConfig.iMode = aMode;
+            aConfig.iEnabledCategories = TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryUserHeap |
+                                         TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryUserStacks |
+                                         TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryGlobalData |
+                                         TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategorySystemMemory;
+            aConfig.iDumpData = EFalse;
+            break;
+            }
+        case TMemSpyEngineHelperSysMemTrackerConfig::MemSpyEngineSysMemTrackerModeFull:
+            {
+            aConfig.iMode = aMode;
+            aConfig.iEnabledCategories = TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryAll;
+            aConfig.iDumpData = ETrue;
+            aConfig.iThreadNameFilter = KNullDesC;
+            break;
+            }
+        case TMemSpyEngineHelperSysMemTrackerConfig::MemSpyEngineSysMemTrackerModeCustom:
+            {
+            aConfig.iMode = aMode;
+            aConfig.iEnabledCategories = iOriginalConfig.iEnabledCategories;
+            aConfig.iDumpData = iOriginalConfig.iDumpData;
+            aConfig.iThreadNameFilter = iOriginalConfig.iThreadNameFilter;
+            break;
+            }
+        default: User::Leave( KErrArgument );
+        }
+    // Push changes to SWMT
+    CMemSpyEngineHelperSysMemTracker& swmt = iEngine.HelperSysMemTracker();
+    swmt.SetConfigL( aConfig );
+    Settings().StoreSettingsL();
+    }
+
+
+TInt CMemSpyViewHeapTracking::AsyncStopTimerCallback( TAny* aParam )
+    {
+    CMemSpyViewHeapTracking* view = static_cast<CMemSpyViewHeapTracking*>( aParam );
+    return view->AsyncStopTimerCallback();
+    }
+
+
+TInt CMemSpyViewHeapTracking::AsyncStopTimerCallback()
+    {
+    iState = EMemSpyViewHeapTrackingStateIdle;
+    iEngine.HelperSysMemTracker().RemoveObserver( this );
+    TRAP_IGNORE(
+        iEngine.HelperSysMemTracker().StopL();
+        RefreshL();
+        );
+    delete iStopTimerCallBack;
+    iStopTimerCallBack = NULL;
+    return KErrNone;
+    }
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewHeapTrackingResults.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,434 @@
+/*
+* 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 "MemSpyViewHeapTrackingResults.h"
+
+// System includes
+#include <hal.h>
+#ifdef __EPOC32__
+#include <e32rom.h>
+#endif
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyenginehelpersysmemtrackercycle.h>
+#include <memspy/engine/memspyenginehelpersysmemtrackercyclechange.h>
+#include <memspy/engine/memspyenginehelpersysmemtrackerenums.h>
+#include <memspy/engine/memspyenginehelpersysmemtracker.h>
+#include <memspy/engine/memspyenginehelpersysmemtrackerconfig.h>
+#include <memspyui.rsg>
+
+// User includes
+#include "MemSpyUiUtils.h"
+#include "MemSpyContainer.h"
+#include "MemSpyViewHeapTracking.h"
+#include "MemSpyContainerObserver.h"
+
+
+CMemSpyViewHeapTrackingResults::CMemSpyViewHeapTrackingResults( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
+:   CMemSpyViewBase( aEngine, aObserver )
+    {
+    iEngine.HelperSysMemTracker().SetObserver( this );
+    }
+
+
+CMemSpyViewHeapTrackingResults::~CMemSpyViewHeapTrackingResults()
+    {
+    iEngine.HelperSysMemTracker().RemoveObserver( this );
+    }
+
+
+void CMemSpyViewHeapTrackingResults::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    _LIT( KTitle, "Results Summary" );
+    SetTitleL( KTitle );
+    //
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+
+    // Make sure the correct item is selected
+    const TInt cycleNumber = ((TInt) aSelectionRune);
+    const TInt maxCycle = iEngine.HelperSysMemTracker().MdcaCount();
+    if  ( cycleNumber > 0 && cycleNumber <= maxCycle )
+        {
+        iListBox->SetCurrentItemIndex( cycleNumber - 1 );
+        HandleListBoxItemSelectedL( cycleNumber );
+        }
+    }
+
+
+void CMemSpyViewHeapTrackingResults::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewHeapTrackingResults::ViewType() const
+    {
+    return EMemSpyViewTypeHeapTrackingResults;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewHeapTrackingResults::PrepareParentViewL()
+    {
+    CMemSpyViewHeapTracking* parent = new(ELeave) CMemSpyViewHeapTracking( iEngine, iObserver );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
+    CleanupStack::Pop( parent );
+    //
+    iEngine.HelperSysMemTracker().RemoveObserver( this );
+    //
+    return parent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewHeapTrackingResults::PrepareChildViewL()
+    {
+    const TInt index = iListBox->CurrentItemIndex();
+    //
+    CMemSpyViewBase* child = NULL;
+    if  ( index >= 0 )
+        {
+        const CMemSpyEngineHelperSysMemTrackerCycle* cycle = iEngine.HelperSysMemTracker().CompletedCycles()[ index ];
+        //
+        child = new(ELeave) CMemSpyViewHeapTrackingResultsCycleInfo( iEngine, iObserver, *cycle );
+        CleanupStack::PushL( child );
+        child->ConstructL( Rect(), *Parent() );
+        CleanupStack::Pop( child );
+        //
+        iEngine.HelperSysMemTracker().RemoveObserver( this );
+        }
+    //
+    return child;
+    }
+
+
+void CMemSpyViewHeapTrackingResults::SetListBoxModelL()
+    {
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    MDesCArray* contents = &iEngine.HelperSysMemTracker();
+    listbox->Model()->SetItemTextArray( contents );
+    listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+
+
+void CMemSpyViewHeapTrackingResults::HandleCyclesResetL()
+    {
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+void CMemSpyViewHeapTrackingResults::HandleCycleStartedL( const CMemSpyEngineHelperSysMemTrackerCycle& /*aCycle*/ )
+    {
+    }
+
+
+void CMemSpyViewHeapTrackingResults::HandleCycleFinishedL( const CMemSpyEngineHelperSysMemTrackerCycle& /*aCycle*/ )
+    {
+    SetListBoxCurrentItemIndexL( iEngine.HelperSysMemTracker().MdcaCount() - 1 );
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+CMemSpyViewHeapTrackingResultsCycleInfo::CMemSpyViewHeapTrackingResultsCycleInfo( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, const CMemSpyEngineHelperSysMemTrackerCycle& aCycle )
+:   CMemSpyViewBase( aEngine, aObserver ), iCycle( aCycle )
+    {
+    iEngine.HelperSysMemTracker().SetObserver( this );
+    }
+
+
+CMemSpyViewHeapTrackingResultsCycleInfo::~CMemSpyViewHeapTrackingResultsCycleInfo()
+    {
+    iEngine.HelperSysMemTracker().RemoveObserver( this );
+    }
+
+
+void CMemSpyViewHeapTrackingResultsCycleInfo::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    _LIT( KTitleFormat, "Cycle Summary [%04d]" );
+    TBuf<30> buf;
+    buf.Format( KTitleFormat, iCycle.CycleNumber() );
+    SetTitleL( buf );
+    //
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+
+    // Make sure the correct item is selected
+    const TInt index = ((TInt) aSelectionRune);
+    iListBox->SetCurrentItemIndex( index );
+    HandleListBoxItemSelectedL( index );
+    }
+
+
+void CMemSpyViewHeapTrackingResultsCycleInfo::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewHeapTrackingResultsCycleInfo::ViewType() const
+    {
+    return EMemSpyViewTypeHeapTrackingResultsCycleInfo;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewHeapTrackingResultsCycleInfo::PrepareParentViewL()
+    {
+    CMemSpyViewHeapTrackingResults* parent = new(ELeave) CMemSpyViewHeapTrackingResults( iEngine, iObserver );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), (TAny*) iCycle.CycleNumber() );
+    CleanupStack::Pop( parent );
+    //
+    iEngine.HelperSysMemTracker().RemoveObserver( this );
+    //
+    return parent;
+    }
+
+
+void CMemSpyViewHeapTrackingResultsCycleInfo::SetListBoxModelL()
+    {
+    MDesCArray& model = const_cast< MDesCArray& >( static_cast< const MDesCArray&>( iCycle ) );
+    //
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( &model );
+    listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+
+
+void CMemSpyViewHeapTrackingResultsCycleInfo::HandleCyclesResetL()
+    {
+    Container().NavigateToParentViewL();
+    }
+
+
+void CMemSpyViewHeapTrackingResultsCycleInfo::HandleCycleStartedL( const CMemSpyEngineHelperSysMemTrackerCycle& /*aCycle*/ )
+    {
+    }
+
+
+void CMemSpyViewHeapTrackingResultsCycleInfo::HandleCycleFinishedL( const CMemSpyEngineHelperSysMemTrackerCycle& /*aCycle*/ )
+    {
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*
+
+
+
+CMemSpyViewHeapTrackingResultsChangeDescriptor::CMemSpyViewHeapTrackingResultsChangeDescriptor( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, const CMemSpyEngineHelperSysMemTrackerCycle& aCycle, const CMemSpyEngineHelperSysMemTrackerCycleChange& aChangeDescriptor, TInt aIndex )
+:   CMemSpyViewBase( aEngine, aObserver ), iCycle( aCycle ), iChangeDescriptor( aChangeDescriptor ), iIndex( aIndex )
+    {
+    iEngine.HelperSysMemTracker().SetObserver( this );
+    }
+
+
+CMemSpyViewHeapTrackingResultsChangeDescriptor::~CMemSpyViewHeapTrackingResultsChangeDescriptor()
+    {
+    iEngine.HelperSysMemTracker().RemoveObserver( this );
+    }
+
+
+void CMemSpyViewHeapTrackingResultsChangeDescriptor::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    TBuf<30> buf;
+    if  ( iChangeDescriptor.Type() == EMemSpyEngineSysMemTrackerTypeHeapUser )
+        {
+        _LIT( KTitleFormat, "User Heap Change [%04d]" );
+        buf.Format( KTitleFormat, iCycle.CycleNumber() );
+        }
+    else if ( iChangeDescriptor.Type() == EMemSpyEngineSysMemTrackerTypeHeapKernel )
+        {
+        _LIT( KTitleFormat, "Kernel Heap Change [%04d]" );
+        buf.Format( KTitleFormat, iCycle.CycleNumber() );
+        }
+    else if ( iChangeDescriptor.Type() == EMemSpyEngineSysMemTrackerTypeChunk )
+        {
+        _LIT( KTitleFormat, "Chunk Change [%04d]" );
+        buf.Format( KTitleFormat, iCycle.CycleNumber() );
+        }
+    else if ( iChangeDescriptor.Type() == EMemSpyEngineSysMemTrackerTypeRamDrive )
+        {
+        _LIT( KTitleFormat, "RAM Drive Change [%04d]" );
+        buf.Format( KTitleFormat, iCycle.CycleNumber() );
+        }
+    else if ( iChangeDescriptor.Type() == EMemSpyEngineSysMemTrackerTypeStack )
+        {
+        _LIT( KTitleFormat, "Stack Change [%04d]" );
+        buf.Format( KTitleFormat, iCycle.CycleNumber() );
+        }
+    else if ( iChangeDescriptor.Type() == EMemSpyEngineSysMemTrackerTypeGlobalData )
+        {
+        _LIT( KTitleFormat, "Global Data Change [%04d]" );
+        buf.Format( KTitleFormat, iCycle.CycleNumber() );
+        }
+    else if ( iChangeDescriptor.Type() == EMemSpyEngineSysMemTrackerTypeCode )
+        {
+        _LIT( KTitleFormat, "RAM-Loaded Code Change [%04d]" );
+        buf.Format( KTitleFormat, iCycle.CycleNumber() );
+        }
+    else if ( iChangeDescriptor.Type() == EMemSpyEngineSysMemTrackerTypeHandle )
+        {
+        _LIT( KTitleFormat, "Handle Change [%04d]" );
+        buf.Format( KTitleFormat, iCycle.CycleNumber() );
+        }
+    else if ( iChangeDescriptor.Type() == EMemSpyEngineSysMemTrackerTypeOpenFile )
+        {
+        _LIT( KTitleFormat, "Open File Change [%04d]" );
+        buf.Format( KTitleFormat, iCycle.CycleNumber() );
+        }
+    else if ( iChangeDescriptor.Type() == EMemSpyEngineSysMemTrackerTypeDiskSpace )
+        {
+        _LIT( KTitleFormat, "Disk Space Change [%04d]" );
+        buf.Format( KTitleFormat, iCycle.CycleNumber() );
+        }
+    else if ( iChangeDescriptor.Type() == EMemSpyEngineSysMemTrackerTypeBitmap )
+        {
+        _LIT( KTitleFormat, "Bitmap Change [%04d]" );
+        buf.Format( KTitleFormat, iCycle.CycleNumber() );
+        }
+    //
+    SetTitleL( buf );
+    //
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+    }
+
+
+void CMemSpyViewHeapTrackingResultsChangeDescriptor::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewHeapTrackingResultsChangeDescriptor::ViewType() const
+    {
+    return EMemSpyViewTypeHeapTrackingResultsCycleChangeDescriptor;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewHeapTrackingResultsChangeDescriptor::PrepareParentViewL()
+    {
+    CMemSpyViewHeapTrackingResultsCycleInfo* parent = new(ELeave) CMemSpyViewHeapTrackingResultsCycleInfo( iEngine, iObserver, iCycle );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), (TAny*) iIndex );
+    CleanupStack::Pop( parent );
+    //
+    iEngine.HelperSysMemTracker().RemoveObserver( this );
+    //
+    return parent;
+    }
+
+
+void CMemSpyViewHeapTrackingResultsChangeDescriptor::SetListBoxModelL()
+    {
+    MDesCArray& model = const_cast< MDesCArray& >( static_cast< const MDesCArray&>( iChangeDescriptor ) );
+    //
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( &model );
+    listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+
+
+void CMemSpyViewHeapTrackingResultsChangeDescriptor::HandleCyclesResetL()
+    {
+    CMemSpyViewHeapTrackingResults* mainResultsMenu = new(ELeave) CMemSpyViewHeapTrackingResults( iEngine, iObserver );
+    CleanupStack::PushL( mainResultsMenu );
+    mainResultsMenu->ConstructL( Rect(), *Parent() );
+    CleanupStack::Pop( mainResultsMenu );
+    //
+    Container().SetNewActiveViewL( mainResultsMenu );
+    }
+
+
+void CMemSpyViewHeapTrackingResultsChangeDescriptor::HandleCycleStartedL( const CMemSpyEngineHelperSysMemTrackerCycle& aCycle )
+    {
+    }
+
+
+void CMemSpyViewHeapTrackingResultsChangeDescriptor::HandleCycleFinishedL( const CMemSpyEngineHelperSysMemTrackerCycle& aCycle )
+    {
+    }
+*/
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewHeapTrackingSettings.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,422 @@
+/*
+* 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 "MemSpyViewHeapTrackingSettings.h"
+
+// System includes
+#include <hal.h>
+#ifdef __EPOC32__
+#include <e32rom.h>
+#endif
+#include <AknQueryDialog.h>
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyenginehelpersysmemtracker.h>
+#include <memspy/engine/memspyenginehelpersysmemtrackerconfig.h>
+#include <memspyui.rsg>
+
+// User includes
+#include "MemSpyUiUtils.h"
+#include "MemSpySettings.h"
+#include "MemSpyViewHeapTracking.h"
+#include "MemSpyContainerObserver.h"
+
+
+CMemSpyViewHeapTrackingSettings::CMemSpyViewHeapTrackingSettings( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
+:   CMemSpyViewBase( aEngine, aObserver )
+    {
+    }
+
+
+CMemSpyViewHeapTrackingSettings::~CMemSpyViewHeapTrackingSettings()
+    {
+    }
+
+
+void CMemSpyViewHeapTrackingSettings::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    _LIT( KTitle, "Settings" );
+    SetTitleL( KTitle );
+    //
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+    }
+
+
+void CMemSpyViewHeapTrackingSettings::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewHeapTrackingSettings::ViewType() const
+    {
+    return EMemSpyViewTypeHeapTrackingSettings;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewHeapTrackingSettings::PrepareParentViewL()
+    {
+    CMemSpyViewHeapTracking* parent = new(ELeave) CMemSpyViewHeapTracking( iEngine, iObserver );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewHeapTrackingSettings::PrepareChildViewL()
+    {
+    const TInt index = iListBox->CurrentItemIndex();
+
+    // Get current config
+    CMemSpyEngineHelperSysMemTracker& swmt = iEngine.HelperSysMemTracker();
+    TMemSpyEngineHelperSysMemTrackerConfig config;
+    swmt.GetConfig( config );
+
+    // This view abuses the child view callback to toggle field values and/or
+    // display settings dialogs.
+    if  ( index == 0 )
+        {
+        TInt period = config.iTimerPeriod.Int() / 1000000;
+        CAknNumberQueryDialog* dialog = new(ELeave) CAknNumberQueryDialog( period );
+        if  ( dialog->ExecuteLD( R_MEMSPY_HEAP_TRACKER_TIMER_PERIOD ) )
+            {
+            config.iTimerPeriod = period * 1000000;
+            }
+        }
+    else if ( index == 1 )
+        {
+        TInt categories( config.iEnabledCategories );
+        CSWMTCategorySelectionCheckBoxSettingItem* settingItem = new (ELeave) CSWMTCategorySelectionCheckBoxSettingItem( 0, categories );
+        CleanupStack::PushL( settingItem );
+        settingItem->ConstructL( EFalse,
+                                 0,
+                                 _L("SWMT Categories"),
+                                 NULL,
+                                 R_MEMSPYUI_SWMT_CATEGORIES_SETTING_PAGE,
+                                 EAknCtPopupSettingList,
+                                 NULL,
+                                 NULL );
+        
+        CMemSpySWMTCategorySelectionCheckBoxSettingPage* dlg = new(ELeave) CMemSpySWMTCategorySelectionCheckBoxSettingPage( R_MEMSPYUI_SWMT_CATEGORIES_SETTING_PAGE, settingItem->ItemArray() );
+        dlg->SetSettingPageObserver( settingItem );
+        if  ( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged ) )
+            {
+            config.iEnabledCategories = categories;
+            }
+        CleanupStack::PopAndDestroy( settingItem );
+        }
+    else if ( index == 2 )
+        {
+        config.iDumpData = !config.iDumpData;
+        }
+    else if  ( index == 3 )
+        {
+        TName nameFilter;
+        nameFilter.Copy( config.iThreadNameFilter );
+        CMemSpyAllowEmptyDataDialog* dialog = new (ELeave) CMemSpyAllowEmptyDataDialog( nameFilter );
+        if  ( dialog->ExecuteLD( R_MEMSPY_HEAP_TRACKER_NAME_FILTER ) )
+            {
+            config.iThreadNameFilter = nameFilter;
+            }
+        }
+    
+    // Push changes to SWMT
+    swmt.SetConfigL( config );
+    Settings().StoreSettingsL();
+
+    RefreshL();
+    return NULL;
+    }
+
+
+void CMemSpyViewHeapTrackingSettings::SetListBoxModelL()
+    {
+    CDesCArrayFlat* model = new(ELeave) CDesCArrayFlat(5);
+    CleanupStack::PushL( model );
+
+    TBuf<KMaxFullName + 1> item;
+
+    // Get current config
+    CMemSpyEngineHelperSysMemTracker& swmt = iEngine.HelperSysMemTracker();
+    TMemSpyEngineHelperSysMemTrackerConfig config;
+    swmt.GetConfig( config );
+
+    // 1st item
+    _LIT( KItem1Format, "\tTracking timer period\t\t%d (sec)" );
+    item.Format( KItem1Format, config.iTimerPeriod.Int() / 1000000 );
+    model->AppendL( item );
+    
+    // 2nd item
+    _LIT( KItem3Format, "\tCategories\t\t%d selected" );
+    item.Format( KItem3Format, config.EnabledCategoryCount() );
+    model->AppendL( item );
+
+    // following items are related only to User Heap category, 
+    // so hide them if User Heap is not selected
+    if ( config.iEnabledCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryUserHeap )
+        {
+        // 3th item
+        _LIT( KItem2Format, "\tDump data" );
+        PrepareItemBufL( item, KItem2Format, config.iDumpData, config.iEnabledCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryUserHeap && config.iThreadNameFilter.Length() > 0 );
+        model->AppendL( item );
+        
+        // 4th item
+        if ( config.iDumpData )
+            {
+            _LIT( KItem4Format, "\tHeap data thread filter\t\t%S" );
+            if ( config.iThreadNameFilter.Length() > 0 )
+                {
+                item.Format( KItem4Format, &config.iThreadNameFilter );
+                }
+            else
+                {
+                item.Format( KItem4Format, &_L("No filtering") );
+                }
+            model->AppendL( item );        
+            }        
+        }
+    
+    // Set up list box
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( model );
+    listbox->Model()->SetOwnershipType( ELbmOwnsItemArray );
+    CleanupStack::Pop( model );
+    }
+
+
+void CMemSpyViewHeapTrackingSettings::PrepareItemBufL( TDes& aBuf, const TDesC& aCaption, TBool aStatus, TBool aHeapCategorySelected )
+    {
+    aBuf.Copy( aCaption ); 
+    //
+    if  ( aStatus )
+        {
+        if ( aHeapCategorySelected )
+            {
+            _LIT( KItemEnabled, "\t\tCustom" );
+            aBuf.Append( KItemEnabled );            
+            }
+        else
+            {
+            _LIT( KItemEnabled, "\t\tAll user heaps" );
+            aBuf.Append( KItemEnabled );   
+            }
+        }
+    else
+        {
+        _LIT( KItemDisabled, "\t\tDisabled" );
+        aBuf.Append( KItemDisabled );
+        }
+    }
+
+
+
+
+
+
+
+
+
+// --------------------------------------------------------------------------------------------
+
+CSWMTCategorySelectionCheckBoxSettingItem::CSWMTCategorySelectionCheckBoxSettingItem( TInt aIdentifier, TInt& aCategories ): 
+    CAknSettingItem(aIdentifier), iExtCategories( aCategories ) 
+    {
+    }   
+
+
+CSWMTCategorySelectionCheckBoxSettingItem::~CSWMTCategorySelectionCheckBoxSettingItem()
+    {
+    delete iSettingText;
+    if( iItemArray )
+        {
+        iItemArray->ResetAndDestroy();
+        delete iItemArray;
+        }
+    }
+
+
+CSelectionItemList* CSWMTCategorySelectionCheckBoxSettingItem::ItemArray() const
+    {
+    return iItemArray;
+    }
+
+
+void CSWMTCategorySelectionCheckBoxSettingItem::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 CSWMTCategorySelectionCheckBoxSettingItem::CompleteConstructionL()
+    {
+    SetEmptyItemTextL(_L("Nothing selected"));
+    iItemArray = new(ELeave) CSelectionItemList(16);
+    AddNewItemToArrayL( _L("User Heap") );       // 0
+    AddNewItemToArrayL( _L("Kernel Heap") );     // 1
+    AddNewItemToArrayL( _L("User Stacks") );     // 2
+    AddNewItemToArrayL( _L("Global Data") );     // 3
+    AddNewItemToArrayL( _L("Disk Usage") );      // 4
+    AddNewItemToArrayL( _L("Open Files") );      // 5
+    AddNewItemToArrayL( _L("RAM-loaded Code") ); // 6
+    AddNewItemToArrayL( _L("System Memory") );   // 7
+    AddNewItemToArrayL( _L("Local Chunks") );    // 8
+    AddNewItemToArrayL( _L("Global Chunks") );   // 9
+    AddNewItemToArrayL( _L("RAM Drive") );       // 10
+    AddNewItemToArrayL( _L("FileServer Cache") );// 11
+    AddNewItemToArrayL( _L("Kernel Handles") );  // 12
+    AddNewItemToArrayL( _L("Bitmap Handles") );  // 13
+    AddNewItemToArrayL( _L("Window Groups") );   // 14
+    }
+
+
+void CSWMTCategorySelectionCheckBoxSettingItem::StoreL()
+    {
+    iExtCategories = 0;
+    if ( iItemArray->At( 11 )->SelectionStatus() )
+        iExtCategories |= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryFileServerCache; 
+    if ( iItemArray->At( 13 )->SelectionStatus() )
+        iExtCategories |= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryBitmapHandles; 
+    if ( iItemArray->At( 0 )->SelectionStatus() )
+        iExtCategories |= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryUserHeap; 
+    if ( iItemArray->At( 1 )->SelectionStatus() )
+        iExtCategories |= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryKernelHeap; 
+    if ( iItemArray->At( 8 )->SelectionStatus() )
+        iExtCategories |= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryLocalChunks; 
+    if ( iItemArray->At( 9 )->SelectionStatus() )
+        iExtCategories |= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryGlobalChunks; 
+    if ( iItemArray->At( 10 )->SelectionStatus() )
+        iExtCategories |= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryRAMDrive; 
+    if ( iItemArray->At( 2 )->SelectionStatus() )
+        iExtCategories |= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryUserStacks; 
+    if ( iItemArray->At( 3 )->SelectionStatus() )
+        iExtCategories |= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryGlobalData; 
+    if ( iItemArray->At( 6 )->SelectionStatus() )
+        iExtCategories |= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryRAMLoadedCode; 
+    if ( iItemArray->At( 12 )->SelectionStatus() )
+        iExtCategories |= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryKernelHandles; 
+    if ( iItemArray->At( 5 )->SelectionStatus() )
+        iExtCategories |= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryOpenFiles; 
+    if ( iItemArray->At( 4 )->SelectionStatus() )
+        iExtCategories |= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryDiskusage; 
+    if ( iItemArray->At( 7 )->SelectionStatus() )
+        iExtCategories |= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategorySystemMemory; 
+    if ( iItemArray->At( 14 )->SelectionStatus() )
+        iExtCategories |= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryWindowGroups; 
+    }
+
+
+void CSWMTCategorySelectionCheckBoxSettingItem::LoadL()
+    {
+    iItemArray->At( 11 )->SetSelectionStatus( iExtCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryFileServerCache );
+    iItemArray->At( 13 )->SetSelectionStatus( iExtCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryBitmapHandles );
+    iItemArray->At( 0 )->SetSelectionStatus( iExtCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryUserHeap );
+    iItemArray->At( 1 )->SetSelectionStatus( iExtCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryKernelHeap );
+    iItemArray->At( 8 )->SetSelectionStatus( iExtCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryLocalChunks );
+    iItemArray->At( 9 )->SetSelectionStatus( iExtCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryGlobalChunks );
+    iItemArray->At( 10 )->SetSelectionStatus( iExtCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryRAMDrive );
+    iItemArray->At( 2 )->SetSelectionStatus( iExtCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryUserStacks );
+    iItemArray->At( 3 )->SetSelectionStatus( iExtCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryGlobalData );
+    iItemArray->At( 6 )->SetSelectionStatus( iExtCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryRAMLoadedCode );
+    iItemArray->At( 12 )->SetSelectionStatus( iExtCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryKernelHandles );
+    iItemArray->At( 5 )->SetSelectionStatus( iExtCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryOpenFiles );
+    iItemArray->At( 4 )->SetSelectionStatus( iExtCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryDiskusage );
+    iItemArray->At( 7 )->SetSelectionStatus( iExtCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategorySystemMemory );
+    iItemArray->At( 14 )->SetSelectionStatus( iExtCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryWindowGroups );
+    }
+
+
+void CSWMTCategorySelectionCheckBoxSettingItem::HandleSettingPageEventL( CAknSettingPage* aSettingPage, TAknSettingPageEvent aEventType )
+    {
+    switch( aEventType )
+        {
+        case EEventSettingOked:
+            {
+            // If settings oked, save new values
+            StoreL();
+            break;
+            }
+        case EEventSettingCancelled:
+            {
+            // If setting is cancelled, load old values
+            LoadL();
+            break;
+            }
+        case EEventSettingChanged:
+            {
+            // If setting has changed, update CBA visibility
+            static_cast<CMemSpySWMTCategorySelectionCheckBoxSettingPage*>( aSettingPage )->UpdateCba();
+            break;
+            }
+        default:
+            {
+            break;
+            }
+        }
+    CAknSettingItem::HandleSettingPageEventL( aSettingPage, aEventType );
+    }
+
+
+CMemSpySWMTCategorySelectionCheckBoxSettingPage::CMemSpySWMTCategorySelectionCheckBoxSettingPage(TInt aResourceID, CSelectionItemList* aItemArray )
+    : CAknCheckBoxSettingPage( aResourceID, aItemArray )
+    {
+    }
+
+
+void CMemSpySWMTCategorySelectionCheckBoxSettingPage::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 );
+        }
+    }
+
+
+
+
+CMemSpyAllowEmptyDataDialog::CMemSpyAllowEmptyDataDialog( TDes& aText, const TTone& aTone )
+    : CAknTextQueryDialog( aText, aTone )
+    {
+    }
+ 
+
+void CMemSpyAllowEmptyDataDialog::UpdateLeftSoftKeyL()
+    {
+    MakeLeftSoftkeyVisible( ETrue );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewKernel.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,161 @@
+/*
+* 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 "MemSpyViewKernel.h"
+
+// System includes
+#include <hal.h>
+#ifdef __EPOC32__
+#include <e32rom.h>
+#endif
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+
+// User includes
+#include "MemSpyUiUtils.h"
+#include "MemSpyViewMainMenu.h"
+#include "MemSpyContainerObserver.h"
+#include "MemSpyViewKernelHeap.h"
+#include "MemSpyViewKernelContainers.h"
+
+
+
+CMemSpyViewKernel::CMemSpyViewKernel( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
+:   CMemSpyViewBase( aEngine, aObserver )
+    {
+    }
+
+
+CMemSpyViewKernel::~CMemSpyViewKernel()
+    {
+    }
+
+
+void CMemSpyViewKernel::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    _LIT( KTitle, "Kernel" );
+    SetTitleL( KTitle );
+    //
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+    
+    // Make sure the correct item is selected
+    const TMemSpyViewType viewType = (TMemSpyViewType) ((TInt) aSelectionRune);
+    const TInt index = IndexByViewType( viewType );
+    iListBox->SetCurrentItemIndex( index );
+    HandleListBoxItemSelectedL( index );
+    }
+
+
+void CMemSpyViewKernel::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewKernel::ViewType() const
+    {
+    return EMemSpyViewTypeKernel;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewKernel::PrepareParentViewL()
+    {
+    CMemSpyViewMainMenu* parent = new(ELeave) CMemSpyViewMainMenu( iEngine, iObserver );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewKernel::PrepareChildViewL()
+    {
+    CMemSpyViewBase* child = NULL;
+    const TInt index = iListBox->CurrentItemIndex();
+    //
+    if  ( index == 0 )
+        {
+        child = new(ELeave) CMemSpyViewKernelContainers( iEngine, iObserver );
+        }
+    else if ( index == 1 )
+        {
+        child = new(ELeave) CMemSpyViewKernelHeap( iEngine, iObserver );
+        }
+
+    CleanupStack::PushL( child );
+    child->ConstructL( Rect(), *Parent() );
+    CleanupStack::Pop( child );
+    return child;
+    }
+
+
+void CMemSpyViewKernel::SetListBoxModelL()
+    {
+    CDesCArrayFlat* model = new(ELeave) CDesCArrayFlat(5);
+    CleanupStack::PushL( model );
+
+    TBuf<KMaxFullName + 1> item;
+
+    // 1st item = Processes
+    _LIT( KItem1Format, "\tObjects" );
+    item.Format( KItem1Format );
+    model->AppendL( item );
+
+    // 2nd item = System Config
+    _LIT( KItem2Format, "\tHeap" );
+    model->AppendL( KItem2Format );
+
+    // Set up list box
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( model );
+    listbox->Model()->SetOwnershipType( ELbmOwnsItemArray );
+    CleanupStack::Pop( model );
+    }
+
+
+TInt CMemSpyViewKernel::IndexByViewType( TMemSpyViewType aType )
+    {
+    TInt index = 0;
+    //
+    switch( aType )
+        {
+    default:
+    case EMemSpyViewTypeKernelContainers:
+        index = 0;
+        break;
+    case EMemSpyViewTypeKernelHeap:
+        index = 1;
+        break;
+        }
+    //
+    return index;
+    }
+
+
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewKernelContainers.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,137 @@
+/*
+* 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 "MemSpyViewKernelContainers.h"
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyenginehelperkernelcontainers.h>
+
+// User includes
+#include "MemSpyUiUtils.h"
+#include "MemSpyViewKernel.h"
+#include "MemSpyContainerObserver.h"
+#include "MemSpyViewKernelObjects.h"
+
+// Literal constants
+
+
+
+CMemSpyViewKernelContainers::CMemSpyViewKernelContainers( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
+:   CMemSpyViewBase( aEngine, aObserver )
+    {
+    }
+
+
+CMemSpyViewKernelContainers::~CMemSpyViewKernelContainers()
+    {
+    delete iModel;
+    }
+
+
+void CMemSpyViewKernelContainers::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    _LIT( KTitle, "Kernel Objects" );
+    SetTitleL( KTitle );
+    //
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+    }
+
+
+void CMemSpyViewKernelContainers::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewKernelContainers::ViewType() const
+    {
+    return EMemSpyViewTypeKernelContainers;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewKernelContainers::PrepareParentViewL()
+    {
+    CMemSpyViewKernel* parent = new(ELeave) CMemSpyViewKernel( iEngine, iObserver );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewKernelContainers::PrepareChildViewL()
+    {
+    CMemSpyViewBase* child = NULL;
+    const TInt index = iListBox->CurrentItemIndex();
+    child = new(ELeave) CMemSpyViewKernelObjects( iEngine, iObserver, iModel->At( index ).Type() );
+    CleanupStack::PushL( child );
+    child->ConstructL( Rect(), *Parent() );
+    CleanupStack::Pop( child );
+    return child;
+    }
+
+
+void CMemSpyViewKernelContainers::SetListBoxModelL()
+    {
+    // Take ownership of new model
+    CMemSpyEngineHelperKernelContainers& kernelContainerManager = iEngine.HelperKernelContainers();
+    CMemSpyEngineGenericKernelObjectContainer* model = kernelContainerManager.ObjectsAllL();
+    delete iModel;
+    iModel = model;
+    
+    // Set up list box
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( model );
+    listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+
+
+TBool CMemSpyViewKernelContainers::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = ETrue;
+    //
+    switch ( aCommand )
+        {
+    case EMemSpyCmdKernelContainersOutput:
+        OnCmdOutputAllContainerContentsL();
+        break;
+
+    default:
+        handled = CMemSpyViewBase::HandleCommandL( aCommand );
+        break;
+        }
+    //
+    return handled;
+    }
+
+
+void CMemSpyViewKernelContainers::OnCmdOutputAllContainerContentsL()
+    {
+    CMemSpyEngineOutputSink& sink = iEngine.Sink();
+    iModel->OutputL( sink );
+    }
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewKernelHeap.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,130 @@
+/*
+* 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 "MemSpyViewKernelHeap.h"
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyenginehelperheap.h>
+#include <memspy/engine/memspyengineoutputlist.h>
+
+// User includes
+#include "MemSpyUiUtils.h"
+#include "MemSpyViewKernel.h"
+#include "MemSpyContainerObserver.h"
+
+// Literal constants
+
+
+
+CMemSpyViewKernelHeap::CMemSpyViewKernelHeap( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
+:   CMemSpyViewBase( aEngine, aObserver )
+    {
+    }
+
+
+CMemSpyViewKernelHeap::~CMemSpyViewKernelHeap()
+    {
+    }
+
+
+void CMemSpyViewKernelHeap::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    _LIT( KTitle, "Kernel Heap" );
+    SetTitleL( KTitle );
+    //
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+    }
+
+
+void CMemSpyViewKernelHeap::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewKernelHeap::ViewType() const
+    {
+    return EMemSpyViewTypeKernelHeap;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewKernelHeap::PrepareParentViewL()
+    {
+    CMemSpyViewKernel* parent = new(ELeave) CMemSpyViewKernel( iEngine, iObserver );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewKernelHeap::PrepareChildViewL()
+    {
+    CMemSpyViewBase* child = NULL;
+    return child;
+    }
+
+
+void CMemSpyViewKernelHeap::SetListBoxModelL()
+    {
+    // Get list contents
+    TMemSpyHeapInfo heapInfo;
+    iEngine.HelperHeap().GetHeapInfoKernelL( heapInfo );
+    CMemSpyEngineOutputList* list = iEngine.HelperHeap().NewHeapSummaryShortLC( heapInfo );
+
+    // Set up list box
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( list );
+    listbox->Model()->SetOwnershipType( ELbmOwnsItemArray );
+    CleanupStack::Pop( list );
+    }
+
+
+TBool CMemSpyViewKernelHeap::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = ETrue;
+    //
+    switch ( aCommand )
+        {
+    case EMemSpyCmdKernelHeapDump:
+        OnCmdDumpKernelHeapL();
+        break;
+
+    default:
+        handled = CMemSpyViewBase::HandleCommandL( aCommand );
+        break;
+        }
+    //
+    return handled;
+    }
+
+
+void CMemSpyViewKernelHeap::OnCmdDumpKernelHeapL()
+    {
+    iEngine.HelperHeap().OutputHeapDataKernelL();
+    }
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewKernelObjects.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,851 @@
+/*
+* 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 "MemSpyViewKernelObjects.h"
+
+// System includes
+#include <eikspane.h>
+#include <aknnavide.h> 
+#include <akntabgrp.h>
+#include <eikclbd.h>
+#include <AknQueryDialog.h>
+#include <aknnotewrappers.h>
+#include <apgwgnam.h>
+#include <aknmessagequerydialog.h>
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyenginehelperkernelcontainers.h>
+#include <memspy/engine/memspyenginehelperserver.h>
+#include <memspy/engine/memspyenginehelpercondvar.h>
+
+// User includes
+#include "MemSpyUiUtils.h"
+#include "MemSpyViewKernel.h"
+#include "MemSpyContainerObserver.h"
+#include "MemSpyViewKernelContainers.h"
+
+const TInt KMaxInfoLength = 128;
+
+CMemSpyViewKernelObjects::CMemSpyViewKernelObjects( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, TMemSpyDriverContainerType aObjectType )
+:   CMemSpyViewBase( aEngine, aObserver ),
+    iObjectType( aObjectType ),
+    iCurrItemIndex( KErrNotFound )
+    {
+    }
+
+
+CMemSpyViewKernelObjects::~CMemSpyViewKernelObjects()
+    {
+    if ( iNavContainer && iNavDecorator )
+        {
+        iNavContainer->Pop( iNavDecorator );
+        delete iNavDecorator;
+        }
+    delete iModel;
+    delete iItems;
+    delete iObjectList;
+    }
+
+
+void CMemSpyViewKernelObjects::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    _LIT( KTitle, "Kernel Objects" );
+    SetTitleL( KTitle );
+    iItems = new(ELeave) CDesCArrayFlat(5);
+    //
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+    CreateTabsL();
+    }
+
+
+CEikListBox* CMemSpyViewKernelObjects::ConstructListBoxL()
+    {
+    delete iListBox;
+    iListBox = NULL;
+    CAknSingleStyleListBox* listbox = new (ELeave) CAknSingleStyleListBox();
+    iListBox = listbox;
+    listbox->ConstructL( this, EAknListBoxSelectionList | EAknListBoxLoopScrolling );
+    listbox->SetContainerWindowL( *this );
+    listbox->CreateScrollBarFrameL( ETrue );
+    SetListBoxModelL();
+    listbox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
+    listbox->SetListBoxObserver( this );
+    listbox->ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue);
+    listbox->SetObserver( this );
+    return listbox;
+    }
+
+
+void CMemSpyViewKernelObjects::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewKernelObjects::ViewType() const
+    {
+    return EMemSpyViewTypeKernelObjects;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewKernelObjects::PrepareParentViewL()
+    {
+    if ( iNavContainer && iNavDecorator )
+        {
+        iNavContainer->Pop( iNavDecorator );
+        delete iNavDecorator;
+        iNavDecorator = NULL;
+        }
+    CMemSpyViewBase* parent = new(ELeave) CMemSpyViewKernelContainers( iEngine, iObserver );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewKernelObjects::PrepareChildViewL()
+    {
+    CMemSpyViewBase* child = NULL;
+    if ( iListBox && 
+         iListBox->Model()->NumberOfItems() && 
+         iListBox->CurrentItemIndex() > KErrNotFound )
+        {
+        DetailsL();
+        }
+    return child;
+    }
+
+
+void CMemSpyViewKernelObjects::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
+    {
+    if  ( aResourceId == R_MEMSPY_MENUPANE )
+       {
+       if ( iObjectType > EMemSpyDriverContainerTypeProcess )
+           {
+           // Display Terminate, Switch to, End and Panic
+           // commands only for Threads and processes
+           aMenuPane->SetItemDimmed( EMemSpyCmdKernelObjects, ETrue );
+           }
+        }
+    }
+
+
+void CMemSpyViewKernelObjects::SetListBoxModelL()
+    {
+    _LIT( KLineFormatSpec, "\t%S" );
+    
+    // Take ownership of new model
+    CMemSpyEngineHelperKernelContainers& kernelContainerManager = iEngine.HelperKernelContainers();
+    CMemSpyEngineGenericKernelObjectContainer* model = kernelContainerManager.ObjectsAllL();
+    
+    delete iModel;
+    iModel = model;
+    
+    iItems->Reset();
+    delete iObjectList;
+    iObjectList = NULL;
+    iObjectList = kernelContainerManager.ObjectsForSpecificContainerL( iObjectType );
+    
+    // TODO: CMemSpyEngineGenericKernelObjectList could inherit MDesCArray like
+    // CMemSpyEngineGenericKernelObjectContainer does. iObjectList could then be passed
+    // to listbox model:
+    // listbox->Model()->SetItemTextArray( iObjectList );
+    
+    TName item;
+    TName name;
+    for ( TInt i = 0; i < iObjectList->Count(); i++ )
+        {
+        name.Copy( iObjectList->At( i ).iName );
+        item.Format( KLineFormatSpec, &name );
+        iItems->AppendL( item );
+        }
+    
+    // Set up list box
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( iItems );
+    listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+
+
+TBool CMemSpyViewKernelObjects::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = ETrue;
+    //
+    switch ( aCommand )
+        {
+        case EMemSpyCmdKernelObjectTerminate:
+            {
+            TRAPD( err, OnCmdTerminateL() );
+            if ( err )
+                {
+                CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote( ETrue );
+                note->ExecuteLD( _L("Cannot terminate task") );
+                }
+            break;
+            }
+        case EMemSpyCmdKernelObjectSwitchTo:
+            {
+            TRAPD( err, OnCmdSwitchToL() );
+            if ( err )
+                {
+                CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote( ETrue );
+                note->ExecuteLD( _L("Cannot bring to foreground") );
+                }
+            break;
+            }
+        case EMemSpyCmdKernelObjectEnd:
+            {
+            TRAPD( err, OnCmdEndL() );
+            if ( err )
+                {
+                CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote( ETrue );
+                note->ExecuteLD( _L("Cannot end task") );
+                }
+            break;
+            }
+        case EMemSpyCmdKernelObjectPanic:
+            {
+            TRAPD( err, OnCmdPanicL() );
+            if ( err )
+                {
+                CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote( ETrue );
+                note->ExecuteLD( _L("Cannot panic task") );
+                }
+            break;
+            }
+        default:
+            {
+            handled = CMemSpyViewBase::HandleCommandL( aCommand );
+            break;        
+            }
+        }
+    //
+    return handled;
+    }
+
+
+TKeyResponse CMemSpyViewKernelObjects::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
+    {
+    TKeyResponse resp = EKeyWasNotConsumed;
+    if  ( iTabs && ( aKeyEvent.iScanCode == EStdKeyRightArrow || aKeyEvent.iScanCode == EStdKeyLeftArrow ) )
+        {
+        resp = iTabs->OfferKeyEventL( aKeyEvent, aType );
+        }
+    else
+        {
+        resp = CMemSpyViewBase::OfferKeyEventL( aKeyEvent, aType );    
+        }
+    return resp;
+    }
+
+
+void CMemSpyViewKernelObjects::TabChangedL( TInt /*aIndex*/ )
+    {
+    iObjectType = (TMemSpyDriverContainerType)iTabs->ActiveTabId();
+    RefreshL();
+    }
+
+
+void CMemSpyViewKernelObjects::OnCmdTerminateL()
+    {
+    switch ( iObjectType )
+        {
+        case EMemSpyDriverContainerTypeThread:
+            {
+            TBool doTerminate = ETrue;
+            
+            CMemSpyEngineObjectContainer& container = iEngine.Container();
+            TThreadId id( iObjectList->At( iListBox->CurrentItemIndex() ).iId );
+            
+            // Try to find the thread in question...
+            CMemSpyProcess* process = NULL;
+            CMemSpyThread* thread = NULL; 
+            User::LeaveIfError( container.ProcessAndThreadByThreadId( id, process, thread ) );
+
+            if ( thread )
+                {
+                thread->Open();
+                //
+                if  ( thread->IsSystemPermanent() || thread->IsSystemCritical() )
+                    {
+                    CAknQueryDialog* importDialog = CAknQueryDialog::NewL();
+                    doTerminate = ( importDialog->ExecuteLD( R_MEMSPY_PANIC_SYSTEM_CRITICAL_THREAD_OR_PROCESS ) );
+                    }
+                //
+                if  ( doTerminate )
+                    {
+                    thread->TerminateL();
+                    }                
+                }
+            RefreshL();
+            break;
+            }
+        case EMemSpyDriverContainerTypeProcess:
+            {
+            TBool doTerminate = ETrue;
+            // Obtain the process that corresponds to the selected item
+            CMemSpyEngineObjectContainer& container = iEngine.Container();
+            TProcessId id( iObjectList->At( iListBox->CurrentItemIndex() ).iId );
+            CMemSpyProcess& process = container.ProcessByIdL( id );
+            process.Open();
+
+            if  ( process.IsSystemPermanent() || process.IsSystemCritical() )
+                {
+                CAknQueryDialog* importDialog = CAknQueryDialog::NewL();
+                doTerminate = ( importDialog->ExecuteLD( R_MEMSPY_PANIC_SYSTEM_CRITICAL_THREAD_OR_PROCESS ) );
+                }
+            //
+            if  ( doTerminate )
+                {
+                process.TerminateL();
+                RefreshL();
+                }
+            break;
+            }
+        default:
+            {
+            // Programming error
+            __ASSERT_ALWAYS( EFalse, User::Panic( _L("MemSpy-View"), 0 ) );
+            }
+        }
+    }
+
+
+void CMemSpyViewKernelObjects::OnCmdSwitchToL()
+    {
+    TInt wgCount;
+    RWsSession wsSession;
+    User::LeaveIfError( wsSession.Connect() );
+    CleanupClosePushL( wsSession );
+    User::LeaveIfError( wgCount = wsSession.NumWindowGroups() );
+    RArray<RWsSession::TWindowGroupChainInfo> wgArray;
+    CleanupClosePushL( wgArray );
+    User::LeaveIfError( wsSession.WindowGroupList( &wgArray ) );
+    TApaTask task( wsSession );
+    TBool brought( EFalse );
+    TInt wgId( KErrNotFound );
+    TThreadId threadId;
+    switch ( iObjectType )
+        {
+        case EMemSpyDriverContainerTypeThread:
+            {
+            TThreadId currentThreadId( iObjectList->At( iListBox->CurrentItemIndex() ).iId );
+            
+            // loop trough all window groups and see if a thread id matches
+            while( !brought && wgCount-- )
+                {
+                wgId = wgArray[wgCount].iId;
+                User::LeaveIfError( wsSession.GetWindowGroupClientThreadId( wgId, threadId ) );
+                if ( threadId == currentThreadId )
+                    {
+                    CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC( wsSession, wgId );
+                    task.SetWgId( wgId );
+                    if ( !wgName->Hidden() && task.Exists() )
+                        {
+                        task.BringToForeground();
+                        brought = ETrue;                        
+                        }
+                    CleanupStack::PopAndDestroy( wgName );
+                    }
+                }                
+            break;
+            }
+        case EMemSpyDriverContainerTypeProcess:
+            {
+            CMemSpyEngineObjectContainer& container = iEngine.Container();
+            TProcessId id( iObjectList->At( iListBox->CurrentItemIndex() ).iId );
+            CMemSpyProcess& process = container.ProcessByIdL( id );
+            
+            // loop trough threads in a process
+            for ( TInt i = 0; i < process.MdcaCount(); i++ )
+                {
+                TInt wgCountLocal = wgCount;
+                
+                // loop trough all window groups and see if a thread id matches
+                while( !brought && wgCountLocal-- )
+                    {
+                    wgId = wgArray[wgCountLocal].iId;
+                    User::LeaveIfError( wsSession.GetWindowGroupClientThreadId( wgId, threadId ) );
+                    if ( threadId == process.At( i ).Id() )
+                        {
+                        CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC( wsSession, wgId );
+                        task.SetWgId( wgId );
+                        if ( !wgName->Hidden() && task.Exists() )
+                            {
+                            task.BringToForeground();
+                            brought = ETrue;                        
+                            }
+                        CleanupStack::PopAndDestroy( wgName );
+                        }
+                    }
+                }
+
+            break;
+            }
+        default:
+            {
+            // Programming error
+            __ASSERT_ALWAYS( EFalse, User::Panic( _L("MemSpy-View"), 0 ) );
+            }
+        }
+    if ( !brought )
+        {
+        // Error handling in HandleCommandL
+        User::Leave( KErrGeneral );
+        }
+    CleanupStack::PopAndDestroy( 2 ); //wgArray,wsSession
+    }
+
+
+void CMemSpyViewKernelObjects::OnCmdEndL()
+    {
+    switch ( iObjectType )
+        {
+        case EMemSpyDriverContainerTypeThread:
+            {
+            TBool doTerminate = ETrue;
+            
+            CMemSpyEngineObjectContainer& container = iEngine.Container();
+            TThreadId id( iObjectList->At( iListBox->CurrentItemIndex() ).iId );
+            
+            // Try to find the thread in question...
+            CMemSpyProcess* process = NULL;
+            CMemSpyThread* thread = NULL; 
+            User::LeaveIfError( container.ProcessAndThreadByThreadId( id, process, thread ) );
+
+            if ( thread )
+                {
+                thread->Open();
+                //
+                if  ( thread->IsSystemPermanent() || thread->IsSystemCritical() )
+                    {
+                    CAknQueryDialog* importDialog = CAknQueryDialog::NewL();
+                    doTerminate = ( importDialog->ExecuteLD( R_MEMSPY_PANIC_SYSTEM_CRITICAL_THREAD_OR_PROCESS ) );
+                    }
+                //
+                if  ( doTerminate )
+                    {
+                    thread->KillL();
+                    }                
+                }
+            RefreshL();
+            break;
+            }
+        case EMemSpyDriverContainerTypeProcess:
+            {
+            TBool doTerminate = ETrue;
+            // Obtain the process that corresponds to the selected item
+            CMemSpyEngineObjectContainer& container = iEngine.Container();
+            TProcessId id( iObjectList->At( iListBox->CurrentItemIndex() ).iId );
+            CMemSpyProcess& process = container.ProcessByIdL( id );
+            process.Open();
+
+            if  ( process.IsSystemPermanent() || process.IsSystemCritical() )
+                {
+                CAknQueryDialog* importDialog = CAknQueryDialog::NewL();
+                doTerminate = ( importDialog->ExecuteLD( R_MEMSPY_PANIC_SYSTEM_CRITICAL_THREAD_OR_PROCESS ) );
+                }
+            if  ( doTerminate )
+                {
+                process.KillL();
+                RefreshL();
+                }
+
+            break;
+            }
+        default:
+            {
+            // Programming error
+            __ASSERT_ALWAYS( EFalse, User::Panic( _L("MemSpy-View"), 0 ) );
+            }
+        }    
+    }
+
+
+void CMemSpyViewKernelObjects::OnCmdPanicL()
+    {
+    switch ( iObjectType )
+        {
+        case EMemSpyDriverContainerTypeThread:
+            {
+            TBool doTerminate = ETrue;
+            
+            CMemSpyEngineObjectContainer& container = iEngine.Container();
+            TThreadId id( iObjectList->At( iListBox->CurrentItemIndex() ).iId );
+            
+            // Try to find the thread in question...
+            CMemSpyProcess* process = NULL;
+            CMemSpyThread* thread = NULL; 
+            User::LeaveIfError( container.ProcessAndThreadByThreadId( id, process, thread ) );
+
+            if ( thread )
+                {
+                thread->Open();
+                //
+                if  ( thread->IsSystemPermanent() || thread->IsSystemCritical() )
+                    {
+                    CAknQueryDialog* importDialog = CAknQueryDialog::NewL();
+                    doTerminate = ( importDialog->ExecuteLD( R_MEMSPY_PANIC_SYSTEM_CRITICAL_THREAD_OR_PROCESS ) );
+                    }
+                //
+                if  ( doTerminate )
+                    {
+                    thread->PanicL();
+                    }                
+                }
+            RefreshL();
+            break;
+            }
+        case EMemSpyDriverContainerTypeProcess:
+            {
+            TBool doTerminate = ETrue;
+            // Obtain the process that corresponds to the selected item
+            CMemSpyEngineObjectContainer& container = iEngine.Container();
+            TProcessId id( iObjectList->At( iListBox->CurrentItemIndex() ).iId );
+            CMemSpyProcess& process = container.ProcessByIdL( id );
+            process.Open();
+
+            if  ( process.IsSystemPermanent() || process.IsSystemCritical() )
+                {
+                CAknQueryDialog* importDialog = CAknQueryDialog::NewL();
+                doTerminate = ( importDialog->ExecuteLD( R_MEMSPY_PANIC_SYSTEM_CRITICAL_THREAD_OR_PROCESS ) );
+                }
+            if  ( doTerminate )
+                {
+                process.PanicL();
+                RefreshL();
+                }
+            break;
+            }
+        default:
+            {
+            // Programming error
+            __ASSERT_ALWAYS( EFalse, User::Panic( _L("MemSpy-View"), 0 ) );
+            }
+        }
+    }
+
+
+void CMemSpyViewKernelObjects::CreateTabsL()
+    {
+    CEikStatusPane* statusPane = static_cast<CAknAppUi*> ( iEikonEnv->EikAppUi() )->StatusPane();
+    TUid uid;
+    uid.iUid = EEikStatusPaneUidNavi;
+    iNavDecorator = ((CAknNavigationControlContainer*)(statusPane->ControlL(uid)))->Top();
+
+    if ( !iNavDecorator )
+        {
+        iNavContainer = (CAknNavigationControlContainer*)statusPane->ControlL(uid);
+        iNavDecorator = iNavContainer->CreateTabGroupL();
+
+        iTabs = ( CAknTabGroup* )iNavDecorator->DecoratedControl();
+        iTabs->SetTabFixedWidthL( KTabWidthWithThreeLongTabs );
+    
+        for ( TInt i = 0; i < iModel->Count(); i++ )
+            {
+            const CMemSpyEngineGenericKernelObjectList& item = iModel->At( i );
+            iTabs->AddTabL( item.Type(), item.TypeAsString( item.Type() ) );
+            }
+        iTabs->SetActiveTabById( iObjectType );
+        iTabs->SetObserver( this );
+        iNavContainer->PushL( *iNavDecorator );
+        }
+    }
+
+
+void CMemSpyViewKernelObjects::DetailsL()
+    {
+    HBufC* messageBuf = HBufC::NewLC( 40960 );
+    TPtr messagePtr = messageBuf->Des();
+
+    const TMemSpyDriverHandleInfoGeneric& selectedObject = iObjectList->At( iListBox->CurrentItemIndex() );
+
+    // General attributes:
+    TFullName name;
+    name.Copy( selectedObject.iNameDetail );
+    AppendFormatString( messagePtr, _L("Name: %S\n"), &name );
+    name.Zero();
+    name.Copy( selectedObject.iName );
+    AppendFormatString( messagePtr, _L("FullName: %S\n"), &name );
+    name.Zero();
+    AppendFormatString( messagePtr, _L("AccessCount: %d\n"), selectedObject.iAccessCount );
+    AppendFormatString( messagePtr, _L("UniqueID: %d\n"), selectedObject.iUniqueID );
+    AppendFormatString( messagePtr, _L("Protection: %u\n"), selectedObject.iProtection );
+    AppendFormatString( messagePtr, _L("OwnrAddr: 0x%08X\n"), selectedObject.iAddressOfKernelOwner );
+    AppendFormatString( messagePtr, _L("KernelAddr: 0x%08X"), selectedObject.iHandle );
+    
+    // Object type specific attributes:
+    switch ( selectedObject.iType )
+        {
+        case EMemSpyDriverContainerTypeUnknown:
+            {
+            break;
+            }
+        case EMemSpyDriverContainerTypeThread:
+            {
+            AppendFormatString( messagePtr, _L("\nOwnrPrAddr: 0x%08X\n"), selectedObject.iAddressOfOwningProcess );
+            AppendFormatString( messagePtr, _L("ThreadID: %d\n"), selectedObject.iId );
+            AppendFormatString( messagePtr, _L("Priority: %d\n"), selectedObject.iPriority );
+            TFullName procName;
+            procName.Copy( selectedObject.iNameOfOwner );
+            AppendFormatString( messagePtr, _L("Proc: %S"), &procName );
+            procName.Zero();
+            break;
+            }
+        case EMemSpyDriverContainerTypeProcess:
+            {
+            AppendFormatString( messagePtr, _L("\nOwnrPrAddr: 0x%08X\n"), selectedObject.iAddressOfOwningProcess );
+            AppendFormatString( messagePtr, _L("CreatorId: %u\n"), selectedObject.iCreatorId );
+            AppendFormatString( messagePtr, _L("Attributes: 0x%08X\n"), selectedObject.iAttributes );
+            AppendFormatString( messagePtr, _L("StckChnk: 0x%08X\n"), selectedObject.iAddressOfDataBssStackChunk );
+            AppendFormatString( messagePtr, _L("ProcessID: %d\n"), selectedObject.iId );
+            AppendFormatString( messagePtr, _L("Priority: %d\n"), selectedObject.iPriority );
+            AppendFormatString( messagePtr, _L("SecurityZone: %d"), selectedObject.iSecurityZone );
+            CMemSpyEngineObjectContainer& container = iEngine.Container();
+            TProcessId id( selectedObject.iId );
+            TRAP_IGNORE(
+                CMemSpyProcess& process = container.ProcessByIdL( id );
+                AppendFormatString( messagePtr, _L("\nSID: 0x%08X\n"), process.SID() );
+                AppendFormatString( messagePtr, _L("VID: 0x%08X\n"), process.VID() );
+                AppendFormatString( messagePtr, _L("UID1: 0x%08X\n"), process.UIDs()[0].iUid  );
+                AppendFormatString( messagePtr, _L("UID2: 0x%08X\n"), process.UIDs()[1].iUid  );
+                AppendFormatString( messagePtr, _L("UID3: 0x%08X\n"), process.UIDs()[2].iUid );
+                AppendFormatString( messagePtr, _L("Caps: 0x%08X%08X"), process.Capabilities().iCaps[0], process.Capabilities().iCaps[1]);
+                );
+            break;
+            }
+        case EMemSpyDriverContainerTypeChunk:
+            {
+            AppendFormatString( messagePtr, _L("\nOwnrPrAddr: 0x%08X\n"), selectedObject.iAddressOfOwningProcess );
+            AppendFormatString( messagePtr, _L("Size: %d\n"), selectedObject.iSize );
+            AppendFormatString( messagePtr, _L("MaxSize: %d\n"), selectedObject.iMaxSize );
+            AppendFormatString( messagePtr, _L("Bottom: %d\n"), selectedObject.iBottom );
+            AppendFormatString( messagePtr, _L("Top: %d\n"), selectedObject.iTop );
+            AppendFormatString( messagePtr, _L("Attr: 0x%08X\n"), selectedObject.iAttributes );
+            AppendFormatString( messagePtr, _L("Start: %d\n"), selectedObject.iStartPos );
+            AppendFormatString( messagePtr, _L("CntrlID: %u\n"), selectedObject.iControllingOwner );
+            AppendFormatString( messagePtr, _L("Restrictions: %u\n"), selectedObject.iRestrictions );
+            AppendFormatString( messagePtr, _L("MapAttr: %u\n"), selectedObject.iMapAttr );
+            AppendFormatString( messagePtr, _L("Type: %u\n"), selectedObject.iChunkType );
+            TFullName procName;
+            procName.Copy( selectedObject.iNameOfOwner );
+            AppendFormatString( messagePtr, _L("Proc: %S"), &procName );
+            procName.Zero();
+            // OwnerAddr iAddressOfKernelOwner already listed
+            // ProcAddr iAddressOfOwningProcess already listed
+            break;
+            }
+        case EMemSpyDriverContainerTypeLibrary:
+            {
+            AppendFormatString( messagePtr, _L("\nMapCount: %d\n"), selectedObject.iMapCount );
+            AppendFormatString( messagePtr, _L("State: %u\n"), selectedObject.iState );
+            AppendFormatString( messagePtr, _L("CodeSeg: 0x%08X"), selectedObject.iAddressOfCodeSeg );
+            break;
+            }
+        case EMemSpyDriverContainerTypeSemaphore:
+            {
+            AppendFormatString( messagePtr, _L("\nCount: %d\n"), selectedObject.iCount );
+            AppendFormatString( messagePtr, _L("Resetting: %u"), selectedObject.iResetting );
+            break;
+            }
+        case EMemSpyDriverContainerTypeMutex:
+            {
+            AppendFormatString( messagePtr, _L("\nHoldCount: %d\n"), selectedObject.iCount );
+            AppendFormatString( messagePtr, _L("WaitCount: %d\n"), selectedObject.iWaitCount );
+            AppendFormatString( messagePtr, _L("Resetting: %u\n"), selectedObject.iResetting );
+            AppendFormatString( messagePtr, _L("Order: %u"), selectedObject.iOrder );
+            break;
+            }
+        case EMemSpyDriverContainerTypeTimer:
+            {
+            AppendFormatString( messagePtr, _L("\nState: %d\n"), selectedObject.iTimerState );
+            AppendFormatString( messagePtr, _L("Type: %d"), selectedObject.iTimerType );
+            break;
+            }
+        case EMemSpyDriverContainerTypeServer:
+            {
+            // Owner == ThrdAddr
+            AppendFormatString( messagePtr, _L("\nThrdAddr: 0x%08X\n"), selectedObject.iAddressOfOwningThread );
+            TFullName thrName;
+            thrName.Copy( selectedObject.iNameOfOwner );
+            AppendFormatString( messagePtr, _L("Thr: %S\n"), &thrName );
+            thrName.Zero();
+            AppendFormatString( messagePtr, _L("Type: %d\n"), selectedObject.iSessionType );
+            TBuf8<55>buf;
+            RArray<TMemSpyDriverServerSessionInfo> sessions;
+            CleanupClosePushL( sessions );
+            iEngine.HelperServer().GetServerSessionsL( selectedObject, sessions );
+            const TInt count = sessions.Count();
+            for ( TInt i = 0; i < count; i++ )
+                {
+                const TMemSpyDriverServerSessionInfo& session = sessions[ i ];
+                AppendFormatString( messagePtr, _L("SessAddr: 0x%08X\n"), session.iAddress );
+                TFullName sessName;
+                sessName.Copy( session.iName );
+                AppendFormatString( messagePtr, _L("Sess: %S\n"), &sessName );
+                }
+            CleanupStack::PopAndDestroy( &sessions );
+            break;
+            }
+        case EMemSpyDriverContainerTypeSession:
+            {
+            // Server == SvrAddr
+            AppendFormatString( messagePtr, _L("\nServer: 0x%08X\n"), selectedObject.iAddressOfServer );
+            TFullName srvName;
+            srvName.Copy( selectedObject.iName );
+            AppendFormatString( messagePtr, _L("Srv: %S\n"), &srvName );
+            srvName.Zero();
+            // Session: not supported
+            AppendFormatString( messagePtr, _L("AccCount: %u\n"), selectedObject.iTotalAccessCount );
+            AppendFormatString( messagePtr, _L("SesType: %u\n"), selectedObject.iSessionType );
+            AppendFormatString( messagePtr, _L("SvrType: %u\n"), selectedObject.iSvrSessionType );
+            AppendFormatString( messagePtr, _L("MsgCount: %d\n"),  selectedObject.iMsgCount );
+            AppendFormatString( messagePtr, _L("MsgLimit: %d"), selectedObject.iMsgLimit );
+            break;
+            }
+        case EMemSpyDriverContainerTypeLogicalDevice:
+            {
+            AppendFormatString( messagePtr, 
+                                _L("\nVersion: %d.%d.%d\n"), 
+                                selectedObject.iVersion.iMajor,
+                                selectedObject.iVersion.iMinor,
+                                selectedObject.iVersion.iBuild );
+            AppendFormatString( messagePtr, _L("ParseMask: 0x%08X\n"), selectedObject.iParseMask );
+            AppendFormatString( messagePtr, _L("UnitsMask: 0x%08X\n"), selectedObject.iUnitsMask );
+            AppendFormatString( messagePtr, _L("Open channels: %d"), selectedObject.iOpenChannels );
+            break;
+            }
+        case EMemSpyDriverContainerTypePhysicalDevice:
+            {
+            AppendFormatString( messagePtr, 
+                                _L("\nVersion: %d.%d.%d\n"), 
+                                selectedObject.iVersion.iMajor,
+                                selectedObject.iVersion.iMinor,
+                                selectedObject.iVersion.iBuild );
+            AppendFormatString( messagePtr, _L("UnitsMask: 0x%08X\n"), selectedObject.iUnitsMask );
+            AppendFormatString( messagePtr, _L("CodeSeg: 0x%08X"), selectedObject.iAddressOfCodeSeg );
+            break;
+            }
+        case EMemSpyDriverContainerTypeLogicalChannel:
+            {
+            // No other details
+            break;
+            }
+        case EMemSpyDriverContainerTypeChangeNotifier:
+            {
+            AppendFormatString( messagePtr, _L("\nChanges: %u\n"), selectedObject.iChanges );
+            // Thread == ThrdAddr
+            AppendFormatString( messagePtr, _L("ThrdAddr: 0x%08X\n"), selectedObject.iAddressOfOwningThread );
+            TFullName thrName;
+            thrName.Copy( selectedObject.iNameOfOwner );
+            AppendFormatString( messagePtr, _L("Thr: %S"), &thrName );
+            thrName.Zero();
+            break;
+            }
+        case EMemSpyDriverContainerTypeUndertaker:
+            {
+            // Thread == ThrdAddr
+            AppendFormatString( messagePtr, _L("\nThrdAddr: 0x%08X\n"), selectedObject.iAddressOfOwningThread );
+            TFullName thrName;
+            thrName.Copy( selectedObject.iNameOfOwner );
+            AppendFormatString( messagePtr, _L("Thr: %S"), &thrName );
+            thrName.Zero();
+            break;
+            }
+        case EMemSpyDriverContainerTypeMsgQueue:
+            {
+            // No other details
+            break;
+            }
+        case EMemSpyDriverContainerTypePropertyRef:
+            {
+            /*
+            Not listing details here, as propertyRef is not listed in TaskMgr.
+            Following propertyRef attributes are available at engine side. 
+            
+            IsReady
+            Type
+            Category
+            Key
+            RefCount
+            ThreadId
+            CreatorSID
+            */
+            break;
+            }
+        case EMemSpyDriverContainerTypeCondVar:
+            {
+            AppendFormatString( messagePtr, _L("\nResetting: %u\n"), selectedObject.iResetting );
+            // Using iAddressOfOwningThread for mutex
+            AppendFormatString( messagePtr, _L("Mutex: 0x%08X\n"), selectedObject.iAddressOfOwningThread );
+            // Using iNameOfOwner for mutex
+            TFullName mtxName;
+            mtxName.Copy( selectedObject.iNameOfOwner );
+            AppendFormatString( messagePtr, _L("Mtx: %S\n"), &mtxName );
+            mtxName.Zero();
+            AppendFormatString( messagePtr, _L("WaitCount: %d\n"), selectedObject.iWaitCount );
+            
+            RArray<TMemSpyDriverCondVarSuspendedThreadInfo> threads;
+            CleanupClosePushL( threads );
+            iEngine.HelperCondVar().GetCondVarSuspendedThreadsL( selectedObject, threads );
+            const TInt count = threads.Count();
+            for ( TInt i = 0; i < count; i++ )
+                {
+                const TMemSpyDriverCondVarSuspendedThreadInfo& thr = threads[ i ];
+                AppendFormatString( messagePtr, _L("SuspThrdAddr: 0x%08X\n"), thr.iAddress );
+                TFullName thrName;
+                thrName.Copy( thr.iName );
+                AppendFormatString( messagePtr, _L("Thr: %S\n"), &thrName );
+                }
+            CleanupStack::PopAndDestroy( &threads );
+            break;
+            }
+        default:
+            {
+            // Programming error
+            __ASSERT_ALWAYS( EFalse, User::Panic( _L("MemSpy-View"), 0 ) );
+            }
+        }
+    
+    CAknMessageQueryDialog* dialog = new(ELeave) CAknMessageQueryDialog( CAknQueryDialog::ENoTone );
+    dialog->PrepareLC( R_MEMSPY_KERNEL_OBJECT_DETAILS_DIALOG );
+    TFileName headerText;
+    headerText.Copy( selectedObject.iName );
+    dialog->SetHeaderTextL( headerText );
+    dialog->SetMessageTextL(messagePtr);
+    dialog->RunLD();
+    CleanupStack::PopAndDestroy( messageBuf );
+    }
+
+
+void CMemSpyViewKernelObjects::AppendFormatString( TPtr& aPtr, TRefByValue<const TDesC> aFmt, ... )
+    {
+    TBuf<KMaxInfoLength> infoString;
+    VA_LIST list;
+    VA_START ( list, aFmt );
+    infoString.FormatList( aFmt, list );
+    aPtr.Append( infoString );
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewMainMenu.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,300 @@
+/*
+* 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 "MemSpyViewMainMenu.h"
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyenginehelperprocess.h>
+
+// User includes
+#include "MemSpyContainerObserver.h"
+#include "MemSpyViewProcesses.h"
+#include "MemSpyViewRAMInfo.h"
+#include "MemSpyViewROMInfo.h"
+#include "MemSpyViewServerList.h"
+#include "MemSpyViewOpenFiles.h"
+#include "MemSpyViewFBServBitmaps.h"
+#include "MemSpyViewSystemConfig.h"
+#include "MemSpyViewCodeSegList.h"
+#include "MemSpyViewChunkList.h"
+#include "MemSpyViewKernel.h"
+#include "MemSpyViewHeapTracking.h"
+#include "MemSpyViewDriveInfo.h"
+#include "MemSpyViewECom.h"
+#include "MemSpyViewMemoryTrackingAutoStartConfig.h"
+#include "MemSpyViewWindowGroups.h"
+
+// System includes
+#include <aknnotewrappers.h>
+
+
+CMemSpyViewMainMenu::CMemSpyViewMainMenu( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
+:   CMemSpyViewBase( aEngine, aObserver )
+    {
+    }
+
+
+void CMemSpyViewMainMenu::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    _LIT( KTitle, "MemSpy" );
+    SetTitleL( KTitle );
+    //
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+    
+    // Make sure the correct item is selected
+    const TMemSpyViewType viewType = (TMemSpyViewType) ((TInt) aSelectionRune);
+    const TInt index = IndexByViewType( viewType );
+    iListBox->SetCurrentItemIndex( index );
+    HandleListBoxItemSelectedL( index );
+    }
+
+
+void CMemSpyViewMainMenu::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewMainMenu::ViewType() const
+    {
+    return EMemSpyViewTypeMainMenu;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewMainMenu::PrepareChildViewL()
+    {
+    CMemSpyViewBase* child = NULL;
+    const TInt index = iListBox->CurrentItemIndex();
+    
+#ifdef __WINS__
+    // threads & process view is not supported in the emulator environment
+    if  ( index == 0 )
+        {
+        CAknInformationNote* note = new (ELeave) CAknInformationNote;
+        note->ExecuteLD(_L("Not supported in the emulator, try Kernel -> Objects view"));
+        return NULL;
+        }
+#endif
+
+    if  ( index == 0 )
+        {
+        child = new(ELeave) CMemSpyViewProcesses( iEngine, iObserver );
+        }
+    else if ( index == 1 )
+        {
+        child = new(ELeave) CMemSpyViewRAMInfo( iEngine, iObserver );
+        }
+    else if ( index == 2 )
+        {
+        child = new(ELeave) CMemSpyViewROMInfo( iEngine, iObserver );
+        }
+    else if ( index == 3 )
+        {
+        child = new(ELeave) CMemSpyViewFBServBitmaps( iEngine, iObserver );
+        }
+    else if ( index == 4 )
+        {
+        child = new(ELeave) CMemSpyViewServerList( iEngine, iObserver );
+        }
+    else if ( index == 5 )
+        {
+        child = new(ELeave) CMemSpyViewChunkList( iEngine, iObserver );
+        }
+    else if ( index == 6 )
+        {
+        child = new(ELeave) CMemSpyViewCodeSegList( iEngine, iObserver );
+        }
+    else if ( index == 7 )
+        {
+        child = new(ELeave) CMemSpyViewOpenFiles( iEngine, iObserver );
+        }
+    else if ( index == 8 )
+        {
+        child = new(ELeave) CMemSpyViewSystemConfig( iEngine, iObserver );
+        }
+    else if ( index == 9 )
+        {
+        child = new(ELeave) CMemSpyViewKernel( iEngine, iObserver );
+        }
+    else if ( index == 10 )
+        {
+        child = new(ELeave) CMemSpyViewHeapTracking( iEngine, iObserver );
+        }
+    else if ( index == 11 )
+        {
+        child = new(ELeave) CMemSpyViewMemoryTrackingAutoStartConfig( iEngine, iObserver );
+        }
+    else if ( index == 12 )
+        {
+        child = new(ELeave) CMemSpyViewDriveList( iEngine, iObserver );
+        }
+    else if ( index == 13 )
+        {
+        child = new(ELeave) CMemSpyViewECom( iEngine, iObserver );
+        }
+    else if ( index == 14 )
+        {
+        child = new(ELeave) CMemSpyViewWindowGroups( iEngine, iObserver );
+        }
+    CleanupStack::PushL( child );
+    child->ConstructL( Rect(), *Parent() );
+    CleanupStack::Pop( child );
+    return child;
+    }
+
+
+void CMemSpyViewMainMenu::SetListBoxModelL()
+    {
+    CDesCArrayFlat* model = new(ELeave) CDesCArrayFlat(5);
+    CleanupStack::PushL( model );
+
+    TBuf<KMaxFullName + 1> item;
+
+    // 1st item = Processes
+    _LIT(KItem1Format, "\tProcesses & Threads");
+    item.Format( KItem1Format );
+    model->AppendL( item );
+
+    // 2nd item = RAM info
+    _LIT(KItem2Format, "\tRAM Info");
+    model->AppendL( KItem2Format );
+
+    // 3rd item = ROM info
+    _LIT(KItem3Format, "\tROM Info");
+    model->AppendL( KItem3Format );
+
+    // 4th item = FBServ Bitmaps
+    _LIT(KItem4Format, "\tFont & Bitmap\nServer");
+    model->AppendL( KItem4Format );
+
+    // 5th item = Servers
+    _LIT(KItem5Format, "\tServers");
+    item.Format( KItem5Format);
+    model->AppendL( item );
+
+    // 6th item = Chunks
+    _LIT(KItem6Format, "\tChunks");
+    model->AppendL( KItem6Format );
+
+    // 7th item = Code Segments
+    _LIT(KItem7Format, "\tCode Segments");
+    model->AppendL( KItem7Format );
+
+    // 8th item = Open Files
+    _LIT(KItem8Format, "\tOpen Files");
+    model->AppendL( KItem8Format );
+
+    // 9th item = System Config
+    _LIT(KItem9Format, "\tSystem\nConfiguration");
+    model->AppendL( KItem9Format );
+
+    // 10th item = Kernel
+    _LIT(KItem10Format, "\tKernel");
+    model->AppendL( KItem10Format );
+
+    // 11th item = Heap Tracking
+    _LIT(KItem11Format, "\tSystem-Wide Memory Tracking");
+    model->AppendL( KItem11Format );
+
+    // 12th item = Process-specific Tracking
+    _LIT(KItem12Format, "\tProcess-Specific Memory Tracking");
+    model->AppendL( KItem12Format );
+
+    // 13th item = Drive Info
+    _LIT(KItem13Format, "\tDrive Summary");
+    model->AppendL( KItem13Format );
+
+    // 14th item = ECOM
+    _LIT(KItem14Format, "\tECom");
+    model->AppendL( KItem14Format );
+
+    // 15th item = Window Groups
+    _LIT(KItem15Format, "\tWindow Groups");
+    model->AppendL( KItem15Format );
+    
+    // Set up list box
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( model );
+    listbox->Model()->SetOwnershipType( ELbmOwnsItemArray );
+    CleanupStack::Pop( model );
+    }
+
+
+TInt CMemSpyViewMainMenu::IndexByViewType( TMemSpyViewType aType )
+    {
+    TInt index = 0;
+    //
+    switch( aType )
+        {
+    default:
+    case EMemSpyViewTypeProcesses:
+        index = 0;
+        break;
+    case EMemSpyViewTypeRAMInfo:
+        index = 1;
+        break;
+    case EMemSpyViewTypeROMInfo:
+        index = 2;
+        break;
+    case EMemSpyViewTypeFBServBitmaps:
+        index = 3;
+        break;
+    case EMemSpyViewTypeServerList:
+        index = 4;
+        break;
+    case EMemSpyViewTypeChunkList:
+        index = 5;
+        break;
+    case EMemSpyViewTypeCodeSegmentList:
+        index = 6;
+        break;
+    case EMemSpyViewTypeOpenFiles:
+        index = 7;
+        break;
+    case EMemSpyViewTypeSystemConfig:
+        index = 8;
+        break;
+    case EMemSpyViewTypeKernel:
+        index = 9;
+        break;
+    case EMemSpyViewTypeHeapTracking:
+        index = 10;
+        break;
+    case EMemSpyViewTypeThreadInfoItemMemoryTrackingAutoStartConfig:
+        index = 11;
+        break;
+    case EMemSpyViewTypeDriveSummary:
+        index = 12;
+        break;
+    case EMemSpyViewTypeECom:
+        index = 13;
+        break;
+    case EMemSpyViewTypeWindowGroups:
+        index = 14;
+        break;        
+        }
+    //
+    return index;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewMemoryTrackingAutoStartConfig.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,570 @@
+/*
+* 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 "MemSpyViewMemoryTrackingAutoStartConfig.h"
+
+// System includes
+#include <AknQueryDialog.h>
+#include <charconv.h>
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyengineprocessmemorytracker.h>
+#include <memspy/engine/memspyenginehelperprocess.h>
+
+// User includes
+#include "MemSpyUiUtils.h"
+#include "MemSpyViewMainMenu.h"
+#include "MemSpyContainerObserver.h"
+
+// Literal constants
+_LIT8( KMemSpyProcessMemoryTrackerXmlFileMimeType, "text/xml" );
+_LIT8( KMemSpyXmlSpec_MasterSection, "memspy_process_memory_tracking" );
+_LIT8( KMemSpyXmlSpec_EntryProcess, "process" );
+_LIT8( KMemSpyXmlSpec_EntryProcess_SID, "sid" );
+_LIT8( KMemSpyXmlSpec_HexPrefix, "0x" );
+
+
+
+CMemSpyViewMemoryTrackingAutoStartConfig::CMemSpyViewMemoryTrackingAutoStartConfig( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
+:   CMemSpyViewBase( aEngine, aObserver )
+    {
+    }
+
+
+CMemSpyViewMemoryTrackingAutoStartConfig::~CMemSpyViewMemoryTrackingAutoStartConfig()
+    {
+    iProcessUids.Close();
+    //
+    delete iParser;
+    delete iConverter;
+    //
+    delete iXMLFileNameInstallTime;
+    delete iXMLFileNameUserSupplied;
+    }
+
+
+void CMemSpyViewMemoryTrackingAutoStartConfig::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+
+    // We only convert from UTF-8 to UTF-16
+	iParser = CParser::NewL( KMemSpyProcessMemoryTrackerXmlFileMimeType, *this );
+    iConverter = CCnvCharacterSetConverter::NewL();
+    if  ( iConverter->PrepareToConvertToOrFromL( KCharacterSetIdentifierUtf8, iEngine.FsSession() ) == CCnvCharacterSetConverter::ENotAvailable )
+	    {
+		User::Leave(KErrNotFound);
+		}
+
+    // Search for standard files
+    FindXmlInstallTimeL();
+    FindXmlUserSuppliedL();
+
+    // Copy items to our own temporary list...
+    const RArray<TUid>& list = iEngine.HelperProcess().MemoryTrackingAutoStartProcessList();
+    for( TInt i=0; i<list.Count(); i++ )
+        {
+        User::LeaveIfError( iProcessUids.Append( list[ i ] ) );
+        }
+
+    // Reset the title
+    _LIT( KCustomTitle, "Process-Specific Memory Tracking" );
+    SetTitleL( KCustomTitle );
+    }
+
+
+TMemSpyViewType CMemSpyViewMemoryTrackingAutoStartConfig::ViewType() const
+    {
+    return EMemSpyViewTypeThreadInfoItemMemoryTrackingAutoStartConfig;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewMemoryTrackingAutoStartConfig::PrepareParentViewL()
+    {
+    CMemSpyViewMainMenu* parent = new(ELeave) CMemSpyViewMainMenu( iEngine, iObserver );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
+    CleanupStack::Pop( parent );
+
+    return parent;
+    }
+
+
+TBool CMemSpyViewMemoryTrackingAutoStartConfig::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = ETrue;
+    //
+    switch ( aCommand )
+        {
+    case EMemSpyCmdMemoryTrackingAutoStartItemAdd:
+        OnCmdItemAddL();
+        break;
+    case EMemSpyCmdMemoryTrackingAutoStartItemEdit:
+        OnCmdItemEditL();
+        break;
+    case EMemSpyCmdMemoryTrackingAutoStartItemDelete:
+        OnCmdItemDeleteL();
+        break;
+    case EMemSpyCmdMemoryTrackingAutoStartItemDeleteAll:
+        OnCmdItemDeleteAllL();
+        break;
+    case EMemSpyCmdMemoryTrackingAutoStartItemImport:
+        OnCmdItemImportL();
+        break;
+    default:
+        handled = CMemSpyViewBase::HandleCommandL( aCommand );
+        break;
+        }
+    //
+    return handled;
+    }
+
+
+void CMemSpyViewMemoryTrackingAutoStartConfig::HandleListBoxItemActionedL( TInt /*aIndex*/ )
+    {
+    OnCmdItemEditL();
+    }
+
+
+void CMemSpyViewMemoryTrackingAutoStartConfig::SetListBoxModelL()
+    {
+    CDesCArrayFlat* model = new(ELeave) CDesCArrayFlat(5);
+    CleanupStack::PushL( model );
+
+    TBuf<128> buf;
+    _LIT( KProcUidFormatSpec, "\t0x%08x" );
+
+    const TInt count = iProcessUids.Count();
+    for( TInt i=0; i<count; i++ )
+        {
+        const TUid procUid = iProcessUids[ i ];
+        //
+        buf.Format( KProcUidFormatSpec, procUid.iUid );
+        model->AppendL( buf );
+        }
+
+    // Set up list box
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( model );
+    listbox->Model()->SetOwnershipType( ELbmOwnsItemArray );
+    CleanupStack::Pop( model );
+    }
+
+
+void CMemSpyViewMemoryTrackingAutoStartConfig::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    iListBox->HandleItemAdditionL();
+    iListBox->DrawDeferred();
+    }
+
+
+void CMemSpyViewMemoryTrackingAutoStartConfig::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
+    {
+    if  ( aResourceId == MenuCascadeResourceId() )
+        {
+        const TInt count = iProcessUids.Count();
+        const TInt index = iListBox->CurrentItemIndex();
+
+        // We cannot edit an item if none exists
+        aMenuPane->SetItemDimmed( EMemSpyCmdMemoryTrackingAutoStartItemEdit, ( count == 0 || index < 0 || index > count - 1 ) );
+        aMenuPane->SetItemDimmed( EMemSpyCmdMemoryTrackingAutoStartItemDelete, ( count == 0 || index < 0 || index > count - 1 ) );
+        aMenuPane->SetItemDimmed( EMemSpyCmdMemoryTrackingAutoStartItemDeleteAll, ( count <= 1 || index > count - 1 ) );
+
+        // We can only import items if an XML file is available
+        const TBool xmlAvailable = ( iXMLFileNameInstallTime->Length() || iXMLFileNameUserSupplied->Length() );
+        aMenuPane->SetItemDimmed( EMemSpyCmdMemoryTrackingAutoStartItemImport, !xmlAvailable );
+        }
+    }
+
+
+TUint CMemSpyViewMemoryTrackingAutoStartConfig::MenuCascadeResourceId() const
+    {
+    return R_MEMSPY_MENUPANE_MEMORY_TRACKING_AUTOSTART;
+    }
+
+
+TInt CMemSpyViewMemoryTrackingAutoStartConfig::MenuCascadeCommandId() const
+    {
+    return EMemSpyCmdMemoryTrackingAutoStart;
+    }
+   
+    
+void CMemSpyViewMemoryTrackingAutoStartConfig::OnCmdItemAddL()
+    {
+    const TUid uid = ShowDialogL( KNullUid );
+    if ( uid != KNullUid )
+        {
+        User::LeaveIfError( iProcessUids.Append( uid ) );
+        SaveChangesL();
+        RefreshL();
+        iListBox->HandleItemAdditionL();
+        iListBox->DrawDeferred();
+        }
+    }
+
+
+void CMemSpyViewMemoryTrackingAutoStartConfig::OnCmdItemEditL()
+    {
+    const TInt index = iListBox->CurrentItemIndex();
+    if ( index >= 0 && index < iProcessUids.Count() )
+        {
+        TUid processUid = iProcessUids[ index ];
+        processUid = ShowDialogL( processUid );
+        //
+        if ( processUid != KNullUid )
+            {
+            iProcessUids[ index ] = processUid;
+            SaveChangesL();
+            RefreshL();
+            iListBox->HandleItemAdditionL();
+            iListBox->DrawDeferred();
+            }
+        }
+    }
+
+
+void CMemSpyViewMemoryTrackingAutoStartConfig::OnCmdItemDeleteL()
+    {
+    const TInt index = iListBox->CurrentItemIndex();
+    if ( index >= 0 && index < iProcessUids.Count() )
+        {
+        iProcessUids.Remove( index );
+        SaveChangesL();
+        RefreshL();
+        iListBox->HandleItemRemovalL();
+        iListBox->DrawDeferred();
+        
+        const TInt newIndex = index - 1;
+        const TInt count = iProcessUids.Count();
+        if ( newIndex >=0 && newIndex < count )
+            {
+            iListBox->SetCurrentItemIndex( index );
+            }
+        }
+    }
+
+
+void CMemSpyViewMemoryTrackingAutoStartConfig::OnCmdItemDeleteAllL()
+    {
+    iProcessUids.Reset();
+    SaveChangesL();
+    RefreshL();
+    iListBox->HandleItemRemovalL();
+    iListBox->DrawDeferred();
+    }
+
+
+void CMemSpyViewMemoryTrackingAutoStartConfig::OnCmdItemImportL()
+    {
+    if  ( iXMLFileNameInstallTime->Length() )
+        {
+        CAknQueryDialog* importDialog = CAknQueryDialog::NewL();
+        if  ( importDialog->ExecuteLD( R_MEMSPY_MEMORY_TRACKING_IMPORT_FROM_INSTALLED_XML_DIALOG ) )
+            {
+            TRAP_IGNORE( ParseL( *iXMLFileNameInstallTime ) );
+            }
+        }
+    if  ( iXMLFileNameUserSupplied->Length() )
+        {
+        CAknQueryDialog* importDialog = CAknQueryDialog::NewL();
+        if  ( importDialog->ExecuteLD( R_MEMSPY_MEMORY_TRACKING_IMPORT_FROM_USERDEFINED_XML_DIALOG ) )
+            {
+            TRAP_IGNORE( ParseL( *iXMLFileNameUserSupplied ) );
+            }
+        }
+
+    SaveChangesL();
+    RefreshL();
+    iListBox->HandleItemRemovalL();
+    iListBox->DrawDeferred();
+    }
+
+
+TUid CMemSpyViewMemoryTrackingAutoStartConfig::ShowDialogL( TUid aUid )
+    {
+    TUid uid = KNullUid;
+    //
+    _LIT( KProcessUidFormat, "%x" );
+    TBuf<128> buf;
+    buf.Format( KProcessUidFormat, aUid );
+    //
+    CAknTextQueryDialog* dialog = new(ELeave) CAknTextQueryDialog( buf );
+    const TBool dialogActioned = ( dialog->ExecuteLD( R_MEMSPY_MEMORY_TRACKING_PROCESS_UID_DIALOG ) );
+    //
+    if ( dialogActioned )
+        {
+        // Validate the text
+        uid = ValidateProcessUid( buf );
+        }
+    //
+    return uid;
+    }
+
+
+void CMemSpyViewMemoryTrackingAutoStartConfig::SaveChangesL()
+    {
+    iEngine.HelperProcess().SetMemoryTrackingAutoStartProcessListL( iProcessUids );
+    Settings().StoreSettingsL();
+    }
+
+
+TUid CMemSpyViewMemoryTrackingAutoStartConfig::ValidateProcessUid( const TDesC& aUid )
+    {
+    TUid ret = KNullUid;
+    TBool isValid = ETrue;
+    //
+    const TInt length = aUid.Length();
+    for( TInt i=0; i<length && isValid; i++ )
+        {
+        const TChar charValue = aUid[ i ];
+        //
+        switch( charValue )
+            {
+        case '0':
+        case '1':
+        case '2':
+        case '3':
+        case '4':
+        case '5':
+        case '6':
+        case '7':
+        case '8':
+        case '9':
+        case 'a':
+        case 'A':
+        case 'b':
+        case 'B':
+        case 'c':
+        case 'C':
+        case 'd':
+        case 'D':
+        case 'e':
+        case 'E':
+        case 'f':
+        case 'F':
+            break;
+        default:
+            isValid = EFalse;
+            break;
+            }
+        }
+    //
+    if ( isValid )
+        {
+        TUint32 val = 0;
+        TLex lexer( aUid );
+        if ( lexer.Val( val, EHex ) == KErrNone )
+            {
+            ret.iUid = val;
+            }
+        }
+    //
+    return ret;
+    }
+
+
+void CMemSpyViewMemoryTrackingAutoStartConfig::FindXmlInstallTimeL()
+    {
+    RFs& fsSession = iEngine.FsSession();
+    //
+    TFileName* fileName = new(ELeave) TFileName();
+    CleanupStack::PushL( fileName );
+    //
+    fsSession.PrivatePath( *fileName );
+    //
+    TFindFile findFile( fsSession );
+    if  ( findFile.FindByPath( KMemSpyProcessMemoryTrackingAutoStartConfigFileName, fileName ) == KErrNone )
+        {
+        iXMLFileNameInstallTime = findFile.File().AllocL();
+        }
+    else
+        {
+        iXMLFileNameInstallTime = KNullDesC().AllocL();
+        RDebug::Print( _L("CMemSpyViewMemoryTrackingAutoStartConfig::FindXmlInstallTimeL() - NO FILE FOUND") );
+        }
+    //
+    CleanupStack::PopAndDestroy( fileName );
+    }
+
+
+void CMemSpyViewMemoryTrackingAutoStartConfig::FindXmlUserSuppliedL()
+    {
+    TFindFile findFile( iEngine.FsSession() );
+    if  ( findFile.FindByPath( KMemSpyProcessMemoryTrackingAutoStartConfigFileName, &KMemSpyProcessMemoryTrackingAutoStartConfigSearchPath ) == KErrNone )
+        {
+        iXMLFileNameUserSupplied = findFile.File().AllocL();
+        }
+    else
+        {
+        iXMLFileNameUserSupplied = KNullDesC().AllocL();
+        RDebug::Print( _L("CMemSpyViewMemoryTrackingAutoStartConfig::FindXmlUserSuppliedL() - NO FILE FOUND") );
+        }
+    }
+
+
+void CMemSpyViewMemoryTrackingAutoStartConfig::ParseL( const TDesC& aFileName )
+    {
+	Xml::ParseL( *iParser, iEngine.FsSession(), aFileName );
+    //
+    const TInt error = iParserErrorCode;
+    iParserErrorCode = KErrNone;
+    //
+	User::LeaveIfError( error );
+    }
+
+
+void CMemSpyViewMemoryTrackingAutoStartConfig::OnSectionProcessL( const RAttributeArray& aAttributes )
+    {
+    TUid uid = KNullUid;
+    TBool gotSID = EFalse;
+    //
+    const TInt count = aAttributes.Count();
+	for( TInt i=0; i<count; i++ )
+		{
+		const TPtrC8 attrib( aAttributes[ i ].Attribute().LocalName().DesC() );
+		const TPtrC8 value( aAttributes[ i ].Value().DesC() );
+        //
+		if  ( attrib.CompareF( KMemSpyXmlSpec_EntryProcess_SID ) == 0 )
+			{
+            if  ( gotSID )
+                {
+                User::LeaveIfError( KErrCorrupt );
+                }
+            else
+                {
+                if  ( value.Length() >= 8 )
+                    {
+                    TRadix radix = EDecimal;
+                    TPtrC8 pValue( value );
+                    //
+                    if  ( value.Length() == 10 && value.Left( 2 ) == KMemSpyXmlSpec_HexPrefix )
+                        {
+                        pValue.Set( value.Mid( 2 ) );
+                        radix = EHex;
+                        }
+                    //
+                    TUint32 uidVal = 0;
+                    TLex8 lexer( pValue );
+                    const TInt err = lexer.Val( uidVal, radix );
+                    User::LeaveIfError( err );
+                    uid.iUid = uidVal;
+                    gotSID = ETrue;
+                    }
+                }
+			}
+        }
+    //
+    if  ( gotSID )
+        {
+        User::LeaveIfError( iProcessUids.Append( uid ) );
+        }
+    else
+        {
+        User::Leave( KErrCorrupt );
+        }
+    }
+
+
+void CMemSpyViewMemoryTrackingAutoStartConfig::OnStartDocumentL( const RDocumentParameters& /*aDocParam*/, TInt aErrorCode )
+    {
+    User::LeaveIfError( aErrorCode );
+    }
+
+
+void CMemSpyViewMemoryTrackingAutoStartConfig::OnEndDocumentL( TInt aErrorCode )
+    {
+    User::LeaveIfError( aErrorCode );
+    }
+
+
+void CMemSpyViewMemoryTrackingAutoStartConfig::OnStartElementL( const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aErrorCode )
+    {
+    User::LeaveIfError( aErrorCode );
+    //
+	const TPtrC8 name( aElement.LocalName().DesC() );
+    //
+    if  ( name.CompareF( KMemSpyXmlSpec_MasterSection ) == 0 )
+		{
+		iSeenMasterSection = ETrue;
+		}
+    else if ( iSeenMasterSection && name.CompareF( KMemSpyXmlSpec_EntryProcess ) == 0 )
+        {
+        OnSectionProcessL( aAttributes );
+        }
+    }
+
+
+void CMemSpyViewMemoryTrackingAutoStartConfig::OnEndElementL( const RTagInfo& /*aElement*/, TInt aErrorCode )
+    {
+    User::LeaveIfError( aErrorCode );
+    }
+
+
+void CMemSpyViewMemoryTrackingAutoStartConfig::OnContentL( const TDesC8& /*aBytes*/, TInt aErrorCode )
+    {
+    User::LeaveIfError( aErrorCode );
+    }
+
+
+void CMemSpyViewMemoryTrackingAutoStartConfig::OnStartPrefixMappingL( const RString& /*aPrefix*/, const RString& /*aUri*/, TInt aErrorCode )
+    {
+    User::LeaveIfError( aErrorCode );
+    }
+
+
+void CMemSpyViewMemoryTrackingAutoStartConfig::OnEndPrefixMappingL( const RString& /*aPrefix*/, TInt aErrorCode )
+    {
+    User::LeaveIfError( aErrorCode );
+    }
+
+
+void CMemSpyViewMemoryTrackingAutoStartConfig::OnIgnorableWhiteSpaceL( const TDesC8& /*aBytes*/, TInt aErrorCode )
+    {
+    User::LeaveIfError( aErrorCode );
+    }
+
+
+void CMemSpyViewMemoryTrackingAutoStartConfig::OnSkippedEntityL( const RString& /*aName*/, TInt aErrorCode )
+    {
+    User::LeaveIfError( aErrorCode );
+    }
+
+
+void CMemSpyViewMemoryTrackingAutoStartConfig::OnProcessingInstructionL( const TDesC8& /*aTarget*/, const TDesC8& /*aData*/, TInt aErrorCode )
+    {
+    User::LeaveIfError( aErrorCode );
+    }
+
+
+void CMemSpyViewMemoryTrackingAutoStartConfig::OnError( TInt aErrorCode )
+    {
+    iParserErrorCode = aErrorCode;
+    }
+
+
+TAny* CMemSpyViewMemoryTrackingAutoStartConfig::GetExtendedInterface( const TInt32 /*aUid*/ )
+    {
+    return NULL;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewOpenFiles.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,274 @@
+/*
+* 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 "MemSpyViewOpenFiles.h"
+
+// System includes
+#include <AknIconArray.h>
+#include <eikdef.h>
+#include <eikclbd.h>
+#include <aknconsts.h>
+#include <gulicon.h>
+#include <avkon.mbg>
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyenginehelperprocess.h>
+
+// User includes
+#include "MemSpyUiUtils.h"
+#include "MemSpyViewThreads.h"
+#include "MemSpyViewMainMenu.h"
+#include "MemSpyContainerObserver.h"
+
+
+
+
+CMemSpyViewOpenFiles::CMemSpyViewOpenFiles( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
+:   CMemSpyViewBase( aEngine, aObserver )
+    {
+    }
+
+
+CMemSpyViewOpenFiles::~CMemSpyViewOpenFiles()
+    {
+    iThreadIds.Close();
+    iFileNames.Close();
+    }
+
+
+void CMemSpyViewOpenFiles::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    _LIT( KTitle, "Open Files" );
+    SetTitleL( KTitle );
+    //
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+    }
+
+
+CEikListBox* CMemSpyViewOpenFiles::ConstructListBoxL()
+    {
+    delete iListBox;
+    iListBox = NULL;
+    CAknDoubleGraphicStyleListBox* listbox = new (ELeave) CAknDoubleGraphicStyleListBox();
+    iListBox = listbox;
+    //
+    listbox->ConstructL( this, EAknListBoxSelectionList | EAknListBoxLoopScrolling );
+    listbox->SetContainerWindowL( *this );
+    listbox->CreateScrollBarFrameL( ETrue );
+    SetListBoxModelL();
+    listbox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
+    listbox->SetListBoxObserver( this );
+    listbox->SetObserver( this );
+
+    // Create icon array
+    CAknIconArray* iconArray = new (ELeave) CAknIconArray(1);
+    CleanupStack::PushL( iconArray );
+
+    // Create bitmap
+    CFbsBitmap* bitmap = new(ELeave) CFbsBitmap();
+    CleanupStack::PushL( bitmap );
+    const TInt error1 = bitmap->Create( TSize(10,10), EColor16M );
+    User::LeaveIfError( error1 );
+
+    // Create mask
+    CFbsBitmap* mask = new(ELeave) CFbsBitmap();
+    CleanupStack::PushL( mask );
+    const TInt error2 = mask->Create( TSize(10,10), EColor16M );
+    User::LeaveIfError( error2 );
+
+    // Create icon & transfer bitmap
+    CGulIcon* icon = CGulIcon::NewL( bitmap, mask );
+    CleanupStack::Pop( 2, bitmap );
+    CleanupStack::PushL( icon );
+
+    // Transfer icon to array
+    iconArray->AppendL( icon );
+    CleanupStack::Pop( icon );
+    
+    // Give icon array to listbox
+    static_cast<CEikFormattedCellListBox*>(iListBox)->ItemDrawer()->FormattedCellData()->SetIconArrayL(iconArray);
+    CleanupStack::Pop( iconArray );
+    //
+    return listbox;
+    }
+
+
+void CMemSpyViewOpenFiles::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewOpenFiles::ViewType() const
+    {
+    return EMemSpyViewTypeOpenFiles;
+    }
+
+
+TBool CMemSpyViewOpenFiles::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = ETrue;
+    //
+    switch ( aCommand )
+        {
+	case EMemSpyCmdToolsListOpenFiles:
+        OnCmdListOpenFilesL();
+        break;
+
+    default:
+        handled = CMemSpyViewBase::HandleCommandL( aCommand );
+        break;
+        }
+    //
+    return handled;
+    }
+
+
+void CMemSpyViewOpenFiles::OnCmdListOpenFilesL()
+    {
+    iEngine.ListOpenFilesL();
+    }
+
+
+CMemSpyViewBase* CMemSpyViewOpenFiles::PrepareParentViewL()
+    {
+    CMemSpyViewMainMenu* parent = new(ELeave) CMemSpyViewMainMenu( iEngine, iObserver );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewOpenFiles::PrepareChildViewL()
+    {
+    CMemSpyViewBase* child = NULL;
+
+    // First, try to find the selected thread
+    if  ( iActionedThreadId )
+        {
+        // Try to create a view of the thread in question
+        CMemSpyProcess* process = NULL;
+        CMemSpyThread* thread = NULL;
+        const TInt error = iEngine.Container().ProcessAndThreadByThreadId( *iActionedThreadId, process, thread );
+        if  ( error == KErrNone && thread != NULL )
+            {
+            child = new(ELeave) CMemSpyViewThreads( iEngine, iObserver, thread->Process() );
+            CleanupStack::PushL( child );
+            child->ConstructL( Rect(), *Parent(), thread );
+            CleanupStack::Pop( child );
+            }
+        }
+    //
+    return child;
+    }
+
+
+void CMemSpyViewOpenFiles::SetListBoxModelL()
+    {
+    _LIT(KLineFormatSpec, "%d\t%S\t%S %S");
+
+    CDesCArrayFlat* model = new(ELeave) CDesCArrayFlat(5);
+    CleanupStack::PushL( model );
+
+    TBuf<KMaxFullName + 50> item;
+    TMemSpySizeText valueBuf;
+    TBuf<64> timeBuf;
+
+    iFileNames.Reset();
+    iThreadIds.Reset();
+    iActionedThreadId = NULL;
+
+    RFs& fsSession = iCoeEnv->FsSession();
+    TOpenFileScan scanner( fsSession );
+
+    CFileList* list = NULL;
+    scanner.NextL( list );
+
+    TIdentityRelation<TEntry> comparer( CompareTEntryObjects );
+
+    while( list != NULL )
+        {
+        CleanupStack::PushL( list );
+    
+        const TInt entryCount = list->Count();
+        for(TInt i=0; i<entryCount; i++)
+            {
+            const TEntry& entry = (*list)[ i ];
+
+            // Check for duplicates
+            const TInt foundIndex = iFileNames.Find( entry, comparer );
+            if  ( foundIndex == KErrNotFound )
+                {
+                // Get time and size format strings
+                valueBuf = MemSpyUiUtils::FormatSizeText( entry.iSize );
+                MemSpyUiUtils::FormatTimeL( timeBuf, entry.iModified );
+
+                // Get just file name
+                TParsePtrC parser( entry.iName );
+                const TPtrC pJustName( parser.NameAndExt() );
+
+                // Create item 
+                item.Format( KLineFormatSpec, 0, &pJustName, &valueBuf, &timeBuf );
+                model->AppendL( item );
+                iThreadIds.AppendL( scanner.ThreadId() );
+                iFileNames.AppendL( entry );
+                }
+            }
+
+        CleanupStack::PopAndDestroy( list );
+        list = NULL;
+        scanner.NextL( list );
+        }
+
+    // Set up list box
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( model );
+    listbox->Model()->SetOwnershipType( ELbmOwnsItemArray );
+    CleanupStack::Pop( model );
+    }
+
+
+void CMemSpyViewOpenFiles::HandleListBoxItemActionedL( TInt aCurrentIndex )
+    {
+    if  ( aCurrentIndex >= 0 && aCurrentIndex < iThreadIds.Count() )
+        {
+        iActionedThreadId = &iThreadIds[ aCurrentIndex ];
+        }
+    else
+        {
+        iActionedThreadId = NULL;
+        }
+
+    // Notify observer about an item being 'fired'
+    ReportEventL( MMemSpyViewObserver::EEventItemActioned );
+    }
+
+
+TBool CMemSpyViewOpenFiles::CompareTEntryObjects( const TEntry& aLeft, const TEntry& aRight )
+    {
+    return ( aLeft.iName.CompareF( aRight.iName ) == 0 );
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewProcesses.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,513 @@
+/*
+* 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 "MemSpyViewProcesses.h"
+
+// System includes
+#include <aknsfld.h>
+#include <AknQueryDialog.h>
+#include <memspyui.rsg>
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyenginehelperprocess.h>
+
+// User includes
+#include "MemSpyViewThreads.h"
+#include "MemSpyViewMainMenu.h"
+#include "MemSpyContainerObserver.h"
+
+// Constants
+const TInt KMemSpyMaxSearchTextLength = 30;
+const TInt KMemSpyMaxSearchTextLengthWithWildcards = KMemSpyMaxSearchTextLength + 4;
+
+
+
+CMemSpyViewProcesses::CMemSpyViewProcesses( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
+:   CMemSpyViewBase( aEngine, aObserver )
+    {
+    }
+
+
+CMemSpyViewProcesses::CMemSpyViewProcesses( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyProcess& aProcess )
+:   CMemSpyViewBase( aEngine, aObserver ), iCurrentProcess( &aProcess )
+    {
+    iCurrentProcess->Open();
+    }
+
+
+CMemSpyViewProcesses::~CMemSpyViewProcesses()
+    {
+    if  ( iCurrentProcess )
+        {
+        iCurrentProcess->Close();
+        }
+    //
+    delete iSearchField;
+    delete iMatcherBuffer;
+    }
+
+
+void CMemSpyViewProcesses::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    _LIT( KTitle, "Processes\n& Threads" );
+    SetTitleL( KTitle );
+    //
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+    //
+    iMatcherBuffer = HBufC::NewL( KMemSpyMaxSearchTextLengthWithWildcards );
+    //
+    iSearchField = CAknSearchField::NewL( *this, CAknSearchField::ESearch, NULL, KMemSpyMaxSearchTextLength );
+    iSearchField->SetObserver( this );
+    iSearchField->SetFocus( ETrue );
+    iSearchField->SetComponentsToInheritVisibility( ETrue );
+    //
+    CMemSpyEngineObjectContainer& container = iEngine.Container();
+    if  ( aSelectionRune )
+        {
+        CMemSpyProcess* selectedItem = reinterpret_cast< CMemSpyProcess* >( aSelectionRune );
+        const TInt index = container.ProcessIndexById( selectedItem->Id() );
+        if  ( index >= 0 && index < iListBox->Model()->NumberOfItems() )
+            {
+            iListBox->SetCurrentItemIndex( index );
+            HandleListBoxItemSelectedL( index );
+            }
+        }
+    else if ( container.Count() > 0 )
+        {
+        iListBox->SetCurrentItemIndex( 0 );
+        HandleListBoxItemSelectedL( 0 );
+        }
+    //
+    SizeChanged();
+    ActivateL();
+    }
+
+
+CMemSpyProcess& CMemSpyViewProcesses::CurrentProcess() const
+    {
+    __ASSERT_ALWAYS( iCurrentProcess != NULL, User::Invariant() );
+    return *iCurrentProcess;
+    }
+
+
+void CMemSpyViewProcesses::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewProcesses::ViewType() const
+    {
+    return EMemSpyViewTypeProcesses;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewProcesses::PrepareParentViewL()
+    {
+    CMemSpyViewMainMenu* parent = new(ELeave) CMemSpyViewMainMenu( iEngine, iObserver );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewProcesses::PrepareChildViewL()
+    {
+    CMemSpyViewThreads* child = new(ELeave) CMemSpyViewThreads( iEngine, iObserver, *iCurrentProcess );
+    CleanupStack::PushL( child );
+    child->ConstructL( Rect(), *Parent() );
+    CleanupStack::Pop( child );
+    return child;
+    }
+
+
+void CMemSpyViewProcesses::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
+    {
+    if  ( aResourceId == MenuCascadeResourceId() )
+        {
+        CMemSpyProcess& process = CurrentProcess();
+        const TBool hide = ( iEngine.Container().Count() == 0 ) || process.IsDead();
+        //
+        aMenuPane->SetItemDimmed( EMemSpyCmdProcessInfo, hide );
+        aMenuPane->SetItemDimmed( EMemSpyCmdProcessEnd, hide );
+        }
+    }
+
+
+TBool CMemSpyViewProcesses::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = ETrue;
+    //
+    switch ( aCommand )
+        {
+    // Sorting
+    case EMemSpyCmdProcessSortById:
+        OnCmdSortByIdL();
+		break;
+    case EMemSpyCmdProcessSortByName:
+        OnCmdSortByNameL();
+		break;
+    case EMemSpyCmdProcessSortByThreadCount:
+        OnCmdSortByThreadCountL();
+		break;
+    case EMemSpyCmdProcessSortByCodeSegs:
+        OnCmdSortByCodeSegsL();
+		break;
+    case EMemSpyCmdProcessSortByHeapUsage:
+        OnCmdSortByHeapUsageL();
+		break;
+    case EMemSpyCmdProcessSortByStackUsage:
+        OnCmdSortByStackUsageL();
+		break;
+    // End
+    case EMemSpyCmdProcessEndTerminate:
+        OnCmdEndTerminateL();
+		break;
+    case EMemSpyCmdProcessEndKill:
+        OnCmdEndKillL();
+		break;
+    case EMemSpyCmdProcessEndPanic:
+        OnCmdEndPanicL();
+		break;
+    // Info
+    case EMemSpyCmdProcessInfoSummary:
+        OnCmdInfoSummaryL();
+		break;
+    case EMemSpyCmdProcessInfoHandles:
+        OnCmdInfoHandlesL();
+        break;
+
+    default:
+        handled = CMemSpyViewBase::HandleCommandL( aCommand );
+        break;
+        }
+    //
+    return handled;
+    }
+
+
+void CMemSpyViewProcesses::OnCmdSortByIdL()
+    {
+    iEngine.Container().SortById();
+    RefreshL();
+    }
+
+
+void CMemSpyViewProcesses::OnCmdSortByNameL()
+    {
+    iEngine.Container().SortByName();
+    RefreshL();
+    }
+
+
+void CMemSpyViewProcesses::OnCmdSortByThreadCountL()
+    {
+    iEngine.Container().SortByThreadCount();
+    RefreshL();
+    }
+
+
+void CMemSpyViewProcesses::OnCmdSortByCodeSegsL()
+    {
+    iEngine.Container().SortByCodeSegs();
+    RefreshL();
+    }
+
+
+void CMemSpyViewProcesses::OnCmdSortByHeapUsageL()
+    {
+    iEngine.Container().SortByHeapUsage();
+    RefreshL();
+    }
+
+
+void CMemSpyViewProcesses::OnCmdSortByStackUsageL()
+    {
+    iEngine.Container().SortByStackUsage();
+    RefreshL();
+    }
+
+
+void CMemSpyViewProcesses::OnCmdInfoSummaryL()
+    {
+    CMemSpyProcess& process = CurrentProcess();
+    iEngine.HelperProcess().OutputProcessInfoL( process );
+    }
+
+
+void CMemSpyViewProcesses::OnCmdInfoHandlesL()
+    {
+    CMemSpyProcess& process = CurrentProcess();
+    //
+    const TInt threadCount = process.Count();
+    for( TInt i=0; i<threadCount; i++ )
+        {
+        CMemSpyThread& thread = process.At( i );
+        thread.InfoContainerForceSyncronousConstructionL().PrintL();
+        }
+    }
+
+
+void CMemSpyViewProcesses::OnCmdEndTerminateL()
+    {
+    TBool doTerminate = ETrue;
+    CMemSpyProcess& process = CurrentProcess();
+    //
+    if  ( process.IsSystemPermanent() || process.IsSystemCritical() )
+        {
+        CAknQueryDialog* importDialog = CAknQueryDialog::NewL();
+        doTerminate = ( importDialog->ExecuteLD( R_MEMSPY_PANIC_SYSTEM_CRITICAL_THREAD_OR_PROCESS ) );
+        }
+    //
+    if  ( doTerminate )
+        {
+        process.TerminateL();
+        RefreshL();
+        }
+    }
+
+
+void CMemSpyViewProcesses::OnCmdEndPanicL()
+    {
+    TBool doTerminate = ETrue;
+    CMemSpyProcess& process = CurrentProcess();
+    //
+    if  ( process.IsSystemPermanent() || process.IsSystemCritical() )
+        {
+        CAknQueryDialog* importDialog = CAknQueryDialog::NewL();
+        doTerminate = ( importDialog->ExecuteLD( R_MEMSPY_PANIC_SYSTEM_CRITICAL_THREAD_OR_PROCESS ) );
+        }
+    //
+    if  ( doTerminate )
+        {
+        process.PanicL();
+        RefreshL();
+        }
+    }
+
+
+void CMemSpyViewProcesses::OnCmdEndKillL()
+    {
+    TBool doTerminate = ETrue;
+    CMemSpyProcess& process = CurrentProcess();
+    //
+    if  ( process.IsSystemPermanent() || process.IsSystemCritical() )
+        {
+        CAknQueryDialog* importDialog = CAknQueryDialog::NewL();
+        doTerminate = ( importDialog->ExecuteLD( R_MEMSPY_PANIC_SYSTEM_CRITICAL_THREAD_OR_PROCESS ) );
+        }
+    //
+    if  ( doTerminate )
+        {
+        process.KillL();
+        RefreshL();
+        }
+    }
+
+
+
+
+void CMemSpyViewProcesses::SetListBoxModelL()
+    {
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( &iEngine.Container() );
+    listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+
+
+void CMemSpyViewProcesses::HandleListBoxItemActionedL( TInt /*aIndex*/ )
+    {
+    // Notify observer about an item being 'fired'
+    ReportEventL( MMemSpyViewObserver::EEventItemActioned );
+    }
+
+
+void CMemSpyViewProcesses::HandleListBoxItemSelectedL( TInt aIndex )
+    {
+    if  ( iCurrentProcess )
+        {
+        iCurrentProcess->Close();
+        }
+
+    // Obtain the process that corresponds to the selected item
+    CMemSpyEngineObjectContainer& container = iEngine.Container();
+    CMemSpyProcess& process = container.At( aIndex );
+    iCurrentProcess = &process;
+    iCurrentProcess->Open();
+
+    // Notify observer about item selection
+    ReportEventL( MMemSpyViewObserver::EEventItemSelected );
+    }
+
+
+void CMemSpyViewProcesses::SizeChanged()
+    {
+    const TRect rect( Rect() );
+    
+    if  ( iListBox && iSearchField )
+        {
+        const TInt lafIndex_H = 1;
+        AknLayoutUtils::LayoutControl( iListBox, rect, AknLayout::list_gen_pane( lafIndex_H ) );
+        AknLayoutUtils::LayoutControl( iSearchField, rect, AknLayout::find_pane() );
+        }
+    else
+        {
+        CMemSpyViewBase::SizeChanged();
+        }
+
+/*
+    // Search field
+    TSize searchFieldSize( iSearchField->MinimumSize() ); // BALLS: search field doesn't implement minimum size correctly?!?!?
+    searchFieldSize.SetWidth( rect.Width() );
+    const TRect searchFieldRect( TPoint( rect.iTl.iX, rect.iBr.iY ), searchFieldSize );
+    iSearchField->SetRect( searchFieldRect );
+
+    // Listbox
+    TSize listBoxSize( rect.Size() - TSize( 0, searchFieldSize.iHeight ) );
+    iListBox->SetRect( rect.iTl, listBoxSize );
+*/
+    }
+
+
+TInt CMemSpyViewProcesses::CountComponentControls() const
+    {
+    TInt count = 0;
+    //
+    if  ( iListBox != NULL )
+        {
+        ++count;
+        }
+    if  ( iSearchField != NULL )
+        {
+        ++count;
+        }
+    //
+    return count;
+    }
+
+
+CCoeControl* CMemSpyViewProcesses::ComponentControl( TInt aIndex ) const
+    {
+    CCoeControl* ret = iListBox;
+    //
+    if  ( aIndex == 1 )
+        {
+        ret = iSearchField;
+        }
+    //
+    return ret;
+    }
+
+
+TKeyResponse CMemSpyViewProcesses::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
+    {
+    TKeyResponse resp = EKeyWasNotConsumed;
+    //
+    if  ( aType == EEventKey )
+        {
+        switch( aKeyEvent.iCode )
+            {
+        case EKeyUpArrow:
+        case EKeyDownArrow:
+        case EKeyEnter:
+        case EKeyOK:
+            if  ( iListBox )
+                {
+                resp = iListBox->OfferKeyEventL( aKeyEvent, aType );
+                }
+            break;
+        default:
+            break;
+            }
+        //
+        if  ( resp == EKeyWasNotConsumed )
+            {
+            // Do we need to show the find field?
+            resp = iSearchField->OfferKeyEventL( aKeyEvent, aType );
+            }
+        }
+    //
+    return resp;
+    }
+
+
+void CMemSpyViewProcesses::HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType )
+    {
+    CMemSpyViewBase::HandleControlEventL( aControl, aEventType );
+    //
+    if  ( aEventType == MCoeControlObserver::EEventStateChanged )
+        {
+        if  ( aControl == iSearchField )
+            {
+            SelectListBoxItemByFindTextL();
+            }
+        }
+    }
+
+
+void CMemSpyViewProcesses::FocusChanged( TDrawNow /*aDrawNow*/ )
+    {
+    if  ( iListBox )
+        {
+        iListBox->SetFocus( IsFocused() );
+        }
+    if  ( iSearchField )
+        {
+        iSearchField->SetFocus( IsFocused() );
+        }
+    }
+
+
+void CMemSpyViewProcesses::SelectListBoxItemByFindTextL()
+    {
+    _LIT( KMemSpyWildcardCharacter, "*" );
+    
+    TPtr pBuffer( iMatcherBuffer->Des() );
+    iSearchField->GetSearchText( pBuffer );
+    //pBuffer.Insert( 0, KMemSpyWildcardCharacter );
+    pBuffer.Append( KMemSpyWildcardCharacter );
+    
+    CMemSpyEngineObjectContainer& container = iEngine.Container();
+    const TInt count = container.Count();
+    //
+    TInt index = 0;
+    while( index < count )
+        {
+        CMemSpyProcess& process = container.At( index );
+        const TPtrC processName( process.Name() );
+        //
+        if  ( processName.MatchF( pBuffer ) >= 0 )
+            {
+            HandleListBoxItemSelectedL( index );
+            iListBox->ScrollToMakeItemVisible( index );
+            iListBox->SetCurrentItemIndexAndDraw( index );
+            return;
+            }
+            
+        ++index;
+        }
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewRAMInfo.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,211 @@
+/*
+* 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 "MemSpyViewRAMInfo.h"
+
+// System includes
+#include <hal.h>
+#include <aknnotedialog.h>
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyenginehelperprocess.h>
+#include <memspy/engine/memspyenginehelperram.h>
+#include <memspy/engine/memspyengineutils.h>
+
+// User includes
+#include "MemSpyUiUtils.h"
+#include "MemSpyViewMainMenu.h"
+#include "MemSpyContainerObserver.h"
+
+
+
+
+
+
+CMemSpyViewRAMInfo::CMemSpyViewRAMInfo( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
+:   CMemSpyViewBase( aEngine, aObserver )
+    {
+    }
+
+
+void CMemSpyViewRAMInfo::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    _LIT( KTitle, "RAM Info" );
+    SetTitleL( KTitle );
+    //
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+    }
+
+
+void CMemSpyViewRAMInfo::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewRAMInfo::ViewType() const
+    {
+    return EMemSpyViewTypeRAMInfo;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewRAMInfo::PrepareParentViewL()
+    {
+    CMemSpyViewMainMenu* parent = new(ELeave) CMemSpyViewMainMenu( iEngine, iObserver );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewRAMInfo::PrepareChildViewL()
+    {
+    CMemSpyViewBase* child = NULL;
+    return child;
+    }
+
+
+void CMemSpyViewRAMInfo::SetListBoxModelL()
+    {
+    CDesCArrayFlat* model = new(ELeave) CDesCArrayFlat(5);
+    CleanupStack::PushL( model );
+
+    TBuf<KMaxFullName + 1> item;
+
+    TInt value;
+    TMemSpySizeText size;
+    TMemoryInfoV1Buf memInfoBuf;
+    UserHal::MemoryInfo( memInfoBuf );
+    const TMemoryInfoV1 memInfo( memInfoBuf() );
+
+    // 1st item = Total RAM
+    _LIT(KItem1Format, "\tTotal RAM\t\t%S");
+    size = MemSpyUiUtils::FormatSizeText( memInfo.iTotalRamInBytes );
+    item.Format( KItem1Format, &size );
+    model->AppendL( item );
+
+    // 2nd item = Max free RAM
+    _LIT(KItem2Format, "\tMax Free RAM\t\t%S");
+    size = MemSpyUiUtils::FormatSizeText( memInfo.iMaxFreeRamInBytes );
+    item.Format( KItem2Format, &size );
+    model->AppendL( item );
+
+    // 3rd item = Free RAM
+    _LIT(KItem3Format, "\tFree RAM\t\t%S (%S)");
+    const TMemSpyPercentText freeRamPercentage( MemSpyEngineUtils::FormatPercentage( TReal( memInfo.iTotalRamInBytes ), TReal( memInfo.iFreeRamInBytes ) ) );
+    size = MemSpyUiUtils::FormatSizeText( memInfo.iFreeRamInBytes );
+    item.Format( KItem3Format, &size, &freeRamPercentage );
+    model->AppendL( item );
+
+    // 4th item = RAM disk info
+    _LIT(KItem4Format, "\tRAM Disk Size\t\t%S");
+    size = MemSpyUiUtils::FormatSizeText( memInfo.iInternalDiskRamInBytes );
+    item.Format( KItem4Format, &size );
+    model->AppendL( item );
+
+    // 5th item = Max RAM disk size
+    _LIT(KItem5Format, "\tMax RAM Disk Size\t\t%S");
+    HAL::Get( HALData::EMaxRAMDriveSize, value );
+    size = MemSpyUiUtils::FormatSizeText( value );
+    item.Format( KItem5Format, &size );
+    model->AppendL( item );
+
+    // 6th item = RAM page size
+    _LIT(KItem6Format, "\tMemory Page Size\t\t%S");
+    HAL::Get( HALData::EMemoryPageSize, value );
+    size = MemSpyUiUtils::FormatSizeText( value );
+    item.Format( KItem6Format, &size );
+    model->AppendL( item );
+
+    // Set up list box
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( model );
+    listbox->Model()->SetOwnershipType( ELbmOwnsItemArray );
+    CleanupStack::Pop( model );
+    }
+
+
+TBool CMemSpyViewRAMInfo::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = ETrue;
+    //
+    if  ( iEngine.HelperRAM().IsAknIconCacheConfigurable() )
+        {
+        switch ( aCommand )
+            {
+        case EMemSpyCmdRAMAvkonIconCacheDisabled:
+            OnCmdSetIconCacheStatusL( EFalse );
+		    break;
+        case EMemSpyCmdRAMAvkonIconCacheEnabled:
+            OnCmdSetIconCacheStatusL( ETrue );
+		    break;
+
+        default:
+            handled = CMemSpyViewBase::HandleCommandL( aCommand );
+            break;
+            }
+        }
+    else
+        {
+        handled = CMemSpyViewBase::HandleCommandL( aCommand );
+        }
+    //
+    return handled;
+    }
+
+
+void CMemSpyViewRAMInfo::OnCmdSetIconCacheStatusL( TBool aEnabled )
+    {
+    ASSERT( iEngine.HelperRAM().IsAknIconCacheConfigurable() );
+    //
+    const TInt64 savedAmount = iEngine.HelperRAM().SetAknIconCacheStatusL( aEnabled );
+    if ( !aEnabled )
+        {
+        TBuf<128> buf;
+        //
+        if  ( savedAmount != 0 ) 
+            {
+            _LIT(KSavedAmountFormatBuffer, "Saved %S of RAM");
+            const TMemSpySizeText savedAmountString( MemSpyEngineUtils::FormatSizeText( savedAmount, 0, EFalse ) );
+            buf.Format( KSavedAmountFormatBuffer, &savedAmountString );
+            }
+        else
+            {
+            _LIT(KDidNotSaveAnyRAM, "Operation did not save any RAM");
+            buf.Copy( KDidNotSaveAnyRAM );
+            }
+
+        // Show dialog
+	    CAknNoteDialog* note = new( ELeave ) CAknNoteDialog( CAknNoteDialog::ENoTone );
+	    CleanupStack::PushL( note );
+	    note->SetTextWrapping( ETrue );
+	    note->PrepareLC( R_MEMSPY_RAM_MEMORY_DELTA_DIALOG );
+	    note->SetTextL( buf );
+	    CleanupStack::Pop( note );
+	    note->RunLD();
+        }
+    //
+    RefreshL();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewROMInfo.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,270 @@
+/*
+* 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 "MemSpyViewROMInfo.h"
+
+// System includes
+#include <hal.h>
+#ifdef __EPOC32__
+#include <e32rom.h>
+#endif
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyenginehelperprocess.h>
+
+// User includes
+#include "MemSpyUiUtils.h"
+#include "MemSpyViewMainMenu.h"
+#include "MemSpyContainerObserver.h"
+
+// Remap of E32 DP constants, needed so MemSpy can still build on v9.1
+enum TMemSpyDemandPagingKernelConfigFlags
+    {
+    EMemSpyKernelConfigPagingPolicyMask = 3<<5,
+    EMemSpyKernelConfigPagingPolicyNoPaging = 0<<5,
+    EMemSpyKernelConfigPagingPolicyAlwaysPage = 1<<5,
+    EMemSpyKernelConfigPagingPolicyDefaultUnpaged = 2<<5,
+    EMemSpyKernelConfigPagingPolicyDefaultPaged = 3<<5,
+    };
+
+
+
+CMemSpyViewROMInfo::CMemSpyViewROMInfo( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
+:   CMemSpyViewBase( aEngine, aObserver )
+    {
+    }
+
+
+void CMemSpyViewROMInfo::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    _LIT( KTitle, "ROM Info" );
+    SetTitleL( KTitle );
+    //
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+    }
+
+
+void CMemSpyViewROMInfo::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewROMInfo::ViewType() const
+    {
+    return EMemSpyViewTypeROMInfo;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewROMInfo::PrepareParentViewL()
+    {
+    CMemSpyViewMainMenu* parent = new(ELeave) CMemSpyViewMainMenu( iEngine, iObserver );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewROMInfo::PrepareChildViewL()
+    {
+    CMemSpyViewBase* child = NULL;
+    return child;
+    }
+
+
+void CMemSpyViewROMInfo::SetListBoxModelL()
+    {
+    CDesCArrayFlat* model = new(ELeave) CDesCArrayFlat(5);
+    CleanupStack::PushL( model );
+
+    TBuf<KMaxFullName + 1> item;
+
+    TInt value = 0;
+    TMemSpySizeText valueBuf;
+    TMemSpySizeText valueBuf2;
+    
+    // 1st item = Total RAM
+    _LIT(KItem1Format, "\tROM Size (HAL)\t\t%S");
+    HAL::Get( HALData::EMemoryROM, value );
+    valueBuf = MemSpyUiUtils::FormatSizeText( value );
+    item.Format( KItem1Format, &valueBuf );
+    model->AppendL( item );
+
+#ifdef __EPOC32__
+    TBuf<128> buf2;
+    _LIT( KTimeFormatSpecLocal, "%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B" );
+	const TUint main_start = UserSvr::RomHeaderAddress();
+    TRomHeader* romHeader = (TRomHeader*) main_start;
+
+    _LIT(KItem2Format, "\tROM Size (Header)\t\t%S");
+    valueBuf = MemSpyUiUtils::FormatSizeText( TInt64( romHeader->iRomSize ) );
+    item.Format( KItem2Format, &valueBuf );
+    model->AppendL( item );
+
+    _LIT(KItem2aFormat, "\tROM Page Size\t\t%S");
+    HAL::Get( HALData::EMemoryPageSize, value );
+    valueBuf = MemSpyUiUtils::FormatSizeText( value );
+    item.Format( KItem2aFormat, &valueBuf );
+    model->AppendL( item );
+
+    _LIT(KItem10Format, "\tVersion\t\tv%2d.%02d.%06d");
+    item.Format( KItem10Format, romHeader->iVersion.iMajor, romHeader->iVersion.iMinor, romHeader->iVersion.iBuild );
+    model->AppendL( item );
+
+    _LIT(KItem3Format, "\tTimestamp\t\t%S");
+    TTime time( romHeader->iTime );
+    time.FormatL( buf2, KTimeFormatSpecLocal );
+    item.Format( KItem3Format, &buf2 );
+    model->AppendL( item );
+
+    _LIT(KItem4Format, "\tAddress Range\t\t%S - %S");
+    MemSpyUiUtils::FormatHex( valueBuf, romHeader->iRomBase );
+    MemSpyUiUtils::FormatHex( valueBuf2, (romHeader->iRomBase + romHeader->iRomSize ));
+    item.Format( KItem4Format, &valueBuf, &valueBuf2 );
+    model->AppendL( item );
+
+    _LIT(KItem5Format, "\tPrimary File Address\t\t%S");
+    MemSpyUiUtils::FormatHex( valueBuf, romHeader->iPrimaryFile );
+    item.Format( KItem5Format, &valueBuf );
+    model->AppendL( item );
+
+    _LIT(KItem6Format, "\tSecondary File Address\t\t%S");
+    MemSpyUiUtils::FormatHex( valueBuf, romHeader->iSecondaryFile );
+    item.Format( KItem6Format, &valueBuf );
+    model->AppendL( item );
+
+    _LIT(KItem7Format, "\tChecksum\t\t%S");
+    MemSpyUiUtils::FormatHex( valueBuf, romHeader->iCheckSum );
+    item.Format( KItem7Format, &valueBuf );
+    model->AppendL( item );
+
+    _LIT(KItem8Format, "\tKernel Config Flags\t\t%S");
+    MemSpyUiUtils::FormatHex( valueBuf, romHeader->iKernelConfigFlags );
+    item.Format( KItem8Format, &valueBuf );
+    model->AppendL( item );
+
+    if  ( romHeader->iKernelConfigFlags & EKernelConfigIpcV1Available )
+        {
+        _LIT(KItem8aFormat, "\tIPC v1 Available\t\tYes");
+        item.Copy( KItem8aFormat );
+        model->AppendL( item );
+        }
+    if  ( romHeader->iKernelConfigFlags & EKernelConfigPlatSecEnforcement )
+        {
+        _LIT(KItem8bFormat, "\tPlatSec Enforcement\t\tYes");
+        item.Copy( KItem8bFormat );
+        model->AppendL( item );
+        }
+    if  ( romHeader->iKernelConfigFlags & EKernelConfigPlatSecDiagnostics )
+        {
+        _LIT(KItem8cFormat, "\tPlatSec Diagnostics\t\tYes");
+        item.Copy( KItem8cFormat );
+        model->AppendL( item );
+        }
+    if  ( romHeader->iKernelConfigFlags & EKernelConfigPlatSecProcessIsolation )
+        {
+        _LIT(KItem8dFormat, "\tPlatSec Process Isolation\t\tYes");
+        item.Copy( KItem8dFormat );
+        model->AppendL( item );
+        }
+    if  ( romHeader->iKernelConfigFlags & EKernelConfigPlatSecEnforceSysBin )
+        {
+        _LIT(KItem8eFormat, "\tEnforce \\Sys\\Bin\\\t\tYes");
+        item.Copy( KItem8eFormat );
+        model->AppendL( item );
+        }
+
+    const TUint32 pagingPolicy = ( romHeader->iKernelConfigFlags & EMemSpyKernelConfigPagingPolicyMask );
+#ifdef _DEBUG
+    RDebug::Printf( "pagingPolicy: %u (0x%08x)", pagingPolicy, pagingPolicy );
+#endif
+    _LIT(KItem8eFormat, "\tDemand Paging\t\t%S");
+    //
+    if  ( pagingPolicy & EMemSpyKernelConfigPagingPolicyNoPaging )
+        {
+        _LIT( KDemandPagingPolicyNoPaging, "No Paging" );
+        item.Format( KItem8eFormat, &KDemandPagingPolicyNoPaging );
+        }
+    else if ( pagingPolicy & EMemSpyKernelConfigPagingPolicyAlwaysPage )
+        {
+        _LIT( KDemandPagingPolicyAlwaysPage, "Always Paging" );
+        item.Format( KItem8eFormat, &KDemandPagingPolicyAlwaysPage);
+        }
+    else if ( pagingPolicy & EMemSpyKernelConfigPagingPolicyDefaultUnpaged )
+        {
+        _LIT( KDemandPagingPolicyDefaultUnpaged, "Default Unpaged" );
+        item.Format( KItem8eFormat, &KDemandPagingPolicyDefaultUnpaged);
+        }
+    else if ( pagingPolicy & EMemSpyKernelConfigPagingPolicyDefaultPaged )
+        {
+        _LIT( KDemandPagingPolicyDefaultPaged, "Default Paged" );
+        item.Format( KItem8eFormat, &KDemandPagingPolicyDefaultPaged );
+        }
+    //
+    model->AppendL( item );
+
+    _LIT(KItem9Format, "\tSection Header Address\t\t%S");
+    MemSpyUiUtils::FormatHex( valueBuf, romHeader->iRomSectionHeader );
+    item.Format( KItem9Format, &valueBuf );
+    model->AppendL( item );
+
+    _LIT(KItem11Format, "\tCompressed Size\t\t%S");
+    valueBuf = MemSpyUiUtils::FormatSizeText( TInt64( romHeader->iCompressedSize ) );
+    item.Format( KItem11Format, &valueBuf );
+    model->AppendL( item );
+
+    _LIT(KItem12Format, "\tUncompressed Size\t\t%S");
+    valueBuf = MemSpyUiUtils::FormatSizeText( TInt64( romHeader->iUncompressedSize ) );
+    item.Format( KItem12Format, &valueBuf );
+    model->AppendL( item );
+
+    _LIT(KItem13Format, "\tDisabled Caps. #1\t\t%S");
+    MemSpyUiUtils::FormatHex( valueBuf, romHeader->iDisabledCapabilities[0] );
+    item.Format( KItem13Format, &valueBuf );
+    model->AppendL( item );
+
+    _LIT(KItem14Format, "\tDisabled Caps. #2\t\t%S");
+    MemSpyUiUtils::FormatHex( valueBuf, romHeader->iDisabledCapabilities[1] );
+    item.Format( KItem14Format, &valueBuf );
+    model->AppendL( item );
+
+    for(TInt i=0; i<TRomHeader::KNumTraceMask; i++)
+        {
+        _LIT(KItem15Format, "\tTrace Mask #%d\t\t%S");
+        MemSpyUiUtils::FormatHex( valueBuf, romHeader->iTraceMask[i] );
+        item.Format( KItem15Format, i+1, &valueBuf );
+        model->AppendL( item );
+        }
+
+#endif
+
+    // Set up list box
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( model );
+    listbox->Model()->SetOwnershipType( ELbmOwnsItemArray );
+    CleanupStack::Pop( model );
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewServerList.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,227 @@
+/*
+* 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 "MemSpyViewServerList.h"
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyenginehelperprocess.h>
+#include <memspy/engine/memspyenginehelperheap.h>
+#include <memspy/engine/memspyenginehelperserver.h>
+
+// User includes
+#include "MemSpyUiUtils.h"
+#include "MemSpyViewMainMenu.h"
+#include "MemSpyViewThreads.h"
+#include "MemSpyContainerObserver.h"
+
+
+
+
+CMemSpyViewServerList::CMemSpyViewServerList( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
+:   CMemSpyViewBase( aEngine, aObserver )
+    {
+    }
+
+
+CMemSpyViewServerList::~CMemSpyViewServerList()
+    {
+    delete iList;
+    }
+
+
+void CMemSpyViewServerList::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    _LIT( KTitle, "Running Servers" );
+    SetTitleL( KTitle );
+    //
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+    }
+
+
+TBool CMemSpyViewServerList::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = ETrue;
+    //
+    switch ( aCommand )
+        {
+    case EMemSpyCmdServerListSortByName:
+        OnCmdServerListSortByNameL();
+        break;
+    case EMemSpyCmdServerListSortBySessionCount:
+        OnCmdServerListSortBySessionCountL();
+        break;
+    case EMemSpyCmdServerListOutputListCSV:
+        OnCmdServerListOutputSummaryL();
+        break;
+    case EMemSpyCmdServerListOutputListDetailed:
+        OnCmdServerListOutputDetailedL();
+        break;
+
+    default:
+        handled = CMemSpyViewBase::HandleCommandL( aCommand );
+        break;
+        }
+    //
+    return handled;
+    }
+
+
+void CMemSpyViewServerList::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewServerList::ViewType() const
+    {
+    return EMemSpyViewTypeServerList;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewServerList::PrepareParentViewL()
+    {
+    CMemSpyViewMainMenu* parent = new(ELeave) CMemSpyViewMainMenu( iEngine, iObserver );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewServerList::PrepareChildViewL()
+    {
+    CMemSpyViewBase* child = NULL;
+
+    // First, try to find the selected thread
+    if  ( iActionedItem )
+        {
+        // Try to create a view of the thread in question
+        CMemSpyProcess* process = NULL;
+        CMemSpyThread* thread = NULL;
+        //
+        const TInt error = iEngine.Container().ProcessAndThreadByThreadId( iActionedItem->Id(), process, thread );
+        //
+        if  ( error == KErrNone && thread != NULL )
+            {
+            child = new(ELeave) CMemSpyViewThreads( iEngine, iObserver, thread->Process() );
+            CleanupStack::PushL( child );
+            child->ConstructL( Rect(), *Parent(), thread );
+            CleanupStack::Pop( child );
+            }
+        }
+    //
+    return child;
+    }
+
+
+void CMemSpyViewServerList::SetListBoxModelL()
+    {
+    delete iList;
+    iList = NULL;
+    iList = iEngine.HelperServer().ServerListL();
+    //
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( iList );
+    listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+
+
+void CMemSpyViewServerList::HandleListBoxItemActionedL( TInt aCurrentIndex )
+    {
+    if  ( aCurrentIndex >= 0 && aCurrentIndex < iList->Count() )
+        {
+        const CMemSpyEngineServerEntry& serverInfo = iList->At( aCurrentIndex );
+        iActionedItem = &serverInfo;
+        }
+    else
+        {
+        iActionedItem = NULL;
+        }
+
+    // Notify observer about an item being 'fired'
+    ReportEventL( MMemSpyViewObserver::EEventItemActioned );
+    }
+
+
+void CMemSpyViewServerList::OnCmdServerListSortByNameL()
+    {
+    iList->SortByNameL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+void CMemSpyViewServerList::OnCmdServerListSortBySessionCountL()
+    {
+    iList->SortBySessionCountL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+void CMemSpyViewServerList::OnCmdServerListOutputSummaryL()
+    {
+    OnCmdServerListOutputGenericL( EFalse );
+    }
+
+
+void CMemSpyViewServerList::OnCmdServerListOutputDetailedL()
+    {
+    OnCmdServerListOutputGenericL( ETrue );
+    }
+
+
+void CMemSpyViewServerList::OnCmdServerListOutputGenericL( TBool aDetailed )
+    {
+    // Begin a new data stream
+    _LIT( KMemSpyContext, "Server List - " );
+    _LIT( KMemSpyFolder, "Servers" );
+    iEngine.Sink().DataStreamBeginL( KMemSpyContext, KMemSpyFolder );
+
+    // Set prefix for overall listing
+    iEngine.Sink().OutputPrefixSetLC( KMemSpyContext );
+
+    // Create header
+    CMemSpyEngineServerList::OutputDataColumnsL( iEngine, aDetailed );
+    
+    // List items
+    const TInt count = iList->Count();
+    for(TInt i=0; i<count; i++)
+        {
+        const CMemSpyEngineServerEntry& server = iList->At( i );
+        //
+        server.OutputDataL( iEngine.HelperServer(), aDetailed );
+        }
+
+    // Tidy up
+    CleanupStack::PopAndDestroy(); // prefix
+ 
+    // End data stream
+    iEngine.Sink().DataStreamEndL();
+    }
+
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewSystemConfig.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,883 @@
+/*
+* 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 "MemSpyViewSystemConfig.h"
+
+// System includes
+#include <hal.h>
+#include <bautils.h>
+#include <eikenv.h>
+#ifdef __EPOC32__
+#include <e32rom.h>
+#endif
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyenginehelperprocess.h>
+#include <memspy/engine/memspyenginehelperfilesystem.h>
+
+// User includes
+#include "MemSpyUiUtils.h"
+#include "MemSpyViewMainMenu.h"
+#include "MemSpyContainerObserver.h"
+
+// Literal constants
+_LIT( KMemSpyItemValueNotKnown, "Unknown" );
+
+
+
+CMemSpyViewSystemConfig::CMemSpyViewSystemConfig( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
+:   CMemSpyViewBase( aEngine, aObserver )
+    {
+    }
+
+
+CMemSpyViewSystemConfig::~CMemSpyViewSystemConfig()
+    {
+    delete iModel;
+    }
+
+
+void CMemSpyViewSystemConfig::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    _LIT( KTitle, "System Configuration" );
+    SetTitleL( KTitle );
+    //
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+    }
+
+
+void CMemSpyViewSystemConfig::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewSystemConfig::ViewType() const
+    {
+    return EMemSpyViewTypeSystemConfig;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewSystemConfig::PrepareParentViewL()
+    {
+    CMemSpyViewMainMenu* parent = new(ELeave) CMemSpyViewMainMenu( iEngine, iObserver );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewSystemConfig::PrepareChildViewL()
+    {
+    CMemSpyViewBase* child = NULL;
+    return child;
+    }
+
+
+void CMemSpyViewSystemConfig::SetListBoxModelL()
+    {
+    CDesCArrayFlat* model = new(ELeave) CDesCArrayFlat(5);
+    delete iModel;
+    iModel = model;
+
+    TBuf<128> valueBuf;
+    TInt value = 0;
+    TInt value2 = 0;
+    TMemSpySizeText sizeBuf;
+
+    //
+    _LIT(KItem1Format, "Manufacturer");
+    GetManufacturer( valueBuf );
+    AddItemL( KItem1Format, valueBuf );
+
+    //
+    _LIT(KItem2Format, "Machine Uid");
+    GetMachineUid( valueBuf );
+    AddItemL( KItem2Format, valueBuf );
+
+    //
+    _LIT(KItem1aFormat, "Model Uid");
+    GetHALValueAsHexL( HALData::EModel, KItem1aFormat );
+
+    //
+    _LIT(KItem2aFormat, "Device Family");
+    GetDeviceFamily( valueBuf );
+    AddItemL( KItem2aFormat, valueBuf );
+
+    //
+    _LIT(KItem2bFormat, "Device Family Rev.");
+    GetHALValueAsNumericL( HALData::EDeviceFamilyRev, KItem2bFormat );
+
+    //
+    _LIT(KItem3Format, "Hardware Rev.");
+    GetHALValueAsNumericL( HALData::EManufacturerHardwareRev, KItem3Format );
+
+    //
+    _LIT(KItem4Format, "Software Rev.");
+    GetHALValueAsNumericL( HALData::EManufacturerSoftwareRev, KItem4Format );
+
+    //
+    _LIT(KItem5Format, "Software Build");
+    GetHALValueAsNumericL( HALData::EManufacturerSoftwareBuild, KItem5Format );
+
+    //
+    _LIT(KItem6Format, "CPU");
+    GetCPU( valueBuf );
+    AddItemL( KItem6Format, valueBuf );
+
+    //
+    _LIT(KItem7Format, "CPU ABI");
+    GetCPUABI( valueBuf );
+    AddItemL( KItem7Format, valueBuf );
+
+    //
+    _LIT(KItem8Format, "CPU Speed");
+    _LIT(KItem8Suffix, "KHz");
+    GetHALValueAsNumericL( HALData::ECPUSpeed, KItem8Format, &KItem8Suffix );
+
+    //
+    _LIT(KItem8aFormat, "Floating Point Support");
+    GetHALValueAsYesNoL( HALData::EHardwareFloatingPoint, KItem8aFormat );
+
+    //
+    _LIT(KItem8bFormat, "System Tick Period");
+    _LIT(KItem8bSuffix, "ms");
+    GetHALValueAsNumericL( HALData::ESystemTickPeriod, KItem8bFormat, &KItem8bSuffix );
+
+    //
+    _LIT(KItem8cFormat, "Nano Tick Period");
+    _LIT(KItem8cSuffix, "us");
+    GetHALValueAsNumericL( HALData::ENanoTickPeriod, KItem8cFormat, &KItem8cSuffix );
+
+    //
+    _LIT(KItem9Format, "Startup Reason");
+    GetStartupReason( valueBuf );
+    AddItemL( KItem9Format, valueBuf );
+
+    //
+    _LIT(KItem10Format, "Language");
+    GetHALValueAsNumericL( HALData::ELanguageIndex, KItem10Format, NULL, 4 );
+
+    //
+    _LIT(KItem10aFormat, "Locale");
+    GetHALValueAsNumericL( HALData::ELocaleLoaded, KItem10aFormat, NULL, 4 );
+
+    //
+    _LIT(KItem11aFormat, "Clipboard Drive");
+    GetHALValueAsDriveLetterL( HALData::EClipboardDrive, KItem11aFormat );
+
+    //
+    _LIT(KItem11bFormat, "System Drive (Hal)");
+    GetHALValueAsDriveLetterL( HALData::ESystemDrive, KItem11bFormat );
+
+    //
+    _LIT(KItem11cFormat, "System Drive (F32)");
+    TDriveNumber systemDrive = CMemSpyEngineHelperFileSystem::GetSystemDrive();
+    AddItemL( systemDrive, KItem11cFormat );
+
+    //
+    _LIT(KItem11dFormat, "System Drive (Bafl)");
+    value = BaflUtils::GetSystemDrive( systemDrive );
+    if ( value == KErrNone )
+        {
+        AddItemL( systemDrive, KItem11dFormat );
+        }
+    else
+        {
+        MemSpyUiUtils::GetErrorText( valueBuf, value );
+        AddItemL( KItem11dFormat, valueBuf );
+        }
+
+    //
+    _LIT(KItem12Format, "Display Type");
+    GetDisplayType( valueBuf );
+    AddItemL( KItem12Format, valueBuf );
+    //
+    _LIT(KItem12aCaption, "Display Size");
+    _LIT(KItem12aFormat, "%d x %d");
+    value = value2 = 0;
+    GetHALValue( HALData::EDisplayXPixels, value );
+    GetHALValue( HALData::EDisplayYPixels, value2 );
+    valueBuf.Format( KItem12aFormat, value, value2 );
+    AddItemL( KItem12aCaption, valueBuf );
+
+    //
+    _LIT(KItem13Format, "Display Depth");
+    _LIT(KItem13Suffix, "bpp");
+    GetHALValueAsNumericL( HALData::EDisplayBitsPerPixel, KItem13Format, &KItem13Suffix );
+
+    //
+    _LIT(KItem14Format, "Display Mode Count");
+    GetHALValueAsNumericL( HALData::EDisplayNumModes, KItem14Format );
+
+    //
+    _LIT(KItem14aFormat, "Current Mode");
+    GetHALValueAsNumericL( HALData::EDisplayMode, KItem14aFormat );
+
+    //
+    _LIT(KItem15Format, "Display Address");
+    GetHALValueAsHexL( HALData::EDisplayMemoryAddress, KItem15Format );
+
+    //
+    _LIT(KItem16Format, "Screen Count");
+    GetHALValueAsNumericL( HALData::EDisplayNumberOfScreens, KItem16Format );
+
+    //
+    _LIT(KItem17Format, "Eikon Def. Disp. Mode");
+    GetDisplayMode( valueBuf, static_cast<TMemSpyDisplayMode>( CEikonEnv::Static()->DefaultDisplayMode() ) );
+    AddItemL( KItem17Format, valueBuf );
+
+    // Set up list box
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( model );
+    listbox->Model()->SetOwnershipType( ELbmOwnsItemArray );
+    iModel = NULL;
+    }
+
+
+void CMemSpyViewSystemConfig::GetManufacturer( TDes& aBuf )
+    {
+    TInt value = KErrGeneral;
+    GetHALValue( HALData::EManufacturer, value );
+    //
+    switch( value )
+        {
+    case HALData::EManufacturer_Ericsson:
+        {
+        _LIT( KName, "Ericsson" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::EManufacturer_Motorola:
+        {
+        _LIT( KName, "Motorola" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::EManufacturer_Nokia:
+        {
+        _LIT( KName, "Nokia" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::EManufacturer_Panasonic:
+        {
+        _LIT( KName, "Panasonic" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::EManufacturer_Psion:
+        {
+        _LIT( KName, "Psion" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::EManufacturer_Intel:
+        {
+        _LIT( KName, "Intel" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::EManufacturer_Cogent:
+        {
+        _LIT( KName, "Cogent" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::EManufacturer_Cirrus:
+        {
+        _LIT( KName, "Cirrus" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::EManufacturer_Linkup:
+        {
+        _LIT( KName, "Linkup" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::EManufacturer_TexasInstruments:
+        {
+        _LIT( KName, "Texas Instruments" );
+        aBuf.Copy( KName );
+        }
+        break;
+    default:
+        aBuf.Copy( KMemSpyItemValueNotKnown );
+        break;
+        }
+    }
+
+
+void CMemSpyViewSystemConfig::GetDisplayMode( TDes& aBuf, TMemSpyDisplayMode aMode )
+    {
+    switch( aMode )
+        {
+    case ENone:
+        {
+        _LIT( KName, "ENone" );
+        aBuf.Copy( KName );
+        }
+    case EGray2:
+        {
+        _LIT( KName, "EGray2" );
+        aBuf.Copy( KName );
+        }
+    case EGray4:
+        {
+        _LIT( KName, "EGray4" );
+        aBuf.Copy( KName );
+        }
+    case EGray16:
+        {
+        _LIT( KName, "EGray16" );
+        aBuf.Copy( KName );
+        }
+    case EGray256:
+        {
+        _LIT( KName, "EGray256" );
+        aBuf.Copy( KName );
+        }
+    case EColor16:
+        {
+        _LIT( KName, "EColor16" );
+        aBuf.Copy( KName );
+        }
+    case EColor256:
+        {
+        _LIT( KName, "EColor256" );
+        aBuf.Copy( KName );
+        }
+    case EColor64K:
+        {
+        _LIT( KName, "EColor64K" );
+        aBuf.Copy( KName );
+        }
+    case EColor16M:
+        {
+        _LIT( KName, "EColor16M" );
+        aBuf.Copy( KName );
+        }
+    case ERgb:
+        {
+        _LIT( KName, "ERgb" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case EColor4K:
+        {
+        _LIT( KName, "EColor4K" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case EColor16MU:
+        {
+        _LIT( KName, "EColor16MU" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case EColor16MA:
+        {
+        _LIT( KName, "EColor16MA" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case EColor16MAP:
+        {
+        _LIT( KName, "EColor16MAP" );
+        aBuf.Copy( KName );
+        }
+        break;
+    default:
+        aBuf.Copy( KMemSpyItemValueNotKnown );
+        break;
+        }
+    }
+
+
+void CMemSpyViewSystemConfig::GetDeviceFamily( TDes& aBuf )
+    {
+    TInt value = KErrGeneral;
+    GetHALValue( HALData::EDeviceFamily, value );
+    //
+    switch( value )
+        {
+    case HALData::EDeviceFamily_Crystal:
+        {
+        _LIT( KName, "Crystal" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::EDeviceFamily_Pearl:
+        {
+        _LIT( KName, "Pearl" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::EDeviceFamily_Quartz:
+        {
+        _LIT( KName, "Quartz" );
+        aBuf.Copy( KName );
+        }
+        break;
+    default:
+        aBuf.Copy( KMemSpyItemValueNotKnown );
+        break;
+        }
+    }
+
+
+void CMemSpyViewSystemConfig::GetCPU( TDes& aBuf )
+    {
+    TInt value = KErrGeneral;
+    GetHALValue( HALData::ECPU, value );
+    //
+    switch( value )
+        {
+    case HALData::ECPU_ARM:
+        {
+        _LIT( KName, "ARM" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::ECPU_MCORE:
+        {
+        _LIT( KName, "mCORE" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::ECPU_X86:
+        {
+        _LIT( KName, "X86" );
+        aBuf.Copy( KName );
+        }
+        break;
+    default:
+        aBuf.Copy( KMemSpyItemValueNotKnown );
+        break;
+        }
+    }
+
+
+void CMemSpyViewSystemConfig::GetCPUABI( TDes& aBuf )
+    {
+    TInt value = KErrGeneral;
+    GetHALValue( HALData::ECPUABI, value );
+    //
+    switch( value )
+        {
+    case HALData::ECPUABI_ARM4:
+        {
+        _LIT( KName, "ARM4" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::ECPUABI_ARMI:
+        {
+        _LIT( KName, "ARMI" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::ECPUABI_THUMB:
+        {
+        _LIT( KName, "ARM4" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::ECPUABI_MCORE:
+        {
+        _LIT( KName, "mCORE" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::ECPUABI_MSVC:
+        {
+        _LIT( KName, "MSVC" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::ECPUABI_ARM5T:
+        {
+        _LIT( KName, "ARM5T" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::ECPUABI_X86:
+        {
+        _LIT( KName, "X86" );
+        aBuf.Copy( KName );
+        }
+        break;
+    default:
+        aBuf.Copy( KMemSpyItemValueNotKnown );
+        break;
+        }
+    }
+
+
+void CMemSpyViewSystemConfig::GetStartupReason( TDes& aBuf )
+    {
+    TInt value = KErrGeneral;
+    GetHALValue( HALData::ESystemStartupReason, value );
+    //
+    switch( value )
+        {
+    case HALData::ESystemStartupReason_Cold:
+        {
+        _LIT( KName, "Cold" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::ESystemStartupReason_Warm:
+        {
+        _LIT( KName, "Warm" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::ESystemStartupReason_Fault:
+        {
+        _LIT( KName, "Fault" );
+        aBuf.Copy( KName );
+        }
+        break;
+    default:
+        aBuf.Copy( KMemSpyItemValueNotKnown );
+        break;
+        }
+    }
+
+
+void CMemSpyViewSystemConfig::GetKeyboard( TDes& aBuf )
+    {
+    _LIT(KComma, ", ");
+    TInt value = KErrGeneral;
+    GetHALValue( HALData::EKeyboard, value );
+    //
+    aBuf.Zero();
+    if  ( value & EKeyboard_Keypad )
+        {
+        _LIT( KName, "Keypad" );
+        aBuf.Copy( KName );
+        }
+
+
+    if  ( value & EKeyboard_Full )
+        {
+        if  ( aBuf.Length() )
+            {
+            aBuf.Append( KComma );
+            }
+
+        _LIT( KName, "Full Keyboard" );
+        aBuf.Copy( KName );
+        }
+
+    if  ( !aBuf.Length() )
+        {
+        aBuf.Copy( KMemSpyItemValueNotKnown );
+        }
+    }
+
+
+void CMemSpyViewSystemConfig::GetMachineUid( TDes& aBuf )
+    {
+    TInt value = KErrGeneral;
+    GetHALValue( HALData::EMachineUid, value );
+    //
+    switch( value )
+        {
+    case HALData::EMachineUid_Series5mx:
+        {
+        _LIT( KName, "Series 5mx" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::EMachineUid_Brutus:
+        {
+        _LIT( KName, "Brutus" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::EMachineUid_Cogent:
+        {
+        _LIT( KName, "Cogent" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::EMachineUid_Win32Emulator:
+        {
+        _LIT( KName, "Win32 Emulator" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::EMachineUid_WinC:
+        {
+        _LIT( KName, "WINC" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::EMachineUid_CL7211_Eval:
+        {
+        _LIT( KName, "CL7211" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::EMachineUid_LinkUp:
+        {
+        _LIT( KName, "LinkUp" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::EMachineUid_Assabet:
+        {
+        _LIT( KName, "Assabet" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::EMachineUid_IQ80310:
+        {
+        _LIT( KName, "IQ80310" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::EMachineUid_Lubbock:
+        {
+        _LIT( KName, "Lubbock" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::EMachineUid_Integrator:
+        {
+        _LIT( KName, "Integrator" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::EMachineUid_Helen:
+        {
+        _LIT( KName, "Helen" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::EMachineUid_X86PC:
+        {
+        _LIT( KName, "X86PC" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::EMachineUid_OmapH2:
+        {
+        _LIT( KName, "OmapH2" );
+        aBuf.Copy( KName );
+        }
+        break;
+    case HALData::EMachineUid_OmapH4:
+        {
+        _LIT( KName, "OmapH4" );
+        aBuf.Copy( KName );
+        }
+        break;
+    default:
+        {
+        _LIT( KName, "0x%08x" );
+        aBuf.Format( KName, value );
+        }
+        break;
+        }
+    }
+
+
+void CMemSpyViewSystemConfig::GetDisplayType( TDes& aBuf )
+    {
+    TInt value = KErrGeneral;
+    GetHALValue( HALData::EDisplayIsMono, value );
+    //
+    if  ( value == 0 )
+        {
+        _LIT( KName, "Colour" );
+        aBuf.Copy( KName );
+        }
+    else if ( value == 1 )
+        {
+        _LIT( KName, "Mono" );
+        aBuf.Copy( KName );
+        }
+    else
+        {
+        MemSpyUiUtils::GetErrorText( aBuf, value );
+        }
+    }
+
+
+TInt CMemSpyViewSystemConfig::GetHALValue( HALData::TAttribute aAttribute, TInt& aValue )
+    {
+    aValue = KErrGeneral;
+    const TInt error = HAL::Get( aAttribute, aValue );
+
+#ifdef _DEBUG
+    if  ( error != KErrNone )
+        {
+        RDebug::Printf("CMemSpyViewSystemConfig::GetHALValue() - aAttribute: %3d, error: %d, value: %d", aAttribute, error, aValue);
+        }
+#endif
+
+    return error;
+    }
+
+
+TInt CMemSpyViewSystemConfig::GetHALValueAsNumericL( HALData::TAttribute aAttribute, const TDesC& aCaption, const TDesC* aSuffix, TInt aWidth )
+    {
+    TBuf<20> valueBuf; 
+    TInt value = 0;
+    //
+    const TInt error = GetHALValue( aAttribute, value );
+    if  ( error == KErrNone )
+        {
+        if  ( aWidth > 0 && aWidth < 12 )
+            {
+            valueBuf.NumFixedWidthUC( (TUint) value, EDecimal, aWidth );
+            }
+        else
+            {
+            valueBuf.Num( value );
+            }
+
+        AddItemL( aCaption, valueBuf, aSuffix );
+        }
+    else
+        {
+        MemSpyUiUtils::GetErrorText( valueBuf, error );
+        AddItemL( aCaption, valueBuf );
+        }
+    //
+    return error;
+    }
+
+
+TInt CMemSpyViewSystemConfig::GetHALValueAsHexL( HALData::TAttribute aAttribute, const TDesC& aCaption, const TDesC* aSuffix )
+    {
+    TBuf<20> valueBuf; 
+    TInt value = 0;
+    //
+    const TInt error = GetHALValue( aAttribute, value );
+    if  ( error == KErrNone )
+        {
+        MemSpyEngineUtils::FormatHex( valueBuf, value );
+        AddItemL( aCaption, valueBuf, aSuffix );
+        }
+    else
+        {
+        MemSpyUiUtils::GetErrorText( valueBuf, error );
+        AddItemL( aCaption, valueBuf );
+        }
+    //
+    return error;
+    }
+
+
+TInt CMemSpyViewSystemConfig::GetHALValueAsYesNoL( HALData::TAttribute aAttribute, const TDesC& aCaption, const TDesC* aSuffix )
+    {
+    TBuf<20> valueBuf; 
+    TInt value = 0;
+    //
+    const TInt error = GetHALValue( aAttribute, value );
+    if  ( error == KErrNone || error == KErrNotSupported )
+        {
+        _LIT(KYes, "Yes");
+        _LIT(KNo, "No");
+        _LIT(KError, "Error: %d");
+
+        if ( error < KErrNone )
+            {
+            valueBuf.Format( KError, error );
+            }
+        else if ( value == EFalse )
+            {
+            valueBuf.Copy( KNo );
+            }
+        else if ( error == KErrNone )
+            {
+            valueBuf.Copy( KYes );
+            }
+
+        AddItemL( aCaption, valueBuf, aSuffix );
+        }
+    else
+        {
+        MemSpyUiUtils::GetErrorText( valueBuf, error );
+        AddItemL( aCaption, valueBuf );
+        }
+    //
+    return error;
+    }
+
+
+TInt CMemSpyViewSystemConfig::GetHALValueAsDriveLetterL( HALData::TAttribute aAttribute, const TDesC& aCaption, const TDesC* aSuffix )
+    {
+    TInt value = 0;
+    const TInt error = GetHALValue( aAttribute, value );
+    //
+    if  ( error == KErrNone && ( value >= EDriveA && value <= EDriveZ ) )
+        {
+        AddItemL( (TDriveNumber) value, aCaption, aSuffix );
+        }
+    else
+        {
+        _LIT( KItemNotSet, "Not Defined");
+        AddItemL( aCaption, KItemNotSet );
+        }
+    //
+    return error;
+    }
+
+
+void CMemSpyViewSystemConfig::AddItemL( const TDesC& aCaption, const TDesC& aValue, const TDesC* aSuffix )
+    {
+    _LIT(KItemFormat, "\t%S\t\t%S");
+    //
+    TBuf<KMaxFullName> item;
+    item.Format( KItemFormat, &aCaption, &aValue );
+    if  ( aSuffix ) 
+        {
+        _LIT(KSpace, " ");
+        item.Append( KSpace );
+        item.Append( *aSuffix );
+        }
+    //
+    iModel->AppendL( item );
+    }
+
+
+void CMemSpyViewSystemConfig::AddItemL( TDriveNumber aDrive, const TDesC& aCaption, const TDesC* aSuffix )
+    {
+    TBuf<20> valueBuf; 
+    //
+    const TDriveUnit drive( aDrive );
+    valueBuf.Copy( drive.Name() );
+    //
+    AddItemL( aCaption, valueBuf, aSuffix );
+    }
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewThreadInfoItemActiveObject.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,241 @@
+/*
+* 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 "MemSpyViewThreadInfoItemActiveObject.h"
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyenginehelperactiveobject.h>
+
+// User includes
+#include "MemSpyContainerObserver.h"
+
+
+
+CMemSpyViewThreadInfoItemActiveObjectBase::CMemSpyViewThreadInfoItemActiveObjectBase( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer )
+:   CMemSpyViewThreadInfoItemGeneric( aEngine, aObserver, aContainer, EMemSpyThreadInfoItemTypeActiveObject )
+    {
+    }
+
+
+TBool CMemSpyViewThreadInfoItemActiveObjectBase::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = ETrue;
+    //
+    switch ( aCommand )
+        {
+    case EMemSpyCmdActiveObjectListing:
+        OnCmdWriteAOListingL();
+        break;
+    default:
+        handled = CMemSpyViewBase::HandleCommandL( aCommand );
+        break;
+        }
+    //
+    return handled;
+    }
+
+
+void CMemSpyViewThreadInfoItemActiveObjectBase::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
+    {
+    if  ( aResourceId == R_MEMSPY_MENUPANE )
+        {
+        aMenuPane->SetItemDimmed( EMemSpyCmdActiveObject, Thread().IsDead() );
+        }
+    }
+
+
+CMemSpyEngineActiveObjectArray& CMemSpyViewThreadInfoItemActiveObjectBase::ActiveObjectArray() const
+    {
+    CMemSpyThreadInfoActiveObjects* activeObjectArray = static_cast< CMemSpyThreadInfoActiveObjects* >( iInfoItem );
+    return activeObjectArray->Array();
+    }
+    
+    
+void CMemSpyViewThreadInfoItemActiveObjectBase::OnCmdWriteAOListingL()
+    {
+    CMemSpyEngineActiveObjectArray& objects = ActiveObjectArray();
+
+    // Begin a new data stream
+    _LIT( KMemSpyContext, "Active Object List - " );
+    _LIT( KMemSpyFolder, "Active Objects" );
+    iEngine.Sink().DataStreamBeginL( KMemSpyContext, KMemSpyFolder );
+
+    // Set prefix for overall listing
+    iEngine.Sink().OutputPrefixSetLC( KMemSpyContext );
+
+    // Create header
+    CMemSpyEngineActiveObjectArray::OutputDataColumnsL( iEngine );
+    
+    // List items
+    const TInt count = objects.Count();
+    for(TInt i=0; i<count; i++)
+        {
+        const CMemSpyEngineActiveObject& object = objects.At( i );
+        //
+        object.OutputDataL( iEngine );
+        }
+
+    // Tidy up
+    CleanupStack::PopAndDestroy(); // prefix
+
+    // End data stream
+    iEngine.Sink().DataStreamEndL();
+    }
+
+
+
+
+
+
+
+
+
+
+
+CMemSpyViewThreadInfoItemActiveObject::CMemSpyViewThreadInfoItemActiveObject( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer )
+:   CMemSpyViewThreadInfoItemActiveObjectBase( aEngine, aObserver, aContainer )
+    {
+    }
+
+
+void CMemSpyViewThreadInfoItemActiveObject::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    // Causes list of server's to be prepared
+    CMemSpyViewThreadInfoItemActiveObjectBase::ConstructL( aRect, aContainer, aSelectionRune );
+
+    _LIT( KTitle, "Active Objects" );
+    SetTitleL( KTitle );
+
+    // Try to select the correct server
+    CMemSpyThreadInfoHandleObjectBase* infoItem = static_cast< CMemSpyThreadInfoHandleObjectBase* >( iInfoItem );
+    TInt selectedIndex = 0;
+    if  ( aSelectionRune )
+        {
+        CMemSpyEngineActiveObjectArray& activeObjectArray = ActiveObjectArray();
+        const TInt index = activeObjectArray.ObjectIndexByAddress( aSelectionRune );
+        if  ( index >= 0 && index < activeObjectArray.Count() )
+            {
+            selectedIndex = index + 1;
+            }
+        }
+
+    // Select item
+    if  ( infoItem->DetailsCount() > 0 )
+        {
+        iListBox->SetCurrentItemIndex( selectedIndex );
+        HandleListBoxItemSelectedL( selectedIndex );
+        }
+    }
+
+
+TMemSpyViewType CMemSpyViewThreadInfoItemActiveObject::ViewType() const
+    {
+    return EMemSpyViewTypeThreadInfoItemActiveObject;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewThreadInfoItemActiveObject::PrepareChildViewL()
+    {
+    CMemSpyViewBase* child = NULL;
+
+    // Get current entry address
+    TInt index = iListBox->CurrentItemIndex();
+    if  ( index > 0 )
+        {
+        --index;
+        CMemSpyEngineActiveObjectArray& activeObjectArray = ActiveObjectArray();
+        //
+        if  ( index >= 0 && index < activeObjectArray.MdcaCount() )
+            {
+            CMemSpyEngineActiveObject& object = activeObjectArray.At( index );
+            TAny* aoAddress = object.Address();
+            //
+            child = new(ELeave) CMemSpyViewThreadInfoItemActiveObjectDetails( iEngine, iObserver, iInfoItem->Container(), aoAddress );
+            CleanupStack::PushL( child );
+            child->ConstructL( Rect(), *Parent(), NULL );
+            CleanupStack::Pop( child );
+            }
+        }
+    //
+    return child;
+    }
+
+
+
+
+
+
+
+
+
+
+
+CMemSpyViewThreadInfoItemActiveObjectDetails::CMemSpyViewThreadInfoItemActiveObjectDetails( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer, TAny* aObjectAddress )
+:   CMemSpyViewThreadInfoItemActiveObjectBase( aEngine, aObserver, aContainer ), iObjectAddress( aObjectAddress )
+    {
+    }
+
+
+void CMemSpyViewThreadInfoItemActiveObjectDetails::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    CMemSpyViewThreadInfoItemActiveObjectBase::ConstructL( aRect, aContainer, aSelectionRune );
+
+    _LIT( KTitle, "Active Object Details" );
+    SetTitleL( KTitle );
+    }
+    
+
+TMemSpyViewType CMemSpyViewThreadInfoItemActiveObjectDetails::ViewType() const
+    {
+    return EMemSpyViewTypeThreadInfoItemActiveObjectDetails;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewThreadInfoItemActiveObjectDetails::PrepareParentViewL()
+    {
+    CMemSpyViewThreadInfoItemActiveObject* parent = new(ELeave) CMemSpyViewThreadInfoItemActiveObject( iEngine, iObserver, iInfoItem->Container() );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), iObjectAddress );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+void CMemSpyViewThreadInfoItemActiveObjectDetails::SetListBoxModelL()
+    {
+    // Try to find the right entry
+    CMemSpyEngineActiveObjectArray& activeObjectArray = ActiveObjectArray();
+    const TInt index = activeObjectArray.ObjectIndexByAddress( iObjectAddress );
+    User::LeaveIfError( index );
+    CMemSpyEngineActiveObject& object = activeObjectArray.At( index );
+    //
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( &object );
+    listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewThreadInfoItemChunk.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -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 "MemSpyViewThreadInfoItemChunk.h"
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyenginehelperprocess.h>
+#include <memspy/engine/memspyenginehelperchunk.h>
+
+// User includes
+#include "MemSpyContainerObserver.h"
+#include "MemSpyViewChunkList.h"
+
+
+
+CMemSpyViewThreadInfoItemChunk::CMemSpyViewThreadInfoItemChunk( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer )
+:   CMemSpyViewThreadInfoItemGeneric( aEngine, aObserver, aContainer, EMemSpyThreadInfoItemTypeChunk )
+    {
+    }
+
+
+CMemSpyViewBase* CMemSpyViewThreadInfoItemChunk::PrepareChildViewL()
+    {
+    CMemSpyViewBase* child = NULL;
+    
+    // Get the code segment list
+    CMemSpyThreadInfoChunk* chunkInfoItem = static_cast< CMemSpyThreadInfoChunk* >( iInfoItem );
+    CMemSpyEngineChunkList* list = &chunkInfoItem->List();
+    
+    // Get the current code segment that corresponds to our currently focused list item.
+    const TInt index = iListBox->CurrentItemIndex();
+    if  ( index >= 0 && index < list->Count() )
+        {
+        CMemSpyEngineChunkEntry& entry = list->At( index );
+        child = new(ELeave) CMemSpyViewChunkDetails( iEngine, iObserver, *list, entry );
+        
+        // Ownership is transferred to child. Cleanupstack guarantees it will be destroyed now.
+        // This object is about to die in any case.
+        chunkInfoItem->NullifyList();
+
+        CleanupStack::PushL( child );
+        child->ConstructL( Rect(), *Parent() );
+        CleanupStack::Pop( child );
+        }
+        
+    return child;
+    }
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewThreadInfoItemCodeSeg.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,76 @@
+/*
+* 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 "MemSpyViewThreadInfoItemCodeSeg.h"
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyenginehelperprocess.h>
+#include <memspy/engine/memspyenginehelpercodesegment.h>
+
+// User includes
+#include "MemSpyContainerObserver.h"
+#include "MemSpyViewCodeSegList.h"
+
+
+
+CMemSpyViewThreadInfoItemCodeSeg::CMemSpyViewThreadInfoItemCodeSeg( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer )
+:   CMemSpyViewThreadInfoItemGeneric( aEngine, aObserver, aContainer, EMemSpyThreadInfoItemTypeCodeSeg )
+    {
+    }
+
+
+TBool CMemSpyViewThreadInfoItemCodeSeg::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = CMemSpyViewBase::HandleCommandL( aCommand );
+    return handled;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewThreadInfoItemCodeSeg::PrepareChildViewL()
+    {
+    CMemSpyViewBase* child = NULL;
+    
+    // Get the code segment list
+    CMemSpyThreadInfoCodeSeg* codeSegInfoItem = static_cast< CMemSpyThreadInfoCodeSeg* >( iInfoItem );
+    CMemSpyEngineCodeSegList* list = &codeSegInfoItem->List();
+    
+    // Get the current code segment that corresponds to our currently focused list item.
+    const TInt index = iListBox->CurrentItemIndex();
+    if  ( index >= 0 && index < list->Count() )
+        {
+        CMemSpyEngineCodeSegEntry& entry = list->At( index );
+        child = new(ELeave) CMemSpyViewCodeSegDetails( iEngine, iObserver, *list, entry );
+        
+        // Ownership is transferred to child. Cleanupstack guarantees it will be destroyed now.
+        // This object is about to die in any case.
+        codeSegInfoItem->NullifyList();
+
+        CleanupStack::PushL( child );
+        child->ConstructL( Rect(), *Parent() );
+        CleanupStack::Pop( child );
+        }
+        
+    return child;
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewThreadInfoItemGeneralInfo.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -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:
+*
+*/
+
+#include "MemSpyViewThreadInfoItemGeneralInfo.h"
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyenginehelperprocess.h>
+#include <memspy/engine/memspyenginehelperheap.h>
+
+// User includes
+#include "MemSpyContainerObserver.h"
+#include "MemSpyViewThreads.h"
+#include "MemSpyViewThreadInfoItemHeap.h"
+
+
+
+CMemSpyViewThreadInfoItemGeneralInfo::CMemSpyViewThreadInfoItemGeneralInfo( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer )
+:   CMemSpyViewThreadInfoItemGeneric( aEngine, aObserver, aContainer, EMemSpyThreadInfoItemTypeGeneralInfo )
+    {
+    }
+
+
+TBool CMemSpyViewThreadInfoItemGeneralInfo::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = ETrue;
+    //
+    switch ( aCommand )
+        {
+    default:
+        handled = CMemSpyViewBase::HandleCommandL( aCommand );
+        break;
+        }
+    //
+    return handled;
+    }
+
+
+
+
+void CMemSpyViewThreadInfoItemGeneralInfo::HandleListBoxItemActionedL( TInt /*aIndex*/ )
+    {
+    // Notify observer about item selection
+    ReportEventL( MMemSpyViewObserver::EEventItemActioned );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewThreadInfoItemGeneric.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,315 @@
+/*
+* 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 "MemSpyViewThreadInfoItemGeneric.h"
+
+// System includes
+#include <AknWaitDialog.h>
+#include <memspyui.rsg>
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyenginehelperprocess.h>
+
+// User includes
+#include "MemSpyContainerObserver.h"
+#include "MemSpyViewThreadInfoItemList.h"
+
+// Constants
+const TInt KMemSpyConstructionCheckerTimerPeriod = 500000; // 1/2 second
+
+
+
+CMemSpyViewThreadInfoItemGeneric::CMemSpyViewThreadInfoItemGeneric( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aInfoContainer, TMemSpyThreadInfoItemType aType )
+:   CMemSpyViewBase( aEngine, aObserver ), iContainer( aInfoContainer )
+    {
+    iContainer.Thread().Process().Open();
+    iContainer.Thread().Open();
+    iContainer.Open();
+    //
+    iInfoItem = &iContainer.Item( aType );
+    __ASSERT_ALWAYS( iInfoItem != NULL, User::Invariant() );
+    iInfoItem->Open();
+    }
+
+
+CMemSpyViewThreadInfoItemGeneric::~CMemSpyViewThreadInfoItemGeneric()
+    {
+    if  ( iInfoItem )
+        {
+        iInfoItem->Close();
+        }
+    //
+    DestroyWaitNote();
+    //
+    iContainer.Close();
+    iContainer.Thread().Close();
+    iContainer.Thread().Process().Close();
+    }
+
+
+void CMemSpyViewThreadInfoItemGeneric::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    const TPtrC pTitle( iInfoItem->Name().Mid( 1 ) );
+    SetTitleL( pTitle );
+    //
+    if  ( iInfoItem->IsReady() == EFalse )
+        {
+#ifdef _DEBUG
+        RDebug::Printf( "CMemSpyViewThreadInfoItemGeneric::ConstructL() - show wait note - item not ready, iType: %d", iInfoItem->Type() );
+#endif
+
+        // Wait for engine data to be made ready... 
+        ShowWaitNoteL();
+        }
+
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+    }
+
+
+CMemSpyProcess& CMemSpyViewThreadInfoItemGeneric::Process() const
+    {
+    return iContainer.Thread().Process();
+    }
+
+
+CMemSpyThread& CMemSpyViewThreadInfoItemGeneric::Thread() const
+    {
+    return iContainer.Thread();
+    }
+
+
+CMemSpyThreadInfoContainer& CMemSpyViewThreadInfoItemGeneric::Container() const
+    {
+    return iContainer;
+    }
+
+
+CMemSpyThreadInfoItemBase& CMemSpyViewThreadInfoItemGeneric::InfoItem() const
+    {
+    __ASSERT_ALWAYS( iInfoItem != NULL, User::Invariant() );
+    return *iInfoItem;
+    }
+
+
+void CMemSpyViewThreadInfoItemGeneric::RefreshL()
+    {
+    iInfoItem->RebuildL();    
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewThreadInfoItemGeneric::ViewType() const
+    {
+    TMemSpyViewType type = EMemSpyViewTypeNone;
+    //
+    switch( iInfoItem->Type() )
+        {
+    case EMemSpyThreadInfoItemTypeHeap:
+        type = EMemSpyViewTypeThreadInfoItemHeap;
+        break;
+    case EMemSpyThreadInfoItemTypeStack:
+        type = EMemSpyViewTypeThreadInfoItemStack;
+        break;
+    case EMemSpyThreadInfoItemTypeChunk:
+        type = EMemSpyViewTypeThreadInfoItemChunk;
+        break;
+    case EMemSpyThreadInfoItemTypeCodeSeg:
+        type = EMemSpyViewTypeThreadInfoItemCodeSeg;
+        break;
+    case EMemSpyThreadInfoItemTypeServer:
+        type = EMemSpyViewTypeThreadInfoItemServer;
+        break;
+    case EMemSpyThreadInfoItemTypeSession:
+        type = EMemSpyViewTypeThreadInfoItemSession;
+        break;
+    case EMemSpyThreadInfoItemTypeSemaphore:
+        type = EMemSpyViewTypeThreadInfoItemSemaphore;
+        break;
+    case EMemSpyThreadInfoItemTypeMutex:
+        type = EMemSpyViewTypeThreadInfoItemMutex;
+        break;
+    case EMemSpyThreadInfoItemTypeTimer:
+        type = EMemSpyViewTypeThreadInfoItemTimer;
+        break;
+    case EMemSpyThreadInfoItemTypeLDD:
+        type = EMemSpyViewTypeThreadInfoItemLDD;
+        break;
+    case EMemSpyThreadInfoItemTypePDD:
+        type = EMemSpyViewTypeThreadInfoItemPDD;
+        break;
+    case EMemSpyThreadInfoItemTypeLogicalChannel:
+        type = EMemSpyViewTypeThreadInfoItemLogicalChannel;
+        break;
+    case EMemSpyThreadInfoItemTypeChangeNotifier:
+        type = EMemSpyViewTypeThreadInfoItemChangeNotifier;
+        break;
+    case EMemSpyThreadInfoItemTypeUndertaker:
+        type = EMemSpyViewTypeThreadInfoItemUndertaker;
+        break;
+    case EMemSpyThreadInfoItemTypeMessageQueue:
+        type = EMemSpyViewTypeThreadInfoItemMessageQueue;
+        break;
+    case EMemSpyThreadInfoItemTypeConditionalVariable:
+        type = EMemSpyViewTypeThreadInfoItemConditionalVariable;
+        break;
+    case EMemSpyThreadInfoItemTypeOpenFiles:
+        type = EMemSpyViewTypeThreadInfoItemOpenFiles;
+        break;
+    case EMemSpyThreadInfoItemTypeActiveObject:
+        type = EMemSpyViewTypeThreadInfoItemActiveObject;
+        break;
+    case EMemSpyThreadInfoItemTypeGeneralInfo:
+        type = EMemSpyViewTypeThreadInfoItemGeneralInfo;
+        break;
+    case EMemSpyThreadInfoItemTypeOtherThreads:
+        type = EMemSpyViewTypeThreadInfoItemOtherThreads;
+        break;
+    case EMemSpyThreadInfoItemTypeOtherProcesses:
+        type = EMemSpyViewTypeThreadInfoItemOtherProcesses;
+        break;
+    case EMemSpyThreadInfoItemTypeOwnedThreadHandles:
+        type = EMemSpyViewTypeThreadInfoItemOwnedThreadHandles;
+        break;
+    case EMemSpyThreadInfoItemTypeOwnedProcessHandles:
+        type = EMemSpyViewTypeThreadInfoItemOwnedProcessHandles;
+        break;
+
+    default:
+        __ASSERT_DEBUG( EFalse, User::Invariant() );
+        break;
+        }
+    //
+    return type;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewThreadInfoItemGeneric::PrepareParentViewL()
+    {
+    CMemSpyViewThreadInfoItemList* parent = new(ELeave) CMemSpyViewThreadInfoItemList( iEngine, iObserver, Thread() );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), iInfoItem );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewThreadInfoItemGeneric::PrepareChildViewL()
+    {
+    __ASSERT_ALWAYS( iInfoItem != NULL, User::Invariant() );
+    CMemSpyViewBase* child = NULL;
+    //
+    return child;
+    }
+
+
+TBool CMemSpyViewThreadInfoItemGeneric::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = CMemSpyViewBase::HandleCommandL( aCommand );
+    return handled;
+    }
+
+
+void CMemSpyViewThreadInfoItemGeneric::SetListBoxModelL()
+    {
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( iInfoItem );
+    listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+
+
+void CMemSpyViewThreadInfoItemGeneric::HandleListBoxItemActionedL( TInt /*aIndex*/ )
+    {
+    // Notify observer about an item being 'fired'
+    ReportEventL( MMemSpyViewObserver::EEventItemActioned );
+    }
+
+
+void CMemSpyViewThreadInfoItemGeneric::HandleListBoxItemSelectedL( TInt /*aIndex*/ )
+    {
+    // Notify observer about item selection
+    ReportEventL( MMemSpyViewObserver::EEventItemSelected );
+    }
+
+
+
+void CMemSpyViewThreadInfoItemGeneric::ShowWaitNoteL()
+    {
+    // Ugly, but I'm not adding an observer mechanism just for this wait dialog.
+    __ASSERT_ALWAYS( iWaitConstructionChecker == NULL, User::Invariant() );
+    iWaitConstructionChecker = CPeriodic::NewL( CActive::EPriorityLow );
+    iWaitConstructionChecker->Start( KMemSpyConstructionCheckerTimerPeriod, 
+                                     KMemSpyConstructionCheckerTimerPeriod, 
+                                     TCallBack( CheckForItemConstructionComplete, this ) );
+
+    if  ( !iWaitNote )
+        {
+        iWaitNote = new ( ELeave ) CAknWaitDialog( reinterpret_cast<CEikDialog**> ( &iWaitNote ), ETrue );
+        iWaitNote->ExecuteDlgLD( CAknNoteDialog::ENoTone, R_MEMSPY_PREPARING_INFO_ITEM_CONTAINER_WAIT_NOTE );
+        }
+    }
+
+
+void CMemSpyViewThreadInfoItemGeneric::DestroyWaitNote()
+    {
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyViewThreadInfoItemGeneric::DestroyWaitNote() - START" );
+#endif
+	//
+    delete iWaitConstructionChecker;
+    iWaitConstructionChecker = NULL;
+    //
+    if  ( iWaitNote )
+        {
+        TRAP_IGNORE( iWaitNote->ProcessFinishedL() ); // deletes the dialog
+        iWaitNote = NULL;
+        }
+	//
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyViewThreadInfoItemGeneric::DestroyWaitNote() - END" );
+#endif
+    }
+
+
+TInt CMemSpyViewThreadInfoItemGeneric::CheckForItemConstructionComplete( TAny* aSelf )
+    {
+    CMemSpyViewThreadInfoItemGeneric& self = *reinterpret_cast< CMemSpyViewThreadInfoItemGeneric* >( aSelf );
+    //
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyViewThreadInfoItemGeneric::CheckForItemConstructionComplete() - ready status: %d, iType: %d", self.iInfoItem->IsReady(), self.iInfoItem->Type() );
+#endif
+	//
+    TBool callAgain = ETrue;
+    if  ( self.iInfoItem->IsReady() )
+        {
+        self.DestroyWaitNote();
+        callAgain = EFalse;
+        }
+    //
+    return callAgain;
+    }
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewThreadInfoItemHeap.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,94 @@
+/*
+* 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 "MemSpyViewThreadInfoItemHeap.h"
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyenginehelperprocess.h>
+#include <memspy/engine/memspyenginehelperheap.h>
+
+// User includes
+#include "MemSpyContainerObserver.h"
+#include "MemSpyViewThreads.h"
+#include "MemSpyViewThreadInfoItemHeap.h"
+
+
+
+CMemSpyViewThreadInfoItemHeap::CMemSpyViewThreadInfoItemHeap( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer )
+:   CMemSpyViewThreadInfoItemGeneric( aEngine, aObserver, aContainer, EMemSpyThreadInfoItemTypeHeap )
+    {
+    }
+
+
+TBool CMemSpyViewThreadInfoItemHeap::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = ETrue;
+    //
+    switch ( aCommand )
+        {
+#ifndef __WINS__
+	case EMemSpyCmdHeapDataDump:
+        OnCmdHeapDataL();
+        break;
+#endif
+	case EMemSpyCmdHeapCellListing:
+        OnCmdHeapCellListingL();
+        break;
+    case EMemSpyCmdHeapInfoThread:
+        OnCmdHeapInfoL();
+        break;
+
+    default:
+        handled = CMemSpyViewBase::HandleCommandL( aCommand );
+        break;
+        }
+    //
+    return handled;
+    }
+
+
+void CMemSpyViewThreadInfoItemHeap::OnCmdHeapDataL()
+    {
+    iEngine.HelperHeap().OutputHeapDataUserL( Thread() );
+    }
+
+
+void CMemSpyViewThreadInfoItemHeap::OnCmdHeapCellListingL()
+    {
+    iEngine.HelperHeap().OutputCellListingUserL( Thread() );
+    }
+
+
+void CMemSpyViewThreadInfoItemHeap::OnCmdHeapInfoL()
+    {
+    iEngine.HelperHeap().OutputHeapInfoUserL( Thread() );
+    }
+
+
+void CMemSpyViewThreadInfoItemHeap::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
+    {
+    if  ( aResourceId == R_MEMSPY_MENUPANE )
+        {
+        aMenuPane->SetItemDimmed( EMemSpyCmdHeap, Thread().IsDead() );
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewThreadInfoItemList.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,336 @@
+/*
+* 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 "MemSpyViewThreadInfoItemList.h"
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyenginehelperprocess.h>
+
+// User includes
+#include "MemSpyContainerObserver.h"
+#include "MemSpyViewThreads.h"
+#include "MemSpyViewThreadInfoItemHeap.h"
+#include "MemSpyViewThreadInfoItemStack.h"
+#include "MemSpyViewThreadInfoItemChunk.h"
+#include "MemSpyViewThreadInfoItemCodeSeg.h"
+#include "MemSpyViewThreadInfoItemServer.h"
+#include "MemSpyViewThreadInfoItemActiveObject.h"
+#include "MemSpyViewThreadInfoItemGeneralInfo.h"
+#include "MemSpyViewThreadInfoItemMemoryTracking.h"
+
+// Constants
+const TInt KMemSpyIdleResetListboxTimerPeriod = 250000;
+
+
+CMemSpyViewThreadInfoItemList::CMemSpyViewThreadInfoItemList( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThread& aThread )
+:   CMemSpyViewBase( aEngine, aObserver ), iThread( aThread )
+    {
+    iThread.Process().Open();
+    iThread.Open();
+    }
+
+
+CMemSpyViewThreadInfoItemList::~CMemSpyViewThreadInfoItemList()
+    {
+    delete iIdleResetListboxTimer;
+
+    TRAP_IGNORE( 
+        CMemSpyThreadInfoContainer& container = iThread.InfoContainerL();
+        container.ObserverRemove( *this );
+    );
+
+    if  ( iCurrentInfoItem )
+        {
+        iCurrentInfoItem->Close();
+        }
+
+    iThread.Process().Close();
+    iThread.Close();
+    }
+
+
+
+void CMemSpyViewThreadInfoItemList::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    _LIT( KTitle, "Thread Objects" );
+    SetTitleL( KTitle );
+    //
+    iIdleResetListboxTimer = CPeriodic::NewL( CActive::EPriorityIdle );
+    //
+    CMemSpyThreadInfoContainer& container = iThread.InfoContainerL();
+    container.ObserverAddL( *this );
+    //
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+    //
+    if  ( aSelectionRune )
+        {
+        CMemSpyThreadInfoItemBase* selectedItem = reinterpret_cast< CMemSpyThreadInfoItemBase* >( aSelectionRune );
+        const TInt index = container.InfoItemIndexByType( selectedItem->Type() );
+        if  ( index >= 0 && index < iListBox->Model()->NumberOfItems() )
+            {
+            iListBox->SetCurrentItemIndex( index );
+            HandleListBoxItemSelectedL( index );
+            }
+        }
+    else if ( container.MdcaCount() > 0 )
+        {
+        iListBox->SetCurrentItemIndex( 0 );
+        HandleListBoxItemSelectedL( 0 );
+        }
+    }
+
+
+const CMemSpyProcess& CMemSpyViewThreadInfoItemList::Process() const
+    {
+    return iThread.Process();
+    }
+
+
+const CMemSpyThread& CMemSpyViewThreadInfoItemList::Thread() const
+    {
+    return iThread;
+    }
+
+
+const CMemSpyThreadInfoItemBase& CMemSpyViewThreadInfoItemList::CurrentInfoItem() const
+    {
+    __ASSERT_ALWAYS( iCurrentInfoItem != NULL, User::Invariant() );
+    return *iCurrentInfoItem;
+    }
+
+
+void CMemSpyViewThreadInfoItemList::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewThreadInfoItemList::ViewType() const
+    {
+    return EMemSpyViewTypeThreadInfoItemList;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewThreadInfoItemList::PrepareParentViewL()
+    {
+    CMemSpyViewBase* parent = new(ELeave) CMemSpyViewThreads( iEngine, iObserver, iThread.Process() );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), &iThread );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewThreadInfoItemList::PrepareChildViewL()
+    {
+    __ASSERT_ALWAYS( iCurrentInfoItem != NULL, User::Invariant() );
+    CMemSpyViewBase* child = NULL;
+
+    // Decide what type of child view to create...
+    const TMemSpyThreadInfoItemType type = iCurrentInfoItem->Type();
+    //
+    switch( type )
+        {
+    case EMemSpyThreadInfoItemTypeHeap:
+        child = new(ELeave) CMemSpyViewThreadInfoItemHeap( iEngine, iObserver, iThread.InfoContainerL() );
+        break;
+    case EMemSpyThreadInfoItemTypeStack:
+        child = new(ELeave) CMemSpyViewThreadInfoItemStack( iEngine, iObserver, iThread.InfoContainerL() );
+        break;
+    case EMemSpyThreadInfoItemTypeChunk:
+        child = new(ELeave) CMemSpyViewThreadInfoItemChunk( iEngine, iObserver, iThread.InfoContainerL() );
+        break;
+    case EMemSpyThreadInfoItemTypeCodeSeg:
+        child = new(ELeave) CMemSpyViewThreadInfoItemCodeSeg( iEngine, iObserver, iThread.InfoContainerL() );
+        break;
+    case EMemSpyThreadInfoItemTypeServer:
+        child = new(ELeave) CMemSpyViewThreadInfoItemServer( iEngine, iObserver, iThread.InfoContainerL() );
+        break;
+    case EMemSpyThreadInfoItemTypeActiveObject:
+        child = new(ELeave) CMemSpyViewThreadInfoItemActiveObject( iEngine, iObserver, iThread.InfoContainerL() );
+        break;
+    case EMemSpyThreadInfoItemTypeGeneralInfo:
+        child = new(ELeave) CMemSpyViewThreadInfoItemGeneralInfo( iEngine, iObserver, iThread.InfoContainerL() );
+        break;
+    case EMemSpyThreadInfoItemTypeMemoryTracking:
+        child = new(ELeave) CMemSpyViewThreadInfoItemMemoryTracking( iEngine, iObserver, iThread.InfoContainerL() );
+        break;
+    case EMemSpyThreadInfoItemTypeSession:
+    case EMemSpyThreadInfoItemTypeSemaphore:
+    case EMemSpyThreadInfoItemTypeMutex:
+    case EMemSpyThreadInfoItemTypeTimer:
+    case EMemSpyThreadInfoItemTypeLDD:
+    case EMemSpyThreadInfoItemTypePDD:
+    case EMemSpyThreadInfoItemTypeLogicalChannel:
+    case EMemSpyThreadInfoItemTypeChangeNotifier:
+    case EMemSpyThreadInfoItemTypeUndertaker:
+    case EMemSpyThreadInfoItemTypeMessageQueue:
+    case EMemSpyThreadInfoItemTypeConditionalVariable:
+    case EMemSpyThreadInfoItemTypeOpenFiles:
+    case EMemSpyThreadInfoItemTypeOtherThreads:
+    case EMemSpyThreadInfoItemTypeOtherProcesses:
+    case EMemSpyThreadInfoItemTypeOwnedThreadHandles:
+    case EMemSpyThreadInfoItemTypeOwnedProcessHandles:
+        child = new(ELeave) CMemSpyViewThreadInfoItemGeneric( iEngine, iObserver, iThread.InfoContainerL(), type );
+        break;
+    
+    default:
+        __ASSERT_ALWAYS( EFalse, User::Panic( _L("MemSpy-View"), 0) );
+        break;
+        }
+    //
+    CleanupStack::PushL( child );
+    child->ConstructL( Rect(), *Parent() );
+    CleanupStack::Pop( child );
+    return child;
+    }
+
+
+TBool CMemSpyViewThreadInfoItemList::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = ETrue;
+    //
+    switch ( aCommand )
+        {
+	case EMemSpyCmdThreadInfoHandles:
+        OnCmdInfoHandlesL();
+        break;
+
+    default:
+        handled = CMemSpyViewBase::HandleCommandL( aCommand );
+        break;
+        }
+    //
+    return handled;
+    }
+
+    
+void CMemSpyViewThreadInfoItemList::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
+    {
+    if  ( aResourceId == R_MEMSPY_MENUPANE )
+        {
+        aMenuPane->SetItemDimmed( EMemSpyCmdThread, iThread.IsDead() );
+        }
+    else if ( aResourceId == MenuCascadeResourceId() )
+        {
+        // Always remove these items - they are only shown in the master thread view
+        aMenuPane->SetItemDimmed( EMemSpyCmdThreadSetPriority, ETrue );
+        aMenuPane->SetItemDimmed( EMemSpyCmdThreadEnd, ETrue );
+        }
+    }
+
+
+void CMemSpyViewThreadInfoItemList::OnCmdInfoHandlesL()
+    {
+    iThread.InfoContainerForceSyncronousConstructionL().PrintL();
+    }
+
+
+void CMemSpyViewThreadInfoItemList::HandleMemSpyEngineInfoContainerEventL( TEvent aEvent, TMemSpyThreadInfoItemType aType )
+    {
+    if  ( aEvent == EInfoItemChanged )
+        {
+        }
+    else if ( aEvent == EInfoItemDestroyed )
+        {
+        if  ( iCurrentInfoItem && iCurrentInfoItem->Type() == aType )
+            {
+            iCurrentInfoItem->Close();
+            iCurrentInfoItem = NULL;
+            }
+        }
+
+    iIdleResetListboxTimer->Cancel();
+    iIdleResetListboxTimer->Start( KMemSpyIdleResetListboxTimerPeriod, KMemSpyIdleResetListboxTimerPeriod, TCallBack( IdleUpdateListBoxModel, this ) );
+    }
+
+
+void CMemSpyViewThreadInfoItemList::SetListBoxModelL()
+    {
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( &iThread.InfoContainerL() );
+    listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+
+
+void CMemSpyViewThreadInfoItemList::HandleListBoxItemActionedL( TInt /*aIndex*/ )
+    {
+    // Notify observer about an item being 'fired'
+    ReportEventL( MMemSpyViewObserver::EEventItemActioned );
+    }
+
+
+void CMemSpyViewThreadInfoItemList::HandleListBoxItemSelectedL( TInt aIndex )
+    {
+    if  ( iCurrentInfoItem )
+        {
+        CMemSpyThreadInfoItemBase* item = iCurrentInfoItem;
+        iCurrentInfoItem = NULL;
+        item->Close();
+        }
+
+    // Identify the type of item to display...
+    iCurrentInfoItem = &iThread.InfoContainerL().Item( aIndex );
+    iCurrentInfoItem->Open();
+
+    // Notify observer about item selection
+    ReportEventL( MMemSpyViewObserver::EEventItemSelected );
+    }
+
+
+TInt CMemSpyViewThreadInfoItemList::IdleUpdateListBoxModel( TAny* aSelf )
+    {
+    CMemSpyViewThreadInfoItemList* self = reinterpret_cast< CMemSpyViewThreadInfoItemList* >( aSelf );
+    TRAP_IGNORE( self->DoIdleUpdateListBoxModelL() );
+    return EFalse;
+    }
+
+
+void CMemSpyViewThreadInfoItemList::DoIdleUpdateListBoxModelL()
+    {
+    CMemSpyThreadInfoContainer& container = iThread.InfoContainerL();
+
+    // Try to maintain current item selection if at all possible.
+    TMemSpyThreadInfoItemType type = EMemSpyThreadInfoItemTypeHeap;
+    if  ( iCurrentInfoItem )
+        {
+        type = iCurrentInfoItem->Type();
+        }
+   
+    // Update list box & model
+    SetListBoxModelL();
+    iListBox->HandleItemAdditionL();
+    RefreshL();
+    
+    // Try to select previous item if it is still available
+    const TInt index = container.InfoItemIndexByType( type );
+    if  ( index >= 0 && index < container.MdcaCount() )
+        {
+        iListBox->SetCurrentItemIndex( index );
+        HandleListBoxItemSelectedL( index );
+        }
+
+    iIdleResetListboxTimer->Cancel();
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewThreadInfoItemMemoryTracking.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,664 @@
+/*
+* 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 "MemSpyViewThreadInfoItemMemoryTracking.h"
+
+// System includes
+#include <AknQueryDialog.h>
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyengineprocessmemorytracker.h>
+#include <memspy/engine/memspyenginehelperprocess.h>
+
+// User includes
+#include "MemSpyContainerObserver.h"
+
+
+CMemSpyViewThreadInfoItemMemoryTracking::CMemSpyViewThreadInfoItemMemoryTracking( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer )
+:   CMemSpyViewThreadInfoItemGeneric( aEngine, aObserver, aContainer, EMemSpyThreadInfoItemTypeMemoryTracking )
+    {
+    }
+
+
+void CMemSpyViewThreadInfoItemMemoryTracking::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    CMemSpyViewThreadInfoItemGeneric::ConstructL( aRect, aContainer, aSelectionRune );
+    CMemSpyThreadInfoMemoryTracking* item = static_cast< CMemSpyThreadInfoMemoryTracking* >( iInfoItem );
+    item->TrackingObserverAddL( *this );
+
+    // Reset the title
+    _LIT( KCustomTitle, "Memory Statistics" );
+    SetTitleL( KCustomTitle );
+    
+    // Select the appropriate view
+    const TMemSpyViewType viewType = (TMemSpyViewType) ((TInt) aSelectionRune );
+    const TInt index = IndexByViewType( viewType );
+    //
+#ifdef _DEBUG
+    RDebug::Printf( "[MemSpy] CMemSpyViewThreadInfoItemMemoryTracking::ConstructL() - aSelectionRune: 0x%08x, viewType: %d, index: %d", aSelectionRune, viewType, index );
+#endif
+    //
+    if  ( index >= 0 && index < iListBox->Model()->NumberOfItems() )
+        {
+        iListBox->SetCurrentItemIndex( index );
+        HandleListBoxItemSelectedL( index );
+        }
+    }
+
+
+TMemSpyViewType CMemSpyViewThreadInfoItemMemoryTracking::ViewType() const
+    {
+    return EMemSpyViewTypeThreadInfoItemMemoryTrackingStatistics;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewThreadInfoItemMemoryTracking::PrepareParentViewL()
+    {
+    CMemSpyViewBase* parent = CMemSpyViewThreadInfoItemGeneric::PrepareParentViewL();
+    
+    // Stop observing changes
+    CMemSpyThreadInfoMemoryTracking* item = static_cast< CMemSpyThreadInfoMemoryTracking* >( iInfoItem );
+    item->TrackingObserverRemove( *this );
+
+    return parent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewThreadInfoItemMemoryTracking::PrepareChildViewL()
+    {
+    CMemSpyViewBase* child = NULL;
+    //
+    CMemSpyThreadInfoMemoryTracking* item = static_cast< CMemSpyThreadInfoMemoryTracking* >( iInfoItem );
+    const TInt index = iListBox->CurrentItemIndex();
+    if  ( index == 1 )
+        {
+        child = new(ELeave) CMemSpyViewThreadInfoItemMemoryTrackingCurrent( iEngine, iObserver, Container() );
+        }
+    else if ( index == 2 )
+        {
+        child = new(ELeave) CMemSpyViewThreadInfoItemMemoryTrackingHWM( iEngine, iObserver, Container() );
+        }
+    else if ( index == 3 )
+        {
+        child = new(ELeave) CMemSpyViewThreadInfoItemMemoryTrackingPeak( iEngine, iObserver, Container() );
+        }
+    //        
+    if  ( child )
+        {
+        CleanupStack::PushL( child );
+        child->ConstructL( Rect(), *Parent() );
+        CleanupStack::Pop( child );
+           
+        // Stop observing changes
+        item->TrackingObserverRemove( *this );
+        }
+    //
+    return child;
+    }
+
+
+TBool CMemSpyViewThreadInfoItemMemoryTracking::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = ETrue;
+    //
+    switch ( aCommand )
+        {
+    case EMemSpyCmdMemoryTrackingStart:
+        OnCmdTrackingStartL();
+        break;
+    case EMemSpyCmdMemoryTrackingStop:
+        OnCmdTrackingStopL();
+        break;
+    case EMemSpyCmdMemoryTrackingHWMReset:
+        OnCmdHWMResetL();
+        break;
+    case EMemSpyCmdMemoryTrackingTotalWithSharedMem:
+        OnCmdTotalWithSharedMemL();
+        break;
+    case EMemSpyCmdMemoryTrackingTotalWithoutSharedMem:
+        OnCmdTotalWithoutSharedMemL();
+        break;
+    default:
+        handled = CMemSpyViewBase::HandleCommandL( aCommand );
+        break;
+        }
+    //
+    return handled;
+    }
+
+
+TInt CMemSpyViewThreadInfoItemMemoryTracking::IndexByViewType( TMemSpyViewType aType )
+    {
+    TInt index = 0;
+    //
+    switch( aType )
+        {
+    default:
+    case EMemSpyViewTypeThreadInfoItemMemoryTrackingStatisticsCurrent:
+        index = 1;
+        break;
+    case EMemSpyViewTypeThreadInfoItemMemoryTrackingStatisticsHWM:
+        index = 2;
+        break;
+    case EMemSpyViewTypeThreadInfoItemMemoryTrackingStatisticsPeak:
+        index = 3;
+        break;
+        }
+    //
+    return index;
+    }
+
+
+void CMemSpyViewThreadInfoItemMemoryTracking::HandleListBoxItemActionedL( TInt aIndex )
+    {
+    if  ( aIndex == 0 )
+        {
+        CMemSpyThreadInfoMemoryTracking* item = static_cast< CMemSpyThreadInfoMemoryTracking* >( iInfoItem );
+        if  ( item->TrackingActive() )
+            {
+            OnCmdTrackingStopL();
+            }
+        else
+            {
+            OnCmdTrackingStartL();
+            }
+        }
+
+    // Notify observer about item selection
+    ReportEventL( MMemSpyViewObserver::EEventItemActioned );
+
+    // Ensure we refresh the listbox content
+    iListBox->DrawDeferred();
+    }
+
+
+void CMemSpyViewThreadInfoItemMemoryTracking::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    iListBox->DrawDeferred();
+    }
+
+
+void CMemSpyViewThreadInfoItemMemoryTracking::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
+    {
+    if  ( aResourceId == MenuCascadeResourceId() )
+        {
+        CMemSpyThreadInfoMemoryTracking* item = static_cast< CMemSpyThreadInfoMemoryTracking* >( iInfoItem );
+        //
+        if  ( !item->TrackerExists() || item->TrackingActive() )
+            {
+            aMenuPane->SetItemDimmed( EMemSpyCmdMemoryTrackingStart, ETrue );
+            }
+        else
+            {
+            aMenuPane->SetItemDimmed( EMemSpyCmdMemoryTrackingStop, ETrue );
+            }
+        //
+        if ( item->TotalIncludesSharedMemory() )
+            {
+            aMenuPane->SetItemDimmed( EMemSpyCmdMemoryTrackingTotalWithSharedMem, ETrue );
+            }
+        else
+            {
+            aMenuPane->SetItemDimmed( EMemSpyCmdMemoryTrackingTotalWithoutSharedMem, ETrue );
+            }
+
+        aMenuPane->SetItemDimmed( EMemSpyCmdMemoryTrackingHWMReset, Thread().IsDead() );
+        }
+    else if ( aResourceId == R_MEMSPY_MENUPANE )
+        {
+        aMenuPane->SetItemDimmed( EMemSpyCmdMemoryTracking, Thread().IsDead() );
+        aMenuPane->SetItemDimmed( EMemSpyCmdMemoryTrackingAutoStart, Thread().IsDead() );
+        }
+    }
+
+
+void CMemSpyViewThreadInfoItemMemoryTracking::HandleMemoryTrackingStartedL()
+    {
+    RefreshL();
+    }
+
+
+void CMemSpyViewThreadInfoItemMemoryTracking::HandleMemoryTrackingStoppedL()
+    {
+    RefreshL();
+    }
+
+
+void CMemSpyViewThreadInfoItemMemoryTracking::HandleMemoryChangedL( const TProcessId& /*aPid*/, const TMemSpyDriverProcessInspectionInfo& /*aCurrentInfo*/, const TMemSpyDriverProcessInspectionInfo& /*aHWMInfoIncShared*/, const TMemSpyDriverProcessInspectionInfo& /*aHWMInfoExcShared*/ )
+    {
+#ifdef _DEBUG
+    RDebug::Printf( "[MemSpy] CMemSpyViewThreadInfoItemMemoryTracking::HandleMemoryChangedL() - START - this: 0x%08x", this );
+#endif 
+
+    CMemSpyViewBase::RefreshL();
+    iListBox->DrawDeferred();
+
+#ifdef _DEBUG
+    RDebug::Printf( "[MemSpy] CMemSpyViewThreadInfoItemMemoryTracking::HandleMemoryChangedL() - END - this: 0x%08x", this );
+#endif 
+    }
+
+
+void CMemSpyViewThreadInfoItemMemoryTracking::OnCmdTrackingStartL()
+    {
+    CMemSpyThreadInfoMemoryTracking* item = static_cast< CMemSpyThreadInfoMemoryTracking* >( iInfoItem );
+    item->TrackingStartL();
+    }
+
+
+void CMemSpyViewThreadInfoItemMemoryTracking::OnCmdTrackingStopL()
+    {
+    CMemSpyThreadInfoMemoryTracking* item = static_cast< CMemSpyThreadInfoMemoryTracking* >( iInfoItem );
+    item->TrackingStopL();
+    }
+
+
+void CMemSpyViewThreadInfoItemMemoryTracking::OnCmdHWMResetL()
+    {
+    CMemSpyThreadInfoMemoryTracking* item = static_cast< CMemSpyThreadInfoMemoryTracking* >( iInfoItem );
+    item->TrackingResetHWML();
+    RefreshL();
+    }
+
+
+void CMemSpyViewThreadInfoItemMemoryTracking::OnCmdTotalWithSharedMemL()
+    {
+    CMemSpyThreadInfoMemoryTracking* item = static_cast< CMemSpyThreadInfoMemoryTracking* >( iInfoItem );
+    item->TrackingSetTotalIncludesSharedMemoryL( ETrue );
+    RefreshL();
+    }
+
+
+void CMemSpyViewThreadInfoItemMemoryTracking::OnCmdTotalWithoutSharedMemL()
+    {
+    CMemSpyThreadInfoMemoryTracking* item = static_cast< CMemSpyThreadInfoMemoryTracking* >( iInfoItem );
+    item->TrackingSetTotalIncludesSharedMemoryL( EFalse );
+    RefreshL();
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+CMemSpyViewThreadInfoItemMemoryTrackingCurrent::CMemSpyViewThreadInfoItemMemoryTrackingCurrent( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer )
+:   CMemSpyViewThreadInfoItemGeneric( aEngine, aObserver, aContainer, EMemSpyThreadInfoItemTypeMemoryTracking )
+    {
+    }
+
+
+void CMemSpyViewThreadInfoItemMemoryTrackingCurrent::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    CMemSpyViewThreadInfoItemGeneric::ConstructL( aRect, aContainer, aSelectionRune );
+
+    CMemSpyThreadInfoMemoryTracking* item = static_cast< CMemSpyThreadInfoMemoryTracking* >( iInfoItem );
+    item->TrackingObserverAddL( *this );
+
+    // Reset the title
+    _LIT( KCustomTitle, "Current Statistics" );
+    SetTitleL( KCustomTitle );
+    }
+
+
+TMemSpyViewType CMemSpyViewThreadInfoItemMemoryTrackingCurrent::ViewType() const
+    {
+    return EMemSpyViewTypeThreadInfoItemMemoryTrackingStatisticsCurrent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewThreadInfoItemMemoryTrackingCurrent::PrepareParentViewL()
+    {
+    CMemSpyViewThreadInfoItemMemoryTracking* parent = new(ELeave) CMemSpyViewThreadInfoItemMemoryTracking( iEngine, iObserver, Container() );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
+    CleanupStack::Pop( parent );
+    
+    // Stop observing changes
+    CMemSpyThreadInfoMemoryTracking* item = static_cast< CMemSpyThreadInfoMemoryTracking* >( iInfoItem );
+    item->TrackingObserverRemove( *this );
+
+    return parent;
+    }
+
+
+void CMemSpyViewThreadInfoItemMemoryTrackingCurrent::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+void CMemSpyViewThreadInfoItemMemoryTrackingCurrent::SetListBoxModelL()
+    {
+    CMemSpyThreadInfoMemoryTracking* item = static_cast< CMemSpyThreadInfoMemoryTracking* >( iInfoItem );
+    MDesCArray* model = &item->InfoCurrent();
+
+    // Set up list box
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( model );
+    listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+    
+
+void CMemSpyViewThreadInfoItemMemoryTrackingCurrent::HandleMemoryChangedL( const TProcessId& /*aPid*/, const TMemSpyDriverProcessInspectionInfo& /*aCurrentInfo*/, const TMemSpyDriverProcessInspectionInfo& /*aHWMInfoIncShared*/, const TMemSpyDriverProcessInspectionInfo& /*aHWMInfoExcShared*/ )
+    {
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+CMemSpyViewThreadInfoItemMemoryTrackingHWM::CMemSpyViewThreadInfoItemMemoryTrackingHWM( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer )
+:   CMemSpyViewThreadInfoItemGeneric( aEngine, aObserver, aContainer, EMemSpyThreadInfoItemTypeMemoryTracking )
+    {
+    }
+
+
+void CMemSpyViewThreadInfoItemMemoryTrackingHWM::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    CMemSpyViewThreadInfoItemGeneric::ConstructL( aRect, aContainer, aSelectionRune );
+
+    CMemSpyThreadInfoMemoryTracking* item = static_cast< CMemSpyThreadInfoMemoryTracking* >( iInfoItem );
+    item->TrackingObserverAddL( *this );
+
+    // Reset the title
+    _LIT( KCustomTitle, "HWM Statistics" );
+    SetTitleL( KCustomTitle );
+    }
+
+
+TMemSpyViewType CMemSpyViewThreadInfoItemMemoryTrackingHWM::ViewType() const
+    {
+    return EMemSpyViewTypeThreadInfoItemMemoryTrackingStatisticsHWM;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewThreadInfoItemMemoryTrackingHWM::PrepareParentViewL()
+    {
+    CMemSpyViewThreadInfoItemMemoryTracking* parent = new(ELeave) CMemSpyViewThreadInfoItemMemoryTracking( iEngine, iObserver, Container() );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
+    CleanupStack::Pop( parent );
+    
+    // Stop observing changes
+    CMemSpyThreadInfoMemoryTracking* item = static_cast< CMemSpyThreadInfoMemoryTracking* >( iInfoItem );
+    item->TrackingObserverRemove( *this );
+
+    return parent;
+    }
+
+
+TBool CMemSpyViewThreadInfoItemMemoryTrackingHWM::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = ETrue;
+    //
+    switch ( aCommand )
+        {
+    case EMemSpyCmdMemoryTrackingHWMReset:
+        OnCmdHWMResetL();
+        break;
+    default:
+        handled = CMemSpyViewBase::HandleCommandL( aCommand );
+        break;
+        }
+    //
+    return handled;
+    }
+
+
+void CMemSpyViewThreadInfoItemMemoryTrackingHWM::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+void CMemSpyViewThreadInfoItemMemoryTrackingHWM::SetListBoxModelL()
+    {
+    CMemSpyThreadInfoMemoryTracking* item = static_cast< CMemSpyThreadInfoMemoryTracking* >( iInfoItem );
+    MDesCArray* model = &item->InfoHWM();
+
+    // Set up list box
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( model );
+    listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+    
+
+void CMemSpyViewThreadInfoItemMemoryTrackingHWM::HandleMemoryChangedL( const TProcessId& /*aPid*/, const TMemSpyDriverProcessInspectionInfo& /*aCurrentInfo*/, const TMemSpyDriverProcessInspectionInfo& /*aHWMInfoIncShared*/, const TMemSpyDriverProcessInspectionInfo& /*aHWMInfoExcShared*/ )
+    {
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+void CMemSpyViewThreadInfoItemMemoryTrackingHWM::OnCmdHWMResetL()
+    {
+    CMemSpyThreadInfoMemoryTracking* item = static_cast< CMemSpyThreadInfoMemoryTracking* >( iInfoItem );
+    item->TrackingResetHWML();
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+CMemSpyViewThreadInfoItemMemoryTrackingPeak::CMemSpyViewThreadInfoItemMemoryTrackingPeak( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer )
+:   CMemSpyViewThreadInfoItemGeneric( aEngine, aObserver, aContainer, EMemSpyThreadInfoItemTypeMemoryTracking )
+    {
+    }
+
+
+void CMemSpyViewThreadInfoItemMemoryTrackingPeak::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    CMemSpyViewThreadInfoItemGeneric::ConstructL( aRect, aContainer, aSelectionRune );
+
+    CMemSpyThreadInfoMemoryTracking* item = static_cast< CMemSpyThreadInfoMemoryTracking* >( iInfoItem );
+    item->TrackingObserverAddL( *this );
+
+    // Reset the title
+    _LIT( KCustomTitle, "Peak Statistics" );
+    SetTitleL( KCustomTitle );
+    }
+
+
+TMemSpyViewType CMemSpyViewThreadInfoItemMemoryTrackingPeak::ViewType() const
+    {
+    return EMemSpyViewTypeThreadInfoItemMemoryTrackingStatisticsPeak;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewThreadInfoItemMemoryTrackingPeak::PrepareParentViewL()
+    {
+    CMemSpyViewThreadInfoItemMemoryTracking* parent = new(ELeave) CMemSpyViewThreadInfoItemMemoryTracking( iEngine, iObserver, Container() );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
+    CleanupStack::Pop( parent );
+    
+    // Stop observing changes
+    CMemSpyThreadInfoMemoryTracking* item = static_cast< CMemSpyThreadInfoMemoryTracking* >( iInfoItem );
+    item->TrackingObserverRemove( *this );
+
+    return parent;
+    }
+
+
+TBool CMemSpyViewThreadInfoItemMemoryTrackingPeak::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = ETrue;
+    //
+    switch ( aCommand )
+        {
+    default:
+        handled = CMemSpyViewBase::HandleCommandL( aCommand );
+        break;
+        }
+    //
+    return handled;
+    }
+
+
+void CMemSpyViewThreadInfoItemMemoryTrackingPeak::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+void CMemSpyViewThreadInfoItemMemoryTrackingPeak::SetListBoxModelL()
+    {
+    CMemSpyThreadInfoMemoryTracking* item = static_cast< CMemSpyThreadInfoMemoryTracking* >( iInfoItem );
+    MDesCArray* model = &item->InfoPeak();
+
+    // Set up list box
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( model );
+    listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+    
+
+void CMemSpyViewThreadInfoItemMemoryTrackingPeak::HandleMemoryChangedL( const TProcessId& /*aPid*/, const TMemSpyDriverProcessInspectionInfo& /*aCurrentInfo*/, const TMemSpyDriverProcessInspectionInfo& /*aHWMInfoIncShared*/, const TMemSpyDriverProcessInspectionInfo& /*aHWMInfoExcShared*/ )
+    {
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewThreadInfoItemServer.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,391 @@
+/*
+* 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 "MemSpyViewThreadInfoItemServer.h"
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyenginehelperprocess.h>
+#include <memspy/engine/memspyenginehelperheap.h>
+#include <memspy/engine/memspyenginehelperserver.h>
+
+// User includes
+#include "MemSpyContainerObserver.h"
+
+// Constants
+const TInt KMemSpyServerSessionsIndex = 2;
+
+
+
+CMemSpyViewThreadInfoItemServer::CMemSpyViewThreadInfoItemServer( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer )
+:   CMemSpyViewThreadInfoItemGeneric( aEngine, aObserver, aContainer, EMemSpyThreadInfoItemTypeServer )
+    {
+    }
+
+
+void CMemSpyViewThreadInfoItemServer::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    // Causes list of server's to be prepared
+    CMemSpyViewThreadInfoItemGeneric::ConstructL( aRect, aContainer, aSelectionRune );
+
+    _LIT( KTitle, "Server List" );
+    SetTitleL( KTitle );
+
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyViewThreadInfoItemServer::ConstructL() - aSelectionRune: 0x%08x", aSelectionRune );
+#endif
+
+    // Try to select the correct server
+    CMemSpyThreadInfoHandleObjectBase* infoItem = static_cast< CMemSpyThreadInfoHandleObjectBase* >( iInfoItem );
+    TInt selectedIndex = 0;
+    if  ( aSelectionRune )
+        {
+        // Treat the rune as a handle, and try to look it up
+        selectedIndex = infoItem->DetailsIndexByHandle( aSelectionRune );
+        }
+
+    // Select item
+    if  ( infoItem->DetailsCount() > 0 )
+        {
+        iListBox->SetCurrentItemIndex( selectedIndex );
+        HandleListBoxItemSelectedL( selectedIndex );
+        }
+    }
+
+
+TBool CMemSpyViewThreadInfoItemServer::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = CMemSpyViewBase::HandleCommandL( aCommand );
+    return handled;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewThreadInfoItemServer::PrepareChildViewL()
+    {
+    CMemSpyViewThreadInfoItemServerDetails* child = new(ELeave) CMemSpyViewThreadInfoItemServerDetails( iEngine, iObserver, iContainer, iCurrentInfoItemDetails );
+    CleanupStack::PushL( child );
+    child->ConstructL( Rect(), *Parent() );
+    CleanupStack::Pop( child );
+    return child;
+    }
+
+
+void CMemSpyViewThreadInfoItemServer::HandleListBoxItemSelectedL( TInt aIndex )
+    {
+    // Identify the type of item to display...
+    CMemSpyThreadInfoHandleObjectBase* infoItem = static_cast< CMemSpyThreadInfoHandleObjectBase* >( iInfoItem );
+    iCurrentInfoItemDetails = infoItem->DetailsAt( aIndex );
+
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyViewThreadInfoItemServer::HandleListBoxItemSelectedL() - iCurrentInfoItemDetails.iHandle: 0x%08x", iCurrentInfoItemDetails.iHandle );
+#endif
+
+    // Notify observer about item selection
+    ReportEventL( MMemSpyViewObserver::EEventItemSelected );
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+CMemSpyViewThreadInfoItemServerDetails::CMemSpyViewThreadInfoItemServerDetails( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer, const TMemSpyDriverHandleInfoGeneric& aInfoItemDetails )
+:   CMemSpyViewThreadInfoItemGeneric( aEngine, aObserver, aContainer, EMemSpyThreadInfoItemTypeServer ), iInfoItemDetails( aInfoItemDetails )
+    {
+    }
+
+
+void CMemSpyViewThreadInfoItemServerDetails::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    // Causes list of server's to be prepared
+    CMemSpyViewThreadInfoItemGeneric::ConstructL( aRect, aContainer, aSelectionRune );
+
+    _LIT( KTitle, "Server Details" );
+    SetTitleL( KTitle );
+
+    // Try to select the correct server
+    TInt selectedIndex = 0;
+    if  ( aSelectionRune )
+        {
+        // Presence of non-null item means that we came from the "Server sessions" list
+        selectedIndex = KMemSpyServerSessionsIndex;
+        }
+
+    // Select item
+    iListBox->SetCurrentItemIndex( selectedIndex );
+    HandleListBoxItemSelectedL( selectedIndex );
+    }
+
+
+TBool CMemSpyViewThreadInfoItemServerDetails::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = CMemSpyViewBase::HandleCommandL( aCommand );
+    return handled;
+    }
+
+
+TMemSpyViewType CMemSpyViewThreadInfoItemServerDetails::ViewType() const
+    {
+    return EMemSpyViewTypeThreadInfoItemServerDetails;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewThreadInfoItemServerDetails::PrepareChildViewL()
+    {
+    CMemSpyViewBase* child = NULL;
+    const TInt currentIndex = iListBox->CurrentItemIndex();
+    //
+    if  ( currentIndex == KMemSpyServerSessionsIndex )
+        {
+        CMemSpyViewThreadInfoItemServerSessions* serverSessions = new(ELeave) CMemSpyViewThreadInfoItemServerSessions( iEngine, iObserver, iInfoItem->Container(), iInfoItemDetails );
+        CleanupStack::PushL( serverSessions );
+        serverSessions->ConstructL( Rect(), *Parent(), NULL );
+        CleanupStack::Pop( serverSessions );
+        child = serverSessions;
+        }
+    //
+    return child;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewThreadInfoItemServerDetails::PrepareParentViewL()
+    {
+    CMemSpyViewThreadInfoItemServer* parent = new(ELeave) CMemSpyViewThreadInfoItemServer( iEngine, iObserver, iInfoItem->Container() );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), iInfoItemDetails.iHandle );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+void CMemSpyViewThreadInfoItemServerDetails::SetListBoxModelL()
+    {
+    CDesCArrayFlat* model = new(ELeave) CDesCArrayFlat(4);
+    CleanupStack::PushL( model );
+
+    TBuf<KMaxFullName + 1> item;
+
+    // 1st item = session type
+    const TPtrC pServerSessionType = CMemSpyThreadInfoServer::SessionType( iInfoItemDetails.iSessionType );
+    _LIT(KItem1Format, "\tServer Type\t\t%S");
+    item.Format( KItem1Format, &pServerSessionType );
+    model->AppendL( item );
+
+    // 2nd item = session count
+    _LIT(KItem2Format, "\tConnected Sessions\t\t%d");
+    item.Format( KItem2Format, iInfoItemDetails.iCount );
+    model->AppendL( item );
+
+    // 3rd item = view sessions
+    if  ( iInfoItem->Container().MdcaCount() > 0 )
+        {
+        _LIT(KItem3Format, "\tView Sessions");
+        model->AppendL( KItem3Format );
+        }
+
+    // Set up list box
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( model );
+    listbox->Model()->SetOwnershipType( ELbmOwnsItemArray );
+    CleanupStack::Pop( model );
+    }
+
+
+void CMemSpyViewThreadInfoItemServerDetails::HandleListBoxItemActionedL( TInt /*aIndex*/ )
+    {
+    // Notify observer about an item being 'fired'
+    ReportEventL( MMemSpyViewObserver::EEventItemActioned );
+    }
+
+
+void CMemSpyViewThreadInfoItemServerDetails::HandleListBoxItemSelectedL( TInt /*aIndex*/ )
+    {
+    // Notify observer about item selection
+    ReportEventL( MMemSpyViewObserver::EEventItemSelected );
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+CMemSpyViewThreadInfoItemServerSessions::CMemSpyViewThreadInfoItemServerSessions( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer, const TMemSpyDriverHandleInfoGeneric& aInfoItemDetails )
+:   CMemSpyViewThreadInfoItemGeneric( aEngine, aObserver, aContainer, EMemSpyThreadInfoItemTypeServer ), iInfoItemDetails( aInfoItemDetails )
+    {
+    }
+
+
+void CMemSpyViewThreadInfoItemServerSessions::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    CMemSpyViewThreadInfoItemGeneric::ConstructL( aRect, aContainer, aSelectionRune );
+    //
+    _LIT( KTitle, "Connected Session List" );
+    SetTitleL( KTitle );
+    }
+
+
+TBool CMemSpyViewThreadInfoItemServerSessions::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = CMemSpyViewBase::HandleCommandL( aCommand );
+    return handled;
+    }
+
+
+TMemSpyViewType CMemSpyViewThreadInfoItemServerSessions::ViewType() const
+    {
+    return EMemSpyViewTypeThreadInfoItemServerSessions;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewThreadInfoItemServerSessions::PrepareParentViewL()
+    {
+    CMemSpyViewThreadInfoItemServerDetails* parent = new(ELeave) CMemSpyViewThreadInfoItemServerDetails( iEngine, iObserver, iInfoItem->Container(), iInfoItemDetails );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), this );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+void CMemSpyViewThreadInfoItemServerSessions::SetListBoxModelL()
+    {
+    CDesCArrayFlat* model = new(ELeave) CDesCArrayFlat(4);
+    CleanupStack::PushL( model );
+
+    // Get handles
+    RArray<TMemSpyDriverServerSessionInfo> sessions;
+    CleanupClosePushL( sessions );
+    iEngine.HelperServer().GetServerSessionsL( iInfoItemDetails, sessions );
+
+    // Prepare items
+    TBuf<KMaxFullName + 1> item;
+    const TInt count = sessions.Count();
+    for( TInt i=0; i<count; i++ )
+        {
+        _LIT(KInsertTab, "\t");
+
+        const TMemSpyDriverServerSessionInfo& session = sessions[ i ];
+        item.Zero();
+
+        if  ( session.iOwnerType == TMemSpyDriverServerSessionInfo::EOwnerThread )
+            {
+            // Find the thread object
+            CMemSpyThread* thread = NULL;
+            CMemSpyProcess* process = NULL;
+            //
+            const TInt error = iEngine.Container().ProcessAndThreadByThreadId( session.iOwnerId, process, thread );
+            //
+            if  ( error == KErrNone )
+                {
+                item.Append( process->Name() );
+                item.Append( KInsertTab );
+                item.Append( KInsertTab );
+                item.Append( thread->Name() );
+                }
+            }
+        else if ( session.iOwnerType == TMemSpyDriverServerSessionInfo::EOwnerProcess )
+            {
+            // Find the process object
+            CMemSpyProcess* process = NULL;
+            TRAPD( error, process = &iEngine.Container().ProcessByIdL( session.iOwnerId ) );
+            if  ( error == KErrNone )
+                {
+                item.Append( process->Name() );
+                }
+            }
+
+        if  ( !item.Length() )
+            {
+            // Fall-back case
+            item.Copy( session.iName );
+            }
+
+        // Add item
+        item.Insert( 0, KInsertTab );
+        model->AppendL( item );
+        }
+    CleanupStack::PopAndDestroy( &sessions );
+
+    // Set up list box
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( model );
+    listbox->Model()->SetOwnershipType( ELbmOwnsItemArray );
+    CleanupStack::Pop( model );
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewThreadInfoItemStack.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,94 @@
+/*
+* 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 "MemSpyViewThreadInfoItemStack.h"
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyenginehelperprocess.h>
+#include <memspy/engine/memspyenginehelperstack.h>
+
+// User includes
+#include "MemSpyContainerObserver.h"
+#include "MemSpyViewThreads.h"
+#include "MemSpyViewThreadInfoItemHeap.h"
+
+
+
+CMemSpyViewThreadInfoItemStack::CMemSpyViewThreadInfoItemStack( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer )
+:   CMemSpyViewThreadInfoItemGeneric( aEngine, aObserver, aContainer, EMemSpyThreadInfoItemTypeStack )
+    {
+    }
+
+
+TBool CMemSpyViewThreadInfoItemStack::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = ETrue;
+    //
+    switch ( aCommand )
+        {
+#ifndef __WINS__
+	case EMemSpyCmdStackDataUser:
+        OnCmdStackDataUserL();
+		break;
+	case EMemSpyCmdStackDataKernel:
+        OnCmdStackDataKernelL();
+		break;
+#endif
+	case EMemSpyCmdStackInfoThread:
+        OnCmdStackInfoL();
+		break;
+
+    default:
+        handled = CMemSpyViewBase::HandleCommandL( aCommand );
+        break;
+        }
+    //
+    return handled;
+    }
+
+
+void CMemSpyViewThreadInfoItemStack::OnCmdStackInfoL()
+    {
+    iEngine.HelperStack().OutputStackInfoL( Thread() );
+    }
+
+
+void CMemSpyViewThreadInfoItemStack::OnCmdStackDataUserL()
+    {
+    iEngine.HelperStack().OutputStackDataL( Thread(), EMemSpyDriverDomainUser );
+    }
+
+
+void CMemSpyViewThreadInfoItemStack::OnCmdStackDataKernelL()
+    {
+    iEngine.HelperStack().OutputStackDataL( Thread(), EMemSpyDriverDomainKernel );
+    }    
+
+
+void CMemSpyViewThreadInfoItemStack::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
+    {
+    if  ( aResourceId == R_MEMSPY_MENUPANE )
+        {
+        aMenuPane->SetItemDimmed( EMemSpyCmdStack, Thread().IsDead() );
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewThreads.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,355 @@
+/*
+* 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 "MemSpyViewThreads.h"
+
+// System includes
+#include <AknQueryDialog.h>
+#include <memspyui.rsg>
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyenginehelperprocess.h>
+
+// User includes
+#include "MemSpyContainerObserver.h"
+#include "MemSpyViewProcesses.h"
+#include "MemSpyViewThreadInfoItemList.h"
+
+
+
+
+CMemSpyViewThreads::CMemSpyViewThreads( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyProcess& aProcess )
+:   CMemSpyViewBase( aEngine, aObserver ), iParentProcess( aProcess )
+    {
+    iParentProcess.Open();
+    }
+
+
+CMemSpyViewThreads::~CMemSpyViewThreads()
+    {
+    iParentProcess.Close();
+    if  ( iCurrentThread )
+        {
+        iCurrentThread->Close();
+        }
+    }
+
+ 
+void CMemSpyViewThreads::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    _LIT( KTitle, "Threads" );
+    SetTitleL( KTitle );
+    //
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+    //
+    if  ( aSelectionRune )
+        {
+        CMemSpyThread* selectedItem = reinterpret_cast< CMemSpyThread* >( aSelectionRune );
+        const TInt index = iParentProcess.ThreadIndexById( selectedItem->Id() );
+        if  ( index >= 0 && index < iListBox->Model()->NumberOfItems() )
+            {
+            iListBox->SetCurrentItemIndex( index );
+            HandleListBoxItemSelectedL( index );
+            }
+        }
+    else if ( iParentProcess.Count() > 0 )
+        {
+        iListBox->SetCurrentItemIndex( 0 );
+        HandleListBoxItemSelectedL( 0 );
+        }
+    }
+
+
+const CMemSpyProcess& CMemSpyViewThreads::Process() const
+    {
+    return iParentProcess;
+    }
+
+
+CMemSpyThread& CMemSpyViewThreads::CurrentThread()
+    {
+    __ASSERT_ALWAYS( iCurrentThread != NULL, User::Invariant() );
+    return *iCurrentThread;
+    }
+
+
+void CMemSpyViewThreads::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewThreads::ViewType() const
+    {
+    return EMemSpyViewTypeThreads;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewThreads::PrepareParentViewL()
+    {
+    CMemSpyViewProcesses* parent = new(ELeave) CMemSpyViewProcesses( iEngine, iObserver, iParentProcess );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), &iParentProcess );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewThreads::PrepareChildViewL()
+    {
+    CMemSpyViewThreadInfoItemList* child = new(ELeave) CMemSpyViewThreadInfoItemList( iEngine, iObserver, *iCurrentThread );
+    CleanupStack::PushL( child );
+    child->ConstructL( Rect(), *Parent() );
+    CleanupStack::Pop( child );
+    return child;
+    }
+
+
+void CMemSpyViewThreads::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
+    {
+    if  ( aResourceId == R_MEMSPY_MENUPANE )
+        {
+        CMemSpyThread& thread = CurrentThread();
+        aMenuPane->SetItemDimmed( EMemSpyCmdThread, thread.IsDead() );
+        }
+    }
+
+
+TBool CMemSpyViewThreads::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = ETrue;
+    //
+    switch ( aCommand )
+        {
+    case EMemSpyCmdThreadEndKill:
+        OnCmdEndKillL();
+		break;
+    case EMemSpyCmdThreadEndTerminate:
+        OnCmdEndTerminateL();
+		break;
+    case EMemSpyCmdThreadEndPanic:
+        OnCmdEndPanicL();
+		break;
+	case EMemSpyCmdThreadSetPriorityAbsoluteVeryLow:
+	case EMemSpyCmdThreadSetPriorityAbsoluteLowNormal:
+	case EMemSpyCmdThreadSetPriorityAbsoluteLow:
+	case EMemSpyCmdThreadSetPriorityAbsoluteBackgroundNormal:
+	case EMemSpyCmdThreadSetPriorityAbsoluteBackground:
+	case EMemSpyCmdThreadSetPriorityAbsoluteForegroundNormal:
+	case EMemSpyCmdThreadSetPriorityAbsoluteForeground:
+	case EMemSpyCmdThreadSetPriorityAbsoluteHighNormal:
+	case EMemSpyCmdThreadSetPriorityAbsoluteHigh:
+	case EMemSpyCmdThreadSetPriorityAbsoluteRealTime1:
+	case EMemSpyCmdThreadSetPriorityAbsoluteRealTime2:
+	case EMemSpyCmdThreadSetPriorityAbsoluteRealTime3:
+	case EMemSpyCmdThreadSetPriorityAbsoluteRealTime4:
+	case EMemSpyCmdThreadSetPriorityAbsoluteRealTime5:
+	case EMemSpyCmdThreadSetPriorityAbsoluteRealTime6:
+	case EMemSpyCmdThreadSetPriorityAbsoluteRealTime7: 
+	case EMemSpyCmdThreadSetPriorityAbsoluteRealTime8:
+        OnCmdSetPriorityL( aCommand );
+        break;
+
+    case EMemSpyCmdThreadInfoHandles:
+        OnCmdInfoHandlesL();
+        break;
+
+    default:
+        handled = CMemSpyViewBase::HandleCommandL( aCommand );
+        break;
+        }
+    //
+    return handled;
+    }
+
+
+void CMemSpyViewThreads::OnCmdEndKillL()
+    {
+    TBool doTerminate = ETrue;
+    CMemSpyThread& thread = CurrentThread();
+    //
+    if  ( thread.IsSystemPermanent() )
+        {
+        CAknQueryDialog* importDialog = CAknQueryDialog::NewL();
+        doTerminate = ( importDialog->ExecuteLD( R_MEMSPY_PANIC_SYSTEM_CRITICAL_THREAD_OR_PROCESS ) );
+        }
+    //
+    if  ( doTerminate )
+        {
+        thread.KillL();
+        RefreshL();
+        }
+    }
+
+
+void CMemSpyViewThreads::OnCmdEndTerminateL()
+    {
+    TBool doTerminate = ETrue;
+    CMemSpyThread& thread = CurrentThread();
+    //
+    if  ( thread.IsSystemPermanent() || thread.IsSystemCritical() )
+        {
+        CAknQueryDialog* importDialog = CAknQueryDialog::NewL();
+        doTerminate = ( importDialog->ExecuteLD( R_MEMSPY_PANIC_SYSTEM_CRITICAL_THREAD_OR_PROCESS ) );
+        }
+    //
+    if  ( doTerminate )
+        {
+        thread.TerminateL();
+        RefreshL();
+        }
+    }
+
+
+void CMemSpyViewThreads::OnCmdEndPanicL()
+    {
+    TBool doTerminate = ETrue;
+    CMemSpyThread& thread = CurrentThread();
+    //
+    if  ( thread.IsSystemPermanent() || thread.IsSystemCritical() )
+        {
+        CAknQueryDialog* importDialog = CAknQueryDialog::NewL();
+        doTerminate = ( importDialog->ExecuteLD( R_MEMSPY_PANIC_SYSTEM_CRITICAL_THREAD_OR_PROCESS ) );
+        }
+    //
+    if  ( doTerminate )
+        {
+        thread.PanicL();
+        RefreshL();
+        }
+    }
+
+
+void CMemSpyViewThreads::OnCmdSetPriorityL( TInt aCommand )
+    {
+    TThreadPriority pri = EPriorityAbsoluteBackground;
+    switch( aCommand )
+        {
+	case EMemSpyCmdThreadSetPriorityAbsoluteVeryLow:
+        pri = EPriorityAbsoluteVeryLow;
+        break;
+	case EMemSpyCmdThreadSetPriorityAbsoluteLowNormal:
+        pri = EPriorityAbsoluteLowNormal;
+        break;
+	case EMemSpyCmdThreadSetPriorityAbsoluteLow:
+        pri = EPriorityAbsoluteLow;
+        break;
+	case EMemSpyCmdThreadSetPriorityAbsoluteBackgroundNormal:
+        pri = EPriorityAbsoluteBackgroundNormal;
+        break;
+	case EMemSpyCmdThreadSetPriorityAbsoluteBackground:
+        pri = EPriorityAbsoluteBackground;
+        break;
+	case EMemSpyCmdThreadSetPriorityAbsoluteForegroundNormal:
+        pri = EPriorityAbsoluteForegroundNormal;
+        break;
+	case EMemSpyCmdThreadSetPriorityAbsoluteForeground:
+        pri = EPriorityAbsoluteForeground;
+        break;
+	case EMemSpyCmdThreadSetPriorityAbsoluteHighNormal:
+        pri = EPriorityAbsoluteHighNormal;
+        break;
+	case EMemSpyCmdThreadSetPriorityAbsoluteHigh:
+        pri = EPriorityAbsoluteHigh;
+        break;
+	case EMemSpyCmdThreadSetPriorityAbsoluteRealTime1:
+        pri = EPriorityAbsoluteRealTime1;
+        break;
+	case EMemSpyCmdThreadSetPriorityAbsoluteRealTime2:
+        pri = EPriorityAbsoluteRealTime2;
+        break;
+	case EMemSpyCmdThreadSetPriorityAbsoluteRealTime3:
+        pri = EPriorityAbsoluteRealTime3;
+        break;
+	case EMemSpyCmdThreadSetPriorityAbsoluteRealTime4:
+        pri = EPriorityAbsoluteRealTime4;
+        break;
+	case EMemSpyCmdThreadSetPriorityAbsoluteRealTime5:
+        pri = EPriorityAbsoluteRealTime5;
+        break;
+	case EMemSpyCmdThreadSetPriorityAbsoluteRealTime6:
+        pri = EPriorityAbsoluteRealTime6;
+        break;
+	case EMemSpyCmdThreadSetPriorityAbsoluteRealTime7: 
+        pri = EPriorityAbsoluteRealTime7;
+        break;
+	case EMemSpyCmdThreadSetPriorityAbsoluteRealTime8:
+        pri = EPriorityAbsoluteRealTime8;
+        break;
+        }
+
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyViewThreads::OnCmdSetPriorityL() - pri: %d", pri );
+#endif
+
+    CMemSpyThread& thread = CurrentThread();
+    thread.SetPriorityL( pri );
+    RefreshL();
+
+#ifdef _DEBUG
+    RDebug::Printf( "CMemSpyViewThreads::OnCmdSetPriorityL() - END" );
+#endif
+    }
+
+
+void CMemSpyViewThreads::OnCmdInfoHandlesL()
+    {
+    CMemSpyThread& thread = CurrentThread();
+    thread.InfoContainerForceSyncronousConstructionL().PrintL();
+    }
+
+
+void CMemSpyViewThreads::SetListBoxModelL()
+    {
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( &iParentProcess );
+    listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+
+
+void CMemSpyViewThreads::HandleListBoxItemActionedL( TInt /*aIndex*/ )
+    {
+    // Notify observer about an item being 'fired'
+    ReportEventL( MMemSpyViewObserver::EEventItemActioned );
+    }
+
+
+void CMemSpyViewThreads::HandleListBoxItemSelectedL( TInt aIndex )
+    {
+    if  ( iCurrentThread )
+        {
+        iCurrentThread->Close();
+        }
+
+    // Obtain the thread that corresponds to the selected item
+    CMemSpyThread& thread = iParentProcess.At( aIndex );
+    iCurrentThread = &thread;
+    iCurrentThread->Open();
+
+    // Notify observer about item selection
+    ReportEventL( MMemSpyViewObserver::EEventItemSelected );
+    }
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewType.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,86 @@
+/*
+* 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 "MemSpyViewType.h"
+
+
+
+
+TBool MemSpyViewTypeUtils::IsOpenableItem( TMemSpyViewType aType )
+    {
+    TBool openable = EFalse;
+    //
+    switch( aType )
+        {
+    case EMemSpyViewTypeMainMenu:
+    case EMemSpyViewTypeProcesses:
+    case EMemSpyViewTypeServerList:
+    case EMemSpyViewTypeThreads:
+    case EMemSpyViewTypeThreadInfoItemList:
+    case EMemSpyViewTypeThreadInfoItemServer:
+    case EMemSpyViewTypeThreadInfoItemSession:
+        openable = ETrue;
+        break;
+    default:
+        break;
+        }
+    //
+    return openable;
+    }
+
+
+TBool MemSpyViewTypeUtils::IsThreadInfoItem( TMemSpyViewType aType )
+    {
+    TBool infoItem = ETrue;
+    //
+    switch( aType )
+        {
+    case EMemSpyViewTypeMainMenu:
+    case EMemSpyViewTypeRAMInfo:
+    case EMemSpyViewTypeROMInfo:
+    case EMemSpyViewTypeServerList:
+    case EMemSpyViewTypeOpenFiles:
+    case EMemSpyViewTypeProcesses:
+    case EMemSpyViewTypeThreads:
+    case EMemSpyViewTypeThreadInfoItemList:
+        infoItem = EFalse;
+        break;
+    default:
+        break;
+        }
+    //
+    return infoItem;
+    }
+
+
+TBool MemSpyViewTypeUtils::IsExitableView( TMemSpyViewType aType )
+    {
+    TBool ret = EFalse;
+    //
+    switch( aType )
+        {
+    case EMemSpyViewTypeMainMenu:
+        ret = ETrue;
+        break;
+    default:
+        break;
+        }
+    //
+    return ret;
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspyui/source/MemSpyViewWindowGroups.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,314 @@
+/*
+* 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 "MemSpyViewWindowGroups.h"
+
+// System includes
+#include <eikclbd.h>
+#include <aknmessagequerydialog.h>
+#include <aknnotewrappers.h>
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+#include <memspy/engine/memspyengineobjectthread.h>
+
+// User includes
+#include "MemSpyUiUtils.h"
+#include "MemSpyViewMainMenu.h"
+#include "MemSpyContainerObserver.h"
+
+// Literal constants
+const TInt KMaxInfoLength = 128;
+
+
+CMemSpyViewWindowGroups::CMemSpyViewWindowGroups( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
+:   CMemSpyViewBase( aEngine, aObserver )
+    {
+    }
+
+
+CMemSpyViewWindowGroups::~CMemSpyViewWindowGroups()
+    {
+    delete iWindowGroupList;
+    }
+
+
+void CMemSpyViewWindowGroups::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
+    {
+    _LIT( KTitle, "Window Groups" );
+    SetTitleL( KTitle );
+    //
+    CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
+    }
+
+
+CEikListBox* CMemSpyViewWindowGroups::ConstructListBoxL()
+    {
+    delete iListBox;
+    iListBox = NULL;
+    CAknSingleNumberStyleListBox* listbox = new (ELeave) CAknSingleNumberStyleListBox();
+    iListBox = listbox;
+    listbox->ConstructL( this, EAknListBoxSelectionList | EAknListBoxLoopScrolling );
+    listbox->SetContainerWindowL( *this );
+    listbox->CreateScrollBarFrameL( ETrue );
+    SetListBoxModelL();
+    listbox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
+    listbox->SetListBoxObserver( this );
+    listbox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
+    listbox->SetObserver( this );
+    return listbox;
+    }
+
+void CMemSpyViewWindowGroups::RefreshL()
+    {
+    SetListBoxModelL();
+    CMemSpyViewBase::RefreshL();
+    }
+
+
+TMemSpyViewType CMemSpyViewWindowGroups::ViewType() const
+    {
+    return EMemSpyViewTypeWindowGroups;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewWindowGroups::PrepareParentViewL()
+    {
+    CMemSpyViewMainMenu* parent = new(ELeave) CMemSpyViewMainMenu( iEngine, iObserver );
+    CleanupStack::PushL( parent );
+    parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
+    CleanupStack::Pop( parent );
+    return parent;
+    }
+
+
+CMemSpyViewBase* CMemSpyViewWindowGroups::PrepareChildViewL()
+    {
+    CMemSpyViewBase* child = NULL;
+    if ( iListBox && 
+         iListBox->Model()->NumberOfItems() && 
+         iListBox->CurrentItemIndex() > KErrNotFound )
+        {
+        DetailsL();
+        }
+    return child;
+    }
+
+
+void CMemSpyViewWindowGroups::SetListBoxModelL()
+    {
+    // Take ownership of new model
+    MMemSpyEngineHelperWindowServer& windowServerManager = iEngine.HelperWindowServer();
+    MMemSpyEngineWindowGroupList* windowGroupList = windowServerManager.WindowGroupListL();
+    delete iWindowGroupList;
+    iWindowGroupList = windowGroupList;
+    
+    // Set up list box
+    CAknSingleNumberStyleListBox* listbox = static_cast< CAknSingleNumberStyleListBox* >( iListBox );
+    listbox->Model()->SetItemTextArray( iWindowGroupList );
+    listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+
+
+TBool CMemSpyViewWindowGroups::HandleCommandL( TInt aCommand )
+    {
+    TBool handled = ETrue;
+    //
+    switch ( aCommand )
+        {
+        case EMemSpyCmdWindowGroupTerminate:
+            {
+            TRAPD( err, OnCmdEndL( aCommand ) );
+            CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote( ETrue );
+            if ( err )
+                {
+                note->ExecuteLD( _L("Cannot terminate task") );
+                }
+            else
+                {
+                note->ExecuteLD( _L("Task terminated") );
+                }
+            break;
+            }
+        case EMemSpyCmdWindowGroupSwitchTo:
+            {
+            TRAPD( err, OnCmdSwitchToL() );
+            if ( err )
+                {
+                CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote( ETrue );
+                note->ExecuteLD( _L("Cannot bring to foreground") );
+                }
+            break;
+            }
+        case EMemSpyCmdWindowGroupEnd:
+            {
+            TRAPD( err, OnCmdEndL( aCommand ) );
+            CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote( ETrue );
+            if ( err )
+                {
+                note->ExecuteLD( _L("Cannot end task") );
+                }
+            else
+                {
+                note->ExecuteLD( _L("Task exited") );
+                }
+            break;
+            }
+        case EMemSpyCmdWindowGroupPanic:
+            {
+            TRAPD( err, OnCmdEndL( aCommand ) );
+            CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote( ETrue );
+            if ( err )
+                {
+                note->ExecuteLD( _L("Cannot panic task") );
+                }
+            else
+                {
+                note->ExecuteLD( _L("Task panic'ed") );
+                }
+            break;
+            }
+        default:
+            {
+            handled = CMemSpyViewBase::HandleCommandL( aCommand );
+            break;        
+            }
+        }
+    //
+    return handled;
+    }
+
+
+void CMemSpyViewWindowGroups::OnCmdSwitchToL()
+    {
+    MMemSpyEngineHelperWindowServer& windowServerManager = iEngine.HelperWindowServer();
+    TInt id = iWindowGroupList->At( iListBox->CurrentItemIndex() ).iId;
+    windowServerManager.SwitchToL( id );
+    }
+
+
+void CMemSpyViewWindowGroups::OnCmdEndL( TInt aCommand )
+    {
+    TBool doTerminate = ETrue;
+    
+    CMemSpyEngineObjectContainer& container = iEngine.Container();
+    TThreadId id = iWindowGroupList->At( iListBox->CurrentItemIndex() ).iThreadId;
+    
+    // Try to find the thread in question...
+    CMemSpyProcess* process = NULL;
+    CMemSpyThread* thread = NULL; 
+    User::LeaveIfError( container.ProcessAndThreadByThreadId( id, process, thread ) );
+
+    if ( thread )
+        {
+        thread->Open();
+        //
+        if  ( thread->IsSystemPermanent() || thread->IsSystemCritical() )
+            {
+            CAknQueryDialog* importDialog = CAknQueryDialog::NewL();
+            doTerminate = ( importDialog->ExecuteLD( R_MEMSPY_PANIC_SYSTEM_CRITICAL_THREAD_OR_PROCESS ) );
+            }
+        //
+        if  ( doTerminate )
+            {
+            switch ( aCommand )
+                {
+                case EMemSpyCmdWindowGroupTerminate:
+                    {
+                    thread->TerminateL();
+                    break;
+                    }
+                case EMemSpyCmdWindowGroupEnd:
+                    {
+                    thread->KillL();
+                    break;
+                    }
+                case EMemSpyCmdWindowGroupPanic:
+                    {
+                    thread->PanicL();
+                    break;
+                    }
+                default:
+                    {
+                    // Programming error
+                    __ASSERT_ALWAYS( EFalse, User::Panic( _L("MemSpy-View"), 0 ) );
+                    }                
+                }
+            }                
+        }
+    RefreshL();
+    }
+
+
+void CMemSpyViewWindowGroups::DetailsL()
+    {
+    HBufC* messageBuf = HBufC::NewLC( 4096 );
+    TPtr messagePtr = messageBuf->Des();
+
+    // Fetch data from helper
+    TMemSpyEngineWindowGroupDetails selectedObject;
+    MMemSpyEngineHelperWindowServer& windowServerManager = iEngine.HelperWindowServer();
+    TInt id = iWindowGroupList->At( iListBox->CurrentItemIndex() ).iId;
+    windowServerManager.GetWindowGroupDetailsL( id, selectedObject );
+    
+    // Append info to string buffer
+    AppendFormatString( messagePtr, _L("WG ID: %d\n"), selectedObject.iId );
+    AppendFormatString( messagePtr, _L("Client ThreadId: %Lu\n"), selectedObject.iThreadId.Id() );
+    TFullName name;
+    name.Copy( selectedObject.iFullName );
+    AppendFormatString( messagePtr, _L("Thr: %S\n"), &name );
+    name.Zero();
+    AppendFormatString( messagePtr, _L("Priority: %d\n"), selectedObject.iPriority );
+    AppendFormatString( messagePtr, _L("Handle: 0x%08X\n"), selectedObject.iWindowGroupHandle );
+    name.Copy( selectedObject.iName );
+    AppendFormatString( messagePtr, _L("Name: %S\n"), &name );
+    name.Zero();
+    AppendFormatString( messagePtr, _L("UID: 0x%08X\n"), selectedObject.iUID );
+    AppendFormatString( messagePtr, _L("IsBusy: %d\n"), selectedObject.iIsBusy );
+    AppendFormatString( messagePtr, _L("IsSystem: %d\n"), selectedObject.iIsSystem );
+    AppendFormatString( messagePtr, _L("IsHidden: %d\n"), selectedObject.iIsHidden );
+    name.Copy( selectedObject.iCaption );
+    AppendFormatString( messagePtr, _L("Caption: %S\n"), &name );
+    name.Zero();
+    name.Copy( selectedObject.iDocName );
+    AppendFormatString( messagePtr, _L("Docname: %S"), &name );
+    name.Zero();
+
+    // Display the buffer on a dialog
+    CAknMessageQueryDialog* dialog = new(ELeave) CAknMessageQueryDialog( CAknQueryDialog::ENoTone );
+    dialog->PrepareLC( R_MEMSPY_KERNEL_OBJECT_DETAILS_DIALOG );
+    TFileName headerText;
+    headerText.Copy( selectedObject.iFullName );
+    dialog->SetHeaderTextL( headerText );
+    dialog->SetMessageTextL( messagePtr );
+    dialog->RunLD();
+   
+    CleanupStack::PopAndDestroy( messageBuf );
+    }
+
+
+void CMemSpyViewWindowGroups::AppendFormatString( TPtr& aPtr, TRefByValue<const TDesC> aFmt, ... )
+    {
+    TBuf<KMaxInfoLength> infoString;
+    VA_LIST list;
+    VA_START ( list, aFmt );
+    infoString.FormatList( aFmt, list );
+    aPtr.Append( infoString );
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/package_definition.xml	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<SystemDefinition schema="3.0.0">
+  <package id="rndtools" name="R&amp;D tools" levels="support generic test util">
+    <collection id="creator" name="Creator" level="support">
+      <component id="creator_build" filter="s60" name="Creator Tool" purpose="development" target="device" class="tool">
+        <unit bldFile="creator/group"/>
+      </component>
+    </collection>
+    <collection id="filebrowser" name="File Browser" level="util">
+		<!-- consider collapsing into a single component -->
+      <component id="fileopserver" filter="s60" name="File Operations Server" purpose="development" target="device" class="tool">
+        <unit bldFile="filebrowser/fileopserver/group"/>
+      </component>
+      <component id="fileopclient" filter="s60" name="File Operations Client" purpose="development" target="device" class="tool">
+        <unit bldFile="filebrowser/fileopclient/group"/>
+      </component>
+      <component id="filebrowser_build" filter="s60" name="File Browser Application" purpose="development" target="device" class="tool">
+        <unit bldFile="filebrowser/group"/>
+      </component>
+    </collection>
+    <collection id="launcher" name="Launcher" level="util">
+      <component id="launcher_build" filter="s60" name="Launcher Utility" purpose="development" target="device" class="tool">
+        <unit bldFile="launcher/group"/>
+      </component>
+    </collection>
+    <collection id="screengrabber" name="Screen Grabber" level="util">
+      <component id="screengrabber_build" filter="s60"  name="ScreenGrabber" purpose="development" target="device" class="tool">
+        <unit bldFile="screengrabber/group"/>
+      </component>
+    </collection>
+    <collection id="stifui" name="STIF UI" level="generic">
+      <component id="stifui_stifui" filter="s60" name="STIF UI" purpose="development" target="device">
+        <unit bldFile="stifui/stifui/group"/>
+      </component>
+      <component id="uitestserverstarter" filter="s60" name="UI Test Server Starter" purpose="development" target="device">
+        <unit bldFile="stifui/uitestserverstarter/group"/>
+      </component>
+      <component id="stifui_build" filter="s60" name="STIF UI Build" purpose="development">
+		<!-- can this be split up into the other components? -->
+        <unit bldFile="stifui/group"/>
+      </component>
+    </collection>
+    <collection id="loadgen" name="Load Generator" level="test">
+      <component id="loadgen_build" filter="s60" name="Load Generator Application" purpose="development" target="device" class="tool">
+        <unit bldFile="loadgen/group"/>
+      </component>
+    </collection>
+    <collection id="perfmon" name="Performance Monitor" level="test">
+      <component id="perfmon_build" filter="s60" name="Performance Monitor Tool" purpose="development" target="device" class="tool">
+        <unit bldFile="perfmon/group"/>
+      </component>
+    </collection>
+    <collection id="htiui" name="Harmonized Test Interface UI" level="generic">
+      <component id="HtiCommPlugins" filter="s60" name="HTI Comm Plugins" purpose="development" target="device" class="plugin">
+        <unit bldFile="htiui/HtiCommPlugins/HtiBtCommPlugin/group"/>
+      </component>
+      <component id="HtiServicePlugins" filter="s60" name="HTI Service Plugins" purpose="development" target="device" class="plugin">
+		<!-- can only have a single unit. Should #include from a common bld.inf file -->
+        <unit bldFile="htiui/HtiServicePlugins/HtiAppServicePlugin/group"/>
+        <unit bldFile="htiui/HtiServicePlugins/HtiAudioServicePlugin/group"/>
+        <unit bldFile="htiui/HtiServicePlugins/HtiKeyEventServicePlugin/group"/>
+        <unit bldFile="htiui/HtiServicePlugins/HtiMessagesServicePlugin/group"/>
+        <unit bldFile="htiui/HtiServicePlugins/HtiPIMServicePlugin/group"/>
+        <unit bldFile="htiui/HtiServicePlugins/HtiScreenshotServicePlugin/group"/>
+        <unit bldFile="htiui/HtiServicePlugins/HtiSysInfoServicePlugin/group"/>
+        <unit bldFile="htiui/HtiServicePlugins/HtiFtpBackupFake/group"/>
+      </component>
+      <component id="htidevicereboot" filter="s60" name="HTI Device Reboot" purpose="development" target="device">
+        <unit bldFile="htiui/htidevicereboot/group"/>
+      </component>
+      <component id="htistartupwait" filter="s60" name="HTI Startup Wait" purpose="development" target="device">
+        <unit bldFile="htiui/htistartupwait/group"/>
+      </component>
+      <component id="htiadmin" filter="s60" name="HTI Admin" purpose="development" target="device">
+        <unit bldFile="htiui/htiadmin/group"/>
+      </component>
+      <component id="htiui_build" filter="s60" name="HTI UI Build" purpose="development">
+		<!-- can this be split up into the other components? -->
+        <unit bldFile="htiui/group"/>
+      </component>
+    </collection>
+    <collection id="memspyui" name="Memspy UI" level="generic">
+      <component id="memspyui_build" filter="s60" name="Memspy UI Application" purpose="development" target="device" class="tool">
+        <unit bldFile="memspyui/group"/>
+      </component>
+    </collection>
+  </package>
+</SystemDefinition>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/data/perfmon.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,693 @@
+/*
+* 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 "perfmon.hrh"
+#include "perfmon_std.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_perfmon_status_pane;
+    //menubar = r_perfmon_menubar;
+    //cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
+    }
+
+//----------------------------------------------------
+//    r_perfmon_status_pane
+//----------------------------------------------------
+//   
+RESOURCE STATUS_PANE_APP_MODEL r_perfmon_status_pane
+    {
+	panes=
+		{
+		SPANE_PANE
+			{
+			id = EEikStatusPaneUidNavi;
+			type = EAknCtNaviPane;
+			resource = r_perfmon_navi_decorator;
+			}
+		};
+    }
+    
+//----------------------------------------------------
+//    r_perfmon_navi_decorator
+//----------------------------------------------------
+//
+RESOURCE NAVI_DECORATOR r_perfmon_navi_decorator
+    {
+    type = ENaviDecoratorControlTabGroup;
+    control = TAB_GROUP
+		{
+		tab_width = EAknTabWidthWithTwoTabs;
+		active = 0;
+		tabs = {
+			TAB
+				{
+                id = ETabMainViewValues;
+                txt = "Values";
+                },
+			TAB
+				{
+                id = ETabMainViewGraphs;
+                txt = "Graphs";
+				}
+			};
+		};
+	}
+	
+//----------------------------------------------------
+//   
+//    r_perfmon_hotkeys
+//
+//----------------------------------------------------
+//
+RESOURCE HOTKEYS r_perfmon_hotkeys
+    {
+    control=
+        {
+        HOTKEY { command=EAknCmdExit; key='e'; }
+        };
+    }
+
+
+//----------------------------------------------------
+//    r_perfmon_view_values
+//----------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_perfmon_view_values
+    {
+    hotkeys=r_perfmon_hotkeys;
+    menubar=r_perfmon_menubar_view_values;  
+    cba=R_AVKON_SOFTKEYS_OPTIONS_EXIT;    
+    }
+
+//----------------------------------------------------
+//    r_perfmon_menubar_view_values
+//----------------------------------------------------
+//
+RESOURCE MENU_BAR r_perfmon_menubar_view_values
+    {
+    titles=
+        {
+        MENU_TITLE { menu_pane=r_perfmon_app_menu; txt="App"; },
+        MENU_TITLE { menu_pane=r_perfmon_view_values_menu; txt="Values"; }
+        };
+    }
+
+//----------------------------------------------------
+//    r_perfmon_view_values_menu
+//----------------------------------------------------
+//
+
+RESOURCE MENU_PANE r_perfmon_view_values_menu
+    {
+    items=
+        {
+        };
+    }
+
+//----------------------------------------------------
+//    r_perfmon_view_graphs
+//----------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_perfmon_view_graphs
+    {
+    hotkeys=r_perfmon_hotkeys;
+    menubar=r_perfmon_menubar_view_graphs;  
+    cba=R_AVKON_SOFTKEYS_OPTIONS_EXIT;    
+    }
+
+//----------------------------------------------------
+//    r_perfmon_menubar_view_graphs
+//----------------------------------------------------
+//
+RESOURCE MENU_BAR r_perfmon_menubar_view_graphs
+    {
+    titles=
+        {
+        MENU_TITLE { menu_pane=r_perfmon_app_menu; txt="App"; },
+        MENU_TITLE { menu_pane=r_perfmon_view_graphs_menu; txt="graphs"; }
+        };
+    }
+
+//----------------------------------------------------
+//    r_perfmon_view_graphs_menu
+//----------------------------------------------------
+//
+
+RESOURCE MENU_PANE r_perfmon_view_graphs_menu
+    {
+    items=
+        {
+        };
+    }
+           
+        
+//----------------------------------------------------
+//    r_perfmon_app_menu
+//----------------------------------------------------
+//
+RESOURCE MENU_PANE r_perfmon_app_menu
+    {
+    items=
+        {
+        MENU_ITEM { command=EPerfMonCmdEnableLogging; txt="Enable Logging"; },
+        MENU_ITEM { command=EPerfMonCmdDisableLogging; txt="Disable Logging"; },
+        MENU_ITEM { command=EPerfMonCmdSettings; txt="Settings"; },
+        MENU_ITEM { command=EPerfMonCmdAbout; txt="About"; },
+        MENU_ITEM { command=EAknCmdExit; txt="Exit"; }
+        };
+    }
+
+//----------------------------------------------------
+//    r_perfmon_settings_dialog
+//    Dialog for setting list
+//----------------------------------------------------
+//
+RESOURCE DIALOG r_perfmon_settings_dialog
+    {
+    flags =
+        EEikDialogFlagNoDrag | EEikDialogFlagFillAppClientRect |
+        EEikDialogFlagButtonsRight | EEikDialogFlagCbaButtons |
+        EEikDialogFlagWait | EEikDialogFlagNoTitleBar;
+    buttons = R_AVKON_SOFTKEYS_OPTIONS_BACK;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtSettingListBox;
+            id = EPerfMonSettingItemList;
+            itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
+            control = LISTBOX
+                {
+                flags = EAknListBoxSelectionList;
+                };
+            }
+        };
+    }
+
+//----------------------------------------------------
+//    r_perfmon_settings_menubar
+//----------------------------------------------------
+//
+
+RESOURCE MENU_BAR r_perfmon_settings_menubar
+    {
+    titles =
+        {
+        MENU_TITLE
+            {
+            menu_pane = r_perfmon_settings_menupane;
+            txt = " ";   // dummy
+            }
+        };
+    }
+
+RESOURCE MENU_PANE r_perfmon_settings_menupane
+    {
+    items =
+        {
+        MENU_ITEM
+            {
+            command = EPerfMonCmdSettingsChange;
+            txt = "Change";
+            },
+        MENU_ITEM
+            {
+            command = EPerfMonCmdSettingsExit;
+            txt = "Exit";
+            }
+        };
+    }
+
+
+//----------------------------------------------------
+//   
+//    Setting item resources
+//
+//----------------------------------------------------
+//
+
+// generic resources
+RESOURCE POPUP_SETTING_LIST r_popup_setting_list_editor
+	{
+	}
+RESOURCE AVKON_SETTING_PAGE r_binary_setting_page
+    {   
+    number = EAknSettingPageNoOrdinalDisplayed;
+    type = EAknCtPopupSettingList;
+	editor_resource_id = r_popup_setting_list_editor;
+    }
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_yesno_binaryselection_texts
+	{
+	setting_texts_resource = r_yesno_binaryselection_text_array;
+	}
+RESOURCE ARRAY r_yesno_binaryselection_text_array
+	{
+	items =
+		{
+		AVKON_ENUMERATED_TEXT { value=0; text = "No"; },
+		AVKON_ENUMERATED_TEXT { value=1; text = "Yes"; }
+		};
+	}
+
+//
+// resources for heartbeat selection
+//
+RESOURCE TBUF r_heartbeat_setting_title
+    {
+    buf = "Heart beat (ms)";
+    }
+RESOURCE AVKON_SETTING_PAGE r_heartbeat_setting_page
+	{
+	type = EAknCtIntegerEdwin;
+	editor_resource_id = r_heartbeat_integer_editor;
+	}
+RESOURCE AVKON_INTEGER_EDWIN r_heartbeat_integer_editor
+	{
+	maxlength = 5;
+	min = 1;
+	max = 99999;
+	}    
+    
+
+//
+// resources for maxsamples selection
+//
+RESOURCE TBUF r_maxsamples_setting_title
+    {
+    buf = "Max samples";
+    }
+RESOURCE AVKON_SETTING_PAGE r_maxsamples_setting_page
+	{
+	type = EAknCtIntegerEdwin;
+	editor_resource_id = r_maxsamples_integer_editor;
+	}
+RESOURCE AVKON_INTEGER_EDWIN r_maxsamples_integer_editor
+	{
+	maxlength = 4;
+	min = 1;
+	max = 9999;
+	} 
+
+
+//
+// resources for priority selection
+//
+RESOURCE TBUF r_priority_setting_title
+    {
+    buf = "Priority";
+    }
+RESOURCE AVKON_SETTING_PAGE r_priority_setting_page
+	{
+    number = EAknSettingPageNoOrdinalDisplayed; 
+	type = EAknCtPopupSettingList;
+	editor_resource_id = r_popup_setting_list_editor;
+	}
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_priority_setting_texts
+	{
+	setting_texts_resource = r_priority_text_array;
+	}
+RESOURCE ARRAY r_priority_text_array
+	{
+	items =
+		{
+		AVKON_ENUMERATED_TEXT { value=EThreadPriorityTypeMuchLess; text = "Much less"; },
+		AVKON_ENUMERATED_TEXT { value=EThreadPriorityTypeLess; text = "Less"; },
+		AVKON_ENUMERATED_TEXT { value=EThreadPriorityTypeNormal; text = "Normal"; },
+		AVKON_ENUMERATED_TEXT { value=EThreadPriorityTypeMore; text = "More"; },
+		AVKON_ENUMERATED_TEXT { value=EThreadPriorityTypeMuchMore; text = "Much more"; },
+		AVKON_ENUMERATED_TEXT { value=EThreadPriorityTypeRealTime; text = "Real time"; },
+		AVKON_ENUMERATED_TEXT { value=EThreadPriorityTypeAbsoluteVeryLow; text = "Abs. very low"; },
+		AVKON_ENUMERATED_TEXT { value=EThreadPriorityTypeAbsoluteLow; text = "Abs. low"; },
+		AVKON_ENUMERATED_TEXT { value=EThreadPriorityTypeAbsoluteBackground; text = "Abs. background"; },
+		AVKON_ENUMERATED_TEXT { value=EThreadPriorityTypeAbsoluteForeground; text = "Abs. foreground"; },
+		AVKON_ENUMERATED_TEXT { value=EThreadPriorityTypeAbsoluteHigh; text = "Abs. high"; }
+		};
+	}
+
+
+//
+// resources for cpumode selection
+//
+RESOURCE TBUF r_cpumode_setting_title
+    {
+    buf = "CPU sampling mode";
+    }
+RESOURCE AVKON_SETTING_PAGE r_cpumode_setting_page
+	{
+    number = EAknSettingPageNoOrdinalDisplayed; 
+	type = EAknCtPopupSettingList;
+	editor_resource_id = r_popup_setting_list_editor;
+	}
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_cpumode_setting_texts
+	{
+	setting_texts_resource = r_cpumode_text_array;
+	}
+RESOURCE ARRAY r_cpumode_text_array
+	{
+	items =
+		{
+		AVKON_ENUMERATED_TEXT { value=ECPUModeCPUTime; text = "CPU Time"; },
+		AVKON_ENUMERATED_TEXT { value=ECPUModeNOPs; text = "NOPs"; }
+		};
+	}
+
+
+//
+// resources for keepbacklighton selections
+//
+RESOURCE TBUF r_keepbacklighton_setting_title
+    {
+    buf = "Keep backlight on";
+    }
+
+
+//
+// resources for datapopupvisibility selection
+//
+RESOURCE TBUF r_datapopupvisibility_setting_title
+    {
+    buf = "Visibility";
+    }
+RESOURCE AVKON_SETTING_PAGE r_datapopupvisibility_setting_page
+	{
+    number = EAknSettingPageNoOrdinalDisplayed; 
+	type = EAknCtPopupSettingList;
+	editor_resource_id = r_popup_setting_list_editor;
+	}
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_datapopupvisibility_setting_texts
+	{
+	setting_texts_resource = r_datapopupvisibility_text_array;
+	}
+RESOURCE ARRAY r_datapopupvisibility_text_array
+	{
+	items =
+		{
+		AVKON_ENUMERATED_TEXT { value=EDataPopupVisbilityAlwaysOn; text = "On"; },
+		AVKON_ENUMERATED_TEXT { value=EDataPopupVisbilityBackgroundOnly; text = "Backgr. only"; },
+		AVKON_ENUMERATED_TEXT { value=EDataPopupVisbilityAlwaysAlwaysOff; text = "Off"; }
+		};
+	}    
+
+//
+// resources for datapopuplocation selection
+//
+RESOURCE TBUF r_datapopuplocation_setting_title
+    {
+    buf = "Location";
+    }
+RESOURCE AVKON_SETTING_PAGE r_datapopuplocation_setting_page
+	{
+    number = EAknSettingPageNoOrdinalDisplayed; 
+	type = EAknCtPopupSettingList;
+	editor_resource_id = r_popup_setting_list_editor;
+	}
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_datapopuplocation_setting_texts
+	{
+	setting_texts_resource = r_datapopuplocation_text_array;
+	}
+RESOURCE ARRAY r_datapopuplocation_text_array
+	{
+	items =
+		{
+		AVKON_ENUMERATED_TEXT { value=EDataPopupLocationTopRight; text = "Top right"; },
+		AVKON_ENUMERATED_TEXT { value=EDataPopupLocationBottomMiddle; text = "Bottom middle"; }
+		};
+	}
+
+//
+// resources for sources selection
+//
+RESOURCE TBUF r_sources_setting_title
+    {
+    buf = "Sources";
+    }
+RESOURCE AVKON_SETTING_PAGE r_sources_setting_page
+	{
+	type = EAknSetListBox;
+	editor_resource_id = r_sources_items_listbox;
+	label = "Sources";
+	}	
+RESOURCE LISTBOX r_sources_items_listbox
+	{
+	flags = EAknListBoxMultipleSelection;
+	}	
+
+
+//
+// resources for graphsverticalbar selection
+//
+RESOURCE TBUF r_graphsverticalbar_setting_title
+    {
+    buf = "Vertical bar period (s)";
+    }
+RESOURCE AVKON_SETTING_PAGE r_graphsverticalbar_setting_page
+	{
+	type = EAknCtIntegerEdwin;
+	editor_resource_id = r_graphsverticalbar_integer_editor;
+	}
+RESOURCE AVKON_INTEGER_EDWIN r_graphsverticalbar_integer_editor
+	{
+	maxlength = 3;
+	min = 0;
+	max = 999;
+	} 
+
+
+//
+// resources for loggingmode selection
+//
+RESOURCE TBUF r_loggingmode_setting_title
+    {
+    buf = "Mode";
+    }
+RESOURCE AVKON_SETTING_PAGE r_loggingmode_setting_page
+	{
+    number = EAknSettingPageNoOrdinalDisplayed; 
+	type = EAknCtPopupSettingList;
+	editor_resource_id = r_popup_setting_list_editor;
+	}
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_loggingmode_setting_texts
+	{
+	setting_texts_resource = r_loggingmode_text_array;
+	}
+RESOURCE ARRAY r_loggingmode_text_array
+	{
+	items =
+		{
+		AVKON_ENUMERATED_TEXT { value=ELoggingModeRDebug; text = "RDebug"; },
+		AVKON_ENUMERATED_TEXT { value=ELoggingModeLogFile; text = "Log file"; },
+		AVKON_ENUMERATED_TEXT { value=ELoggingModeRDebugLogFile; text = "RDebug & log file"; }
+		};
+	}
+
+
+//
+// resources for loggingfilepath selection
+//
+RESOURCE TBUF r_loggingfilepath_setting_title
+    {
+    buf = "Log file path";
+    }
+RESOURCE AVKON_SETTING_PAGE r_loggingfilepath_setting_page
+	{
+	type = EEikCtEdwin;
+	editor_resource_id = r_loggingfilepath_text_editor;
+	}
+
+RESOURCE EDWIN r_loggingfilepath_text_editor
+	{
+	lines = 0;  // expanding to multiple rows
+	maxlength = 63;
+	flags = EEikEdwinNoLineOrParaBreaks;
+	}
+
+  
+// ---------------------------------------------------------
+//   
+//   r_perfmon_about_dialog
+//   About dialog - show version and copyright info etc.
+//
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_perfmon_about_dialog
+    {
+    flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow;
+    buttons = R_AVKON_SOFTKEYS_OK_EMPTY;
+    items=
+        {
+        DLG_LINE
+            {
+            type = EAknCtPopupHeadingPane;
+            id = EAknMessageQueryHeaderId;
+            control = AVKON_HEADING
+                {
+                label = "About PerfMon";
+                headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE;
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtMessageQuery;
+            id = EAknMessageQueryContentId;
+            control = AVKON_MESSAGE_QUERY
+                {
+                message = "Version 1.0.0 - 6th March 2008. Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0.";
+                };
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+//   r_general_confirmation_query
+// ---------------------------------------------------------
+//
+
+RESOURCE DIALOG r_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_general_text_query
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_general_text_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items=
+        {
+        DLG_LINE
+            {
+            type = EAknCtQuery;
+            id = EGeneralQuery;
+            control = AVKON_DATA_QUERY
+                {
+                layout = EDataLayout;
+                control = EDWIN
+                    {
+                    width = 256;
+                    lines = 3;
+                    maxlength = 256;
+                    };
+                };
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+//   r_general_numeric_query
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_general_numeric_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtQuery;
+            id = EGeneralQuery;
+            control= AVKON_DATA_QUERY
+                {
+                layout = ENumberLayout;
+                control = AVKON_INTEGER_EDWIN
+                    {
+                    min = -999999;
+                    max = 999999;
+                    };
+                };
+            }
+        };
+    }
+
+
+// ---------------------------------------------------------
+//   
+//    RESOURCE LOCALISABLE_APP_INFO
+//
+// ---------------------------------------------------------
+//
+RESOURCE LOCALISABLE_APP_INFO r_perfmon_localisable_app_info
+    {
+    short_caption = "PerfMon";
+    caption_and_icon = 
+    CAPTION_AND_ICON_INFO
+        {
+        caption = "PerfMon";
+
+        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"\\perfmon_aif.mif";
+        };
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/data/perfmon_reg.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,35 @@
+/*
+* 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 <perfmon.rsg>
+#include <appinfo.rh>
+#include <data_caging_paths_strings.hrh>
+
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0x20011385
+
+
+RESOURCE APP_REGISTRATION_INFO
+    {
+    app_file = "PerfMon";
+    localisable_resource_file = APP_RESOURCE_DIR"\\PerfMon";
+    localisable_resource_id = R_PERFMON_LOCALISABLE_APP_INFO;
+    group_name = "RnD Tools";    
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/envpatcher/EnvPatcher.pl	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,544 @@
+#
+# 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;    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/envpatcher/ReadMe.txt	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,46 @@
+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".
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/group/ReleaseNotes_PerfMon.txt	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,88 @@
+===============================================================================
+
+RELEASE NOTES - PERFORMANCE MONITOR v1.0.0
+RELEASED 6th March 2008 
+
+SUPPORTS S60 3.0+
+
+===============================================================================
+
+Product Description:
+====================
+PerfMon is an S60 UI application that you can use to monitor and log CPU load
+in a device. You can also use it to monitor and log the consumption of memory
+(RAM and disk drives) in a device. 
+
+Main Features:
+==============
+- Three different monitor views for CPU load, RAM and disk usage:
+  - Values
+  - Graphs
+  - Popup (always on top) 
+- Supports CPU load sampling via a null thread CPU counter or with NOPs
+- Source selections for graphs, popup and logging
+- Heartbeat and thread priority configurable via settings
+- Logging to RDebug and/or to a file
+
+===============================================================================
+
+What's New in v1.0.0
+====================
+- Initial version
+
+===============================================================================
+
+Installation Notes:
+===================
+PerfMon 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
+  
+When builing PerfMon 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:
+=============
+N/A
+
+===============================================================================
+
+Version History:
+================
+
+Version 1.0.0 - 6th March 2008
+------------------------------
+- Initial version
+ 
+===============================================================================
+
+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".
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/group/backup_registration.xml	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,8 @@
+<?xml version="1.0" standalone="yes"?>
+<backup_registration>
+  <passive_backup>
+    <include_directory name="\"/>
+  </passive_backup>
+  <system_backup/>
+  <restore requires_reboot = "no"/>
+</backup_registration>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,52 @@
+/*
+* 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/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
+
+perfmon.mmp
+
+
+#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/perfmon.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,79 @@
+/*
+* 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/group/perfmon_icons_aif.mk	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,54 @@
+#
+# 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:  
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z
+else
+ZDIR=\epoc32\data\z
+endif
+
+TARGETDIR=$(ZDIR)\resource\apps
+ICONTARGETFILENAME=$(TARGETDIR)\perfmon_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_perfmon.svg
+	mifconv $(ICONTARGETFILENAME) \
+		/c8,8 ..\icons\qgn_menu_perfmon.svg
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/group/perfmon_stub_sis.mk	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,56 @@
+#
+# 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:  
+#
+
+
+TARGETDIR=$(EPOCROOT)EPOC32\Data\Z\System\Install
+
+SISNAME=PerfMon_stub
+PKGNAME=PerfMon_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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/icons/qgn_menu_perfmon.svg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   version="1.0"
+   width="100%"
+   height="100%"
+   viewBox="0 0 87.999512 88.000488"
+   id="svg76799">
+  <defs
+     id="defs76881" />
+  <path
+     d="M 9.0713171,59.555059 L 9.0713171,59.555059 L 29.815483,31.95446 L 53.905481,46.690373 L 77.99548,28.212006"
+     style="fill:none;fill-opacity:0.46710528;stroke:#0000ff;stroke-width:6;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+     id="path4569" />
+  <path
+     d="M 9.5317326,73.333448 L 30.06138,52.248151 L 53.681509,63.493643 L 77.30164,60.213707"
+     style="fill:none;fill-opacity:0.46710528;stroke:#ff0000;stroke-width:6;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+     id="path4571" />
+  <g
+     transform="matrix(0.1348839,0,0,0.1348839,12.762244,-36.73138)"
+     style="fill:#00a300;fill-opacity:1;stroke:none;stroke-opacity:1"
+     id="g2303">
+    <path
+       d="M 114.897,303.361 C 139.482,303.361 151.775,322.648 151.775,361.221 C 151.775,380.714 148.599,395.205 142.247,404.695 C 135.895,414.184 126.778,418.928 114.897,418.928 C 90.3641,418.928 78.0977,399.692 78.0977,361.221 C 78.0977,341.728 81.2737,327.211 87.6258,317.671 C 93.9779,308.131 103.068,303.361 114.897,303.361 z M 114.897,407.51 C 122.356,407.51 127.988,403.897 131.794,396.671 C 135.6,389.445 137.503,377.628 137.503,361.221 C 137.503,349.804 136.667,340.816 134.995,334.259 C 133.323,327.701 130.803,322.815 127.434,319.6 C 124.066,316.386 119.836,314.779 114.744,314.779 C 107.287,314.779 101.68,318.456 97.9254,325.811 C 94.1705,333.165 92.293,344.968 92.293,361.221 C 92.293,372.485 93.1418,381.409 94.8395,387.992 C 96.5372,394.576 99.0573,399.474 102.4,402.689 C 105.743,405.903 109.908,407.51 114.897,407.51 z "
+       transform="translate(-33.85833,40)"
+       style="fill:#00a300;fill-opacity:1;stroke:none;stroke-opacity:1"
+       id="path2305" />
+    <path
+       d="M 218.098,417 L 204.211,417 L 204.211,328.51 C 197.268,335.093 187.984,340.674 176.361,345.251 L 176.361,331.828 C 192.357,324.165 203.261,314.676 209.072,303.361 L 218.098,303.361 L 218.098,417 z "
+       transform="translate(-33.85833,40)"
+       style="fill:#00a300;fill-opacity:1;stroke:none;stroke-opacity:1"
+       id="path2307" />
+    <path
+       d="M 290.593,303.361 C 315.178,303.361 327.471,322.648 327.471,361.221 C 327.471,380.714 324.295,395.205 317.943,404.695 C 311.591,414.184 302.474,418.928 290.593,418.928 C 266.06,418.928 253.794,399.692 253.794,361.221 C 253.794,341.728 256.97,327.211 263.322,317.671 C 269.674,308.131 278.764,303.361 290.593,303.361 z M 290.593,407.51 C 298.052,407.51 303.684,403.897 307.49,396.671 C 311.296,389.445 313.199,377.628 313.199,361.221 C 313.199,349.804 312.363,340.816 310.691,334.259 C 309.019,327.701 306.499,322.815 303.13,319.6 C 299.762,316.386 295.532,314.779 290.44,314.779 C 282.983,314.779 277.376,318.456 273.621,325.811 C 269.866,333.165 267.989,344.968 267.989,361.221 C 267.989,372.485 268.838,381.409 270.535,387.992 C 272.233,394.576 274.753,399.474 278.096,402.689 C 281.439,405.903 285.604,407.51 290.593,407.51 z "
+       transform="translate(-33.85833,40)"
+       style="fill:#00a300;fill-opacity:1;stroke:none;stroke-opacity:1"
+       id="path2309" />
+    <path
+       d="M 393.794,417 L 379.907,417 L 379.907,328.51 C 372.964,335.093 363.68,340.674 352.057,345.251 L 352.057,331.828 C 368.053,324.165 378.957,314.676 384.768,303.361 L 393.794,303.361 L 393.794,417 z "
+       transform="translate(-33.85833,40)"
+       style="fill:#00a300;fill-opacity:1;stroke:none;stroke-opacity:1"
+       id="path2311" />
+    <path
+       d="M 466.289,303.361 C 490.874,303.361 503.167,322.648 503.167,361.221 C 503.167,380.714 499.991,395.205 493.639,404.695 C 487.287,414.184 478.17,418.928 466.289,418.928 C 441.756,418.928 429.49,399.692 429.49,361.221 C 429.49,341.728 432.666,327.211 439.018,317.671 C 445.37,308.131 454.46,303.361 466.289,303.361 z M 466.289,407.51 C 473.748,407.51 479.38,403.897 483.186,396.671 C 486.992,389.445 488.895,377.628 488.895,361.221 C 488.895,349.804 488.059,340.816 486.387,334.259 C 484.715,327.701 482.195,322.815 478.826,319.6 C 475.458,316.386 471.228,314.779 466.136,314.779 C 458.679,314.779 453.072,318.456 449.317,325.811 C 445.562,333.165 443.685,344.968 443.685,361.221 C 443.685,372.485 444.534,381.409 446.231,387.992 C 447.929,394.576 450.449,399.474 453.792,402.689 C 457.135,405.903 461.3,407.51 466.289,407.51 z "
+       transform="translate(-33.85833,40)"
+       style="fill:#00a300;fill-opacity:1;stroke:none;stroke-opacity:1"
+       id="path2313" />
+  </g>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/inc/perfmon.hrh	Tue Feb 02 00:17:27 2010 +0200
@@ -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/inc/perfmon_app.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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/inc/perfmon_appui.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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/inc/perfmon_datapopupcontainer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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/inc/perfmon_document.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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/inc/perfmon_drawcallback.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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/inc/perfmon_graphscontainer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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/inc/perfmon_graphsview.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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/inc/perfmon_model.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,246 @@
+/*
+* 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/inc/perfmon_settingsviewdlg.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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/inc/perfmon_std.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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/inc/perfmon_valuescontainer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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/inc/perfmon_valuesview.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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/rom/perfmon.iby	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,34 @@
+/*
+* 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_IBY__
+#define __PERFMON_IBY__
+
+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
+
+data=ZPRIVATE\20011385\backup_registration.xml        	private\20011385\backup_registration.xml
+data=ZSYSTEM\Install\PerfMon_stub.sis                   \system\install\PerfMon_stub.sis
+
+#endif // __PERFMON_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/sis/PerfMon_S60-30.pkg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,38 @@
+;
+; 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:
+;
+
+
+; Language - standard language definitions
+&EN
+
+; Standard SIS file header
+#{"PerfMon"},(0x20011385),1,0,0,TYPE=SA
+
+; Supports S60 v 3.0
+[0x101F7961], 0, 0, 0, {"S60ProductID"}
+
+; Non-localised vendor name
+:"Nokia Corporation"
+
+; Localised vendor names
+%{"Nokia Corporation"}
+
+; normal stuff:
+"\epoc32\RELEASE\armv5\UREL\PerfMon.exe"-"!:\sys\bin\PerfMon.exe"
+"\epoc32\data\z\Resource\apps\PerfMon_aif.mif"-"!:\Resource\Apps\PerfMon_aif.mif"
+"\epoc32\data\z\Resource\apps\PerfMon.rsc"-"!:\Resource\Apps\PerfMon.rsc"
+"\epoc32\data\z\PRIVATE\10003A3F\APPS\PerfMon_reg.rsc"-"!:\private\10003a3f\import\apps\PerfMon_reg.rsc"
+"..\group\backup_registration.xml"-"!:\private\20011385\backup_registration.xml"
Binary file perfmon/sis/PerfMon_S60-30.sis has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/sis/PerfMon_stub.pkg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,36 @@
+;
+; 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:
+;
+
+
+; Language - standard language definitions
+&EN
+
+; Standard SIS file header
+#{"PerfMon"},(0x20011385),1,0,0
+
+; Non-localised vendor name
+:"Nokia Corporation"
+
+; Localised vendor names
+%{"Nokia Corporation"}
+
+; normal stuff:
+""-"z:\sys\bin\PerfMon.exe"
+""-"z:\Resource\Apps\PerfMon_aif.mif"
+""-"z:\Resource\Apps\PerfMon.rsc"
+""-"z:\private\10003a3f\import\apps\PerfMon_reg.rsc"
+""-"z:\private\20011385\backup_registration.xml"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/src/perfmon_app.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -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/src/perfmon_appui.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -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/src/perfmon_datapopupcontainer.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -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/src/perfmon_document.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -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/src/perfmon_graphscontainer.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -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/src/perfmon_graphsview.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -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/src/perfmon_model.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,951 @@
+/*
+* 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 = EDataPopupVisbilityAlwaysOn;
+    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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/src/perfmon_settingsviewdlg.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -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/src/perfmon_valuescontainer.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -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/src/perfmon_valuesview.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -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/screengrabber/data/screengrabber.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,550 @@
+/*
+* 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";
+        };
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/data/screengrabber_reg.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,36 @@
+/*
+* 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";    
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/envpatcher/EnvPatcher.pl	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,544 @@
+#
+# 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;    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/envpatcher/ReadMe.txt	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,46 @@
+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".
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/group/ReleaseNotes_ScreenGrabber.txt	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,141 @@
+===============================================================================
+
+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".
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/group/backup_registration.xml	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,8 @@
+<?xml version="1.0" standalone="yes"?>
+<backup_registration>
+  <passive_backup>
+    <include_directory name="\"/>
+  </passive_backup>
+  <system_backup/>
+  <restore requires_reboot = "no"/>
+</backup_registration>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,53 @@
+/*
+* 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/group/screengrabber.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,95 @@
+/*
+* 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/group/screengrabber_icons_aif.mk	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,54 @@
+#
+# 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/group/screengrabber_stub_sis.mk	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,56 @@
+#
+# 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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/icons/qgn_menu_screengrabber.svg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,169 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://web.resource.org/cc/"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   baseProfile="tiny"
+   width="100%"
+   height="100%"
+   viewBox="0 0 88 88"
+   id="svg1926"
+   sodipodi:version="0.32"
+   inkscape:version="0.44"
+   sodipodi:docname="qgn_menu_screengrabber.svg"
+   sodipodi:docbase="X:\ScreenGrabber\aif">
+  <metadata
+     id="metadata1942">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <sodipodi:namedview
+     inkscape:window-height="1110"
+     inkscape:window-width="1600"
+     inkscape:pageshadow="2"
+     inkscape:pageopacity="0.0"
+     guidetolerance="10.0"
+     gridtolerance="10.0"
+     objecttolerance="10.0"
+     borderopacity="1.0"
+     bordercolor="#666666"
+     pagecolor="#ffffff"
+     id="base"
+     inkscape:zoom="8.4442735"
+     inkscape:cx="43.997928"
+     inkscape:cy="45.030743"
+     inkscape:window-x="-4"
+     inkscape:window-y="-4"
+     inkscape:current-layer="svg1926" />
+  <defs
+     id="defs6909">
+    <linearGradient
+       id="linearGradient14494">
+      <stop
+         style="stop-color:#0000bc;stop-opacity:1;"
+         offset="0"
+         id="stop14496" />
+      <stop
+         style="stop-color:#0000bc;stop-opacity:0.71134019;"
+         offset="1"
+         id="stop14498" />
+    </linearGradient>
+  </defs>
+  <g
+     id="g16387"
+     transform="matrix(0.933931,0,0,0.93923,36.62697,-3.375516)">
+    <g
+       id="g14545"
+       transform="matrix(1.00237,0,0,1.019616,-19.44104,89.03461)">
+      <rect
+         style="fill:white;fill-opacity:1;stroke:black;stroke-width:0.2788493;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+         id="rect11835"
+         width="38.227215"
+         height="46.111416"
+         x="-12.352481"
+         y="-76.984528" />
+      <rect
+         style="fill:#0000c8;fill-opacity:1;stroke:black;stroke-width:0;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+         id="rect12722"
+         width="37.948029"
+         height="4.0790625"
+         x="-12.204596"
+         y="-67.491203" />
+    </g>
+    <rect
+       y="-76.984528"
+       x="-12.352481"
+       height="46.111416"
+       width="38.227215"
+       id="rect14551"
+       style="fill:white;fill-opacity:1;stroke:black;stroke-width:0.2788493;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+       transform="matrix(1.00237,0,0,1.019616,-12.79656,94.92987)" />
+    <rect
+       y="-67.491203"
+       x="-12.204596"
+       height="4.0790625"
+       width="37.948029"
+       id="rect14553"
+       style="fill:#0000c8;fill-opacity:1;stroke:black;stroke-width:0;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+       transform="matrix(1.00237,0,0,1.019616,-12.79656,94.92987)" />
+    <rect
+       y="22.592644"
+       x="-17.854233"
+       height="47.015938"
+       width="38.317814"
+       id="rect14559"
+       style="fill:white;fill-opacity:1;stroke:black;stroke-width:0.28190443;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+    <rect
+       y="32.27219"
+       x="-17.705997"
+       height="4.1590772"
+       width="38.037964"
+       id="rect14561"
+       style="fill:#0000c8;fill-opacity:1;stroke:black;stroke-width:0;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+  </g>
+  <g
+     id="g25295"
+     transform="matrix(1,0,0,0.980624,0,1.576279)">
+    <rect
+       y="37.726677"
+       x="41.746223"
+       height="38.990337"
+       width="34.248974"
+       id="rect2069"
+       style="fill:#d03543;fill-opacity:1;stroke:#d03543;stroke-width:9.26854134;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+    <path
+       id="rect2956"
+       d="M 39.728418,36.017758 L 40.699485,36.017758 L 40.699485,36.980375 L 39.728418,36.980375 L 39.728418,36.017758 z "
+       style="fill:white;fill-opacity:1;stroke:white;stroke-width:0.66800833;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+    <path
+       id="path6507"
+       d="M 77.303471,35.71407 L 78.274536,35.71407 L 78.274536,36.676685 L 77.303471,36.676685 L 77.303471,35.71407 z "
+       style="fill:white;fill-opacity:1;stroke:white;stroke-width:0.66800821;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+    <rect
+       y="33.132401"
+       x="43.185398"
+       height="23.865932"
+       width="31.864567"
+       id="rect8279"
+       style="fill:#f7f7ee;fill-opacity:1;stroke:black;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+    <rect
+       y="63.044537"
+       x="49.107658"
+       height="16.862577"
+       width="20.374096"
+       id="rect9166"
+       style="fill:#d5d5d5;fill-opacity:1;stroke:#d5d5d5;stroke-width:2.6285944;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+    <rect
+       y="62.877068"
+       x="51.151539"
+       height="16.583315"
+       width="6.6384521"
+       id="rect10053"
+       style="fill:#d03543;fill-opacity:1;stroke:#d5d5d5;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+  </g>
+  <g
+     transform="matrix(1.00237,0,0,1.019616,-12.79656,94.92987)"
+     id="g14549" />
+  <g
+     id="g27079"
+     transform="translate(-0.273712,-5.897703)">
+    <path
+       id="path19082"
+       d="M 12.524583,46.800016 L 12.524583,63.174645 L 30.994672,63.174645"
+       style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:4.24823713;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+    <path
+       id="path21741"
+       d="M 23.698213,53.535845 L 32.738803,63.153749 L 24.300919,72.504489"
+       style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:4.24823713;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+  </g>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/inc/SG.hrh	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,103 @@
+/*
+* 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/inc/SGApp.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,65 @@
+/*
+* 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
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/inc/SGAppUi.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,90 @@
+/*
+* 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/inc/SGDocument.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,85 @@
+/*
+* 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
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/inc/SGGifAnimator.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,98 @@
+/*
+* 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/inc/SGMainContainer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,97 @@
+/*
+* 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/inc/SGMainView.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,99 @@
+/*
+* 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/inc/SGModel.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,242 @@
+/*
+* 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/inc/SGSettingListContainer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,76 @@
+/*
+* 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/inc/SGSettingListView.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,91 @@
+/*
+* 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/inc/SGStd.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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 SCREENGRABBER_STD_H
+#define SCREENGRABBER_STD_H
+
+
+#endif
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/rom/screengrabber.iby	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,34 @@
+/*
+* 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_IBY__
+#define __SCREENGRABBER_IBY__
+
+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
+
+data=ZPRIVATE\101FB751\backup_registration.xml        	private\101FB751\backup_registration.xml
+data=ZSYSTEM\Install\ScreenGrabber_stub.sis             \system\install\ScreenGrabber_stub.sis
+
+#endif // __SCREENGRABBER_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/sis/ScreenGrabber_S60-30.pkg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,37 @@
+;
+; 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:
+;
+
+; Language - standard language definitions
+&EN
+
+; Standard SIS file header
+#{"ScreenGrabber"},(0x101FB751),4,2,0,TYPE=SA
+
+; Supports S60 v 3.0
+[0x101F7961], 0, 0, 0, {"S60ProductID"}
+
+; Non-localised vendor name
+:"Nokia Corporation"
+
+; Localised vendor names
+%{"Nokia Corporation"}
+
+; normal stuff:
+"\epoc32\RELEASE\armv5\UREL\ScreenGrabber.exe"-"!:\sys\bin\ScreenGrabber.exe"
+"\epoc32\data\z\Resource\apps\ScreenGrabber_aif.mif"-"!:\Resource\Apps\ScreenGrabber_aif.mif"
+"\epoc32\data\z\Resource\apps\ScreenGrabber.rsc"-"!:\Resource\Apps\ScreenGrabber.rsc"
+"\epoc32\data\z\PRIVATE\10003A3F\APPS\ScreenGrabber_reg.rsc"-"!:\private\10003a3f\import\apps\ScreenGrabber_reg.rsc"
+"..\group\backup_registration.xml"-"!:\private\101FB751\backup_registration.xml"
Binary file screengrabber/sis/ScreenGrabber_S60-30.sis has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/sis/ScreenGrabber_S60-32.pkg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,37 @@
+;
+; 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:
+;
+
+; Language - standard language definitions
+&EN
+
+; Standard SIS file header
+#{"ScreenGrabber"},(0x101FB751),4,2,0,TYPE=SA
+
+; Supports S60 v 3.2
+[0x102752AE], 0, 0, 0, {"S60ProductID"}
+
+; Non-localised vendor name
+:"Nokia Corporation"
+
+; Localised vendor names
+%{"Nokia Corporation"}
+
+; normal stuff:
+"\epoc32\RELEASE\armv5\UREL\ScreenGrabber.exe"-"!:\sys\bin\ScreenGrabber.exe"
+"\epoc32\data\z\Resource\apps\ScreenGrabber_aif.mif"-"!:\Resource\Apps\ScreenGrabber_aif.mif"
+"\epoc32\data\z\Resource\apps\ScreenGrabber.rsc"-"!:\Resource\Apps\ScreenGrabber.rsc"
+"\epoc32\data\z\PRIVATE\10003A3F\APPS\ScreenGrabber_reg.rsc"-"!:\private\10003a3f\import\apps\ScreenGrabber_reg.rsc"
+"..\group\backup_registration.xml"-"!:\private\101FB751\backup_registration.xml"
Binary file screengrabber/sis/ScreenGrabber_S60-32.sis has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/sis/ScreenGrabber_stub.pkg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,34 @@
+;
+; 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:
+;
+
+; Language - standard language definitions
+&EN
+
+; Standard SIS file header
+#{"ScreenGrabber"},(0x101FB751),1,0,0
+
+; Non-localised vendor name
+:"Nokia Corporation"
+
+; Localised vendor names
+%{"Nokia Corporation"}
+
+; normal stuff:
+""-"z:\sys\bin\ScreenGrabber.exe"
+""-"z:\Resource\Apps\ScreenGrabber_aif.mif"
+""-"z:\Resource\Apps\ScreenGrabber.rsc"
+""-"z:\private\10003a3f\import\apps\ScreenGrabber_reg.rsc"
+""-"z:\private\101FB751\backup_registration.xml"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/src/SGApp.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -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:  
+*
+*/
+
+
+
+// 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  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/src/SGAppUi.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,148 @@
+/*
+* 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  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/src/SGDocument.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,87 @@
+/*
+* 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  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/src/SGGifAnimator.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,413 @@
+/*
+* 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;
+    }
+
+/*************************************************************************************************/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/src/SGMainContainer.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,399 @@
+/*
+* 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  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/src/SGMainView.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,252 @@
+/*
+* 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
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/src/SGModel.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,1604 @@
+/*
+* 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);
+    }
+
+/*************************************************************************************************/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/src/SGSettingListContainer.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,318 @@
+/*
+* 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  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/src/SGSettingListView.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,155 @@
+/*
+* 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/stifui/group/ReleaseNote.txt	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,47 @@
+========================================================================
+RELEASE NOTE FOR STIF UI - STIF_200952 (7.3.23)
+SUPPORTING SERIES 60 3.0 ->
+========================================================================
+
+Product Description:
+====================
+STIF UI is Series 60 UI application for STIF project.
+STIF is a test harness for testing Symbian & S60 non-UI components.
+This widely used test framework can be used for both test case implementation and test cases execution.
+
+Features :
+=========
+- Easy to use
+- Multiple test cases can be executed concurrently.
+
+
+Enhancements:
+=============
+N/A
+
+
+New Features:
+=============
+N/A
+
+
+System Requirements:
+====================
+Basic Requirements:
+- S60/Symbian OS development environment installed 
+
+- stif project needs to be compiled/installed before stifui can be used
+
+
+Compatibility Issues:
+=====================
+N/A 
+
+Known Issues:
+===========
+If problems with compilation appears (missing platform_paths.hrh file error message), 
+please use EnvPatcher.pl script from stif/envpatcher folder to fix environment. 
+
+
+Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+All rights reserved.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,46 @@
+/*
+* 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 Toplevel build information for STIF UI
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+// Specify the platforms your component needs to be built for here.
+// If not specified all platforms can be built.
+
+// Note that if you want to build STIF to GCCE platform, GCCE must be
+// specified separately - it is not part of default platforms.
+// DEFAULT GCCE
+
+	DEFAULT
+
+
+PRJ_EXPORTS
+// This is added in order to export iby files automaticly in 5.0 env
+	../rom/Stifui.iby     CORE_IBY_EXPORT_PATH(tools,Stifui.iby)
+
+PRJ_TESTEXPORTS
+
+PRJ_MMPFILES
+	// StifUI
+	#include "../stifui/group/bld.inf"
+
+	// UiTestServerStarter
+	#include "../uitestserverstarter/group/bld.inf"
+
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/rom/Stifui.iby	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,47 @@
+/*
+* 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: Stifui.iby file specifies needed STIF and STIF UI 
+* and UITetsServerstarter components for ROM image
+*
+*/
+
+#ifndef __STIF_UI_IBY__
+#define __STIF_UI_IBY__
+
+S60_APP_EXE(Stifui)
+
+#ifdef S60_UPGRADABLE_APP_REG_RSC
+  S60_UPGRADABLE_APP_REG_RSC(Stifui)
+#else
+  S60_APP_AIF_RSC(Stifui)
+#endif
+
+S60_APP_RESOURCE(Stifui)
+
+S60_APP_EXE(UITestServerStarter)
+
+#ifdef S60_UPGRADABLE_APP_REG_RSC
+  S60_UPGRADABLE_APP_REG_RSC(UITestServerStarter)
+#else
+  S60_APP_AIF_RSC(UITestServerStarter)
+#endif
+
+
+S60_APP_RESOURCE(UITestServerStarter)
+
+// Note: before creating image, copy Stifui_31_Stub.sis from \stifui\sis\ to \epoc32\data\Z\system\install\
+data=ZSYSTEM\install\Stifui_31_Stub.sis    System\Install\Stifui_31_Stub.sis
+
+#endif
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/sis/Stifui.pkg	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,67 @@
+;
+; 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: Installation file for STIF UI
+;
+
+; Languages
+&EN
+
+; Package header, uid is the Stifui's uid
+#{"STIF UI"},(0x1028311D),0,1,0,TYPE=SA
+
+; Series60 product id for S60 3.0
+[0x101F7961], 0, 0, 0, {"Series60ProductID"}
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+; Logo
+; None
+
+; Package signature - Optional
+; None
+
+; Start of Package body
+
+; Condition blocks
+; None
+
+; Options list
+; None
+
+; Install files
+
+   ;// Note: STIF needs to be installed before STIF UI can be used
+
+  "\epoc32\release\armv5\udeb\Stifui.exe"-"!:\Sys\Bin\Stifui.exe"
+  "\epoc32\data\z\private\10003a3f\apps\Stifui_reg.rsc"-"!:\Private\10003a3f\import\apps\Stifui_reg.rsc"
+  "\epoc32\data\z\Resource\apps\Stifui.rsc"-"!:\Resource\apps\Stifui.rsc"
+
+  "\epoc32\release\armv5\udeb\UITestServerStarter.exe"-"!:\Sys\Bin\UITestServerStarter.exe"
+  "\epoc32\data\z\private\10003a3f\apps\UITestServerStarter_reg.rsc"-"!:\Private\10003a3f\import\apps\UITestServerStarter_reg.rsc"
+  "\epoc32\data\z\Resource\apps\UITestServerStarter.rsc"-"!:\Resource\apps\UITestServerStarter.rsc"  
+
+; Embedded SIS 
+; None
+
+; End of Package body
+
+; PKG dependencies
+; None
+
+; PKG capabilities
+; None
\ No newline at end of file
Binary file stifui/sis/Stifui_31.sis has changed
Binary file stifui/sis/Stifui_31_Stub.SIS has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/data/Stifui.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,2057 @@
+/*
+* 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: This file defines StifUI resources.
+*
+*/
+
+//	RESOURCE IDENTIFIER
+NAME	STIF // 4 letter ID
+
+//	INCLUDES
+
+#include <eikon.rh>
+#include "Stifui.hrh"
+#include "Stifui_loc.hrh"
+#include <avkon.rsg>
+#include <avkon.rh>
+#include <avkon.mbg>
+#include <avkon.hrh>
+#include <CommonDialogs.hrh> // Enumerations of memory selection, file selection, save etc dialogs
+#include <CommonDialogs.rh> // Resource structures of memory selection, file selection, save etc dialogs
+#if defined (__S60_)
+    #include <data_caging_paths_strings.hrh>
+#endif
+#include <appinfo.rh>
+
+//	CONSTANTS  
+
+
+//	MACROS	
+
+
+//	RESOURCE DEFINITIONS 
+
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE TBUF { buf="STIF UI"; }
+
+RESOURCE EIK_APP_INFO
+	{
+	status_pane = r_appui_status_pane;
+	}
+
+STRUCT STRING 
+    { 
+	BUF text;
+    }
+
+
+//  RESOURCE DEFINITIONS 
+//-----------------------------------------------------------------------------
+//	 
+// r_appui_hotkeys
+// ?description
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE HOTKEYS r_appui_hotkeys
+	{
+	control=
+		{
+		HOTKEY { command=EAknCmdExit; key='e'; }
+		};
+	}
+
+
+// APPUI
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_status_pane
+//	  Applications status panel.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE STATUS_PANE_APP_MODEL r_appui_status_pane
+	{
+	panes=
+		{
+		//SPANE_PANE
+		//	{
+		//	id = EEikStatusPaneUidNavi;
+		//	//type = EEikCtLabel;
+		//	//type = EAknCtTitlePane;
+		//	type = EAknCtNaviPane;
+		//	//resource = r_appui_statuspane_text;
+		//	resource = r_appui_navi_decorator;
+		//	},
+		SPANE_PANE
+			{
+			id = EEikStatusPaneUidTitle;
+			type = EAknCtTitlePane;
+			resource = r_appui_overriden_app_name;
+			}
+		//SPANE_PANE
+		//	{
+		//	id = EEikStatusPaneUidContext;
+		//	type = EAknCtContextPane;
+		//	resource = ;
+		//	}
+		};
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_status_pane
+//	  Status panel text.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE LABEL r_appui_statuspane_text
+    {
+    txt = "STIF UI";
+    }
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_overriden_app_name
+//	  Application name.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE TITLE_PANE r_appui_overriden_app_name
+	{
+	txt = qtn_app_caption_string;
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_navi_decorator
+//	  ?description
+//
+//-----------------------------------------------------------------------------
+//
+/*
+RESOURCE NAVI_DECORATOR r_appui_navi_decorator
+	{
+	type = ENaviDecoratorControlTabGroup;
+	control = TAB_GROUP
+		{
+		tab_width = EAknTabWidthWithTwoTabs;  // two tabs
+		active = 0;
+		tabs = {
+			TAB
+				{
+				id = ETestCaseMenuTab; // from application hrh
+				txt = qtn_testcase_menu_tab;
+				},
+			TAB
+				{
+				id = ETestModulesMenuTab; // from application hrh
+				txt = qtn_testmodules_menu_tab;
+				},
+			TAB
+				{
+				id = ETestSetsMenuTab; // from application hrh
+				txt = qtn_testsets_menu_tab;
+				}
+			};
+		};
+	}
+*/
+
+// MAIN MENU
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_mainmenuview
+//	  Mainmenu view.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_appui_mainmenuview
+	{
+	menubar=r_appui_menubar_mainmenuview;  
+	cba=R_AVKON_SOFTKEYS_OPTIONS_EXIT;
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_menubar_mainmenuview
+//	  Main menu menubar.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_BAR r_appui_menubar_mainmenuview
+	{
+	titles=
+		{
+		MENU_TITLE 
+				{ 
+				menu_pane=r_appui_mainmenuview_menu;
+				}
+		};
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_mainmenuview_menu
+//	  Main menu options menu.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_appui_mainmenuview_menu
+	{
+	items=
+		{
+		MENU_ITEM 
+				{ 
+				command= EAknCmdOpen; 
+				txt = "Open"; 
+				},
+			MENU_ITEM
+				{
+				command = ECmdShowAbout;
+				txt = "About";
+				},
+        	MENU_ITEM 
+				{
+				command = EAknSoftkeyExit;   
+				txt = "Exit";
+				}
+		};
+	}
+
+//-----------------------------------------------------------------------------
+//
+//	  r_main_menu_listbox
+//	  ListBox( Single )
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE LISTBOX r_main_menu_listbox
+	{
+	array_id = r_main_menu_items;
+	flags = EAknListBoxSelectionList;
+	}
+
+//-----------------------------------------------------------------------------
+//
+//	  r_main_menu_items
+//	  Items array for Main Menu
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE ARRAY r_main_menu_items
+	{
+	items =
+		{
+		LBUF
+			{
+			txt = qtn_mainmenulist_test_cases;
+			},
+		LBUF
+			{
+			txt = qtn_mainmenulist_modules;
+			},
+		LBUF
+			{
+			txt = qtn_mainmenulist_test_sets;
+			}
+		};
+	}
+
+
+
+// TEST CASES MENU
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_testcasemenuview
+//	  Test case menu view.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_appui_testcasemenuview
+	{
+	menubar=r_appui_menubar_testcasemenuview;
+	cba=R_AVKON_SOFTKEYS_OPTIONS_BACK;
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_menubar_testcasemenuview
+//	  Test case view menubar.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_BAR r_appui_menubar_testcasemenuview
+	  {
+	titles=
+		{
+		MENU_TITLE 
+				{ 
+				menu_pane=r_appui_testcasemenuview_menu;
+				}
+		};
+
+	  }
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_testcasemenuview_menu
+//	  Testcase view options menu.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_appui_testcasemenuview_menu
+	{
+	items=
+		{
+		MENU_ITEM 
+				{ 
+				command= EAknCmdOpen; 
+				txt = "Open"; 
+				},
+        	MENU_ITEM 
+				{
+				command = EAknSoftkeyExit;   
+				txt = "Exit";
+				}
+		};
+	}
+
+//-----------------------------------------------------------------------------
+//
+//	  r_testcase_menu_listbox
+//	  ListBox( Single )
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE LISTBOX r_testcase_menu_listbox
+	{
+	array_id = r_testcase_menu_items;
+	flags = EAknListBoxSelectionList;
+	}
+
+//-----------------------------------------------------------------------------
+//
+//	  r_testcase_menu_items
+//	  Items array for Test Case Menu
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE ARRAY r_testcase_menu_items
+	{
+	items =
+		{
+		LBUF
+			{
+			txt = qtn_testcasemenu_startcase; // "\tStart Case(s)";
+			},
+		LBUF
+			{
+			txt = qtn_testcasemenu_startedcases; // "\tStarted Cases";
+			}
+		};
+	}
+
+
+
+// START CASES
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_startcasesview
+//	  Startcases view.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_appui_startcasesview
+	{
+	hotkeys=r_appui_hotkeys;
+	menubar=r_appui_menubar_startcasesview;  
+	cba=R_AVKON_SOFTKEYS_OPTIONS_BACK;	  
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_menubar_startcasesview
+//	  Startcases view menubar.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_BAR r_appui_menubar_startcasesview
+	{
+	titles=
+		{
+		MENU_TITLE 
+				{ 
+				menu_pane=r_appui_startcasesview_menu;
+				//menu_pane=R_AVKON_MENUPANE_MARKABLE_LIST;
+				}
+		};
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_loadtestsetview_menu
+//	  loadtestset view options menu.
+//
+//-----------------------------------------------------------------------------
+RESOURCE MENU_PANE r_appui_loadtestsetview_menu
+	{
+	items= 
+		{
+		MENU_ITEM 
+			{ 
+			command=EAknCmdOpen; 
+			txt = qtn_start; 
+			},
+		MENU_ITEM 
+			{ 
+			command=EEikCmdExit; 
+			txt = qtn_exit; 
+			}
+		};
+	}
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_loadtestsetview
+//	  Started cases view.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_appui_loadtestsetview
+	{
+	//hotkeys=r_appui_hotkeys;
+	menubar=r_appui_menubar_startedcasesmenuview;  
+	cba=R_AVKON_SOFTKEYS_OPTIONS_BACK;	  
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_menubar_startedcasesmenuview
+//	  Started cases menubar.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_BAR r_appui_menubar_loadtestsetview
+	  {
+	titles=
+		{
+		MENU_TITLE 
+				{ 
+				menu_pane=r_appui_loadtestsetview_menu;
+				}
+		};
+
+	  }
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_startcasesview_menu
+//	  Startcases view options menu.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_appui_startcasesview_menu
+	{
+	items=
+		{
+		MENU_ITEM
+		    {
+		    command = ECmdFilterMenu;
+		    txt = qtn_filter_menu;
+		    cascade = r_appui_filtermenu;
+		    },
+		/*
+		MENU_ITEM 
+			{ 
+			command=ECmdFilterByModule; 
+			txt = qtn_filter_by_modules; 
+			cascade = r_appui_filterbymodules_menu; 
+			},
+		MENU_ITEM 
+			{ 
+			command=ECmdFilterByTestCaseFile; 
+			txt = qtn_filter_by_test_case_file;
+			cascade = r_appui_filter_by_testcasefile_menu; 
+			},
+		MENU_ITEM 
+			{ 
+			command=ECmdNOFiltering; 
+			txt = qtn_no_filtering; 
+			},
+		*/
+		MENU_ITEM 
+			{ 
+			command=ECmdMarkMenu;
+		    txt = qtn_markmenu_title; 
+		    cascade = r_appui_markunmark_menu;
+		    },
+		MENU_ITEM 
+			{ 
+			command=ECmdStartCases; 
+			txt = qtn_start_test_cases; 
+			},
+		MENU_ITEM 
+			{ 
+			command=EEikCmdExit; 
+			txt = qtn_exit; 
+			}
+		};
+	}
+
+
+
+// STARTED CASES
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_startedcasesmenuview
+//	  Started cases view.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_appui_startedcasesmenuview
+	{
+	//hotkeys=r_appui_hotkeys;
+	menubar=r_appui_menubar_startedcasesmenuview;  
+	cba=R_AVKON_SOFTKEYS_OPTIONS_BACK;	  
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_menubar_startedcasesmenuview
+//	  Started cases menubar.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_BAR r_appui_menubar_startedcasesmenuview
+	  {
+	titles=
+		{
+		MENU_TITLE 
+				{ 
+				menu_pane=r_appui_startedcasesmenuview_menu;
+				}
+		};
+
+	  }
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_startedcasesmenuview_menu
+//	  Started cases view options menu.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_appui_startedcasesmenuview_menu
+	{
+	items=
+		{
+		MENU_ITEM 
+				{ 
+				command= EAknCmdOpen; 
+				txt = "Open"; 
+				},
+        	MENU_ITEM 
+				{
+				command = EAknSoftkeyExit;   
+				txt = "Exit";
+				}
+		};
+	}
+
+//-----------------------------------------------------------------------------
+//
+//	  r_started_cases_menu_listbox
+//	  ListBox( Single )
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE LISTBOX r_started_cases_menu_listbox
+	{
+	array_id = r_startedcases_menu_items;
+	flags = EAknListBoxSelectionList;
+	}
+
+
+
+//-----------------------------------------------------------------------------
+//
+//	  r_startedcases_menu_items
+//	  Items array for Test Case Menu
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE ARRAY r_startedcases_menu_items
+	{
+	items =
+		{
+		LBUF
+			{
+			txt = qtn_startedcases_allcases;
+			},
+		LBUF
+			{
+			txt = qtn_startedcases_ongoing;
+			},
+		LBUF
+			{
+			txt = qtn_startedcases_paused;
+			},
+		LBUF
+			{
+			txt = qtn_startedcases_passed;
+			},
+		LBUF
+			{
+			txt = qtn_startedcases_failed;
+			},
+		LBUF
+			{
+			txt = qtn_startedcases_crashed_aborted;
+			},
+		LBUF
+			{
+			txt = qtn_startedcases_statistics;
+			}
+		};
+	}
+
+
+
+// SHOW STARTED CASES
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_showstartedcasesview
+//	  Show started cases view.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_appui_showstartedcasesview
+	{
+	hotkeys=r_appui_hotkeys;
+	menubar=r_appui_menubar_showstartedcasesview;  
+	cba=R_AVKON_SOFTKEYS_OPTIONS_BACK;	  
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_menubar_showstartedcasesview
+//	  Show started cases view menubar.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_BAR r_appui_menubar_showstartedcasesview
+	{
+	titles=
+		{
+		MENU_TITLE 
+				{ 
+				menu_pane=r_appui_showstartedcasesview_menu;
+				}
+		};
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_showstartedcasesview_menu
+//	  Show started cases view options menu.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_appui_showstartedcasesview_menu
+	{
+	items=
+		{
+		MENU_ITEM 
+			{ 
+			command=ECmdViewOutput; 
+			txt = qtn_view_output; 
+			},
+		MENU_ITEM
+		    {
+		    command = ECmdFilterMenu;
+		    txt = qtn_filter_menu;
+		    cascade = r_appui_filtermenu;
+		    },
+		MENU_ITEM
+		    { 
+			command=ECmdShowSetMenu;
+			txt = qtn_testcase_control_menu;
+			cascade = r_testcase_control_submenu;
+			},
+		MENU_ITEM 
+		    { 
+			command=EEikCmdExit; 
+			txt = qtn_exit; 
+			}
+			
+        /*
+		MENU_ITEM 
+				{ 
+				command=ECmdPauseTestCase; 
+				txt = qtn_pause_testcase; 
+				},
+		MENU_ITEM 
+				{ 
+				command=ECmdResumeTestCase; 
+				txt = qtn_resume_testcase; 
+				},
+		MENU_ITEM 
+				{ 
+				command=ECmdAbortTestCase; 
+				txt = qtn_abort_testcase; 
+				},
+        */
+        
+        /*
+		MENU_ITEM 
+				{ 
+				command=ECmdFilterByModule; 
+				txt = qtn_filter_by_modules; 
+				cascade = r_appui_filterbymodules_menu; 
+				},
+		MENU_ITEM 
+				{ 
+				command=ECmdFilterByTestCaseFile; 
+				txt = qtn_filter_by_test_case_file;
+				cascade = r_appui_filter_by_testcasefile_menu; 
+				},
+		MENU_ITEM 
+				{ 
+				command=ECmdNOFiltering; 
+				txt = qtn_no_filtering; 
+				},
+		*/
+		
+		/*
+		MENU_ITEM 
+				{ 
+				command=ECmdRemoveExecution; 
+				txt = qtn_remove_execution; 
+				},
+		MENU_ITEM 
+				{ 
+				command=ECmdRemoveAllExecutions; 
+				txt = qtn_remove_all_executions; 
+				},
+	    */
+
+		};
+	}
+
+
+// STATISTICS VIEW
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_statisticsview
+//	  Statistics view.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_appui_statisticsview
+	{
+	menubar= r_appui_menubar_statisticsview;
+	cba=R_AVKON_SOFTKEYS_OPTIONS_BACK;	  
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_menubar_statisticsview
+//	  Statistics view menubar.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_BAR r_appui_menubar_statisticsview
+	{
+	titles=
+		{
+		MENU_TITLE 
+			{ 
+			menu_pane=r_appui_statisticsview_menu; 
+			}
+		};
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_statisticsview_menu
+//	  Statistics view options menu.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_appui_statisticsview_menu
+	{
+	items=
+		{
+		MENU_ITEM 
+			{ 
+			command=ECmdFilterByModule; 
+			txt = qtn_filter_by_modules; 
+			cascade = r_appui_filterbymodules_menu; 
+			},
+		MENU_ITEM 
+			{ 
+			command=ECmdFilterByTestCaseFile; 
+			txt = qtn_filter_by_test_case_file;
+			cascade = r_appui_filter_by_testcasefile_menu; 
+			},
+		MENU_ITEM 
+			{ 
+			command=ECmdNOFiltering; 
+			txt = qtn_no_filtering; 
+			},
+
+		MENU_ITEM 
+			{ 
+			command=EEikCmdExit; 
+			txt = qtn_exit; 
+			}
+		};
+	}
+
+
+// TESTCASE OUTPUT VIEW
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_testcaseoutputview
+//	  Testcase output view.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_appui_testcaseoutputview
+	{
+	hotkeys=r_appui_hotkeys;
+	menubar=r_appui_menubar_testcaseoutputview;  
+	cba=R_AVKON_SOFTKEYS_OPTIONS_BACK;	  
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_menubar_testcaseoutputview
+//	  Testcase output view menub bar.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_BAR r_appui_menubar_testcaseoutputview
+	{
+	titles=
+		{
+		MENU_TITLE 
+			{ 
+			menu_pane=r_appui_testcaseoutputview_menu; 
+			}
+		};
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_testcaseoutputview_menu
+//	  Testcase output view options menu.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_appui_testcaseoutputview_menu
+	{
+	items=
+		{
+		MENU_ITEM 
+			{ 
+			command=ECmdPauseTestCase; 
+			txt = qtn_pause_testcase; 
+			},
+		MENU_ITEM 
+			{ 
+			command=ECmdResumeTestCase; 
+			txt = qtn_resume_testcase; 
+			},
+		MENU_ITEM 
+			{ 
+			command=ECmdAbortTestCase; 
+			txt = qtn_abort_testcase; 
+			},
+		MENU_ITEM 
+			{ 
+			command=EEikCmdExit; 
+			txt = qtn_exit; 
+			}
+		};
+	}
+
+
+
+// MODULES MENU
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_testmodulesmenuview
+//	  Test modules menu view.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_appui_testmodulesmenuview
+	{
+	hotkeys=r_appui_hotkeys;
+	menubar=r_appui_menubar_testmodulesmenuview;  
+	cba=R_AVKON_SOFTKEYS_OPTIONS_BACK;	  
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_menubar_testmodulesmenuview
+//	  Test modules view menubar.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_BAR r_appui_menubar_testmodulesmenuview
+	{
+	titles=
+		{
+		MENU_TITLE 
+			{ 
+			menu_pane=r_appui_testmodulesmenuview_menu; 
+			}
+		};
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_testmodulesmenuview_menu
+//	  Testmodules view options menu.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_appui_testmodulesmenuview_menu
+	{
+	items=
+		{
+		// MENU_ITEM 
+		//	{ 
+		//	command=ECmdOpenModule; 
+		//	txt = qtn_open_module; 
+		//	},
+		MENU_ITEM 
+			{ 
+			command=ECmdAddModule; 
+			txt = qtn_add_module; 
+			},
+		MENU_ITEM 
+			{ 
+			command=ECmdRemoveModule; 
+			txt = qtn_remove_module; 
+			},
+	        MENU_ITEM 
+			{ 
+			command=EAknCmdExit; 
+			txt = qtn_exit; 
+			}
+		};
+	}
+
+//-----------------------------------------------------------------------------
+//	  r_testmodules_menu_listbox
+//	  ListBox( Single )
+//
+//-----------------------------------------------------------------------------
+//
+/*
+RESOURCE LISTBOX r_testmodules_menu_listbox
+	{
+	array_id = r_testmodules_menu_items;
+	flags = EAknListBoxSelectionList;
+	}
+*/
+
+//-----------------------------------------------------------------------------
+//	  r_testmodules_menu_items
+//	  Items array for Test Case Menu
+//
+//-----------------------------------------------------------------------------
+//
+/*
+RESOURCE ARRAY r_testmodules_menu_items
+	{
+	items =
+		{
+		LBUF
+			{
+			txt = "\tModule1";
+			},
+		LBUF
+			{
+			txt = "\tModule2";
+			}
+		};
+	}
+*/
+
+
+// TEST SET BASE
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_testsetbasemenuview
+//	  Testset base menu view.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_appui_testsetbasemenuview
+	{
+	menubar=r_appui_menubar_testsetbasemenuview;
+	cba=R_AVKON_SOFTKEYS_OPTIONS_BACK;
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_menubar_testsetbasemenuview
+//	  Testset base menu view menubar.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_BAR r_appui_menubar_testsetbasemenuview
+	  {
+	titles=
+		{
+		MENU_TITLE 
+				{ 
+				menu_pane=r_appui_testsetbasemenuview_menu;
+				}
+		};
+
+	  }
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_testsetbasemenuview_menu
+//	  Testset base menu view options menu.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_appui_testsetbasemenuview_menu
+	{
+	items=
+		{
+		MENU_ITEM 
+				{ 
+				command= ECmdCreateTestSet; 
+				txt = "Create test set";
+				},
+		MENU_ITEM 
+				{ 
+				command= ECmdLoadTestSet; 
+				txt = "Load test set";
+				},
+        	MENU_ITEM 
+				{
+				command = EAknSoftkeyExit;   
+				txt = "Exit";
+				}
+		};
+	}
+
+//-----------------------------------------------------------------------------
+//
+//	  r_testsetbase_menu_listbox
+//	  ListBox( Single )
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE LISTBOX r_testsetbase_menu_listbox
+	{
+	array_id = r_testsetbase_menu_items;
+	flags = EAknListBoxSelectionList;
+	}
+
+
+
+//-----------------------------------------------------------------------------
+//
+//	  r_testsetbase_menu_items
+//	  Items array for Test Sets Base Menu
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE ARRAY r_testsetbase_menu_items
+	{
+	items =
+		{
+		LBUF
+			{
+			txt = qtn_testsetbasemenu_createtestset;
+			},
+		LBUF
+			{
+			txt = qtn_testsetbasemenu_loadtestset;
+			}
+		};
+	}
+
+
+// TESTSET MENU
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_testsetmenuview
+//	  Test set menu view.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_appui_testsetmenuview
+	{
+	menubar=r_appui_menubar_testsetmenuview;
+	cba=R_AVKON_SOFTKEYS_OPTIONS_BACK;
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_menubar_testsetmenuview
+//	  Test set menu view menubar.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_BAR r_appui_menubar_testsetmenuview
+	  {
+	titles=
+		{
+		MENU_TITLE 
+				{ 
+				menu_pane=r_appui_testsetmenuview_menu;
+				}
+		};
+
+	  }
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_testsetmenuview_menu
+//	  Test set menu view options menu.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_appui_testsetmenuview_menu
+	{
+	items=
+		{
+		MENU_ITEM 
+				{ 
+				command= ECmdStartTestSet; 
+				txt = "Start testing";
+				},
+		MENU_ITEM 
+				{ 
+				command= ECmdShowStartedTestSet; 
+				txt = "View started cases";
+				},				
+		MENU_ITEM 
+				{ 
+				command= ECmdSaveTestSet; 
+				txt = "Save test set"; 
+				},
+		MENU_ITEM 
+				{ 
+				command= ECmdInsertTestCases; 
+				txt = "Insert test case(s)";
+				},
+		MENU_ITEM 
+				{ 
+				command= ECmdRemoveTestCases; 
+				txt = "Remove test case"; 
+				},
+        MENU_ITEM 
+				{
+				command = EAknSoftkeyExit;   
+				txt = "Exit";
+				}
+		};
+	}
+
+//-----------------------------------------------------------------------------
+//
+//	  r_testset_menu_listbox
+//	  ListBox( Single )
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE LISTBOX r_testset_menu_listbox
+	{
+	array_id = r_testset_menu_items;
+	flags = EAknListBoxSelectionList;
+	}
+
+
+
+//-----------------------------------------------------------------------------
+//
+//	  r_testset_menu_items
+//	  Items array for Test Sets Menu
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE ARRAY r_testset_menu_items
+	{
+	items =
+		{
+		LBUF
+			{
+			txt = "";
+			}			
+		};
+	}
+
+
+// TESTSET STARTED CASES
+//-----------------------------------------------------------------------------
+//	 
+//	  r_test_set_startedcasesview
+//	  Test set started cases view.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_testset_startedcasesview
+	{
+	//hotkeys=r_appui_hotkeys;
+	menubar=r_testset_menubar_startedcasesview;  
+	cba=R_AVKON_SOFTKEYS_OPTIONS_BACK;	  
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_test_set_menubar_startedcasesview
+//	  Test set started cases view menubar.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_BAR r_testset_menubar_startedcasesview
+	{
+	titles=
+		{
+		MENU_TITLE 
+				{ 
+				menu_pane=r_testset_startedcasesview_menu;
+				}
+		};
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_testset_startedcasesview_menu
+//	  Test set started cases view options menu.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_testset_startedcasesview_menu
+	{
+	items=
+		{
+		MENU_ITEM
+				{
+				txt = qtn_testset_started_menu;
+				cascade = r_testset_startedcases_submenu;
+				},
+		MENU_ITEM 
+				{ 
+				command=ECmdViewOutput; 
+				txt = qtn_view_output; 
+				},
+        MENU_ITEM 
+				{ 
+				command=ECmdShowSetMenu;
+				txt = qtn_testcase_control_menu;
+				cascade = r_testcase_control_submenu;
+				},
+		MENU_ITEM 
+				{ 
+				command=EEikCmdExit; 
+				txt = qtn_exit; 
+				}
+		};
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_testset_startedcases_submenu
+//	  Test set started cases view sub menu.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_testset_startedcases_submenu
+	{
+	items=
+		{
+		MENU_ITEM
+				{
+				command = ECmdShowAllStartedCases;
+				txt = qtn_testset_started_allcases;
+				},
+		MENU_ITEM
+				{
+				command = ECmdShowOngoingCases;
+				txt = qtn_testset_started_ongoing;
+				},
+		MENU_ITEM
+				{
+				command = ECmdShowPausedCases;
+				txt = qtn_testset_started_paused;
+				},
+		MENU_ITEM
+				{
+				command = ECmdShowPassedCases;
+				txt = qtn_testset_started_passed;
+				},
+		MENU_ITEM
+				{
+				command = ECmdShowFailedCases;
+				txt = qtn_testset_started_failed;
+				},
+		MENU_ITEM
+				{
+				command = ECmdShowCrashedAbortedCases;
+				txt = qtn_testset_started_crashed_aborted;
+				}
+		};
+	}
+
+
+// TESTSET INSERT CASES
+//-----------------------------------------------------------------------------
+//	 
+//	  r_insert_testcases_view
+//	  Insert test cases view.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_insert_testcases_view
+	{
+	//hotkeys=r_appui_hotkeys;
+	menubar=r_insert_testcases_menubar;  
+	cba=R_AVKON_SOFTKEYS_OPTIONS_CANCEL;	  
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_insert_testcases_menubar
+//	  Insert test cases view menubar.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_BAR r_insert_testcases_menubar
+	{
+	titles=
+		{
+		MENU_TITLE 
+				{ 
+				menu_pane=r_insert_testcases_menu;
+				}
+		};
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_insert_testcases_menu
+//	  Insert test cases view options menu.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_insert_testcases_menu
+	{
+	items=
+		{
+		MENU_ITEM 
+			{ 
+			command=ECmdInsertSelectedCases;
+			txt = qtn_testsetinsert_add_selected; 
+			},
+        MENU_ITEM
+		    {
+		    command = ECmdFilterMenu;
+		    txt = qtn_filter_menu;
+		    cascade = r_appui_filtermenu;
+		    },
+		MENU_ITEM 
+			{ 
+			command=ECmdMarkMenu;
+		    txt = qtn_markmenu_title; 
+		    cascade = r_appui_markunmark_menu;
+		    },
+		MENU_ITEM 
+			{ 
+			command=EEikCmdExit; 
+			txt = qtn_exit; 
+			}
+		};
+	}
+
+
+
+// GENERAL
+// MARKMENU
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_markunmark_menu
+//	  Submenu for marking items.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_appui_markunmark_menu
+	{
+	items=
+		{
+		MENU_ITEM 
+			{ 
+			command=EAknCmdMark; 
+			txt = qtn_markmenu_mark; 
+			},
+		MENU_ITEM 
+			{ 
+			command=EAknCmdUnmark; 
+			txt = qtn_markmenu_unmark; 
+			},
+		MENU_ITEM 
+			{ 
+			command=EAknMarkAll; 
+			txt = qtn_markmenu_markall; 
+			},
+		MENU_ITEM 
+			{ 
+			command=EAknUnmarkAll; 
+			txt = qtn_markmenu_unmarkall; 
+			}
+		};
+	}
+
+// TEST CASE CONTROL
+//-----------------------------------------------------------------------------
+//	 
+//	  r_testset_stertedcases_setmenu
+//	  Test set started cases view set menu.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_testcase_control_submenu
+	{
+	items=
+		{
+		MENU_ITEM 
+				{ 
+				command=ECmdPauseTestCase; 
+				txt = qtn_pause_testcase; 
+				},
+		MENU_ITEM 
+				{ 
+				command=ECmdResumeTestCase; 
+				txt = qtn_resume_testcase; 
+				},
+		MENU_ITEM 
+				{ 
+				command=ECmdAbortTestCase; 
+				txt = qtn_abort_testcase; 
+				}
+		};
+	}
+
+// FILTERING			
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_filtermenu
+//	  MenuPane for Filter submenu.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_appui_filtermenu
+	{
+	items=
+		{
+		MENU_ITEM 
+			{ 
+			command=ECmdFilterByModule; 
+			txt = qtn_filter_by_modules; 
+			cascade = r_appui_filterbymodules_menu; 
+			},
+		MENU_ITEM 
+			{ 
+			command=ECmdFilterByTestCaseFile; 
+			txt = qtn_filter_by_test_case_file;
+			cascade = r_appui_filter_by_testcasefile_menu; 
+			},
+		MENU_ITEM 
+			{ 
+			command=ECmdNOFiltering; 
+			txt = qtn_no_filtering; 
+			}
+	    };
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_filterbymodules_menu
+//	  MenuPane for Filter submenu.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_appui_filterbymodules_menu
+	{
+	items=
+		{
+		// items (modules) are added dynamically when
+		// Filter by module submenu is opened
+		};
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_appui_filter_by_testcasefile_menu
+//	  MenuPane for Filter submenu.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_appui_filter_by_testcasefile_menu
+	{
+	items=
+		{
+		// Items (testcase files are added dynamically when
+		// Filter by testcase file menu is opened
+		};
+	}
+
+
+// DIALOGS
+// START TEST CASES
+//-----------------------------------------------------------------------------
+//	 
+//	  r_start_testcase_list_query
+//	  Query dialog for starting single test case.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_LIST_QUERY r_start_testcase_list_query
+	{
+	flags = EGeneralQueryFlags;
+	softkeys = R_AVKON_SOFTKEYS_OK_CANCEL;
+	items = 
+		{
+		DLG_LINE   //AVKON_LIST_QUERY_DLG_LINE
+			{
+			type = EAknCtListQueryControl;
+			id = EListQueryControl;
+			control = AVKON_LIST_QUERY_CONTROL
+				{
+				listtype = EAknCtSinglePopupMenuListBox;
+				listbox = LISTBOX		//AVKON_LIST_QUERY_LIST
+					{
+					flags = EAknListBoxMenuList;
+					height = 3;
+					width = 3;
+					array_id = r_start_testcase_listbox_item_array;
+					};
+				heading = qtn_starting_test_case;
+				};
+			}
+		};
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_start_testcase_listbox_item_array
+//	  Listbox items in query dialog for starting single test case.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE ARRAY r_start_testcase_listbox_item_array
+	{
+	items =
+		{
+		LBUF { txt = qtn_start_test; },
+		LBUF { txt = qtn_start_test_output; }
+		};
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_start_multiple_testcases_list_query
+//	  Query dialog for starting multiple test cases.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_LIST_QUERY r_start_multiple_testcases_list_query
+	{
+	flags = EGeneralQueryFlags;
+	softkeys = R_AVKON_SOFTKEYS_OK_CANCEL;
+	items = 
+		{
+		DLG_LINE   //AVKON_LIST_QUERY_DLG_LINE
+			{
+			type = EAknCtListQueryControl;
+			id = EListQueryControl;
+			control = AVKON_LIST_QUERY_CONTROL
+				{
+				listtype = EAknCtSinglePopupMenuListBox;
+				listbox = LISTBOX		//AVKON_LIST_QUERY_LIST
+					{
+					flags = EAknListBoxMenuList;
+					height = 3;
+					width = 3;
+					array_id = r_start_multiple_testcases_listbox_item_array;
+					};
+				heading = qtn_starting_test_cases;
+				};
+			}
+		};
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_start_multiple_testcases_listbox_item_array
+//	  Listbox items in query dialog for starting single test case.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE ARRAY r_start_multiple_testcases_listbox_item_array
+	{
+	items =
+		{
+		LBUF { txt = qtn_start_tests_parallel; },
+		LBUF { txt = qtn_start_tests_serial; }
+		};
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_general_confirmation_dialog
+//	  General confirmation dialog with empty label.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_general_confirmation_dialog
+	{
+	flags = EGeneralQueryFlags;
+	buttons = R_AVKON_SOFTKEYS_YES_NO;
+	items = 
+		{
+		DLG_LINE
+			{
+			type = EAknCtQuery;
+			id = EGeneralQuery;
+			control = AVKON_CONFIRMATION_QUERY
+				{
+				layout = EConfirmationQueryLayout;
+        		label = "";
+				};
+			}
+		};
+
+	} 
+
+//-----------------------------------------------------------------------------
+//	 
+//    r_stifui_about_dialog
+//	  "About" dialog
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_stifui_about_dialog
+{
+    flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow;
+    buttons = R_AVKON_SOFTKEYS_OK_EMPTY;
+    items=
+    {
+        DLG_LINE
+        {
+            type = EAknCtPopupHeadingPane;
+            id = EAknMessageQueryHeaderId;
+            control = AVKON_HEADING
+            {
+                label = "About STIF";
+                headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE;
+            };
+        },
+        DLG_LINE
+        {
+            type = EAknCtMessageQuery;
+            id = EAknMessageQueryContentId;
+            control = AVKON_MESSAGE_QUERY
+            {
+                
+            };
+        }
+    };
+}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_memory_selection_dialog
+//	  Selection dialog for selectiong either C or E drive.
+//        Not yet used.
+//
+//-----------------------------------------------------------------------------
+//
+/*
+RESOURCE MEMORYSELECTIONDIALOG r_memory_selection_dialog
+	{
+	title = "Choose memory:";
+	softkey_1 = "Ok";
+	softkey_2 = "Cancel";
+	locations = 
+		{
+		LOCATION { root_path = "C:\\"; },
+		LOCATION { root_path = "E:\\";  //default_folder = "TestFramework\\";
+                 }
+		};
+	}
+*/
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_file_selection_dialog
+//	  Fileselection dialog.
+//        Not yet used.
+//
+//-----------------------------------------------------------------------------
+//
+/*
+RESOURCE FILESELECTIONDIALOG r_file_selection_dialog
+	{
+	title = "Select-a-file:";
+	root_path = "C:\\";
+	filters =
+		{
+		FILTER
+			{
+			filter_type = EAttributeFilter; //EAttributeFilter;
+			filter_style = EExclusiveFilter; //EExclusiveFilter;
+			filter_data = 
+				{
+				"SH",
+				"R"
+				}; // Excludes system, hidden and read-only attributes
+			}
+		};
+	}
+*/
+    
+
+// APPLICATION NAVIPANEL TITLES
+//-----------------------------------------------------------------------------
+//	 
+//	  r_navititle_main
+//	  Main menu title.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE NAVI_LABEL r_navititle_main
+	{
+	txt = qtn_navi_main;
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_navititle_testcases
+//	  Test cases menu title.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE NAVI_LABEL r_navititle_testcases
+	{
+	txt = qtn_navi_testcases;
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_navititle_startcases
+//	  Startcases menu title.
+//
+//-----------------------------------------------------------------------------
+//	
+RESOURCE NAVI_LABEL r_navititle_startcases
+	{
+	txt = qtn_navi_startcases;
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_navititle_loadtestset
+//	  Startcases menu title.
+//
+//-----------------------------------------------------------------------------
+//	
+RESOURCE NAVI_LABEL r_navititle_loadtestset
+	{
+	txt = qtn_navi_load_test_set;
+	}
+
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_navititle_startedcases
+//	  Started cases menu title.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE NAVI_LABEL r_navititle_startedcases
+	{
+	txt = qtn_navi_startedcases;
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_navititle_testcase_output
+//	  Test case output view title.
+//
+//-----------------------------------------------------------------------------
+//	
+RESOURCE NAVI_LABEL r_navititle_testcase_output
+	{
+	txt = qtn_navi_testcase_output;
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_navititle_modules
+//	  Modules menu title.
+//
+//-----------------------------------------------------------------------------
+//	
+RESOURCE NAVI_LABEL r_navititle_modules
+	{
+	txt = qtn_navi_modules;
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_navititle_testset_base
+//	  Testset base menu title.
+//
+//-----------------------------------------------------------------------------
+//	
+RESOURCE NAVI_LABEL r_navititle_testset_base
+	{
+	txt = qtn_navi_testset_base;
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_navititle_testset
+//	  Testset menu title.
+//
+//-----------------------------------------------------------------------------
+//	
+RESOURCE NAVI_LABEL r_navititle_testset
+	{
+	txt = qtn_navi_testset;
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_navititle_testset_insert
+//	  Testset insert menu title.
+//
+//-----------------------------------------------------------------------------
+//	
+RESOURCE NAVI_LABEL r_navititle_testset_insert
+	{
+	txt = qtn_navi_testset_insert;
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_navititle_started
+//	  Started cases view menu title.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE NAVI_LABEL r_navititle_started
+	{
+	txt = qtn_navi_started;
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_navititle_started_all
+//	  All started cases view menu title.
+//
+//-----------------------------------------------------------------------------
+//	
+RESOURCE NAVI_LABEL r_navititle_started_all
+	{
+	txt = qtn_navi_started_all;
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_navititle_started_ongoing
+//	  Ongoing cases view menu title.
+//
+//-----------------------------------------------------------------------------
+//	
+RESOURCE NAVI_LABEL r_navititle_started_ongoing
+	{
+	txt = qtn_navi_started_ongoing;
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_navititle_started_paused
+//	  Paused cases view menu title.
+//
+//-----------------------------------------------------------------------------
+//	
+RESOURCE NAVI_LABEL r_navititle_started_paused
+	{
+	txt = qtn_navi_started_paused;
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_navititle_started_passed
+//	  Passed cases view menu title.
+//
+//-----------------------------------------------------------------------------
+//	
+RESOURCE NAVI_LABEL r_navititle_started_passed
+	{
+	txt = qtn_navi_started_passed;
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_navititle_started_failed
+//	  Failed cases view menu title.
+//
+//-----------------------------------------------------------------------------
+//	
+RESOURCE NAVI_LABEL r_navititle_started_failed
+	{
+	txt = qtn_navi_started_failed;
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_navititle_started_crashed_aborted
+//	  Crashed cases view menu title.
+//
+//-----------------------------------------------------------------------------
+//	
+RESOURCE NAVI_LABEL r_navititle_started_crashed_aborted
+	{
+	txt = qtn_navi_started_crashed_aborted;
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_navititle_started_stats
+//	  Statistics view menu title.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE NAVI_LABEL r_navititle_started_stats
+	{
+	txt = qtn_navi_started_stats;
+	}
+
+
+// RESOURCE TEXTS
+//-----------------------------------------------------------------------------
+//	 
+//	  r_insert_confirmation_question
+//	  Insert test cases confirmation query text.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE STRING r_insert_confirmation_question
+	{
+	text = qtn_insert_confirmation;
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_insert_nocases_text
+//	  Infomsg text to inform user that there´s no test cases selected when 
+//    trying to insert test cases.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE STRING r_insert_nocases_text
+	{
+	text = qtn_insert_none_selected;
+	}
+	
+//-----------------------------------------------------------------------------
+//	 
+//	  r_insert_confirmation_question
+//	  Overwrite existing test set confirmation query text.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE STRING r_overwrite_testset_question
+	{
+	text = qtn_owerwrite_testset_confirmation;
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_insert_confirmation_question
+//	  Save test set confirmation query text.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE STRING r_save_testset_question
+	{
+	text = qtn_save_testset_confirmation;
+	}
+
+//-----------------------------------------------------------------------------
+//	 
+//	  r_insert_confirmation_question
+//	  Loading test set failed text.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE STRING r_load_testset_failed
+	{
+	text = qtn_load_testset_errornote;
+	}
+
+	
+// TEST CASE STATES
+RESOURCE STRING r_testcase_state_running
+	{
+	text = qtn_testcase_state_running;
+	}
+
+RESOURCE STRING r_testcase_state_passed
+	{
+	text = qtn_testcase_state_passed;
+	}
+
+RESOURCE STRING r_testcase_state_failed
+	{
+	text = qtn_testcase_state_failed;
+	}
+
+RESOURCE STRING r_testcase_state_crashed_aborted
+	{
+	text = qtn_testcase_state_crashed_aborted;
+	}
+	
+RESOURCE STRING r_testcase_state_unknown
+	{
+	text = qtn_testcase_state_unknown;
+	}
+
+RESOURCE LOCALISABLE_APP_INFO r_stifui_localisable_app_info
+    {
+    short_caption = qtn_app_short_caption_string;
+    caption_and_icon = 
+    CAPTION_AND_ICON_INFO
+        {
+        caption = qtn_app_caption_string;
+        };
+    }	
+			
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/data/Stifui_reg.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,37 @@
+/*
+* 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: This file defines StifUI resources.
+*
+*/
+
+#include <Stifui.rsg>
+#include <appinfo.rh>
+#if defined (__S60_)
+  #include <data_caging_paths_strings.hrh>
+#endif
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0x1028311D
+
+RESOURCE APP_REGISTRATION_INFO
+    {
+    app_file = "Stifui";
+    localisable_resource_file = APP_RESOURCE_DIR"\\Stifui";
+    localisable_resource_id = R_STIFUI_LOCALISABLE_APP_INFO;
+    group_name = "RnD Tools";
+    }
+
+// End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/group/Stifui.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,122 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+* 
+* Description: STIFUI MMP file.
+*
+*/
+
+#include <platform_paths.hrh>
+
+SMPSAFE
+
+TARGET 			Stifui.exe
+TARGETTYPE 		exe
+UID             0x100039ce 0x1028311D 
+VENDORID	    0x101FB657
+SECUREID        0x102073DC
+CAPABILITY      AllFiles SwEvent CommDD
+
+START RESOURCE  ../data/Stifui.rss
+	HEADER
+	TARGETPATH  resource/apps
+END 
+
+SOURCEPATH      ../data
+START RESOURCE  ./Stifui_reg.rss
+	DEPENDS stifui.rsg
+	TARGETPATH  /private/10003a3f/apps
+END
+
+SOURCEPATH ../src
+
+
+SOURCE  AppUIApp.cpp 
+SOURCE  AppUIAppUi.cpp
+SOURCE  AppUIDocument.cpp
+SOURCE  View.cpp
+SOURCE  Container.cpp
+SOURCE  UIStoreHandler.cpp
+
+SOURCE  MainMenuView.cpp
+SOURCE  MainMenuContainer.cpp
+
+SOURCE  TestCaseMenuView.cpp
+SOURCE  TestCaseMenuContainer.cpp
+
+SOURCE  StartCasesView.cpp
+SOURCE  StartCasesContainer.cpp
+
+SOURCE  StartedCasesMenuView.cpp
+SOURCE  StartedCasesMenuContainer.cpp
+
+SOURCE  ShowStartedCasesView.cpp
+SOURCE  ShowStartedCasesContainer.cpp
+
+SOURCE  TestCaseOutputView.cpp
+SOURCE  TestCaseOutputContainer.cpp
+
+SOURCE  Testmodulesmenuview.cpp
+SOURCE  TestModulesMenuContainer.cpp
+
+SOURCE	StatisticsView.cpp
+SOURCE	StatisticsContainer.cpp
+
+SOURCE  TestSetBaseMenuView.cpp
+SOURCE  TestSetBaseMenuContainer.cpp
+
+SOURCE  TestSetMenuView.cpp
+SOURCE  TestSetMenuContainer.cpp
+
+SOURCE  TestSetInsertMenuView.cpp
+SOURCE  TestSetInsertMenuContainer.cpp
+
+SOURCE  TestSetStartedCasesView.cpp
+SOURCE  TestSetStartedCasesContainer.cpp
+
+//SOURCE  MenuListBox.cpp
+
+SOURCE  MenuListBox.cpp CreatedTestSetMenuContainer.cpp CreatedTestSetMenuView.cpp
+
+USERINCLUDE ../inc
+
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY euser.lib
+LIBRARY apparc.lib
+LIBRARY cone.lib
+LIBRARY eikcore.lib 
+
+LIBRARY eikcoctl.lib
+LIBRARY avkon.lib
+
+LIBRARY stiftestengine.lib
+LIBRARY stiftestinterface.lib
+LIBRARY bafl.lib
+LIBRARY eikctl.lib 		// For adding icons
+LIBRARY StifTFwIf.lib 
+LIBRARY efsrv.lib
+
+LIBRARY egul.lib
+LIBRARY aknskins.lib
+LIBRARY aknicon.lib
+
+START WINS      
+// ?wins_specific_information
+END
+
+START MARM
+// ?marm_specific_information
+END
+ 
+EPOCHEAPSIZE    0x10000 0x500000
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+* 
+* Description: bld.inf build information for STIF UI.
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+// Specify the platforms your component needs to be built for here.
+// ARM4 not supported in SDK
+	
+	DEFAULT
+
+
+PRJ_EXPORTS
+// None
+
+PRJ_TESTEXPORTS
+// None
+
+PRJ_MMPFILES
+	
+	Stifui.mmp
+
+PRJ_TESTMMPFILES
+// None
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/AppUIApp.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,58 @@
+/*
+* 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: This file contains CAppUIApp class declaration.
+*
+*/
+
+#ifndef APPUIAPP_H
+#define APPUIAPP_H
+
+// INCLUDES
+#include <aknapp.h>
+
+// CONSTANTS
+// UID of the application
+const TUid KUidAppUI = { 0x1028311D };
+
+// CLASS DECLARATION
+
+/**
+* CAppUIApp application class.
+* Provides factory to create concrete document object.
+* 
+*/
+class CAppUIApp : public CAknApplication
+    {
+    
+    public: // Functions from base classes
+    private:
+
+        /**
+        * From CApaApplication, creates CAppUIDocument document object.
+        * @return A pointer to the created document object.
+        */
+        CApaDocument* CreateDocumentL();
+        
+        /**
+        * From CApaApplication, returns application's UID (KUidAppUI).
+        * @return The value of KUidAppUI.
+        */
+        TUid AppDllUid() const;
+    };
+
+#endif
+
+// End of File
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/AppUIAppUi.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,222 @@
+/*
+* 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: This file contains CAppUIAppUi class declaration.
+*
+*/
+
+#ifndef APPUIAPPUI_H
+#define APPUIAPPUI_H
+
+// INCLUDES
+#include <eikapp.h>
+#include <e32std.h>
+#include <aknviewappui.h>
+#include <akntabgrp.h>
+#include <aknnavide.h>
+#include <StifLogger.h>
+#include "Stifui.hrh"
+
+//#include "UIStoreIf.h"             
+//#include "UIStore.h"               
+//#include "UIEngine.h"              
+//#include "SettingServerClient.h"   
+
+#include <stifinternal/UIStoreIf.h>
+#include <stifinternal/UIStore.h>
+#include <stifinternal/UIEngine.h>
+#include <SettingServerClient.h>
+
+#include "UIStoreHandler.h"
+
+
+// FORWARD DECLARATIONS
+class CAppUIContainer;
+class CUIStoreHandler;
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+_LIT( KDefaultPathAndIni, "C:\\TestFramework\\TestFramework.ini" );
+
+// CLASS DECLARATION
+
+
+/**
+ * Class contains static methods for calling different
+ * types of message dialog boxes.
+ */
+class TMessageBoxUtil 
+	{
+	public:
+	
+	    /**
+	     * Display message that executed funtion is not implemented yet.
+	     */      
+		static void ShowNotImplementedYetL();
+
+	    /**
+	     * Display error note.
+	     * @param aMessage Error message to display.
+	     */      
+		static void ShowErrorNoteL( const TDesC& aMessage );
+	};
+
+
+/**
+* Application UI class.
+* Provides support for the following features:
+* - EIKON control architecture
+* - view architecture
+* - status pane
+* 
+*/
+class CAppUIAppUi : public CAknViewAppUi
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Symbian OS default constructor.
+        */      
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */      
+        ~CAppUIAppUi();
+
+    public: // New functions
+
+        /**
+        * Returns pointer to UIStoreHandler object, 
+        * which handles test cases and test modules.
+        * @return UIStoreHandler to CData object
+        */
+        CUIStore* UIStoreHandler();
+
+        /**
+        * Shows outputs of the test case.
+        * @param aTestCase Pointer to started test case.
+        */
+        void ShowTestCaseOutput(CStartedTestCase* aTestCase);
+
+        /**
+        * Receives output update notification from CData.
+        * @param aTestCase Pointer to started test case.
+        * @param aStatus Status.
+        */
+        void OutputUpdateL( CStartedTestCase* aTestCase, TInt aStatus );
+        
+		/**
+        * Sets pointer to selected test case for viewing output.
+        * @param aStartedCase Pointer to started test case.
+        */
+        void SetStartedTestCase( CStartedTestCase* aStartedCase );   
+         
+        /**
+        * Returns pointer to started test case for viewing output.
+        * @return Poiner to started test case.
+        */
+		CStartedTestCase* GetStartedTestCase( ); 
+		
+		/**
+		 * Saves position of focus of any specific view
+		 * @param aViewId ID of view under which the position will be stored
+		 * @param aPosition is a number to be stored
+		 */
+		void SaveFocusPosition(TAppUIViewNumber aViewId, TInt aPosition);
+		
+		/**
+		 * Used to retrieve previous focus position in a specific view
+		 * @param aViewId - ID of view that the position should be retrieved for
+		 * @return the previous focus position
+		 */
+		TInt GetFocusPosition(TAppUIViewNumber aViewId);
+		
+
+    public: // Functions from base classes
+
+    private:
+        /**
+        * Initializes menu pane.
+        * @param aResourceId Menu pane resource ID.
+        * @param aMenuPane Menu pane pointer.
+        */
+        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
+        CUIStoreHandler*                iUIStoreHandler;
+        CStartedTestCase*               iStartedTestCase;
+        TInt                            iPreviousView; // For Back function
+        
+        RArray<TInt>					iPreviousFocusPosition;	
+        // used to store positions in different views
+        
+        TBool							iPreviousPositionListValid; 
+        // used to mark validity of iPreviousFocusPosition array
+		
+    public: //Data
+        
+        /**
+        * Pointer to logger.
+        */
+        CStifLogger*                        iLogger;
+        
+        /**
+        * Mode of view started cases.
+        */
+        TInt /*enum TShowStartedCasesMode*/ iShowStartedCasesMode;
+        
+        /**
+        * Index of started test set.
+        */
+		TInt								iStartedTestSet;
+		
+	    /**
+        * Handle to Setting server.
+        */	
+		RSettingServer                      iSettingServer;
+		
+    public:     // Friend classes
+
+    protected:  // Friend classes
+
+    private:    // Friend classes
+                
+        // For iExecutedTestCaseCount moving
+        friend class CStartCasesView;
+        friend class CStatisticsView;
+        friend class CTestCaseOutputView;
+        friend class CTestSetInsertMenuView;
+        friend class CTestSetMenuView;
+
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/AppUIDocument.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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: This file contains CAppUIDocument class declaration.
+*
+*/
+
+#ifndef APPUIDOCUMENT_H
+#define APPUIDOCUMENT_H
+
+// INCLUDES
+#include <akndoc.h>
+   
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class  CEikAppUi;
+
+// CLASS DECLARATION
+
+/**
+*  CAppUIDocument application class.
+*/
+class CAppUIDocument : public CAknDocument
+    {
+    public: // Constructors and destructor
+        /**
+        * Two-phased constructor.
+        */
+        static CAppUIDocument* NewL(CEikApplication& aApp);
+
+        /**
+        * Destructor.
+        */
+        virtual ~CAppUIDocument();
+
+    public: // New functions
+
+    protected:  // New functions
+
+    protected:  // Functions from base classes
+
+    private:
+
+        /**
+        * Symbian OS default constructor.
+        */
+        CAppUIDocument(CEikApplication& aApp);
+        void ConstructL();
+
+    private:
+
+        /**
+        * From CEikDocument, create CAppUIAppUi "App UI" object.
+        */
+        CEikAppUi* CreateAppUiL();
+    };
+
+#endif
+
+// End of File
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/Container.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,263 @@
+/*
+* 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: This file contains CTestCaseListBoxModel class
+* declaration
+*
+*/
+
+#ifndef CCONTAINER_H
+#define CCONTAINER_H
+
+#include <e32std.h>
+// Define *.mbm file name.
+_LIT(KListMbmFileName, "\\Resource\\Apps\\Stifui.mbm");
+
+// INCLUDES
+#include "View.h"
+
+#include <coecntrl.h>
+#include <eiklbo.h>     //  MEikListBoxObserver
+#include <bamdesca.h>   //  MDesCArray
+#include <aknsfld.h>
+
+//#include "RRefArray.h"        
+//#include "UIEngine.h"         
+//#include "UIStoreIf.h"        
+//#include "UIStoreContainer.h" 
+
+#include <stifinternal/RRefArray.h>
+#include <stifinternal/UIEngine.h>
+#include <stifinternal/UIStoreIf.h>
+#include <stifinternal/UIStoreContainer.h>
+   
+// FORWARD DECLARATIONS
+class CEikTextListBox;
+class CDesC16Array;
+
+//class CTestSetInsertMenuView;
+class CEikColumnListBox;
+class CStartedTestCase;
+
+class CUIStoreHandler;
+class CUIStore;
+class CUIStoreIf;
+class CUIEngineContainer;
+class CUIEngine;
+
+// CLASS DECLARATION
+
+class CTestCaseListBoxModel : public CBase, public MDesCArray
+    {
+    public:
+        /**
+        * Destructor.
+        */
+        ~CTestCaseListBoxModel();
+        
+        /**
+        * Two-phased constructor.
+        * @param aTestCasesInView Array of test cases in view.
+        * @return Pointer to created list box model.
+        */
+        static CTestCaseListBoxModel* NewL(
+            RPointerArray<CTestInfo>* aTestCasesInView);
+
+    public: // Functions from base classes
+    
+        /**
+        * Returns the number of descriptor elements in the array.
+        * @return The number of descriptor elements.
+        */
+        virtual TInt MdcaCount() const;
+        
+        /**
+        * Indexes into a descriptor array.
+        * @param aIndex The position of the descriptor element within the
+        *               array. The position is relative to zero; i.e. zero
+        *               implies the first descriptor element in the array. 
+        *               This value must be non-negative and less than the 
+        *               number of descriptors currently within the array 
+        *               otherwise the operator panics with 
+        *               EArrayIndexOutOfRange. 
+        * @return A non-modifiable pointer descriptor representing the 
+        *         descriptor element located at position aIndex within 
+        *         the array.
+        */
+        virtual TPtrC MdcaPoint(TInt aIndex) const;
+
+    protected:
+        /**
+        * Symbian OS two phased constructor.
+        * Completes the construction of the object.
+        */
+        void ConstructL();
+    
+    protected: //data
+        RPointerArray<CTestInfo>*   iTestCasesInView;
+        HBufC*                      iBuffer;
+        
+    private: //data
+        
+    };
+    
+/**
+*  CContainer  container control class.
+*  
+*/
+class CContainer : public CCoeControl
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Symbian OS default constructor.
+        * @param aRect Frame rectangle for container.
+        */
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */
+        ~CContainer();
+
+    public: // New functions
+    
+        /**
+        * Show only testcases which are defined is specified module.
+        * @param aModuleName Module which test cases are shown.
+        */
+        virtual void FilterCasesByModuleL(TName aModuleName);
+        
+        /**
+        * Show only testcases which are defined in specified test case file.
+        * @param aTestCaseFileName Test cases file name.
+        */
+        virtual void FilterCasesByTCFileNameL(TFileName aTestCaseFileName);
+        
+        /**
+        * Remove possible filtering of test cases -> show all test cases.
+        */
+        virtual void NoFilteringL();
+        
+        /**
+        * Returns pointers to selected test cases.
+        * @param aSelectedTestCases Currently selected test case.
+        */
+        virtual void SelectedTestCases(RPointerArray<CTestInfo>& aSelectedTestCases);
+
+        /**
+        * Sets graphic icon using listbox as CEikColumnListBox.
+        * @param aListBox Pointer to list box.
+        */
+        virtual void SetGraphicIconL( CEikColumnListBox* aListBox );
+
+        /**
+        * Appends graphics data.
+        * @param aIcons Pointer array of icons.
+        */
+        virtual void GraphicIconL( CArrayPtr<CGulIcon>* aIcons );
+        
+        /**
+        * Gets the index number of the current item in the view.
+        * @return Index number of the current item.
+        */
+        virtual TInt CurrentItemIndex();
+        
+        /**
+        * Sets the current item.
+        * @param aIndex Index of the item to make current.
+        */
+        virtual void SetCurrentItemIndex(TInt aCurrentTestCase);
+		
+		/**
+		* Inline function for getting pointer to list box.
+		* @return Pointer to list box.
+		*/
+		virtual inline CEikListBox* ListBox() { return (CEikListBox*)iListBox; };
+		
+		
+		
+		/**
+		* Processes user commands.
+		* @param aCommand ID of the command to respond to.
+		*/
+		virtual void ProcessCommandL( TInt  aCommand );
+		
+		/**
+		* Processes user commands.
+		* @param aCommand ID of the command to respond to.
+		*/
+		virtual void SelectionListProcessCommandL( TInt  aCommand );
+		
+		/**
+		* Handles mark commands.
+		* @param aCommand ID of the command to respond to.
+		*/
+		virtual void HandleMarkCommandL( TInt aCommand );
+		
+		
+		
+    public: // Functions from base classes
+
+    private: // Functions from base classes
+
+        /**
+        * From CoeControl,SizeChanged.
+        * Called by framework when the view size is changed.
+        */
+        virtual void SizeChanged();
+
+
+
+
+        /**
+        * From CoeControl,CountComponentControls.
+        * Gets a count of the component controls of this list box control.
+        * This information is used for DrawNow().
+        */
+        virtual TInt CountComponentControls() const;
+
+        /**
+        * From CCoeControl,ComponentControl.
+        * Gets a pointer to the specified component control.
+        * @param aIndex Index of the component control to look up.
+        * @return The control at aIndex.
+        */
+        virtual CCoeControl* ComponentControl(TInt aIndex) const;
+
+
+
+        /**
+        * From CCoeControl,Draw.
+        * Draw a control, called by window server.
+        * @param aRect The region of the control to be redrawn. Co-ordinates
+        *              are relative to the control's origin (top left corner).
+        */
+        virtual void Draw(const TRect& aRect) const;
+        
+    protected: //data
+        
+        CView*                          iParentView;
+        CEikColumnListBox*              iListBox;
+        //CEikTextListBox*                iListBox;
+        CTestCaseListBoxModel*          iListBoxModel;
+        RPointerArray<CTestInfo>        iTestCasesInView;
+        CUIStore*                       iUIStore;
+                        
+    private: //data
+        
+    };
+
+#endif // CTestSetInsertMenuContainer_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/CreatedTestSetMenuContainer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -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: This file contains CCreatedTestSetMenuContainer
+* class declaration.
+*
+*/
+
+#ifndef CREATETESTSETMENUCONTAINER_H
+#define CREATETESTSETMENUCONTAINER_H
+
+// INCLUDES
+#include "Container.h"
+
+#include <coecntrl.h>
+#include <eiklbo.h> // MEikListBoxObserver
+#include <bamdesca.h> // MDesCArray
+#include <aknsfld.h>
+
+#include <stifinternal/RRefArray.h>
+#include <stifinternal/UIEngine.h>
+#include <stifinternal/UIStoreIf.h>
+#include <stifinternal/UIStoreContainer.h>
+   
+// FORWARD DECLARATIONS
+class CEikTextListBox;
+class CDesC16Array;
+
+class CCreatedTestSetMenuView;
+class CEikColumnListBox;
+class CStartedTestCase;
+
+class CUIStoreHandler;
+class CUIStore;
+class CUIStoreIf;
+class CUIEngineContainer;
+class CUIEngine;
+
+// CLASS DECLARATION
+/**
+*  CCreatedTestSetMenuContainer  container control class.
+*  
+*/
+class CCreatedTestSetMenuContainer : public CContainer//public CCoeControl /*, MEikListBoxObserver */ /* MCoeControlObserver */
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Symbian OS default constructor.
+        * @param aRect Frame rectangle for container.
+        */
+        void ConstructL(const TRect& aRect, MEikListBoxObserver* aListBoxObserver);
+
+        /**
+        * Destructor.
+        */
+        ~CCreatedTestSetMenuContainer();
+
+    public: // New functions
+        
+        /**
+         * Stores current position of focus of iListBox to the CAppUiAppUi object
+         */
+        void SaveActiveLine();
+        
+    public: // Functions from base classes
+
+    private: // Functions from base classes
+
+        /**
+        * From CoeControl,SizeChanged.
+        * Called by framework when the view size is changed.
+        */
+        void SizeChanged();
+
+        /**
+        * From CoeControl,CountComponentControls.
+        * Gets a count of the component controls of this list box control.
+        * This information is used for DrawNow().
+        */
+        TInt CountComponentControls() const;
+
+        /**
+        * From CCoeControl,ComponentControl.
+        * Gets a pointer to the specified component control.
+        * @param aIndex Index of the component control to look up.
+        * @return The control at aIndex.
+        */
+        CCoeControl* ComponentControl(TInt aIndex) const;
+
+        /**
+        * From CCoeControl,Draw.
+        * Draw a control, called by window server.
+        * @param aRect The region of the control to be redrawn. Co-ordinates
+        *              are relative to the control's origin (top left corner).
+        */
+        void Draw(const TRect& aRect) const;
+        
+        /**
+        * From CCoeControl,OfferKeyEventL
+        * Handles key events.
+        * @param aKeyEvent The key event.
+        * @param aType The type of key event.
+        * @return Indicates whether or not the key event was used 
+        *         by this control.
+        */
+		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
+		        
+    private: //data
+        
+        CCreatedTestSetMenuView*            iParentView;
+    };
+
+#endif // CREATETESTSETMENUCONTAINER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/CreatedTestSetMenuView.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,120 @@
+/*
+* 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: This file contains CCreatedTestSetMenuView class
+* declaration.
+*
+*/
+
+#ifndef CREATEDTESTSETSETMENUVIEW_H
+#define CREATEDTESTSETSETMENUVIEW_H
+
+// INCLUDES
+#include "View.h"
+#include <eiklbo.h> // MEikListBoxObserver
+#include <aknnavide.h> 
+
+
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class CCreatedTestSetMenuContainer;
+
+
+// CLASS DECLARATION
+
+/**
+*  CTestCaseMenuView view class.
+* 
+*/
+class CCreatedTestSetMenuView : public CView, public MEikListBoxObserver //CAknView
+    {
+    public: // Constructors and destructor
+
+        /**
+        * Symbian OS default constructor.
+        */
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */
+        ~CCreatedTestSetMenuView();
+
+    public: // Functions from base classes
+        
+        /**
+        * Returns view´s id.
+        * @return View id.
+        */
+        TUid Id() const;
+
+        /**
+        * Handles a command.
+        * @param aCommand A command ID.
+        */
+        void HandleCommandL( TInt aCommand );
+
+        /**
+        * Handles client rect changes.
+        */
+        void HandleClientRectChange();
+
+        /**
+        * Handles a list box event.
+        * @param aListBox A pointer to list box.
+        * @param aEventType Type of list box event.
+        */
+        void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
+
+    public: // New functions
+        
+     
+
+    private:
+
+        /**
+        * Initializes view when activated.
+        * @param aPrevViewId Id of the previous view (not used).
+        * @param aCustomMessageId Custom message id (not used).
+        * @param aCustomMessage Custom message (not used).
+        */
+        void DoActivateL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,
+            const TDesC8& aCustomMessage);
+
+        /**
+        * Deactivates view.
+        */
+        void DoDeactivate();
+
+    
+    private: // New functions
+        
+        /**
+        * Checks listbox selections and launches 
+        * query dialog to start test cases.
+        * @param aListBox Pointer to listbox.
+        */
+        void CheckListBoxSelectionsL(CEikListBox* aListBox);
+
+    private: // Data
+        CAknNavigationDecorator*    iNaviDecorator;
+        CCreatedTestSetMenuContainer*       iContainer;
+        TInt                        iCurrentTestCase;
+        TBufC<50>                   iCurrentTestSet;
+        TBool                       iSaveNeeded;
+    };
+
+#endif //CREATEDTESTSETSETMENUVIEW_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/MainMenuContainer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,127 @@
+/*
+* 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: This file contains CMainMenuContainer class definition.
+*
+*/
+
+#ifndef CMAINMENUCONTAINER_H
+#define CMAINMENUCONTAINER_H
+
+// INCLUDES
+#include <coecntrl.h>
+#include <eiklbo.h>
+
+   
+// FORWARD DECLARATIONS
+class CEikTextListBox;
+
+// CLASS DECLARATION
+
+/**
+*  CMainMenuContainer  container control class.
+*  
+*/
+class CMainMenuContainer : public CCoeControl, public MEikListBoxObserver /* MCoeControlObserver */
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Symbian OS default constructor.
+        * @param aRect Frame rectangle for container.
+        */
+        void ConstructL(const TRect& aRect);
+
+        /**
+        * Destructor.
+        */
+        ~CMainMenuContainer();
+
+    public: // New functions
+    
+        /**
+        * Get currently selected items index.
+        * @return Current item index.
+        */		
+		TInt GetActiveLine();   
+		
+		/**
+		 * Makes the iListBox store its focus position to CAppUiAppUi object
+		 */
+		void SaveActiveLine();
+
+    public: // Functions from base classes
+   
+        /**
+        * Method HandleSelectedListItemL handles valix index.
+        * @param aIndex Current item index.
+        */
+        void HandleSelectedListItemL( TInt aIndex );    
+
+    private: // Functions from base classes
+
+        /**
+        * From CoeControl,SizeChanged.
+        * Called by framework when the view size is changed.
+        */
+        void SizeChanged();
+
+        /**
+        * From CoeControl,CountComponentControls.
+        * @return Number of controls indside this container.
+        */
+        TInt CountComponentControls() const;
+
+        /**
+        * From CCoeControl,ComponentControl.
+        * Gets the specified component of a compound control.
+        * @param aIndex The index of the control to get.
+        * @return The component control with an index of aIndex.
+        */
+        CCoeControl* ComponentControl(TInt aIndex) const;
+
+        /**
+        * From CCoeControl,Draw.
+        * Draw a control, called by window server.
+        * @param aRect The region of the control to be redrawn. Co-ordinates 
+        *              are relative to the control's origin (top left corner).
+        */
+        void Draw(const TRect& aRect) const;
+
+        /**
+        * Handles list box events.
+        * @param aListBox The originating list box. 
+        * @param aEventType A code for the event. Further information may be
+        *                   obtained by accessing the list box itself.
+        */
+		void HandleListBoxEventL(CEikListBox* aListBox,TListBoxEvent aEventType);
+
+        /**
+        * From CCoeControl,OfferKeyEventL
+        * Handles key events.
+        * @param aKeyEvent The key event.
+        * @param aType The type of key event.
+        * @return Indicates whether or not the key event was used 
+        *         by this control.
+        */
+		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
+		
+        
+    private: //data
+        
+		CEikTextListBox*    iListBox;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/MainMenuView.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,94 @@
+/*
+* 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: This file contains CMainMenuView class declaration.
+*
+*/
+
+#ifndef MAINMENUVIEW_H
+#define MAINMENUVIEW_H
+
+// INCLUDES
+#include "View.h"
+#include <aknnavide.h> 
+
+// CONSTANTS
+// UID of view
+const TUid KMainMenuViewId = {1};
+
+// FORWARD DECLARATIONS
+class CMainMenuContainer;
+
+// CLASS DECLARATION
+
+/**
+*  CMainMenuView view class.
+* 
+*/
+class CMainMenuView : public CView //CAknView
+    {
+    public: // Constructors and destructor
+
+        /**
+        * Symbian OS default constructor.
+        */
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */
+        ~CMainMenuView();
+
+    public: // Functions from base classes
+        
+        /**
+        * Returns view´s id.
+        * @return View id.
+        */
+        TUid Id() const;
+
+        /**
+        * Handles a command.
+        * @param aCommand A command ID.
+        */
+        void HandleCommandL( TInt aCommand );
+
+        /**
+        * Handles client rect changes.
+        */
+        void HandleClientRectChange();
+
+    private:
+        
+        /**
+        * Initializes view when activated.
+        * @param aPrevViewId Id of the previous view (not used).
+        * @param aCustomMessageId Custom message id (not used).
+        * @param aCustomMessage Custom message (not used).
+        */
+        void DoActivateL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,
+            const TDesC8& aCustomMessage);
+
+        /**
+        * Deactivates view.
+        */
+        void DoDeactivate();
+
+    private: // Data
+        CMainMenuContainer*         iContainer;
+        CAknNavigationDecorator*    iNaviDecorator;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/MenuListBox.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,75 @@
+/*
+* 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: This file contains CMenuListBox class declaration.
+*
+*/
+
+#ifndef MENULISTBOX_H_
+#define MENULISTBOX_H_
+
+// INCLUDES
+#include <eiktxlbx.h>
+#include "Stifui.hrh"
+#include "AppUIAppUi.h"
+#include <AknView.h>
+#include <aknlists.h>
+
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+*  CMenuListBox class. Has ability to store and retrieve previous focus position
+*/
+class CMenuListBox : public CAknSingleStyleListBox
+    {
+    public: // Constructors and destructor
+
+        static CMenuListBox* NewL(TAppUIViewNumber aViewId);
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CMenuListBox();
+        
+        /**
+         * Sets focus on last chosen position
+         */
+        void SetPreviousFocus();
+        
+        /**
+         * Saves position of focus to CAppUiAppUi object
+         */
+        void SaveFocusPosition();
+        
+    private: // Constructors and destructor
+    
+    	CMenuListBox(TAppUIViewNumber aViewId);
+    	
+    	/**
+        * Symbian OS default constructor.
+        */
+        void ConstructL();
+
+    public: // Functions from base classes
+
+    private:
+
+    private: // Data
+    	const TAppUIViewNumber	iViewId;
+    };
+
+#endif /*MENULISTBOX_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/ShowStartedCasesContainer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,252 @@
+/*
+* 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: This file contains CStartedTestsListBoxModel class
+* declaration.
+*
+*/
+
+#ifndef CSHOWSTARTEDCASESCONTAINER_H
+#define CSHOWSTARTEDCASESCONTAINER_H
+
+// INCLUDES
+#include "Container.h"
+
+#include <coecntrl.h>
+#include <eiklbo.h>
+#include <bamdesca.h> // MDesCArray
+
+//#include "RRefArray.h" 
+#include <stifinternal/RRefArray.h>
+
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class CEikTextListBox;
+class CAknSingleGraphicStyleListBox;
+class CDesC16ArrayFlat;
+class CStartedTestCase;
+class CUIStore;
+
+// CLASS DECLARATION
+
+class CStartedTestsListBoxModel : public CTestCaseListBoxModel //public CBase, public MDesCArray
+    {
+    public:
+        /**
+        * Destructor.
+        */
+        ~CStartedTestsListBoxModel();
+        
+        /**
+        * Two-phased constructor.
+        * @param aTestsInView Array of test cases in view.
+        * @return Pointer to created list box model.
+        */
+        static CStartedTestsListBoxModel* NewL(
+                            RRefArray<CStartedTestCase>* aTestsInView);
+
+    public: // Functions from base classes
+        
+        /**
+        * Returns the number of descriptor elements in the array.
+        * @return The number of descriptor elements.
+        */
+        TInt MdcaCount() const;
+        
+        /**
+        * Indexes into a descriptor array.
+        * @param aIndex The position of the descriptor element within the
+        *               array. The position is relative to zero; i.e. zero
+        *               implies the first descriptor element in the array. 
+        *               This value must be non-negative and less than the 
+        *               number of descriptors currently within the array 
+        *               otherwise the operator panics with 
+        *               EArrayIndexOutOfRange. 
+        * @return A non-modifiable pointer descriptor representing the 
+        *         descriptor element located at position aIndex within 
+        *         the array.
+        */
+        TPtrC MdcaPoint(TInt aIndex) const;
+
+    private:
+
+        /**
+        * Symbian OS two phased constructor.
+        * Completes the construction of the object.
+        */
+        void ConstructL();
+
+    private: //data
+        RRefArray<CStartedTestCase>*        iTestCasesInView;
+    };
+
+/**
+*  CShowStartedCasesContainer  container control class.
+*  
+*/
+class CShowStartedCasesContainer : public CContainer //public CCoeControl /*, MEikListBoxObserver */ /* MCoeControlObserver */
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Symbian OS default constructor.
+        * @param aRect Frame rectangle for container.
+        * @return Observer for list box.
+        */
+        void ConstructL(const TRect& aRect, MEikListBoxObserver* aListBoxObserver);
+
+        /**
+        * Destructor.
+        */
+        ~CShowStartedCasesContainer();
+
+    public: // New functions
+        
+        /**
+        * Show only testcases which are defined is specified module.
+        * @param aModuleName Module which test cases are shown.
+        */
+        void FilterCasesByModuleL(TName aModuleName);
+        
+        /**
+        * Show only testcases which are defined in specified test case file.
+        * @param aTestCaseFileName Test cases file name.
+        */
+        void FilterCasesByTCFileNameL(TFileName aTestCaseFileName);
+        
+        /**
+        * Remove possible filtering of test cases -> show all test cases.
+        */
+        void NoFilteringL();
+        
+        /**
+        * Returns reference to currently selected test case in view (listbox).
+        * @return Currently selected test case.
+        */
+        CStartedTestCase* SelectedTestCase();
+        
+        /**
+        * Constructs list box model without any filtering.
+        */
+        void ConstructListBoxModelL();
+        
+        /**
+        * Draws the list box.
+        */
+        void DrawListBox();
+        
+        /**
+        * Returns count of test cases in view.
+        * @return Count of test cases in view.
+        */
+        TInt TestsInViewCount();
+        
+        /**
+        * Handles the addition of an item to the model.
+        */
+        void HandleItemAdditionL();
+        
+        /**
+        * Handles the removal of an item from the model.
+        */
+        void HandleItemRemovalL();
+        
+        /**
+        * Returns pointer to currently selected test case.
+        * @param Current test case.
+        */
+        CStartedTestCase* CurrentTestCase();
+        
+        /**
+        * Sets the current item.
+        * @param aIndex Index of the item to make current.
+        */
+        void SetCurrentItemIndex(TInt aIndex);
+        
+        /**
+        * Resets the selection indices, top and current item indices,
+        * the selection, and the horizontal scroll offset of this list box.
+        * This function does not redraw the list box.
+        */
+        void ResetListBox();
+        
+        /**
+        * Removes items from list box.
+        */
+        void RemoveSelectedExecutionsL();
+        
+        /**
+        * Removes all started test cases from list box.
+        */
+        void RemoveAllExecutionsInViewL();
+        
+        /**
+         * Stores current position of focus of iListBox to the CAppUiAppUi object
+         */
+        void SaveActiveLine();
+
+    private: // New functions
+
+    public: // Functions from base classes
+
+    private: // Functions from base classes
+
+        /**
+        * From CoeControl,SizeChanged.
+        * Called by framework when the view size is changed.
+        */
+        void SizeChanged();
+
+        /**
+        * From CoeControl,CountComponentControls.
+        * Gets a count of the component controls of this list box control.
+        * This information is used for DrawNow().
+        */
+        TInt CountComponentControls() const;
+
+        /**
+        * From CCoeControl,ComponentControl.
+        * Gets a pointer to the specified component control.
+        * @param aIndex Index of the component control to look up.
+        * @return The control at aIndex.
+        */
+        CCoeControl* ComponentControl(TInt aIndex) const;
+
+        /**
+        * From CCoeControl,Draw.
+        * Draw a control, called by window server.
+        * @param aRect The region of the control to be redrawn. Co-ordinates
+        *              are relative to the control's origin (top left corner).
+        */
+        void Draw(const TRect& aRect) const;
+
+        /**
+        * From CCoeControl,OfferKeyEventL
+        * Handles key events.
+        * @param aKeyEvent The key event.
+        * @param aType The type of key event.
+        * @return Indicates whether or not the key event was used 
+        *         by this control.
+        */
+		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
+	
+    private: //data
+        
+        CStartedTestsListBoxModel*  iListBoxModel;    
+        RRefArray<CStartedTestCase> iStartedTestsPtrs;
+    };
+
+#endif // CSHOWSTARTEDCASESCONTAINER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/ShowStartedCasesView.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,130 @@
+/*
+* 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: This file contains CShowStartedCasesView class 
+* declaration.
+*
+*/
+
+#ifndef SHOWSTARTEDCASESVIEW_H
+#define SHOWSTARTEDCASESVIEW_H
+
+// INCLUDES
+#include "View.h"
+#include <eiklbo.h>     // MEikListBoxObserver
+#include <aknnavide.h>  //CAknNavigationDecorator
+
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class CShowStartedCasesContainer;
+
+// CLASS DECLARATION
+
+/**
+*  CShowStartedCasesView view class.
+* 
+*/
+class CShowStartedCasesView : public CView, public MEikListBoxObserver
+    {
+    public: // Constructors and destructor
+
+        /**
+        * Symbian OS default constructor.
+        */
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */
+        ~CShowStartedCasesView();
+
+    public: // Functions from base classes
+        
+        /**
+        * Returns view´s id.
+        * @return View id.
+        */
+        TUid Id() const;
+
+        /**
+        * Handles a command.
+        * @param aCommand A command ID.
+        */
+        void HandleCommandL( TInt aCommand );
+
+        /**
+        * Handles client rect changes.
+        */
+        void HandleClientRectChange();
+
+        /**
+        * Handles a list box event.
+        * @param aListBox A pointer to list box (not used).
+        * @param aEventType Type of list box event.
+        */
+        void HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType);
+
+    public: // New functions
+        
+        /**
+        * Handles status changes of test cases in view.
+        */
+        void TestCaseStateChangedL();
+        
+        /**
+        * Handles call to view test case´s output data.
+        */
+        void ViewTestCaseOutputL();
+
+    private:
+    
+        /**
+        * Initializes view when activated.
+        * @param aPrevViewId Id of the previous view (not used).
+        * @param aCustomMessageId Custom message id (not used).
+        * @param aCustomMessage Custom message (not used).
+        */
+        void DoActivateL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,
+            const TDesC8& aCustomMessage);
+
+        /**
+        * Deactivates view.
+        */
+        void DoDeactivate();
+
+        /** From MEikMenuObserver
+        * Initializes menu pane.
+        * @param aResourceId Menu pane resource ID
+        * @param aMenuPane Menu pane pointer
+        */
+        void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
+        
+        /**
+        * Refreshes view name shown in the navi pane.
+        */
+        void RefreshNaviTitleL();
+
+    private: // Data
+        CShowStartedCasesContainer* iContainer;
+        CAknNavigationDecorator*    iNaviDecorator;
+        TName                       iFilterModule;
+        TFileName                   iFilterTestCaseFile;
+        TInt                        iSelectedTestCase; // Which testcase was 
+                                                       // selected when view 
+                                                       // was active earlier.
+    };
+
+#endif //SHOWSTARTEDCASESVIEW_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/StartCasesContainer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,131 @@
+/*
+* 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: This file contains CStartCasesContainer class 
+* declaration.
+*
+*/
+
+#ifndef CSTARTCASESCONTAINER_H
+#define CSTARTCASESCONTAINER_H
+
+// INCLUDES
+#include "Container.h"
+
+#include <coecntrl.h>
+#include <eiklbo.h> // MEikListBoxObserver
+#include <bamdesca.h> // MDesCArray
+#include <aknsfld.h>
+
+//#include "RRefArray.h"        
+//#include "UIEngine.h"         
+//#include "UIStoreIf.h"        
+//#include "UIStoreContainer.h" 
+
+#include <stifinternal/RRefArray.h>
+#include <stifinternal/UIEngine.h>
+#include <stifinternal/UIStoreIf.h>
+#include <stifinternal/UIStoreContainer.h>
+   
+// FORWARD DECLARATIONS
+class CEikTextListBox;
+class CDesC16Array;
+
+class CStartCasesView;
+class CEikColumnListBox;
+class CStartedTestCase;
+
+class CUIStoreHandler;
+class CUIStore;
+class CUIStoreIf;
+class CUIEngineContainer;
+class CUIEngine;
+
+// CLASS DECLARATION
+/**
+*  CStartCasesContainer  container control class.
+*  
+*/
+class CStartCasesContainer : public CContainer//public CCoeControl /*, MEikListBoxObserver */ /* MCoeControlObserver */
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Symbian OS default constructor.
+        * @param aRect Frame rectangle for container.
+        */
+        void ConstructL(const TRect& aRect, MEikListBoxObserver* aListBoxObserver);
+
+        /**
+        * Destructor.
+        */
+        ~CStartCasesContainer();
+
+    public: // New functions
+        
+        /**
+         * Stores current position of focus of iListBox to the CAppUiAppUi object
+         */
+        void SaveActiveLine();
+        
+    public: // Functions from base classes
+
+    private: // Functions from base classes
+
+        /**
+        * From CoeControl,SizeChanged.
+        * Called by framework when the view size is changed.
+        */
+        void SizeChanged();
+
+        /**
+        * From CoeControl,CountComponentControls.
+        * Gets a count of the component controls of this list box control.
+        * This information is used for DrawNow().
+        */
+        TInt CountComponentControls() const;
+
+        /**
+        * From CCoeControl,ComponentControl.
+        * Gets a pointer to the specified component control.
+        * @param aIndex Index of the component control to look up.
+        * @return The control at aIndex.
+        */
+        CCoeControl* ComponentControl(TInt aIndex) const;
+
+        /**
+        * From CCoeControl,Draw.
+        * Draw a control, called by window server.
+        * @param aRect The region of the control to be redrawn. Co-ordinates
+        *              are relative to the control's origin (top left corner).
+        */
+        void Draw(const TRect& aRect) const;
+        
+        /**
+        * From CCoeControl,OfferKeyEventL
+        * Handles key events.
+        * @param aKeyEvent The key event.
+        * @param aType The type of key event.
+        * @return Indicates whether or not the key event was used 
+        *         by this control.
+        */
+		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
+		        
+    private: //data
+        
+        CStartCasesView*            iParentView;
+    };
+
+#endif // CSTARTCASESCONTAINER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/StartCasesView.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,132 @@
+/*
+* 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: This file contains CStartCasesView class declaration.
+*
+*/
+
+#ifndef STARTCASESVIEW_H
+#define STARTCASESVIEW_H
+
+// INCLUDES
+#include "View.h"
+#include <eiklbo.h> // MEikListBoxObserver
+#include <aknnavide.h> 
+
+
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class CStartCasesContainer;
+
+
+// CLASS DECLARATION
+
+/**
+*  CTestCaseMenuView view class.
+* 
+*/
+class CStartCasesView : public CView, public MEikListBoxObserver //CAknView
+    {
+    public: // Constructors and destructor
+
+        /**
+        * Symbian OS default constructor.
+        */
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */
+        ~CStartCasesView();
+
+    public: // Functions from base classes
+        
+        /**
+        * Returns view´s id.
+        * @return View id.
+        */
+        TUid Id() const;
+
+        /**
+        * Handles a command.
+        * @param aCommand A command ID.
+        */
+        void HandleCommandL( TInt aCommand );
+
+        /**
+        * Handles client rect changes.
+        */
+        void HandleClientRectChange();
+
+        /**
+        * Handles a list box event.
+        * @param aListBox A pointer to list box.
+        * @param aEventType Type of list box event.
+        */
+        void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
+
+    public: // New functions
+        
+        /** 
+        * Starts test case.
+        */
+        void StartTestCaseL();
+        
+        /**
+        * Starts multiple test cases.
+        * @param aSelectedÍndexes Indexes of selected test cases.
+        */
+        void StartTestCasesL( RArray<TInt> aSelectedIndexes );
+
+    private:
+
+        /**
+        * Initializes view when activated.
+        * @param aPrevViewId Id of the previous view (not used).
+        * @param aCustomMessageId Custom message id (not used).
+        * @param aCustomMessage Custom message (not used).
+        */
+        void DoActivateL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,
+            const TDesC8& aCustomMessage);
+
+        /**
+        * Deactivates view.
+        */
+        void DoDeactivate();
+
+        /**
+        * Initializes menu pane.
+        * @param aResourceId Menu pane resource ID.
+        * @param aMenuPane Menu pane pointer.
+        */
+        void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
+    
+    private: // New functions
+        
+        /**
+        * Checks listbox selections and launches 
+        * query dialog to start test cases.
+        * @param aListBox Pointer to listbox.
+        */
+        void CheckListBoxSelectionsL(CEikListBox* aListBox);
+
+    private: // Data
+        CAknNavigationDecorator*    iNaviDecorator;
+        CStartCasesContainer*       iContainer;
+        TInt                        iCurrentTestCase;
+    };
+
+#endif //STARTCASESVIEW_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/StartedCasesMenuContainer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,130 @@
+/*
+* 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: This file contains CStartedCasesMenuContainer class
+* declaration.
+*
+*/
+
+#ifndef CSTARTEDCASESMENUCONTAINER_H
+#define CSTARTEDCASESMENUCONTAINER_H
+
+// INCLUDES
+#include <coecntrl.h>
+#include <eiklbo.h>
+
+   
+// FORWARD DECLARATIONS
+class CEikTextListBox;
+
+// CLASS DECLARATION
+
+/**
+*  CStartedCasesMenuContainer  container control class.
+*  
+*/
+class CStartedCasesMenuContainer : public CCoeControl , public MEikListBoxObserver  /* MCoeControlObserver */
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Symbian OS default constructor.
+        * @param aRect Frame rectangle for container.
+        */
+        void ConstructL(const TRect& aRect );
+
+        /**
+        * Destructor.
+        */
+        ~CStartedCasesMenuContainer();
+
+    public: // New functions
+    
+        /**
+        * Get currently selected items index.
+        * @return Current item index.
+        */			
+		TInt GetActiveLine();   
+
+        /**
+         * Stores current position of focus of iListBox to the CAppUiAppUi object
+         */
+		void SaveActiveLine();
+		
+    public: // Functions from base classes
+    
+        /**
+        * Method HandleSelectedListItemL handles valix index.
+        * @param        TInt aIndex
+        * @return       nothing
+        */
+        void HandleSelectedListItemL( TInt aIndex );        
+
+    private: // Functions from base classes
+        
+        /**
+        * From CoeControl,SizeChanged.
+        * Called by framework when the view size is changed.
+        */
+        void SizeChanged();
+
+        /**
+        * From CoeControl,CountComponentControls.
+        * Gets a count of the component controls of this list box control.
+        * This information is used for DrawNow().
+        */
+        TInt CountComponentControls() const;
+
+        /**
+        * From CCoeControl,ComponentControl.
+        * Gets a pointer to the specified component control.
+        * @param aIndex Index of the component control to look up.
+        * @return The control at aIndex.
+        */
+        CCoeControl* ComponentControl(TInt aIndex) const;
+
+        /**
+        * From CCoeControl,Draw.
+        * Draw a control, called by window server.
+        * @param aRect The region of the control to be redrawn. Co-ordinates
+        *              are relative to the control's origin (top left corner).
+        */
+        void Draw(const TRect& aRect) const;
+       
+        /**
+        * Handles list box events.
+        * @param aListBox The originating list box. 
+        * @param aEventType A code for the event. Further information may be
+        *                   obtained by accessing the list box itself.
+        */
+        void HandleListBoxEventL(CEikListBox* aListBox,TListBoxEvent aEventType);
+
+        /**
+        * From CCoeControl,OfferKeyEventL
+        * Handles key events.
+        * @param aKeyEvent The key event.
+        * @param aType The type of key event.
+        * @return Indicates whether or not the key event was used 
+        *         by this control.
+        */
+		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
+		
+        
+    private: //data
+        
+		CEikTextListBox*    iListBox;
+    };
+
+#endif // CSTARTEDCASESMENUCONTAINER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/StartedCasesMenuView.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,95 @@
+/*
+* 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: This file contains CStartedCasesMenuView class
+* declaration.
+*
+*/
+
+#ifndef STARTEDCASESMENUVIEW_H
+#define STARTEDCASESMENUVIEW_H
+
+// INCLUDES
+#include <eiklbo.h> // MEikListBoxObserver
+#include <aknnavide.h> 
+#include "View.h"
+
+
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class CStartedCasesMenuContainer;
+
+// CLASS DECLARATION
+
+/**
+*  CStartedCasesMenuView view class.
+* 
+*/
+class CStartedCasesMenuView : public CView
+    {
+    public: // Constructors and destructor
+
+        /**
+        * Symbian OS default constructor.
+        */
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */
+        ~CStartedCasesMenuView();
+
+    public: // Functions from base classes
+        
+        /**
+        * Returns view´s id.
+        * @return View id.
+        */
+        TUid Id() const;
+
+        /**
+        * Handles a command.
+        * @param aCommand A command ID.
+        */
+        void HandleCommandL( TInt aCommand );
+
+        /**
+        * Handles client rect changes.
+        */
+        void HandleClientRectChange();
+
+    private:
+
+        /**
+        * Initializes view when activated.
+        * @param aPrevViewId Id of the previous view (not used).
+        * @param aCustomMessageId Custom message id (not used).
+        * @param aCustomMessage Custom message (not used).
+        */
+        void DoActivateL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,
+            const TDesC8& aCustomMessage);
+
+        /**
+        * Deactivates view.
+        */
+        void DoDeactivate();
+
+    private: // Data
+        CAknNavigationDecorator*    iNaviDecorator;
+        CStartedCasesMenuContainer* iContainer;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/StatisticsContainer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,115 @@
+/*
+* 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: This file contains CStatisticsContainer class
+* declaration.
+*
+*/
+
+#ifndef CSTATISTICSCONTAINER_H
+#define CSTATISTICSCONTAINER_H
+
+// INCLUDES
+#include "Container.h"
+
+#include <coecntrl.h>
+#include <eiklbo.h>     // MEikListBoxObserver
+#include <bamdesca.h>   // MDesCArray
+#include <aknsfld.h>
+
+// FORWARD DECLARATIONS
+class CEikTextListBox;
+class CDesC16Array;
+
+class CStartCasesView;
+class CEikColumnListBox;
+
+// CLASS DECLARATION
+/**
+*  StatisticsContainer container control class.
+*  
+*/
+class CStatisticsContainer : public CContainer//public CCoeControl /*, MEikListBoxObserver */ /* MCoeControlObserver */
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Symbian OS default constructor.
+        * @param aRect Frame rectangle for container.
+        */
+        void ConstructL(const TRect& aRect, MEikListBoxObserver* aListBoxObserver);
+
+        /**
+        * Destructor.
+        */
+        ~CStatisticsContainer();
+
+    public: // New functions
+
+        /**
+         * Stores current position of focus of iListBox to the CAppUiAppUi object
+         */
+        void SaveActiveLine();
+
+    public: // Functions from base classes
+
+    private: // Functions from base classes
+
+        /**
+        * From CoeControl,SizeChanged.
+        * Called by framework when the view size is changed.
+        */
+        void SizeChanged();
+
+        /**
+        * From CoeControl,CountComponentControls.
+        * Gets a count of the component controls of this list box control.
+        * This information is used for DrawNow().
+        */
+        TInt CountComponentControls() const;
+
+        /**
+        * From CCoeControl,ComponentControl.
+        * Gets a pointer to the specified component control.
+        * @param aIndex Index of the component control to look up.
+        * @return The control at aIndex.
+        */
+        CCoeControl* ComponentControl(TInt aIndex) const;
+
+        /**
+        * From CCoeControl,Draw.
+        * Draw a control, called by window server.
+        * @param aRect The region of the control to be redrawn. Co-ordinates
+        *              are relative to the control's origin (top left corner).
+        */
+        void Draw(const TRect& aRect) const;
+
+        /**
+        * From CCoeControl,OfferKeyEventL
+        * Handles key events.
+        * @param aKeyEvent The key event.
+        * @param aType The type of key event.
+        * @return Indicates whether or not the key event was used 
+        *         by this control.
+        */
+		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
+		        
+    private: //data
+        
+        CStartCasesView*            iParentView;
+        CDesC16ArrayFlat*           iTestCaseArray;
+    };
+
+#endif // CSTATISTICSCONTAINER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/StatisticsView.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,115 @@
+/*
+* 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: This file contains CStatisticsView class declaration.
+*
+*/
+
+#ifndef STATISTICSVIEW_H
+#define STATISTICSVIEW_H
+
+// INCLUDES
+#include "View.h"
+#include <eiklbo.h> // MEikListBoxObserver
+
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class CStatisticsContainer;
+
+// CLASS DECLARATION
+
+/**
+*  CTestCaseMenuView view class.
+* 
+*/
+class CStatisticsView : public CView, public MEikListBoxObserver //CAknView
+    {
+    public: // Constructors and destructor
+
+        /**
+        * Symbian OS default constructor.
+        */
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */
+        ~CStatisticsView();
+
+    public: // Functions from base classes
+        
+        /**
+        * Returns view´s id.
+        * @return View id.
+        */
+        TUid Id() const;
+
+        /**
+        * Handles a command.
+        * @param aCommand A command ID.
+        */
+        void HandleCommandL( TInt aCommand );
+
+        /**
+        * Handles client rect changes.
+        */
+        void HandleClientRectChange();
+
+        /**
+        * Handles a list box event.
+        * @param aListBox A pointer to list box.
+        * @param aEventType Type of list box event.
+        */
+        void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
+
+    public: // New functions
+
+        /** 
+        * Starts test case.
+        */
+        void StartTestCasesL();
+
+    private:
+
+        /**
+        * Initializes view when activated.
+        * @param aPrevViewId Id of the previous view (not used).
+        * @param aCustomMessageId Custom message id (not used).
+        * @param aCustomMessage Custom message (not used).
+        */
+        void DoActivateL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,
+            const TDesC8& aCustomMessage);
+
+        /**
+        * Deactivates view.
+        */
+        void DoDeactivate();
+
+        /** From MEikMenuObserver
+        * Initializes menu pane.
+        * @param aResourceId Menu pane resource ID
+        * @param aMenuPane Menu pane pointer
+        */
+        void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
+
+
+    private: // Data
+        CAknNavigationDecorator*    iNaviDecorator;
+        CStatisticsContainer*       iContainer;
+        TInt                        iCurrentTestCase;
+    };
+
+#endif //STATISTICSVIEW_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/Stifui.hrh	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,112 @@
+/*
+* 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: Const definitions file.
+*
+*/
+
+#ifndef STIF_UI_HRH
+#define STIF_UI_HRH
+
+enum TAppUICommandIds
+    {
+    EAppUIGoBack = 1,
+    EAppUIGoToMainMenu,
+    EAppUIGoToTestCaseMenu,
+    EAppUIGoToModulesMenu,
+    EAppUIGoToTestSetsMenu,
+	ECmdGoToStartCasesView,
+	ECmdGoToStartedCasesView,
+    ECmdShowStartedTestSet,
+    ECmdCreateTestSet,
+    ECmdLoadTestSet,
+    ECmdStartTestSet,
+    ECmdSaveTestSet,
+    ECmdInsertTestCases,
+    ECmdRemoveTestCases,
+	ECmdFilterCases,
+	ECmdMarkMenu,
+    ECmdInsertSelectedCases,
+    ECmdShowSetMenu,
+	ECmdStartCases,
+	ECmdShowAllStartedCases,
+	ECmdShowOngoingCases,
+	ECmdShowPassedCases,
+	ECmdShowFailedCases,
+	ECmdShowPausedCases,
+	ECmdShowCrashedAbortedCases,
+	ECmdShowStatistics,
+    ECmdViewOutput,
+	ECmdPauseTestCase,
+	ECmdResumeTestCase,
+	ECmdAbortTestCase,
+	ECmdRemoveExecution,
+	ECmdRemoveAllExecutions,
+	ECmdOpenModule,
+	ECmdAddModule,
+	ECmdRemoveModule,
+    ECmdFilterMenu,
+    ECmdShowAbout,
+	ECmdFilterByModule = 0x1000,
+	ECmdFilterByTestCaseFile = 0x2000,
+	ECmdNOFiltering = 0x3000,
+	ECmdGoToTestSetView
+    };
+
+
+enum TAppUITabViewId
+    {
+	ETestCaseMenuTab = 1,
+    ETestModulesMenuTab,
+    ETestSetsMenuTab
+    };
+ 
+// Application view ids.
+enum TAppUIViewNumber
+	{
+    EMainMenuViewId = 1,
+    ETestCaseMenuViewId,
+    EStartCaseMenuViewId,
+    EStartedCasesMenuViewId,
+    ETestModulesMenuViewId,
+    ETestSetBaseMenuViewId,
+    ETestSetMenuViewId,
+    ETestSetInsertMenuViewId,
+    ETestSetStartedCasesViewId,
+    ETestSetsMenuViewId, /*???*/
+    EShowStartedCasesViewId,
+    EShowStatisticsViewId,
+	ETestCaseOutputViewId,
+	EStatisticsViewId,
+	ECreatedTestSetMenuViewId
+	};
+
+enum TPanic
+    {
+    EModuleIndexOutOfBound,
+    EShowCasesOutOfSync
+    };
+
+enum TShowStartedCasesMode
+    {
+    EShowAllStartedCases,
+    EShowOngoingCases,
+    EShowPausedCases,
+    EShowPassedCases,
+    EShowFailedCases,
+    EShowCrashedAbortedCases,
+    EShowStatistics
+    };
+
+#endif      // STIF_UI_HRH
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/Stifui_loc.hrh	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,145 @@
+/*
+* 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: This file contains localized strings.
+*
+*/
+
+// LOCALISATION STRINGS
+
+//#define qtn_testcase_menu_tab           "Cases"
+//#define qtn_testmodules_menu_tab        "Modules"
+//#define qtn_testsets_menu_tab           "Sets"
+
+// Main menu
+#define qtn_mainmenulist_test_cases     "\tTest Cases"
+#define qtn_mainmenulist_modules        "\tModules"
+#define qtn_mainmenulist_test_sets      "\tTest Sets"
+
+// Test cases menu
+#define qtn_testcasemenu_startcase      "\tStart Case(s)"
+#define qtn_testcasemenu_startedcases   "\tStarted Cases"
+
+// Started cases menu
+#define qtn_startedcases_allcases       "\tAll Started Cases"
+#define qtn_startedcases_ongoing        "\tOngoing Cases"
+#define qtn_startedcases_paused         "\tPaused Cases"
+#define qtn_startedcases_passed         "\tPassed Cases"
+#define qtn_startedcases_failed         "\tFailed Cases"
+#define qtn_startedcases_crashed_aborted        "\tCrashed/Aborted Cases"
+#define qtn_startedcases_statistics     "\tStatistics"
+
+// Modules menu
+#define qtn_open_module                 "Open module"
+#define qtn_add_module                  "Load all module(s)"
+#define qtn_remove_module               "Remove module"
+
+// Test set menu.
+#define qtn_testsetbasemenu_createtestset	"\tCreate test set"
+#define qtn_testsetbasemenu_loadtestset		"\tLoad test set"
+#define qtn_owerwrite_testset_confirmation	"Test set already created. Do you want to overwrite it?"
+#define qtn_save_testset_confirmation       "Save current test?"//changes for STIF-451
+#define qtn_load_testset_errornote          "Error loading test set."
+
+#define qtn_testsetinsert_add_selected  "Add selected"
+#define qtn_insert_confirmation			"Add selected test case(s) to test set?"
+#define qtn_insert_none_selected        "No test cases selected."
+
+#define qtn_testset_started_menu        "Show"
+#define qtn_testset_set_menu            "Set"
+
+#define qtn_testset_started_allcases    "Started Cases"
+#define qtn_testset_started_ongoing     "Ongoing Cases"
+#define qtn_testset_started_paused      "Paused Cases"
+#define qtn_testset_started_passed      "Passed Cases"
+#define qtn_testset_started_failed      "Failed Cases"
+#define qtn_testset_started_crashed_aborted     "Crashed/Aborted Cases"
+
+#define qtn_filter_test_cases           "Filter"
+#define qtn_by_module                   "By module"
+#define qtn_by_testcasefile             "By test case file"
+
+// Test case operations and menu texts
+#define qtn_markmenu_title				"Mark/Unmark"
+#define qtn_markmenu_mark				"Mark"
+#define qtn_markmenu_unmark				"Unmark"
+#define qtn_markmenu_markall			"Mark All"
+#define qtn_markmenu_unmarkall			"Unmark All"
+#define qtn_mark_test_case              "Mark"
+#define qtn_unmark_test_case            "Unmark"
+
+#define qtn_filter_menu                 "Filtering"
+#define qtn_filter_by_modules 		    "Filter by module"
+#define qtn_filter_by_test_case_file 	"Filter by test case file"
+#define qtn_no_filtering 		        "No filtering"
+
+
+//#define qtn_remove_execution            "Remove execution"
+//#define qtn_remove_all_executions       "Remove all executions"
+#define qtn_testcase_control_menu       "Test case control"
+#define qtn_view_output                 "View ouput of case"
+#define qtn_pause_testcase              "Pause"
+#define qtn_resume_testcase             "Resume"
+#define qtn_abort_testcase              "Abort"
+
+#define qtn_exit                        "Exit"
+
+// Start test cases queries.
+#define qtn_start_test_cases            "Start Case(s)"
+#define qtn_starting_test_case          "Start test?"
+#define qtn_starting_test_cases         "Start tests?"
+
+#define qtn_start                       "Start"
+#define qtn_start_and_view_output       "Start and view output"
+
+#define qtn_start_test					"Start"
+#define qtn_start_test_output			"Start&view output"
+#define qtn_start_tests_parallel		"Parallel"
+#define qtn_start_tests_serial			"Sequential"
+
+// example caption strings for app
+#define qtn_app_caption_string          "STIF UI"
+#define qtn_appui_demo              	"Demo"
+
+#define qtn_app_short_caption_string    "STIF UI"
+
+// Navipanel titles
+#define qtn_navi_load_test_set			"Load Test Set"
+#define qtn_navi_main					"Main menu"
+#define qtn_navi_testcases				"Test cases menu"
+#define qtn_navi_startcases				"Start cases"
+#define qtn_navi_startedcases			"Started cases"
+#define qtn_navi_testcase_output		"Test case output"
+#define qtn_navi_modules				"Modules menu"
+#define qtn_navi_testset_base			"Test set menu"
+#define qtn_navi_testset				"Test set"
+#define qtn_navi_testset_insert			"Insert test case"
+
+#define qtn_navi_started    			"Started cases"
+#define qtn_navi_started_all			"All started cases"
+#define qtn_navi_started_ongoing		"Ongoing cases"
+#define qtn_navi_started_paused			"Paused cases"
+#define qtn_navi_started_passed			"Passed cases"
+#define qtn_navi_started_failed			"Failed cases"
+#define qtn_navi_started_crashed_aborted		"Crashed/Aborted cases"
+#define qtn_navi_started_stats			"Statistics"
+
+// Test case states
+#define qtn_testcase_state_running      "Running"
+#define qtn_testcase_state_passed       "Passed"
+#define qtn_testcase_state_failed       "Failed"
+#define qtn_testcase_state_crashed_aborted      "Crashed/Aborted"
+#define qtn_testcase_state_unknown      "Undefined state!"
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/TestCaseMenuContainer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,129 @@
+/*
+* 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: This file contains CTestCaseMenuContainer class 
+* declaration.
+*
+*/
+
+#ifndef CTESTCASEMENUCONTAINER_H
+#define CTESTCASEMENUCONTAINER_H
+
+// INCLUDES
+#include <coecntrl.h>
+#include <eiklbo.h>
+
+   
+// FORWARD DECLARATIONS
+class CEikTextListBox;
+
+// CLASS DECLARATION
+
+/**
+*  CTestCaseMenuContainer  container control class.
+*  
+*/
+class CTestCaseMenuContainer : public CCoeControl, public MEikListBoxObserver  /* MCoeControlObserver */
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Symbian OS default constructor.
+        * @param aRect Frame rectangle for container.
+        */
+        void ConstructL(const TRect& aRect);
+
+        /**
+        * Destructor.
+        */
+        ~CTestCaseMenuContainer();
+
+    public: // New functions
+
+        /**
+        * Get currently selected items index.
+        * @return Current item index.
+        */	
+		TInt GetActiveLine();
+		
+        /**
+         * Stores current position of focus of iListBox to the CAppUiAppUi object
+         */
+		void SaveActiveLine();
+    
+    public: // Functions from base classes
+     
+        /**
+        * Method HandleSelectedListItemL handles valix index.
+        * @param        TInt aIndex
+        * @return       nothing
+        */
+        void HandleSelectedListItemL( TInt aIndex );      
+
+    private: // Functions from base classes
+
+        /**
+        * From CoeControl,SizeChanged.
+        * Called by framework when the view size is changed.
+        */
+        void SizeChanged();
+
+        /**
+        * From CoeControl,CountComponentControls.
+        * Gets a count of the component controls of this list box control.
+        * This information is used for DrawNow().
+        */
+        TInt CountComponentControls() const;
+
+        /**
+        * From CCoeControl,ComponentControl.
+        * Gets a pointer to the specified component control.
+        * @param aIndex Index of the component control to look up.
+        * @return The control at aIndex.
+        */
+        CCoeControl* ComponentControl(TInt aIndex) const;
+
+        /**
+        * From CCoeControl,Draw.
+        * Draw a control, called by window server.
+        * @param aRect The region of the control to be redrawn. Co-ordinates
+        *              are relative to the control's origin (top left corner).
+        */
+        void Draw(const TRect& aRect) const;
+       
+        /**
+        * Handles list box events.
+        * @param aListBox The originating list box. 
+        * @param aEventType A code for the event. Further information may be
+        *                   obtained by accessing the list box itself.
+        */
+        void HandleListBoxEventL(CEikListBox* aListBox,TListBoxEvent aEventType);
+
+        /**
+        * From CCoeControl,OfferKeyEventL
+        * Handles key events.
+        * @param aKeyEvent The key event.
+        * @param aType The type of key event.
+        * @return Indicates whether or not the key event was used 
+        *         by this control.
+        */
+		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
+		        
+    private: //data
+        
+		CEikTextListBox*    iListBox;
+    };
+
+#endif // CTESTCASEMENUCONTAINER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/TestCaseMenuView.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,96 @@
+/*
+* 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: This file contains CTestCaseMenuView class 
+* declaration.
+*
+*/
+
+#ifndef TESTCASEMENUVIEW_H
+#define TESTCASEMENUVIEW_H
+
+// INCLUDES
+#include "View.h"
+#include <aknnavide.h> 
+
+
+// CONSTANTS
+// UID of view
+const TUid KTestCaseMenuViewId = {2};
+
+// FORWARD DECLARATIONS
+class CTestCaseMenuContainer;
+
+// CLASS DECLARATION
+
+/**
+*  CTestCaseMenuView view class.
+* 
+*/
+class CTestCaseMenuView : public CView //CAknView
+    {
+    public: // Constructors and destructor
+
+        /**
+        * Symbian OS default constructor.
+        */
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */
+        ~CTestCaseMenuView();
+
+    public: // Functions from base classes
+        
+        /**
+        * Returns view´s id.
+        * @return View id.
+        */
+        TUid Id() const;
+
+        /**
+        * Handles a command.
+        * @param aCommand A command ID.
+        */
+        void HandleCommandL( TInt aCommand );
+
+        /**
+        * Handles client rect changes.
+        */
+        void HandleClientRectChange();
+
+    private:
+
+        /**
+        * Initializes view when activated.
+        * @param aPrevViewId Id of the previous view (not used).
+        * @param aCustomMessageId Custom message id (not used).
+        * @param aCustomMessage Custom message (not used).
+        */
+        void DoActivateL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,
+            const TDesC8& aCustomMessage);
+
+        /**
+        * Deactivates view.
+        */
+        void DoDeactivate();
+        
+    private: // Data
+        CAknNavigationDecorator*    iNaviDecorator;
+        CTestCaseMenuContainer*     iContainer;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/TestCaseOutputContainer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,184 @@
+/*
+* 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: This file contains CTestOutputListBoxModel class
+* declaration.
+*
+*/
+
+#ifndef TESTCASEOUTPUTCONTAINER_H
+#define TESTCASEOUTPUTCONTAINER_H
+
+// INCLUDES
+#include <coecntrl.h>
+#include <eiklbo.h>
+#include <bamdesca.h>   // MDesCArray
+
+// #include "RRefArray.h"  
+#include <stifinternal/RRefArray.h>
+
+
+// Define *.mbm file name.
+_LIT(KMbmFileName, "\\Resource\\Apps\\Stifui.mbm");
+
+// FORWARD DECLARATIONS
+class CEikTextListBox;
+class CAknSingleGraphicStyleListBox;
+class CDesC16ArrayFlat;
+class CStartedTestCase;
+
+class CUIStore;
+
+// CLASS DECLARATION
+
+class CTestOutputListBoxModel : public CBase, public MDesCArray
+    {
+    public:
+        /**
+        * Destructor.
+        */
+        ~CTestOutputListBoxModel();
+        
+        /**
+        * Two-phased constructor.
+        * @param aStartedTestCase Pointer to started test case.
+        * @return Pointer to created list box model.
+        */
+        static CTestOutputListBoxModel* NewL(CStartedTestCase* aStartedTestCase);
+
+    public: // Functions from base classes
+    
+        /**
+        * Returns the number of descriptor elements in the array.
+        * @return The number of descriptor elements.
+        */
+        TInt MdcaCount() const;
+        
+        /**
+        * Indexes into a descriptor array.
+        * @param aIndex The position of the descriptor element within the
+        *               array. The position is relative to zero; i.e. zero
+        *               implies the first descriptor element in the array. 
+        *               This value must be non-negative and less than the 
+        *               number of descriptors currently within the array 
+        *               otherwise the operator panics with 
+        *               EArrayIndexOutOfRange. 
+        * @return A non-modifiable pointer descriptor representing the 
+        *         descriptor element located at position aIndex within 
+        *         the array.
+        */
+        TPtrC MdcaPoint(TInt aIndex) const;
+
+    private:
+        /**
+        * Symbian OS two phased constructor.
+        * Completes the construction of the object.
+        */
+        void ConstructL();
+
+    private: //data
+        CStartedTestCase* iStartedTestCase;
+        HBufC*            iBuffer;
+
+    };
+
+/**
+*  CTestCaseOutputContainer  container control class.
+*  
+*/
+class CTestCaseOutputContainer : public CCoeControl, public MEikListBoxObserver /* MCoeControlObserver */
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Symbian OS default constructor.
+        * @param aRect Frame rectangle for container.
+        */
+        //void ConstructL(const TRect& aRect, TInt aExecutedTestCaseCount );
+        void ConstructL(const TRect& aRect, CStartedTestCase* aStartedTestCase );
+
+        /**
+        * Destructor.
+        */
+        ~CTestCaseOutputContainer();
+
+    public: // New functions
+        /**
+        * Handles addition of item to list box.
+        */
+        void OutputUpdateL();
+
+    private:
+
+    public: // Functions from base classes
+
+    private: // Functions from base classes
+    
+        /**
+        * From CoeControl,SizeChanged.
+        * Called by framework when the view size is changed.
+        */
+        void SizeChanged();
+
+        /**
+        * From CoeControl,CountComponentControls.
+        * Gets a count of the component controls of this list box control.
+        * This information is used for DrawNow().
+        */
+        TInt CountComponentControls() const;
+
+        /**
+        * From CCoeControl,ComponentControl.
+        * Gets a pointer to the specified component control.
+        * @param aIndex Index of the component control to look up.
+        * @return The control at aIndex.
+        */
+        CCoeControl* ComponentControl(TInt aIndex) const;
+
+        /**
+        * From CCoeControl,Draw.
+        * Draw a control, called by window server.
+        * @param aRect The region of the control to be redrawn. Co-ordinates
+        *              are relative to the control's origin (top left corner).
+        */
+        void Draw(const TRect& aRect) const;
+       
+        /**
+        * Handles list box events.
+        * @param aListBox The originating list box. 
+        * @param aEventType A code for the event. Further information may be
+        *                   obtained by accessing the list box itself.
+        */
+        void HandleListBoxEventL(CEikListBox* aListBox,TListBoxEvent aEventType);
+
+        /**
+        * From CCoeControl,OfferKeyEventL
+        * Handles key events.
+        * @param aKeyEvent The key event.
+        * @param aType The type of key event.
+        * @return Indicates whether or not the key event was used 
+        *         by this control.
+        */
+		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
+        
+    private: //data
+        
+        CEikTextListBox*            iListBox;
+        CTestOutputListBoxModel*    iListBoxModel;
+        CUIStore*                   iUIStore;
+
+    };
+
+#endif // TESTCASEOUTPUTCONTAINER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/TestCaseOutputView.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,122 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+* 
+* Description: This file contains CTestCaseOutputView class 
+* declaration.
+*
+*/
+
+#ifndef TESTCASEOUTPUTVIEW_H
+#define TESTCASEOUTPUTVIEW_H
+
+// INCLUDES
+#include "View.h"
+#include <aknnavide.h> 
+
+
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class CTestCaseOutputContainer;
+
+// CLASS DECLARATION
+
+/**
+*  CTestCaseOutputView view class.
+* 
+*/
+class CTestCaseOutputView : public CView
+    {
+    public: // Constructors and destructor
+
+        /**
+        * Symbian OS default constructor.
+        */
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */
+        ~CTestCaseOutputView();
+
+    public: // Functions from base classes
+        
+        /**
+        * Returns view´s id.
+        * @return View id.
+        */
+        TUid Id() const;
+
+        /**
+        * Handles a command.
+        * @param aCommand A command ID.
+        */
+        void HandleCommandL( TInt aCommand );
+
+        /**
+        * Handles client rect changes.
+        */
+        void HandleClientRectChange();
+
+    public: // New functions
+        
+        /**
+        * Receives output update notification from AppUI
+        * @param aTestCase A pointer to started test case.
+        */
+        void OutputUpdateL( CStartedTestCase* aTestCase );
+
+        /**
+        * Prints test case state to title pane
+        */
+        void PrintTestCaseStateL();
+
+        /**
+        * Handles test case state changed notification
+        */
+        void TestCaseStateChangedL();
+
+    private:
+
+        /**
+        * Initializes view when activated.
+        * @param aPrevViewId Id of the previous view (not used).
+        * @param aCustomMessageId Custom message id (not used).
+        * @param aCustomMessage Custom message (not used).
+        */
+        void DoActivateL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,
+            const TDesC8& aCustomMessage);
+
+        /**
+        * Deactivates view.
+        */
+        void DoDeactivate();
+
+        /** From MEikMenuObserver
+        * Initializes menu pane.
+        * @param aResourceId Menu pane resource ID
+        * @param aMenuPane Menu pane pointer
+        */
+        void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
+
+
+    private: // Data
+        CAknNavigationDecorator*    iNaviDecorator;
+        CTestCaseOutputContainer*   iContainer;
+        CStartedTestCase* 			iCurrentTestCase;
+
+    };
+
+#endif //SHOWSTARTEDCASESVIEW_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/TestModulesMenuContainer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,169 @@
+/*
+* 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: This file contains CTestModulesListBoxModel class 
+* declaration.
+*
+*/
+
+#ifndef CTESTMODULESMENUCONTAINER_H
+#define CTESTMODULESMENUCONTAINER_H
+
+// INCLUDES
+#include <coecntrl.h>
+#include <eiklbo.h>
+
+// #include "RRefArray.h" 
+#include <stifinternal/RRefArray.h>
+
+// FORWARD DECLARATIONS
+class CEikTextListBox;
+class CUIStore;
+
+// CLASS DECLARATION
+class CTestModulesListBoxModel : public CBase, public MDesCArray
+    {
+    public:
+        /**
+        * Destructor.
+        */
+        ~CTestModulesListBoxModel();
+
+        /**
+        * Two-phased constructor.
+        * @param aTestModules Array of test modules names.
+        * @return Pointer to created list box model.
+        */
+        static CTestModulesListBoxModel* NewL(RRefArray<TDesC> aTestModules);
+
+    public: // Functions from base classes
+    
+        /**
+        * Returns the number of descriptor elements in the array.
+        * @return The number of descriptor elements.
+        */
+        TInt MdcaCount() const;
+        
+        /**
+        * Indexes into a descriptor array.
+        * @param aIndex The position of the descriptor element within the
+        *               array. The position is relative to zero; i.e. zero
+        *               implies the first descriptor element in the array. 
+        *               This value must be non-negative and less than the 
+        *               number of descriptors currently within the array 
+        *               otherwise the operator panics with 
+        *               EArrayIndexOutOfRange. 
+        * @return A non-modifiable pointer descriptor representing the 
+        *         descriptor element located at position aIndex within 
+        *         the array.
+        */
+        TPtrC MdcaPoint(TInt aIndex) const;
+
+    private:
+        /**
+        * Symbian OS two phased constructor.
+        * Completes the construction of the object.
+        */
+        void ConstructL();
+
+    private: //data
+        RRefArray<TDesC>            iTestModules;
+        HBufC*                      iBuffer;
+    };
+
+/**
+*  CTestModulesMenuContainer  container control class.
+*  
+*/
+class CTestModulesMenuContainer : public CCoeControl
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Symbian OS default constructor.
+        * @param aRect Frame rectangle for container.
+        */
+        void ConstructL(const TRect& aRect, MEikListBoxObserver* aListBoxObserver);
+
+        /**
+        * Destructor.
+        */
+        ~CTestModulesMenuContainer();
+
+    public: // New functions
+
+        /**
+        * Gets the index number of the current item in the view.
+        * @return Index number of the current item.
+        */
+        TInt CurrentItemIndex();
+
+    public: // New functions
+    	
+	    /**
+	     * Stores current position of focus of iListBox to the CAppUiAppUi object
+	     */
+    	void SaveActiveLine();
+
+    private: // Functions from base classes
+
+       /**
+        * From CoeControl,SizeChanged.
+        * Called by framework when the view size is changed.
+        */
+        void SizeChanged();
+
+        /**
+        * From CoeControl,CountComponentControls.
+        * Gets a count of the component controls of this list box control.
+        * This information is used for DrawNow().
+        */
+        TInt CountComponentControls() const;
+
+        /**
+        * From CCoeControl,ComponentControl.
+        * Gets a pointer to the specified component control.
+        * @param aIndex Index of the component control to look up.
+        * @return The control at aIndex.
+        */
+        CCoeControl* ComponentControl(TInt aIndex) const;
+
+        /**
+        * From CCoeControl,Draw.
+        * Draw a control, called by window server.
+        * @param aRect The region of the control to be redrawn. Co-ordinates
+        *              are relative to the control's origin (top left corner).
+        */
+        void Draw(const TRect& aRect) const;
+
+        /**
+        * From CCoeControl,OfferKeyEventL
+        * Handles key events.
+        * @param aKeyEvent The key event.
+        * @param aType The type of key event.
+        * @return Indicates whether or not the key event was used 
+        *         by this control.
+        */
+		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
+        
+    private: //data
+        
+		CEikTextListBox*            iListBox;
+        CTestModulesListBoxModel*   iListBoxModel;
+        CUIStore*                   iUIStore;
+        RRefArray<TDesC>            iModules;
+    };
+
+#endif // CTESTMODULESMENUCONTAINER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/TestModulesMenuView.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,108 @@
+/*
+* 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: This file contains CTestModulesMenuView class
+* declaration.
+*
+*/
+
+#ifndef TESTMODULEMENUVIEW_H
+#define TESTMODULEMENUVIEW_H
+
+// INCLUDES
+#include "View.h"
+#include <eiklbo.h> // MEikListBoxObserver
+#include <aknnavide.h> 
+
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class CTestModulesMenuContainer;
+
+// CLASS DECLARATION
+
+/**
+*  CTestModulesMenuView view class.
+* 
+*/
+class CTestModulesMenuView : public CView, public MEikListBoxObserver
+    {
+    public: // Constructors and destructor
+
+        /**
+        * Symbian OS default constructor.
+        */
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */
+        ~CTestModulesMenuView();
+
+    public: // Functions from base classes
+        
+         /**
+        * Returns view´s id.
+        * @return View id.
+        */
+        TUid Id() const;
+
+        /**
+        * Handles a command.
+        * @param aCommand A command ID.
+        */
+        void HandleCommandL( TInt aCommand );
+
+        /**
+        * Handles client rect changes.
+        */
+        void HandleClientRectChange();
+
+        /**
+        * Handles a list box event.
+        * @param aListBox A pointer to list box (not used).
+        * @param aEventType Type of list box event.
+        */
+        void HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType);
+        
+        /**
+        * Initializes menu pane.
+        * @param aResourceId Menu pane resource ID.
+        * @param aMenuPane Menu pane pointer.
+        */
+        void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
+
+    private:
+
+        /**
+        * Initializes view when activated.
+        * @param aPrevViewId Id of the previous view (not used).
+        * @param aCustomMessageId Custom message id (not used).
+        * @param aCustomMessage Custom message (not used).
+        */
+        void DoActivateL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,
+            const TDesC8& aCustomMessage);
+
+        /**
+        * Deactivates view.
+        */
+        void DoDeactivate();
+
+    private: // Data
+        CAknNavigationDecorator*    iNaviDecorator;
+        CTestModulesMenuContainer*  iContainer;
+    };
+
+#endif // TESTMODULEMENUVIEW_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/TestSetBaseMenuContainer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,124 @@
+/*
+* 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: This file contains CTestSetBaseMenuContainer 
+* class declaration.
+*
+*/
+
+#ifndef CTestSetBaseMenuContainer_H
+#define CTestSetBaseMenuContainer_H
+
+// INCLUDES
+#include <coecntrl.h>
+#include <eiklbo.h>
+
+   
+// FORWARD DECLARATIONS
+//class CEikLabel;        // for example labels
+class CEikTextListBox;
+
+// CLASS DECLARATION
+
+/**
+*  CTestSetBaseMenuContainer  container control class.
+*  
+*/
+class CTestSetBaseMenuContainer : public CCoeControl
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Symbian OS default constructor.
+        * @param aRect Frame rectangle for container.
+        * @return Observer for list box.
+        */
+        void ConstructL(const TRect& aRect, MEikListBoxObserver* aListBoxObserver);
+
+        /**
+        * Destructor.
+        */
+        ~CTestSetBaseMenuContainer();
+
+    public: // New functions
+
+        /**
+        * Get currently selected items index.
+        * @return Current item index.
+        */		
+		TInt GetActiveLine();    
+		
+        /**
+         * Stores current position of focus of iListBox to the CAppUiAppUi object
+         */
+		void SaveActiveLine();
+    
+    public: // Functions from base classes
+     
+        /**
+        * Method HandleSelectedListItemL handles valix index.
+        * @param        TInt aIndex
+        * @return       nothing
+        */
+        void HandleSelectedListItemL( TInt aIndex );      
+
+    private: // Functions from base classes
+
+        /**
+        * From CoeControl,SizeChanged.
+        * Called by framework when the view size is changed.
+        */
+        void SizeChanged();
+
+        /**
+        * From CoeControl,CountComponentControls.
+        * Gets a count of the component controls of this list box control.
+        * This information is used for DrawNow().
+        */
+        TInt CountComponentControls() const;
+
+        /**
+        * From CCoeControl,ComponentControl.
+        * Gets a pointer to the specified component control.
+        * @param aIndex Index of the component control to look up.
+        * @return The control at aIndex.
+        */
+        CCoeControl* ComponentControl(TInt aIndex) const;
+
+        /**
+        * From CCoeControl,Draw.
+        * Draw a control, called by window server.
+        * @param aRect The region of the control to be redrawn. Co-ordinates
+        *              are relative to the control's origin (top left corner).
+        */
+        void Draw(const TRect& aRect) const;
+
+        /**
+        * From CCoeControl,OfferKeyEventL
+        * Handles key events.
+        * @param aKeyEvent The key event.
+        * @param aType The type of key event.
+        * @return Indicates whether or not the key event was used 
+        *         by this control.
+        */
+		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
+		
+        
+    private: //data
+        
+		CEikTextListBox*    iListBox;
+    };
+
+#endif // CTestSetBaseMenuContainer_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/TestSetBaseMenuView.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,101 @@
+/*
+* 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: This file contains CTestSetBaseMenuView class declaration.
+*
+*/
+
+#ifndef TESTSETBASEMENUVIEW_H
+#define TESTSETBASEMENUVIEW_H
+
+// INCLUDES
+#include "View.h"
+#include <eiklbo.h> // MEikListBoxObserver
+#include <aknnavide.h> 
+
+
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class CTestSetBaseMenuContainer;
+
+// CLASS DECLARATION
+
+/**
+*  CTestSetBaseMenuView view class.
+* 
+*/
+class CTestSetBaseMenuView : public CView, public MEikListBoxObserver
+    {
+    public: // Constructors and destructor
+
+        /**
+        * Symbian OS default constructor.
+        */
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */
+        ~CTestSetBaseMenuView();
+
+    public: // Functions from base classes
+        
+        /**
+        * Returns view´s id.
+        * @return View id.
+        */
+        TUid Id() const;
+
+        /**
+        * Handles a command.
+        * @param aCommand A command ID.
+        */
+        void HandleCommandL( TInt aCommand );
+
+        /**
+        * Handles client rect changes.
+        */
+        void HandleClientRectChange();
+
+        /**
+        * Handles a list box event.
+        * @param aListBox A pointer to list box.
+        * @param aEventType Type of list box event.
+        */
+        void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
+
+    private:
+
+        /**
+        * Initializes view when activated.
+        * @param aPrevViewId Id of the previous view (not used).
+        * @param aCustomMessageId Custom message id (not used).
+        * @param aCustomMessage Custom message (not used).
+        */
+        void DoActivateL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,
+            const TDesC8& aCustomMessage);
+
+        /**
+        * Deactivates view.
+        */
+        void DoDeactivate();
+
+    private: // Data
+        CAknNavigationDecorator*    iNaviDecorator;
+        CTestSetBaseMenuContainer*  iContainer;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/TestSetInsertMenuContainer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,133 @@
+/*
+* 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: This file contains CTestSetInsertMenuContainer 
+* class definition.
+*
+*/
+
+#ifndef TESTSETINSERTMENUCONTAINER_H
+#define TESTSETINSERTMENUCONTAINER_H
+
+// INCLUDES
+#include "Container.h"
+
+#include <coecntrl.h>
+#include <eiklbo.h>     // MEikListBoxObserver
+#include <bamdesca.h>   // MDesCArray
+#include <aknsfld.h>
+
+//#include "RRefArray.h"        
+//#include "UIEngine.h"         
+//#include "UIStoreIf.h"        
+//#include "UIStoreContainer.h" 
+
+#include <stifinternal/RRefArray.h>
+#include <stifinternal/UIEngine.h>
+#include <stifinternal/UIStoreIf.h>
+#include <stifinternal/UIStoreContainer.h>
+
+
+   
+// FORWARD DECLARATIONS
+class CEikTextListBox;
+class CDesC16Array;
+
+class CTestSetInsertMenuView;
+class CEikColumnListBox;
+class CStartedTestCase;
+
+class CUIStoreHandler;
+class CUIStore;
+class CUIStoreIf;
+class CUIEngineContainer;
+class CUIEngine;
+
+// CLASS DECLARATION
+/**
+*  CTestSetInsertMenuContainer  container control class.
+*  
+*/
+class CTestSetInsertMenuContainer : public CContainer //public CCoeControl /*, MEikListBoxObserver */ /* MCoeControlObserver */
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Symbian OS default constructor.
+        * @param aRect Frame rectangle for container.
+        */
+        void ConstructL(const TRect& aRect, MEikListBoxObserver* aListBoxObserver);
+
+        /**
+        * Destructor.
+        */
+        ~CTestSetInsertMenuContainer();
+
+    public: // New functions
+        
+        /**
+         * Stores current position of focus of iListBox to the CAppUiAppUi object
+         */
+        void SaveActiveLine();
+        
+    public: // Functions from base classes
+
+    private: // Functions from base classes
+
+        /**
+        * From CoeControl,SizeChanged.
+        * Called by framework when the view size is changed.
+        */
+        void SizeChanged();
+
+        /**
+        * From CoeControl,CountComponentControls.
+        * Gets a count of the component controls of this list box control.
+        * This information is used for DrawNow().
+        */
+        TInt CountComponentControls() const;
+
+        /**
+        * From CCoeControl,ComponentControl.
+        * Gets a pointer to the specified component control.
+        * @param aIndex Index of the component control to look up.
+        * @return The control at aIndex.
+        */
+        CCoeControl* ComponentControl(TInt aIndex) const;
+
+        /**
+        * From CCoeControl,Draw.
+        * Draw a control, called by window server.
+        * @param aRect The region of the control to be redrawn. Co-ordinates
+        *              are relative to the control's origin (top left corner).
+        */
+        void Draw(const TRect& aRect) const;
+        
+        /**
+        * From CCoeControl,OfferKeyEventL
+        * Handles key events.
+        * @param aKeyEvent The key event.
+        * @param aType The type of key event.
+        * @return Indicates whether or not the key event was used 
+        *         by this control.
+        */
+		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
+         
+    private: //data
+        
+        CTestSetInsertMenuView*         iParentView;
+    };
+
+#endif // CTestSetInsertMenuContainer_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/TestSetInsertMenuView.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,123 @@
+/*
+* 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: This  file contains CTestSetInsertMenuView class 
+* declaration.
+*
+*/
+
+#ifndef TESTSETINSERTMENUVIEW_H
+#define TESTSETINSERTMENUVIEW_H
+
+// INCLUDES
+#include "View.h"
+#include <eiklbo.h> // MEikListBoxObserver
+#include <aknnavide.h> 
+
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class CTestSetInsertMenuContainer;
+
+
+// CLASS DECLARATION
+
+/**
+*  CTestCaseMenuView view class.
+* 
+*/
+class CTestSetInsertMenuView : public CView, public MEikListBoxObserver //CAknView
+    {
+    public: // Constructors and destructor
+
+        /**
+        * Symbian OS default constructor.
+        */
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */
+        ~CTestSetInsertMenuView();
+
+    public: // Functions from base classes
+        
+        /**
+        * Returns view´s id.
+        * @return View id.
+        */
+        TUid Id() const;
+
+        /**
+        * Handles a command.
+        * @param aCommand A command ID.
+        */
+        void HandleCommandL( TInt aCommand );
+
+        /**
+        * Handles client rect changes.
+        */
+        void HandleClientRectChange();
+
+        /**
+        * Handles a list box event.
+        * @param aListBox A pointer to list box.
+        * @param aEventType Type of list box event.
+        */
+        void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
+
+    public: // New functions
+        
+        /**
+        * Adds selected test cases to the current test set.
+        * @param aSelectedIndexes Indexes of selected test cases.
+        */
+        void AddCasesToTestSet( RArray<TInt> aSelectedIndexes );
+
+    private:
+
+        /**
+        * Initializes view when activated.
+        * @param aPrevViewId Id of the previous view (not used).
+        * @param aCustomMessageId Custom message id (not used).
+        * @param aCustomMessage Custom message (not used).
+        */
+        void DoActivateL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,
+            const TDesC8& aCustomMessage);
+
+        /**
+        * Deactivates view.
+        */
+        void DoDeactivate();
+
+        /**
+        * Initializes menu pane.
+        * @param aResourceId Menu pane resource ID.
+        * @param aMenuPane Menu pane pointer.
+        */
+        void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
+               
+        /**
+        * Show confirmation dialog for inserting test cases.
+        */
+        void ShowInsertCasesDialogL();
+
+    private: // Data
+        CAknNavigationDecorator*        iNaviDecorator;
+        CTestSetInsertMenuContainer*    iContainer;
+        TInt                            iCurrentTestCase;
+    };
+
+#endif //TestSetInsertMenuView_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/TestSetMenuContainer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,209 @@
+/*
+* 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: This file contains CTestSetMenuContainer class 
+* declaration.
+*
+*/
+
+#ifndef TestSetMenuContainer_H
+#define TestSetMenuContainer_H
+
+// INCLUDES
+#include <coecntrl.h>
+#include <eiklbo.h>     // MEikListBoxObserver
+#include <bamdesca.h>   // MDesCArray
+#include <aknsfld.h>
+
+//#include "RRefArray.h"        
+//#include "UIEngine.h"         
+//#include "UIStoreIf.h"        
+//#include "UIStoreContainer.h" 
+
+#include <stifinternal/RRefArray.h>
+#include <stifinternal/UIEngine.h>
+#include <stifinternal/UIStoreIf.h>
+#include <stifinternal/UIStoreContainer.h>
+   
+// FORWARD DECLARATIONS
+class CEikTextListBox;
+class CDesC16Array;
+
+class CTestSetMenuView;
+class CEikColumnListBox;
+class CTestCaseListBoxModel;
+
+class CUIStoreHandler;
+class CUIStore;
+class CUIStoreIf;
+class CUIEngineContainer;
+class CUIEngine;
+
+// CLASS DECLARATION
+/**
+*  CTestSetMenuContainer  container control class.
+*  
+*/
+class CTestSetMenuContainer : public CCoeControl /*, MEikListBoxObserver */ /* MCoeControlObserver */
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Symbian OS default constructor.
+        * @param aRect Frame rectangle for container.
+        */
+        void ConstructL(const TRect& aRect, MEikListBoxObserver* aListBoxObserver);
+
+        /**
+        * Destructor.
+        */
+        ~CTestSetMenuContainer();
+
+    public: // New functions
+        /**
+        * Show only testcases which are defined is specified module.
+        * @param aModuleName Module which test cases are shown.
+        */
+        void FilterCasesByModuleL(TName aModuleName);
+        
+        /**
+        * Show only testcases which are defined in specified test case file.
+        * @param aTestCaseFileName Test cases file name.
+        */
+        void FilterCasesByTCFileNameL(TFileName aTestCaseFileName);
+        
+        /**
+        * Remove possible filtering of test cases -> show all test cases.
+        */
+        void NoFilteringL();
+        
+        /**
+        * Returns pointers to selected test cases.
+        * @param aSelectedTestCases Currently selected test case.
+        */
+        void SelectedTestCases(RPointerArray<CTestInfo>& aSelectedTestCases);
+
+        /**
+        * Sets graphic icon using listbox as CEikColumnListBox.
+        * @param aListBox Pointer to list box.
+        */
+        void SetGraphicIconL( CEikColumnListBox* aListBox );
+
+        /**
+        * Appends graphics data.
+        * @param aIcons Pointer array of icons.
+        */
+        void GraphicIconL( CArrayPtr<CGulIcon>* aIcons );
+        
+        /**
+        * Gets the index number of the current item in the view.
+        * @return Index number of the current item.
+        */
+        TInt CurrentItemIndex();
+        
+        /**
+        * Sets the current item.
+        * @param aIndex Index of the item to make current.
+        */
+        void SetCurrentItemIndex(TInt aCurrentTestCase);
+		
+		/**
+		* Inline function for getting pointer to list box.
+		* @return Pointer to list box.
+		*/
+		inline CEikListBox* ListBox() { return (CEikListBox*)iListBox; };
+		
+		/**
+		* Processes user commands.
+		* @param aCommand ID of the command to respond to.
+		*/
+		void ProcessCommandL( TInt  aCommand );
+		
+		/**
+		* Processes user commands.
+		* @param aCommand ID of the command to respond to.
+		*/
+		void SelectionListProcessCommandL( TInt  aCommand );
+		
+		/**
+		* Handles mark commands.
+		* @param aCommand ID of the command to respond to.
+		*/
+		void HandleMarkCommandL( TInt aCommand );
+        
+        /**
+		* Removes items from list box.
+		* @param aSelected Indexes of removed items.
+		*/
+		void RemoveListBoxItemL( TInt aSelected );
+		
+        /**
+         * Stores current position of focus of iListBox to the CAppUiAppUi object
+         */
+		void SaveActiveLine();
+		
+    public: // Functions from base classes
+
+    private: // Functions from base classes
+
+        /**
+        * From CoeControl,SizeChanged.
+        * Called by framework when the view size is changed.
+        */
+        void SizeChanged();
+
+        /**
+        * From CoeControl,CountComponentControls.
+        * Gets a count of the component controls of this list box control.
+        * This information is used for DrawNow().
+        */
+        TInt CountComponentControls() const;
+
+        /**
+        * From CCoeControl,ComponentControl.
+        * Gets a pointer to the specified component control.
+        * @param aIndex Index of the component control to look up.
+        * @return The control at aIndex.
+        */
+        CCoeControl* ComponentControl(TInt aIndex) const;
+
+        /**
+        * From CCoeControl,Draw.
+        * Draw a control, called by window server.
+        * @param aRect The region of the control to be redrawn. Co-ordinates
+        *              are relative to the control's origin (top left corner).
+        */
+        void Draw(const TRect& aRect) const;
+        
+        /**
+        * From CCoeControl,OfferKeyEventL
+        * Handles key events.
+        * @param aKeyEvent The key event.
+        * @param aType The type of key event.
+        * @return Indicates whether or not the key event was used 
+        *         by this control.
+        */
+		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
+        
+    private: //data
+        
+        CTestSetMenuView*           iParentView;
+        CEikColumnListBox*          iListBox;
+        CTestCaseListBoxModel*      iListBoxModel;
+        RPointerArray<CTestInfo>    iTestCasesInView;
+        CUIStore*                   iUIStore;
+    };
+
+#endif // CTestSetMenuContainer_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/TestSetMenuView.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,167 @@
+/*
+* 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: This file contains CTestSetMenuView class declaration.
+*
+*/
+
+#ifndef TESTSETMENUVIEW_H
+#define TESTSETMENUVIEW_H
+
+// INCLUDES
+#include "View.h"
+#include <eiklbo.h> // MEikListBoxObserver
+#include <aknnavide.h> 
+
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class CTestSetMenuContainer;
+
+// CLASS DECLARATION
+/**
+*  CTestCaseMenuView view class.
+*/
+class CTestSetMenuView : public CView, public MEikListBoxObserver
+    {
+    public: // Constructors and destructor
+
+        /**
+        * Symbian OS default constructor.
+        */
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */
+        ~CTestSetMenuView();
+
+    public: // Functions from base classes
+        
+        /**
+        * Returns view´s id.
+        * @return View id.
+        */
+        TUid Id() const;
+
+        /**
+        * Handles a command.
+        * @param aCommand A command ID.
+        */
+        void HandleCommandL( TInt aCommand );
+
+        /**
+        * Handles client rect changes.
+        */
+        void HandleClientRectChange();
+    
+    public: // From MEikListBoxObserver
+        
+        /**
+        * Handles list box event.
+        * @param aListBox Pointer to list box.
+        * @param aEventType List box event.
+        */
+        void HandleListBoxEventL(CEikListBox* aListBox, 
+            TListBoxEvent aEventType);
+                
+    public: // New functions
+        
+        /**
+        * Starts all cases in active test set.
+        */
+        void StartTestSetL();
+        
+        /**
+        * Removes selected test cases from active test set.
+        */
+        void RemoveSelectedTestCasesL();
+        
+        /**
+        * Creates new test set.
+        * @param aTestSetName Name of the test set.
+        * @return Symbian OS error code.
+.       */
+        TInt CreateTestSetL( const TDesC& aTestSetName );
+        
+        /**
+        * Loads saved test set.
+        * @param aTestSetName Name of the test set.
+        * @return Symbian OS error code.
+        */
+        TInt LoadTestSetL( const TDesC& aTestSetName );
+        
+        /**
+        * Saves current test set.
+        * @return Symbian OS error code.
+        */
+        TInt SaveCurrentTestSetL();
+        
+        /**
+        * Removes current test set.
+        * @return Symbian OS error code.
+        */
+        TInt RemoveActiveTestSet();
+        
+        /**
+        * Get name of the current test set.
+        * @return Name of the current test set.
+        */
+        inline const TDesC& CurrentTestSet()
+            { return iCurrentTestSet; }
+        
+        /**
+        * Set save needed flag.
+        */
+        inline void SetSaveNeeded( TBool aSave )
+            { iSaveNeeded = aSave; }
+                
+    private: // From AknView
+
+        /**
+        * Initializes view when activated.
+        * @param aPrevViewId Id of the previous view (not used).
+        * @param aCustomMessageId Custom message id (not used).
+        * @param aCustomMessage Custom message (not used).
+        */
+        void DoActivateL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,
+            const TDesC8& aCustomMessage);
+
+        /**
+        * Deactivates view.
+        */
+        void DoDeactivate();
+
+    private: // From MEikMenuObserver
+        
+        /**
+        * Initializes menu pane.
+        * @param aResourceId Menu pane resource ID.
+        * @param aMenuPane Menu pane pointer.
+        */
+        void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
+
+    private: // Data
+        CAknNavigationDecorator*    iNaviDecorator;
+        CTestSetMenuContainer*      iContainer;
+        CUIStore*                   iUIStore;
+        TInt                        iCurrentTestCase;
+        TInt                        iTestSetIndex;
+        TBuf<50>                    iCurrentTestSet;
+        TBool                       iSaveNeeded;
+        
+    };
+
+#endif // TESTSETMENUVIEW_H
+
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/TestSetStartedCasesContainer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,193 @@
+/*
+* 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: This file contains CTestSetStartedCasesContainer
+* class declaration.
+*
+*/
+
+#ifndef TESTSETSTARTEDCASESCONTAINER_H
+#define TESTSETSTARTEDCASESCONTAINER_H
+
+// INCLUDES
+#include <coecntrl.h>
+#include <eiklbo.h>
+#include <bamdesca.h> // MDesCArray
+
+//#include "RRefArray.h" 
+#include <stifinternal/RRefArray.h>
+
+
+// Define *.mbm file name.
+_LIT(KMbmFileName, "\\Resource\\Apps\\Stifui.mbm");
+
+// FORWARD DECLARATIONS
+class CEikTextListBox;
+class CAknSingleGraphicStyleListBox;
+class CDesC16ArrayFlat;
+class CStartedTestCase;
+
+class CUIStore;
+class CStartedTestsListBoxModel;
+
+// CLASS DECLARATION
+
+/**
+*  CTestSetStartedCasesContainer  container control class.
+*  
+*/
+class CTestSetStartedCasesContainer : public CCoeControl /*, MEikListBoxObserver */ /* MCoeControlObserver */
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Symbian OS default constructor.
+        * @param aRect Frame rectangle for container.
+        */
+        void ConstructL(const TRect& aRect, MEikListBoxObserver* aListBoxObserver);
+
+        /**
+        * Destructor.
+        */
+        ~CTestSetStartedCasesContainer();
+
+    public: // New functions
+    
+        /**
+        * Returns reference to currently selected test case in view (listbox).
+        * @return Currently selected test case.
+        */
+        CStartedTestCase* SelectedTestCase();
+        
+        /**
+        * Constructs list box model.
+        */
+        void ConstructListBoxModelL();
+        
+        /**
+        * Draws the list box.
+        */
+        void DrawListBox();
+        
+        /**
+        * Returns count of test cases in view.
+        * @return Count of test cases in view.
+        */
+        TInt TestsInViewCount();
+        
+        /**
+        * Handles the addition of an item to the model.
+        */
+        void HandleItemAdditionL();
+        
+        /**
+        * Handles the removal of an item from the model.
+        */
+        void HandleItemRemovalL();
+        
+        /**
+        * Returns pointer to currently selected test case.
+        * @param Current test case.
+        */
+        CStartedTestCase* CurrentTestCase();
+        
+        /**
+        * Gets the index number of the current item in the view.
+        * @return Index number of the current item.
+        */
+        TInt CurrentItemIndex();
+        
+        /**
+        * Sets the current item.
+        * @param aIndex Index of the item to make current.
+        */
+        void SetCurrentItemIndex(TInt aIndex);
+        
+        /**
+        * Resets the selection indices, top and current item indices,
+        * the selection, and the horizontal scroll offset of this list box.
+        * This function does not redraw the list box.
+        */
+        void ResetListBox();
+        
+        /**
+        * Removes items from list box.
+        */
+        void RemoveSelectedExecutionsL();
+        
+        /**
+        * Removes all started test cases from list box.
+        */
+        void RemoveAllExecutionsInViewL();
+        
+        /**
+         * Stores current position of focus of iListBox to the CAppUiAppUi object
+         */
+        void SaveActiveLine();
+
+    private: // New functions
+
+    public: // Functions from base classes
+
+    private: // Functions from base classes
+    
+        /**
+        * From CoeControl,SizeChanged.
+        * Called by framework when the view size is changed.
+        */
+        void SizeChanged();
+
+        /**
+        * From CoeControl,CountComponentControls.
+        * Gets a count of the component controls of this list box control.
+        * This information is used for DrawNow().
+        */
+        TInt CountComponentControls() const;
+
+        /**
+        * From CCoeControl,ComponentControl.
+        * Gets a pointer to the specified component control.
+        * @param aIndex Index of the component control to look up.
+        * @return The control at aIndex.
+        */
+        CCoeControl* ComponentControl(TInt aIndex) const;
+
+        /**
+        * From CCoeControl,Draw.
+        * Draw a control, called by window server.
+        * @param aRect The region of the control to be redrawn. Co-ordinates
+        *              are relative to the control's origin (top left corner).
+        */
+        void Draw(const TRect& aRect) const;
+
+        /**
+        * From CCoeControl,OfferKeyEventL
+        * Handles key events.
+        * @param aKeyEvent The key event.
+        * @param aType The type of key event.
+        * @return Indicates whether or not the key event was used 
+        *         by this control.
+        */
+		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
+	    
+    private: //data
+        
+        CEikTextListBox*            iListBox;
+        CStartedTestsListBoxModel*  iListBoxModel;    
+        RRefArray<CStartedTestCase> iStartedTestsPtrs;
+        CUIStore*                   iUIStore;
+    };
+
+#endif // CTestSetStartedCasesCONTAINER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/TestSetStartedCasesView.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,130 @@
+/*
+* 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: This file contains CTestSetStartedCasesView class
+* declaration.
+*
+*/
+
+#ifndef TESTSETSTARTEDCASESVIEW_H
+#define TESTSETSTARTEDCASESVIEW_H
+
+// INCLUDES
+#include "View.h"
+#include <eiklbo.h> // MEikListBoxObserver
+#include <aknnavide.h> //CAknNavigationDecorator
+
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class CTestSetStartedCasesContainer;
+
+// CLASS DECLARATION
+
+/**
+*  CTestSetStartedCasesView view class.
+* 
+*/
+class CTestSetStartedCasesView : public CView, public MEikListBoxObserver
+    {
+    public: // Constructors and destructor
+
+        /**
+        * Symbian OS default constructor.
+        */
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */
+        ~CTestSetStartedCasesView();
+
+    public: // Functions from base classes
+        
+        /**
+        * Returns view´s id.
+        * @return View id.
+        */
+        TUid Id() const;
+
+        /**
+        * Handles a command.
+        * @param aCommand A command ID.
+        */
+        void HandleCommandL( TInt aCommand );
+
+        /**
+        * Handles client rect changes.
+        */
+        void HandleClientRectChange();
+
+        /**
+        * Handles a list box event.
+        * @param aListBox A pointer to list box (not used).
+        * @param aEventType Type of list box event.
+        */
+        void HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType);
+
+    public: // New functions
+        
+        /**
+        * Handles status changes of test cases in view.
+        */
+        void TestCaseStateChangedL();
+        
+        /**
+        * Handles call to view test case´s output data.
+        */
+        void ViewTestCaseOutputL();
+
+    private:
+
+        /**
+        * Initializes view when activated.
+        * @param aPrevViewId Id of the previous view (not used).
+        * @param aCustomMessageId Custom message id (not used).
+        * @param aCustomMessage Custom message (not used).
+        */
+        void DoActivateL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,
+            const TDesC8& aCustomMessage);
+
+        /**
+        * Deactivates view.
+        */
+        void DoDeactivate();
+
+        /**
+        * Initializes menu pane.
+        * @param aResourceId Menu pane resource ID.
+        * @param aMenuPane Menu pane pointer.
+        */
+        void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
+        
+        /**
+        * Refreshes view name shown in the navi pane.
+        */
+        void RefreshNaviTitleL();
+
+    private: // Data
+        CAknNavigationDecorator*    iNaviDecorator;
+        CTestSetStartedCasesContainer* iContainer;
+        TName                       iFilterModule;
+        TFileName                   iFilterTestCaseFile;
+        TInt                        iSelectedTestCase;  // Which testcase was 
+                                                        // selected when view 
+                                                        // was active earlier.
+    };
+
+#endif //TestSetStartedCasesVIEW_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/UIStoreHandler.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,135 @@
+/*
+* 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: This file contains CUIStoreHandler class declaration.
+*
+*/
+
+#ifndef UISTOREHANDLER_H
+#define UISTOREHANDLER_H
+
+//  INCLUDES
+//#include "UIStoreIf.h"  
+//#include "UIStore.h"   
+//#include "UIEngine.h"  
+
+#include <stifinternal/UIStoreIf.h>
+#include <stifinternal/UIStore.h>
+#include <stifinternal/UIEngine.h>
+
+#include "AppUIAppUi.h"
+
+// CONSTANTS
+// None
+
+// MACROS
+// None
+
+// DATA TYPES
+// None
+
+// FUNCTION PROTOTYPES
+// None
+
+// FORWARD DECLARATIONS
+// None
+
+// CLASS DECLARATION
+// None
+class CAppUIAppUi;
+
+// DESCRIPTION
+// CUIStoreHandler is a STIF Test Framework Series60 UI class.
+// CUIStoreHandler's methods purpose is to offer handle to UI Engine.
+// Because multible inheritance in not allowed in SOS we cannot 
+// inheritance CUIStore class direct so we use this class.
+
+class CUIStoreHandler 
+            :public CUIStoreIf
+    {
+    public:     // Enumerations
+
+    private:    // Enumerations
+
+    public:     // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        * @param aAppUIAppUI Pointer to application ui.
+        * @return Pointer to UIStoreHandler.
+        */
+        static CUIStoreHandler* NewL( CAppUIAppUi* aAppUIAppUI );
+
+        /**
+        * Destructor.
+        */
+        ~CUIStoreHandler();
+
+    public:     // New functions
+
+        /**
+        * C++ default constructor.
+        * @param aAppUIAppUI Pointer to application ui.
+        */
+        CUIStoreHandler( CAppUIAppUi* aAppUIAppUI );
+
+        /**
+        * Receives output update notify from started test case.
+        * Checks if that test case is currently in output view then
+        * sends notification to AppUI which handles notification onward.
+        * @param aTestCase
+        * @param aStatus
+        */
+        void Update( CStartedTestCase* aTestCase, TInt aStatus );
+
+    public:     // Functions from base classes
+
+    protected:  // New functions
+
+    protected:  // Functions from base classes
+
+    private:
+
+        /**
+        * By default Symbian OS constructor is private.
+        */
+        void ConstructL();
+
+    public:     // Data
+
+        /**
+        * Returns the AppUI of the application
+        * @return Pointer to the Application UI.
+        */
+        CAppUIAppUi* iAppUIAppUI;
+        
+        /**
+        * Counter for executed test cases
+        */
+        TInt iExecutedTestCaseCount;
+
+    protected:  // Data
+
+    private:    // Data
+
+    public:     // Friend classes
+
+    protected:  // Friend classes
+
+    private:    // Friend classes
+
+    };
+
+#endif      // UISTOREHANDLER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/View.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,101 @@
+/*
+* 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: This file contains CView class declaration.
+*
+*/
+
+#ifndef VIEW_H
+#define VIEW_H
+
+// INCLUDES
+#include <aknview.h>
+
+//#include "UIStoreIf.h" 
+#include <stifinternal/UIStoreIf.h>
+
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+//class CMainMenuContainer;
+
+// CLASS DECLARATION
+
+/**
+*  CMainMenuView view class.
+* 
+*/
+class CView : public CAknView
+    {
+    public: // Constructors and destructor
+
+        /**
+        * Symbian OS default constructor.
+        */
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */
+        ~CView();
+
+    public: // Functions from base classes
+        
+        /**
+        * Returns view´s id.
+        * @return View id.
+        */
+        virtual TUid Id() const;
+
+        /**
+        * Handles a command.
+        * @param aCommand A command ID.
+        */
+        virtual void HandleCommandL( TInt aCommand );
+
+        /**
+        * Handles client rect changes.
+        */
+        virtual void HandleClientRectChange();
+        
+    private:
+
+        /**
+        * Initializes view when activated.
+        * @param aPrevViewId Id of the previous view (not used).
+        * @param aCustomMessageId Custom message id (not used).
+        * @param aCustomMessage Custom message (not used).
+        */
+        virtual void DoActivateL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,
+            const TDesC8& aCustomMessage);
+
+        /**
+        * Deactivates view.
+        */
+        virtual void DoDeactivate();
+
+    protected: // Data
+        
+        /**
+        * Pointer to UI Store.
+        */
+        CUIStore*     iUIStore;
+		
+		
+    private: // Data
+
+    };
+
+#endif // VIEW_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/inc/version.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+* 
+* Description: This file contains STIF UI version declaration.
+*
+*/
+
+#ifndef VERSION_H_
+#define VERSION_H_
+
+#define STIFUI_MAJOR_VERSION 7
+#define STIFUI_MINOR_VERSION 3
+#define STIFUI_BUILD_VERSION 23
+
+#define STIFUI_REL_DATE "22nd Dec 2009"
+
+#define TO_UNICODE(text) _L(text) 
+
+#endif /*VERSION_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/AppUIApp.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,71 @@
+/*
+* 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: This file contains CAppUIApp class definition.
+*
+*/
+
+// INCLUDE FILES
+#include    "AppUIApp.h"
+#include    "AppUIDocument.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CSTIFAppUIApp::AppDllUid()
+// Returns application UID
+// ---------------------------------------------------------
+//
+TUid CAppUIApp::AppDllUid() const
+    {
+    return KUidAppUI;
+    }
+
+   
+// ---------------------------------------------------------
+// CSTIFAppUIApp::CreateDocumentL()
+// Creates CSTIFAppUIDocument object
+// ---------------------------------------------------------
+//
+CApaDocument* CAppUIApp::CreateDocumentL()
+    {
+    return CAppUIDocument::NewL( *this );
+    }
+
+// ================= OTHER EXPORTED FUNCTIONS ==============
+//
+
+	#include <eikstart.h>
+	// ---------------------------------------------------------
+	// NewApplication() 
+	// Exported function
+	// Returns: CApaApplication: 
+	// ---------------------------------------------------------
+	//
+	LOCAL_C CApaApplication* NewApplication()
+		{
+		return new CAppUIApp;
+		}
+	// ---------------------------------------------------------
+	// E32Main() 
+	// EXE Entry point
+	// Returns: KErrNone: No error
+	// ---------------------------------------------------------
+	//
+	GLDEF_C TInt E32Main()
+		{
+		return EikStart::RunApplication(NewApplication);
+		}
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/AppUIAppUi.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,698 @@
+/*
+* 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: This file contains TMessageBoxUtil class definition.
+*
+*/
+
+// INCLUDE FILES
+#include "AppUIAppUi.h"
+
+#include "MainMenuView.h"
+#include "TestCaseMenuView.h"
+#include "StartCasesView.h"
+#include "TestModulesMenuView.h"
+#include "StartedCasesMenuView.h"
+#include "ShowStartedCasesView.h"
+#include "TestCaseOutputView.h"
+#include "StatisticsView.h"
+#include "TestSetBaseMenuView.h"
+#include "TestSetMenuView.h"
+#include "TestSetInsertMenuView.h"
+#include "TestSetStartedCasesView.h"
+#include <aknmessagequerydialog.h> 
+#include "version.h"
+
+#include "CreatedTestSetMenuView.h"
+
+#include <Stifui.rsg>
+#include "Stifui.hrh"
+
+
+#include <StifTestInterface.h>
+
+#include <aknnotewrappers.h>
+#include <stringloader.h>
+
+_LIT( KTestSet, "DefaultSet" );
+
+static const TInt KCopyrightChar = 169;
+
+// ----------------------------------------------------------
+// CMessageBoxUtil::ShowNotImplementedYetL
+// Displays message that executed funtion is not implemented yet.
+// ----------------------------------------------------------
+//
+void TMessageBoxUtil::ShowNotImplementedYetL()
+    {
+    _LIT(message, "Not implemented yet");
+    CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
+    informationNote->ExecuteLD(message);
+    }
+
+// ----------------------------------------------------------
+// Display error note.
+// @param aMessage Error message to display.
+// ----------------------------------------------------------
+//
+void TMessageBoxUtil::ShowErrorNoteL( const TDesC& aMessage )
+	{
+	CAknErrorNote* errorNote = new (ELeave) CAknErrorNote(ETrue);
+	// set timeout to 5 sec	
+	errorNote->SetTimeout( (CAknNoteDialog::TTimeout)5000000 );
+	errorNote->ExecuteLD( aMessage );
+	}
+
+// ================= MEMBER FUNCTIONS =======================
+//
+// ----------------------------------------------------------
+// CAppUIAppUi::ConstructL()
+// ?implementation_description
+// ----------------------------------------------------------
+//
+void CAppUIAppUi::ConstructL()
+    {
+    TInt error(0);
+
+    BaseConstructL( EAknEnableSkin );
+
+    // connection to setting server needs to be open as long as STIF Series 60 UI APP is alive
+    TInt ret = iSettingServer.Connect();
+    if ( ret != KErrNone )
+        {
+        User::Leave( ret );
+        }
+    
+    iLogger = CStifLogger::NewL( _L("E\x3a\\"), _L("stif_tfw_ui"),
+                                CStifLogger::ETxt, CStifLogger::EFile,
+                                ETrue, EFalse, ETrue, EFalse, EFalse );
+
+    iLogger->Log( _L("--- UI log starts ---") );
+    iLogger->Log( _L(" ") );
+    iLogger->Log( _L("appui: ConstructL") );
+
+	// Create CData object which handles all test cases data and running of them
+    iUIStoreHandler = CUIStoreHandler::NewL( this );
+    
+    // CUIStore open 
+    error = UIStoreHandler()->Open( KDefaultPathAndIni );
+    if ( KErrNone != error )
+    	{
+    	User::Leave( error );
+    	}
+
+    CMainMenuView* mainMenuView = new (ELeave) CMainMenuView;
+    CleanupStack::PushL( mainMenuView );
+    mainMenuView->ConstructL();
+    AddViewL( mainMenuView );      // transfer ownership to CAknViewAppUi
+    CleanupStack::Pop();    // MainMenuView
+
+    iLogger->Log(_L("appui:mainview "));
+
+    CCreatedTestSetMenuView* testCreatedTestSetMenuView = new (ELeave) CCreatedTestSetMenuView;
+        CleanupStack::PushL( testCreatedTestSetMenuView );
+       testCreatedTestSetMenuView->ConstructL();
+        AddViewL( testCreatedTestSetMenuView );      // transfer ownership to CAknViewAppUi
+        CleanupStack::Pop();    // testCaseMenuView
+    CTestCaseMenuView* testCaseMenuView = new (ELeave) CTestCaseMenuView;
+    CleanupStack::PushL( testCaseMenuView );
+    testCaseMenuView->ConstructL();
+    AddViewL( testCaseMenuView );      // transfer ownership to CAknViewAppUi
+    CleanupStack::Pop();    // testCaseMenuView
+
+    iLogger->Log(_L("appui:caseview "));
+
+    CStartCasesView* startCasesView = new (ELeave) CStartCasesView;
+    CleanupStack::PushL( startCasesView );
+    startCasesView->ConstructL();
+    AddViewL( startCasesView );      // transfer ownership to CAknViewAppUi
+    CleanupStack::Pop();    // startCasesView
+
+    iLogger->Log(_L("appui:startcaseview "));
+
+    CStartedCasesMenuView* startedCasesMenuView = new (ELeave) CStartedCasesMenuView;
+    CleanupStack::PushL( startedCasesMenuView );
+    startedCasesMenuView->ConstructL();
+    AddViewL( startedCasesMenuView );      // transfer ownership to CAknViewAppUi
+    CleanupStack::Pop();    // startedCasesMenuView
+
+    iLogger->Log(_L("appui:started cases view created"));
+
+    CShowStartedCasesView* showStartedCasesView = new (ELeave) CShowStartedCasesView;
+    CleanupStack::PushL( showStartedCasesView );
+    showStartedCasesView->ConstructL();
+    AddViewL( showStartedCasesView );      // transfer ownership to CAknViewAppUi
+    CleanupStack::Pop();    // showStartedCasesView
+
+    iLogger->Log(_L("appui: show started cases view created"));
+
+    CTestCaseOutputView* testCaseOutputView = new (ELeave) CTestCaseOutputView;
+    CleanupStack::PushL( testCaseOutputView );
+    testCaseOutputView->ConstructL();
+    AddViewL( testCaseOutputView );      // transfer ownership to CAknViewAppUi
+    CleanupStack::Pop();    // testCaseOutputView
+
+    iLogger->Log(_L("appui: test case output view created"));
+
+    CTestModulesMenuView* testModulesMenuView = new (ELeave) CTestModulesMenuView;
+    CleanupStack::PushL( testModulesMenuView );
+    testModulesMenuView->ConstructL();
+    AddViewL( testModulesMenuView );      // transfer ownership to CAknViewAppUi
+    CleanupStack::Pop();    // testModulesMenuView
+
+    iLogger->Log(_L("appui:modulesview "));
+
+    CStatisticsView* statisticsMenuView = new (ELeave) CStatisticsView;
+    CleanupStack::PushL( statisticsMenuView );
+    statisticsMenuView->ConstructL();
+    AddViewL( statisticsMenuView );      // transfer ownership to CAknViewAppUi
+    CleanupStack::Pop();    // statisticsMenuView
+
+    iLogger->Log(_L("appui:modulesview "));
+
+	//
+	CTestSetBaseMenuView* testSetBaseMenuView = new (ELeave) CTestSetBaseMenuView;
+    CleanupStack::PushL( testSetBaseMenuView );
+    testSetBaseMenuView->ConstructL();
+    AddViewL( testSetBaseMenuView );      // transfer ownership to CAknViewAppUi
+    CleanupStack::Pop();    // testSetBaseMenuView
+
+    iLogger->Log(_L("appui:testsetsbaseview "));
+    
+    CTestSetMenuView* testSetMenuView = new (ELeave) CTestSetMenuView;
+    CleanupStack::PushL( testSetMenuView );
+    testSetMenuView->ConstructL();
+    AddViewL( testSetMenuView );      // transfer ownership to CAknViewAppUi
+    CleanupStack::Pop();    // testSetMenuView
+
+    iLogger->Log(_L("appui:testsetsview "));
+	
+	CTestSetInsertMenuView* testSetInsertMenuView = new (ELeave) CTestSetInsertMenuView;
+    CleanupStack::PushL( testSetInsertMenuView );
+    testSetInsertMenuView->ConstructL();
+    AddViewL( testSetInsertMenuView );      // transfer ownership to CAknViewAppUi
+    CleanupStack::Pop();    // testSetInsertMenuView
+   	
+   	iLogger->Log(_L("appui:testsetinsertview "));
+   	
+   	CTestSetStartedCasesView* testSetStartedCasesView = new (ELeave) CTestSetStartedCasesView;
+    CleanupStack::PushL( testSetStartedCasesView );
+    testSetStartedCasesView->ConstructL();
+    AddViewL( testSetStartedCasesView );      // transfer ownership to CAknViewAppUi
+    CleanupStack::Pop();    // testSetStartedCasesView
+
+    iLogger->Log(_L("appui:testsetStartedCasesView "));
+    
+
+    SetDefaultViewL( *mainMenuView );
+
+    iLogger->Log(_L("appui:setdefview "));
+    
+    iStartedTestCase = NULL;
+    iStartedTestSet = -1;
+    
+    iPreviousPositionListValid = ETrue;
+    }
+
+// ----------------------------------------------------
+// CAppUIAppUi::~CAppUIAppUi()
+// Destructor
+// Frees reserved resources
+// ----------------------------------------------------
+//
+CAppUIAppUi::~CAppUIAppUi()
+    {
+    
+    if ( iLogger )
+    {
+    iLogger->Log( _L(" ") );
+    iLogger->Log( _L("--- UI log ends ---") );    	
+    }
+
+    delete iLogger;
+    iSettingServer.Close();
+    UIStoreHandler()->Close();
+    delete iUIStoreHandler;
+    
+    // Closing of array of positions of focus in various menus
+    iPreviousFocusPosition.Close();
+    // iPreviousFocusPosition is no longer valid and cannot be used any more
+    iPreviousPositionListValid = EFalse;
+    //RemoveView(EMainMenuViewId);
+    }
+
+// ------------------------------------------------------------------------------
+// CAppUIAppUi::Data( )
+// Just returns pointer to CUIStore object, which is created by CAppUIAppUi
+// ------------------------------------------------------------------------------
+//
+CUIStore* CAppUIAppUi::UIStoreHandler()
+    {
+    return &iUIStoreHandler->UIStore();
+
+    }
+
+// ------------------------------------------------------------------------------
+// CAppUIAppUi::::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 CAppUIAppUi::DynInitMenuPaneL(
+    TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
+    {
+
+    }
+
+// ----------------------------------------------------
+// CAppUIAppUi::HandleKeyEventL(
+//     const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
+// ?implementation_description
+// ----------------------------------------------------
+//
+TKeyResponse CAppUIAppUi::HandleKeyEventL(
+    const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
+    {
+	TInt currentView;
+
+	if ( iView )
+	{
+    currentView = (iView->Id()).iUid;
+ 			
+    
+    switch ( aKeyEvent.iCode )
+        {
+        case EKeyLeftArrow:
+			{
+			switch ( currentView )
+				{
+				case ETestModulesMenuViewId:
+					{
+                    HandleCommandL( EAppUIGoToTestCaseMenu );
+					break;
+					}
+				case ETestSetBaseMenuViewId:
+					{
+                    HandleCommandL( EAppUIGoToModulesMenu );
+					ActivateLocalViewL(TUid::Uid(ETestModulesMenuViewId));
+					break;
+					}
+                }
+            break;
+			}
+        case EKeyRightArrow:
+			{
+			switch ( currentView )
+				{
+				case ETestCaseMenuViewId:
+					{
+                    HandleCommandL( EAppUIGoToModulesMenu ); // TestCaseMenu --> TestModuleMenu
+					ActivateLocalViewL(TUid::Uid(ETestModulesMenuViewId));
+					break;
+					}
+				case ETestModulesMenuViewId:
+					{
+					HandleCommandL( EAppUIGoToTestSetsMenu );
+					ActivateLocalViewL(TUid::Uid(ETestSetBaseMenuViewId));
+					break;
+					}
+				case ETestSetsMenuViewId:
+					{
+					break;
+					}
+
+				}
+            break;
+			}
+
+        default:
+			{
+            return EKeyWasNotConsumed;
+            //break; 
+			}
+        }
+	}
+
+    return EKeyWasConsumed;
+
+    }
+
+// ----------------------------------------------------
+// CAppUIAppUi::HandleCommandL(TInt aCommand)
+// ?implementation_description
+// ----------------------------------------------------
+//
+void CAppUIAppUi::HandleCommandL(TInt aCommand)
+    {
+	TInt currentView, newView;
+    TInt error(0);
+    
+    currentView = (iView->Id()).iUid;
+
+    switch ( aCommand )
+        {
+        case EEikCmdExit:
+        case EAknSoftkeyExit:
+            {
+            PrepareToExit();
+            Exit();
+			newView = currentView;
+            break;
+            }
+        case EAppUIGoBack:
+            {
+			switch ( currentView )
+				{
+				case ETestCaseMenuViewId:
+					{
+					newView = EMainMenuViewId;  // Test Cases Menu --> Main Menu
+					break;
+					}
+				case EStartCaseMenuViewId:
+					{
+					newView = ETestCaseMenuViewId; // Start Cases Menu --> Test Cases Menu
+                    //iTabGroup->SetActiveTabByIndex(0);
+					break;
+					}
+				case ETestModulesMenuViewId:
+					{
+					newView = EMainMenuViewId; // Test Modules Menu --> Main Menu
+					break;
+					}
+				case EStartedCasesMenuViewId:
+					{
+					newView = ETestCaseMenuViewId; // Started Cases Menu --> Test Case Menu
+					break;
+					}
+				case EShowStartedCasesViewId:
+					{
+					newView = EStartedCasesMenuViewId; // Show started cases --> Started Cases Menu
+					break;
+					}
+				case ETestCaseOutputViewId:
+					{
+                    newView = iPreviousView; // Test case output view --> previous view
+					break;
+					}
+				case EStatisticsViewId:
+					{
+                    newView = EStartedCasesMenuViewId; // Statistic view --> Started Cases Menu
+					break;
+					}
+				case ETestSetBaseMenuViewId:
+					{
+					newView = EMainMenuViewId;  // Test Sets Base Menu --> Main Menu
+					break;
+					}
+				case ETestSetMenuViewId:
+					{
+					newView = ETestSetBaseMenuViewId;  // Test Sets Menu --> Test Sets Base Menu
+					break;
+					}
+				case ETestSetInsertMenuViewId:
+					{
+					newView = ETestSetMenuViewId;  // Test Set Insert Menu --> Test Sets Menu
+					break;
+					}
+				case ETestSetStartedCasesViewId:
+					{
+					newView = ETestSetMenuViewId;  // Test Set Started Cases Menu --> Test Sets Menu
+					break;
+					}
+				default:
+					{
+					newView = currentView; // Back does not work. This should not happen ever
+					break;
+					}
+				}
+            break;
+			}
+		case EAppUIGoToMainMenu:
+			{
+			newView = EMainMenuViewId;
+			break;
+			}
+		case EAppUIGoToTestCaseMenu:
+			{
+			newView = ETestCaseMenuViewId;
+			break;
+			}
+		case ECmdGoToStartCasesView:
+			{
+			newView = EStartCaseMenuViewId;
+			break;
+			}
+		case ECmdGoToStartedCasesView:
+			{
+			newView = EStartedCasesMenuViewId;
+			break;
+			}
+		case EAppUIGoToModulesMenu:
+			{
+			newView = ETestModulesMenuViewId;
+            //iTabGroup->SetActiveTabByIndex(1);
+			break;
+			}
+		case EAppUIGoToTestSetsMenu:
+			{
+            newView = ETestSetBaseMenuViewId;
+            
+            //ShowNotImplementedYet();
+            //newView = currentView;
+			break;
+			}
+        case ECmdCreateTestSet:
+	        {
+	        CTestSetMenuView* testSetMenu = (CTestSetMenuView*)View( TUid::Uid(ETestSetMenuViewId) );
+	        error = testSetMenu->CreateTestSetL( KTestSet );
+	        if ( KErrNone == error ||  KErrAlreadyExists == error)
+	            {
+	            newView = ETestSetInsertMenuViewId;
+	            currentView = ETestSetMenuViewId; // Store previous view for Back function
+	            }
+	        else
+	            {
+	            newView = ETestSetMenuViewId;
+	            }
+            break;
+    	    }
+    	case ECmdLoadTestSet:
+	        {
+	        newView = ECreatedTestSetMenuViewId; /*ETestSetBaseMenuViewId;*/
+	        break;
+			}
+    	case ECmdGoToTestSetView:
+    		{
+
+    		newView = ETestSetMenuViewId; 
+    		break;
+    		}
+        case ECmdInsertTestCases:
+	        {
+    		newView = ETestSetInsertMenuViewId;
+    		break;
+        	}
+        case ECmdShowStartedTestSet:
+	        {
+    		newView = ETestSetStartedCasesViewId;
+    		iShowStartedCasesMode = EShowAllStartedCases;
+    		break;
+        	}
+        case ECmdShowAllStartedCases:
+            newView = EShowStartedCasesViewId;
+            iShowStartedCasesMode = EShowAllStartedCases;
+			break;
+        case ECmdShowOngoingCases:
+            newView = EShowStartedCasesViewId;
+            iShowStartedCasesMode = EShowOngoingCases;
+        	break;
+        case ECmdShowPassedCases:
+            newView = EShowStartedCasesViewId;
+            iShowStartedCasesMode = EShowPassedCases;
+			break;
+        case ECmdShowPausedCases:
+            newView = EShowStartedCasesViewId;
+            iShowStartedCasesMode = EShowPausedCases;
+			break;
+        case ECmdShowFailedCases:
+            newView = EShowStartedCasesViewId;
+            iShowStartedCasesMode = EShowFailedCases;
+			break;
+        case ECmdShowCrashedAbortedCases:
+            newView = EShowStartedCasesViewId;
+            iShowStartedCasesMode = EShowCrashedAbortedCases;
+			break;
+        case ECmdShowStatistics:
+            newView = EStatisticsViewId;
+			break;
+        case ECmdViewOutput:
+            newView = ETestCaseOutputViewId;
+            break;
+        case ECmdShowAbout:
+        	{
+        	CAknMessageQueryDialog* dlg = new (ELeave) CAknMessageQueryDialog;
+        	TBuf<200> version;
+        	version.Format(_L("STIF UI - Version %d.%d.%d - "), STIFUI_MAJOR_VERSION, STIFUI_MINOR_VERSION, STIFUI_BUILD_VERSION);
+        	version.Append(TO_UNICODE(STIFUI_REL_DATE));
+        	version.Append(_L("\n"));
+        	
+        	TInt stifMajorV;
+        	TInt stifMinorV;
+        	TInt stifBuildV;
+        	TBuf<30> relDate;
+        	TStifUtil::STIFVersion(stifMajorV, stifMinorV, stifBuildV, relDate);
+        	
+        	TBuf<40> stifVersion;
+        	stifVersion.Format(_L("STIF - Version %d.%d.%d - "), stifMajorV, stifMinorV, stifBuildV);
+        	stifVersion.Append(relDate);
+        	stifVersion.Append(_L("\n"));
+        	
+        	version.Append(stifVersion);
+        	
+        	version.Append(_L("Copyright "));
+			version.Append( KCopyrightChar );
+			version.Append(_L(" 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved."));
+        	
+        	dlg->SetMessageText(version);
+        	dlg->ExecuteLD(R_STIFUI_ABOUT_DIALOG);
+        	newView = currentView;
+        	break;
+        	}
+        default:
+			{
+            TMessageBoxUtil::ShowNotImplementedYetL();
+			newView = currentView;
+            break;
+			}
+        }
+
+	if( newView != currentView )
+		{
+        iPreviousView = currentView; // Store previous view for Back function
+		ActivateLocalViewL( TUid::Uid(newView) );
+
+		/*switch ( newView )
+			{
+			case EMainMenuViewId:
+            case EStartedCasesMenuViewId:
+            case EStartCaseMenuViewId:
+            case ETestCaseOutputViewId:
+				{
+		        //StatusPane()->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_USUAL);
+                //iTabGroup->DimTab (ETestCaseMenuTab, ETrue);
+                //iTabGroup->DimTab (ETestModulesMenuTab, ETrue);
+                //iTabGroup->DimTab (ETestSetsMenuTab, ETrue);
+
+                //StatusPane()->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_EMPTY);
+				//StatusPane()->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_IDLE);
+				break;
+				}
+			case ETestCaseMenuViewId:
+			case ETestModulesMenuViewId:
+			case ETestSetsMenuViewId:
+				{
+				//StatusPane()->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_USUAL);
+                //iTabGroup->DimTab (ETestCaseMenuTab, EFalse);
+                //iTabGroup->DimTab (ETestModulesMenuTab, EFalse);
+                //iTabGroup->DimTab (ETestSetsMenuTab, EFalse);
+                break;
+				}
+			default:
+				{
+                break;
+				}
+			}*/
+		}
+
+    }
+
+/**
+* Receives output update notification from UI Storehandler
+* @param
+* @return
+*/
+void CAppUIAppUi::OutputUpdateL( CStartedTestCase* aTestCase, TInt /* aStatus */ )
+    {
+    if( iView->Id().iUid == ETestCaseOutputViewId )
+        {
+        ( ( CTestCaseOutputView* )iView )->OutputUpdateL( aTestCase );
+        }
+    else if( iView->Id().iUid == EShowStartedCasesViewId )
+        {
+        ( ( CShowStartedCasesView* )iView )->TestCaseStateChangedL();
+        }
+    else if( iView->Id().iUid == ETestCaseOutputViewId )
+        {
+        ( ( CTestCaseOutputView* )iView )->TestCaseStateChangedL();
+        }
+    }
+  
+/**
+* Sets index of selected test case for viewing test case output
+* @param
+* @return
+*/    
+void CAppUIAppUi::SetStartedTestCase( CStartedTestCase* aStartedTestCase )
+    {
+    iStartedTestCase = aStartedTestCase;
+    }    
+  
+/**
+* Returns index of selected test case for viewing test case output
+* @param
+* @return
+*/    
+CStartedTestCase* CAppUIAppUi::GetStartedTestCase( )
+    {
+    return iStartedTestCase;
+    }        
+
+/**
+ * Stores focus position of focus from a specyfic view to iPreviousFocusPosition object.
+ * Value is than used to retrieve previous position of focus in the menu
+ * @param aViewId - identification of view
+ * @param aPosition - value to store for a specyfic view
+ */
+void CAppUIAppUi::SaveFocusPosition(TAppUIViewNumber aViewId, TInt aPosition)
+	{
+	if(!iPreviousPositionListValid)
+		{
+		return;
+		}
+	for(TInt counter = iPreviousFocusPosition.Count(); counter <= aViewId; counter++)
+		{
+		iPreviousFocusPosition.Append(0);
+		}
+	iPreviousFocusPosition[aViewId] = aPosition;
+	}
+
+/**
+ * Restores focus position of focus for a specyfic view from iPreviousFocusPosition object.
+ * @param aViewId - identification of view
+ * @return - previous position of focus in the requested view
+ */
+TInt CAppUIAppUi::GetFocusPosition(TAppUIViewNumber aViewId)
+	{
+	if(iPreviousFocusPosition.Count() > aViewId)
+		{
+		return iPreviousFocusPosition[aViewId];
+		}
+	else
+		{
+		return KErrNotFound;
+		}
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/AppUIDocument.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,62 @@
+/*
+* 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: This file contains CAppUIDocument class definition.
+*
+*/
+
+// INCLUDE FILES
+#include "AppUIDocument.h"
+#include "AppUIAppUi.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// constructor
+CAppUIDocument::CAppUIDocument(CEikApplication& aApp)
+: CAknDocument(aApp)    
+    {
+    }
+
+// destructor
+CAppUIDocument::~CAppUIDocument()
+    {
+    }
+
+// Symbian OS default constructor can leave.
+void CAppUIDocument::ConstructL()
+    {
+    }
+
+// Two-phased constructor.
+CAppUIDocument* CAppUIDocument::NewL(
+        CEikApplication& aApp)     // CAppUIApp reference
+    {
+    CAppUIDocument* self = new (ELeave) CAppUIDocument( aApp );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+    
+// ----------------------------------------------------
+// CAppUIDocument::CreateAppUiL()
+// constructs CAppUIAppUi
+// ----------------------------------------------------
+//
+CEikAppUi* CAppUIDocument::CreateAppUiL()
+    {
+    return new (ELeave) CAppUIAppUi;
+    }
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/Container.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,410 @@
+/*
+* 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: This file contains CTestCaseListBoxModel class
+* definition.
+*
+*/
+
+// INCLUDE FILES
+#include <aknlists.h>  // ListBox
+#include <akniconarray.h> // CAknIconArray
+#include <aknnotewrappers.h>
+
+#include <eikclbd.h> //  CColumnListBoxData
+
+#include "Container.h"
+#include <Stifui.rsg>
+#include "Stifui.hrh"
+#include "AppUIAppUi.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+// ----------------------------------------------------------------------------
+// CTestCaseListBoxModel::NewL
+// 
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+
+CTestCaseListBoxModel* CTestCaseListBoxModel::NewL(RPointerArray<CTestInfo>* aTestCasesInView)
+    {
+    CTestCaseListBoxModel* self = new ( ELeave ) CTestCaseListBoxModel();
+    CleanupStack::PushL( self );
+    self->iBuffer = HBufC::NewL( 130 );
+    self->iTestCasesInView = aTestCasesInView;
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseListBoxModel::ConstructL
+// 
+// Symbian OS two phased constructor.
+// ----------------------------------------------------------------------------
+//
+
+void CTestCaseListBoxModel::ConstructL()
+    {
+    //iBuffer = HBufC::NewLC( KMaxInfoName + KMaxName + 2 );
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseListBoxModel::~CTestCaseListBoxModel
+// 
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CTestCaseListBoxModel::~CTestCaseListBoxModel()
+    {
+    delete iBuffer;
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseListBoxModel::MdcaCount
+// 
+// Returns the number of descriptor elements in the array.
+// ----------------------------------------------------------------------------
+//
+
+TInt CTestCaseListBoxModel::MdcaCount() const
+    {
+    return iTestCasesInView->Count();
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseListBoxModel::MdcaPoint
+// 
+// Indexes into a descriptor array.
+// ----------------------------------------------------------------------------
+//
+TPtrC CTestCaseListBoxModel::MdcaPoint(TInt aIndex) const
+    {
+    CTestInfo* testCasePtr = (*iTestCasesInView)[aIndex];
+    TPtr buffer( iBuffer->Des() );
+    buffer.Zero();
+    buffer.Append(_L("\t"));
+    buffer.Append(testCasePtr->TestCaseTitle() );
+    return *iBuffer;
+    }
+
+// ================= MEMBER FUNCTIONS =======================
+// ----------------------------------------------------------------------------
+// CContainer::ConstructL
+// 
+// Symbian OS two phased constructor.
+// ----------------------------------------------------------------------------
+//
+void CContainer::ConstructL()
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CContainer::~CContainer
+// 
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CContainer::~CContainer()
+    {
+    iTestCasesInView.Close(); // does not delete objects whose pointers are contained in the array
+    delete iListBox;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CContainer::SetGraphicIconL
+// 
+// Sets graphic icon using listbox as CEikColumnListBox.
+// ----------------------------------------------------------------------------
+//
+void CContainer::SetGraphicIconL( CEikColumnListBox* aListBox )
+	{
+	    if ( aListBox )
+	        {
+	        // Creates gul icon.
+	        CAknIconArray* iconArray = new(ELeave) CAknIconArray(1);
+	        CleanupStack::PushL( iconArray );
+	        
+	        GraphicIconL( iconArray ); // Appends graphic data.
+	        
+	        // Sets graphics as ListBox icon.
+	        aListBox->ItemDrawer()->ColumnData()->SetIconArray( iconArray );
+	        
+	        CleanupStack::Pop();
+	        }
+	    }
+
+// ----------------------------------------------------------------------------
+// CContainer::CurrentItemIndex
+// 
+// Returns current item index in list box.
+// ----------------------------------------------------------------------------
+//
+TInt CContainer::CurrentItemIndex()
+    {
+    return iListBox->CurrentItemIndex();
+    }
+
+// ----------------------------------------------------------------------------
+// CContainer::SetCurrentItemIndex
+// 
+// Sets current item index in list box.
+// ----------------------------------------------------------------------------
+//
+void CContainer::SetCurrentItemIndex(TInt aCurrentTestCase)
+    {
+    iListBox->SetCurrentItemIndexAndDraw(aCurrentTestCase);
+    }
+
+// ----------------------------------------------------------------------------
+// CContainer::GraphicIconL
+// 
+// Appends graphics data.
+// ----------------------------------------------------------------------------
+//
+void CContainer::GraphicIconL( CArrayPtr<CGulIcon>* aIcons )
+    {
+    if ( aIcons )
+            {
+            CFbsBitmap* markBitmap = NULL;
+            CFbsBitmap* markBitmapMask = NULL;
+    	
+            TRgb defaultColor;
+            defaultColor = CEikonEnv::Static()->Color(EColorControlText);
+    	
+            AknsUtils::CreateColorIconL(AknsUtils::SkinInstance(),
+            		KAknsIIDQgnIndiMarkedAdd,
+            		KAknsIIDQsnIconColors,
+            		EAknsCIQsnIconColorsCG13,
+            		markBitmap,
+            		markBitmapMask,
+            		AknIconUtils::AvkonIconFileName(),
+            		EMbmAvkonQgn_indi_marked_add,
+            		EMbmAvkonQgn_indi_marked_add_mask,
+            		defaultColor );
+            
+            CGulIcon* markIcon = CGulIcon::NewL(markBitmap,markBitmapMask);
+            aIcons->AppendL(markIcon); 
+            }
+        }
+
+
+// ----------------------------------------------------------------------------
+// CContainer::SizeChanged
+// 
+// Called by framework when the view size is changed.
+// ----------------------------------------------------------------------------
+//
+void CContainer::SizeChanged()
+    {
+    if ( iListBox )
+		{
+		iListBox->SetRect( Rect() ); // Sets rectangle of listbox.
+		}
+    }
+
+// ----------------------------------------------------------------------------
+// CContainer::CountComponentControls
+// 
+// Gets a count of the component controls of this list box control.
+// ----------------------------------------------------------------------------
+//
+TInt CContainer::CountComponentControls() const
+    {
+    return 1; // return nbr of controls inside this container
+    }
+
+// ----------------------------------------------------------------------------
+// CContainer::ComponentControl
+// 
+// Gets a pointer to the specified component control.
+// ----------------------------------------------------------------------------
+//
+CCoeControl* CContainer::ComponentControl(TInt aIndex) const
+    {
+    switch ( aIndex )
+        {
+		case 0: 
+			return iListBox;
+        default:
+            return NULL;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CContainer::Draw
+// 
+// Draw a control, called by window server.
+// ----------------------------------------------------------------------------
+//
+void CContainer::Draw(const TRect& /*aRect*/) const
+    {
+    // CWindowGc& gc = SystemGc();
+    }
+
+// ----------------------------------------------------------------------------
+// CContainer::SelectedTestCases
+// 
+// Returns pointers to selected test cases.
+// ----------------------------------------------------------------------------
+//
+void CContainer::SelectedTestCases
+                            (RPointerArray<CTestInfo>& aSelectedTestCases)
+    {
+    aSelectedTestCases.Append( iTestCasesInView[iListBox->CurrentItemIndex()] );
+    }
+
+    
+// ----------------------------------------------------------------------------
+// CContainer::HandleMarkCommandL
+// 
+// Handles mark commands.
+// ----------------------------------------------------------------------------
+//
+void CContainer::HandleMarkCommandL( TInt aCommand )
+	{
+	if (iListBox)
+		{
+		AknSelectionService::HandleMarkableListProcessCommandL( aCommand, iListBox );		
+		}
+	}
+
+// ----------------------------------------------------------------------------
+// CContainer::ProcessCommandL
+// 
+// Processes user commands.
+// ----------------------------------------------------------------------------
+//
+void CContainer::ProcessCommandL( TInt  aCommand )
+	{
+	AknSelectionService::HandleMarkableListProcessCommandL( aCommand, iListBox );
+    }
+    
+// ----------------------------------------------------------------------------
+// CContainer::SelectionListProcessCommandL
+// 
+// Processes user commands.
+// ----------------------------------------------------------------------------
+//     
+void CContainer::SelectionListProcessCommandL( TInt  aCommand )
+	{
+	AknSelectionService::HandleSelectionListProcessCommandL( aCommand, iListBox );
+    }
+    
+// ----------------------------------------------------------------------------
+// CContainer::FilterCasesByModuleL
+// 
+// Show only testcases which are defined is specified module.
+// ----------------------------------------------------------------------------
+//
+void CContainer::FilterCasesByModuleL( TName aModuleName )
+    {
+    iTestCasesInView.Reset(); // Clear testCasesInView pointer array
+   
+    RRefArray<CTestInfo> allCases;
+    TInt ret = iUIStore->TestCases( allCases );
+    if( KErrNone != ret )
+        {
+        ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("FilterCasesByModuleL(): iUIStore->TestCases() fails"));
+        allCases.Reset();
+        allCases.Close();
+        User::Leave( ret );
+        }
+    const TInt KTestCaseCount = allCases.Count();
+    for( TInt i=0; i < KTestCaseCount; i++ )
+        {
+        if ( allCases[i].ModuleName() == aModuleName )
+            {
+            iTestCasesInView.Append( &( allCases[i] ) );
+            }
+        }
+    allCases.Reset();
+    allCases.Close();
+
+    iListBox->Reset();
+    iListBox->DrawNow();
+    }
+
+// ----------------------------------------------------------------------------
+// CContainer::FilterCasesByTCFileNameL
+// 
+// Show only testcases which are defined is specified test case file.
+// ----------------------------------------------------------------------------
+//
+void CContainer::FilterCasesByTCFileNameL( 
+                                                TFileName aTestCaseFileName )
+    {
+
+    iTestCasesInView.Reset(); // Clear testCasesInView pointer array
+  
+    RRefArray<CTestInfo> allCases;
+    TInt ret = iUIStore->TestCases( allCases );
+    if( KErrNone != ret )
+        {
+        ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("FilterCasesByModuleL(): iUIStore->TestCases() fails"));
+        allCases.Reset();
+        allCases.Close();
+        User::Leave( ret );
+        }
+    const TInt KTestCaseCount = allCases.Count();
+    for( TInt i=0; i < KTestCaseCount; i++ )
+        {
+        if ( allCases[i].TestCaseFile() == aTestCaseFileName )
+            {
+            iTestCasesInView.Append( &( allCases[i] ) );
+            }
+        }
+
+    allCases.Reset();
+    allCases.Close();
+
+    iListBox->Reset();
+    iListBox->DrawNow();
+    }
+
+// ----------------------------------------------------------------------------
+// CContainer::NoFilteringL
+// 
+// Remove possible filtering of test cases -> show all test cases.
+// ----------------------------------------------------------------------------
+//
+void CContainer::NoFilteringL()
+    {
+    iTestCasesInView.Reset(); // Clear testCasesInView pointer array
+
+    RRefArray<CTestInfo> allCases;
+    TInt ret = iUIStore->TestCases( allCases );
+    if( KErrNone != ret )
+        {
+        ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("FilterCasesByModuleL(): iUIStore->TestCases() fails"));
+        allCases.Reset();
+        allCases.Close();
+        User::Leave( ret );
+        }
+    const TInt KTestCaseCount = allCases.Count();
+
+    // Add all cases to iTestCasesInView pointer array
+    for( TInt i=0; i < KTestCaseCount; i++ )
+        {
+        iTestCasesInView.Append( &( allCases[i] ) );
+        }
+
+    allCases.Reset();
+    allCases.Close();
+
+    iListBox->Reset();
+    iListBox->DrawNow();
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/CreatedTestSetMenuContainer.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -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: This fiole contains CreatedTestSetMenuContainer class
+* definition.
+*
+*/
+
+// INCLUDE FILES
+#include <aknlists.h>   // ListBox
+#include <akniconarray.h> // CAknIconArray
+#include <aknnotewrappers.h>
+
+#include <eikclbd.h> // CColumnListBoxData
+
+#include "CreatedTestSetMenuContainer.h"
+#include "StartCasesView.h"
+#include <Stifui.rsg>
+#include "Stifui.hrh"
+#include "AppUIAppUi.h"
+
+#include "Container.h"
+#include "MenuListBox.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+// ----------------------------------------------------------------------------
+// CreatedTestSetMenuContainer::ConstructL
+// 
+// Symbian OS two phased constructor.
+// ----------------------------------------------------------------------------
+//
+void CCreatedTestSetMenuContainer::ConstructL(const TRect& aRect, MEikListBoxObserver* aListBoxObserver)
+    {
+    ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("CCreatedTestSetMenuContainer: ConstructL"));
+
+	iParentView = (CCreatedTestSetMenuView*)aListBoxObserver;
+    CreateWindowL();
+
+    iUIStore = ( (CAppUIAppUi*)iCoeEnv->AppUi() )->UIStoreHandler();
+
+    iTestCasesInView.Reset();
+    
+	iListBox = CMenuListBox::NewL(ECreatedTestSetMenuViewId);
+	iListBox->SetContainerWindowL( *this );
+	iListBox->SetListBoxObserver( aListBoxObserver /*this*/ ); // 
+    iListBox->ConstructL(this, EAknListBoxMarkableList /*EAknListBoxSelectionList*/);
+
+    ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("CCreatedTestSetMenuContainer: ListBox constructed"));
+
+    //Create Scroller control for ListBox and set its visibility
+    iListBox->CreateScrollBarFrameL(ETrue);
+    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
+	iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
+
+    if ( iUIStore )
+        {
+        CDesCArray* items = static_cast<CDesCArray*> (iListBox->Model()->ItemTextArray());
+        
+        //Create list of available Test Set
+        RRefArray<TDesC>    allSet;      
+        RRefArray<CTestInfo> allCases;
+        TInt ret = iUIStore->GetTestSetsList( allSet );
+        if( KErrNone != ret )
+            {
+            ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("iUIStore->GetTestSetsList() fails"));
+            allSet.Reset();
+            allSet.Close();
+            User::Leave( ret );
+            }
+
+        const TInt KTestCaseCount = allSet.Count();
+        for (TInt i=0; i <KTestCaseCount; i++)
+            {
+            _LIT(KItemFromat, "0\t%S\t\t");
+     
+           RBuf tmp;
+           tmp.Create(allSet[i].Length() + 6);
+           tmp.Format( KItemFromat, &allSet[i] );
+           items->AppendL( tmp );
+           tmp.Close();
+           }
+       ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("CCreatedTestSetMenuContainer: ListBox model"));         
+       iListBox->Model()->SetOwnershipType(ELbmOwnsItemArray);
+       iListBox->HandleItemAdditionL();
+ 
+        allSet.Reset();
+        allSet.Close();
+        }
+    else
+        {
+        User::Leave( KErrGeneral );
+        }
+
+    // Creates graphic.
+    SetGraphicIconL( iListBox );
+       ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("CCreatedTestSetMenuContainer: icons created"));
+
+    iListBox->ActivateL();
+    ((CMenuListBox*)iListBox)->SetPreviousFocus();
+
+    SetRect(aRect);
+    ActivateL();
+    }
+
+// ----------------------------------------------------------------------------
+//CreatedTestSetMenuContainer::~CStartCasesContainer
+// 
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CCreatedTestSetMenuContainer::~CCreatedTestSetMenuContainer()
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CreatedTestSetMenuContainer::SizeChanged
+// 
+// Called by framework when the view size is changed.
+// ----------------------------------------------------------------------------
+//
+void CCreatedTestSetMenuContainer::SizeChanged()
+    {
+    
+    if ( iListBox )
+		{
+		iListBox->SetRect( Rect() ); // Sets rectangle of listbox.
+		}
+    }
+
+// ----------------------------------------------------------------------------
+//CreatedTestSetMenuContainer::CountComponentControls
+// 
+// Gets a count of the component controls of this list box control.
+// ----------------------------------------------------------------------------
+//
+TInt CCreatedTestSetMenuContainer::CountComponentControls() const
+    {
+    return 1; // return nbr of controls inside this container
+    }
+
+// ----------------------------------------------------------------------------
+// CreatedTestSetMenuContainer::ComponentControl
+// 
+// Gets a pointer to the specified component control.
+// ----------------------------------------------------------------------------
+//
+CCoeControl* CCreatedTestSetMenuContainer::ComponentControl(TInt aIndex) const
+    {
+    switch ( aIndex )
+        {
+		case 0: 
+			return iListBox;
+        default:
+            return NULL;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CreatedTestSetMenuContainer::Draw
+// 
+// Draw a control, called by window server.
+// ----------------------------------------------------------------------------
+//
+void CCreatedTestSetMenuContainer::Draw(const TRect& /*aRect*/) const
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CreatedTestSetMenuContainer::OfferKeyEventL
+// 
+// Handles key events.
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CCreatedTestSetMenuContainer::OfferKeyEventL(
+	const TKeyEvent& aKeyEvent, TEventCode aType )
+    {
+	if (iListBox)
+		{
+	
+		return iListBox->OfferKeyEventL( aKeyEvent, aType );
+		}
+	else
+		{
+		return EKeyWasNotConsumed;
+		}
+    }
+
+// ----------------------------------------------------------------------------
+// CreatedTestSetMenuContainer:::SaveActiveLine
+//
+// Makes the iListBox member save its focus position
+// ----------------------------------------------------------------------------
+//
+void CCreatedTestSetMenuContainer::SaveActiveLine()
+	{
+	((CMenuListBox*)iListBox)->SaveFocusPosition();
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/CreatedTestSetMenuView.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,199 @@
+/*
+* 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: This file contains CStartCasesView class definition.
+*
+*/
+
+// INCLUDE FILES
+#include  <eikmenub.h>
+#include  <aknviewappui.h>
+#include  <aknlistquerydialog.h> 
+#include  <barsread.h>	//TResourceReader
+#include  <Stifui.rsg>
+#include  "CreatedTestSetMenuView.h"
+#include  "CreatedTestSetMenuContainer.h"
+#include  "AppUIAppUi.h"
+#include  "Stifui.hrh" 
+#include "TestSetMenuView.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+// ----------------------------------------------------------------------------
+// CStartCasesView::ConstructL
+// 
+// Symbian OS two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+void CCreatedTestSetMenuView::ConstructL()
+    {
+    CView::ConstructL();  
+    BaseConstructL(R_APPUI_LOADTESTSETVIEW);
+    iCurrentTestCase = 0;
+
+    }
+
+// ----------------------------------------------------------------------------
+// CreatedTestSetMenuView::~CStartCasesView
+// 
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CCreatedTestSetMenuView::~CCreatedTestSetMenuView()
+    {
+    if ( iContainer )
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        }
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;
+    }
+
+// ----------------------------------------------------------------------------
+// CreatedTestSetMenuView::Id
+// 
+// Returns view´s id.
+// ----------------------------------------------------------------------------
+//
+TUid CCreatedTestSetMenuView::Id() const
+    {
+    return TUid::Uid(ECreatedTestSetMenuViewId);
+
+    }
+
+// ----------------------------------------------------------------------------
+// CreatedTestSetMenuView::HandleCommandL
+// 
+// Handles a command.
+// ----------------------------------------------------------------------------
+//
+void CCreatedTestSetMenuView::HandleCommandL(TInt aCommand)
+    {   
+    switch ( aCommand )
+            {
+            case EAknSoftkeyBack:
+                {
+                AppUi()->HandleCommandL(EAppUIGoToTestSetsMenu);
+                break;
+                }
+    		case EAknCmdOpen:
+    			{
+    		   		HandleListBoxEventL(iContainer->ListBox(), EEventEnterKeyPressed);	
+    			break;
+    			}
+            default:
+                {
+                AppUi()->HandleCommandL( aCommand );
+                break;
+                }
+            }
+
+    }
+
+// ----------------------------------------------------------------------------
+//CreatedTestSetMenuView::HandleClientRectChange
+// 
+// Handles client rect changes.
+// ----------------------------------------------------------------------------
+//
+void CCreatedTestSetMenuView::HandleClientRectChange()
+    {
+    if ( iContainer )
+        {
+        iContainer->SetRect( ClientRect() );
+        }
+
+    }
+
+// ----------------------------------------------------------------------------
+// CreatedTestSetMenuView::DoActivateL
+// 
+// Initializes view when activated.
+// ----------------------------------------------------------------------------
+//
+void CCreatedTestSetMenuView::DoActivateL(
+   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
+   const TDesC8& /*aCustomMessage*/)
+    {
+    if (!iContainer)
+        {
+        ((CAppUIAppUi*)AppUi())->iLogger->Log(_L("CreatedTestSetMenuView: DoActivateL"));
+        iContainer = new (ELeave) CCreatedTestSetMenuContainer;
+        iContainer->SetMopParent(this);
+        iContainer->ConstructL( ClientRect(), this );
+           ((CAppUIAppUi*)AppUi())->iLogger->Log(_L("CreatedTestSetMenuView: container constructed"));
+        AppUi()->AddToStackL( *this, iContainer );
+        }
+
+    iContainer->SetCurrentItemIndex(iCurrentTestCase);
+    
+    CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane();
+	CAknNavigationControlContainer* np= (CAknNavigationControlContainer *)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
+	
+	TResourceReader reader;
+	iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_LOADTESTSET);
+	iNaviDecorator = np->CreateNavigationLabelL( reader );
+	CleanupStack::PopAndDestroy(); // resource reader
+	np->PushL(*iNaviDecorator);
+
+    }
+
+// ----------------------------------------------------------------------------
+// CreatedTestSetMenuView::DoDeactivate
+// 
+// Deactivates view.
+// ----------------------------------------------------------------------------
+//
+void CCreatedTestSetMenuView::DoDeactivate()
+    {
+    if ( iContainer )
+        {
+        iContainer->SaveActiveLine();
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        iContainer = NULL;
+        }
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CreatedTestSetMenuView::HandleListBoxEventL
+// 
+// Handles listbox events.
+// ----------------------------------------------------------------------------
+//
+void CCreatedTestSetMenuView::HandleListBoxEventL( CEikListBox* aListBox, 
+    TListBoxEvent aEventType )
+	{
+	if (  aEventType == MEikListBoxObserver::EEventEnterKeyPressed    )
+		{
+	 	// Checking with item from list was selected	
+		CTextListBoxModel* tmp = (CTextListBoxModel*)aListBox->Model();
+		TPtrC item = tmp->ItemText(aListBox->CurrentItemIndex());
+		// Geting propper format of item from list (ex. 2008_8_10_13_16.set ). 
+		TPtrC substracted(item.Left(item.Length()-2));
+		substracted.Set(substracted.Right(substracted.Length()-2));
+		// Creating new view containing 		
+       	CTestSetMenuView* testSetMenu = (CTestSetMenuView*)AppUi()->View( TUid::Uid(ETestSetMenuViewId) ); 
+       	TInt	error = testSetMenu->LoadTestSetL( substracted );
+		AppUi()->HandleCommandL(ECmdGoToTestSetView);
+		
+        }
+ 
+    }
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/MainMenuContainer.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,217 @@
+/*
+* 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: This file contains CMainMenuContainer class
+* definition.
+*
+*/
+
+// INCLUDE FILES
+#include <aknlists.h>  // ListBox
+
+#include <barsread.h> // for TResourceReader
+
+#include <aknnotewrappers.h>
+
+#include "MainMenuContainer.h"
+#include "Stifui.hrh"
+#include <Stifui.rsg>
+#include "MenuListBox.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CMainMenuContainer::ConstructL
+// 
+// Symbian OS two phased constructor
+// ---------------------------------------------------------
+//
+void CMainMenuContainer::ConstructL(const TRect& aRect)
+    {
+    CreateWindowL();
+
+	iListBox = CMenuListBox::NewL(EMainMenuViewId);
+	iListBox->SetContainerWindowL( *this );
+	TResourceReader reader;
+	iCoeEnv->CreateResourceReaderLC( reader, R_MAIN_MENU_LISTBOX );
+	iListBox->SetListBoxObserver( this );
+	iListBox->ConstructFromResourceL( reader );
+	CleanupStack::PopAndDestroy(); // resource stuffs. 
+	iListBox->ActivateL(); // Sets control as ready to be drawn
+	
+	// retrieve previous position of focus for this view/continer and set focus to this value
+	((CMenuListBox*)iListBox)->SetPreviousFocus();
+
+    SetRect(aRect);
+    ActivateL();
+    }
+
+
+// ---------------------------------------------------------
+// CMainMenuContainer::~CMainMenuContainer
+//
+// Destructor
+// ---------------------------------------------------------
+//
+CMainMenuContainer::~CMainMenuContainer()
+    {
+	if( iListBox )
+		{
+		delete iListBox;
+		iListBox = NULL;
+		}
+	}
+
+// ---------------------------------------------------------
+// CMainMenuContainer::SizeChanged
+// 
+// Called by framework when the view size is changed
+// ---------------------------------------------------------
+//
+void CMainMenuContainer::SizeChanged()
+    {
+    if ( iListBox )
+		{
+		iListBox->SetRect( Rect() ); // Sets rectangle of listbox.
+		}
+    }
+
+// ---------------------------------------------------------
+// CMainMenuContainer::CountComponentControls
+//
+// Returns number of controls indside this container.
+// ---------------------------------------------------------
+//
+TInt CMainMenuContainer::CountComponentControls() const
+    {
+    return 1;
+    }
+
+// ---------------------------------------------------------
+// CMainMenuContainer::ComponentControl
+// 
+// Gets the specified component of a compound control.
+// ---------------------------------------------------------
+//
+CCoeControl* CMainMenuContainer::ComponentControl(TInt aIndex) const
+    {
+    switch ( aIndex )
+        {
+		case 0: 
+			return iListBox;
+        default:
+            return NULL;
+        }
+    }
+
+// ---------------------------------------------------------
+// CMainMenuContainer::Draw
+// 
+// Draw a control, called by window server.
+// ---------------------------------------------------------
+//
+void CMainMenuContainer::Draw(const TRect& /*aRect*/) const
+    {
+    }
+
+// ---------------------------------------------------------
+// CMainMenuContainer::HandleListBoxEventL
+//
+// Handles list box events.
+// ---------------------------------------------------------
+//
+void CMainMenuContainer::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType)
+	{
+
+	if ( ( aEventType == EEventEnterKeyPressed ) || ( aEventType == EEventItemDoubleClicked ) )
+		{	
+        HandleSelectedListItemL( aListBox->CurrentItemIndex() );
+		}
+
+	}
+	
+// ----------------------------------------------------------------------------
+// CMainMenuContainer::HandleSelectedListItemL
+//
+// Method HandleSelectedListItemL handles valix index.
+// ----------------------------------------------------------------------------
+//
+void CMainMenuContainer::HandleSelectedListItemL( TInt aIndex )
+	{	 
+		TInt selection = aIndex;
+        
+        // Change active view.
+	    switch ( selection )
+        {
+		    case 0:
+				( (CEikAppUi*)iCoeEnv->AppUi() )->HandleCommandL(EAppUIGoToTestCaseMenu);
+				break;
+			case 1:
+				( (CEikAppUi*)iCoeEnv->AppUi() )->HandleCommandL(EAppUIGoToModulesMenu);
+				break;
+			case 2: 
+				( (CEikAppUi*)iCoeEnv->AppUi() )->HandleCommandL(EAppUIGoToTestSetsMenu);
+				break;
+	        default:
+				break;
+		}
+	}
+
+// ---------------------------------------------------------
+// CMainMenuContainer::OfferKeyEventL
+// 
+// Handles key events.
+// ---------------------------------------------------------
+//
+TKeyResponse CMainMenuContainer::OfferKeyEventL(
+	const TKeyEvent& aKeyEvent, TEventCode aType)
+{
+	if (aType != EEventKey)
+	{
+		return EKeyWasNotConsumed;
+	}
+
+	// Offers key events to list box
+	if (iListBox)
+	{
+		return iListBox->OfferKeyEventL( aKeyEvent, aType );
+	}
+	else
+	{
+		return EKeyWasNotConsumed;
+	}
+}
+
+// ----------------------------------------------------------------------------
+// CMainMenuContainer:::GetActiveLine
+//
+// Get currently selected items index.
+// ----------------------------------------------------------------------------
+//
+TInt CMainMenuContainer::GetActiveLine()
+	{
+	return iListBox->CurrentItemIndex();
+	}
+
+// ----------------------------------------------------------------------------
+// CMainMenuContainer:::SaveActiveLine
+//
+// Makes the iListBox member save its focus position
+// ----------------------------------------------------------------------------
+//
+void CMainMenuContainer::SaveActiveLine()
+	{
+	((CMenuListBox*)iListBox)->SaveFocusPosition();
+	}
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/MainMenuView.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,163 @@
+/*
+* 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: This file contains CMainMenuView class definition.
+*
+*/
+
+// INCLUDE FILES
+#include  <aknviewappui.h>
+#include  <barsread.h>	//TResourceReader
+#include  <Stifui.rsg>
+#include  "MainMenuView.h"
+#include  "MainMenuContainer.h" 
+#include  "Stifui.hrh"
+#include  "AppUIAppUi.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CMainMenuView::ConstructL
+// 
+// Symbian OS two-phased constructor
+// ---------------------------------------------------------
+//
+void CMainMenuView::ConstructL()
+    {
+    BaseConstructL( R_APPUI_MAINMENUVIEW );
+    }
+
+// ---------------------------------------------------------
+// CMainMenuView::~CMainMenuView
+// 
+// Destructor
+// ---------------------------------------------------------
+//
+CMainMenuView::~CMainMenuView()
+    {
+    if ( iContainer )
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        iContainer = NULL;
+        }
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;
+    }
+
+// ---------------------------------------------------------
+// TUid CMainMenuView::Id
+// 
+// Returns view´s id.
+// ---------------------------------------------------------
+//
+TUid CMainMenuView::Id() const
+    {
+    return TUid::Uid(EMainMenuViewId); //KMainMenuViewId;
+    }
+
+// ---------------------------------------------------------
+// CMainMenuView::HandleCommandL
+// 
+// Handles a command.
+// ---------------------------------------------------------
+//
+void CMainMenuView::HandleCommandL(TInt aCommand)
+    {   
+    switch ( aCommand )
+        {
+        case EAknSoftkeyBack:
+            {
+            AppUi()->HandleCommandL(EEikCmdExit);
+            break;
+            }
+		case EAknCmdOpen:
+			{
+			TInt a = iContainer->GetActiveLine();
+			iContainer->HandleSelectedListItemL( a );
+			}
+			break;              
+        default:
+            {
+            AppUi()->HandleCommandL( aCommand );
+            break;
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CMainMenuView::HandleClientRectChange
+//
+// Handles client rect changes.
+// ---------------------------------------------------------
+//
+void CMainMenuView::HandleClientRectChange()
+    {
+    if ( iContainer )
+        {
+        iContainer->SetRect( ClientRect() );
+        }
+    }
+
+// ---------------------------------------------------------
+// CMainMenuView::DoActivateL
+//
+// Initializes view when activated.
+// ---------------------------------------------------------
+//
+void CMainMenuView::DoActivateL(
+   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
+   const TDesC8& /*aCustomMessage*/)
+    {
+    if (!iContainer)
+        {
+        iContainer = new (ELeave) CMainMenuContainer;
+        iContainer->SetMopParent(this);
+        iContainer->ConstructL( ClientRect() );
+        AppUi()->AddToStackL( *this, iContainer );
+        } 
+
+    CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane();
+    CAknNavigationControlContainer* np= (CAknNavigationControlContainer *)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
+		
+	TResourceReader reader;
+	iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_MAIN);
+	iNaviDecorator = np->CreateNavigationLabelL( reader );
+	CleanupStack::PopAndDestroy(); // resource reader
+	
+	np->PushL(*iNaviDecorator);
+   }
+
+// ---------------------------------------------------------
+// CAppUIView::DoDeactivate
+// 
+// Deactivates view.
+// ---------------------------------------------------------
+//
+void CMainMenuView::DoDeactivate()
+    {
+    if ( iContainer )
+        {
+        iContainer->SaveActiveLine();
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        iContainer = NULL;
+        }
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;
+    }
+
+// End of File
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/MenuListBox.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,108 @@
+/*
+* 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: This file contains CMenuListBox class definition.
+*
+*/
+
+// INCLUDE FILES
+#include "MenuListBox.h"
+#include <AknView.h>
+
+// ================= MEMBER FUNCTIONS =======================
+// ---------------------------------------------------------
+// CMainMenuView::CMenuListBox
+// 
+// c++ constructor
+// ---------------------------------------------------------
+//
+CMenuListBox::CMenuListBox(TAppUIViewNumber aViewId) 
+	: CAknSingleStyleListBox(), iViewId(aViewId)
+	{
+	}
+
+// ---------------------------------------------------------
+// CMenuListBox::ConstructL
+// 
+// Symbian OS two-phased constructor
+// ---------------------------------------------------------
+//
+void CMenuListBox::ConstructL()
+	{
+	
+	}
+
+// ---------------------------------------------------------
+// CMenuListBox::~CMenuListBox
+// 
+// Destructor
+// ---------------------------------------------------------
+//
+CMenuListBox::~CMenuListBox()
+	{
+
+	}
+
+// ---------------------------------------------------------
+// CMenuListBox::NewL
+// 
+// Symbian OS public constructor
+// @param aViewId - id of view to identify position in array where focus position will be saved to
+// or retrieved from
+//
+// @return - pointer to an instance of CMenuListBOx
+// ---------------------------------------------------------
+//
+CMenuListBox* CMenuListBox::NewL(TAppUIViewNumber aViewId)
+	{
+	CMenuListBox* self = new(ELeave) CMenuListBox(aViewId);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+// ---------------------------------------------------------
+// CMenuListBox::SaveFocusPosition
+// 
+// Saves current focus position to CAppUiAppUi object
+// ---------------------------------------------------------
+//
+void CMenuListBox::SaveFocusPosition()
+	{
+	((CAppUIAppUi*)iCoeEnv->AppUi())->SaveFocusPosition(iViewId, this->CurrentItemIndex());
+	}
+
+// ---------------------------------------------------------
+// CMenuListBox::SetPreviousFocus
+// 
+// Retrieves previous focus position from CAppUiAppUi object and sets focus
+// to that position
+// ---------------------------------------------------------
+//
+void CMenuListBox::SetPreviousFocus()
+	{
+	TInt previousPosition = ((CAppUIAppUi*)iCoeEnv->AppUi())->GetFocusPosition(iViewId);
+	if(previousPosition != KErrNotFound)
+		{
+		if(previousPosition < this->Model()->NumberOfItems() && previousPosition != 0)
+			{
+			this->SetCurrentItemIndex(previousPosition);
+			}
+		if(previousPosition >= this->Model()->NumberOfItems()) 
+			{
+			this->SetCurrentItemIndex(0); // setting current item to first element if pervious position is grater then current. 
+			}
+		this->SetTopItemIndex(0);
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/ShowStartedCasesContainer.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,648 @@
+/*
+* 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: This file contains CStartedTestsListBoxModel class
+* definition.
+*
+*/
+
+// INCLUDE FILES
+
+#include <aknlists.h>  // ListBox
+#include <akniconarray.h>  // CAknIconArray
+#include <badesca.h> // CDesCArray
+#include <eikclbd.h> // CColumnListBoxData
+#include <aknnotewrappers.h>
+
+#include <Stifui.rsg>
+
+//#include "UIStoreIf.h"         
+//#include "UIStore.h"            
+//#include "UIEngine.h"           
+//#include "UIEngineContainer.h"  
+
+#include <stifinternal/UIStoreIf.h>
+#include <stifinternal/UIStore.h>
+#include <stifinternal/UIEngine.h>
+#include <stifinternal/UIEngineContainer.h>
+
+#include "ShowStartedCasesContainer.h"
+
+#include "Stifui.hrh"
+#include "AppUIAppUi.h"
+#include "MenuListBox.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+// ---------------------------------------------------------
+// CStartedTestsListBoxModel::NewL
+// 
+// Symbian OS two phased constructor
+// ---------------------------------------------------------
+//
+CStartedTestsListBoxModel* CStartedTestsListBoxModel::NewL 
+            ( RRefArray<CStartedTestCase>* aTestCasesInView )
+    {
+    CStartedTestsListBoxModel* self = new ( ELeave ) CStartedTestsListBoxModel();
+    CleanupStack::PushL( self );
+    self->iBuffer = HBufC::NewL( 130 );
+    self->iTestCasesInView = aTestCasesInView;
+    CleanupStack::Pop();
+    return self;
+
+    }
+
+// ---------------------------------------------------------
+// CStartedTestsListBoxModel::ConstructL
+// 
+// Symbian OS two phased constructor
+// Completes the construction of the object.
+// ---------------------------------------------------------
+//
+
+void CStartedTestsListBoxModel::ConstructL()
+    {
+    }
+
+// ---------------------------------------------------------
+// CStartedTestsListBoxModel::~CStartedTestsListBoxModel
+// 
+// Destructor
+// ---------------------------------------------------------
+//
+
+CStartedTestsListBoxModel::~CStartedTestsListBoxModel()
+    {
+    }
+
+// ---------------------------------------------------------
+// CStartedTestsListBoxModel::MdcaCount
+// 
+// Returns the number of descriptor elements in the array.
+// ---------------------------------------------------------
+//
+
+TInt CStartedTestsListBoxModel::MdcaCount() const
+    {
+    return iTestCasesInView->Count();
+
+    }
+
+// ---------------------------------------------------------
+// CStartedTestsListBoxModel::MdcaPoint
+// 
+// Indexes into a descriptor array.
+// ---------------------------------------------------------
+//
+TPtrC CStartedTestsListBoxModel::MdcaPoint(TInt aIndex) const
+    {
+    TPtr buffer( iBuffer->Des() );
+    buffer.Zero();
+    switch ( (*iTestCasesInView)[aIndex].Status() )
+        {
+        case CUIStoreIf::EStatusRunning:
+            {
+            if( (*iTestCasesInView)[aIndex].UIEngineContainer().State() ==
+                CUIEngineContainer::ERunning )
+                {
+                buffer.Append(_L("Running\t"));
+                }
+            else
+                {
+                buffer.Append(_L("Paused\t"));
+                }
+            break;
+            }
+        case CUIStoreIf::EStatusPassed:
+            {
+            buffer.Append(_L("Passed\t"));
+            break;
+            }
+        case CUIStoreIf::EStatusFailed:
+            {
+            buffer.Append(_L("Failed\t"));
+            break;
+            }
+        /*case ECrashed:
+            buffer.Append(_L("Crashed\t"));
+            break;*/
+        case CUIStoreIf::EStatusAborted:
+        	{
+            buffer.Append(_L("Aborted\t"));
+            break;
+        	}
+        default:
+        	{
+            if((*iTestCasesInView)[aIndex].Status() & CUIStoreIf::EStatusPassed)
+            	{
+            	buffer.Append(_L("Passed\t"));
+            	}
+        	else if((*iTestCasesInView)[aIndex].Status() & CUIStoreIf::EStatusFailed)
+            	{
+            	buffer.Append(_L("Failed\t"));
+            	}
+        	else if((*iTestCasesInView)[aIndex].Status() & CUIStoreIf::EStatusAborted)
+            	{
+            	buffer.Append(_L("Aborted\t"));
+            	}
+        	else if((*iTestCasesInView)[aIndex].Status() & CUIStoreIf::EStatusCrashed)
+	        	{
+	            buffer.Append(_L("Crashed\t"));
+	        	}
+        	else
+        		{
+        		buffer.Append(_L("\t"));
+        		}
+        	break;
+        	}
+        }
+        
+    buffer.Append((*iTestCasesInView)[aIndex].TestInfo().TestCaseTitle() );
+    
+    return *iBuffer;
+    
+    }
+
+
+
+// ---------------------------------------------------------
+// CShowStartedCasesContainer::ConstructL
+// 
+// Symbian OS two phased constructor
+// ---------------------------------------------------------
+//
+void CShowStartedCasesContainer::ConstructL(const TRect& aRect, MEikListBoxObserver* aListBoxObserver)
+    {
+    CreateWindowL();
+
+    iUIStore = ( (CAppUIAppUi*)iCoeEnv->AppUi() )->UIStoreHandler();
+
+    const TInt KSelectedMode = ((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode;
+    
+    if(KSelectedMode == EShowOngoingCases || KSelectedMode == EShowPausedCases
+    		|| KSelectedMode == EShowCrashedAbortedCases  || KSelectedMode == EShowAllStartedCases)
+    	{
+    	iListBox = new (ELeave) CAknSingleHeadingStyleListBox();
+    	}
+    else
+    	{
+    	iListBox = CMenuListBox::NewL(EShowStartedCasesViewId); //CAknSingleStyleListBox();
+    	}
+	iListBox->SetContainerWindowL( *this );
+	iListBox->SetListBoxObserver( aListBoxObserver );
+    iListBox->ConstructL(this, EAknListBoxSelectionList);
+
+    //Create Scroller control for ListBox and set its visibility
+    iListBox->CreateScrollBarFrameL(ETrue);
+    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
+	iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
+
+    if ( iUIStore )
+        {
+        ConstructListBoxModelL();
+        iListBoxModel = CStartedTestsListBoxModel::NewL( &iStartedTestsPtrs );
+        iListBox->Model()->SetItemTextArray(iListBoxModel);
+        }
+    else
+        {
+        //User::Leave( syy?? )
+        }
+	iListBox->ActivateL();
+	if(KSelectedMode != EShowOngoingCases && KSelectedMode != EShowPausedCases
+	    	&& KSelectedMode != EShowCrashedAbortedCases  && KSelectedMode != EShowAllStartedCases)
+		{
+		((CMenuListBox*)iListBox)->SetPreviousFocus();
+		}
+
+    SetRect(aRect);
+    ActivateL();
+
+    }
+
+// ---------------------------------------------------------
+// CShowStartedCasesContainer::ConstructListBoxModelL
+// 
+// Constructs list box model without any filtering.
+// ---------------------------------------------------------
+//
+void CShowStartedCasesContainer::ConstructListBoxModelL()
+    {
+    TInt ret( 0 );
+    RRefArray<CStartedTestCase> startedTestCases;
+    ret = iUIStore->StartedTestCases( startedTestCases );
+    if( KErrNone != ret )
+        {
+        startedTestCases.Reset();
+        startedTestCases.Close();
+        User::Leave( ret );
+        }
+    CleanupClosePushL( startedTestCases ); // Closes the handle
+
+    const TInt KStartedCaseCount = startedTestCases.Count();
+
+    iStartedTestsPtrs.Reset(); // Remove all pointers (does not delete objects)
+
+    const TInt KSelectedMode = ((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode;
+
+    // Loop through all started cases
+    for( TInt i=0; i < KStartedCaseCount; i++ )
+        {
+        switch ( KSelectedMode )
+            {
+            case EShowAllStartedCases:
+                {
+                iStartedTestsPtrs.Append( startedTestCases[i] );
+                break;
+                }
+            case EShowOngoingCases:
+                {
+                // Note: PAUSE IS ALSO RUNNIN STATUS
+                if ( startedTestCases[i].Status() & CUIStoreIf::EStatusRunning )
+                    {
+                    iStartedTestsPtrs.Append(startedTestCases[i]);
+                    }
+                break;
+                }
+            case EShowPassedCases:
+                {
+                if ( startedTestCases[i].Status() & CUIStoreIf::EStatusPassed )
+                    {
+                    iStartedTestsPtrs.Append( startedTestCases[i] );
+                    }
+                break;
+                }
+            case EShowPausedCases:
+                {
+                if ( startedTestCases[i].Status() & CUIStoreIf::EStatusRunning )
+                    {
+                    if( startedTestCases[i].UIEngineContainer().State() == CUIEngineContainer::EPaused )
+                        {
+                        iStartedTestsPtrs.Append( startedTestCases[i] );
+                        }
+                    }
+                break;
+                }
+            case EShowFailedCases:
+                {
+                if ( startedTestCases[i].Status() & CUIStoreIf::EStatusFailed )
+                    {
+                    iStartedTestsPtrs.Append( startedTestCases[i] );
+                    }
+                break;
+                }
+            case EShowCrashedAbortedCases:
+                {
+                if ( startedTestCases[i].Status() & CUIStoreIf::EStatusAborted 
+                		|| startedTestCases[i].Status() & CUIStoreIf::EStatusCrashed)
+                    {
+                    iStartedTestsPtrs.Append( startedTestCases[i] );
+                    }
+                break;
+                }
+            }
+        }
+    startedTestCases.Reset();
+    startedTestCases.Close();
+
+    CleanupStack::PopAndDestroy(); // startedTestCases
+
+    }
+
+// ---------------------------------------------------------
+// CShowStartedCasesContainer::~CShowStartedCasesContainer
+// 
+// Destructor
+// ---------------------------------------------------------
+//
+CShowStartedCasesContainer::~CShowStartedCasesContainer()
+    {
+    iStartedTestsPtrs.Close(); // does not delete objects whose pointers are contained in the array
+    }
+
+// ---------------------------------------------------------
+// CShowStartedCasesContainer::SizeChanged
+// 
+// Called by framework when the view size is changed
+// ---------------------------------------------------------
+//
+void CShowStartedCasesContainer::SizeChanged()
+    {
+    if ( iListBox )
+		{
+		iListBox->SetRect( Rect() ); // Sets rectangle of listbox.
+		}
+    }
+
+// ---------------------------------------------------------
+// CShowStartedCasesContainer::CountComponentControls
+//
+// Gets a count of the component controls of this list box control.
+// ---------------------------------------------------------
+//
+TInt CShowStartedCasesContainer::CountComponentControls() const
+    {
+    return 1; // return nbr of controls inside this container
+    }
+
+// ---------------------------------------------------------
+// CShowStartedCasesContainer::ComponentControl
+//
+// Gets a pointer to the specified component control.
+// ---------------------------------------------------------
+//
+CCoeControl* CShowStartedCasesContainer::ComponentControl(TInt aIndex) const
+    {
+    switch ( aIndex )
+        {
+		case 0: 
+			return iListBox;
+        default:
+            return NULL;
+        }
+    }
+
+// ---------------------------------------------------------
+// CShowStartedCasesContainer::Draw
+// 
+// Draw a control, called by window server.
+// ---------------------------------------------------------
+//
+void CShowStartedCasesContainer::Draw(const TRect& /*aRect*/) const
+    {
+    }
+
+// ---------------------------------------------------------
+// CShowStartedCasesContainer::OfferKeyEventL
+// 
+// Handles key events.
+// ---------------------------------------------------------
+//
+TKeyResponse CShowStartedCasesContainer::OfferKeyEventL(
+	const TKeyEvent& aKeyEvent, TEventCode aType)
+    {
+	if (aType != EEventKey)
+	    {
+		return EKeyWasNotConsumed;
+	    }
+
+	if (iListBox)
+		{
+		return iListBox->OfferKeyEventL( aKeyEvent, aType );
+		}
+	else
+		{
+		return EKeyWasNotConsumed;
+		}
+		
+	}
+	
+// ---------------------------------------------------------
+// CShowStartedCasesContainer::SelectedTestCase
+// 
+// Returns reference to currently selected test case in view (listbox).
+// ---------------------------------------------------------
+//
+CStartedTestCase* CShowStartedCasesContainer::SelectedTestCase()
+    {
+    if ( iStartedTestsPtrs.Count() > 0 )
+        {
+        return &(iStartedTestsPtrs[ iListBox->CurrentItemIndex() ]);
+        }
+    else
+        {
+        return NULL;
+        }
+    }
+
+// ---------------------------------------------------------
+// CShowStartedCasesContainer::DrawListBox
+// 
+// Refresh ListBox, if aSelectedTestCase is still found from ListBox
+// it is set as selected test case.
+// ---------------------------------------------------------
+//
+void CShowStartedCasesContainer::DrawListBox()
+    {
+    if ( iListBox )
+        {
+        iListBox->DrawNow();
+        }
+
+    }
+
+// ---------------------------------------------------------
+// CShowStartedCasesContainer::HandleItemAdditionL
+// 
+// Refresh ListBox after new item was added to listbox model.
+// ---------------------------------------------------------
+//
+void CShowStartedCasesContainer::HandleItemAdditionL()
+    {
+    iListBox->HandleItemAdditionL();
+
+    }
+
+
+// ---------------------------------------------------------
+// CShowStartedCasesContainer::HandleItemRemovalL
+// 
+// Refresh ListBox after item is removed from listbox model.
+// ---------------------------------------------------------
+//
+void CShowStartedCasesContainer::HandleItemRemovalL()
+    {
+    iListBox->HandleItemRemovalL();
+
+    // HandleItemRemovalL "loses selection" if current item is removed
+    // -> we have to check it and set one item as current item to make it possible for
+    // user to select one item from items left after remove
+    if ( iListBox->CurrentItemIndex() == -1 ) // No item selected
+        if ( ((CStartedTestsListBoxModel*)iListBox->Model())->MdcaCount() > 0 ) // there are items
+            SetCurrentItemIndex(0);
+
+    }
+
+// ---------------------------------------------------------
+// CShowStartedCasesContainer::TestsInViewCount
+// 
+// Returns count of test cases in view.
+// ---------------------------------------------------------
+//
+TInt CShowStartedCasesContainer::TestsInViewCount()
+    {
+    return ((CStartedTestsListBoxModel*)iListBox->Model())->MdcaCount();
+
+    }
+    
+// ---------------------------------------------------------
+// CShowStartedCasesContainer::CurrentTestCase
+// 
+// Returns pointer to currently selected test case.
+// ---------------------------------------------------------
+//
+CStartedTestCase* CShowStartedCasesContainer::CurrentTestCase()
+    {
+    return &iStartedTestsPtrs[ iListBox->CurrentItemIndex() ];
+    }
+
+// ---------------------------------------------------------
+// CShowStartedCasesContainer::SetCurrentItemIndex
+// 
+// Sets the current item.
+// ---------------------------------------------------------
+//
+void CShowStartedCasesContainer::SetCurrentItemIndex(TInt aIndex)
+    {
+    TInt itemCount = ((CStartedTestsListBoxModel*)iListBox->Model())->MdcaCount();
+    if ( aIndex < itemCount )
+        {
+        iListBox->SetCurrentItemIndex(aIndex);
+        }
+    else
+        {
+        iListBox->SetCurrentItemIndex(itemCount);
+        }
+
+    }
+
+// ---------------------------------------------------------
+// CShowStartedCasesContainer::ResetListBox
+// 
+// Resets the selection indices, top and current item indices,
+// the selection, and the horizontal scroll offset of this list box.
+// This function does not redraw the list box.
+// ---------------------------------------------------------
+//
+void CShowStartedCasesContainer::ResetListBox()
+    {
+    iListBox->Reset();
+
+    }
+
+// ---------------------------------------------------------
+// CShowStartedCasesContainer::RemoveSelectedExecutionsL
+// 
+// Removes items from list box.
+// ---------------------------------------------------------
+//
+void CShowStartedCasesContainer::RemoveSelectedExecutionsL()
+    {
+    TInt indexOfRemovedExecution = 0;
+    iStartedTestsPtrs.Remove(indexOfRemovedExecution);
+    HandleItemRemovalL();
+
+    }
+
+// ---------------------------------------------------------
+// CShowStartedCasesContainer::RemoveAllExecutionsInViewL
+// 
+// Removes all started test cases from list box.
+// ---------------------------------------------------------
+//
+void CShowStartedCasesContainer::RemoveAllExecutionsInViewL()
+    {
+    TInt exutionsInViewCount = iStartedTestsPtrs.Count();
+    iStartedTestsPtrs.Reset(); //Empties the array, does not delete the objects whose pointers are contained in the array
+    HandleItemRemovalL();
+
+    }
+
+// ----------------------------------------------------------------------------
+// CContainer::FilterCasesByModuleL
+// 
+// Show only testcases which are defined is specified module.
+// ----------------------------------------------------------------------------
+//
+void CShowStartedCasesContainer::FilterCasesByModuleL(TName aModuleName)
+    {
+    //First the list box model have to be reconstructed to make sure that all
+    //possible earlier filtering does not affect
+    ConstructListBoxModelL();
+    
+    TInt i;
+    const TInt KCurrentShowedCaseCount = iStartedTestsPtrs.Count();
+
+    for ( i = KCurrentShowedCaseCount-1; i >= 0; i-- )
+        {
+        RRefArray<CStartedTestCase> startedTestCases;
+        TInt ret = iUIStore->StartedTestCases( startedTestCases );
+        if( ret != KErrNone )
+            {
+            startedTestCases.Reset();
+            startedTestCases.Close();
+            }
+        if ( startedTestCases[i].TestInfo().ModuleName() != aModuleName )
+            {
+            iStartedTestsPtrs.Remove(i); // delete pointer to CStartedTestCase
+            }
+        startedTestCases.Reset();
+        startedTestCases.Close();
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CContainer::FilterCasesByTCFileNameL
+// 
+// Show only testcases which are defined is specified test case file.
+// ----------------------------------------------------------------------------
+//
+void CShowStartedCasesContainer::FilterCasesByTCFileNameL(TFileName aTestCaseFileName)
+    {
+
+    //First the list box model have to be reconstructed to make sure that all
+    //possible earlier filtering does not affect
+    ConstructListBoxModelL();
+
+    const TInt KCurrentShowedCaseCount = iStartedTestsPtrs.Count();
+
+    for ( TInt i = KCurrentShowedCaseCount-1; i >= 0; i-- )
+        {
+        RRefArray<CStartedTestCase> startedTestCases;
+        TInt ret = iUIStore->StartedTestCases( startedTestCases );
+        if( ret != KErrNone )
+            {
+            startedTestCases.Reset();
+            startedTestCases.Close();
+            }
+        if ( startedTestCases[i].TestInfo().TestCaseFile() != aTestCaseFileName )
+            {
+            iStartedTestsPtrs.Remove(i); // delete pointer to CStartedTestCase
+            }
+        startedTestCases.Reset();
+        startedTestCases.Close();
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CContainer::NoFilteringL
+// 
+// Remove possible filtering of test cases -> show all test cases.
+// ----------------------------------------------------------------------------
+//
+void CShowStartedCasesContainer::NoFilteringL()
+    {
+    ConstructListBoxModelL();
+    }
+
+// ----------------------------------------------------------------------------
+// CShowStartedCasesContainer:::SaveActiveLine
+//
+// Makes the iListBox member save its focus position
+// ----------------------------------------------------------------------------
+//
+void CShowStartedCasesContainer::SaveActiveLine()
+	{
+	((CMenuListBox*)iListBox)->SaveFocusPosition();
+	}
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/ShowStartedCasesView.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,668 @@
+/*
+* 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: This file contains CShowStartedCasesView class
+* definition.
+*
+*/
+
+// INCLUDE FILES
+#include  <eikmenub.h>
+#include  <aknviewappui.h>
+#include  <barsread.h>	//TResourceReader
+#include  <Stifui.rsg>
+
+//#include  "UIEngineContainer.h"  
+#include <stifinternal/UIEngineContainer.h>
+
+#include  "Stifui.hrh" 
+#include  "ShowStartedCasesView.h"
+#include  "ShowStartedCasesContainer.h"
+#include  "AppUIAppUi.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ----------------------------------------------------------------------------
+// CShowStartedCasesView::ConstructL
+// 
+// Symbian OS two-phased constructor
+// ----------------------------------------------------------------------------
+//
+void CShowStartedCasesView::ConstructL()
+    {
+    CView::ConstructL();
+    BaseConstructL( R_APPUI_SHOWSTARTEDCASESVIEW );
+    iFilterModule.Zero();
+    iFilterTestCaseFile.Zero();
+    iSelectedTestCase=0;
+    iNaviDecorator = NULL;
+    }
+
+// ----------------------------------------------------------------------------
+// CShowStartedCasesView::~CShowStartedCasesView()
+// 
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CShowStartedCasesView::~CShowStartedCasesView()
+    {
+    if ( iContainer )
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        }
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;
+    }
+
+// ----------------------------------------------------------------------------
+// TUid CShowStartedCasesView::Id()
+// 
+// Returns view´s id.
+// ----------------------------------------------------------------------------
+//
+TUid CShowStartedCasesView::Id() const
+    {
+    return TUid::Uid(EShowStartedCasesViewId);
+    }
+
+// ----------------------------------------------------------------------------
+// CShowStartedCasesView::HandleCommandL(TInt aCommand)
+// 
+// Handles a command.
+// ----------------------------------------------------------------------------
+//
+void CShowStartedCasesView::HandleCommandL(TInt aCommand)
+    {   
+    if ( aCommand >= ECmdFilterByModule && aCommand < ECmdFilterByTestCaseFile )
+        {
+        TInt moduleNumber = aCommand - ECmdFilterByModule;
+        RRefArray<TDesC> testModules;
+        TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->Modules( testModules );
+        if( KErrNone != ret )
+            {
+            testModules.Reset();
+            testModules.Close();
+            User::Leave( ret );
+            }
+        iFilterModule = testModules[moduleNumber];
+            
+        iFilterTestCaseFile.Zero();
+        
+        iContainer->FilterCasesByModuleL(iFilterModule);
+        //iContainer->ResetListBox();
+        //iContainer->DrawListBox();
+        
+        testModules.Reset();
+        testModules.Close();
+
+        return;
+        }
+
+    else if ( aCommand >= ECmdFilterByTestCaseFile && aCommand < ECmdNOFiltering )
+        {
+        TInt testCaseFileNumber = aCommand - ECmdFilterByTestCaseFile;
+        RRefArray<TDesC> testCaseFiles;
+        TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->TestCaseFiles( testCaseFiles );
+        if( KErrNone != ret )
+            {
+            testCaseFiles.Reset();
+            testCaseFiles.Close();
+            User::Leave( ret );
+            }
+
+        iFilterTestCaseFile = testCaseFiles[ testCaseFileNumber ];
+        iFilterModule.Zero();
+        //iContainer->FilterCasesByTCFileNameL(testCaseFileName);
+        iContainer->FilterCasesByTCFileNameL(iFilterTestCaseFile);
+        iContainer->ResetListBox();
+        iContainer->DrawListBox();
+
+        testCaseFiles.Reset();
+        testCaseFiles.Close();
+
+        return;
+        }
+
+    else if ( aCommand == ECmdNOFiltering )
+        {
+        iFilterModule.Zero();
+        iFilterTestCaseFile.Zero();
+        iContainer->NoFilteringL();
+        iContainer->ResetListBox();
+        iContainer->DrawListBox();
+        return;
+        }
+
+    // Handle rest possible commands
+    switch ( aCommand )
+        {
+        case ECmdViewOutput:
+            {
+            ViewTestCaseOutputL();
+            break;
+            }
+        case ECmdRemoveExecution:
+            {
+            iContainer->RemoveSelectedExecutionsL();
+            break;
+            }
+        case ECmdRemoveAllExecutions:
+            {
+            iContainer->RemoveAllExecutionsInViewL();
+            break;
+            }
+        case ECmdPauseTestCase:
+            {
+            TInt index = iContainer->CurrentItemIndex();
+            RRefArray<CStartedTestCase> runningTestCases;
+            TShowStartedCasesMode currentMode = (TShowStartedCasesMode)((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode;
+			TInt ret = KErrNone;
+			if(currentMode == EShowAllStartedCases)
+				ret = iUIStore->StartedTestCases(runningTestCases, CUIStoreIf::EStatusAll);
+			else if(currentMode == EShowOngoingCases)
+				ret = iUIStore->StartedTestCases(runningTestCases, CUIStoreIf::EStatusRunning);
+ 			if( KErrNone != ret )
+ 			    {
+ 			    User::Leave( ret );
+ 			    }
+ 			runningTestCases[index].UIEngineContainer().PauseTest();
+ 			runningTestCases.Close();
+            break;
+            }
+        case ECmdResumeTestCase:
+            {
+            TInt index = iContainer->CurrentItemIndex();
+            RRefArray<CStartedTestCase> runningTestCases;
+            TShowStartedCasesMode currentMode = (TShowStartedCasesMode)((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode;
+			TInt ret = KErrNone;
+			if(currentMode == EShowAllStartedCases)
+				ret = iUIStore->StartedTestCases(runningTestCases, CUIStoreIf::EStatusAll);
+			else if(currentMode == EShowOngoingCases || currentMode == EShowPausedCases)
+				ret = iUIStore->StartedTestCases(runningTestCases, CUIStoreIf::EStatusRunning);
+ 			if( KErrNone != ret )
+ 			    {
+ 			    User::Leave( ret );
+ 			    }
+ 			TInt testCaseToControl = 0;
+ 			if(currentMode == EShowAllStartedCases || currentMode == EShowOngoingCases)
+				{
+				testCaseToControl = index;
+				}
+			else if(currentMode == EShowPausedCases)
+				{
+				TInt pausedTestCasesCounter = 0;
+				for(int i = 0; i < runningTestCases.Count(); i++)
+					{
+					if(runningTestCases[i].UIEngineContainer().State() == CUIEngineContainer::EPaused)
+						{
+						if(pausedTestCasesCounter == index)
+							{
+							testCaseToControl = i;
+							break;
+							}
+						pausedTestCasesCounter++;
+						}
+					}
+				}
+ 			
+ 			runningTestCases[testCaseToControl].UIEngineContainer().ResumeTest();
+ 			runningTestCases.Close();
+            break;
+            }
+        case ECmdAbortTestCase:
+            { 
+			TInt index = iContainer->CurrentItemIndex();
+			RRefArray<CStartedTestCase> runningTestCases;
+			TShowStartedCasesMode currentMode = (TShowStartedCasesMode)((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode;
+			TInt ret = KErrNone;
+			if(currentMode == EShowAllStartedCases)
+				ret = iUIStore->StartedTestCases(runningTestCases, CUIStoreIf::EStatusAll);
+			else if(currentMode == EShowOngoingCases || currentMode == EShowPausedCases)
+				ret = iUIStore->StartedTestCases(runningTestCases, CUIStoreIf::EStatusRunning);
+				
+			if( KErrNone != ret )
+			    {
+			    User::Leave( ret );
+			    }
+			TInt testCaseToControl = 0;
+			
+			if(currentMode == EShowAllStartedCases || currentMode == EShowOngoingCases)
+				{
+				testCaseToControl = index;
+				}
+			else if(currentMode == EShowPausedCases)
+				{
+				TInt pausedTestCasesCounter = 0;
+				for(int i = 0; i < runningTestCases.Count(); i++)
+					{
+					if(runningTestCases[i].UIEngineContainer().State() == CUIEngineContainer::EPaused)
+						{
+						if(pausedTestCasesCounter == index)
+							{
+							testCaseToControl = i;
+							break;
+							}
+						pausedTestCasesCounter++;
+						}
+					}
+				}
+			
+			runningTestCases[testCaseToControl].UIEngineContainer().CancelTest();
+			runningTestCases.Close();
+            break;
+            }
+        case EAknSoftkeyOk:
+            {
+            iEikonEnv->InfoMsg( _L("TestCase Menu ok") );
+            break;
+            }
+        case EAknSoftkeyBack:
+            {
+            // Remove possible filterings so that they does not affect when coming again to this view
+            iFilterModule.Zero();
+            iFilterTestCaseFile.Zero();
+            iSelectedTestCase=0; //Reset selected test case information
+            AppUi()->HandleCommandL(EAppUIGoBack);
+            break;
+            }
+        default:
+            {
+            AppUi()->HandleCommandL( aCommand );
+            break;
+            }
+        }
+
+    }
+
+// ----------------------------------------------------------------------------
+// CShowStartedCasesView::HandleListBoxEventL
+// 
+// Handles listbox events.
+// ----------------------------------------------------------------------------
+//
+void CShowStartedCasesView::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
+	{
+	if ( ( aEventType == EEventEnterKeyPressed ) || ( aEventType == EEventItemDoubleClicked ) )
+		{
+        ViewTestCaseOutputL();
+        }
+
+    }
+
+// ----------------------------------------------------------------------------
+// CShowStartedCasesView::ViewTestCaseOutputL
+// 
+// Shows outputs of test case which is selected in Container.
+// ----------------------------------------------------------------------------
+//
+void CShowStartedCasesView::ViewTestCaseOutputL()
+	{
+    iSelectedTestCase = iContainer->CurrentItemIndex();
+    
+    // Sets index  of selected test case to AppUi
+    //( ( CAppUIAppUi* )AppUi() )->SetTestCaseIndex( iSelectedTestCase );
+    ( ( CAppUIAppUi* )AppUi() )->SetStartedTestCase( iContainer->CurrentTestCase() );
+    
+    AppUi()->HandleCommandL(ECmdViewOutput);
+    }
+
+
+// ----------------------------------------------------------------------------
+// CShowStartedCasesView::HandleClientRectChange()
+// 
+// Handles client rect changes.
+// ----------------------------------------------------------------------------
+//
+void CShowStartedCasesView::HandleClientRectChange()
+    {
+    if ( iContainer )
+        {
+        iContainer->SetRect( ClientRect() );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CShowStartedCasesView::DoActivateL
+// 
+// Initializes view when activated.
+// ----------------------------------------------------------------------------
+//
+void CShowStartedCasesView::DoActivateL(
+   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
+   const TDesC8& /*aCustomMessage*/)
+    {
+    if (!iContainer)
+        {
+        iContainer = new (ELeave) CShowStartedCasesContainer;
+        iContainer->SetMopParent(this);
+        iContainer->ConstructL( ClientRect(), this );
+        AppUi()->AddToStackL( *this, iContainer );
+        } 
+
+    // Check if filtering by module or by test case file is selected
+    if ( iFilterModule.Length() )
+        {
+        iContainer->FilterCasesByModuleL(iFilterModule);
+        }
+    else if ( iFilterTestCaseFile.Length() )
+        {
+        iContainer->FilterCasesByTCFileNameL(iFilterTestCaseFile);
+        }
+    if ( iSelectedTestCase )
+        iContainer->SetCurrentItemIndex(iSelectedTestCase);
+    
+    RefreshNaviTitleL();
+    
+    iContainer->DrawListBox();
+   }
+
+
+// ----------------------------------------------------------------------------
+// CShowStartedCasesView::RefreshNaviTitle
+// 
+// Refreshes view name shown in the navi pane.
+// ----------------------------------------------------------------------------
+//
+void CShowStartedCasesView::RefreshNaviTitleL()
+    {
+    CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane();
+	CAknNavigationControlContainer* np= (CAknNavigationControlContainer *)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
+	TResourceReader reader;
+
+    switch ( ((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode )
+        {
+        case EShowAllStartedCases:
+            iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTED_ALL);
+            break;
+        case EShowOngoingCases:
+            iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTED_ONGOING);
+            break;
+        case EShowPausedCases:
+            iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTED_PAUSED);
+            break;
+        case EShowPassedCases:
+            iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTED_PASSED);
+            break;
+        case EShowFailedCases:
+            iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTED_FAILED);
+            break;
+        case EShowCrashedAbortedCases:
+            iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTED_CRASHED_ABORTED);
+            break;
+        default:
+            iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_TESTSET);
+            break;
+        }
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;        
+    iNaviDecorator = np->CreateNavigationLabelL( reader );
+	CleanupStack::PopAndDestroy(); // resource reader
+	np->PushL(*iNaviDecorator);
+    }
+    
+    
+// ----------------------------------------------------------------------------
+// CShowStartedCasesView::DoDeactivate
+// 
+// Deactivates view.
+// ----------------------------------------------------------------------------
+//
+void CShowStartedCasesView::DoDeactivate()
+    {
+    if ( iContainer )
+        {
+        TInt mode = ((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode;
+        if(mode != EShowOngoingCases && mode != EShowPausedCases
+		    	&& mode != EShowCrashedAbortedCases  && mode != EShowAllStartedCases)
+        	{
+        	iContainer->SaveActiveLine();
+        	}
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        iContainer = NULL;        
+        }
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;
+
+    }
+
+
+// ----------------------------------------------------------------------------
+// CShowStartedCasesView::DynInitMenuPaneL
+// 
+// Initializes menu pane.
+// ----------------------------------------------------------------------------
+//
+void CShowStartedCasesView::DynInitMenuPaneL(
+    TInt aResourceId, CEikMenuPane* aMenuPane)
+    {
+    // options menu
+    if ( R_APPUI_SHOWSTARTEDCASESVIEW_MENU == aResourceId )
+        {
+        CStartedTestCase* startedTestCase = iContainer->SelectedTestCase();
+        if ( NULL != startedTestCase )
+            {
+            aMenuPane->SetItemDimmed( ECmdFilterMenu, EFalse );
+            switch ( startedTestCase->Status() )
+                {
+                // test case running
+                case CUIStoreIf::EStatusRunning:
+                    {
+                    switch ( startedTestCase->UIEngineContainer().State() )
+                        {
+                        case CUIEngineContainer::ERunning:
+                        case CUIEngineContainer::EPaused:
+                            {
+                            aMenuPane->SetItemDimmed( ECmdShowSetMenu, EFalse );
+                            break;
+                            }
+                        //case CUIEngineContainer::ENotStarted:
+                        //case CUIEngineContainer::EExecuted:
+                        //case CUIEngineContainer::EFinished:
+                        default:
+                            {
+                            aMenuPane->SetItemDimmed( ECmdShowSetMenu, ETrue );
+                            }
+                        }
+                    break;
+                    }
+                        
+                // test case not running
+                //case CUIStoreIf::EStatusPassed:
+                //case CUIStoreIf::EStatusFailed:
+                //case CUIStoreIf::EStatusAborted:
+                //case CUIStoreIf::EStatusExecuted
+                default:
+                    {
+                    aMenuPane->SetItemDimmed( ECmdShowSetMenu, ETrue );
+                    }
+                }
+            }
+        else
+            {
+            //aMenuPane->SetItemDimmed( ECmdFilterMenu, ETrue );
+            aMenuPane->SetItemDimmed( ECmdViewOutput, ETrue );
+            aMenuPane->SetItemDimmed( ECmdShowSetMenu, ETrue );
+            }
+        }
+
+    // test case control menu
+    if ( R_TESTCASE_CONTROL_SUBMENU == aResourceId )
+        {
+        CStartedTestCase* startedTestCase = iContainer->SelectedTestCase();
+        
+        if ( NULL != startedTestCase )
+            {
+            if ( startedTestCase->Status() == CUIStoreIf::EStatusRunning )
+                {
+                switch ( startedTestCase->UIEngineContainer().State() )
+                    {
+                    case CUIEngineContainer::ERunning:
+                        {
+                        aMenuPane->SetItemDimmed( ECmdResumeTestCase, ETrue );
+                        aMenuPane->SetItemDimmed( ECmdPauseTestCase, EFalse );
+                        aMenuPane->SetItemDimmed( ECmdAbortTestCase, EFalse );
+                        break;
+                        }
+                    case CUIEngineContainer::EPaused:
+                        {
+                        aMenuPane->SetItemDimmed( ECmdResumeTestCase, EFalse );
+                        aMenuPane->SetItemDimmed( ECmdPauseTestCase, ETrue );
+                        aMenuPane->SetItemDimmed( ECmdAbortTestCase, EFalse );
+                        break;
+                        }
+                    //case CUIEngineContainer::ENotStarted:
+                    //case CUIEngineContainer::EExecuted:
+                    //case CUIEngineContainer::EFinished:
+                    default:
+                        {
+                        aMenuPane->SetItemDimmed( ECmdResumeTestCase, ETrue );
+                        aMenuPane->SetItemDimmed( ECmdPauseTestCase, ETrue );
+                        aMenuPane->SetItemDimmed( ECmdAbortTestCase, ETrue );
+                        break;
+                        }
+                    }
+                }
+            else
+                {
+                aMenuPane->SetItemDimmed( ECmdResumeTestCase, ETrue );
+                aMenuPane->SetItemDimmed( ECmdPauseTestCase, ETrue );
+                aMenuPane->SetItemDimmed( ECmdAbortTestCase, ETrue );
+                }
+            }
+        else
+            {
+            aMenuPane->SetItemDimmed( ECmdResumeTestCase, ETrue );
+            aMenuPane->SetItemDimmed( ECmdPauseTestCase, ETrue );
+            aMenuPane->SetItemDimmed( ECmdAbortTestCase, ETrue );
+            }
+        }
+
+    // Test modules are added to filter by test module submenu if the submenu is opened
+    if (R_APPUI_FILTERBYMODULES_MENU == aResourceId)
+        {
+        RRefArray<TDesC> testModules;
+        TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->Modules( testModules );
+        if( KErrNone != ret )
+            {
+            testModules.Reset();
+            testModules.Close();
+            User::Leave( ret );
+            }        
+        TInt moduleCount = testModules.Count();
+
+        TInt i;
+        CEikMenuPaneItem::SData item;
+
+        item.iCommandId = ECmdFilterByModule;
+        item.iFlags = 0;
+        item.iCascadeId = 0;
+
+        for (i = 0; i < moduleCount; i++)
+            {
+            item.iText = testModules[i];
+            aMenuPane->AddMenuItemL(item);
+            item.iCommandId++; // command IDs 0x1000 - 0x1FFF are reserved for modules in hrh file
+            }
+        
+        testModules.Reset();
+        testModules.Close();
+
+        }
+
+    // Test case files are added to filter by test case file submenu if the submenu is opened
+    if (R_APPUI_FILTER_BY_TESTCASEFILE_MENU == aResourceId)
+        {
+        RRefArray<TDesC> testCaseFiles;
+        TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->TestCaseFiles( testCaseFiles );
+        if( KErrNone != ret )
+            {
+            testCaseFiles.Reset();
+            testCaseFiles.Close();
+            User::Leave( ret );
+            }        
+        TInt testCaseFileCount = testCaseFiles.Count();
+
+        TInt i;
+        CEikMenuPaneItem::SData item;
+
+        item.iCommandId = ECmdFilterByTestCaseFile;
+        item.iFlags = 0;
+        item.iCascadeId = 0;
+
+        for (i = 0; i < testCaseFileCount; i++)
+            {
+            item.iText = testCaseFiles[i];
+            // If there´s no test case file, don´t add item to menu.
+            if ( testCaseFiles[i].Length() > 0 )
+                {
+                aMenuPane->AddMenuItemL(item);
+                }
+            item.iCommandId++; // command IDs 0x2000 - 0x2FFF are reserved for test case files in hrh file
+            }
+        
+        testCaseFiles.Reset();
+        testCaseFiles.Close();
+
+        }
+
+    }
+
+// ----------------------------------------------------------------------------
+// CShowStartedCasesView::TestCaseStateChangedL
+// 
+// Handles status changes of test cases in view.
+// ----------------------------------------------------------------------------
+//
+void CShowStartedCasesView::TestCaseStateChangedL()
+    {
+    if ( iContainer )
+        {
+
+        //CStartedTestCase* currentlySelectedTest = iContainer->SelectedTestCase();
+
+        TInt numOfTestsInViewBeforeStateChange = iContainer->TestsInViewCount();
+
+            //((CStartedTestsListBoxModel*)iContainer->iListBox->Model())->MdcaCount();
+
+        iContainer->ConstructListBoxModelL();
+
+        // Check if filtering by module or by test case file is selected
+        if ( iFilterModule.Length() )
+            {
+            iContainer->FilterCasesByModuleL(iFilterModule);
+            }
+        else if ( iFilterTestCaseFile.Length() )
+            {
+            iContainer->FilterCasesByTCFileNameL(iFilterTestCaseFile);
+            }
+
+        TInt numOfTestsInViewAfterStateChange = iContainer->TestsInViewCount();
+            //((CStartedTestsListBoxModel*)iContainer->iListBox->Model())->MdcaCount();
+
+        if ( numOfTestsInViewAfterStateChange >= numOfTestsInViewBeforeStateChange )
+            iContainer->HandleItemAdditionL();
+        else
+            iContainer->HandleItemRemovalL();
+        
+        if(iContainer->CurrentItemIndex() < 0)
+        	{
+        	iContainer->SetCurrentItemIndex(0);
+        	}
+        iContainer->DrawListBox();
+
+        }
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/StartCasesContainer.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,227 @@
+/*
+* 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: This file contains CStartCasesContainer class 
+* definition
+*
+*/
+
+// INCLUDE FILES
+#include <aknlists.h>   // ListBox
+#include <akniconarray.h> // CAknIconArray
+#include <aknnotewrappers.h>
+
+#include <eikclbd.h> // CColumnListBoxData
+
+#include "StartCasesContainer.h"
+#include "StartCasesView.h"
+#include <Stifui.rsg>
+#include "Stifui.hrh"
+#include "AppUIAppUi.h"
+
+#include "Container.h"
+#include "MenuListBox.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+// ----------------------------------------------------------------------------
+// CStartCasesContainer::ConstructL
+// 
+// Symbian OS two phased constructor.
+// ----------------------------------------------------------------------------
+//
+void CStartCasesContainer::ConstructL(const TRect& aRect, MEikListBoxObserver* aListBoxObserver)
+    {
+    ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("StartCasesContainer: ConstructL"));
+
+	iParentView = (CStartCasesView*)aListBoxObserver;
+    CreateWindowL();
+
+    iUIStore = ( (CAppUIAppUi*)iCoeEnv->AppUi() )->UIStoreHandler();
+
+    iTestCasesInView.Reset();
+        //((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("StartCasesContainer: iTCInV Reset"));
+    
+	iListBox = CMenuListBox::NewL(EStartCaseMenuViewId);
+	iListBox->SetContainerWindowL( *this );
+	iListBox->SetListBoxObserver( aListBoxObserver /*this*/ ); // jos peritty MEikListBoxObserver:sta
+    iListBox->ConstructL(this, EAknListBoxMarkableList /*EAknListBoxSelectionList*/);
+
+    ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("StartCasesContainer: ListBox constructed"));
+
+    //Create Scroller control for ListBox and set its visibility
+    iListBox->CreateScrollBarFrameL(ETrue);
+    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
+	iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
+
+    if ( iUIStore )
+        {
+        RRefArray<CTestInfo> allCases;
+        TInt ret = iUIStore->TestCases( allCases );
+        if( KErrNone != ret )
+            {
+            ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("iUIStore->TestCases() fails"));
+            allCases.Reset();
+            allCases.Close();
+            User::Leave( ret );
+            }
+
+        const TInt KTestCaseCount = allCases.Count();
+        for (TInt i=0; i < KTestCaseCount; i++)
+            {
+            ret = iTestCasesInView.Append( &allCases[i] );
+            if( ret != KErrNone )
+            	{
+            	((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("Test case append fails with: %d"), ret );
+    			User::Leave( ret );
+	            }
+            }
+
+        iListBoxModel = CTestCaseListBoxModel::NewL(&iTestCasesInView);
+             ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("StartCasesContainer: ListBox model"));
+
+        iListBox->Model()->SetItemTextArray(iListBoxModel);
+             ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("StartCasesContainer: ListBox model set"));
+
+        allCases.Reset();
+        allCases.Close();
+        }
+    else
+        {
+        User::Leave( KErrGeneral );
+        }
+
+    // Creates graphic.
+    SetGraphicIconL( iListBox );
+       ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("StartCasesContainer: icons created"));
+
+    iListBox->ActivateL();
+    ((CMenuListBox*)iListBox)->SetPreviousFocus();
+
+    SetRect(aRect);
+    ActivateL();
+    }
+
+// ----------------------------------------------------------------------------
+// CStartCasesContainer::~CStartCasesContainer
+// 
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CStartCasesContainer::~CStartCasesContainer()
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CStartCasesContainer::SizeChanged
+// 
+// Called by framework when the view size is changed.
+// ----------------------------------------------------------------------------
+//
+void CStartCasesContainer::SizeChanged()
+    {
+    if ( iListBox )
+		{
+		iListBox->SetRect( Rect() ); // Sets rectangle of listbox.
+		}
+    }
+
+// ----------------------------------------------------------------------------
+// CStartCasesContainer::CountComponentControls
+// 
+// Gets a count of the component controls of this list box control.
+// ----------------------------------------------------------------------------
+//
+TInt CStartCasesContainer::CountComponentControls() const
+    {
+    return 1; // return nbr of controls inside this container
+    }
+
+// ----------------------------------------------------------------------------
+// CStartCasesContainer::ComponentControl
+// 
+// Gets a pointer to the specified component control.
+// ----------------------------------------------------------------------------
+//
+CCoeControl* CStartCasesContainer::ComponentControl(TInt aIndex) const
+    {
+    switch ( aIndex )
+        {
+		case 0: 
+			return iListBox;
+        default:
+            return NULL;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CStartCasesContainer::Draw
+// 
+// Draw a control, called by window server.
+// ----------------------------------------------------------------------------
+//
+void CStartCasesContainer::Draw(const TRect& /*aRect*/) const
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CStartCasesContainer::OfferKeyEventL
+// 
+// Handles key events.
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CStartCasesContainer::OfferKeyEventL(
+	const TKeyEvent& aKeyEvent, TEventCode aType )
+    {
+	if (aType != EEventKey)
+	    {
+		return EKeyWasNotConsumed;
+	    }
+
+	if (iListBox)
+		{
+		//if multiple items selected
+		if ( iListBox->SelectionIndexes()->Count() > 0 )
+			{
+			TUint mask = 0x40488;
+			
+			//if event is enter key,
+			//don´t send it to listbox
+			if ( aKeyEvent.iScanCode == 0xa7 
+				&& ( aKeyEvent.iModifiers & mask ) == 0 )
+				{
+				iParentView->HandleListBoxEventL( iListBox, MEikListBoxObserver::EEventEnterKeyPressed );
+				return EKeyWasConsumed;	
+				}
+			}
+			
+		return iListBox->OfferKeyEventL( aKeyEvent, aType );
+		}
+	else
+		{
+		return EKeyWasNotConsumed;
+		}
+    }
+
+// ----------------------------------------------------------------------------
+// CStartCasesContainer:::SaveActiveLine
+//
+// Makes the iListBox member save its focus position
+// ----------------------------------------------------------------------------
+//
+void CStartCasesContainer::SaveActiveLine()
+	{
+	((CMenuListBox*)iListBox)->SaveFocusPosition();
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/StartCasesView.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,474 @@
+/*
+* 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: This file contains CStartCasesView class definition.
+*
+*/
+
+// INCLUDE FILES
+#include  <eikmenub.h>
+#include  <aknviewappui.h>
+#include  <aknlistquerydialog.h> 
+#include  <barsread.h>	//TResourceReader
+#include  <Stifui.rsg>
+#include  "StartCasesView.h"
+#include  "StartCasesContainer.h"
+#include  "AppUIAppUi.h"
+#include  "Stifui.hrh" 
+
+
+// ================= MEMBER FUNCTIONS =======================
+// ----------------------------------------------------------------------------
+// CStartCasesView::ConstructL
+// 
+// Symbian OS two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+void CStartCasesView::ConstructL()
+    {
+    CView::ConstructL();
+    BaseConstructL( R_APPUI_STARTCASESVIEW );
+    iCurrentTestCase = 0;
+
+    }
+
+// ----------------------------------------------------------------------------
+// CStartCasesView::~CStartCasesView
+// 
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CStartCasesView::~CStartCasesView()
+    {
+    if ( iContainer )
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        }
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;
+    }
+
+// ----------------------------------------------------------------------------
+// CStartCasesView::Id
+// 
+// Returns view´s id.
+// ----------------------------------------------------------------------------
+//
+TUid CStartCasesView::Id() const
+    {
+    return TUid::Uid(EStartCaseMenuViewId);
+
+    }
+
+// ----------------------------------------------------------------------------
+// CStartCasesView::HandleCommandL
+// 
+// Handles a command.
+// ----------------------------------------------------------------------------
+//
+void CStartCasesView::HandleCommandL(TInt aCommand)
+    {   
+    if ( aCommand >= ECmdFilterByModule && aCommand < ECmdFilterByTestCaseFile ) // 0x1000 - 0x1FFF
+        {
+        TInt moduleNumber = aCommand - ECmdFilterByModule;
+        RRefArray<TDesC> allModules;
+        TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->Modules( allModules );
+        if( KErrNone != ret )
+            {
+            allModules.Reset();
+            allModules.Close();
+            User::Leave( ret );
+            }
+        TName moduleName = allModules[ moduleNumber ];
+
+        iContainer->FilterCasesByModuleL( moduleName );
+
+        allModules.Reset();
+        allModules.Close();
+        }
+	else if ( aCommand >= ECmdFilterByTestCaseFile && aCommand < ECmdNOFiltering )
+        {
+        TInt testCaseFileNumber = aCommand - ECmdFilterByTestCaseFile;
+        RRefArray<TDesC> allTestCases;
+        TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->TestCaseFiles( allTestCases );
+        if( KErrNone != ret )
+            {
+            allTestCases.Reset();
+            allTestCases.Close();
+            User::Leave( ret );
+            }
+        TFileName testCaseFileName = allTestCases[ testCaseFileNumber ];
+
+        iContainer->FilterCasesByTCFileNameL( testCaseFileName );
+
+        allTestCases.Reset();
+        allTestCases.Close();
+        }
+	else if ( aCommand == ECmdNOFiltering )
+        {
+        iContainer->NoFilteringL();
+        }
+    else if ( aCommand == EAknCmdMark || aCommand == EAknCmdUnmark 
+    	|| aCommand == EAknMarkAll || aCommand == EAknUnmarkAll )
+    	{
+    	iContainer->HandleMarkCommandL( aCommand );
+    	}
+    else
+	    {
+ 	    switch ( aCommand )
+	        {
+	        case ECmdStartCases:
+	            {
+	            CheckListBoxSelectionsL( iContainer->ListBox() );
+	            break;
+	            }
+	        case EAknSoftkeyBack:
+	            {
+	            iCurrentTestCase = 0;
+	            AppUi()->HandleCommandL(EAppUIGoBack);
+	            break;
+	            }
+	        default:
+	            {
+	            AppUi()->HandleCommandL( aCommand );
+	            break;
+	            }
+	        }
+	    }
+
+    }
+
+// ----------------------------------------------------------------------------
+// CStartCasesView::HandleClientRectChange
+// 
+// Handles client rect changes.
+// ----------------------------------------------------------------------------
+//
+void CStartCasesView::HandleClientRectChange()
+    {
+    if ( iContainer )
+        {
+        iContainer->SetRect( ClientRect() );
+        }
+
+    }
+
+// ----------------------------------------------------------------------------
+// CStartCasesView::DoActivateL
+// 
+// Initializes view when activated.
+// ----------------------------------------------------------------------------
+//
+void CStartCasesView::DoActivateL(
+   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
+   const TDesC8& /*aCustomMessage*/)
+    {
+    if (!iContainer)
+        {
+        ((CAppUIAppUi*)AppUi())->iLogger->Log(_L("StartCasesView: DoActivateL"));
+        iContainer = new (ELeave) CStartCasesContainer;
+        iContainer->SetMopParent(this);
+        iContainer->ConstructL( ClientRect(), this );
+           ((CAppUIAppUi*)AppUi())->iLogger->Log(_L("StartCasesView: container constructed"));
+        AppUi()->AddToStackL( *this, iContainer );
+        }
+
+    iContainer->SetCurrentItemIndex(iCurrentTestCase);
+    
+    CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane();
+	CAknNavigationControlContainer* np= (CAknNavigationControlContainer *)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
+	
+	TResourceReader reader;
+	iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTCASES);
+	iNaviDecorator = np->CreateNavigationLabelL( reader );
+	CleanupStack::PopAndDestroy(); // resource reader
+	np->PushL(*iNaviDecorator);
+
+    }
+
+// ----------------------------------------------------------------------------
+// CStartCasesView::DoDeactivate
+// 
+// Deactivates view.
+// ----------------------------------------------------------------------------
+//
+void CStartCasesView::DoDeactivate()
+    {
+    if ( iContainer )
+        {
+        iContainer->SaveActiveLine();
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        iContainer = NULL;
+        }
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CStartCasesView::DynInitMenuPaneL
+// 
+// Initializes menu pane.
+// ----------------------------------------------------------------------------
+//
+void CStartCasesView::DynInitMenuPaneL(
+    TInt aResourceId, CEikMenuPane* aMenuPane)
+    {
+
+    // Test modules are added to filter by test module submenu if the submenu is opened
+    if (R_APPUI_FILTERBYMODULES_MENU == aResourceId)
+        {
+        RRefArray<TDesC> modules;
+        TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->Modules( modules );
+        if( KErrNone != ret )
+            {
+            modules.Reset();
+            modules.Close();
+            User::Leave( ret );
+            }
+
+        TInt moduleCount = modules.Count();
+        
+        TInt i;
+        CEikMenuPaneItem::SData item;
+
+        item.iCommandId = ECmdFilterByModule;
+        item.iFlags = 0;
+        item.iCascadeId = 0;
+
+        for (i = 0; i < moduleCount; i++)
+            {
+            //item.iText = modules[i].iModuleName;
+            item.iText = modules[i];
+            aMenuPane->AddMenuItemL(item);
+            item.iCommandId++; // command IDs 0x1000 - 0x1FFF are reserved for modules in hrh file
+            }
+        
+        modules.Reset();
+        modules.Close();
+
+        }
+
+    // Test case files are added to filter by test case file submenu if the submenu is opened
+    if (R_APPUI_FILTER_BY_TESTCASEFILE_MENU == aResourceId)
+        {
+        RRefArray<TDesC> testCaseFiles;
+        TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->TestCaseFiles( testCaseFiles );
+        if( KErrNone != ret )
+            {
+            testCaseFiles.Reset();
+            testCaseFiles.Close();
+            User::Leave( ret );
+            }
+
+        TInt testCaseFileCount = testCaseFiles.Count();
+
+        TInt i;
+        CEikMenuPaneItem::SData item;
+
+        item.iCommandId = ECmdFilterByTestCaseFile;
+        item.iFlags = 0;
+        item.iCascadeId = 0;
+
+        for (i = 0; i < testCaseFileCount; i++)
+            {
+            item.iText = testCaseFiles[i];
+            // If there´s no test case file, don´t add item to menu.
+            if ( testCaseFiles[i].Length() > 0 )
+                {
+                aMenuPane->AddMenuItemL(item);
+                }
+            item.iCommandId++; // command IDs 0x2000 - 0x2FFF are reserved for test case files in hrh file
+            }
+        
+        testCaseFiles.Reset();
+        testCaseFiles.Close();
+        }
+
+    }
+
+// ----------------------------------------------------------------------------
+// CStartCasesView::HandleListBoxEventL
+// 
+// Handles listbox events.
+// ----------------------------------------------------------------------------
+//
+void CStartCasesView::HandleListBoxEventL( CEikListBox* aListBox, 
+    TListBoxEvent aEventType )
+	{
+	if ( ( aEventType == EEventEnterKeyPressed ) || ( aEventType == EEventItemDoubleClicked ) )
+		{
+		CheckListBoxSelectionsL( aListBox );
+        }
+        
+    }
+
+// ----------------------------------------------------------------------------
+// CStartCasesView::CheckListBoxSelectionsL
+// 
+// Checks listbox selections and launches query dialog to start test cases.
+// ----------------------------------------------------------------------------
+//
+void CStartCasesView::CheckListBoxSelectionsL( CEikListBox* aListBox )
+    {
+    TInt i(0);
+	TInt count = aListBox->SelectionIndexes()->Count();
+
+	RArray<TInt> selectedIndices;
+	CleanupClosePushL( selectedIndices );
+
+	if ( count > 0 )
+	{
+		for( i = 0; i < count; i++ )
+			{
+			selectedIndices.InsertInOrder( 
+			    (*aListBox->SelectionIndexes())[i] );
+			}
+	}
+	
+	// Check count of selected items.
+	if ( count == 1 )
+		{
+		iCurrentTestCase = selectedIndices[0];
+       	StartTestCaseL();
+		}
+	else if (count > 1)
+		{
+       	StartTestCasesL( selectedIndices );	
+		}
+	else
+		{
+		iCurrentTestCase = iContainer->CurrentItemIndex();
+       	StartTestCaseL();	
+		}
+
+    CleanupStack::PopAndDestroy();
+    
+    }
+    
+// ----------------------------------------------------------------------------
+// CStartCasesView::StartTestCaseL
+// 
+// Starts test case which is selected in containers list box.
+// First shows a list query if user wants just start test case or
+// if he wants to start test case and view test case output.
+// ----------------------------------------------------------------------------
+//
+void CStartCasesView::StartTestCaseL()
+    {
+    TInt selectedItem(0);
+    CAknListQueryDialog* startDialog = new (ELeave) CAknListQueryDialog(&selectedItem);
+    if ( startDialog->ExecuteLD(R_START_TESTCASE_LIST_QUERY) )
+        {
+        RRefArray<CTestInfo> testInfo;
+        TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->TestCases( testInfo );
+        if( KErrNone != ret )
+            {
+            testInfo.Reset();
+            testInfo.Close();
+            User::Leave( ret );
+            }
+        TInt testCaseNumber = iCurrentTestCase;   
+       
+        TInt testCaseIndex( 0 );
+
+        ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->StartTestCase( testInfo[testCaseNumber], testCaseIndex );
+      
+        if( KErrNone != ret )
+            {
+            User::Leave( ret );
+            }
+        testInfo.Reset();
+        testInfo.Close();
+
+        // Increment the counter value
+        ((CAppUIAppUi*)AppUi())->iUIStoreHandler->iExecutedTestCaseCount++;
+     
+        if ( selectedItem == 1 ) // if view output was selected
+            {
+            CStartedTestCase* startedCase = 
+                &((CAppUIAppUi*)AppUi())->UIStoreHandler()->StartedTestCaseL( 
+                testCaseIndex );
+            ((CAppUIAppUi*)AppUi())->SetStartedTestCase( startedCase );
+                
+            AppUi()->HandleCommandL( ECmdViewOutput );
+
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CStartCasesView::StartTestCasesL
+// 
+// Starts multiple test cases which are selected in containers list box.
+// Shows a list query if user wants to start cases parallel or sequential.
+// ----------------------------------------------------------------------------
+//
+void CStartCasesView::StartTestCasesL( RArray<TInt> aSelectedIndexes )
+    {
+    _LIT( KTempSet, "TempSet");
+    TInt selectedItem(0);
+    TInt i(0);
+    TInt ret(0);
+    
+    CAknListQueryDialog* startDialog = new (ELeave) CAknListQueryDialog(&selectedItem);
+    if ( startDialog->ExecuteLD(R_START_MULTIPLE_TESTCASES_LIST_QUERY) )
+    	{
+    	RRefArray<CTestInfo> testInfo;
+    	CleanupClosePushL( testInfo );
+
+    	ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->CreateTestSet( KTempSet );
+    	
+        ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->TestCases( testInfo );
+        if( KErrNone != ret )
+            {
+            testInfo.Reset();
+            testInfo.Close();
+            User::Leave( ret );
+            }
+        
+        for( i = 0; i < aSelectedIndexes.Count(); i++ )
+        	{
+    		ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->AddToTestSet( KTempSet,
+    		 testInfo[ aSelectedIndexes[i] ] );
+    		if( KErrNone != ret )
+    			{
+    			User::Leave( ret );
+    			}
+    		// Increment the counter value
+        	((CAppUIAppUi*)AppUi())->iUIStoreHandler->iExecutedTestCaseCount++;
+	        }
+	    
+	    //start cases
+	    if ( selectedItem == 0 )
+	    	{
+			ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->StartTestSet( 
+		        ((CAppUIAppUi*)AppUi())->UIStoreHandler()->TestSetL( KTempSet ),
+				i, CStartedTestSet::ESetParallel);
+		    }
+	    else if (selectedItem == 1)
+		    {
+	    	ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->StartTestSet(
+	    	    ((CAppUIAppUi*)AppUi())->UIStoreHandler()->TestSetL( KTempSet ),
+	    	    i, CStartedTestSet::ESetSequential);
+	    	}
+
+        ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->RemoveTestSet( KTempSet );
+
+  		CleanupStack::PopAndDestroy();
+    	}
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/StartedCasesMenuContainer.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,234 @@
+/*
+* 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: This file contains CStartedCasesMenuContainer
+* class definition.
+*
+*/
+
+// INCLUDE FILES
+#include "StartedCasesMenuContainer.h"
+#include "Stifui.hrh"
+#include <Stifui.rsg>
+
+#include <aknlists.h>  //ListBox
+#include <barsread.h> // for TResourceReader
+
+#include <aknnotewrappers.h>
+
+#include "MenuListBox.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+// ----------------------------------------------------------------------------
+// CStartedCasesMenuContainer::ConstructL
+// 
+// Symbian OS default constructor.
+// ----------------------------------------------------------------------------
+//
+void CStartedCasesMenuContainer::ConstructL(
+                    const TRect& aRect )
+    {
+    CreateWindowL();
+
+	iListBox = CMenuListBox::NewL(EStartedCasesMenuViewId);
+	iListBox->SetContainerWindowL( *this );
+	TResourceReader reader;
+	iCoeEnv->CreateResourceReaderLC( reader, R_STARTED_CASES_MENU_LISTBOX );
+	iListBox->SetListBoxObserver( this ); // jos peritty MEikListBoxObserver:sta
+	//iListBox->SetObserver( this /*iMainMenuObserver*/ ); //jos peritty MCoeControlObserver:sta
+	iListBox->ConstructFromResourceL( reader );
+    CleanupStack::PopAndDestroy(); // resource stuffs. 
+
+    //Create Scroller control for ListBox and set its visibility
+    iListBox->CreateScrollBarFrameL(ETrue);
+    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
+
+    ((CMenuListBox*)iListBox)->SetPreviousFocus();
+	iListBox->ActivateL();
+
+    SetRect(aRect);
+    ActivateL();
+    }
+
+// Destructor
+CStartedCasesMenuContainer::~CStartedCasesMenuContainer()
+    {
+    if ( iListBox )
+		{    
+    	iListBox->Reset();
+    	delete iListBox;
+        }	
+    }
+
+// ----------------------------------------------------------------------------
+// CStartedCasesMenuContainer::SizeChanged
+// 
+// Called by framework when the view size is changed.
+// ----------------------------------------------------------------------------
+//
+void CStartedCasesMenuContainer::SizeChanged()
+    {
+    if ( iListBox )
+		{
+		iListBox->SetRect( Rect() ); // Sets rectangle of listbox.
+		}
+    }
+
+// ----------------------------------------------------------------------------
+// CStartedCasesMenuContainer::CountComponentControls
+// 
+// Gets a count of the component controls of this list box control.
+// ----------------------------------------------------------------------------
+//
+TInt CStartedCasesMenuContainer::CountComponentControls() const
+    {
+    return 1; // return nbr of controls inside this container
+    }
+
+// ----------------------------------------------------------------------------
+// CStartedCasesMenuContainer::ComponentControl
+// 
+// Gets a pointer to the specified component control.
+// ----------------------------------------------------------------------------
+//
+CCoeControl* CStartedCasesMenuContainer::ComponentControl(TInt aIndex) const
+    {
+    switch ( aIndex )
+        {
+		case 0: 
+			return iListBox;
+        default:
+            return NULL;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CStartedCasesMenuContainer::Draw
+// 
+// Draw a control, called by window server.
+// ----------------------------------------------------------------------------
+//
+void CStartedCasesMenuContainer::Draw(const TRect& /*aRect*/) const
+    {
+    // CWindowGc& gc = SystemGc();
+    }
+
+// ----------------------------------------------------------------------------
+// CStartedCasesMenuContainer::HandleListBoxEventL
+// 
+// Handles list box events.
+// ----------------------------------------------------------------------------
+//
+void CStartedCasesMenuContainer::HandleListBoxEventL(
+                                CEikListBox* aListBox,
+                                TListBoxEvent aEventType )
+	{
+
+	if ( ( aEventType == EEventEnterKeyPressed ) || ( aEventType == EEventItemDoubleClicked ) )
+		{
+		    HandleSelectedListItemL( aListBox->CurrentItemIndex() );
+		}
+	}
+
+
+
+// ----------------------------------------------------------------------------
+// CStartedCasesMenuContainer::HandleSelectedListItemL
+// 
+// Method HandleSelectedListItemL handles valid index.
+// ----------------------------------------------------------------------------
+//
+void CStartedCasesMenuContainer::HandleSelectedListItemL( TInt aIndex )
+	{	 
+		TInt selection = aIndex;
+
+	    switch ( selection )
+			{
+            case 0: ( (CEikAppUi*)iCoeEnv->AppUi() )->HandleCommandL(ECmdShowAllStartedCases);
+				break;
+            case 1:	( (CEikAppUi*)iCoeEnv->AppUi() )->HandleCommandL(ECmdShowOngoingCases);
+				break;
+            case 2: ( (CEikAppUi*)iCoeEnv->AppUi() )->HandleCommandL(ECmdShowPausedCases);
+				break;
+            case 3: ( (CEikAppUi*)iCoeEnv->AppUi() )->HandleCommandL(ECmdShowPassedCases);
+				break;
+            case 4: ( (CEikAppUi*)iCoeEnv->AppUi() )->HandleCommandL(ECmdShowFailedCases);
+				break;
+            case 5: ( (CEikAppUi*)iCoeEnv->AppUi() )->HandleCommandL(ECmdShowCrashedAbortedCases);
+				break;
+            case 6: ( (CEikAppUi*)iCoeEnv->AppUi() )->HandleCommandL(ECmdShowStatistics);
+				break;
+	        default:
+				break;
+			}
+	}	
+
+// ----------------------------------------------------------------------------
+// CStartedCasesMenuContainer::OfferKeyEventL
+// 
+// Handles key events.
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CStartedCasesMenuContainer::OfferKeyEventL(
+	const TKeyEvent& aKeyEvent, TEventCode aType)
+    {
+	if (aType != EEventKey)
+	    {
+		return EKeyWasNotConsumed;
+	    }
+
+    switch ( aKeyEvent.iCode )
+        {
+        case EKeyLeftArrow:
+        case EKeyRightArrow:
+			{   /* Left ja right key eventit valitetaan AppUille joka hoitaa siirtymisen toisiin nakymiin */
+			return EKeyWasNotConsumed;
+            //break;
+            }
+        default:
+			{
+			//Muut Key eventit valitetaan listboxille, joka hoitaa ne
+			if (iListBox)
+				{
+				return iListBox->OfferKeyEventL( aKeyEvent, aType );
+				}
+			}
+        }
+    return EKeyWasNotConsumed;        
+    }
+
+// ----------------------------------------------------------------------------
+// CStartedCasesMenuContainer::GetActiveLine
+// 
+// Get currently selected items index.
+// ----------------------------------------------------------------------------
+//
+TInt CStartedCasesMenuContainer::GetActiveLine()
+	{
+	return iListBox->CurrentItemIndex();
+	}
+
+// ----------------------------------------------------------------------------
+// CStartedCasesMenuContainer:::SaveActiveLine
+//
+// Makes the iListBox member save its focus position
+// ----------------------------------------------------------------------------
+//
+void CStartedCasesMenuContainer::SaveActiveLine()
+	{
+	((CMenuListBox*)iListBox)->SaveFocusPosition();
+	}
+
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/StartedCasesMenuView.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,160 @@
+/*
+* 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: This file contains CStartedCasesMenuView class
+* definition.
+*
+*/
+
+// INCLUDE FILES
+#include  <aknviewappui.h>
+#include  <barsread.h>	//TResourceReader
+#include  <Stifui.rsg>
+#include  "StartedCasesMenuView.h"
+#include  "StartedCasesMenuContainer.h"
+#include  "Stifui.hrh" 
+#include  "AppUIAppUi.h"
+
+// ================= MEMBER FUNCTIONS =======================
+// ----------------------------------------------------------------------------
+// CStartedCasesMenuView::ConstructL
+// 
+// Symbian OS two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+void CStartedCasesMenuView::ConstructL()
+    {
+    CView::ConstructL();
+    BaseConstructL( R_APPUI_STARTEDCASESMENUVIEW );
+    }
+
+// ----------------------------------------------------------------------------
+// CStartedCasesMenuView::~CStartedCasesMenuView
+// 
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CStartedCasesMenuView::~CStartedCasesMenuView()
+    {
+    if ( iContainer )
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        }
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;
+    }
+
+// ----------------------------------------------------------------------------
+// CStartedCasesMenuView::Id
+// 
+// Returns view´s id.
+// ----------------------------------------------------------------------------
+//
+TUid CStartedCasesMenuView::Id() const
+    {
+    return TUid::Uid(EStartedCasesMenuViewId); //KTestCaseMenuViewId;
+    }
+
+// ----------------------------------------------------------------------------
+// CStartedCasesMenuView::HandleCommandL
+// 
+// Handles a command.
+// ----------------------------------------------------------------------------
+//
+void CStartedCasesMenuView::HandleCommandL(TInt aCommand)
+    {   
+    switch ( aCommand )
+        {
+        case EAknSoftkeyBack:
+            {
+            AppUi()->HandleCommandL(EAppUIGoBack);
+            break;
+            }
+		case EAknCmdOpen:
+			{
+			TInt a = iContainer->GetActiveLine();
+			iContainer->HandleSelectedListItemL( a );
+			}
+			break;              
+        default:
+            {
+            AppUi()->HandleCommandL( aCommand );
+            break;
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CStartedCasesMenuView::HandleClientRectChange
+// 
+// Handles client rect changes.
+// ----------------------------------------------------------------------------
+//
+void CStartedCasesMenuView::HandleClientRectChange()
+    {
+    if ( iContainer )
+        {
+        iContainer->SetRect( ClientRect() );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CStartedCasesMenuView::DoActivateL
+// 
+// Initializes view when activated.
+// ----------------------------------------------------------------------------
+//
+void CStartedCasesMenuView::DoActivateL(
+   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
+   const TDesC8& /*aCustomMessage*/)
+    {
+    if (!iContainer)
+        {
+        iContainer = new (ELeave) CStartedCasesMenuContainer;
+        iContainer->SetMopParent(this);
+        iContainer->ConstructL( ClientRect() );
+        AppUi()->AddToStackL( *this, iContainer );
+        } 
+        
+    CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane();
+	CAknNavigationControlContainer* np= (CAknNavigationControlContainer *)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
+	
+	TResourceReader reader;
+	iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTEDCASES);
+	iNaviDecorator = np->CreateNavigationLabelL( reader );
+	CleanupStack::PopAndDestroy(); // resource reader
+	np->PushL(*iNaviDecorator);
+   }
+
+// ----------------------------------------------------------------------------
+// CStartedCasesMenuView::DoDeactivate
+// 
+// Deactivates view.
+// ----------------------------------------------------------------------------
+//
+void CStartedCasesMenuView::DoDeactivate()
+    {
+    if ( iContainer )
+        {
+        iContainer->SaveActiveLine();
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        iContainer = NULL;
+        }
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;
+    }
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/StatisticsContainer.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,297 @@
+/*
+* 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: This file contains CStatisticsContainer class 
+* definition.
+*
+*/
+
+// INCLUDE FILES
+#include <aknlists.h>  // ListBox 
+#include <akniconarray.h> // CAknIconArray
+#include <aknnotewrappers.h>
+
+#include <eikclbd.h> // CColumnListBoxData
+
+#include <Stifui.rsg>
+
+//#include "UIStoreIf.h"         
+//#include "UIStore.h"            
+//#include "UIEngine.h"           
+//#include "UIEngineContainer.h"  
+
+#include <stifinternal/UIStoreIf.h>
+#include <stifinternal/UIStore.h>
+#include <stifinternal/UIEngine.h>
+#include <stifinternal/UIEngineContainer.h>
+
+#include "StatisticsContainer.h"
+#include "Stifui.hrh"
+#include "AppUIAppUi.h"
+
+#include "MenuListBox.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+// ----------------------------------------------------------------------------
+// CStatisticsContainer::ConstructL
+// 
+// Symbian OS two phased constructor.
+// ----------------------------------------------------------------------------
+//
+void CStatisticsContainer::ConstructL( const TRect& aRect, 
+                                        MEikListBoxObserver* aListBoxObserver )
+    {
+
+    ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(
+                            _L("StatisticsContainer: ConstructL"));
+
+    CreateWindowL();
+
+    iUIStore = ( (CAppUIAppUi*)iCoeEnv->AppUi() )->UIStoreHandler();
+
+    //iTestCasesInView.Reset();
+        //((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("StatisticsContainer: iTCInV Reset"));
+    
+	iListBox = CMenuListBox::NewL(EStatisticsViewId);
+	iListBox->SetContainerWindowL( *this );
+	iListBox->SetListBoxObserver( aListBoxObserver /*this*/ ); // jos peritty MEikListBoxObserver:sta
+    iListBox->ConstructL(this, EAknListBoxMarkableList /*EAknListBoxSelectionList*/);
+
+    ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("StatisticsContainer: ListBox constructed"));
+
+    //Create Scroller control for ListBox and set its visibility
+    iListBox->CreateScrollBarFrameL(ETrue);
+    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
+
+    if ( iUIStore )
+        {
+        //RRefArray<CStartedTestCase> allStarted;
+        RRefArray<CStartedTestCase> allStarted;
+        TInt ret = iUIStore->StartedTestCases( allStarted );
+        if( KErrNone != ret )
+            {
+            allStarted.Reset();
+            allStarted.Close();
+            User::Leave( ret );
+            }
+        TInt count = allStarted.Count();
+        // TInt notstarted( 0 );
+        TInt ongoing( 0 );
+        TInt passed( 0 );
+        TInt failed( 0 );
+        TInt other( 0 );
+        //TInt aborted( 0 );
+        // TInt paused( 0 );
+        //TInt crashed( 0 );
+        //TInt executed( 0 );
+        // TInt state( 0 );
+
+        for( TInt a = 0; a < count; a++ )
+            {
+            switch ( allStarted[a].Status() )
+                {
+                case CUIStoreIf::EStatusRunning:
+                    {
+                    ongoing++;
+                    break;
+                    }
+                case CUIStoreIf::EStatusExecuted | CUIStoreIf::EStatusPassed:
+                    {
+                    passed++;
+                    break;
+                    }
+                case CUIStoreIf::EStatusExecuted |CUIStoreIf::EStatusFailed:
+                    {
+                    failed++;
+                    break;
+                    }
+                //case CUIStoreIf::EStatusAborted:
+                //    {
+                //    aborted++;
+                //    break;
+                //    }
+                /*case ECrashed:
+                    {
+                    crashed++;
+                    break;
+                    }
+                */
+                /*case EExecuted:
+                    {
+                    executed++;
+                    break;
+                    }
+                */
+                default:
+                    {
+                    other++;
+                    break;
+                    }
+                }
+            }
+
+        allStarted.Reset();
+        allStarted.Close();
+
+        iTestCaseArray = new (ELeave) CDesC16ArrayFlat(6);
+        iTestCaseArray->Reset();
+
+        HBufC* tmpHBuf = HBufC::NewL( 40 );
+        TPtr buffer( tmpHBuf->Des() );
+
+        buffer = ( _L("\t") );
+        buffer.AppendNum( ongoing );
+        buffer.Append( _L(" Running") );
+        iTestCaseArray->AppendL( buffer );
+
+        buffer = ( _L("\t") );
+        buffer.AppendNum( passed );
+        buffer.Append( _L(" Passed") );
+        iTestCaseArray->AppendL( buffer );
+
+        buffer = ( _L("\t") );
+        buffer.AppendNum( failed );
+        buffer.Append( _L(" Failed") );
+        iTestCaseArray->AppendL( buffer );
+
+        buffer = ( _L("\t") );
+        buffer.AppendNum( other );
+        buffer.Append( _L(" Crashed/Aborted") );
+        iTestCaseArray->AppendL( buffer );
+
+        delete tmpHBuf;
+
+        iListBox->Model()->SetItemTextArray( iTestCaseArray );
+             ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("StatisticsContainer: ListBox model set"));
+        }
+    else
+        {
+        //User::Leave( syy?? )
+        }
+
+    // Creates graphic.
+    //SetGraphicIconL( iListBox );
+    //   ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("StatisticsContainer: icons created"));
+
+    iListBox->ActivateL();
+    ((CMenuListBox*)iListBox)->SetPreviousFocus();
+
+    SetRect(aRect);
+    ActivateL();
+
+    }
+
+// ----------------------------------------------------------------------------
+// CStatisticsContainer::~CStatisticsContainer
+// 
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CStatisticsContainer::~CStatisticsContainer()
+    {
+    //iTestCasesInView.Close(); // does not delete objects whose pointers are contained in the array
+    //delete iListBox;
+    }
+
+// ----------------------------------------------------------------------------
+// CStatisticsContainer::SizeChanged
+// 
+// Called by framework when the view size is changed.
+// ----------------------------------------------------------------------------
+//
+void CStatisticsContainer::SizeChanged()
+    {
+    if ( iListBox )
+		{
+		iListBox->SetRect( Rect() ); // Sets rectangle of listbox.
+		}
+    }
+
+// ----------------------------------------------------------------------------
+// CStatisticsContainer::CountComponentControls
+// 
+// Gets a count of the component controls of this list box control.
+// ----------------------------------------------------------------------------
+//
+TInt CStatisticsContainer::CountComponentControls() const
+    {
+    return 1; // return nbr of controls inside this container
+    }
+
+// ----------------------------------------------------------------------------
+// CStatisticsContainer::ComponentControl
+// 
+// Gets a pointer to the specified component control.
+// ----------------------------------------------------------------------------
+//
+
+CCoeControl* CStatisticsContainer::ComponentControl(TInt aIndex) const
+    {
+    switch ( aIndex )
+        {
+		case 0: 
+			return iListBox;
+        default:
+            return NULL;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CStatisticsContainer::Draw
+// 
+// Draw a control, called by window server.
+// ----------------------------------------------------------------------------
+//
+void CStatisticsContainer::Draw(const TRect& /*aRect*/) const
+    {
+    // CWindowGc& gc = SystemGc();
+    }
+
+// ----------------------------------------------------------------------------
+// CStatisticsContainer::OfferKeyEventL
+// 
+// Handles key events.
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CStatisticsContainer::OfferKeyEventL(
+	const TKeyEvent& aKeyEvent, TEventCode aType)
+    {
+	if (aType != EEventKey)
+	{
+		return EKeyWasNotConsumed;
+	}
+
+	if (iListBox)
+		{
+		return iListBox->OfferKeyEventL( aKeyEvent, aType );
+		}
+	else
+		{
+		return EKeyWasNotConsumed;
+		}
+
+    }
+
+// ----------------------------------------------------------------------------
+// CStatisticsContainer::SaveActiveLine
+//
+// Makes the iListBox member save its focus position
+// ----------------------------------------------------------------------------
+//
+void CStatisticsContainer::SaveActiveLine()
+	{
+	((CMenuListBox*)iListBox)->SaveFocusPosition();
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/StatisticsView.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,350 @@
+/*
+* 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: This file contains CStatisticsView class 
+* definition.
+*
+*/
+
+// INCLUDE FILES
+#include  <eikmenub.h>
+#include  <aknviewappui.h>
+#include  <aknlistquerydialog.h> 
+#include  <barsread.h>	//TResourceReader
+#include  <Stifui.rsg>
+#include  "AppUIAppUi.h"
+#include  "Stifui.hrh" 
+#include  "StatisticsView.h"
+#include  "StatisticsContainer.h"
+
+// ================= MEMBER FUNCTIONS =======================
+// ----------------------------------------------------------------------------
+// CStatisticsView::ConstructL
+// 
+// Symbian OS two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+void CStatisticsView::ConstructL()
+    {
+    CView::ConstructL();
+    BaseConstructL( R_APPUI_STATISTICSVIEW );
+    iCurrentTestCase = 0;
+    }
+
+// ----------------------------------------------------------------------------
+// CStatisticsView::~CStatisticsView
+// 
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CStatisticsView::~CStatisticsView()
+    {
+    if ( iContainer )
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        }
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;
+    }
+
+// ----------------------------------------------------------------------------
+// CStatisticsView::Id
+// 
+// Returns view´s id.
+// ----------------------------------------------------------------------------
+//
+TUid CStatisticsView::Id() const
+    {
+    return TUid::Uid(EStatisticsViewId);
+    }
+
+// ----------------------------------------------------------------------------
+// CStatisticsView::HandleCommandL
+// 
+// Handles a command.
+// ----------------------------------------------------------------------------
+//
+void CStatisticsView::HandleCommandL(TInt aCommand)
+    {   
+    if ( aCommand >= ECmdFilterByModule && aCommand < ECmdFilterByTestCaseFile ) // 0x1000 - 0x1FFF
+        {
+        TInt moduleNumber = aCommand - ECmdFilterByModule;
+
+        RRefArray<TDesC> moduleName;
+        TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->Modules( moduleName );
+        if( KErrNone != ret )
+            {
+            moduleName.Reset();
+            moduleName.Close();
+            User::Leave( ret );
+            }
+        //iFilterModule = testModules[moduleNumber];
+
+        iContainer->FilterCasesByModuleL( moduleName[moduleNumber] );
+
+        moduleName.Reset();
+        moduleName.Close();
+
+        return;
+        }
+
+    if ( aCommand >= ECmdFilterByTestCaseFile && aCommand < ECmdNOFiltering )
+        {
+        TInt testCaseFileNumber = aCommand - ECmdFilterByTestCaseFile;
+        RRefArray<TDesC> testCaseFileName;
+        TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->TestCaseFiles( testCaseFileName );
+        if( KErrNone != ret )
+            {
+            testCaseFileName.Reset();
+            testCaseFileName.Close();
+            User::Leave( ret );
+            }
+
+        iContainer->FilterCasesByTCFileNameL( testCaseFileName[testCaseFileNumber] );
+
+        testCaseFileName.Reset();
+        testCaseFileName.Close();
+
+        return;
+        }
+
+    if ( aCommand == ECmdNOFiltering )
+        {
+        iContainer->NoFilteringL();
+        return;
+        }
+
+    switch ( aCommand )
+        {
+        case ECmdStartCases:
+            {
+            iCurrentTestCase = iContainer->CurrentItemIndex();
+            StartTestCasesL();
+            break;
+            }
+        case EAknSoftkeyBack:
+            {
+            AppUi()->HandleCommandL( EAppUIGoBack );
+            break;
+            }
+        default:
+            {
+            AppUi()->HandleCommandL( aCommand );
+            break;
+            }
+        }
+
+    }
+
+// ----------------------------------------------------------------------------
+// CStatisticsView::HandleClientRectChange
+// 
+// Handles client rect changes.
+// ----------------------------------------------------------------------------
+//
+void CStatisticsView::HandleClientRectChange()
+    {
+    if ( iContainer )
+        {
+        iContainer->SetRect( ClientRect() );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CStatisticsView::DoActivateL
+// 
+// Initializes view when activated.
+// ----------------------------------------------------------------------------
+//
+void CStatisticsView::DoActivateL(
+   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
+   const TDesC8& /*aCustomMessage*/)
+    {
+    if (!iContainer)
+        {
+           ((CAppUIAppUi*)AppUi())->iLogger->Log(_L("StatisticsView: DoActivateL"));
+        //message = _L("eng.open ret:");
+        //message.AppendNum( ret , EDecimal );
+        //AppUi()->iLogger->Log( message );
+        iContainer = new (ELeave) CStatisticsContainer;
+        iContainer->SetMopParent(this);
+        iContainer->ConstructL( ClientRect(), this );
+           ((CAppUIAppUi*)AppUi())->iLogger->Log(_L("StatisticsView: container constructed"));
+        AppUi()->AddToStackL( *this, iContainer );
+        }
+    iContainer->SetCurrentItemIndex(iCurrentTestCase);
+	
+	CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane();
+	CAknNavigationControlContainer* np= (CAknNavigationControlContainer *)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
+	
+	TResourceReader reader;
+	iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTED_STATS);
+	iNaviDecorator = np->CreateNavigationLabelL( reader );
+	CleanupStack::PopAndDestroy(); // resource reader
+	np->PushL(*iNaviDecorator);
+    }
+
+// ----------------------------------------------------------------------------
+// CStatisticsView::DoDeactivate
+// 
+// Deactivates view.
+// ----------------------------------------------------------------------------
+//
+void CStatisticsView::DoDeactivate()
+    {
+    if ( iContainer )
+        {
+        iContainer->SaveActiveLine();
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        iContainer = NULL;
+        }
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;
+    }
+
+// ----------------------------------------------------------------------------
+// CStatisticsView::DynInitMenuPaneL
+// 
+// Initializes menu pane.
+// ----------------------------------------------------------------------------
+//
+void CStatisticsView::DynInitMenuPaneL(
+    TInt aResourceId, CEikMenuPane* aMenuPane)
+    {
+
+    // Test modules are added to filter by test module submenu if the submenu is opened
+    if (R_APPUI_FILTERBYMODULES_MENU == aResourceId)
+        {
+        RRefArray<TDesC> modules;
+        TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->Modules( modules );
+        if( KErrNone != ret )
+            {
+            modules.Reset();
+            modules.Close();
+            User::Leave( ret );
+            }
+
+        TInt moduleCount = modules.Count();
+        
+        TInt i;
+        CEikMenuPaneItem::SData item;
+
+        item.iCommandId = ECmdFilterByModule;
+        item.iFlags = 0;
+        item.iCascadeId = 0;
+
+        for (i = 0; i < moduleCount; i++)
+            {
+            item.iText = modules[i];
+            aMenuPane->AddMenuItemL(item);
+            item.iCommandId++; // command IDs 0x1000 - 0x1FFF are reserved for modules in hrh file
+            }
+        
+        modules.Reset();
+        modules.Close();
+        }
+
+    // Test case files are added to filter by test case file submenu if the submenu is opened
+    if (R_APPUI_FILTER_BY_TESTCASEFILE_MENU == aResourceId)
+        {
+        RRefArray<TDesC> testCaseFiles;
+        TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->TestCaseFiles( testCaseFiles );
+        if( KErrNone != ret )
+            {
+            testCaseFiles.Reset();
+            testCaseFiles.Close();
+            User::Leave( ret );
+            }
+
+        TInt testCaseFileCount = testCaseFiles.Count();
+
+        TInt i;
+        CEikMenuPaneItem::SData item;
+
+        item.iCommandId = ECmdFilterByTestCaseFile;
+        item.iFlags = 0;
+        item.iCascadeId = 0;
+
+        for (i = 0; i < testCaseFileCount; i++)
+            {
+            item.iText = testCaseFiles[i];
+            aMenuPane->AddMenuItemL(item);
+            item.iCommandId++; // command IDs 0x2000 - 0x2FFF are reserved for test case files in hrh file
+            }
+
+        testCaseFiles.Reset();
+        testCaseFiles.Close();
+        }
+
+    }
+
+// ----------------------------------------------------------------------------
+// CStatisticsView::HandleListBoxEventL
+// 
+// Handles a list box event.
+// ----------------------------------------------------------------------------
+//
+void CStatisticsView::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
+	{
+	if ( ( aEventType == EEventEnterKeyPressed ) || ( aEventType == EEventItemDoubleClicked ) )
+		{
+        //iCurrentTestCase = aListBox->CurrentItemIndex();
+        //iCurrentTestCase = iContainer->CurrentItemIndex();
+        //StartTestCases();
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CStatisticsView::StartTestCases
+// 
+// Starts test case(s) which is selected in containers list box.
+// First shows a list query if user wants just start test case or
+// if he wants to start test case and view test case output.
+// ----------------------------------------------------------------------------
+//
+void CStatisticsView::StartTestCasesL()
+    {
+    TInt selectedItem(0);
+    CAknListQueryDialog* startDialog = new (ELeave) CAknListQueryDialog(&selectedItem);
+    if ( startDialog->ExecuteLD(R_START_TESTCASE_LIST_QUERY) )
+        {
+        RRefArray<CTestInfo> testInfo;
+        TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->TestCases( testInfo );
+        if( KErrNone != ret )
+            {
+            testInfo.Reset();
+            testInfo.Close();
+            User::Leave( ret );
+            }
+        TInt testCaseNumber = testInfo[0].TestCaseNum();
+        TInt testCaseIndex( 0 );
+
+        //CUIEngineContainer* container = NULL;
+        ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->StartTestCase( testInfo[testCaseNumber], testCaseIndex );
+        if( KErrNone != ret )
+            {
+            User::Leave( ret );
+            }
+        testInfo.Reset();
+        testInfo.Close();
+
+        // Increment the counter value
+        ((CAppUIAppUi*)AppUi())->iUIStoreHandler->iExecutedTestCaseCount++;
+
+        }
+
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/TestCaseMenuContainer.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -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: This file contains CTestCaseMenuContainer class
+* definition.
+*
+*/
+
+// INCLUDE FILES
+#include "TestCaseMenuContainer.h"
+#include "Stifui.hrh"
+#include <Stifui.rsg>
+
+#include <aknlists.h>  //ListBox
+#include <barsread.h> // for TResourceReader
+
+#include <aknnotewrappers.h>
+
+#include "MenuListBox.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+// ----------------------------------------------------------------------------
+// CTestCaseMenuContainer::ConstructL
+// 
+// Symbian OS two phased constructor.
+// ----------------------------------------------------------------------------
+//
+void CTestCaseMenuContainer::ConstructL(const TRect& aRect)
+    {
+    CreateWindowL();
+     
+	iListBox = CMenuListBox::NewL(ETestCaseMenuViewId);
+	iListBox->SetContainerWindowL( *this );
+	TResourceReader reader;
+	iCoeEnv->CreateResourceReaderLC( reader, R_TESTCASE_MENU_LISTBOX );
+	iListBox->SetListBoxObserver( this );
+	iListBox->ConstructFromResourceL( reader );
+	CleanupStack::PopAndDestroy(); // resource stuffs. 
+
+    // Create Scroller control for ListBox and set its visibility
+    // !!! Not needed yet because there are only two items in list box.
+    // If items are added later, scroller may be taken to use
+    //iListBox->CreateScrollBarFrameL(ETrue);
+    //iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
+    
+    iListBox->ActivateL();
+    ((CMenuListBox*)iListBox)->SetPreviousFocus();
+    
+    SetRect(aRect);
+    ActivateL();
+    }
+
+// Destructor
+CTestCaseMenuContainer::~CTestCaseMenuContainer()
+    {
+    if ( iListBox )
+		{
+		iListBox->Reset();
+    	delete iListBox;
+    	}	
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseMenuContainer::SizeChanged
+// 
+// Called by framework when the view size is changed.
+// ----------------------------------------------------------------------------
+//
+void CTestCaseMenuContainer::SizeChanged()
+    {
+    if ( iListBox )
+		{
+		iListBox->SetRect( Rect() ); // Sets rectangle of listbox.
+		}
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseMenuContainer::CountComponentControls
+// 
+// Gets a count of the component controls of this list box control.
+// ----------------------------------------------------------------------------
+//
+TInt CTestCaseMenuContainer::CountComponentControls() const
+    {
+    return 1; // return nbr of controls inside this container
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseMenuContainer::ComponentControl
+// 
+// Gets a pointer to the specified component control.
+// ----------------------------------------------------------------------------
+//
+CCoeControl* CTestCaseMenuContainer::ComponentControl(TInt aIndex) const
+    {
+    switch ( aIndex )
+        {
+		case 0: 
+			return iListBox;
+        default:
+            return NULL;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseMenuContainer::Draw
+// 
+// Draw a control, called by window server.
+// ----------------------------------------------------------------------------
+//
+void CTestCaseMenuContainer::Draw(const TRect& /*aRect*/) const
+    {
+    // CWindowGc& gc = SystemGc();
+    }
+
+
+// ----------------------------------------------------------------------------
+// CTestCaseMenuContainer::HandleListBoxEventL
+// 
+// Handles list box events.
+// ----------------------------------------------------------------------------
+//
+void CTestCaseMenuContainer::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType)
+	{
+	if ( ( aEventType == EEventEnterKeyPressed ) || ( aEventType == EEventItemDoubleClicked ) )
+		{
+		    HandleSelectedListItemL( aListBox->CurrentItemIndex() );
+
+		}	
+
+	}
+	
+// ----------------------------------------------------------------------------
+// CTestCaseMenuContainer::HandleSelectedListItemL
+// 
+// Method HandleSelectedListItemL handles valid index.
+// ----------------------------------------------------------------------------
+//
+void CTestCaseMenuContainer::HandleSelectedListItemL( TInt aIndex )
+	{	 
+		TInt selection = aIndex;
+
+	    switch ( selection )
+			{
+		    case 0:
+				//Vaihda StartCasesView aktiiviseksi
+				( (CEikAppUi*)iCoeEnv->AppUi() )->HandleCommandL(ECmdGoToStartCasesView);
+				break;
+			case 1:
+				( (CEikAppUi*)iCoeEnv->AppUi() )->HandleCommandL(ECmdGoToStartedCasesView);
+				break;
+	        default:
+				break;
+			}
+	}	
+
+// ----------------------------------------------------------------------------
+// CTestCaseMenuContainer::OfferKeyEventL
+// 
+// Handles key events.
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CTestCaseMenuContainer::OfferKeyEventL(
+	const TKeyEvent& aKeyEvent, TEventCode aType)
+    {
+	if (aType != EEventKey)
+    	{
+		return EKeyWasNotConsumed;
+	    }
+
+    switch ( aKeyEvent.iCode )
+        {
+        case EKeyLeftArrow:
+        case EKeyRightArrow:
+			{   /* Left ja right key eventit valitetaan AppUille joka hoitaa siirtymisen toisiin nakymiin */
+			return EKeyWasNotConsumed;
+            //break;
+            }
+        default:
+			{
+			//Muut Key eventit valitetaan listboxille, joka hoitaa ne
+			if (iListBox)
+				{
+				return iListBox->OfferKeyEventL( aKeyEvent, aType );
+				}
+			}
+        }     
+    return EKeyWasNotConsumed;        
+}
+
+// ----------------------------------------------------------------------------
+// CTestCaseMenuContainer::GetActiveLine
+// 
+// Get currently selected items index.
+// ----------------------------------------------------------------------------
+//
+TInt CTestCaseMenuContainer::GetActiveLine()
+	{
+	return iListBox->CurrentItemIndex();
+	}
+
+// ----------------------------------------------------------------------------
+// CTestCaseMenuContainer::SaveActiveLine
+//
+// Makes the iListBox member save its focus position
+// ----------------------------------------------------------------------------
+//
+void CTestCaseMenuContainer::SaveActiveLine()
+	{
+	((CMenuListBox*)iListBox)->SaveFocusPosition();
+	}
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/TestCaseMenuView.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,165 @@
+/*
+* 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: This file contains CTestCaseMenuView class
+* definition.
+*
+*/
+
+// INCLUDE FILES
+#include  <aknviewappui.h>
+#include  <barsread.h>	//TResourceReader
+#include  <Stifui.rsg>
+#include  "TestCaseMenuView.h"
+#include  "TestCaseMenuContainer.h"
+#include  "Stifui.hrh" 
+#include  "AppUIAppUi.h" // loggerin kayttoa varten, muuten ei tarvittaisi
+
+// ================= MEMBER FUNCTIONS =======================
+// ----------------------------------------------------------------------------
+// CTestCaseMenuView::ConstructL
+// 
+// Symbian OS two phased constructor.
+// ----------------------------------------------------------------------------
+//
+void CTestCaseMenuView::ConstructL()
+    {
+    CView::ConstructL();
+    BaseConstructL( R_APPUI_TESTCASEMENUVIEW );
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseMenuView::~CTestCaseMenuView
+// 
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CTestCaseMenuView::~CTestCaseMenuView()
+    {
+    if ( iContainer )
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        iContainer = NULL;
+        }
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseMenuView::Id
+// 
+// Returns view´s id.
+// ----------------------------------------------------------------------------
+//
+TUid CTestCaseMenuView::Id() const
+    {
+    return TUid::Uid(ETestCaseMenuViewId); //KTestCaseMenuViewId;
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseMenuView::HandleCommandL
+// 
+// Handles a command.
+// ----------------------------------------------------------------------------
+//
+void CTestCaseMenuView::HandleCommandL(TInt aCommand)
+    {   
+    switch ( aCommand )
+        {
+        case EAknSoftkeyBack:
+            {
+            AppUi()->HandleCommandL(EAppUIGoBack);
+            break;
+            }
+		case EAknCmdOpen:
+			{
+			TInt a = iContainer->GetActiveLine();
+			iContainer->HandleSelectedListItemL( a );
+			}
+			break;             
+        default:
+            {
+            AppUi()->HandleCommandL( aCommand );
+            break;
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseMenuView::HandleClientRectChange
+// 
+// Handles client rect changes.
+// ----------------------------------------------------------------------------
+//
+void CTestCaseMenuView::HandleClientRectChange()
+    {
+    if ( iContainer )
+        {
+        iContainer->SetRect( ClientRect() );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseMenuView::DoActivateL
+// 
+// Initializes view when activated.
+// ----------------------------------------------------------------------------
+//
+void CTestCaseMenuView::DoActivateL(
+   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
+   const TDesC8& /*aCustomMessage*/)
+    {
+    if (!iContainer)
+        {
+        ((CAppUIAppUi*)AppUi())->iLogger->Log(_L("TestCaseMenu: DoActivateL"));
+        //message = _L("eng.open ret:");
+        //message.AppendNum( ret , EDecimal );
+        //AppUi->iLogger->Log( message );
+        iContainer = new (ELeave) CTestCaseMenuContainer;
+        iContainer->SetMopParent(this);
+        iContainer->ConstructL( ClientRect() );
+        ((CAppUIAppUi*)AppUi())->iLogger->Log(_L("TestCaseMenu: container constructed"));
+        AppUi()->AddToStackL( *this, iContainer );
+        } 
+    
+    CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane();
+	CAknNavigationControlContainer* np= (CAknNavigationControlContainer *)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
+	
+	TResourceReader reader;
+	iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_TESTCASES);
+	iNaviDecorator = np->CreateNavigationLabelL( reader );
+	CleanupStack::PopAndDestroy(); // resource reader
+	np->PushL(*iNaviDecorator);
+   }
+
+// ----------------------------------------------------------------------------
+// CTestCaseMenuView::DoDeactivate
+// 
+// Deactivates view.
+// ----------------------------------------------------------------------------
+//
+void CTestCaseMenuView::DoDeactivate()
+    {
+    if ( iContainer )
+        {
+        iContainer->SaveActiveLine();
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        iContainer = NULL;         
+        }  
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;      
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/TestCaseOutputContainer.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,328 @@
+/*
+* 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: This file contains CTestCaseOutputContainer class
+* definition.
+*
+*/
+
+// INCLUDE FILES
+#include "TestCaseOutputContainer.h"
+#include <Stifui.rsg>
+#include "Stifui.hrh"
+#include "AppUIAppUi.h"
+
+#include <aknlists.h>  // ListBox
+#include <akniconarray.h>  // CAknIconArray
+#include <badesca.h> // CDesCArray
+#include <eikclbd.h> // CColumnListBoxData
+#include <aknnotewrappers.h>
+
+//#include "UIStoreIf.h"         
+//#include "UIStore.h"            
+//#include "UIEngine.h"           
+//#include "UIEngineContainer.h"  
+
+#include <stifinternal/UIStoreIf.h>
+#include <stifinternal/UIStore.h>
+#include <stifinternal/UIEngine.h>
+#include <stifinternal/UIEngineContainer.h>
+
+#include "MenuListBox.h"
+
+//#include <gdi.h>
+
+
+// ================= MEMBER FUNCTIONS =======================
+// ----------------------------------------------------------------------------
+// CTestCaseOutputContainer::ConstructL
+// 
+// Symbian OS two phased constructor.
+// ----------------------------------------------------------------------------
+//
+void CTestCaseOutputContainer::ConstructL(const TRect& aRect, CStartedTestCase* aStartedTestCase ) //TInt aExecutedTestCaseCount )
+    {
+    CreateWindowL();
+
+    iUIStore = ( (CAppUIAppUi*)iCoeEnv->AppUi() )->UIStoreHandler();
+    
+	iListBox = CMenuListBox::NewL(ETestCaseOutputViewId);
+	iListBox->SetContainerWindowL( *this );
+	iListBox->SetListBoxObserver( this );
+    iListBox->ConstructL(this, EAknListBoxSelectionList);
+
+    //Create Scroller control for ListBox and set its visibility
+    iListBox->CreateScrollBarFrameL(ETrue);
+    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
+    
+    if( iUIStore )
+        {
+        iListBoxModel = CTestOutputListBoxModel::NewL( aStartedTestCase );
+        iListBox->Model()->SetItemTextArray( iListBoxModel );
+        }
+    else
+        {
+        //User::Leave( syy?? )
+        }
+	iListBox->ActivateL();
+	((CMenuListBox*)iListBox)->SetPreviousFocus();
+
+    SetRect(aRect);
+    ActivateL();
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseOutputContainer::~CTestCaseOutputContainer
+// 
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CTestCaseOutputContainer::~CTestCaseOutputContainer()
+    {
+    // Discard and destroy the font
+    //CWindowGc* listBoxGc = iListBox->View()->ItemDrawer()->Gc();
+    //listBoxGc->DiscardFont();
+
+    //CWindowGc& gc = SystemGc();
+    //gc.DiscardFont();
+    
+    //iCoeEnv->ScreenDevice()->ReleaseFont(iListBoxFont);
+
+    delete iListBox;
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseOutputContainer::SizeChanged
+// 
+// Called by framework when the view size is changed.
+// ----------------------------------------------------------------------------
+//
+void CTestCaseOutputContainer::SizeChanged()
+    {
+    if ( iListBox )
+		{
+		iListBox->SetRect( Rect() ); // Sets rectangle of listbox.
+		}
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseOutputContainer::CountComponentControls
+// 
+// Gets a count of the component controls of this list box control.
+// ----------------------------------------------------------------------------
+//
+TInt CTestCaseOutputContainer::CountComponentControls() const
+    {
+    return 1; // return nbr of controls inside this container
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseOutputContainer::ComponentControl
+// 
+// Gets a pointer to the specified component control.
+// ----------------------------------------------------------------------------
+//
+CCoeControl* CTestCaseOutputContainer::ComponentControl(TInt aIndex) const
+    {
+    switch ( aIndex )
+        {
+		case 0: 
+			return iListBox;
+        default:
+            return NULL;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseOutputContainer::Draw
+// 
+// Draw a control, called by window server.
+// ----------------------------------------------------------------------------
+//
+void CTestCaseOutputContainer::Draw(const TRect& /*aRect*/) const
+    {
+    // CWindowGc& gc = SystemGc();
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseOutputContainer::HandleListBoxEventL
+// 
+// Handles list box events.
+// ----------------------------------------------------------------------------
+//
+void CTestCaseOutputContainer::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
+	{
+	if ( ( aEventType == EEventEnterKeyPressed ) || ( aEventType == EEventItemDoubleClicked ) )
+		{
+        //TBuf<200> outputLine;
+        //CAknNoteDialog* outputLineNote = new (ELeave) CAknNoteDialog;
+        //outputLineNote->SetTextL( iListBoxModel->MdcaPoint(iListBox->CurrentItemIndex()) );
+        //outputLineNote->RunDlgLD();
+
+
+
+        //CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
+        //informationNote->SetTextL( iListBoxModel->MdcaPoint(iListBox->CurrentItemIndex()) );
+		//informationNote->SetTextPluralityL( ETrue );
+        //informationNote->SetTextL( _L("Number of cases: %d") );
+        //informationNote->SetTextNumberL( count );
+        //informationNote->ExecuteLD();
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseOutputContainer::OfferKeyEventL
+// 
+// Handles key events.
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CTestCaseOutputContainer::OfferKeyEventL(
+	const TKeyEvent& aKeyEvent, TEventCode aType)
+{
+	if (aType != EEventKey)
+	{
+		return EKeyWasNotConsumed;
+	}
+
+	if (iListBox)
+		{
+		return iListBox->OfferKeyEventL( aKeyEvent, aType );
+		}
+	else
+		{
+		return EKeyWasNotConsumed;
+		}
+
+    /*
+    switch ( aKeyEvent.iCode )
+        {
+        case EKeyLeftArrow:
+        case EKeyRightArrow:
+			{ */  /* Left ja right key eventit valitetaan AppUille joka hoitaa siirtymisen toisiin nakymiin */
+    /*			return EKeyWasNotConsumed;
+            break;
+            }
+        default:
+			{
+			//Muut Key eventit valitetaan listboxille, joka hoitaa ne
+			if (iListBox)
+				{
+				return iListBox->OfferKeyEventL( aKeyEvent, aType );
+				}
+			else
+				{
+				return EKeyWasNotConsumed;
+				}
+            break;
+			}
+        }*/
+}
+
+// ----------------------------------------------------------------------------
+// CTestCaseOutputContainer::OutputUpdateL
+// 
+// Handles addition of item to list box.
+// ----------------------------------------------------------------------------
+//
+void CTestCaseOutputContainer::OutputUpdateL()
+    {
+    if ( iListBox )
+        {
+        iListBox->HandleItemAdditionL();
+        iListBox->DrawNow();
+        }
+    }
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ----------------------------------------------------------------------------
+// CTestOutputListBoxModel::NewL
+// 
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CTestOutputListBoxModel* CTestOutputListBoxModel::NewL(CStartedTestCase* aStartedTestCase /*, HBufC* aBuffer*/)
+    {
+
+    CTestOutputListBoxModel* self = new ( ELeave ) CTestOutputListBoxModel();
+    CleanupStack::PushL( self );
+    //self->ConstructL();
+    //self->iBuffer = aBuffer;
+    self->iBuffer = HBufC::NewL( 150 );
+    self->iStartedTestCase = aStartedTestCase;
+    CleanupStack::Pop();
+    return self;
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestOutputListBoxModel::ConstructL
+// 
+// Symbian OS two phased constructor.
+// Completes the construction of the object.
+// ----------------------------------------------------------------------------
+//
+void CTestOutputListBoxModel::ConstructL()
+    {
+    //iBuffer = HBufC::NewLC( KMaxInfoName + KMaxName + 2 );
+    }
+
+// ----------------------------------------------------------------------------
+// CTestOutputListBoxModel::~CTestCaseOutputContainer
+// 
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CTestOutputListBoxModel::~CTestOutputListBoxModel()
+    {
+    delete iBuffer;
+    }
+
+// ----------------------------------------------------------------------------
+// CTestOutputListBoxModel::MdcaCount
+// 
+// Returns the number of descriptor elements in the array.
+// ----------------------------------------------------------------------------
+//
+TInt CTestOutputListBoxModel::MdcaCount() const
+    {
+
+    TInt rows = iStartedTestCase->PrintArray().Count();
+    return rows;
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestOutputListBoxModel::MdcaPoint
+// 
+// Indexes into a descriptor array.
+// ----------------------------------------------------------------------------
+//
+TPtrC CTestOutputListBoxModel::MdcaPoint(TInt aIndex) const
+    {
+    const RPointerArray<CTestProgress> printArray = iStartedTestCase->PrintArray();
+
+    TPtr buffer( iBuffer->Des() );
+    buffer.Zero();
+    buffer.Append(_L("\t"));
+    buffer.Append(printArray[aIndex]->iDescription);
+    buffer.Append(_L(" "));
+    buffer.Append(printArray[aIndex]->iText);
+    
+    return *iBuffer;
+
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/TestCaseOutputView.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,380 @@
+/*
+* 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: This file contains CTestCaseOutputView class 
+* definition.
+*
+*/
+
+// INCLUDE FILES
+#include  <eikmenub.h>
+#include  <aknviewappui.h>
+#include  <akntitle.h>
+#include  <barsread.h>	//TResourceReader
+#include  <Stifui.rsg>
+
+//#include "UIStoreIf.h"         
+//#include "UIStore.h"            
+//#include "UIEngine.h"           
+//#include "UIEngineContainer.h"  
+
+#include <stifinternal/UIStoreIf.h>
+#include <stifinternal/UIStore.h>
+#include <stifinternal/UIEngine.h>
+#include <stifinternal/UIEngineContainer.h>
+
+#include  "TestCaseOutputView.h"
+#include  "TestCaseOutputContainer.h"
+#include  "AppUIAppUi.h"
+#include  "Stifui.hrh" 
+
+// ================= MEMBER FUNCTIONS =======================
+// ----------------------------------------------------------------------------
+// CTestCaseOutputView::ConstructL
+// 
+// Symbian OS two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+void CTestCaseOutputView::ConstructL()
+    {
+    CView::ConstructL();
+    BaseConstructL( R_APPUI_TESTCASEOUTPUTVIEW );
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseOutputView::~CTestCaseOutputView
+// 
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CTestCaseOutputView::~CTestCaseOutputView()
+    {
+    if ( iContainer )
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        }
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;
+    
+    iCurrentTestCase = NULL;
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseOutputView::Id
+// 
+// Returns view´s id.
+// ----------------------------------------------------------------------------
+//
+TUid CTestCaseOutputView::Id() const
+    {
+    return TUid::Uid(ETestCaseOutputViewId);
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseOutputView::HandleCommandL
+// 
+// Handles a command.
+// ----------------------------------------------------------------------------
+//
+void CTestCaseOutputView::HandleCommandL(TInt aCommand)
+    {   
+    switch ( aCommand )
+        {
+        case EAknSoftkeyBack:
+            {
+            AppUi()->HandleCommandL(EAppUIGoBack);
+            break;
+            }
+        case ECmdPauseTestCase:
+            {
+            /*
+            TInt index( 0 );
+			index = ( ( CAppUIAppUi* )AppUi() )->GetTestCaseIndex();
+             CStartedTestCase* startedTestCase = NULL;
+             TRAPD( ret, startedTestCase = &iUIStore->StartedTestCaseL( index ) );
+             if( ret != KErrNone )
+                 {
+                 // Leave
+                 }
+            */
+            CStartedTestCase* startedTestCase = 
+                ( ( CAppUIAppUi* )AppUi() )->GetStartedTestCase();
+            startedTestCase->UIEngineContainer().PauseTest(); 
+            break;
+            }
+        case ECmdResumeTestCase:
+            {
+            /*
+            TInt index( 0 );
+			index = ( ( CAppUIAppUi* )AppUi() )->GetTestCaseIndex();
+             CStartedTestCase* startedTestCase = NULL;
+             TRAPD( ret, startedTestCase = &iUIStore->StartedTestCaseL( index ) );
+             if( ret != KErrNone )
+                 {
+                 // Leave
+                 }
+            */
+            CStartedTestCase* startedTestCase = 
+                ( ( CAppUIAppUi* )AppUi() )->GetStartedTestCase();
+            startedTestCase->UIEngineContainer().ResumeTest();            
+            break;
+            }
+        case ECmdAbortTestCase:
+            {
+            /*
+            TInt index( 0 );
+			index = ( ( CAppUIAppUi* )AppUi() )->GetTestCaseIndex();
+             CStartedTestCase* startedTestCase = NULL;
+             TRAPD( ret, startedTestCase = &iUIStore->StartedTestCaseL( index ) );
+             if( ret != KErrNone )
+                 {
+                 // Leave
+                 }
+            */
+            CStartedTestCase* startedTestCase = 
+                ( ( CAppUIAppUi* )AppUi() )->GetStartedTestCase();
+            startedTestCase->UIEngineContainer().CancelTest();             
+            break;
+            }
+        default:
+            {
+            AppUi()->HandleCommandL( aCommand );
+            break;
+            }
+        }
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseOutputView::HandleClientRectChange
+// 
+// Handles client rect changes.
+// ----------------------------------------------------------------------------
+//
+void CTestCaseOutputView::HandleClientRectChange()
+    {
+    if ( iContainer )
+        {
+        iContainer->SetRect( ClientRect() );
+        }
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseOutputView::DoActivateL
+// 
+// Initializes view when activated.
+// ----------------------------------------------------------------------------
+//
+void CTestCaseOutputView::DoActivateL(
+   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
+   const TDesC8& /*aCustomMessage*/)
+    {
+    if (!iContainer)
+        {
+        iContainer = new (ELeave) CTestCaseOutputContainer;
+        iContainer->SetMopParent(this);
+
+        iCurrentTestCase = ( ( CAppUIAppUi* )AppUi() )->GetStartedTestCase();
+        iContainer->ConstructL( ClientRect(), iCurrentTestCase );
+        
+        AppUi()->AddToStackL( *this, iContainer );
+        }
+    PrintTestCaseStateL();
+	
+	CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane();
+	CAknNavigationControlContainer* np= (CAknNavigationControlContainer *)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
+	
+	TResourceReader reader;
+	iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_TESTCASE_OUTPUT);
+	iNaviDecorator = np->CreateNavigationLabelL( reader );
+	CleanupStack::PopAndDestroy(); // resource reader
+	np->PushL(*iNaviDecorator);
+	
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseOutputView::DoDeactivate
+// 
+// Deactivates view.
+// ----------------------------------------------------------------------------
+//
+void CTestCaseOutputView::DoDeactivate()
+    {
+    if ( iContainer )
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        iContainer = NULL;
+        }
+    
+    CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane();
+    // Because DoDeactivate method can't leave we must 
+    // catch unexpected leaves.
+	TInt ret = KErrNone;
+    TRAP( ret,
+    CAknTitlePane* tp=(CAknTitlePane*)sp->ControlL(TUid::Uid(EEikStatusPaneUidTitle));
+    if ( tp != NULL )
+    	{
+    	tp->SetTextToDefaultL(); // Set application name.
+    	}
+    ); // TRAPD end
+    
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;
+    
+    iCurrentTestCase = NULL;
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseOutputView::DynInitMenuPaneL
+// 
+// Initializes menu pane.
+// ----------------------------------------------------------------------------
+//
+void CTestCaseOutputView::DynInitMenuPaneL(
+    TInt aResourceId, CEikMenuPane* aMenuPane)
+    {
+    CStartedTestCase* startedTestCase = 
+        ( ( CAppUIAppUi* )AppUi() )->GetStartedTestCase();
+
+    if (R_APPUI_TESTCASEOUTPUTVIEW_MENU == aResourceId)
+        {
+  
+        if ( startedTestCase->Status() == CUIStoreIf::EStatusRunning )
+            {
+            if( startedTestCase->UIEngineContainer().State() == CUIEngineContainer::ENotStarted )
+                {
+                aMenuPane->SetItemDimmed( ECmdPauseTestCase, ETrue );
+                aMenuPane->SetItemDimmed( ECmdResumeTestCase, ETrue );
+                aMenuPane->SetItemDimmed( ECmdAbortTestCase, ETrue );
+                }
+            else if( startedTestCase->UIEngineContainer().State() == CUIEngineContainer::ERunning )
+                {
+                aMenuPane->SetItemDimmed( ECmdResumeTestCase, ETrue );
+                aMenuPane->SetItemDimmed( ECmdPauseTestCase, EFalse );
+                }
+            else if( startedTestCase->UIEngineContainer().State() == CUIEngineContainer::EPaused )
+                {
+                aMenuPane->SetItemDimmed( ECmdPauseTestCase, ETrue );
+                aMenuPane->SetItemDimmed( ECmdResumeTestCase, EFalse );
+                }
+            else if( startedTestCase->UIEngineContainer().State() == CUIEngineContainer::EExecuted )
+                {
+                aMenuPane->SetItemDimmed( ECmdPauseTestCase, ETrue );
+                aMenuPane->SetItemDimmed( ECmdResumeTestCase, ETrue );
+                aMenuPane->SetItemDimmed( ECmdAbortTestCase, ETrue );
+                }
+            else if( startedTestCase->UIEngineContainer().State() == CUIEngineContainer::EFinished )
+                {
+                aMenuPane->SetItemDimmed( ECmdPauseTestCase, ETrue );
+                aMenuPane->SetItemDimmed( ECmdResumeTestCase, ETrue );
+                aMenuPane->SetItemDimmed( ECmdAbortTestCase, ETrue );
+                }
+                                                                                     
+            }
+		else
+            {
+            aMenuPane->SetItemDimmed( ECmdPauseTestCase, ETrue );
+            aMenuPane->SetItemDimmed( ECmdResumeTestCase, ETrue );
+            aMenuPane->SetItemDimmed( ECmdAbortTestCase, ETrue );
+            }
+        }
+        
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseOutputView::OutputUpdate
+// 
+// Receives output update notification from AppUI.
+// ----------------------------------------------------------------------------
+//
+void CTestCaseOutputView::OutputUpdateL( CStartedTestCase* /*aTestCase*/ )
+    {
+    PrintTestCaseStateL();
+    iContainer->OutputUpdateL();
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseOutputView::TestCaseStateChangedL
+// 
+// Receives test case state changed notification from AppUI.
+// ----------------------------------------------------------------------------
+//
+void CTestCaseOutputView::TestCaseStateChangedL()
+    {
+    PrintTestCaseStateL();
+    iContainer->OutputUpdateL();
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestCaseOutputView::PrintTestCaseState
+// 
+// Prints test case state to title pane.
+// ----------------------------------------------------------------------------
+//
+void CTestCaseOutputView::PrintTestCaseStateL()
+    {
+    TBuf<50> statusMessage;
+    CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane();
+    CAknTitlePane* tp=(CAknTitlePane*)sp->ControlL(TUid::Uid(EEikStatusPaneUidTitle));
+
+    if ( iCurrentTestCase != NULL )
+        {
+        TUint status = iCurrentTestCase->Status();
+
+        if( status & CUIStoreIf::EStatusRunning )
+            {
+            CEikonEnv::Static()->ReadResource( statusMessage,
+                R_TESTCASE_STATE_RUNNING );
+            }
+        else if( status & CUIStoreIf::EStatusExecuted && 
+                            status & CUIStoreIf::EStatusPassed )
+            {
+            CEikonEnv::Static()->ReadResource( statusMessage, 
+                R_TESTCASE_STATE_PASSED );
+            }
+        else if( status & CUIStoreIf::EStatusExecuted && 
+                            status & CUIStoreIf::EStatusFailed )
+            {
+            CEikonEnv::Static()->ReadResource( statusMessage, 
+                R_TESTCASE_STATE_FAILED );
+            }
+        else if( status & CUIStoreIf::EStatusAborted )
+            {
+            CEikonEnv::Static()->ReadResource( statusMessage, 
+                R_TESTCASE_STATE_CRASHED_ABORTED );
+            }
+        else if( status & CUIStoreIf::EStatusCrashed )
+            {
+            CEikonEnv::Static()->ReadResource( statusMessage, 
+                R_TESTCASE_STATE_CRASHED_ABORTED );
+            }
+        else
+            {
+            CEikonEnv::Static()->ReadResource( statusMessage, 
+                R_TESTCASE_STATE_UNKNOWN );
+            }
+        
+        tp->SetTextL( statusMessage );
+        tp->DrawNow();
+
+        }
+
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/TestModulesMenuContainer.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,310 @@
+/*
+* 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: This file contains CTestModulesListBoxModel class
+* definition.
+*
+*/
+
+// INCLUDE FILES
+#include <aknlists.h>  // ListBox
+#include <barsread.h> // for TResourceReader
+#include <aknnotewrappers.h>
+
+#include "Stifui.hrh"
+#include <Stifui.rsg>
+
+//#include "UIStoreIf.h"         
+//#include "UIStore.h"            
+//#include "UIEngine.h"           
+//#include "UIEngineContainer.h"  
+
+#include <stifinternal/UIStoreIf.h>
+#include <stifinternal/UIStore.h>
+#include <stifinternal/UIEngine.h>
+#include <stifinternal/UIEngineContainer.h>
+
+#include "TestModulesMenuContainer.h"
+#include "AppUIAppUi.h"
+
+#include "MenuListBox.h"
+
+// ================= MEMBER FUNCTIONS =======================
+// ----------------------------------------------------------------------------
+// CTestModulesListBoxModel::NewL
+// 
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CTestModulesListBoxModel* CTestModulesListBoxModel::NewL(RRefArray<TDesC> aTestModules)
+    {
+
+    CTestModulesListBoxModel* self = new ( ELeave ) CTestModulesListBoxModel();
+    CleanupStack::PushL( self );
+    self->iBuffer = HBufC::NewL( 130 );
+    self->iTestModules = aTestModules;
+    CleanupStack::Pop();
+    return self;
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestModulesListBoxModel::ConstructL
+// 
+// Symbian OS two phased constructor.
+// Completes the construction of the object.
+// ----------------------------------------------------------------------------
+//
+void CTestModulesListBoxModel::ConstructL()
+    {
+    //iBuffer = HBufC::NewLC( KMaxInfoName + KMaxName + 2 );
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestModulesListBoxModel::~CTestCaseOutputView
+// 
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CTestModulesListBoxModel::~CTestModulesListBoxModel()
+    {
+    delete iBuffer;
+    
+    }
+
+// ----------------------------------------------------------------------------
+// CTestModulesListBoxModel::MdcaCount
+// 
+// Returns the number of descriptor elements in the array.
+// ----------------------------------------------------------------------------
+//
+TInt CTestModulesListBoxModel::MdcaCount() const
+    {
+    return iTestModules.Count();
+    }
+
+// ----------------------------------------------------------------------------
+// CTestModulesListBoxModel::MdcaPoint
+// 
+// Indexes into a descriptor array.
+// ----------------------------------------------------------------------------
+//
+TPtrC CTestModulesListBoxModel::MdcaPoint(TInt aIndex) const
+    {
+    TPtrC testModule = (iTestModules)[aIndex];
+    TPtr buffer( iBuffer->Des() );
+    buffer.Zero();
+
+    buffer.Append(_L("\t"));
+    buffer.Append( testModule );
+    
+    return *iBuffer;
+    
+    }
+
+// ----------------------------------------------------------------------------
+// CTestModulesMenuContainer::ConstructL
+// 
+// Symbian OS two phased constructor.
+// ----------------------------------------------------------------------------
+//
+void CTestModulesMenuContainer::ConstructL(const TRect& aRect, MEikListBoxObserver* aListBoxObserver)
+    {
+    _LIT( KErrMessage, "Error loading modules! Check Test engine log.");
+    CreateWindowL();
+
+  	iListBox = CMenuListBox::NewL(ETestModulesMenuViewId);
+	iListBox->SetContainerWindowL( *this );
+	iListBox->SetListBoxObserver( aListBoxObserver /*this*/ ); // jos peritty MEikListBoxObserver:sta
+    iListBox->ConstructL(this, EAknListBoxSelectionList /*EAknListBoxMarkableList*/ );
+        ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("StartCasesContainer: ListBox constructed"));
+
+    //Create Scroller control for ListBox and set its visibility
+    iListBox->CreateScrollBarFrameL(ETrue);
+    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
+
+    iUIStore = ( (CAppUIAppUi*)iCoeEnv->AppUi() )->UIStoreHandler();
+
+    if( iUIStore )
+        {
+        /*const CFixedFlatArray<TTestInfo>& allCases = iData->AllCases();
+        const TInt KTestCaseCount = allCases.Count();
+        for (TInt i=0; i < KTestCaseCount; i++)
+            {
+            iTestCasesInView.Append(&(allCases[i]));
+            } */
+
+        //RRefArray<TDesC> modules;
+        TInt ret = iUIStore->Modules( iModules );
+        if( ret != KErrNone )
+            {
+             //iModules.Reset();
+             //iModules.Close();
+			TMessageBoxUtil::ShowErrorNoteL( KErrMessage );
+            }
+       
+        iListBoxModel = CTestModulesListBoxModel::NewL( iModules );
+        ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("StartCasesContainer: ListBox model"));
+
+
+         iListBox->Model()->SetItemTextArray(iListBoxModel);
+        ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("StartCasesContainer: ListBox model set"));
+        
+        }
+    else
+        {
+        // General error becouse UIStore should be opened in AppUI when
+        // program starts.
+        User::Leave( KErrGeneral );
+        }
+
+    iListBox->ActivateL();
+    ((CMenuListBox*)iListBox)->SetPreviousFocus();
+    SetRect(aRect);
+    ActivateL();
+    }
+
+// ----------------------------------------------------------------------------
+// CTestModulesMenuContainer::~CTestCaseOutputView
+// 
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CTestModulesMenuContainer::~CTestModulesMenuContainer()
+    {
+    
+		iModules.Reset();
+        iModules.Close();
+
+	if( iListBox )
+		{
+		delete iListBox;
+		iListBox = NULL;
+		}
+		
+	}
+
+// ----------------------------------------------------------------------------
+// CTestModulesMenuContainer::SizeChanged
+// 
+// Called by framework when the view size is changed.
+// ----------------------------------------------------------------------------
+//
+void CTestModulesMenuContainer::SizeChanged()
+    {
+    if ( iListBox )
+		{
+		iListBox->SetRect( Rect() ); // Sets rectangle of listbox.
+		}
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestModulesMenuContainer::CountComponentControls
+// 
+// Gets a count of the component controls of this list box control.
+// ----------------------------------------------------------------------------
+//
+TInt CTestModulesMenuContainer::CountComponentControls() const
+    {
+    return 1; // return nbr of controls inside this container
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestModulesMenuContainer::ComponentControl
+// 
+// Gets a pointer to the specified component control.
+// ----------------------------------------------------------------------------
+//
+CCoeControl* CTestModulesMenuContainer::ComponentControl(TInt aIndex) const
+    {
+    switch ( aIndex )
+        {
+		case 0: 
+			return iListBox;
+        default:
+            return NULL;
+        }
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestModulesMenuContainer::Draw
+// 
+// Draw a control, called by window server.
+// ----------------------------------------------------------------------------
+//
+void CTestModulesMenuContainer::Draw(const TRect& /*aRect*/) const
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CTestModulesMenuContainer::OfferKeyEventL
+// 
+// Handles key events.
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CTestModulesMenuContainer::OfferKeyEventL(
+	const TKeyEvent& aKeyEvent, TEventCode aType)
+    {
+	if (aType != EEventKey)
+	    {
+		return EKeyWasNotConsumed;
+	    }
+
+    switch ( aKeyEvent.iCode )
+        {
+        case EKeyLeftArrow:
+        case EKeyRightArrow:
+			{   /* Left ja right key eventit valitetaan AppUille joka hoitaa siirtymisen toisiin nakymiin */
+			return EKeyWasNotConsumed;
+            //break;
+            }
+        default:
+			{
+			//Muut Key eventit valitetaan listboxille, joka hoitaa ne
+			if (iListBox)
+				{
+				return iListBox->OfferKeyEventL( aKeyEvent, aType );
+				}
+			}
+        }
+    return EKeyWasNotConsumed;
+    }
+
+// ----------------------------------------------------------------------------
+// CTestModulesMenuContainer::CurrentItemIndex
+// 
+// Returns current item index in list box.
+// ----------------------------------------------------------------------------
+//
+TInt CTestModulesMenuContainer::CurrentItemIndex()
+    {
+    return iListBox->CurrentItemIndex();
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestModulesMenuContainer::SaveActiveLine
+//
+// Makes the iListBox member save its focus position
+// ----------------------------------------------------------------------------
+//
+void CTestModulesMenuContainer::SaveActiveLine()
+	{
+	((CMenuListBox*)iListBox)->SaveFocusPosition();
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/TestSetBaseMenuContainer.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,188 @@
+/*
+* 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: This file contains CTestSetBaseMenuContainer class 
+* definition.
+*
+*/
+
+// INCLUDE FILES
+#include "TestSetBaseMenuContainer.h"
+#include "Stifui.hrh"
+
+#include <Stifui.rsg>
+
+#include <aknlists.h>  //ListBox
+#include <barsread.h> // for TResourceReader
+
+#include <aknnotewrappers.h>
+
+#include "MenuListBox.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+// ----------------------------------------------------------------------------
+// CTestSetBaseMenuContainer::ConstructL
+// 
+// Symbian OS two phased constructor.
+// ----------------------------------------------------------------------------
+//
+void CTestSetBaseMenuContainer::ConstructL(const TRect& aRect, MEikListBoxObserver* aListBoxObserver)
+    {
+    CreateWindowL();
+     
+	iListBox = CMenuListBox::NewL(ETestSetMenuViewId);
+	iListBox->SetContainerWindowL( *this );
+	TResourceReader reader;
+	iCoeEnv->CreateResourceReaderLC( reader, R_TESTSETBASE_MENU_LISTBOX );
+	iListBox->SetListBoxObserver( aListBoxObserver );
+	iListBox->ConstructFromResourceL( reader );
+	CleanupStack::PopAndDestroy(); // resource stuffs. 
+
+    // Create Scroller control for ListBox and set its visibility
+    // !!! Not needed yet because there are only two items in list box.
+    // If items are added later, scroller may be taken to use
+    //iListBox->CreateScrollBarFrameL(ETrue);
+    //iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
+    
+    iListBox->ActivateL();
+    ((CMenuListBox*)iListBox)->SetPreviousFocus();
+    
+    SetRect(aRect);
+    ActivateL();
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetBaseMenuContainer::~CTestSetBaseMenuContainer
+// 
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CTestSetBaseMenuContainer::~CTestSetBaseMenuContainer()
+    {
+    if ( iListBox )
+		{
+		iListBox->Reset();
+    	delete iListBox;
+    	}	
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetBaseMenuContainer::SizeChanged
+// 
+// Called by framework when the view size is changed.
+// ----------------------------------------------------------------------------
+//
+void CTestSetBaseMenuContainer::SizeChanged()
+    {
+    if ( iListBox )
+		{
+		iListBox->SetRect( Rect() ); // Sets rectangle of listbox.
+		}
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetBaseMenuContainer::CountComponentControls
+// 
+// Gets a count of the component controls of this list box control.
+// ----------------------------------------------------------------------------
+//
+TInt CTestSetBaseMenuContainer::CountComponentControls() const
+    {
+    return 1; // return nbr of controls inside this container
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetBaseMenuContainer::ComponentControl
+// 
+// Gets a pointer to the specified component control.
+// ----------------------------------------------------------------------------
+//
+CCoeControl* CTestSetBaseMenuContainer::ComponentControl(TInt aIndex) const
+    {
+    switch ( aIndex )
+        {
+		case 0: 
+			return iListBox;
+        default:
+            return NULL;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetBaseMenuContainer::Draw
+// 
+// Draw a control, called by window server.
+// ----------------------------------------------------------------------------
+//
+void CTestSetBaseMenuContainer::Draw(const TRect& /*aRect*/) const
+    {
+    // CWindowGc& gc = SystemGc();
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetBaseMenuContainer::OfferKeyEventL
+// 
+// Handles key events..
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CTestSetBaseMenuContainer::OfferKeyEventL(
+	const TKeyEvent& aKeyEvent, TEventCode aType)
+    {
+	if (aType != EEventKey)
+	{
+		return EKeyWasNotConsumed;
+	}
+	
+    switch ( aKeyEvent.iCode )
+        {
+        case EKeyLeftArrow:
+        case EKeyRightArrow:
+			{   /* Left ja right key eventit valitetaan AppUille joka hoitaa siirtymisen toisiin nakymiin */
+			return EKeyWasNotConsumed;
+            //break;
+            }
+        default:
+			{
+			//Muut Key eventit valitetaan listboxille, joka hoitaa ne
+			if (iListBox)
+				{
+				return iListBox->OfferKeyEventL( aKeyEvent, aType );
+				}
+	    	}
+        }     
+    return EKeyWasNotConsumed;        
+}
+
+// ----------------------------------------------------------------------------
+// CTestSetBaseMenuContainer::GetActiveLine
+// 
+// Get currently selected items index.
+// ----------------------------------------------------------------------------
+//
+TInt CTestSetBaseMenuContainer::GetActiveLine()
+	{
+	return iListBox->CurrentItemIndex();
+	}
+
+// ----------------------------------------------------------------------------
+// CTestSetBaseMenuContainer::SaveActiveLine
+//
+// Makes the iListBox member save its focus position
+// ----------------------------------------------------------------------------
+//
+void CTestSetBaseMenuContainer::SaveActiveLine()
+	{
+	((CMenuListBox*)iListBox)->SaveFocusPosition();
+	}
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/TestSetBaseMenuView.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,200 @@
+/*
+* 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: This file contains CTestSetBaseMenuView class
+* definition.
+*
+*/
+
+// INCLUDE FILES
+#include  <aknviewappui.h>
+#include  <aknlists.h> 
+#include  <barsread.h>	//TResourceReader
+#include  <Stifui.rsg>
+#include  "TestSetBaseMenuView.h"
+#include  "TestSetBaseMenuContainer.h"
+#include  "Stifui.hrh" 
+#include  "AppUIAppUi.h" // loggerin kayttoa varten, muuten ei tarvittaisi
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CTestSetBaseMenuView::ConstructL
+// 
+// Symbian OS two-phased constructor.
+// ---------------------------------------------------------
+//
+void CTestSetBaseMenuView::ConstructL()
+    {
+    CView::ConstructL();
+    BaseConstructL( R_APPUI_TESTSETBASEMENUVIEW );
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetBaseMenuView::~CTestSetBaseMenuView
+// 
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CTestSetBaseMenuView::~CTestSetBaseMenuView()
+    {
+    if ( iContainer )
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        iContainer = NULL;
+        }
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetBaseMenuView::Id
+// 
+// Returns view´s id.
+// ----------------------------------------------------------------------------
+//
+TUid CTestSetBaseMenuView::Id() const
+    {
+    return TUid::Uid(ETestSetBaseMenuViewId); //KTestSetBaseMenuViewId;
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetBaseMenuView::HandleCommandL
+// 
+// Handles a command.
+// ----------------------------------------------------------------------------
+//
+void CTestSetBaseMenuView::HandleCommandL(TInt aCommand)
+    {   
+    switch ( aCommand )
+        {
+        case EAknSoftkeyBack:
+            {
+            AppUi()->HandleCommandL(EAppUIGoBack);
+            break;
+            }
+		case EAknCmdOpen:
+			{
+			break;
+			}
+		case ECmdCreateTestSet:
+            {
+            AppUi()->HandleCommandL(ECmdCreateTestSet);
+            break;
+            }
+		case ECmdLoadTestSet:
+            {
+            AppUi()->HandleCommandL(ECmdLoadTestSet);
+            break;
+            }
+        default:
+            {
+            AppUi()->HandleCommandL( aCommand );
+            break;
+            }
+        }
+    }
+
+
+// ----------------------------------------------------------------------------
+// CTestSetBaseMenuView::HandleListBoxEventL
+// 
+// Handles a list box event.
+// ----------------------------------------------------------------------------
+//
+void CTestSetBaseMenuView::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType)
+	{
+	if ( ( aEventType == EEventEnterKeyPressed ) || ( aEventType == EEventItemDoubleClicked ) )
+		{
+	    switch ( aListBox->CurrentItemIndex() )
+			{
+		    case 0:
+		    	HandleCommandL( ECmdCreateTestSet );
+				break;
+			case 1:
+				HandleCommandL( ECmdLoadTestSet );
+				break;
+			}
+		}
+	}
+	
+		
+// ----------------------------------------------------------------------------
+// CTestSetBaseMenuView::HandleClientRectChange
+// 
+// Handles client rect changes.
+// ----------------------------------------------------------------------------
+//
+void CTestSetBaseMenuView::HandleClientRectChange()
+    {
+    if ( iContainer )
+        {
+        iContainer->SetRect( ClientRect() );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetBaseMenuView::DoActivateL
+// 
+// Initializes view when activated.
+// ----------------------------------------------------------------------------
+//
+void CTestSetBaseMenuView::DoActivateL(
+   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
+   const TDesC8& /*aCustomMessage*/)
+    {
+    if (!iContainer)
+        {
+        ((CAppUIAppUi*)AppUi())->iLogger->Log(_L("TestSetBaseMenu: DoActivateL"));
+        //message = _L("eng.open ret:");
+        //message.AppendNum( ret , EDecimal );
+        //AppUi->iLogger->Log( message );
+        iContainer = new (ELeave) CTestSetBaseMenuContainer;
+        iContainer->SetMopParent(this);
+        iContainer->ConstructL( ClientRect(), this );
+        ((CAppUIAppUi*)AppUi())->iLogger->Log(_L("TestSetBaseMenu: container constructed"));
+        AppUi()->AddToStackL( *this, iContainer );
+        } 
+	
+    CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane();
+	CAknNavigationControlContainer* np= (CAknNavigationControlContainer *)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
+	
+	TResourceReader reader;
+	iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_TESTSET_BASE);
+	iNaviDecorator = np->CreateNavigationLabelL( reader );
+	CleanupStack::PopAndDestroy(); // resource reader
+	np->PushL(*iNaviDecorator);
+
+   }
+
+// ----------------------------------------------------------------------------
+// CTestSetBaseMenuView::DoDeactivate
+// 
+// Deactivates view.
+// ----------------------------------------------------------------------------
+//
+void CTestSetBaseMenuView::DoDeactivate()
+    {
+    if ( iContainer )
+        {
+        iContainer->SaveActiveLine();
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        iContainer = NULL;         
+        }    
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;    
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/TestSetInsertMenuContainer.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -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: This file contains CTestSetInsertMenuContainer class
+* definition.
+*
+*/
+
+// INCLUDE FILES 
+#include <aknlists.h>  // ListBox
+#include <akniconarray.h> // CAknIconArray
+#include <aknnotewrappers.h>
+
+#include <eikclbd.h> // CColumnListBoxData
+
+#include "TestSetInsertMenuContainer.h"
+#include "TestSetInsertMenuView.h"
+#include <Stifui.rsg>
+#include "Stifui.hrh"
+#include "AppUIAppUi.h"
+
+#include "MenuListBox.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+// ----------------------------------------------------------------------------
+// CTestSetInsertMenuContainer::ConstructL
+// 
+// Symbian OS two phased constructor.
+// ----------------------------------------------------------------------------
+//
+void CTestSetInsertMenuContainer::ConstructL(const TRect& aRect, MEikListBoxObserver* aListBoxObserver)
+    {
+    ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("TestSetInsertMenuContainer: ConstructL"));
+
+	iParentView = (CTestSetInsertMenuView*)aListBoxObserver;
+    CreateWindowL();
+
+    iUIStore = ( (CAppUIAppUi*)iCoeEnv->AppUi() )->UIStoreHandler();
+
+    iTestCasesInView.Reset();
+        //((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("TestSetInsertMenuContainer: iTCInV Reset"));
+    
+	iListBox = CMenuListBox::NewL(ETestSetInsertMenuViewId);
+	iListBox->SetContainerWindowL( *this );
+	iListBox->SetListBoxObserver( aListBoxObserver /*this*/ ); // jos peritty MEikListBoxObserver:sta
+    iListBox->ConstructL(this, EAknListBoxMarkableList /*EAknListBoxSelectionList*/);
+
+    ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("TestSetInsertMenuContainer: ListBox constructed"));
+
+    //Create Scroller control for ListBox and set its visibility
+    iListBox->CreateScrollBarFrameL(ETrue);
+    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
+    iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
+
+    if ( iUIStore )
+        {
+        RRefArray<CTestInfo> allCases;
+        TInt ret = iUIStore->TestCases( allCases );
+        if( KErrNone != ret )
+            {
+            ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("iUIStore->TestCases() fails"));
+            allCases.Reset();
+            allCases.Close();
+            User::Leave( ret );
+            }
+
+        const TInt KTestCaseCount = allCases.Count();
+        for (TInt i=0; i < KTestCaseCount; i++)
+            {
+            iTestCasesInView.Append( &allCases[i] );
+            }
+
+        iListBoxModel = CTestCaseListBoxModel::NewL(&iTestCasesInView);
+             ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("TestSetInsertMenuContainer: ListBox model"));
+
+        iListBox->Model()->SetItemTextArray(iListBoxModel);
+             ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("TestSetInsertMenuContainer: ListBox model set"));
+
+        allCases.Reset();
+        allCases.Close();
+        }
+    else
+        {
+        //User::Leave( syy?? )
+        }
+
+    // Creates graphic.
+    SetGraphicIconL( iListBox );
+       ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("TestSetInsertMenuContainer: icons created"));
+
+    iListBox->ActivateL();
+    ((CMenuListBox*)iListBox)->SetPreviousFocus();
+
+    SetRect(aRect);
+    ActivateL();
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetInsertMenuContainer::~CTestSetInsertMenuContainer
+// 
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CTestSetInsertMenuContainer::~CTestSetInsertMenuContainer()
+    {
+    //iTestCasesInView.Close(); // does not delete objects whose pointers are contained in the array
+    //delete iListBox;
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetInsertMenuContainer::SizeChanged
+// 
+// Called by framework when the view size is changed.
+// ----------------------------------------------------------------------------
+//
+void CTestSetInsertMenuContainer::SizeChanged()
+    {
+    if ( iListBox )
+		{
+		iListBox->SetRect( Rect() ); // Sets rectangle of listbox.
+		}
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetInsertMenuContainer::CountComponentControls
+// 
+// Gets a count of the component controls of this list box control.
+// ----------------------------------------------------------------------------
+//
+TInt CTestSetInsertMenuContainer::CountComponentControls() const
+    {
+    return 1; // return nbr of controls inside this container
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetInsertMenuContainer::ComponentControl
+// 
+// Gets a pointer to the specified component control.
+// ----------------------------------------------------------------------------
+//
+CCoeControl* CTestSetInsertMenuContainer::ComponentControl(TInt aIndex) const
+    {
+    switch ( aIndex )
+        {
+		case 0: 
+			return iListBox;
+        default:
+            return NULL;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetInsertMenuContainer::Draw
+// 
+// Draw a control, called by window server.
+// ----------------------------------------------------------------------------
+//
+void CTestSetInsertMenuContainer::Draw(const TRect& /*aRect*/) const
+    {
+    // CWindowGc& gc = SystemGc();
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetInsertMenuContainer::OfferKeyEventL
+// 
+// Handles key events.
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CTestSetInsertMenuContainer::OfferKeyEventL(
+	const TKeyEvent& aKeyEvent, TEventCode aType )
+    {
+	if (aType != EEventKey)
+	    {
+		return EKeyWasNotConsumed;
+	    }
+
+	if (iListBox)
+		{
+		//if multiple items selected
+		if ( iListBox->SelectionIndexes()->Count() > 0 )
+			{
+			TUint mask = 0x40488;
+			
+			//if event is enter key,
+			//don´t send it to listbox
+			if ( aKeyEvent.iScanCode == 0xa7 
+				&& ( aKeyEvent.iModifiers & mask ) == 0 )
+				{
+				iParentView->HandleListBoxEventL( iListBox, MEikListBoxObserver::EEventEnterKeyPressed );
+				return EKeyWasConsumed;	
+				}
+			}
+			
+		return iListBox->OfferKeyEventL( aKeyEvent, aType );
+		}
+	else
+		{
+		return EKeyWasNotConsumed;
+		}
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetInsertMenuContainer::SaveActiveLine
+//
+// Makes the iListBox member save its focus position
+// ----------------------------------------------------------------------------
+//
+void CTestSetInsertMenuContainer::SaveActiveLine()
+	{
+	((CMenuListBox*)iListBox)->SaveFocusPosition();
+	}
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/TestSetInsertMenuView.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,399 @@
+/*
+* 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: This file contains CTestSetInsertMenuView class
+* definition.
+*
+*/
+
+// INCLUDE FILES
+#include  <eikmenub.h>
+#include  <aknviewappui.h>
+#include  <aknlistquerydialog.h> 
+#include  <aknnotewrappers.h>
+#include  <barsread.h>	//TResourceReader
+#include  <Stifui.rsg>
+#include  "TestSetInsertMenuView.h"
+#include  "TestSetInsertMenuContainer.h"
+#include  "TestSetMenuView.h"
+#include  "AppUIAppUi.h"
+#include  "Stifui.hrh" 
+
+
+// ================= MEMBER FUNCTIONS =======================
+// ----------------------------------------------------------------------------
+// CTestSetInsertMenuView::ConstructL
+// 
+// Symbian OS two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+void CTestSetInsertMenuView::ConstructL()
+    {
+    CView::ConstructL();
+    BaseConstructL(  R_INSERT_TESTCASES_VIEW );
+    iCurrentTestCase = 0;
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetInsertMenuView::~CTestSetInsertMenuView
+// 
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CTestSetInsertMenuView::~CTestSetInsertMenuView()
+    {
+    if ( iContainer )
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        }
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetInsertMenuView::Id
+// 
+// Returns view´s id.
+// ----------------------------------------------------------------------------
+//
+TUid CTestSetInsertMenuView::Id() const
+    {
+    return TUid::Uid(ETestSetInsertMenuViewId);
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetInsertMenuView::HandleCommandL
+// 
+// Handles a command.
+// ----------------------------------------------------------------------------
+//
+void CTestSetInsertMenuView::HandleCommandL(TInt aCommand)
+    {   
+    if ( aCommand >= ECmdFilterByModule && aCommand < ECmdFilterByTestCaseFile ) // 0x1000 - 0x1FFF
+        {
+        TInt moduleNumber = aCommand - ECmdFilterByModule;
+        RRefArray<TDesC> allModules;
+        TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->Modules( allModules );
+        if( KErrNone != ret )
+            {
+            allModules.Reset();
+            allModules.Close();
+            User::Leave( ret );
+            }
+        TName moduleName = allModules[ moduleNumber ];
+
+        iContainer->FilterCasesByModuleL( moduleName );
+
+        allModules.Reset();
+        allModules.Close();
+        }
+	else if ( aCommand >= ECmdFilterByTestCaseFile && aCommand < ECmdNOFiltering )
+        {
+        TInt testCaseFileNumber = aCommand - ECmdFilterByTestCaseFile;
+        RRefArray<TDesC> allTestCases;
+        TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->TestCaseFiles( allTestCases );
+        if( KErrNone != ret )
+            {
+            allTestCases.Reset();
+            allTestCases.Close();
+            User::Leave( ret );
+            }
+        TFileName testCaseFileName = allTestCases[ testCaseFileNumber ];
+
+        iContainer->FilterCasesByTCFileNameL( testCaseFileName );
+
+        allTestCases.Reset();
+        allTestCases.Close();
+        }
+	else if ( aCommand == ECmdNOFiltering )
+        {
+        iContainer->NoFilteringL();
+        }
+    else if ( aCommand == EAknCmdMark || aCommand == EAknCmdUnmark 
+    	|| aCommand == EAknMarkAll || aCommand == EAknUnmarkAll )
+    	{
+    	iContainer->HandleMarkCommandL( aCommand );
+    	}
+    else
+	    {
+ 	    switch ( aCommand )
+	        {
+	        case ECmdInsertSelectedCases:
+	            {
+                ShowInsertCasesDialogL();
+	            break;
+	            }
+	        case EAknSoftkeyCancel:
+	            {
+	            //iCurrentTestCase = 0;
+	            ( (CEikAppUi*)iCoeEnv->AppUi() )->HandleCommandL(EAppUIGoToTestSetsMenu);
+	            break;
+	            }
+	        default:
+	            {
+	            AppUi()->HandleCommandL( aCommand );
+	            break;
+	            }
+	        }
+	    }
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetInsertMenuView::HandleClientRectChange
+// 
+// Handles client rect changes.
+// ----------------------------------------------------------------------------
+//
+void CTestSetInsertMenuView::HandleClientRectChange()
+    {
+    if ( iContainer )
+        {
+        iContainer->SetRect( ClientRect() );
+        }
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetInsertMenuView::DoActivateL
+// 
+// Initializes view when activated.
+// ----------------------------------------------------------------------------
+//
+void CTestSetInsertMenuView::DoActivateL(
+   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
+   const TDesC8& /*aCustomMessage*/)
+    {
+    if (!iContainer)
+        {
+           ((CAppUIAppUi*)AppUi())->iLogger->Log(_L("TestSetInsertMenuView: DoActivateL"));
+        //message = _L("eng.open ret:");
+        //message.AppendNum( ret , EDecimal );
+        //AppUi()->iLogger->Log( message );
+        iContainer = new (ELeave) CTestSetInsertMenuContainer;
+        iContainer->SetMopParent(this);
+        iContainer->ConstructL( ClientRect(), this );
+           ((CAppUIAppUi*)AppUi())->iLogger->Log(_L("TestSetInsertMenuView: container constructed"));
+        AppUi()->AddToStackL( *this, iContainer );
+        }
+   
+   //testing
+    iContainer->SetCurrentItemIndex(iCurrentTestCase);
+	
+	CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane();
+	CAknNavigationControlContainer* np= (CAknNavigationControlContainer *)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
+	
+	TResourceReader reader;
+	iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_TESTSET_INSERT);
+	iNaviDecorator = np->CreateNavigationLabelL( reader );
+	CleanupStack::PopAndDestroy(); // resource reader
+	np->PushL(*iNaviDecorator);
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetInsertMenuView::DoDeactivate
+// 
+// Deactivates view.
+// ----------------------------------------------------------------------------
+//
+void CTestSetInsertMenuView::DoDeactivate()
+    {
+    if ( iContainer )
+        {
+        iContainer->SaveActiveLine();
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        iContainer = NULL;
+        }
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetInsertMenuView::DynInitMenuPaneL
+// 
+// Initializes menu pane.
+// ----------------------------------------------------------------------------
+//
+void CTestSetInsertMenuView::DynInitMenuPaneL(
+    TInt aResourceId, CEikMenuPane* aMenuPane)
+    {
+
+    // Test modules are added to filter by test module submenu if the submenu is opened
+    if (R_APPUI_FILTERBYMODULES_MENU == aResourceId)
+        {
+        RRefArray<TDesC> modules;
+        TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->Modules( modules );
+        if( KErrNone != ret )
+            {
+            modules.Reset();
+            modules.Close();
+            User::Leave( ret );
+            }
+
+        TInt moduleCount = modules.Count();
+        
+        TInt i;
+        CEikMenuPaneItem::SData item;
+
+        item.iCommandId = ECmdFilterByModule;
+        item.iFlags = 0;
+        item.iCascadeId = 0;
+
+        for (i = 0; i < moduleCount; i++)
+            {
+            //item.iText = modules[i].iModuleName;
+            item.iText = modules[i];
+            aMenuPane->AddMenuItemL(item);
+            item.iCommandId++; // command IDs 0x1000 - 0x1FFF are reserved for modules in hrh file
+            }
+        
+        modules.Reset();
+        modules.Close();
+
+        }
+
+    // Test case files are added to filter by test case file submenu if the submenu is opened
+    if (R_APPUI_FILTER_BY_TESTCASEFILE_MENU == aResourceId)
+        {
+        RRefArray<TDesC> testCaseFiles;
+        TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->TestCaseFiles( testCaseFiles );
+        if( KErrNone != ret )
+            {
+            testCaseFiles.Reset();
+            testCaseFiles.Close();
+            User::Leave( ret );
+            }
+
+        TInt testCaseFileCount = testCaseFiles.Count();
+
+        TInt i;
+        CEikMenuPaneItem::SData item;
+
+        item.iCommandId = ECmdFilterByTestCaseFile;
+        item.iFlags = 0;
+        item.iCascadeId = 0;
+
+        for (i = 0; i < testCaseFileCount; i++)
+            {
+            item.iText = testCaseFiles[i];
+            aMenuPane->AddMenuItemL(item);
+            item.iCommandId++; // command IDs 0x2000 - 0x2FFF are reserved for test case files in hrh file
+            }
+        }
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetInsertMenuView::HandleListBoxEventL
+// 
+// Handles listbox events.
+// ----------------------------------------------------------------------------
+//
+void CTestSetInsertMenuView::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
+	{
+
+	if ( ( aEventType == EEventEnterKeyPressed ) || ( aEventType == EEventItemDoubleClicked ) )
+		{
+        ShowInsertCasesDialogL();
+		}
+		
+	}
+
+// ----------------------------------------------------------------------------
+// CTestSetInsertMenuView::ShowInsertCasesDialogL
+// 
+// Show confirmation dialog for inserting test cases.
+// ----------------------------------------------------------------------------
+//
+void CTestSetInsertMenuView::ShowInsertCasesDialogL()
+    {
+    TInt i(0);
+    TBuf<50> message;
+    CEikListBox* listBox = iContainer->ListBox();
+	TInt count = listBox->SelectionIndexes()->Count();
+	
+	if ( count > 0 )
+	    {
+    	CEikonEnv::Static()->ReadResource( message, R_INSERT_CONFIRMATION_QUESTION );
+    		
+    	CAknQueryDialog * dlg = CAknQueryDialog::NewL(CAknQueryDialog::ENoTone);
+    	if ( dlg->ExecuteLD( R_GENERAL_CONFIRMATION_DIALOG, message ) )
+    		{
+    		CEikListBox* newListBox = iContainer->ListBox();
+		    TInt newCount = newListBox->SelectionIndexes()->Count();
+    		RArray<TInt> selectedIndices;
+		    CleanupClosePushL( selectedIndices );
+		    if ( newCount > 0 )
+    			{
+    			for( i = 0; i < newCount; i++ )
+	    			{
+    				selectedIndices.InsertInOrder( (*newListBox->SelectionIndexes())[i] );
+		    		}	
+    				
+	    		AddCasesToTestSet( selectedIndices );
+	    		// Test cases added, set save needed flag to true.
+		    	((CTestSetMenuView*)AppUi()->View( 
+		    	    TUid::Uid(ETestSetMenuViewId) ))->SetSaveNeeded(ETrue);
+			    }
+    		CleanupStack::PopAndDestroy();
+	    	
+		    // Test cases added -> go to test set menu
+    		AppUi()->HandleCommandL(EAppUIGoBack);
+	    	}
+	    }
+	else
+	    {
+	    CAknWarningNote* dialog = new(ELeave)CAknWarningNote();
+	    CEikonEnv::Static()->ReadResource( message, R_INSERT_NOCASES_TEXT );
+	    dialog->ExecuteLD(message);
+	    }
+	    
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetInsertMenuView::AddCasesToTestSet
+// 
+// Adds selected test cases to the current test set.
+// ----------------------------------------------------------------------------
+//
+void CTestSetInsertMenuView::AddCasesToTestSet( RArray<TInt> aSelectedIndexes )
+	{
+	TInt ret(0);
+	TInt i(0);
+	RRefArray<CTestInfo> allCases;
+	CTestSetMenuView* testSetMenuView = 
+    	(CTestSetMenuView*)((CAppUIAppUi*)AppUi())->View( TUid::Uid(ETestSetMenuViewId) );
+
+	ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->TestCases(allCases);
+    
+	for ( i = 0; i < aSelectedIndexes.Count(); i++ )
+		{
+		ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->AddToTestSet( 
+    		testSetMenuView->CurrentTestSet(),
+   			allCases[ aSelectedIndexes[i] ] );
+		}    
+    if( ret != KErrNone )		
+        {
+        RDebug::Print( _L("AddCasesToTestSet failed with value: %d"), ret );
+        }
+    
+	allCases.Reset();
+	allCases.Close();
+
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/TestSetMenuContainer.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,486 @@
+/*
+* 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: This file contains CTestSetMenuContainer class 
+* definition.
+*
+*/
+
+// INCLUDE FILES
+#include <aknlists.h>  // ListBox
+#include <akniconarray.h> // CAknIconArray
+#include <aknnotewrappers.h>
+
+#include <eikclbd.h> // CColumnListBoxData
+
+#include "TestSetMenuContainer.h"
+#include "TestSetMenuView.h"
+#include "StartCasesContainer.h"
+#include <Stifui.rsg>
+#include "Stifui.hrh"
+#include "AppUIAppUi.h"
+
+#include "MenuListBox.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+// ----------------------------------------------------------------------------
+// CTestSetMenuContainer::ConstructL
+// 
+// Symbian OS two phased constructor.
+// ----------------------------------------------------------------------------
+//
+void CTestSetMenuContainer::ConstructL(const TRect& aRect, MEikListBoxObserver* aListBoxObserver)
+    {
+    ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("TestSetMenuContainer: ConstructL"));
+
+	iParentView = (CTestSetMenuView*)aListBoxObserver;
+    CreateWindowL();
+
+    iUIStore = ( (CAppUIAppUi*)iCoeEnv->AppUi() )->UIStoreHandler();
+
+    iTestCasesInView.Reset();
+        //((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("TestSetMenuContainer: iTCInV Reset"));
+    
+	iListBox = CMenuListBox::NewL(ETestSetMenuViewId);
+	iListBox->SetContainerWindowL( *this );
+	iListBox->SetListBoxObserver( aListBoxObserver /*this*/ ); // jos peritty MEikListBoxObserver:sta
+    iListBox->ConstructL(this, EAknListBoxMarkableList /*EAknListBoxSelectionList*/);
+
+    ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("TestSetMenuContainer: ListBox constructed"));
+
+    //Create Scroller control for ListBox and set its visibility
+    iListBox->CreateScrollBarFrameL(ETrue);
+    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
+    iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
+    iListBox->Model()->SetOwnershipType(ELbmOwnsItemArray);
+                     iListBox->HandleItemAdditionL();   
+
+    if ( iUIStore )
+        {
+        //RRefArray<const CTestInfo> allCases;
+        //CTestSetInfo* testSetInfo;
+        //IMPORT_C const CTestSetInfo& TestSetL( const TDesC& aSetName  );
+        
+        TPtrC ptr = iParentView->CurrentTestSet();
+        
+        const CTestSetInfo* testSetInfo = 
+        	&iUIStore->TestSetL( ptr );
+        
+        //inline const RRefArray<const CTestInfo>& TestCases() const
+   		const RRefArray<const CTestInfo>* allCases = &testSetInfo->TestCases();
+        
+        /*if( ret != KErrNone )
+            {
+            ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("iUIStore->TestCases() fails"));
+            // Leave
+            }
+		*/
+
+        const TInt KTestCaseCount = allCases->Count();
+        for (TInt i=0; i < KTestCaseCount; i++)
+            {
+            iTestCasesInView.Append( &allCases->operator[](i) );
+            }
+
+        iListBoxModel = CTestCaseListBoxModel::NewL(&iTestCasesInView);
+             ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("TestSetMenuContainer: ListBox model"));
+
+        iListBox->Model()->SetItemTextArray(iListBoxModel);
+             ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("TestSetMenuContainer: ListBox model set"));
+
+        }
+    else
+        {
+        //User::Leave( syy?? )
+        }
+
+    // Creates graphic.
+    SetGraphicIconL( iListBox );
+       ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("TestSetMenuContainer: icons created"));
+
+    iListBox->ActivateL();
+    ((CMenuListBox*)iListBox)->SetPreviousFocus();
+
+    SetRect(aRect);
+    ActivateL();
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuContainer::SetGraphicIconL
+// 
+// Sets graphic icon using listbox as CEikColumnListBox.
+// ----------------------------------------------------------------------------
+//
+void CTestSetMenuContainer::SetGraphicIconL( CEikColumnListBox* aListBox )
+    {
+	if ( aListBox )
+        {
+        // Creates gul icon.
+        CAknIconArray* iconArray = new(ELeave) CAknIconArray(1);
+        CleanupStack::PushL( iconArray );
+        
+        GraphicIconL( iconArray ); // Appends graphic data.
+        
+        // Sets graphics as ListBox icon.
+        aListBox->ItemDrawer()->ColumnData()->SetIconArray( iconArray );
+        
+        CleanupStack::Pop();
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuContainer::CurrentItemIndex
+// 
+// Returns current item index in list box.
+// ----------------------------------------------------------------------------
+//
+TInt CTestSetMenuContainer::CurrentItemIndex()
+    {
+    return iListBox->CurrentItemIndex();
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuContainer::SetCurrentItemIndex
+// 
+// Sets current item index in list box.
+// ----------------------------------------------------------------------------
+//
+void CTestSetMenuContainer::SetCurrentItemIndex(TInt aCurrentTestCase)
+    {
+    iListBox->SetCurrentItemIndexAndDraw(aCurrentTestCase);
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuContainer::GraphicIconL
+// 
+// Appends graphics data.
+// ----------------------------------------------------------------------------
+//
+void CTestSetMenuContainer::GraphicIconL( CArrayPtr<CGulIcon>* aIcons )
+    {
+    if ( aIcons )
+        {
+        CFbsBitmap* markBitmap = NULL;
+        CFbsBitmap* markBitmapMask = NULL;
+	
+        TRgb defaultColor;
+        defaultColor = CEikonEnv::Static()->Color(EColorControlText);
+	
+        AknsUtils::CreateColorIconL(AknsUtils::SkinInstance(),
+        		KAknsIIDQgnIndiMarkedAdd,
+        		KAknsIIDQsnIconColors,
+        		EAknsCIQsnIconColorsCG13,
+        		markBitmap,
+        		markBitmapMask,
+        		AknIconUtils::AvkonIconFileName(),
+        		EMbmAvkonQgn_indi_marked_add,
+        		EMbmAvkonQgn_indi_marked_add_mask,
+        		defaultColor );
+        
+        CGulIcon* markIcon = CGulIcon::NewL(markBitmap,markBitmapMask);
+        aIcons->AppendL(markIcon); 
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuContainer::~CTestSetMenuContainer
+// 
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CTestSetMenuContainer::~CTestSetMenuContainer()
+    {
+    iTestCasesInView.Close(); // does not delete objects whose pointers are contained in the array
+    delete iListBox;
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuContainer::SizeChanged
+// 
+// Called by framework when the view size is changed.
+// ----------------------------------------------------------------------------
+//
+void CTestSetMenuContainer::SizeChanged()
+    {
+    if ( iListBox )
+		{
+		iListBox->SetRect( Rect() ); // Sets rectangle of listbox.
+		}
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuContainer::CountComponentControls
+// 
+// Gets a count of the component controls of this list box control.
+// ----------------------------------------------------------------------------
+//
+TInt CTestSetMenuContainer::CountComponentControls() const
+    {
+    return 1; // return nbr of controls inside this container
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuContainer::ComponentControl
+// 
+// Gets a pointer to the specified component control.
+// ----------------------------------------------------------------------------
+//
+CCoeControl* CTestSetMenuContainer::ComponentControl(TInt aIndex) const
+    {
+    switch ( aIndex )
+        {
+		case 0: 
+			return iListBox;
+        default:
+            return NULL;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuContainer::Draw
+// 
+// Draw a control, called by window server.
+// ----------------------------------------------------------------------------
+//
+void CTestSetMenuContainer::Draw(const TRect& /*aRect*/) const
+    {
+    // CWindowGc& gc = SystemGc();
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuContainer::SelectedTestCases
+// 
+// Returns pointers to selected test cases.
+// ----------------------------------------------------------------------------
+//
+void CTestSetMenuContainer::SelectedTestCases
+                            (RPointerArray<CTestInfo>& aSelectedTestCases)
+    {
+    aSelectedTestCases.Append( iTestCasesInView[iListBox->CurrentItemIndex()] );
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuContainer::OfferKeyEventL
+// 
+// Handles key events.
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CTestSetMenuContainer::OfferKeyEventL(
+	const TKeyEvent& aKeyEvent, TEventCode aType )
+    {
+	if (aType != EEventKey)
+	    {
+		return EKeyWasNotConsumed;
+	    }
+
+	if (iListBox)
+		{
+		//if multiple items selected
+		if ( iListBox->SelectionIndexes()->Count() > 0 )
+			{
+			TUint mask = 0x40488;
+			
+			//if event is enter key,
+			//don´t send it to listbox
+			if ( aKeyEvent.iScanCode == 0xa7 
+				&& ( aKeyEvent.iModifiers & mask ) == 0 )
+				{
+				iParentView->HandleListBoxEventL( iListBox, MEikListBoxObserver::EEventEnterKeyPressed );
+				return EKeyWasConsumed;	
+				}
+			}
+			
+		return iListBox->OfferKeyEventL( aKeyEvent, aType );
+		}
+	else
+		{
+		return EKeyWasNotConsumed;
+		}
+    }
+    
+// ----------------------------------------------------------------------------
+// CTestSetMenuContainer::HandleMarkCommandL
+// 
+// Handles mark commands.
+// ----------------------------------------------------------------------------
+//
+void CTestSetMenuContainer::HandleMarkCommandL( TInt aCommand )
+	{
+	if (iListBox)
+		{
+		AknSelectionService::HandleMarkableListProcessCommandL( aCommand, iListBox );		
+		}
+	}
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuContainer::ProcessCommandL
+// 
+// Processes user commands.
+// ----------------------------------------------------------------------------
+//
+void CTestSetMenuContainer::ProcessCommandL( TInt  aCommand )
+	{
+	AknSelectionService::HandleMarkableListProcessCommandL( aCommand, iListBox );
+    }
+    
+// ----------------------------------------------------------------------------
+// CTestSetMenuContainer::SelectionListProcessCommandL
+// 
+// Processes user commands.
+// ----------------------------------------------------------------------------
+//    
+void CTestSetMenuContainer::SelectionListProcessCommandL( TInt  aCommand )
+	{
+	AknSelectionService::HandleSelectionListProcessCommandL( aCommand, iListBox );
+    }
+    
+// ----------------------------------------------------------------------------
+// CTestSetMenuContainer::FilterCasesByModuleL
+// 
+// Show only testcases which are defined is specified module.
+// ----------------------------------------------------------------------------
+//
+void CTestSetMenuContainer::FilterCasesByModuleL( TName aModuleName )
+    {
+    iTestCasesInView.Reset(); // Clear testCasesInView pointer array
+   
+    RRefArray<CTestInfo> allCases;
+    TInt ret = iUIStore->TestCases( allCases );
+    if( KErrNone != ret )
+        {
+        ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("FilterCasesByModuleL(): iUIStore->TestCases() fails"));
+        allCases.Reset();
+        allCases.Close();
+        User::Leave( ret );
+        }
+    const TInt KTestCaseCount = allCases.Count();
+    for( TInt i=0; i < KTestCaseCount; i++ )
+        {
+        if ( allCases[i].ModuleName() == aModuleName )
+            {
+            iTestCasesInView.Append( &( allCases[i] ) );
+            }
+        }
+    allCases.Reset();
+    allCases.Close();
+
+    iListBox->Reset();
+    iListBox->DrawNow();
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuContainer::FilterCasesByTCFileNameL
+// 
+// Show only testcases which are defined is specified test case file.
+// ----------------------------------------------------------------------------
+//
+void CTestSetMenuContainer::FilterCasesByTCFileNameL( 
+                                                TFileName aTestCaseFileName )
+    {
+
+    iTestCasesInView.Reset(); // Clear testCasesInView pointer array
+  
+    RRefArray<CTestInfo> allCases;
+    TInt ret = iUIStore->TestCases( allCases );
+    if( KErrNone != ret )
+        {
+        ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("FilterCasesByModuleL(): iUIStore->TestCases() fails"));
+        allCases.Reset();
+        allCases.Close();
+        User::Leave( ret );
+        }
+    const TInt KTestCaseCount = allCases.Count();
+    for( TInt i=0; i < KTestCaseCount; i++ )
+        {
+        if ( allCases[i].TestCaseFile() == aTestCaseFileName )
+            {
+            iTestCasesInView.Append( &( allCases[i] ) );
+            }
+        }
+
+    allCases.Reset();
+    allCases.Close();
+
+    iListBox->Reset();
+    iListBox->DrawNow();
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuContainer::NoFilteringL
+// 
+// Remove possible filtering of test cases -> show all test cases.
+// ----------------------------------------------------------------------------
+//
+void CTestSetMenuContainer::NoFilteringL()
+    {
+    iTestCasesInView.Reset(); // Clear testCasesInView pointer array
+
+    RRefArray<CTestInfo> allCases;
+    TInt ret = iUIStore->TestCases( allCases );
+    if( KErrNone != ret )
+        {
+        ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("FilterCasesByModuleL(): iUIStore->TestCases() fails"));
+        allCases.Reset();
+        allCases.Close();
+        User::Leave( ret );
+        }
+    const TInt KTestCaseCount = allCases.Count();
+
+    // Add all cases to iTestCasesInView pointer array
+    for( TInt i=0; i < KTestCaseCount; i++ )
+        {
+        iTestCasesInView.Append( &( allCases[i] ) );
+        }
+
+    allCases.Reset();
+    allCases.Close();
+
+    iListBox->Reset();
+    iListBox->DrawNow();
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuContainer::RemoveListBoxItemsL
+// 
+// Removes items from list box.
+// ----------------------------------------------------------------------------
+//
+void CTestSetMenuContainer::RemoveListBoxItemL( TInt aSelected )
+	{
+	TInt currentItem(0);
+    TBool remCurr(EFalse);
+	
+	currentItem = iListBox->CurrentItemIndex();
+	if( aSelected == currentItem )
+	    {
+	    remCurr = ETrue;
+	    }
+	    
+	iTestCasesInView.Remove( aSelected );
+	AknListBoxUtils::HandleItemRemovalAndPositionHighlightL(iListBox, aSelected, remCurr);
+	 iListBox->HandleItemAdditionL();
+	}
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuContainer::SaveActiveLine
+//
+// Makes the iListBox member save its focus position
+// ----------------------------------------------------------------------------
+//	
+void CTestSetMenuContainer::SaveActiveLine()
+	{
+	((CMenuListBox*)iListBox)->SaveFocusPosition();
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/TestSetMenuView.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,554 @@
+/*
+* 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: This file contains CTestSetMenuView class ddefinition.
+*
+*/
+
+// INCLUDE FILES
+#include  <eikmenub.h>
+#include  <aknviewappui.h>
+#include  <aknlistquerydialog.h> 
+#include  <aknnotewrappers.h>
+#include  <barsread.h>              //TResourceReader
+#include  <Stifui.rsg>
+#include  "TestSetMenuView.h"
+#include  "TestSetMenuContainer.h"
+#include  "AppUIAppUi.h"
+#include  "Stifui.hrh" 
+
+
+
+// ================= MEMBER FUNCTIONS =========================================
+// ----------------------------------------------------------------------------
+// CTestSetMenuView::ConstructL
+// 
+// Symbian OS two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+void CTestSetMenuView::ConstructL()
+    {
+    CView::ConstructL();
+    BaseConstructL( R_APPUI_TESTSETMENUVIEW );
+    iCurrentTestCase = 0;
+    iSaveNeeded = ETrue;
+    iUIStore = ( (CAppUIAppUi*)iCoeEnv->AppUi() )->UIStoreHandler();
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuView::~CTestSetMenuView
+// 
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CTestSetMenuView::~CTestSetMenuView()
+    {
+    if ( iContainer )
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        }
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuView::Id
+// 
+// Returns view´s id.
+// ----------------------------------------------------------------------------
+//
+TUid CTestSetMenuView::Id() const
+    {
+    return TUid::Uid(ETestSetMenuViewId);
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuView::HandleCommandL
+// 
+// Handles a command.
+// ----------------------------------------------------------------------------
+//
+void CTestSetMenuView::HandleCommandL(TInt aCommand)
+    {   
+    if ( aCommand == EAknCmdMark || aCommand == EAknCmdUnmark 
+        || aCommand == EAknMarkAll || aCommand == EAknUnmarkAll )
+        {
+        iContainer->HandleMarkCommandL( aCommand );
+        }
+    else
+        {
+        switch ( aCommand )
+            {
+            case ECmdStartTestSet:
+                {
+                const CTestSetInfo& testSetInfo = 
+                    iUIStore->TestSetL( iCurrentTestSet );
+                const RRefArray<const CTestInfo>* allCases = 
+                    &testSetInfo.TestCases();
+                
+                TInt testCaseCount = allCases->Count();
+                if (testCaseCount > 0 )
+                    {
+                    StartTestSetL();
+                    }
+                break;
+                }
+            case ECmdShowStartedTestSet:
+                {
+                AppUi()->HandleCommandL(ECmdShowStartedTestSet);
+                break;
+                }
+            case ECmdSaveTestSet:
+                {
+                SaveCurrentTestSetL();
+                break;
+                }
+            case ECmdInsertTestCases:
+                {
+                // iSaveNeeded is set from 
+                // CTestSetInsertMenuView::ShowInsertCasesDialog()
+                //iSaveNeeded = ETrue;
+                AppUi()->HandleCommandL(ECmdInsertTestCases);
+                break;
+                }
+            case ECmdRemoveTestCases:
+                {
+                RemoveSelectedTestCasesL();
+                break;
+                }
+            case EAknSoftkeyBack:
+                {
+                //iCurrentTestCase = 0;
+               // AppUi()->HandleCommandL(ECmdLoadTestSet/*EAppUIGoToTestSetsMenu*/);
+                //( (CEikAppUi*)iCoeEnv->AppUi() )->HandleCommandL(EAppUIGoToTestSetsMenu);
+                SaveCurrentTestSetL();
+                break;
+                }
+            default:
+                {
+                AppUi()->HandleCommandL( aCommand );
+                break;
+                }
+            }
+        }
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuView::HandleClientRectChange
+// 
+// Handles client rect changes.
+// ----------------------------------------------------------------------------
+//
+void CTestSetMenuView::HandleClientRectChange()
+    {
+    if ( iContainer )
+        {
+        iContainer->SetRect( ClientRect() );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuView::DoActivateL
+// 
+// Initializes view when activated.
+// ----------------------------------------------------------------------------
+//
+void CTestSetMenuView::DoActivateL(
+   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
+   const TDesC8& /*aCustomMessage*/)
+    {
+    if (!iContainer)
+        {
+        ((CAppUIAppUi*)AppUi())->iLogger->Log( 
+            _L("TestSetMenuView: DoActivateL") );
+        iContainer = new (ELeave) CTestSetMenuContainer;
+        iContainer->SetMopParent(this);
+        iContainer->ConstructL( ClientRect(), this );
+        ((CAppUIAppUi*)AppUi())->iLogger->Log( 
+            _L("TestSetMenuView: container constructed") );
+        AppUi()->AddToStackL( *this, iContainer );
+        }
+   
+    //testing
+    iContainer->SetCurrentItemIndex(iCurrentTestCase);
+    
+    CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane();
+    CAknNavigationControlContainer* np = 
+        (CAknNavigationControlContainer *)sp->ControlL(
+        TUid::Uid(EEikStatusPaneUidNavi));
+    
+    TResourceReader reader;
+    iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_TESTSET );
+    iNaviDecorator = np->CreateNavigationLabelL( reader );
+    CleanupStack::PopAndDestroy(); // resource reader
+    np->PushL(*iNaviDecorator);
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuView::DoDeactivate
+// 
+// Deactivates view.
+// ----------------------------------------------------------------------------
+//
+void CTestSetMenuView::DoDeactivate()
+    {
+    if ( iContainer )
+        {
+        iContainer->SaveActiveLine();
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        iContainer = NULL;
+        }
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuView::DynInitMenuPaneL
+// 
+// Initializes menu pane.
+// ----------------------------------------------------------------------------
+//
+void CTestSetMenuView::DynInitMenuPaneL(
+    TInt aResourceId, CEikMenuPane* aMenuPane)
+    {
+
+    // Test modules are added to filter by test module submenu 
+    // if the submenu is opened
+    if (R_APPUI_FILTERBYMODULES_MENU == aResourceId)
+        {
+        RRefArray<TDesC> modules;
+        TInt ret = iUIStore->Modules( modules );
+        if( KErrNone != ret )
+            {
+            modules.Reset();
+            modules.Close();
+            User::Leave( ret );
+            }
+
+        TInt moduleCount = modules.Count();
+        
+        TInt i;
+        CEikMenuPaneItem::SData item;
+
+        item.iCommandId = ECmdFilterByModule;
+        item.iFlags = 0;
+        item.iCascadeId = 0;
+
+        for (i = 0; i < moduleCount; i++)
+            {
+            item.iText = modules[i];
+            aMenuPane->AddMenuItemL(item);
+            item.iCommandId++; // Command IDs 0x1000 - 0x1FFF are reserved
+                               // for modules in hrh file.
+            }
+        
+        modules.Reset();
+        modules.Close();
+        }
+
+    // Test case files are added to filter by test case file submenu
+    // if the submenu is opened.
+    if (R_APPUI_FILTER_BY_TESTCASEFILE_MENU == aResourceId)
+        {
+        RRefArray<TDesC> testCaseFiles;
+        TInt ret = iUIStore->TestCaseFiles( testCaseFiles );
+        if( KErrNone != ret )
+            {
+            testCaseFiles.Reset();
+            testCaseFiles.Close();
+            User::Leave( ret );
+            }
+
+        TInt testCaseFileCount = testCaseFiles.Count();
+
+        TInt i;
+        CEikMenuPaneItem::SData item;
+
+        item.iCommandId = ECmdFilterByTestCaseFile;
+        item.iFlags = 0;
+        item.iCascadeId = 0;
+
+        for (i = 0; i < testCaseFileCount; i++)
+            {
+            item.iText = testCaseFiles[i];
+            aMenuPane->AddMenuItemL(item);
+            item.iCommandId++; // Command IDs 0x2000 - 0x2FFF are reserved for
+                               // test case files in hrh file.
+            }
+        }
+        
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuView::HandleListBoxEventL
+// 
+// Handles listbox events.
+// ----------------------------------------------------------------------------
+//
+void CTestSetMenuView::HandleListBoxEventL(CEikListBox* /*aListBox*/, 
+    TListBoxEvent aEventType)
+    {
+
+    if ( ( aEventType == EEventEnterKeyPressed ) || ( aEventType == EEventItemDoubleClicked ) )
+        {
+        const CTestSetInfo& testSetInfo = 
+            iUIStore->TestSetL( iCurrentTestSet );
+        const RRefArray<const CTestInfo>* allCases = &testSetInfo.TestCases();
+
+        TInt testCaseCount = allCases->Count();
+           if (testCaseCount > 0 )
+            {
+            StartTestSetL();
+            }
+        }
+   }
+ 
+// ----------------------------------------------------------------------------
+// CTestSetMenuView::CreateTestSet
+// 
+// Creates new test set.
+// ----------------------------------------------------------------------------
+//
+TInt CTestSetMenuView::CreateTestSetL( const TDesC& aTestSetName )
+    {
+    TInt error = 0;
+    TBuf<100> message;
+    
+    _LIT(KPath, "c:\\TestFramework\\");
+    RFs fs;
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    TEntry entry;
+    // we check if the c:\testframework directory exists
+    // It is mandatory for this dir to exist if we want to save a test set.
+    // This dir must be localised on the C drive of the device
+    if(fs.Entry(KPath, entry) != KErrNone)
+    	{	// if the dir does not exist 
+    	TInt err = fs.MkDirAll(KPath);	// we create it
+    	if(err != KErrNone)
+    		{	// if of any reason it was impossible to create the dir - inform user about it
+	    	CAknInformationNote* note = new (ELeave) CAknInformationNote(ETrue);
+	    	note->ExecuteLD( _L("Could not create c:\\TestFramework dir!") );
+    		}
+    	}
+    CleanupStack::PopAndDestroy(&fs);	// close and remove RFs object 
+    
+    error = iUIStore->LoadTestSet( aTestSetName );
+    
+    // If testset is either active or already created and saved.
+ /*   if ( KErrNone == error)// || KErrAlreadyExists == error )
+        {
+        CEikonEnv::Static()->ReadResource( message, 
+            R_OVERWRITE_TESTSET_QUESTION );
+        CAknQueryDialog * dlg = 
+            CAknQueryDialog::NewL(CAknQueryDialog::ENoTone);
+        // Confirm overwrite
+        if ( dlg->ExecuteLD( R_GENERAL_CONFIRMATION_DIALOG, message ) )
+            {
+            error = iUIStore->RemoveTestSet( aTestSetName );
+            error = iUIStore->CreateTestSet( aTestSetName );
+            if ( error == KErrNone )
+                {
+                iCurrentTestSet = aTestSetName;
+                iSaveNeeded = ETrue;
+                }
+            }
+        // Else load saved default test set
+        else
+            {
+            iSaveNeeded = EFalse;
+            iCurrentTestSet = aTestSetName;
+            error = KErrAlreadyExists;
+            }
+        }
+    else if ( KErrNotFound == error )
+        {
+        error = iUIStore->CreateTestSet( aTestSetName );
+        if ( KErrNone == error )
+            {
+            iCurrentTestSet = aTestSetName;
+            iSaveNeeded = ETrue;
+            }
+        }
+    else if ( KErrPathNotFound == error )
+          {
+          error = iUIStore->CreateTestSet( aTestSetName );
+          iCurrentTestSet = aTestSetName;
+          iSaveNeeded = EFalse;
+          }
+    else
+        {
+        ((CAppUIAppUi*)AppUi())->iLogger->Log(_L("Test set creation fails with error: %d"), error );
+        CAknInformationNote* informationNote = new (ELeave) CAknInformationNote(ETrue);
+        informationNote->ExecuteLD( _L("UNDEFINED ERROR!") );
+        }*/
+    
+    error = iUIStore->CreateTestSet( aTestSetName );
+    iCurrentTestSet = aTestSetName;
+    iSaveNeeded = ETrue;
+    return error;
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuView::LoadTestSetL
+// 
+// Loads saved test set.
+// ----------------------------------------------------------------------------
+//
+TInt CTestSetMenuView::LoadTestSetL( const TDesC& aTestSetName )
+    {
+    TInt error = 0;
+    TBuf<100> message;
+    error = iUIStore->LoadTestSet( aTestSetName );
+    if ( KErrNone == error || KErrAlreadyExists == error )
+        {
+        iCurrentTestSet = aTestSetName;
+        iSaveNeeded = EFalse;
+        }
+    else
+        {
+        CEikonEnv::Static()->ReadResource( message, 
+            R_LOAD_TESTSET_FAILED );
+        
+        CAknInformationNote* informationNote = new (ELeave) CAknInformationNote(ETrue);
+        informationNote->ExecuteLD(message);
+        }
+    
+    return error;
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuView::SaveCurrentTestSet
+// 
+// Saves current test set.
+// ----------------------------------------------------------------------------
+//
+TInt CTestSetMenuView::SaveCurrentTestSetL()
+    {
+    TInt error = 0;
+    TBuf<100> message;
+    
+    CEikonEnv::Static()->ReadResource( message, 
+        R_SAVE_TESTSET_QUESTION );
+        
+    CAknQueryDialog * dlg = 
+        CAknQueryDialog::NewL(CAknQueryDialog::ENoTone);
+    
+   if ( dlg->ExecuteLD( R_GENERAL_CONFIRMATION_DIALOG, message ) )
+       {
+        error = iUIStore->SaveTestSet2( iCurrentTestSet );
+        iSaveNeeded = EFalse;
+        
+      }
+   AppUi()->HandleCommandL(EAppUIGoBack);
+
+    return error;
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuView::RemoveActiveTestSet
+// 
+// Removes current test set.
+// ----------------------------------------------------------------------------
+//
+TInt CTestSetMenuView::RemoveActiveTestSet()
+    {
+    TInt error = 0;
+    
+    error = iUIStore->RemoveTestSet( iCurrentTestSet );
+    
+    return error;
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetMenuView::StartTestSetL
+// 
+// Shows confirmation dialog and verify if user really want to start test set.
+// ----------------------------------------------------------------------------
+//
+void CTestSetMenuView::StartTestSetL()
+    {
+    _LIT( KErrorStartingTestSet, 
+        "TestSetMenuView: StartTestSetL() fails (%d)" );
+    
+    TInt ret(KErrNone);
+    TInt index(0);
+    TInt selectedItem(0);
+    
+    // Default mode is parallel.
+    CStartedTestSet::TSetType mode = CStartedTestSet::ESetParallel;
+    
+    CAknListQueryDialog* startDialog = 
+        new (ELeave) CAknListQueryDialog(&selectedItem);
+    
+    // Show confirmation dialog.
+    if ( startDialog->ExecuteLD(R_START_MULTIPLE_TESTCASES_LIST_QUERY) )
+        {
+        index = ((CAppUIAppUi*)AppUi())->iStartedTestSet;
+        // Check mode
+        if ( 1 == selectedItem )
+            {
+            mode = CStartedTestSet::ESetSequential;
+            }
+        
+        // Start test set cases.
+        ret = iUIStore->StartTestSet( 
+            iUIStore->TestSetL( iCurrentTestSet ), index, mode );
+            
+        if ( ret != KErrNone )
+            {
+            ((CAppUIAppUi*)AppUi())->iStartedTestSet = -1;
+            ((CAppUIAppUi*)AppUi())->iLogger->Log( 
+                KErrorStartingTestSet, ret );
+            }
+        else
+            {
+            ((CAppUIAppUi*)AppUi())->iStartedTestSet = index;
+            }
+        }
+        
+    }
+   
+// ----------------------------------------------------------------------------
+// CTestSetMenuView::RemoveSelectedTestCasesL
+// 
+// Removes marked test cases from test set.
+// ----------------------------------------------------------------------------
+//
+void CTestSetMenuView::RemoveSelectedTestCasesL()
+    {
+    TInt positionToRemove(0);
+    
+    const CTestSetInfo& testSetInfo = iUIStore->TestSetL( iCurrentTestSet );
+    const RRefArray<const CTestInfo>* allCases = &testSetInfo.TestCases();
+    CEikListBox* listBox = iContainer->ListBox();
+
+    iSaveNeeded = ETrue;
+    positionToRemove = listBox->CurrentItemIndex();
+    // Remove selected test case from test set.
+    TInt ret = iUIStore->RemoveFromTestSet(iCurrentTestSet, allCases->operator[](positionToRemove));
+    iContainer->RemoveListBoxItemL(positionToRemove);
+    
+    if( ret != KErrNone )
+        {
+        RDebug::Print( _L("RemoveFromTestSet failed with value: %d"), ret );
+        }
+    }
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/TestSetStartedCasesContainer.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,466 @@
+/*
+* 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: This file contains CTestSetStartedCasesContainer 
+* class definition.
+*
+*/
+
+// INCLUDE FILES
+
+#include <aknlists.h>  // ListBox
+#include <akniconarray.h>  // CAknIconArray
+#include <badesca.h> // CDesCArray
+#include <eikclbd.h> // CColumnListBoxData
+#include <aknnotewrappers.h>
+
+#include <Stifui.rsg>
+
+//#include "UIStoreIf.h"         
+//#include "UIStore.h"            
+//#include "UIEngine.h"           
+//#include "UIEngineContainer.h"  
+
+#include <stifinternal/UIStoreIf.h>
+#include <stifinternal/UIStore.h>
+#include <stifinternal/UIEngine.h>
+#include <stifinternal/UIEngineContainer.h>
+
+#include "TestSetStartedCasesContainer.h"
+#include "ShowStartedCasesContainer.h"
+#include "Stifui.hrh"
+#include "AppUIAppUi.h"
+
+#include "MenuListBox.h"
+
+// ================= MEMBER FUNCTIONS =======================
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesContainer::ConstructL
+// 
+// Symbian OS two phased constructor.
+// ----------------------------------------------------------------------------
+//
+void CTestSetStartedCasesContainer::ConstructL(const TRect& aRect, MEikListBoxObserver* aListBoxObserver)
+    {
+    CreateWindowL();
+
+    iUIStore = ( (CAppUIAppUi*)iCoeEnv->AppUi() )->UIStoreHandler();
+    
+	iListBox = CMenuListBox::NewL(ETestSetStartedCasesViewId); /*CAknSingleStyleListBox();*/
+	iListBox->SetContainerWindowL( *this );
+	iListBox->SetListBoxObserver( aListBoxObserver );
+    iListBox->ConstructL(this, EAknListBoxSelectionList);
+
+    //Create Scroller control for ListBox and set its visibility
+    iListBox->CreateScrollBarFrameL(ETrue);
+    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
+
+    if ( iUIStore )
+        {
+        
+        iListBoxModel = CStartedTestsListBoxModel::NewL( &iStartedTestsPtrs );
+        iListBox->Model()->SetItemTextArray(iListBoxModel);
+        ConstructListBoxModelL();
+        iListBox->Model()->SetOwnershipType(ELbmOwnsItemArray);
+        iListBox->HandleItemAdditionL();
+
+        }
+    else
+        {
+        //User::Leave( syy?? )
+        }
+	iListBox->ActivateL();
+	((CMenuListBox*)iListBox)->SetPreviousFocus();
+
+    SetRect(aRect);
+    ActivateL();
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesContainer::ConstructListBoxModelL
+// 
+// Constructs list box model without any filtering.
+// ----------------------------------------------------------------------------
+//
+void CTestSetStartedCasesContainer::ConstructListBoxModelL()
+    {
+    TInt items(0);
+    TInt index = ((CAppUIAppUi*)iCoeEnv->AppUi())->iStartedTestSet;
+    
+    // Check if there is started test sets and if there is,
+    // show test set´s info.
+    if ( index != -1 )
+        {
+        const RRefArray<CStartedTestCase>* startedTestCases;
+        CStartedTestSet* startedTestSet =
+     	    &iUIStore->StartedTestSetL( index );
+        startedTestCases = &startedTestSet->TestCases();
+        
+        const TInt KStartedCaseCount = startedTestCases->Count();
+
+        items = iStartedTestsPtrs.Count();
+        iStartedTestsPtrs.Reset(); // Remove all pointers (does not delete objects)
+        iListBox->HandleItemRemovalL();
+        
+        const TInt KSelectedMode = ((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode;
+        
+        // Loop through all started cases
+        for( TInt i=0; i < KStartedCaseCount; i++ )
+            {
+            switch ( KSelectedMode )
+                {
+                case EShowAllStartedCases:
+                    {
+                    iStartedTestsPtrs.Append( startedTestCases->operator[](i) );
+                    break;
+                    }
+                case EShowOngoingCases:
+                    {
+                    // Note: PAUSE IS ALSO RUNNIN STATUS
+                    if ( startedTestCases->operator[](i).Status() & CUIStoreIf::EStatusRunning )
+                        {
+                        iStartedTestsPtrs.Append( startedTestCases->operator[](i) );
+                        }
+                    break;
+                    }
+                case EShowPassedCases:
+                    {
+                    if ( startedTestCases->operator[](i).Status() & CUIStoreIf::EStatusPassed )
+                        {
+                        iStartedTestsPtrs.Append( startedTestCases->operator[](i) );
+                        }
+                    break;
+                    }
+                case EShowPausedCases:
+                    {
+                    if ( startedTestCases->operator[](i).Status() & CUIStoreIf::EStatusRunning )
+                        {
+                        if( startedTestCases->operator[](i).UIEngineContainer().State() == CUIEngineContainer::EPaused )
+                            {
+                            iStartedTestsPtrs.Append( startedTestCases->operator[](i) );
+                            }
+                        }
+                    break;
+                    }
+                case EShowFailedCases:
+                    {
+                    if ( startedTestCases->operator[](i).Status() & CUIStoreIf::EStatusFailed )
+                        {
+                        iStartedTestsPtrs.Append( startedTestCases->operator[](i) );
+                        }
+                    break;
+                    }
+                case EShowCrashedAbortedCases:
+                    {
+                    if ( startedTestCases->operator[](i).Status() & CUIStoreIf::EStatusAborted
+                    		||
+                    	 startedTestCases->operator[](i).Status() & CUIStoreIf::EStatusCrashed)
+                        {
+                        iStartedTestsPtrs.Append( startedTestCases->operator[](i) );
+                        }
+                    break;
+                    }
+                }
+        }   
+
+        if ( items < iStartedTestsPtrs.Count() )
+            {
+            iListBox->HandleItemAdditionL();
+            }
+        else
+            {
+            iListBox->HandleItemRemovalL();
+            }
+           
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesContainer::~CTestSetStartedCasesContainer
+// 
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CTestSetStartedCasesContainer::~CTestSetStartedCasesContainer()
+    {
+    delete iListBox;
+    
+    iStartedTestsPtrs.Close(); // does not delete objects whose pointers are contained in the array
+    
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesContainer::SizeChanged
+// 
+// Called by framework when the view size is changed.
+// ----------------------------------------------------------------------------
+//
+void CTestSetStartedCasesContainer::SizeChanged()
+    {
+    if ( iListBox )
+		{
+		iListBox->SetRect( Rect() ); // Sets rectangle of listbox.
+		}
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesContainer::CountComponentControls
+// 
+// Gets a count of the component controls of this list box control.
+// ----------------------------------------------------------------------------
+//
+TInt CTestSetStartedCasesContainer::CountComponentControls() const
+    {
+    return 1; // return nbr of controls inside this container
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesContainer::ComponentControl
+// 
+// Gets a pointer to the specified component control.
+// ----------------------------------------------------------------------------
+//
+CCoeControl* CTestSetStartedCasesContainer::ComponentControl(TInt aIndex) const
+    {
+    switch ( aIndex )
+        {
+		case 0: 
+			return iListBox;
+        default:
+            return NULL;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesContainer::Draw
+// 
+// Draw a control, called by window server.
+// ----------------------------------------------------------------------------
+//
+void CTestSetStartedCasesContainer::Draw(const TRect& /*aRect*/) const
+    {
+    // CWindowGc& gc = SystemGc();
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesContainer::OfferKeyEventL
+// 
+// Handles key events.
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CTestSetStartedCasesContainer::OfferKeyEventL(
+	const TKeyEvent& aKeyEvent, TEventCode aType)
+    {
+    if (aType != EEventKey)
+    {
+		return EKeyWasNotConsumed;
+	}
+
+	if (iListBox)
+		{
+		return iListBox->OfferKeyEventL( aKeyEvent, aType );
+		}
+	else
+		{
+		return EKeyWasNotConsumed;
+		}
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesContainer::SelectedTestCase
+// 
+// Returns reference to currently selected test case in view (listbox).
+// ----------------------------------------------------------------------------
+//
+CStartedTestCase* CTestSetStartedCasesContainer::SelectedTestCase()
+    {
+    if ( iStartedTestsPtrs.Count() > 0 )
+        {
+        return &(iStartedTestsPtrs[ iListBox->CurrentItemIndex() ]);
+        }
+    else
+        {
+        return NULL;
+        }
+/*
+    //if ( iListBox->ItemExists(0)  ) // Check that list box is not empty
+    if ( ((CStartedTestsListBoxModel*)iListBox->Model())->MdcaCount()  ) // Check that list box is not empty
+        {
+        return &(iStartedTestsPtrs[ iListBox->CurrentItemIndex() ]);
+        }
+    else
+        {
+        return NULL;
+        }
+*/
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesContainer::DrawListBox
+// 
+// Draws the list box.
+// ----------------------------------------------------------------------------
+//
+void CTestSetStartedCasesContainer::DrawListBox()
+    {
+    if ( iListBox )
+        {
+        iListBox->DrawNow();
+        }
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesContainer::HandleItemAdditionL
+// 
+// Handles the addition of an item to the model.
+// ----------------------------------------------------------------------------
+//
+void CTestSetStartedCasesContainer::HandleItemAdditionL()
+    {
+    iListBox->HandleItemAdditionL();
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesContainer::HandleItemRemovalL
+// 
+// Handles the removal of an item from the model.
+// ----------------------------------------------------------------------------
+//
+void CTestSetStartedCasesContainer::HandleItemRemovalL()
+    {
+    //TInt itemIndexBeforeRemoval = iListBox->CurrentItemIndex();
+
+    iListBox->HandleItemRemovalL();
+
+    // HandleItemRemovalL "loses selection" if current item is removed
+    // -> we have to check it and set one item as current item to make it possible for
+    // user to select one item from items left after remove
+    if ( iListBox->CurrentItemIndex() == -1 ) // No item selected
+        if ( ((CStartedTestsListBoxModel*)iListBox->Model())->MdcaCount() > 0 ) // there are items
+            SetCurrentItemIndex(0);
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesContainer::TestsInViewCount
+// 
+// Returns count of test cases in view.
+// ----------------------------------------------------------------------------
+//
+TInt CTestSetStartedCasesContainer::TestsInViewCount()
+    {
+    return ((CStartedTestsListBoxModel*)iListBox->Model())->MdcaCount();
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesContainer::CurrentTestCase
+// 
+// Returns pointer to currently selected test case.
+// ----------------------------------------------------------------------------
+//
+CStartedTestCase* CTestSetStartedCasesContainer::CurrentTestCase()
+    {
+    return &iStartedTestsPtrs[ iListBox->CurrentItemIndex() ];
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesContainer::CurrentItemIndex
+// 
+// Gets the index number of the current item in the view.
+// ----------------------------------------------------------------------------
+//
+TInt CTestSetStartedCasesContainer::CurrentItemIndex()
+    {
+    return iListBox->CurrentItemIndex();
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesContainer::SetCurrentItemIndex
+// 
+// Sets the current item.
+// ----------------------------------------------------------------------------
+//
+void CTestSetStartedCasesContainer::SetCurrentItemIndex(TInt aIndex)
+    {
+    TInt itemCount = ((CStartedTestsListBoxModel*)iListBox->Model())->MdcaCount();
+    if ( aIndex < itemCount )
+        {
+        iListBox->SetCurrentItemIndex(aIndex);
+        }
+    else
+        {
+        iListBox->SetCurrentItemIndex(itemCount);
+        }
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesContainer::ResetListBox
+// 
+// Resets the selection indices, top and current item indices,
+// the selection, and the horizontal scroll offset of this list box.
+// This function does not redraw the list box.
+// ----------------------------------------------------------------------------
+//
+void CTestSetStartedCasesContainer::ResetListBox()
+    {
+    iListBox->Reset();
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesContainer::RemoveSelectedExecutionsL
+// 
+// Removes items from list box.
+// ----------------------------------------------------------------------------
+//
+void CTestSetStartedCasesContainer::RemoveSelectedExecutionsL()
+    {
+    TInt indexOfRemovedExecution = 0;
+    iStartedTestsPtrs.Remove(indexOfRemovedExecution);
+    HandleItemRemovalL();
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesContainer::RemoveAllExecutionsInViewL
+// 
+// Removes all started test cases from list box.
+// ----------------------------------------------------------------------------
+//
+void CTestSetStartedCasesContainer::RemoveAllExecutionsInViewL()
+    {
+    TInt exutionsInViewCount = iStartedTestsPtrs.Count();
+    iStartedTestsPtrs.Reset(); //Empties the array, does not delete the objects whose pointers are contained in the array
+    HandleItemRemovalL();
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesContainer::SaveActiveLine
+//
+// Makes the iListBox member save its focus position
+// ----------------------------------------------------------------------------
+//	
+void CTestSetStartedCasesContainer::SaveActiveLine()
+	{
+	((CMenuListBox*)iListBox)->SaveFocusPosition();
+	}
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/TestSetStartedCasesView.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,485 @@
+/*
+* 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: This file contains CTestSetStartedCasesView class
+* definition.
+*
+*/
+
+// INCLUDE FILES
+#include  <eikmenub.h>
+#include  <aknviewappui.h>
+#include  <barsread.h>	//TResourceReader
+#include  <Stifui.rsg>
+
+//#include  "UIEngineContainer.h"  
+#include <stifinternal/UIEngineContainer.h>
+
+#include  "Stifui.hrh" 
+
+#include  "TestSetStartedCasesView.h"
+#include  "TestSetStartedCasesContainer.h"
+#include  "AppUIAppUi.h"
+
+// ================= MEMBER FUNCTIONS =======================
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesView::ConstructL
+// 
+// Symbian OS two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+void CTestSetStartedCasesView::ConstructL()
+    {
+    CView::ConstructL();
+    BaseConstructL( R_TESTSET_STARTEDCASESVIEW );
+    iFilterModule.Zero();
+    iFilterTestCaseFile.Zero();
+    iSelectedTestCase=0;
+    iNaviDecorator = NULL;
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesView::~CTestSetStartedCasesView
+// 
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CTestSetStartedCasesView::~CTestSetStartedCasesView()
+    {
+    if ( iContainer )
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        }
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesView::Id
+// 
+// Returns view´s id.
+// ----------------------------------------------------------------------------
+//
+TUid CTestSetStartedCasesView::Id() const
+    {
+    return TUid::Uid(ETestSetStartedCasesViewId);
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesView::HandleCommandL
+// 
+// Handles a command.
+// ----------------------------------------------------------------------------
+//
+void CTestSetStartedCasesView::HandleCommandL(TInt aCommand)
+    {   
+	TBool refreshListBox = EFalse;
+    // Handle rest possible commands
+    switch ( aCommand )
+        {
+        case ECmdShowAllStartedCases:
+            {
+            ((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode = EShowAllStartedCases;
+            refreshListBox = ETrue;
+            break;
+            }
+        case ECmdShowOngoingCases:
+            {
+            ((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode = EShowOngoingCases;
+            refreshListBox = ETrue;
+            break;
+            }
+        case ECmdShowPausedCases:
+            {
+            ((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode = EShowPausedCases;
+            refreshListBox = ETrue;
+            break;
+            }
+        case ECmdShowPassedCases:
+            {
+            ((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode = EShowPassedCases;
+            refreshListBox = ETrue;
+            break;
+            }
+        case ECmdShowFailedCases:
+            {
+            ((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode = EShowFailedCases;
+            refreshListBox = ETrue;
+            break;
+            }
+        case ECmdShowCrashedAbortedCases:
+            {
+            ((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode = EShowCrashedAbortedCases;
+            refreshListBox = ETrue;
+            break;
+            }
+        case ECmdShowStatistics:
+            {
+            //EShowStatistics
+            TMessageBoxUtil::ShowNotImplementedYetL();
+            break;
+            }
+        case ECmdViewOutput:
+            {
+            ViewTestCaseOutputL();
+            break;
+            }
+        case ECmdPauseTestCase:
+            {
+            CStartedTestCase* startedTestCase = iContainer->SelectedTestCase();
+            if ( NULL != startedTestCase )
+                {
+                startedTestCase->UIEngineContainer().PauseTest();
+                }
+            break;
+            }
+        case ECmdResumeTestCase:
+            {
+            CStartedTestCase* startedTestCase = iContainer->SelectedTestCase();
+            if ( NULL != startedTestCase )
+                {
+                startedTestCase->UIEngineContainer().ResumeTest();
+                }
+            break;
+            }
+        case ECmdAbortTestCase:
+            {
+            CStartedTestCase* startedTestCase = iContainer->SelectedTestCase();
+            if ( NULL != startedTestCase )
+                {
+                startedTestCase->UIEngineContainer().CancelTest();
+                }
+            break;
+            }
+        case EAknSoftkeyOk:
+            {
+            iEikonEnv->InfoMsg( _L("TestCase Menu ok") );
+            break;
+            }
+        case EAknSoftkeyBack:
+            {
+            // Remove possible filterings so that they does not affect when coming again to this view
+            iFilterModule.Zero();
+            iFilterTestCaseFile.Zero();
+            iSelectedTestCase=0; //Reset selected test case information
+            AppUi()->HandleCommandL(EAppUIGoBack);
+            break;
+            }
+        default:
+            {
+            AppUi()->HandleCommandL( aCommand );
+            break;
+            }
+        }
+        
+        if ( refreshListBox )
+        	{
+        	RefreshNaviTitleL();
+        	iContainer->ConstructListBoxModelL();
+        	iContainer->DrawListBox();
+        	}
+
+    }
+    
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesView::RefreshNaviTitleL
+// 
+// Refreshes view name shown in the navi pane.
+// ----------------------------------------------------------------------------
+//
+void CTestSetStartedCasesView::RefreshNaviTitleL()
+    {
+    CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane();
+	CAknNavigationControlContainer* np= (CAknNavigationControlContainer *)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
+	TResourceReader reader;
+
+    switch ( ((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode )
+        {
+        case EShowAllStartedCases:
+            iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTED);
+            break;
+        case EShowOngoingCases:
+            iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTED_ONGOING);
+            break;
+        case EShowPausedCases:
+            iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTED_PAUSED);
+            break;
+        case EShowPassedCases:
+            iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTED_PASSED);
+            break;
+        case EShowFailedCases:
+            iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTED_FAILED);
+            break;
+        case EShowCrashedAbortedCases:
+            iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTED_CRASHED_ABORTED);
+            break;
+        default:
+            iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_TESTSET);
+            break;
+        }
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;        
+    iNaviDecorator = np->CreateNavigationLabelL( reader );
+	CleanupStack::PopAndDestroy(); // resource reader
+	np->PushL(*iNaviDecorator);
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesView::HandleListBoxEventL
+// 
+// Handles listbox events.
+// ----------------------------------------------------------------------------
+//
+void CTestSetStartedCasesView::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
+	{
+	if ( ( aEventType == EEventEnterKeyPressed ) || ( aEventType == EEventItemDoubleClicked ) )
+		{
+        ViewTestCaseOutputL();
+        }
+
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesView::ViewTestCaseOutput
+// 
+// Shows outputs of test case which is selected in Container.
+// ----------------------------------------------------------------------------
+//
+void CTestSetStartedCasesView::ViewTestCaseOutputL()
+	{
+    iSelectedTestCase = iContainer->CurrentItemIndex();
+    
+    // Sets index  of selected test case to AppUi
+    ( ( CAppUIAppUi* )AppUi() )->SetStartedTestCase( iContainer->CurrentTestCase() );
+    
+    AppUi()->HandleCommandL(ECmdViewOutput);
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesView::HandleClientRectChange
+// 
+// Handles client rect changes.
+// ----------------------------------------------------------------------------
+//
+void CTestSetStartedCasesView::HandleClientRectChange()
+    {
+    if ( iContainer )
+        {
+        iContainer->SetRect( ClientRect() );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesView::DoActivateL
+// 
+// Initializes view when activated.
+// ----------------------------------------------------------------------------
+//
+void CTestSetStartedCasesView::DoActivateL(
+   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
+   const TDesC8& /*aCustomMessage*/)
+    {
+    if (!iContainer)
+        {
+        iContainer = new (ELeave) CTestSetStartedCasesContainer;
+        iContainer->SetMopParent(this);
+        iContainer->ConstructL( ClientRect(), this );
+        AppUi()->AddToStackL( *this, iContainer );
+        } 
+
+    if ( iSelectedTestCase )
+        iContainer->SetCurrentItemIndex(iSelectedTestCase);
+
+    iContainer->DrawListBox();
+    
+    RefreshNaviTitleL();
+   }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesView::DoDeactivate
+// 
+// Deactivates view.
+// ----------------------------------------------------------------------------
+//
+void CTestSetStartedCasesView::DoDeactivate()
+    {
+    if ( iContainer )
+        {
+        iContainer->SaveActiveLine();
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        iContainer = NULL;        
+        }
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesView::DynInitMenuPaneL
+// 
+// Initializes menu pane.
+// ----------------------------------------------------------------------------
+//
+void CTestSetStartedCasesView::DynInitMenuPaneL(
+    TInt aResourceId, CEikMenuPane* aMenuPane)
+    {
+
+    // options menu
+    if ( R_TESTSET_STARTEDCASESVIEW_MENU == aResourceId )
+        {
+        CStartedTestCase* startedTestCase = iContainer->SelectedTestCase();
+        if ( NULL != startedTestCase )
+            {
+            switch ( startedTestCase->Status() )
+                {
+                // test case running
+                case CUIStoreIf::EStatusRunning:
+                    {
+                    switch ( startedTestCase->UIEngineContainer().State() )
+                        {
+                        case CUIEngineContainer::ERunning:
+                        case CUIEngineContainer::EPaused:
+                            {
+                            aMenuPane->SetItemDimmed( ECmdShowSetMenu, EFalse );
+                            break;
+                            }
+                        //case CUIEngineContainer::ENotStarted:
+                        //case CUIEngineContainer::EExecuted:
+                        //case CUIEngineContainer::EFinished:
+                        default:
+                            {
+                            aMenuPane->SetItemDimmed( ECmdShowSetMenu, ETrue );
+                            }
+                        }
+                    break;
+                    }
+                        
+                // test case not running
+                //case CUIStoreIf::EStatusPassed:
+                //case CUIStoreIf::EStatusFailed:
+                //case CUIStoreIf::EStatusAborted:
+                //case CUIStoreIf::EStatusExecuted
+                default:
+                    {
+                    aMenuPane->SetItemDimmed( ECmdShowSetMenu, ETrue );
+                    }
+                }
+            }
+        else
+            {
+            aMenuPane->SetItemDimmed( ECmdViewOutput, ETrue );
+            aMenuPane->SetItemDimmed( ECmdShowSetMenu, ETrue );
+            }
+        }
+
+    // test case control menu
+    if ( R_TESTCASE_CONTROL_SUBMENU == aResourceId )
+        {
+        CStartedTestCase* startedTestCase = iContainer->SelectedTestCase();
+        
+        if ( NULL != startedTestCase )
+            {
+            if ( startedTestCase->Status() == CUIStoreIf::EStatusRunning )
+                {
+                switch ( startedTestCase->UIEngineContainer().State() )
+                    {
+                    case CUIEngineContainer::ERunning:
+                        {
+                        aMenuPane->SetItemDimmed( ECmdResumeTestCase, ETrue );
+                        aMenuPane->SetItemDimmed( ECmdPauseTestCase, EFalse );
+                        aMenuPane->SetItemDimmed( ECmdAbortTestCase, EFalse );
+                        break;
+                        }
+                    case CUIEngineContainer::EPaused:
+                        {
+                        aMenuPane->SetItemDimmed( ECmdResumeTestCase, EFalse );
+                        aMenuPane->SetItemDimmed( ECmdPauseTestCase, ETrue );
+                        aMenuPane->SetItemDimmed( ECmdAbortTestCase, EFalse );
+                        break;
+                        }
+                    //case CUIEngineContainer::ENotStarted:
+                    //case CUIEngineContainer::EExecuted:
+                    //case CUIEngineContainer::EFinished:
+                    default:
+                        {
+                        aMenuPane->SetItemDimmed( ECmdResumeTestCase, ETrue );
+                        aMenuPane->SetItemDimmed( ECmdPauseTestCase, ETrue );
+                        aMenuPane->SetItemDimmed( ECmdAbortTestCase, ETrue );
+                        break;
+                        }
+                    }
+                }
+            else
+                {
+                aMenuPane->SetItemDimmed( ECmdResumeTestCase, ETrue );
+                aMenuPane->SetItemDimmed( ECmdPauseTestCase, ETrue );
+                aMenuPane->SetItemDimmed( ECmdAbortTestCase, ETrue );
+                }
+            }
+        else
+            {
+            aMenuPane->SetItemDimmed( ECmdResumeTestCase, ETrue );
+            aMenuPane->SetItemDimmed( ECmdPauseTestCase, ETrue );
+            aMenuPane->SetItemDimmed( ECmdAbortTestCase, ETrue );
+            }
+        }
+            
+    }
+
+// ----------------------------------------------------------------------------
+// CTestSetStartedCasesView::TestCaseStateChangedL
+// 
+// Handles status changes of test cases in view.
+// ----------------------------------------------------------------------------
+//
+void CTestSetStartedCasesView::TestCaseStateChangedL()
+    {
+    if ( iContainer )
+        {
+
+        //CStartedTestCase* currentlySelectedTest = iContainer->SelectedTestCase();
+
+        TInt numOfTestsInViewBeforeStateChange = iContainer->TestsInViewCount();
+
+            //((CStartedTestsListBoxModel*)iContainer->iListBox->Model())->MdcaCount();
+
+        iContainer->ConstructListBoxModelL();
+
+        // Check if filtering by module or by test case file is selected
+        /*
+        if ( iFilterModule.Length() )
+            {
+            iContainer->FilterCasesByModuleL(iFilterModule);
+            }
+        else if ( iFilterTestCaseFile.Length() )
+            {
+            iContainer->FilterCasesByTCFileNameL(iFilterTestCaseFile);
+            }
+        */
+
+        TInt numOfTestsInViewAfterStateChange = iContainer->TestsInViewCount();
+            //((CStartedTestsListBoxModel*)iContainer->iListBox->Model())->MdcaCount();
+
+        if ( numOfTestsInViewAfterStateChange >= numOfTestsInViewBeforeStateChange )
+            iContainer->HandleItemAdditionL();
+        else
+            iContainer->HandleItemRemovalL();
+
+        iContainer->DrawListBox();
+
+        }
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/Testmodulesmenuview.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,280 @@
+/*
+* 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: This file contains CTestModulesMenuView class 
+* definition.
+*
+*/
+
+// INCLUDE FILES
+#include  <aknviewappui.h>
+#include  <Stifui.rsg>
+
+#include  <barsread.h>	//TResourceReader
+#include  "TestModulesMenuView.h"
+#include  "TestModulesMenuContainer.h"
+#include  "Stifui.hrh"
+
+#include "AppUIAppUi.h" // For ShowNotImplementedYet() method
+
+// ================= MEMBER FUNCTIONS =======================
+// ----------------------------------------------------------------------------
+// CTestModulesMenuView::ConstructL
+// 
+// Symbian OS two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+void CTestModulesMenuView::ConstructL()
+    {
+    CView::ConstructL();
+    BaseConstructL( R_APPUI_TESTMODULESMENUVIEW );
+    }
+
+// ----------------------------------------------------------------------------
+// CTestModulesMenuView::~CTestCaseOutputView
+// 
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CTestModulesMenuView::~CTestModulesMenuView()
+    {
+    if ( iContainer )
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        iContainer = NULL;
+        }
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;
+    }
+
+// ----------------------------------------------------------------------------
+// CTestModulesMenuView::Id
+// 
+// Returns view´s id.
+// ----------------------------------------------------------------------------
+//
+TUid CTestModulesMenuView::Id() const
+    {
+    return TUid::Uid(ETestModulesMenuViewId); //KTestCaseMenuViewId;
+    }
+
+// ----------------------------------------------------------------------------
+// CTestModulesMenuView::HandleCommandL
+// 
+// Handles a command.
+// ----------------------------------------------------------------------------
+//
+void CTestModulesMenuView::HandleCommandL(TInt aCommand)
+    {   
+    switch ( aCommand )
+        {
+        case EAknSoftkeyOk:
+            {
+            iEikonEnv->InfoMsg( _L("TestCase Menu ok") );
+            break;
+            }
+        case EAknSoftkeyBack:
+            {
+            AppUi()->HandleCommandL(EAppUIGoBack);
+            break;
+            }
+        // Next is removed from Stifui.rss file in 
+        // RESOURCE MENU_PANE r_appui_testmodulesmenuview_menu's
+        // items section. If want back to use remeve comment there
+        //case ECmdOpenModule:
+        //    {
+            //TFileName fileName;
+            //AknCommonDialogs::RunSelectDlgLD (fileName,
+            //                                  R_MEMORY_SELECTION_DIALOG,
+            //                                  R_FILE_SELECTION_DIALOG
+            //
+            //);
+        //    ShowNotImplementedYet();
+        //    break;
+        //    }
+        case ECmdAddModule:
+            {
+            TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->LoadAllModules();
+            if( KErrNone != ret )
+                {
+                iEikonEnv->InfoMsg( _L("Module adding fails!") );
+                break;
+                }
+
+            AppUi()->HandleCommandL( EAppUIGoBack );
+            //ShowNotImplementedYet();
+            break;
+            }
+        case ECmdRemoveModule:
+            {
+            TInt moduleNumber = iContainer->CurrentItemIndex();
+            RRefArray<TDesC> allModules;
+            TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->Modules( allModules );
+            if( KErrNone != ret )
+                {
+                allModules.Reset();
+                allModules.Close();
+                User::Leave( ret );
+                }
+            // No modules exist...break...
+            if( allModules.Count() == 0 )
+                {
+                iEikonEnv->InfoMsg( _L("No modules available!") );
+                allModules.Reset();
+                allModules.Close();
+                break;
+                }
+            // Module found...remove module...
+            ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->RemoveTestModule(
+                                        allModules[ moduleNumber ] );
+            if( KErrNone != ret )
+                {
+                User::Leave( ret );
+                }
+            allModules.Reset();
+            allModules.Close();
+
+            //iContainer->UpdateView();
+            AppUi()->HandleCommandL( EAppUIGoBack );
+            //ShowNotImplementedYet();
+            break;
+            }
+        default:
+            {
+            AppUi()->HandleCommandL( aCommand );
+            break;
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CTestModulesMenuView::DynInitMenuPaneL
+// 
+// Initializes menu pane.
+// ----------------------------------------------------------------------------
+//
+void CTestModulesMenuView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* /* aMenuPane */)
+    {
+
+    if (R_APPUI_TESTMODULESMENUVIEW_MENU == aResourceId)
+        {
+        /*switch ( iData->StartedCaseInOutputView()->State() )
+            {
+            case ENotStarted:
+                {
+                aMenuPane->SetItemDimmed( ECmdOpenModule, ETrue );
+                aMenuPane->SetItemDimmed( ECmdAddModule, ETrue );
+                aMenuPane->SetItemDimmed( ECmdRemoveModule, ETrue );
+                break;
+                }
+            case ERunning:
+                {
+                aMenuPane->SetItemDimmed( ECmdResumeTestCase, ETrue );
+                break;
+                }
+            case EPaused:
+                {
+                aMenuPane->SetItemDimmed( ECmdPauseTestCase, ETrue );
+                break;
+                }
+            case EPassed:
+            case EFailed:
+            case EAborted:
+            case EExecuted:
+                {
+                aMenuPane->SetItemDimmed( ECmdPauseTestCase, ETrue );
+                aMenuPane->SetItemDimmed( ECmdResumeTestCase, ETrue );
+                aMenuPane->SetItemDimmed( ECmdAbortTestCase, ETrue );
+                break;
+                }
+            }*/
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CTestModulesMenuView::HandleClientRectChange
+// 
+// Handles client rect changes.
+// ----------------------------------------------------------------------------
+//
+void CTestModulesMenuView::HandleClientRectChange()
+    {
+    if ( iContainer )
+        {
+        iContainer->SetRect( ClientRect() );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CTestModulesMenuView::HandleListBoxEventL
+// 
+// Handles listbox events.
+// ----------------------------------------------------------------------------
+//
+void CTestModulesMenuView::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
+	{
+	if ( ( aEventType == EEventEnterKeyPressed ) || ( aEventType == EEventItemDoubleClicked ) )
+		{
+        // Open or edit test module or ???
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CTestModulesMenuView::DoActivateL
+// 
+// Initializes view when activated.
+// ----------------------------------------------------------------------------
+//
+void CTestModulesMenuView::DoActivateL(
+   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
+   const TDesC8& /*aCustomMessage*/)
+    {
+    if (!iContainer)
+        {
+        iContainer = new (ELeave) CTestModulesMenuContainer;
+        iContainer->SetMopParent(this);
+        iContainer->ConstructL( ClientRect(), this);
+        AppUi()->AddToStackL( *this, iContainer );
+        } 
+    CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane();
+	CAknNavigationControlContainer* np= (CAknNavigationControlContainer *)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
+	
+	TResourceReader reader;
+	iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_MODULES);
+	iNaviDecorator = np->CreateNavigationLabelL( reader );
+	CleanupStack::PopAndDestroy(); // resource reader
+	np->PushL(*iNaviDecorator);
+   }
+
+// ----------------------------------------------------------------------------
+// CTestModulesMenuView::DoDeactivate
+// 
+// Deactivates view.
+// ----------------------------------------------------------------------------
+//
+void CTestModulesMenuView::DoDeactivate()
+    {
+    if ( iContainer )
+        {
+        iContainer->SaveActiveLine();
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        iContainer = NULL;
+        }
+    delete iNaviDecorator;
+    iNaviDecorator = NULL;
+    }
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/UIStoreHandler.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,140 @@
+/*
+* 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: This module contains implementation of 
+* CUIStoreHandler class member functions.
+*
+*/
+
+// INCLUDE FILES
+#include "UIStoreHandler.h"
+
+// EXTERNAL DATA STRUCTURES
+// None
+
+// EXTERNAL FUNCTION PROTOTYPES  
+// None
+
+// CONSTANTS
+// None
+
+// MACROS
+// None
+
+// LOCAL CONSTANTS AND MACROS
+// None
+
+// MODULE DATA STRUCTURES
+// None
+
+// LOCAL FUNCTION PROTOTYPES
+// None
+
+// FORWARD DECLARATIONS
+// None
+class CUIStore;
+
+// ==================== LOCAL FUNCTIONS =======================================
+// None
+
+// ================= MEMBER FUNCTIONS =========================================
+// ----------------------------------------------------------------------------
+// CUIStoreHandler::CUIStoreHandler
+// 
+// Default constructor.
+// C++ default constructor can NOT contain any code, that might leave.
+// ----------------------------------------------------------------------------
+//
+CUIStoreHandler::CUIStoreHandler( CAppUIAppUi* aAppUIAppUI ) :
+    iAppUIAppUI( aAppUIAppUI ),
+    iExecutedTestCaseCount( 0 )
+    {
+
+    }
+
+// ----------------------------------------------------------------------------
+// CUIStoreHandler::ConstructL
+// 
+// Symbian OS second phase constructor.
+// Symbian OS default constructor can leave.
+// ----------------------------------------------------------------------------
+//
+void CUIStoreHandler::ConstructL()
+    {
+    CUIStoreIf::ConstructL();
+
+    }
+
+// ----------------------------------------------------------------------------
+// CUIStoreHandler::NewL
+// 
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CUIStoreHandler* CUIStoreHandler::NewL( CAppUIAppUi* aAppUIAppUI )
+    {
+    // Create CUIStoreHandler object uistorehandler
+    CUIStoreHandler* uistorehandler = new (ELeave) CUIStoreHandler( aAppUIAppUI );
+
+    CleanupStack::PushL( uistorehandler );
+    uistorehandler->ConstructL();
+    CleanupStack::Pop( uistorehandler );
+
+    return uistorehandler;
+
+    }
+
+// ----------------------------------------------------------------------------
+// CUIStoreHandler::~CUIStoreHandler
+// 
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CUIStoreHandler::~CUIStoreHandler()
+    {
+
+    }
+
+// ----------------------------------------------------------------------------
+// CUIStoreHandler::Update
+// 
+// Receives output update notify from started test case.
+// Checks if that test case is currently in output view then
+// sends notification to AppUI which handles notification onward.
+// ----------------------------------------------------------------------------
+//
+void CUIStoreHandler::Update( CStartedTestCase* aTestCase, TInt aStatus )
+    {
+	_LIT( KErrorMsg, "Error during output update" );
+    TRAPD(err,iAppUIAppUI->OutputUpdateL( aTestCase, aStatus ));
+	if ( err != KErrNone )
+		{
+		RDebug::Print( KErrorMsg );
+		}
+
+        //iAppUi->OutputUpdate();
+    //if( aStatus == EPrintUpdate )
+    //    {
+        //iAppUIAppUI->OutputUpdate( aTestCase );
+    //    }
+    //else
+    //    {
+        //iAppUIAppUI->TestCaseStateChanged();
+    //    }
+
+    }
+
+// ================= OTHER EXPORTED FUNCTIONS =================================
+// None
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/stifui/src/View.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,100 @@
+/*
+* 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: This file contains CView class definition.
+*
+*/
+
+// INCLUDE FILES
+#include  <aknviewappui.h>
+#include  <Stifui.rsg>
+#include  "AppUIAppUi.h"
+#include  "View.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+// ----------------------------------------------------------------------------
+// CView::ConstructL
+// 
+// Symbian OS two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+void CView::ConstructL()
+    {
+    iUIStore = ( (CAppUIAppUi*)AppUi() )->UIStoreHandler();
+    }
+
+// ----------------------------------------------------------------------------
+// CView::~CView
+// 
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CView::~CView()
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CView::Id
+// 
+// Returns view´s id.
+// ----------------------------------------------------------------------------
+//
+TUid CView::Id() const
+    {
+    return TUid::Uid(0);
+    }
+
+// ----------------------------------------------------------------------------
+// CView::HandleCommandL
+// 
+// Handles a command.
+// ----------------------------------------------------------------------------
+//
+void CView::HandleCommandL(TInt /*aCommand*/)
+    {   
+    }
+
+// ----------------------------------------------------------------------------
+// CView::HandleClientRectChange
+// 
+// Handles client rect changes.
+// ----------------------------------------------------------------------------
+//
+void CView::HandleClientRectChange()
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CView::DoActivateL
+// 
+// Initializes view when activated.
+// ----------------------------------------------------------------------------
+//
+void CView::DoActivateL(
+   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
+   const TDesC8& /*aCustomMessage*/ )
+	{
+	}
+
+// ----------------------------------------------------------------------------
+// CView::DoDeactivate
+// 
+// Deactivates view.
+// ----------------------------------------------------------------------------
+//
+void CView::DoDeactivate()
+    {
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/uitestserverstarter/data/UITestServerStarter.rls	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,23 @@
+/*
+* 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: This file contains name of uitestserverstarter.
+*
+*/
+
+//  LOCALISATION STRINGS
+
+// Caption string for app.
+#define qtn_caption_string "UITestServerStarter"
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/uitestserverstarter/data/UITestServerStarter.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,136 @@
+/*
+* 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: This file defines UITestServerStarter resources.
+*
+*/
+
+//  RESOURCE IDENTIFIER
+NAME UITE	// 4 letter ID
+
+
+//  INCLUDES
+#include <eikon.rh>
+#include <avkon.rsg>
+#include <avkon.rh>
+#include <appinfo.rh>
+#include "UITestServerStarter.hrh"
+#include "UITestServerStarter.rls"
+
+//  RESOURCE DEFINITIONS
+// -----------------------------------------------------------------------------
+//
+//	Define the resource file signature
+//	This resource should be empty.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE RSS_SIGNATURE
+	{
+	}
+
+// -----------------------------------------------------------------------------
+//
+//	Default Document Name
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_default_document_name
+	{
+	buf="UITE";
+	}
+
+// -----------------------------------------------------------------------------
+//
+//	Define default menu and CBA key.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE EIK_APP_INFO
+	{
+	//menubar = r_menubar;
+	cba = R_AVKON_SOFTKEYS_EXIT;
+	}
+
+
+// -----------------------------------------------------------------------------
+//
+//   r_menubar
+//   Main menubar
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE MENU_BAR r_menubar
+	{
+	titles =
+		{
+		MENU_TITLE { menu_pane = r_menu; }
+		};
+	}
+
+
+// -----------------------------------------------------------------------------
+//
+//   r_menu
+//   Menu for "Options"
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_menu
+	{
+	items =
+		{
+		MENU_ITEM
+				{
+				command = EAknSoftkeyExit;
+				txt = qtn_exit;
+				}
+		};
+	}
+
+// -----------------------------------------------------------------------------
+//
+// About dialog resource.
+//
+// -----------------------------------------------------------------------------
+//
+// None
+
+// -----------------------------------------------------------------------------
+//
+// Resources for messages.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF32 r_caption_string { buf=qtn_caption_string; }
+
+// ---------------------------------------------------------------------------- 
+//
+// r_localisable_app_info
+//
+// ---------------------------------------------------------------------------- 
+//
+RESOURCE LOCALISABLE_APP_INFO r_localisable_app_info
+	{
+	short_caption = qtn_caption_string;
+	caption_and_icon = 
+	CAPTION_AND_ICON_INFO
+		{
+		caption = qtn_caption_string;
+
+		number_of_icons = 1;
+	   	icon_file = "\\resource\\apps\\UITestServerStarter.mif";
+		};
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/uitestserverstarter/data/UITestServerStarter_reg.rss	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,34 @@
+/*
+* 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: This file defines UITestServerStarter resources.
+*
+*/
+
+#include "UITestServerStarter.hrh"
+#include "UITestServerStarter.rls"
+#include <appinfo.rh>
+#include <UITestServerStarter.rsg>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 _UID3
+
+RESOURCE APP_REGISTRATION_INFO
+	{
+	app_file="UITestServerStarter";
+//	localisable_resource_file =  qtn_loc_resource_file_1;
+//	localisable_resource_id = R_LOCALISABLE_APP_INFO;
+	hidden=KAppIsHidden;
+	embeddability=KAppNotEmbeddable;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/uitestserverstarter/group/UITestServerStarter.mmp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,87 @@
+/*
+* 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: MMP file of UITestServerStarter.
+*
+*/
+
+#include <platform_paths.hrh>
+
+SMPSAFE
+
+TARGET			UITestServerStarter.exe
+TARGETTYPE		exe
+UID		  		0x100039CE 0x2000F8E8
+VENDORID		0x101FB657
+SECUREID		0x2000F8E8
+CAPABILITY		ALL -TCB
+
+START RESOURCE	../data/UITestServerStarter.rss
+	HEADER
+	TARGETPATH resource/apps
+END
+
+SOURCEPATH		../data
+START RESOURCE	UITestServerStarter_reg.rss
+	DEPENDS uitestserverstarter.rsg
+	TARGETPATH		/private/10003a3f/apps
+END
+
+SOURCEPATH		../src
+
+SOURCE			TestServerThreadStarter.cpp
+SOURCE			UITestServerStarter.cpp 
+SOURCE			UITestServerStarterAppView.cpp
+SOURCE			UITestServerStarterAppUi.cpp
+SOURCE			AknUiEnvProxy.cpp
+SOURCE			EventUtil.cpp
+SOURCE			UITestServerStarterApplication.cpp
+SOURCE			UITestServerStarterDocument.cpp
+SOURCE			UITestServerStarterAppContainer.cpp
+
+USERINCLUDE ../inc
+
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY		   euser.lib
+LIBRARY		   apparc.lib
+LIBRARY		   cone.lib
+LIBRARY		   eikcore.lib
+LIBRARY		   avkon.lib
+LIBRARY		   commonengine.lib
+LIBRARY		   efsrv.lib 
+LIBRARY		   estor.lib
+LIBRARY        aknnotify.lib
+LIBRARY        hlplch.lib
+LIBRARY        apgrfx.lib 
+LIBRARY        ws32.lib
+LIBRARY        aknskins.lib 
+LIBRARY        aknskinsrv.lib
+
+LIBRARY         stiftestserver.lib
+
+START WINS      
+// ?wins_specific_information
+END
+
+START MARM
+// ?marm_specific_information
+END
+
+/* Test Server requires large stack. In case of change update also thread creation parameters
+   in "void CTestServerThreadStarter::RunL" method.
+*/
+EPOCSTACKSIZE   40960
+EPOCHEAPSIZE 	0x001000 0x400000
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/uitestserverstarter/group/bld.inf	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,40 @@
+/*
+* 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 build information for UITestServerStarter.
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+// Specify the platforms your component needs to be built for here.
+// ARM4 not supported in SDK
+
+	DEFAULT
+
+
+PRJ_EXPORTS
+// None
+
+PRJ_TESTEXPORTS
+// None
+
+PRJ_MMPFILES
+	
+	UITestServerStarter.mmp
+
+PRJ_TESTMMPFILES
+// None
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/uitestserverstarter/inc/AknUiEnvProxy.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,166 @@
+/*
+* 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: This file contains the header file of the Akn UI 
+* Proxy class implementations.
+*
+*/
+
+#ifndef AKNUIENVPROXY_H_
+#define AKNUIENVPROXY_H_
+
+//  INCLUDES
+#include <stifinternal/UiEnvProxy.h>
+
+// CONSTANTS
+// None
+
+// MACROS
+// None
+
+// DATA TYPES
+// None
+
+// FUNCTION PROTOTYPES
+// None
+
+// FORWARD DECLARATIONS
+class CUITestServerStarterAppUi;
+
+// CLASS DECLARATION
+
+// DESCRIPTION
+// Akn implementation of UI Proxy interface.
+class CAknUiEnvProxy: public CUiEnvProxy
+	{
+	public: // Enumerations
+	    // None
+	
+	private: // Enumerations
+	    // None
+	
+	public:  // Constructors and destructor
+	    /**
+	    * C++ destructor.
+	    */
+	    ~CAknUiEnvProxy();
+	
+	public: // New functions
+	    /**
+	    * NewL is first phase of two-phased constructor.
+	    */		
+		static CAknUiEnvProxy* NewL( CUITestServerStarterAppUi* aAppUi );
+		
+    public: // Functions from base classes
+
+		/**
+		 * Parses key code.
+		 */
+		virtual TInt ParseKeyCode( const TDesC& aKeyCodeName, TUint& aKeyCode ) const;
+	
+		/**
+		 * Parses key scan code.
+		 */
+		virtual TInt ParseKeyScanCode( const TDesC& aKeyScanCodeName, TInt& aKeyScanCode ) const;
+	
+		/**
+		 * Parses key modifier.
+		 */
+		virtual TInt ParseModifier( const TDesC& aModifierName, TUint& aModifier ) const;
+	    
+		/**
+		 * Parse pointer event type
+		 */
+		virtual TInt ParsePointerEventType( const TDesC& aPointerEventTypeName, TUint& aPointerEventType ) const;
+
+		/**
+		 * Brings UI control container to foreground.
+		 */
+		virtual void BringToForeground();
+
+		/**
+		 * Sends UI control container to background.
+		 */
+		virtual void SendToBackground();
+
+		/**
+		 * Sends local key event to UI control.
+		 */
+		virtual void PressKeyL( TRequestStatus* aStatus, TUint aKeyCode, TInt aKeyScanCode = 0, 
+				   TUint aKeyModifiers = 0, TInt aKeyRepeats = 0 );
+
+		/**
+		 * Sends global key event to UI control.
+		 */
+		virtual void PressKeyL( TUint aKeyCode, TInt aKeyScanCode = 0, 
+				   TUint aKeyModifiers = 0, TInt aKeyRepeats = 0 );
+
+		/**
+		 * Sends text to UI control.
+		 */
+		virtual void TypeTextL( TRequestStatus* aStatus, const TDesC& aText );
+
+		/**
+		 * Sends global text to UI control.
+		 */
+		virtual void TypeTextL( const TDesC& aText );
+		
+		/**
+		 * Send pointer event
+		 */
+		virtual void SendPointerEventL( TUint aType, const TPoint& aPosition );		
+		
+		/**
+		 * Send local pointer event
+		 */
+		virtual void SendPointerEventL( TRequestStatus* aStatus, TUint aType, const TPoint& aPosition );
+		
+    protected:	// New functions
+        // None
+        
+    protected:	// Functions from base classes
+        // None
+        
+    private:	// New functions
+	    /**
+	    * C++ default constructor.
+	    */
+		CAknUiEnvProxy();
+    
+	    /**
+	    * By default Symbian OS constructor is private.
+	    */
+    	void ConstructL( CUITestServerStarterAppUi* aAppUi );
+    
+	public:		//Data
+	    // None
+        
+	protected:	// Data
+        // None
+        
+    private:	// Data
+    	CUITestServerStarterAppUi* iAppUi;	// Pointer to AppUi
+		
+    public:		// Friend classes
+        // None
+
+    protected:	// Friend classes
+        // None
+
+    private:	// Friend classes
+        // None
+};
+
+#endif // AKNUIENVPROXY_H_
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/uitestserverstarter/inc/EventUtil.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,115 @@
+/*
+* 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: This file contains TEventUtil class declaration.
+*
+*/
+
+#ifndef EVENTUTIL_H_
+#define EVENTUTIL_H_
+
+//  INCLUDES
+#include <e32base.h>
+
+// CONSTANTS
+// None
+
+// MACROS
+// None
+
+// DATA TYPES
+// None
+
+// FUNCTION PROTOTYPES
+// None
+
+// FORWARD DECLARATIONS
+// None
+
+// CLASS DECLARATION
+
+// DESCRIPTION
+// Utility class for key codes parsing.
+class TEventUtil
+    {
+    private: // Enumerations
+    	// none
+
+    public: // Enumerations
+		enum TCustomPointerEventType { EButton1 = 1000, EButton2, EButton3 };
+    
+    public: // Constructors and destructor
+
+    public: // Constructors and destructor
+
+    public: // New functions
+    	/**
+    	 * Returns descriptive key code name.
+    	 */
+        static TPtrC GetKeyCodeName( TUint aKeyCode );
+        
+        /**
+         * Parses key code.
+         */ 
+        static TInt ParseKeyCode( const TDesC& aKeyCodeName, TUint& aKeyCode );
+
+		/**
+		 * Returns descriptive key scan code name.
+		 */
+        static TPtrC GetKeyScanCodeName( TInt aKeyScanCode );
+        
+        /**
+         * Parses key scan code.
+         */
+        static TInt ParseKeyScanCode( const TDesC& aKeyScanCodeName, TInt& aKeyScanCode );
+
+        /**
+         * Returns descriptive key modifier name.
+         */
+        static TPtrC GetModifierName( TUint aModifier );
+        
+        /**
+         * Parses key modifier.
+         */
+        static TInt ParseModifier( const TDesC& aModifierName, TUint& aModifier );
+        
+        /**
+         * Parses pointer event type.
+         */
+        static TInt ParsePointerEventType( const TDesC& aPointerEventTypeName, TUint& aPointerEventType );
+
+    public: // Functions from base classes
+
+    protected:  // New functions
+
+    protected:  // Functions from base classes
+
+    private:    // New functions
+
+    public:     // Data
+
+    protected:  // Data
+
+    private:    // Data
+
+    public:     // Friend classes
+
+    protected:  // Friend classes
+
+    private:    // Friend classes
+
+    };
+
+#endif /*EVENTUTIL_H_*/
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/uitestserverstarter/inc/TestServerThreadStarter.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,132 @@
+/*
+* 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: This file contains the header file of the 
+* TestServerThreadStarter class.
+*
+*/
+
+
+#ifndef TESTSERVERTHREADSTARTER_H_
+#define TESTSERVERTHREADSTARTER_H_
+
+//  INCLUDES
+#include "e32base.h"
+
+
+// CONSTANTS
+// None
+
+// MACROS
+// None
+
+// DATA TYPES
+// None
+
+// FUNCTION PROTOTYPES
+// None
+
+// FORWARD DECLARATIONS
+class CTestThreadContainerRunnerFactory;
+
+// CLASS DECLARATION
+
+// DESCRIPTION
+// Class used to create thread in which testserver execution code is placed.
+class CTestServerThreadStarter: public CActive
+	{
+	public: // Enumerations
+	    // None
+	
+	private: // Enumerations
+	    // None
+	
+	public:  // Constructors and destructor
+	    /**
+	    * C++ destructor.
+	    */
+		~CTestServerThreadStarter();
+	
+	public: // New functions
+	    /**
+	    * NewL is first phase of two-phased constructor.
+	    */		
+		static CTestServerThreadStarter* NewL();
+	
+		/**
+		 * Performs testserver execution request.
+		 */
+		TInt RunTestServerThread( CTestThreadContainerRunnerFactory* aTestThreadContainerRunnerFactory );
+	public: // Functions from base classes
+		/**
+		 * RunL derived from CActive handles the completed requests.
+		 */
+		void RunL();
+		
+		/**
+		 * DoCancel derived from CActive handles the Cancel.
+		 */
+		void DoCancel();
+
+    protected:	// New functions
+        // None
+        
+    protected:	// Functions from base classes
+        // None
+        
+    private:	// New functions
+    	/**
+    	 * Thread function in which testserver execution code is placed.
+    	 */
+		static TInt TestServerStarterThreadFunction( TAny* aParameters );
+	    
+		/**
+	    * C++ default constructor.
+	    */
+		CTestServerThreadStarter();
+
+	    /**
+	    * By default Symbian OS constructor is private.
+	    */
+		void ConstructL();		
+	
+	public:		//Data
+	    // None
+        
+	protected:	// Data
+        // None
+        
+    private:	// Data
+		RTimer iTimer;	// Timer which complets testserver execution request
+		CTestThreadContainerRunnerFactory* iTestThreadContainerRunnerFactory; 	// Pointer to test thread container
+																				// runner factory passed as a parameter
+																				// to function which executes testserver
+		TThreadId iMainThreadId;	// UITestServerStarter main thread id 
+		TInt iReturnCode;			// TestServer execution return code
+		RSemaphore iServerThreadStartedSemaphore;	// Semaphore which indicates that testserver execution thread
+													// was successfully created		
+    public:		// Friend classes
+        // None
+
+    protected:	// Friend classes
+        // None
+
+    private:	// Friend classes
+        // None
+	};
+
+
+
+#endif // TESTSERVERTHREADSTARTER_H_
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/uitestserverstarter/inc/UITestServerStarter.hrh	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,23 @@
+/*
+* 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: This file contains UID3 definition.
+*
+*/
+
+#ifndef __UITESTSERVERSTARTER_HRH__
+#define __UITESTSERVERSTARTER_HRH__
+
+#define _UID3 0x2000F8E8
+
+#endif // __UITESTSERVERSTARTER_HRH__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/uitestserverstarter/inc/UITestServerStarterAppContainer.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,138 @@
+/*
+* 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: This file contains the header file of the 
+* UITestServerStarter AppUi container class.
+*
+*/
+
+#ifndef UITESTSERVERSTARTERAPPCONTAINER_H_
+#define UITESTSERVERSTARTERAPPCONTAINER_H_
+
+//  INCLUDES
+#include <coecntrl.h>
+#include <coemop.h>
+
+
+// CONSTANTS
+// None
+
+// MACROS
+// None
+
+// DATA TYPES
+// None
+
+// FUNCTION PROTOTYPES
+// None
+
+// FORWARD DECLARATIONS
+class CAknsBasicBackgroundControlContext;
+
+// CLASS DECLARATION
+
+// DESCRIPTION
+// UITestServerStarter standard AppUi container class.
+class CUITestServerStarterAppContainer: public CCoeControl
+	{
+	public: // Enumerations
+	    // None
+	
+	private: // Enumerations
+	    // None
+	
+	public:  // Constructors and destructor
+		/**
+		 * Virtual Destructor.
+		 */
+		~CUITestServerStarterAppContainer();
+
+	private:  // Constructors and destructor
+		/**
+		 * C++ default constructor.
+		 */
+		CUITestServerStarterAppContainer();
+
+		/**
+		 * Perform the second phase construction of a
+		 * CUITestServerStarterAppView object.
+		 */
+		void ConstructL( const TRect& aRect );
+		
+	public: // New functions
+		/**
+		 * Two-phased constructor.
+		 * Create a CUITestServerStarterAppContainer object, which will draw itself to aRect.
+		 */
+		static CUITestServerStarterAppContainer* NewL( const TRect& aRect );
+
+		/**
+		* Two-phased constructor.
+		* Create a CUITestServerStarterAppContainer object, which will draw itself
+		*/
+		static CUITestServerStarterAppContainer* NewLC( const TRect& aRect );
+
+		
+		/**
+		 * This function is used to allow controls to ask their owners 
+		 * for access to other objects that they own
+		 */
+		TTypeUid::Ptr MopSupplyObject( TTypeUid aId );
+	public: // Functions from base classes
+		// None
+	
+    protected:	// New functions
+        // None
+        
+    protected:	// Functions from base classes
+        // None
+        
+    private:	// New functions
+    	// None
+
+    private:	// Functions from base classes
+    
+    	/**
+    	 * Draws the control
+    	 */
+        void Draw( const TRect& aRect ) const;
+        
+        /**
+         * Responds to changes to the size and position of the 
+         * contents of this control
+         */
+        void SizeChanged();
+    
+        //void HandleResourceChange( TInt aType );
+	public:		//Data
+	    // None
+        
+	protected:	// Data
+        // None
+        
+    private:	// Data
+    	CAknsBasicBackgroundControlContext* iBgContext; // Skin background object context pointer
+		
+    public:		// Friend classes
+        // None
+
+    protected:	// Friend classes
+        // None
+
+    private:	// Friend classes
+        // None
+	};
+
+#endif /*UITESTSERVERSTARTERAPPCONTAINER_H_*/
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/uitestserverstarter/inc/UITestServerStarterAppUi.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,172 @@
+/*
+* 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: This file contains the header file of the 
+* UITestServerStarter AppUi class
+*
+*/
+
+#ifndef UITESTSERVERSTARTERAPPUI_H_
+#define UITESTSERVERSTARTERAPPUI_H_
+
+//  INCLUDES
+#include <aknviewappui.h> 
+
+// CONSTANTS
+// None
+
+// MACROS
+// None
+
+// DATA TYPES
+// None
+
+// FUNCTION PROTOTYPES
+// None
+
+// FORWARD DECLARATIONS
+class CUITestServerStarterAppView;
+
+// CLASS DECLARATION
+
+// DESCRIPTION
+// UITestServerStarter AppUi class
+class CUITestServerStarterAppUi : public CAknViewAppUi
+	{
+	public: // Enumerations
+	    // None
+	
+	private: // Enumerations
+		/**
+		 * Currently handled event type.
+		 */
+		enum TEventType { 
+			ENone,		// None 
+			EPressKey,  // Press key event
+			ETypeText, 	// Type text event
+			EPointerEvent, // Pointer event
+			};
+	
+	public:  // Constructors and destructor
+		/**
+		 * C++ default constructor. This needs to be public due to
+		 * the way the framework constructs the AppUi
+		 */
+		CUITestServerStarterAppUi();
+	
+		/**
+		 * Virtual Destructor.
+		 */
+		virtual ~CUITestServerStarterAppUi();
+	
+	public: // New functions
+		/**
+		 * ConstructL.
+		 * 2nd phase constructor.
+		 */
+		void ConstructL();
+
+		/**
+	     * Prepares AppUi to recive type text event
+	     */	
+		virtual void PrepareToTypeText( TInt aTextLength );
+	
+		/**
+	     * Prepares AppUi to recive key press event
+	     */	
+		virtual void PrepareToPressKey();			
+
+		/**
+	     * Prepares AppUi to recive pointer event
+	     */	
+		virtual void PrepareToPointerEvent();			
+		
+		/**
+	     * Notifies that key press event was recived.
+	     */	
+		virtual void KeyPressHandled();
+	
+		/**
+	     * Notifies that text type event was recived.
+	     */	
+		virtual void TextTypeHandled();
+		
+		/**
+	     * Notifies that pointer event was recived.
+	     */	
+		virtual void PointerEventHandled();
+		
+		/**
+	     * Requests notification when key press event is handled.
+	     */	
+		virtual void NotifyAboutHandledKeyPress( TRequestStatus* aStatus );
+	
+		/**
+	     * Requests notification when text type event is handled.
+	     */	
+		virtual void NotifyAboutHandledTextType( TRequestStatus* aStatus );	
+
+		/**
+	     * Requests notification when pointer event is handled.
+	     */	
+		virtual void NotifyAboutHandledPointerEvent( TRequestStatus* aStatus );	
+
+	public: // Functions from base classes
+		/**
+	     * Overwritten version of CCoeAppUi::HandleWsEventL() method.
+	     */	
+		void HandleWsEventL( const TWsEvent& aEvent, CCoeControl* aDestination );
+
+    protected:	// New functions
+        // None
+        
+    protected:	// Functions from base classes
+        // None
+        
+    private:	// New functions
+    	// None
+
+    private: 	// Functions from base classes
+		/**
+		 * From CEikAppUi, HandleCommandL.
+		 * Takes care of command handling.
+		 * @param aCommand Command to be handled.
+		 */
+		void HandleCommandL( TInt aCommand );
+	        
+	public:		//Data
+	    // None
+        
+	protected:	// Data
+        // None
+        
+    private:	// Data
+		CUITestServerStarterAppView* iAppView;	// The application view owned by CUITestServerStarterAppUi		
+		TRequestStatus* iEventStatus;	// Pointer to request statuc which is completed when 
+										// selected event is handled.		
+		TEventType iEventType;	// Currently handled event type;		
+		TInt iTypeTextLength;	// Length of text send by typetext testscripter keyword
+		
+    public:		// Friend classes
+        // None
+
+    protected:	// Friend classes
+        // None
+
+    private:	// Friend classes
+        // None
+	};
+
+#endif // UITESTSERVERSTARTERAPPUI_H_
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/uitestserverstarter/inc/UITestServerStarterAppView.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,142 @@
+/*
+* 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: This file contains the header file of the 
+* UITestServerStarter AppUi view class.
+*
+*/
+
+#ifndef UITESTSERVERSTARTERAPPVIEW_H_
+#define UITESTSERVERSTARTERAPPVIEW_H_
+
+//  INCLUDES
+#include <aknview.h>
+
+// CONSTANTS
+// None
+
+// MACROS
+// None
+
+// DATA TYPES
+// None
+
+// FUNCTION PROTOTYPES
+// None
+
+// FORWARD DECLARATIONS
+class CUITestServerStarterAppContainer;
+
+// CLASS DECLARATION
+
+// DESCRIPTION
+// UITestServerStarter standard AppUi view class.
+class CUITestServerStarterAppView : public CAknView
+	{
+	public: // Enumerations
+	    // None
+	
+	private: // Enumerations
+	    // None
+	
+	public:  // Constructors and destructor
+		/**
+		 * Virtual Destructor.
+		 */
+		virtual ~CUITestServerStarterAppView();
+	
+	private:  // Constructors and destructor
+
+		/**
+		 * Perform the second phase construction of a
+		 * CUITestServerStarterAppView object.
+		 */
+		void ConstructL();
+
+		/**
+		 * C++ default constructor.
+		 */
+		CUITestServerStarterAppView();
+	
+	public: // New functions
+		/**
+		 * Two-phased constructor.
+		 * Create a CUITestServerStarterAppView object.
+		 */
+		static CUITestServerStarterAppView* NewL();
+	
+		/**
+		* Two-phased constructor.
+		* Create a CUITestServerStarterAppView object
+		*/
+		static CUITestServerStarterAppView* NewLC();
+
+	public: // Functions from base classes
+	    /**
+	    * Return Uid
+	    */
+	    TUid Id() const;
+	
+	    /**
+	    * Handle Commands
+	    */
+	    void HandleCommandL(TInt aCommand);
+	
+	    /**
+	    * Handle size changes
+	    */
+	    void HandleClientRectChange();
+		
+    protected:	// New functions
+        // None
+        
+    protected:	// Functions from base classes
+        // None
+        
+    private:	// New functions
+    	// None
+
+    private:	// Functions from base classes
+	    /**
+	    * From AknView, Activates view
+	    */
+	    void DoActivateL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,
+	        const TDesC8& aCustomMessage);
+	
+	    /**
+	    * From AknView, Deactivates view
+	    */
+	    void DoDeactivate();
+    
+	public:		//Data
+	    // None
+        
+	protected:	// Data
+        // None
+        
+    private:	// Data
+    	CUITestServerStarterAppContainer* iContainer; // View container
+		
+    public:		// Friend classes
+        // None
+
+    protected:	// Friend classes
+        // None
+
+    private:	// Friend classes
+        // None
+	};
+
+#endif // UITESTSERVERSTARTERAPPVIEW_H_
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/uitestserverstarter/inc/UITestServerStarterApplication.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,111 @@
+/*
+* 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: This file contains the header file of the 
+* CUITestServerStarterApplication class.
+*
+*/
+
+#ifndef UITESTSERVERSTARTERAPPLICATION_H_
+#define UITESTSERVERSTARTERAPPLICATION_H_
+
+
+//  INCLUDES
+#include <aknapp.h>
+#include "UITestServerStarter.hrh"
+
+// CONSTANTS
+
+// UID for the application;
+const TUid KUidUITestServerStarterApp =
+	{
+	_UID3
+	};
+
+const TUid KMainViewId = { 1982 };
+// CLASS DECLARATION
+
+// CLASS DECLARATION
+// DESCRIPTION
+/**
+ * UITestServerStarterApplication application class.
+ * Provides factory to create concrete document object.
+ * An instance of CUITestServerStarterApplication is the application part of the
+ * AVKON application framework for the CUITestServerStarterApplication application.
+ */
+class CUITestServerStarterApplication : public CAknApplication
+	{
+	public: // Enumerations
+	    // None
+	
+	private: // Enumerations
+	    // None
+	
+	public:  // Constructors and destructor
+	    /**
+	    * C++ destructor.
+	    */
+	
+	public:
+	// Functions from base classes
+	
+	/**
+	 * From CApaApplication, AppDllUid.
+	 * @return Application's UID (KUidUITestServerStarterApplication).
+	 */
+	TUid AppDllUid () const;
+	
+	protected: // Functions from base classes
+	
+	/**
+	 * From CApaApplication, CreateDocumentL.
+	 * Creates CUITestServerStarterDocument document object. The returned
+	 * pointer in not owned by the CUITestServerStarterApplication object.
+	 * @return A pointer to the created document object.
+	 */
+	CApaDocument* CreateDocumentL ();
+	
+	virtual void PreDocConstructL();
+	
+	
+    protected:	// New functions
+        // None
+        
+    protected:	// Functions from base classes
+        // None	
+	
+    private:	// New functions
+    	// None
+	
+	public:		//Data
+	    // None
+        
+	protected:	// Data
+        // None
+        
+    private:	// Data
+    	// None
+			
+	public:		// Friend classes
+		// None
+	
+	protected:	// Friend classes
+		// None
+	
+	private:	// Friend classes
+		// None		
+	};
+
+
+
+#endif /*UITESTSERVERSTARTERAPPLICATION_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/uitestserverstarter/inc/UITestServerStarterDocument.h	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,144 @@
+/*
+* 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: This file contains the header file of the 
+* UITestServerStarter Document class.
+*
+*/
+
+#ifndef UITESTSERVERSTARTERDOCUMENT_H_
+#define UITESTSERVERSTARTERDOCUMENT_H_
+
+//  INCLUDES
+#include <akndoc.h>
+
+// CONSTANTS
+// None
+
+// MACROS
+// None
+
+// DATA TYPES
+// None
+
+// FUNCTION PROTOTYPES
+// None
+
+// FORWARD DECLARATIONS
+class CUITestServerStarterAppUi;
+class CEikApplication;
+
+// CLASS DECLARATION
+
+// DESCRIPTION
+/**
+ * CClockTestDocument application class.
+ * An instance of class CClockTestDocument is the Document part of the
+ * AVKON application framework for the ClockTest example application.
+ */
+class CUITestServerStarterDocument : public CAknDocument
+	{
+	public: // Enumerations
+	    // None
+	
+	private: // Enumerations
+	    // None
+
+	private:  // Constructors and destructor
+		// None
+	public: // New functions
+	
+	/**
+	 * NewL.
+	 * Two-phased constructor.
+	 * Construct a CUITestServerStarterDocument for the AVKON application aApp
+	 * using two phase construction, and return a pointer
+	 * to the created object.
+	 * @param aApp Application creating this document.
+	 * @return A pointer to the created instance of CUITestServerStarterDocument.
+	 */
+	static CUITestServerStarterDocument* NewL (CEikApplication& aApp);
+	
+	/**
+	 * NewLC.
+	 * Two-phased constructor.
+	 * Construct a CUITestServerStarterDocument for the AVKON application aApp
+	 * using two phase construction, and return a pointer
+	 * to the created object.
+	 * @param aApp Application creating this document.
+	 * @return A pointer to the created instance of CUITestServerStarterDocument.
+	 */
+	static CUITestServerStarterDocument* NewLC (CEikApplication& aApp);
+	
+	/**
+	 * ~CUITestServerStarterDocument
+	 * Virtual Destructor.
+	 */
+	virtual ~CUITestServerStarterDocument();
+	
+	public: // Functions from base classes
+	
+		/**
+		 * CreateAppUiL
+		 * From CEikDocument, CreateAppUiL.
+		 * Create a CUITestServerStarterAppUi object and return a pointer to it.
+		 * The object returned is owned by the Uikon framework.
+		 * @return Pointer to created instance of AppUi.
+		 */
+		CEikAppUi* CreateAppUiL ();
+	
+    protected:	// New functions
+        // None
+        
+    protected:	// Functions from base classes
+        // None
+
+    private:	// New functions
+	
+		/**
+		 * ConstructL
+		 * 2nd phase constructor.
+		 */
+		void ConstructL ();
+		
+		/**
+		 * CUITestServerStarterDocument.
+		 * C++ default constructor.
+		 * @param aApp Application creating this document.
+		 */
+		CUITestServerStarterDocument( CEikApplication& aApp );
+    
+	private:	// Functions from base classes
+        // None    
+    
+	public:		//Data
+	    // None
+        
+	protected:	// Data
+        // None
+        
+    private:	// Data
+        // None
+		
+    public:		// Friend classes
+        // None
+
+    protected:	// Friend classes
+        // None
+
+    private:	// Friend classes
+        // None	
+	};
+
+
+#endif /*UITESTSERVERSTARTERDOCUMENT_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/uitestserverstarter/src/AknUiEnvProxy.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,674 @@
+/*
+* 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: This module contains the implementation of 
+* CAknUiEnvProxy class member functions.
+*
+*/
+
+// INCLUDE FILES
+#include "AknUiEnvProxy.h"
+#include "UITestServerStarterAppUi.h"
+#include "EventUtil.h"
+
+#include <coeaui.h>
+#include <eikenv.h>
+#include <apgtask.h>
+#include <w32std.h>
+
+// EXTERNAL DATA STRUCTURES
+// None
+
+// EXTERNAL FUNCTION PROTOTYPES  
+// None
+
+// CONSTANTS
+// None
+
+// MACROS
+// None
+
+// LOCAL CONSTANTS AND MACROS
+// None
+
+// MODULE DATA STRUCTURES
+// None
+
+// LOCAL FUNCTION PROTOTYPES
+// None
+
+// FORWARD DECLARATIONS
+// None
+
+// ================= MEMBER FUNCTIONS =========================================
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CAknUiEnvProxy
+
+     Method: NewL
+
+     Description: NewL is first phase of two-phased constructor.
+
+     NewL is first phase of two-phased constructor.
+
+     Parameters: CUITestServerStarterAppUi* aAppUi: in: Pointer to CUITestServerStarterAppUi.
+     
+     Return Values: Pointer to new CAknUiEnvProxy object.
+
+     Errors/Exceptions: Leaves if new or ConstructL leaves.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+CAknUiEnvProxy* CAknUiEnvProxy::NewL( CUITestServerStarterAppUi* aAppUi )
+	{
+	CAknUiEnvProxy* self = new(ELeave)CAknUiEnvProxy();
+	CleanupStack::PushL( self );
+	self->ConstructL( aAppUi );
+	CleanupStack::Pop( self );
+	return self;
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CAknUiEnvProxy
+
+     Method: ConstructL
+
+     Description: ConstructL is second phase of two-phased constructor.
+
+     Performs construction of CAknUiEnvProxy object.
+
+     Parameters: CUITestServerStarterAppUi* aAppUi: in: Pointer to CUITestServerStarterAppUi.
+     
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CAknUiEnvProxy::ConstructL( CUITestServerStarterAppUi* aAppUi )
+	{	
+	iAppUi = aAppUi;
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CAknUiEnvProxy
+
+     Method: BringToForeground
+
+     Description: Brings UI component container to foreground.
+
+     Brings UI component container to foreground. 
+
+     Parameters: None.
+     
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CAknUiEnvProxy::BringToForeground()
+	{
+	TApaTask task( CCoeEnv::Static()->WsSession() );
+	task.SetWgId( CCoeEnv::Static()->RootWin().Identifier() );
+	task.BringToForeground();	
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CAknUiEnvProxy
+
+     Method: SendToBackground
+
+     Description: Sends UI component container to background.
+
+     Sends UI component container to background.
+
+     Parameters: None.
+     
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CAknUiEnvProxy::SendToBackground(  )
+	{
+	TApaTask task( CCoeEnv::Static()->WsSession() );
+	task.SetWgId( CCoeEnv::Static()->RootWin().Identifier() ); 
+	task.SendToBackground();		
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CAknUiEnvProxy
+
+     Method: PressKeyL
+
+     Description: Sends local key press event to UI component.
+
+     Sends key press event to UI component. UI component must be first added to 
+     AppUi stack to be able to recive this key event. 
+
+     Parameters: TRequestStatus* aStatus: out: Pointer to request status used to notify that
+     										   key event was recived.
+     			 TUint aKeyCode: in: Key code.
+     			 TInt aKeyScanCode: in: Key scan code.
+     			 TUint aKeyModifiers: in: Key modifiers
+     			 TInt aKeyRepeats: in: Key press repeats count.
+     
+     Return Values: None.
+
+     Errors/Exceptions: Leaves if some error occurs during key event sending.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CAknUiEnvProxy::PressKeyL( TRequestStatus* aStatus, TUint aKeyCode, TInt aKeyScanCode, 
+							   TUint aKeyModifiers, TInt aKeyRepeats )
+	{
+	// Fill key event structure
+	TWsEvent wsEvent;
+	wsEvent.SetType(EEventKey);
+	TKeyEvent* keyEvent = wsEvent.Key();
+	keyEvent->iCode = aKeyCode;
+	keyEvent->iScanCode = aKeyScanCode;
+	keyEvent->iModifiers = aKeyModifiers;
+	keyEvent->iRepeats = aKeyRepeats;
+		
+	// Send info to AppUi that we are going to send key event
+	iAppUi->PrepareToPressKey();
+	
+	RWsSession& wsSession = CCoeEnv::Static()->WsSession();
+	TInt wgId = CCoeEnv::Static()->RootWin().Identifier();	
+	// Send key event
+	TInt ret = wsSession.SendEventToWindowGroup( wgId, wsEvent );
+	User::LeaveIfError( ret );
+	
+	// Request notification when key press is handled
+	*aStatus = KRequestPending;
+	iAppUi->NotifyAboutHandledKeyPress( aStatus );
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CAknUiEnvProxy
+
+     Method: PressKeyL
+
+     Description: Sends global key press event to UI component.
+
+     Sends key press event to UI component which is currently focuused. 
+
+     Parameters: TUint aKeyCode: in: Key code.
+     			 TInt aKeyScanCode: in: Key scan code.
+     			 TUint aKeyModifiers: in: Key modifiers
+     			 TInt aKeyRepeats: in: Key press repeats count.
+     
+     Return Values: None.
+
+     Errors/Exceptions: Leaves if some error occurs during key event sending.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CAknUiEnvProxy::PressKeyL( TUint aKeyCode, TInt aKeyScanCode, 
+							   TUint aKeyModifiers, TInt aKeyRepeats )
+	{	
+	// Fill key event structure
+	TWsEvent wsEvent;
+	wsEvent.SetType(EEventKey);
+	TKeyEvent* keyEvent = wsEvent.Key();
+	keyEvent->iCode = aKeyCode;
+	keyEvent->iScanCode = aKeyScanCode;
+	keyEvent->iModifiers = aKeyModifiers;
+	keyEvent->iRepeats = aKeyRepeats;
+		
+	RWsSession& wsSession = CCoeEnv::Static()->WsSession();	
+	TInt wgId = wsSession.GetFocusWindowGroup();	
+	TInt ret = wsSession.SendEventToWindowGroup( wgId, wsEvent );	
+	User::LeaveIfError( ret );
+	}
+
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CAknUiEnvProxy
+
+     Method: TypeTextL
+
+     Description: Sends text to UI component.
+
+     Sends text to UI component. UI component must be first added to 
+     AppUi stack to be able to recive this key event. 
+
+     Parameters: TRequestStatus* aStatus: out: Pointer to request status used to notify that
+     										   key event was recived.
+    			 TPtrC aText: in: Text which will be send to UI component. 
+     
+     Return Values: None.
+
+     Errors/Exceptions: Leaves if some error occurs during key event sending.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CAknUiEnvProxy::TypeTextL( TRequestStatus* aStatus, const TDesC& aText )
+	{
+	TLex textParser( aText );
+
+	// Send info to AppUi that we are going to send text
+	iAppUi->PrepareToTypeText( aText.Length() );
+	
+	TInt wgId = CCoeEnv::Static()->RootWin().Identifier();
+	RWsSession& wsSession = CCoeEnv::Static()->WsSession();
+
+	TChar character = 0;
+	while ( ( character = textParser.Get() ) != 0 )
+		{
+		// Fill key event structure
+		TWsEvent wsEvent;
+		wsEvent.SetType(EEventKey);
+		TKeyEvent* keyEvent = wsEvent.Key();
+		keyEvent->iCode = character;
+		keyEvent->iScanCode = 0;
+		keyEvent->iModifiers = 0;
+		keyEvent->iRepeats = 0;
+		
+		// Send single character from text to UI component
+		TInt ret = wsSession.SendEventToWindowGroup( wgId, wsEvent );
+		User::LeaveIfError( ret );
+		}
+		
+	// Request notification when send text is recived
+	*aStatus = KRequestPending;
+	iAppUi->NotifyAboutHandledTextType( aStatus );	
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CAknUiEnvProxy
+
+     Method: TypeTextL
+
+     Description: Sends global text to UI component.
+
+     Sends global text to UI component. UI component must be focused to receive that event. 
+
+     Parameters: TPtrC aText: in: Text which will be send to UI component. 
+     
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CAknUiEnvProxy::TypeTextL( const TDesC& aText )
+	{
+	TLex textParser( aText );
+
+	RWsSession& wsSession = CCoeEnv::Static()->WsSession();
+	TInt wgId = wsSession.GetFocusWindowGroup();
+
+	TChar character = 0;	
+	while ( ( character = textParser.Get() ) != 0 )
+		{
+		// Fill key event structure
+		TWsEvent wsEvent;
+		wsEvent.SetType(EEventKey);
+		TKeyEvent* keyEvent = wsEvent.Key();
+		keyEvent->iCode = character;
+		keyEvent->iScanCode = 0;
+		keyEvent->iModifiers = 0;
+		keyEvent->iRepeats = 0;
+		
+		// Send single character from text to UI component
+		TInt ret = wsSession.SendEventToWindowGroup( wgId, wsEvent );			
+		User::LeaveIfError( ret );
+		}
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CAknUiEnvProxy
+
+     Method: SendPointerEventL
+
+     Description: Send pointer event
+
+     Send pointer event.
+
+     Parameters: TUint aType: in: KEvent type.
+     			 const TPoint& aPosition: in: Position.
+     			      
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CAknUiEnvProxy::SendPointerEventL( TUint aType, const TPoint& aPosition )
+	{
+	RWsSession& wsSession = CCoeEnv::Static()->WsSession();
+	TRawEvent pointerEvent;
+
+	if ( aType < TEventUtil::EButton1 ) {
+		pointerEvent.Set( ( TRawEvent::TType )aType, aPosition.iX, aPosition.iY );
+		wsSession.SimulateRawEvent( pointerEvent );
+		} 
+	else if ( ( aType >= TEventUtil::EButton1 ) && ( aType <= TEventUtil::EButton3 ) )
+		{
+		TRawEvent pointerEventDown;
+		TRawEvent pointerEventUp;
+		
+		switch ( aType )
+			{
+			case TEventUtil::EButton1:
+				{
+				pointerEventDown.Set( TRawEvent::EButton1Down, aPosition.iX, aPosition.iY );
+				pointerEventUp.Set( TRawEvent::EButton1Up, aPosition.iX, aPosition.iY );
+				}
+				break;
+			case TEventUtil::EButton2:
+				{
+				pointerEventDown.Set( TRawEvent::EButton2Down, aPosition.iX, aPosition.iY );
+				pointerEventUp.Set( TRawEvent::EButton2Up, aPosition.iX, aPosition.iY );
+				}
+				break;
+			case TEventUtil::EButton3:
+				{
+				pointerEventDown.Set( TRawEvent::EButton3Down, aPosition.iX, aPosition.iY );
+				pointerEventUp.Set( TRawEvent::EButton3Up, aPosition.iX, aPosition.iY );
+				}
+				break;
+			default:
+				User::Leave( KErrArgument );
+			}
+		wsSession.SimulateRawEvent( pointerEventDown );
+		wsSession.SimulateRawEvent( pointerEventUp );
+		}
+	else
+		{
+		User::Leave( KErrArgument );
+		}	
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CAknUiEnvProxy
+
+     Method: SendPointerEventL
+
+     Description: Send pointer event
+
+     Send pointer event.
+
+     Parameters: TRequestStatus* aStatus: in: Pointer to request status used to notify that
+     										  pointer event was recived.
+     			 TUint aType: in: KEvent type.
+     			 const TPoint& aPosition: in: Position.
+     			      
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CAknUiEnvProxy::SendPointerEventL( TRequestStatus* aStatus, TUint aType, const TPoint& aPosition )
+	{
+	RWsSession& wsSession = CCoeEnv::Static()->WsSession();
+
+	if ( aType < TEventUtil::EButton1 ) {
+		TRawEvent pointerEvent;
+		pointerEvent.Set( ( TRawEvent::TType )aType, aPosition.iX, aPosition.iY );
+		// Send info to AppUi that we are going to send key event
+		iAppUi->PrepareToPointerEvent();
+		wsSession.SimulateRawEvent( pointerEvent );
+		// Request notification when key press is handled
+		*aStatus = KRequestPending;
+		iAppUi->NotifyAboutHandledPointerEvent( aStatus );	
+		} 
+	else if ( ( aType >= TEventUtil::EButton1 ) && ( aType <= TEventUtil::EButton3 ) )
+		{
+		TRawEvent pointerEventDown;
+		TRawEvent pointerEventUp;
+		switch ( aType )
+			{
+			case TEventUtil::EButton1:
+				{
+				pointerEventDown.Set( TRawEvent::EButton1Down, aPosition.iX, aPosition.iY );
+				pointerEventUp.Set( TRawEvent::EButton1Up, aPosition.iX, aPosition.iY );
+				}
+				break;
+			case TEventUtil::EButton2:
+				{
+				pointerEventDown.Set( TRawEvent::EButton2Down, aPosition.iX, aPosition.iY );
+				pointerEventUp.Set( TRawEvent::EButton2Up, aPosition.iX, aPosition.iY );
+				}
+				break;
+			case TEventUtil::EButton3:
+				{
+				pointerEventDown.Set( TRawEvent::EButton3Down, aPosition.iX, aPosition.iY );
+				pointerEventUp.Set( TRawEvent::EButton3Up, aPosition.iX, aPosition.iY );
+				}
+				break;
+			default:
+				User::Leave( KErrArgument );
+			}
+		
+			CCoeEnv::Static()->RootWin().SimulatePointerEvent( pointerEventDown );
+			
+			// Send info to AppUi that we are going to send key event
+			iAppUi->PrepareToPointerEvent();
+	
+			CCoeEnv::Static()->RootWin().SimulatePointerEvent( pointerEventUp );
+	
+			// Request notification when key press is handled
+			*aStatus = KRequestPending;
+			iAppUi->NotifyAboutHandledPointerEvent( aStatus );	
+		} 
+	else
+		{
+		User::Leave( KErrArgument );
+		}
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CAknUiEnvProxy
+
+     Method: ParseKeyCode
+
+     Description: Parses key code.
+
+     Parses key code.
+
+     Parameters: TDesC& aKeyCodeName: in: Key code name.
+     			 TUint& aKeyCode: out: Parsed key code.
+     
+     Return Values: KErrNone if no error occures during parsing.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+TInt CAknUiEnvProxy::ParseKeyCode( const TDesC& aKeyCodeName, TUint& aKeyCode ) const
+	{
+	return TEventUtil::ParseKeyCode( aKeyCodeName, aKeyCode );
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CAknUiEnvProxy
+
+     Method: ParseKeyScanCode
+
+     Description: Parses key scan code.
+
+     Parses key scan code.
+
+     Parameters: TDesC& aKeyScanCodeName: in: Key scan code name.
+     			 TUint& aKeyScanCode: out: Parsed key scan code.
+     
+     Return Values: KErrNone if no error occures during parsing.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+TInt CAknUiEnvProxy::ParseKeyScanCode( const TDesC& aKeyScanCodeName, TInt& aKeyScanCode ) const
+	{
+	return TEventUtil::ParseKeyScanCode( aKeyScanCodeName, aKeyScanCode );
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CAknUiEnvProxy
+
+     Method: ParseModifier
+
+     Description: Parses key modifier.
+
+     Parses key modifier.
+
+     Parameters: TDesC& aModifierName: in: Key modifier.
+     			 TUint& aModifier: out: Parsed key modifier.
+     
+     Return Values: KErrNone if no error occures during parsing.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+TInt CAknUiEnvProxy::ParseModifier( const TDesC& aModifierName, TUint& aModifier ) const
+	{
+	return TEventUtil::ParseModifier( aModifierName, aModifier );
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CAknUiEnvProxy
+
+     Method: ParsePointerEventType
+
+     Description: Parses pointer event type.
+
+     Parses key modifier.
+
+     Parameters: const TDesC& aPointerEventTypeName: in: Pointer event type.
+     			 TUint& aModifier: out: Parsed pointer event type.
+     
+     Return Values: KErrNone if no error occures during parsing.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+TInt CAknUiEnvProxy::ParsePointerEventType( const TDesC& aPointerEventTypeName, TUint& aPointerEventType ) const
+	{
+	return TEventUtil::ParsePointerEventType( aPointerEventTypeName, aPointerEventType );
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CAknUiEnvProxy
+
+     Method: CAknUiEnvProxy
+
+     Description: C++ constructor.
+
+     C++ constructor.
+
+     Parameters: None
+     
+     Return Values: None
+
+     Errors/Exceptions: None
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+CAknUiEnvProxy::CAknUiEnvProxy()
+	{	
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CAknUiEnvProxy
+
+     Method: ~CAknUiEnvProxy
+
+     Description: C++ destructor.
+
+     C++ destructor.
+
+     Parameters: None
+     
+     Return Values: None
+
+     Errors/Exceptions: None
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+CAknUiEnvProxy::~CAknUiEnvProxy()
+	{	
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/uitestserverstarter/src/EventUtil.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,1100 @@
+/*
+* 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: This module contains the implementation of 
+* CAknUiEnvProxy class member functions.
+*
+*/
+
+// INCLUDE FILES
+#include "EventUtil.h"
+#include <e32def.h>
+#include <e32keys.h>
+#include <w32std.h>
+
+// EXTERNAL DATA STRUCTURES
+// None
+
+// EXTERNAL FUNCTION PROTOTYPES  
+// None
+
+// CONSTANTS
+// None
+
+// MACROS
+
+/**
+ * Key code names definition macro
+ */
+#define DefineKeyCodeNames( varName ) 			\
+	static TText* const varName[] =				\
+        {										\
+        (TText*)L"ekeynull",			\
+        (TText*)L"ekeybell",			\
+        (TText*)L"ekeybackspace",		\
+        (TText*)L"ekeytab",				\
+        (TText*)L"ekeylinefeed",		\
+        (TText*)L"ekeyverticaltab",		\
+        (TText*)L"ekeyformfeed",		\
+        (TText*)L"ekeyenter",			\
+        (TText*)L"ekeyescape",			\
+        (TText*)L"ekeyspace",			\
+        (TText*)L"ekeydelete",			\
+        (TText*)L"ekeyprintscreen",		\
+        (TText*)L"ekeypause",			\
+        (TText*)L"ekeyhome",			\
+        (TText*)L"ekeyend",				\
+        (TText*)L"ekeypageup",			\
+        (TText*)L"ekeypagedown",		\
+        (TText*)L"ekeyinsert",			\
+        (TText*)L"ekeyleftarrow",		\
+        (TText*)L"ekeyrightarrow",		\
+        (TText*)L"ekeyuparrow",			\
+        (TText*)L"ekeydownarrow",		\
+        (TText*)L"ekeyleftshift",		\
+        (TText*)L"ekeyrightshift",		\
+        (TText*)L"ekeyleftalt",			\
+        (TText*)L"ekeyrightalt",		\
+        (TText*)L"ekeyleftctrl",		\
+        (TText*)L"ekeyrightctrl",		\
+        (TText*)L"ekeyleftfunc",		\
+        (TText*)L"ekeyrightfunc",		\
+        (TText*)L"ekeycapslock",		\
+        (TText*)L"ekeynumlock",			\
+        (TText*)L"ekeyscrolllock",		\
+        (TText*)L"ekeyf1",				\
+        (TText*)L"ekeyf2",				\
+        (TText*)L"ekeyf3",				\
+        (TText*)L"ekeyf4",				\
+        (TText*)L"ekeyf5",				\
+        (TText*)L"ekeyf6",				\
+        (TText*)L"ekeyf7",				\
+        (TText*)L"ekeyf8",				\
+        (TText*)L"ekeyf9",				\
+        (TText*)L"ekeyf10",				\
+        (TText*)L"ekeyf11",				\
+        (TText*)L"ekeyf12",				\
+        (TText*)L"ekeyf13",				\
+        (TText*)L"ekeyf14",				\
+        (TText*)L"ekeyf15",				\
+        (TText*)L"ekeyf16",				\
+        (TText*)L"ekeyf17",				\
+        (TText*)L"ekeyf18",				\
+        (TText*)L"ekeyf19",				\
+        (TText*)L"ekeyf20",				\
+        (TText*)L"ekeyf21",				\
+        (TText*)L"ekeyf22",				\
+        (TText*)L"ekeyf23",				\
+        (TText*)L"ekeyf24",				\
+        (TText*)L"ekeyoff",				\
+        (TText*)L"ekeyinccontrast",		\
+        (TText*)L"ekeydeccontrast",		\
+        (TText*)L"ekeybacklighton",		\
+        (TText*)L"ekeybacklightoff",	\
+        (TText*)L"ekeybacklighttoggle",	\
+        (TText*)L"ekeysliderdown",		\
+        (TText*)L"ekeysliderup",		\
+        (TText*)L"ekeymenu",			\
+        (TText*)L"ekeydictaphoneplay",	\
+        (TText*)L"ekeydictaphonestop",	\
+        (TText*)L"ekeydictaphonerecord",\
+        (TText*)L"ekeyhelp",			\
+        (TText*)L"ekeydial",			\
+        (TText*)L"ekeyscreendimension0",\
+        (TText*)L"ekeyscreendimension1",\
+        (TText*)L"ekeyscreendimension2",\
+        (TText*)L"ekeyscreendimension3",\
+        (TText*)L"ekeyincvolume",		\
+        (TText*)L"ekeydecvolume",		\
+        (TText*)L"ekeydevice0",			\
+        (TText*)L"ekeydevice1",			\
+        (TText*)L"ekeydevice2",			\
+        (TText*)L"ekeydevice3",			\
+        (TText*)L"ekeydevice4",			\
+        (TText*)L"ekeydevice5",			\
+        (TText*)L"ekeydevice6",			\
+        (TText*)L"ekeydevice7",			\
+        (TText*)L"ekeydevice8",			\
+        (TText*)L"ekeydevice9",			\
+        (TText*)L"ekeydevicea",			\
+        (TText*)L"ekeydeviceb",			\
+        (TText*)L"ekeydevicec",			\
+        (TText*)L"ekeydeviced",			\
+        (TText*)L"ekeydevicee",			\
+        (TText*)L"ekeydevicef",			\
+        (TText*)L"ekeyapplication0",	\
+        (TText*)L"ekeyapplication1",	\
+        (TText*)L"ekeyapplication2",	\
+        (TText*)L"ekeyapplication3",	\
+        (TText*)L"ekeyapplication4",	\
+        (TText*)L"ekeyapplication5",	\
+        (TText*)L"ekeyapplication6",	\
+        (TText*)L"ekeyapplication7",	\
+        (TText*)L"ekeyapplication8",	\
+        (TText*)L"ekeyapplication9",	\
+        (TText*)L"ekeyapplicationa",	\
+        (TText*)L"ekeyapplicationb",	\
+        (TText*)L"ekeyapplicationc",	\
+        (TText*)L"ekeyapplicationd",	\
+        (TText*)L"ekeyapplicatione",	\
+        (TText*)L"ekeyapplicationf",	\
+        (TText*)L"ekeyyes",				\
+        (TText*)L"ekeyno",				\
+        (TText*)L"ekeyincbrightness",	\
+        (TText*)L"ekeydecbrightness",	\
+        (TText*)L"ekeykeyboardextend",	\
+        (TText*)L"ekeydevice10",		\
+        (TText*)L"ekeydevice11",		\
+        (TText*)L"ekeydevice12",		\
+        (TText*)L"ekeydevice13",		\
+        (TText*)L"ekeydevice14",		\
+        (TText*)L"ekeydevice15",		\
+        (TText*)L"ekeydevice16",		\
+        (TText*)L"ekeydevice17",		\
+        (TText*)L"ekeydevice18",		\
+        (TText*)L"ekeydevice19",		\
+        (TText*)L"ekeydevice1a",		\
+        (TText*)L"ekeydevice1b",		\
+        (TText*)L"ekeydevice1c",		\
+        (TText*)L"ekeydevice1d",		\
+        (TText*)L"ekeydevice1e",		\
+        (TText*)L"ekeydevice1f",		\
+        (TText*)L"ekeyapplication10",	\
+        (TText*)L"ekeyapplication11",	\
+        (TText*)L"ekeyapplication12",	\
+        (TText*)L"ekeyapplication13",	\
+        (TText*)L"ekeyapplication14",	\
+        (TText*)L"ekeyapplication15",	\
+        (TText*)L"ekeyapplication16",	\
+        (TText*)L"ekeyapplication17",	\
+        (TText*)L"ekeyapplication18",	\
+        (TText*)L"ekeyapplication19",	\
+        (TText*)L"ekeyapplication1a",	\
+        (TText*)L"ekeyapplication1b",	\
+        (TText*)L"ekeyapplication1c",	\
+        (TText*)L"ekeyapplication1d",	\
+        (TText*)L"ekeyapplication1e",	\
+        (TText*)L"ekeyapplication1f",	\
+        }
+
+/**
+ * Key codes definition macro
+ */
+#define DefineKeyCodes( varName )		\
+	static TUint const varName[] = 		\
+		{								\
+        (TUint)EKeyNull,				\
+        (TUint)EKeyBell,				\
+        (TUint)EKeyBackspace,			\
+        (TUint)EKeyTab,					\
+        (TUint)EKeyLineFeed,			\
+        (TUint)EKeyVerticalTab,			\
+        (TUint)EKeyFormFeed,			\
+        (TUint)EKeyEnter,				\
+        (TUint)EKeyEscape,				\
+        (TUint)EKeySpace,				\
+        (TUint)EKeyDelete,				\
+        (TUint)EKeyPrintScreen,			\
+        (TUint)EKeyPause,				\
+        (TUint)EKeyHome,				\
+        (TUint)EKeyEnd,					\
+        (TUint)EKeyPageUp,				\
+        (TUint)EKeyPageDown,			\
+        (TUint)EKeyInsert,				\
+        (TUint)EKeyLeftArrow,			\
+        (TUint)EKeyRightArrow,			\
+        (TUint)EKeyUpArrow,				\
+        (TUint)EKeyDownArrow,			\
+        (TUint)EKeyLeftShift,			\
+        (TUint)EKeyRightShift,			\
+        (TUint)EKeyLeftAlt,				\
+        (TUint)EKeyRightAlt,			\
+        (TUint)EKeyLeftCtrl,			\
+        (TUint)EKeyRightCtrl,			\
+        (TUint)EKeyLeftFunc,			\
+        (TUint)EKeyRightFunc,			\
+        (TUint)EKeyCapsLock,			\
+        (TUint)EKeyNumLock,				\
+        (TUint)EKeyScrollLock,			\
+        (TUint)EKeyF1,					\
+        (TUint)EKeyF2,					\
+        (TUint)EKeyF3,					\
+        (TUint)EKeyF4,					\
+        (TUint)EKeyF5,					\
+        (TUint)EKeyF6,					\
+        (TUint)EKeyF7,					\
+        (TUint)EKeyF8,					\
+        (TUint)EKeyF9,					\
+        (TUint)EKeyF10,					\
+        (TUint)EKeyF11,					\
+        (TUint)EKeyF12,					\
+        (TUint)EKeyF13,					\
+        (TUint)EKeyF14,					\
+        (TUint)EKeyF15,					\
+        (TUint)EKeyF16,					\
+        (TUint)EKeyF17,					\
+        (TUint)EKeyF18,					\
+        (TUint)EKeyF19,					\
+        (TUint)EKeyF20,					\
+        (TUint)EKeyF21,					\
+        (TUint)EKeyF22,					\
+        (TUint)EKeyF23,					\
+        (TUint)EKeyF24,					\
+        (TUint)EKeyOff,					\
+        (TUint)EKeyIncContrast,			\
+        (TUint)EKeyDecContrast,			\
+        (TUint)EKeyBacklightOn,			\
+        (TUint)EKeyBacklightOff,		\
+        (TUint)EKeyBacklightToggle,		\
+        (TUint)EKeySliderDown,			\
+        (TUint)EKeySliderUp,			\
+        (TUint)EKeyMenu,				\
+        (TUint)EKeyDictaphonePlay,		\
+        (TUint)EKeyDictaphoneStop,		\
+        (TUint)EKeyDictaphoneRecord,	\
+        (TUint)EKeyHelp,				\
+        (TUint)EKeyDial,				\
+        (TUint)EKeyScreenDimension0,	\
+        (TUint)EKeyScreenDimension1,	\
+        (TUint)EKeyScreenDimension2,	\
+        (TUint)EKeyScreenDimension3,	\
+        (TUint)EKeyIncVolume,			\
+        (TUint)EKeyDecVolume,			\
+        (TUint)EKeyDevice0,				\
+        (TUint)EKeyDevice1,				\
+        (TUint)EKeyDevice2,				\
+        (TUint)EKeyDevice3,				\
+        (TUint)EKeyDevice4,				\
+        (TUint)EKeyDevice5,				\
+        (TUint)EKeyDevice6,				\
+        (TUint)EKeyDevice7,				\
+        (TUint)EKeyDevice8,				\
+        (TUint)EKeyDevice9,				\
+        (TUint)EKeyDeviceA,				\
+        (TUint)EKeyDeviceB,				\
+        (TUint)EKeyDeviceC,				\
+        (TUint)EKeyDeviceD,				\
+        (TUint)EKeyDeviceE,				\
+        (TUint)EKeyDeviceF,				\
+        (TUint)EKeyApplication0,		\
+        (TUint)EKeyApplication1,		\
+        (TUint)EKeyApplication2,		\
+        (TUint)EKeyApplication3,		\
+        (TUint)EKeyApplication4,		\
+        (TUint)EKeyApplication5,		\
+        (TUint)EKeyApplication6,		\
+        (TUint)EKeyApplication7,		\
+        (TUint)EKeyApplication8,		\
+        (TUint)EKeyApplication9,		\
+        (TUint)EKeyApplicationA,		\
+        (TUint)EKeyApplicationB,		\
+        (TUint)EKeyApplicationC,		\
+        (TUint)EKeyApplicationD,		\
+        (TUint)EKeyApplicationE,		\
+        (TUint)EKeyApplicationF,		\
+        (TUint)EKeyYes,					\
+        (TUint)EKeyNo,					\
+        (TUint)EKeyIncBrightness,		\
+        (TUint)EKeyDecBrightness,		\
+        (TUint)EKeyKeyboardExtend,		\
+        (TUint)EKeyDevice10,			\
+        (TUint)EKeyDevice11,			\
+        (TUint)EKeyDevice12,			\
+        (TUint)EKeyDevice13,			\
+        (TUint)EKeyDevice14,			\
+        (TUint)EKeyDevice15,			\
+        (TUint)EKeyDevice16,			\
+        (TUint)EKeyDevice17,			\
+        (TUint)EKeyDevice18,			\
+        (TUint)EKeyDevice19,			\
+        (TUint)EKeyDevice1A,			\
+        (TUint)EKeyDevice1B,			\
+        (TUint)EKeyDevice1C,			\
+        (TUint)EKeyDevice1D,			\
+        (TUint)EKeyDevice1E,			\
+        (TUint)EKeyDevice1F,			\
+        (TUint)EKeyApplication10,		\
+        (TUint)EKeyApplication11,		\
+        (TUint)EKeyApplication12,		\
+        (TUint)EKeyApplication13,		\
+        (TUint)EKeyApplication14,		\
+        (TUint)EKeyApplication15,		\
+        (TUint)EKeyApplication16,		\
+        (TUint)EKeyApplication17,		\
+        (TUint)EKeyApplication18,		\
+        (TUint)EKeyApplication19,		\
+        (TUint)EKeyApplication1A,		\
+        (TUint)EKeyApplication1B,		\
+        (TUint)EKeyApplication1C,		\
+        (TUint)EKeyApplication1D,		\
+        (TUint)EKeyApplication1E,		\
+        (TUint)EKeyApplication1F,		\
+		}
+
+/**
+ * Key scan code names definition macro.
+ */
+#define DefineKeyScanCodeNames( varName ) 			\
+	static TText* const varName[] =					\
+        {											\
+        (TText*)L"estdkeynull",						\
+        (TText*)L"estdkeybackspace",				\
+        (TText*)L"estdkeytab",						\
+        (TText*)L"estdkeyenter",					\
+        (TText*)L"estdkeyescape",					\
+        (TText*)L"estdkeyspace",					\
+        (TText*)L"estdkeyprintscreen",				\
+        (TText*)L"estdkeypause",					\
+        (TText*)L"estdkeyhome",						\
+        (TText*)L"estdkeyend",						\
+        (TText*)L"estdkeypageup",					\
+        (TText*)L"estdkeypagedown",					\
+        (TText*)L"estdkeyinsert",					\
+        (TText*)L"estdkeydelete",					\
+        (TText*)L"estdkeyleftarrow",				\
+        (TText*)L"estdkeyrightarrow",				\
+        (TText*)L"estdkeyuparrow",					\
+        (TText*)L"estdkeydownarrow",				\
+        (TText*)L"estdkeyleftshift",				\
+        (TText*)L"estdkeyrightshift",				\
+        (TText*)L"estdkeyleftalt",					\
+        (TText*)L"estdkeyrightalt",					\
+        (TText*)L"estdkeyleftctrl",					\
+        (TText*)L"estdkeyrightctrl",				\
+        (TText*)L"estdkeyleftfunc",					\
+        (TText*)L"estdkeyrightfunc",				\
+        (TText*)L"estdkeycapslock",					\
+        (TText*)L"estdkeynumlock",					\
+        (TText*)L"estdkeyscrolllock",				\
+        (TText*)L"estdkeyf1",						\
+        (TText*)L"estdkeyf2",						\
+        (TText*)L"estdkeyf3",						\
+        (TText*)L"estdkeyf4",						\
+        (TText*)L"estdkeyf5",						\
+        (TText*)L"estdkeyf6",						\
+        (TText*)L"estdkeyf7",						\
+        (TText*)L"estdkeyf8",						\
+        (TText*)L"estdkeyf9",						\
+        (TText*)L"estdkeyf10",						\
+        (TText*)L"estdkeyf11",						\
+        (TText*)L"estdkeyf12",						\
+        (TText*)L"estdkeyf13",						\
+        (TText*)L"estdkeyf14",						\
+        (TText*)L"estdkeyf15",						\
+        (TText*)L"estdkeyf16",						\
+        (TText*)L"estdkeyf17",						\
+        (TText*)L"estdkeyf18",						\
+        (TText*)L"estdkeyf19",						\
+        (TText*)L"estdkeyf20",						\
+        (TText*)L"estdkeyf21",						\
+        (TText*)L"estdkeyf22",						\
+        (TText*)L"estdkeyf23",						\
+        (TText*)L"estdkeyf24",						\
+        (TText*)L"estdkeyxxx",						\
+        (TText*)L"estdkeycomma",					\
+        (TText*)L"estdkeyfullstop",					\
+        (TText*)L"estdkeyforwardslash",				\
+        (TText*)L"estdkeybackslash",				\
+        (TText*)L"estdkeysemicolon",				\
+        (TText*)L"estdkeysinglequote",				\
+        (TText*)L"estdkeyhash",						\
+        (TText*)L"estdkeysquarebracketleft",		\
+        (TText*)L"estdkeysquarebracketright",		\
+        (TText*)L"estdkeyminus",					\
+        (TText*)L"estdkeyequals",					\
+        (TText*)L"estdkeynkpforwardslash",			\
+        (TText*)L"estdkeynkpasterisk",				\
+        (TText*)L"estdkeynkpminus",					\
+        (TText*)L"estdkeynkpplus",					\
+        (TText*)L"estdkeynkpenter",					\
+        (TText*)L"estdkeynkp1",						\
+        (TText*)L"estdkeynkp2",						\
+        (TText*)L"estdkeynkp3",						\
+        (TText*)L"estdkeynkp4",						\
+        (TText*)L"estdkeynkp5",						\
+        (TText*)L"estdkeynkp6",						\
+        (TText*)L"estdkeynkp7",						\
+        (TText*)L"estdkeynkp8",						\
+        (TText*)L"estdkeynkp9",						\
+        (TText*)L"estdkeynkp0",						\
+        (TText*)L"estdkeynkpfullstop",				\
+        (TText*)L"estdkeymenu",						\
+        (TText*)L"estdkeybacklighton",				\
+        (TText*)L"estdkeybacklightoff",				\
+        (TText*)L"estdkeybacklighttoggle",			\
+        (TText*)L"estdkeyinccontrast",				\
+        (TText*)L"estdkeydeccontrast",				\
+        (TText*)L"estdkeysliderdown",				\
+        (TText*)L"estdkeysliderup",					\
+        (TText*)L"estdkeydictaphoneplay",			\
+        (TText*)L"estdkeydictaphonestop",			\
+        (TText*)L"estdkeydictaphonerecord",			\
+        (TText*)L"estdkeyhelp",						\
+        (TText*)L"estdkeyoff",						\
+        (TText*)L"estdkeydial",						\
+        (TText*)L"estdkeyincvolume",				\
+        (TText*)L"estdkeydecvolume",				\
+        (TText*)L"estdkeydevice0",					\
+        (TText*)L"estdkeydevice1",					\
+        (TText*)L"estdkeydevice2",					\
+        (TText*)L"estdkeydevice3",					\
+        (TText*)L"estdkeydevice4",					\
+        (TText*)L"estdkeydevice5",					\
+        (TText*)L"estdkeydevice6",					\
+        (TText*)L"estdkeydevice7",					\
+        (TText*)L"estdkeydevice8",					\
+        (TText*)L"estdkeydevice9",					\
+        (TText*)L"estdkeydevicea",					\
+        (TText*)L"estdkeydeviceb",					\
+        (TText*)L"estdkeydevicec",					\
+        (TText*)L"estdkeydeviced",					\
+        (TText*)L"estdkeydevicee",					\
+        (TText*)L"estdkeydevicef",					\
+        (TText*)L"estdkeyapplication0",				\
+        (TText*)L"estdkeyapplication1",				\
+        (TText*)L"estdkeyapplication2",				\
+        (TText*)L"estdkeyapplication3",				\
+        (TText*)L"estdkeyapplication4",				\
+        (TText*)L"estdkeyapplication5",				\
+        (TText*)L"estdkeyapplication6",				\
+        (TText*)L"estdkeyapplication7",				\
+        (TText*)L"estdkeyapplication8",				\
+        (TText*)L"estdkeyapplication9",				\
+        (TText*)L"estdkeyapplicationa",				\
+        (TText*)L"estdkeyapplicationb",				\
+        (TText*)L"estdkeyapplicationc",				\
+        (TText*)L"estdkeyapplicationd",				\
+        (TText*)L"estdkeyapplicatione",				\
+        (TText*)L"estdkeyapplicationf",				\
+        (TText*)L"estdkeyyes",						\
+        (TText*)L"estdkeyno",						\
+        (TText*)L"estdkeyincbrightness",			\
+        (TText*)L"estdkeydecbrightness",			\
+        (TText*)L"estdkeykeyboardextend",			\
+        (TText*)L"estdkeydevice10",					\
+        (TText*)L"estdkeydevice11",					\
+        (TText*)L"estdkeydevice12",					\
+        (TText*)L"estdkeydevice13",					\
+        (TText*)L"estdkeydevice14",					\
+        (TText*)L"estdkeydevice15",					\
+        (TText*)L"estdkeydevice16",					\
+        (TText*)L"estdkeydevice17",					\
+        (TText*)L"estdkeydevice18",					\
+        (TText*)L"estdkeydevice19",					\
+        (TText*)L"estdkeydevice1a",					\
+        (TText*)L"estdkeydevice1b",					\
+        (TText*)L"estdkeydevice1c",					\
+        (TText*)L"estdkeydevice1d",					\
+        (TText*)L"estdkeydevice1e",					\
+        (TText*)L"estdkeydevice1f",					\
+        (TText*)L"estdkeyapplication10",			\
+        (TText*)L"estdkeyapplication11",			\
+        (TText*)L"estdkeyapplication12",			\
+        (TText*)L"estdkeyapplication13",			\
+        (TText*)L"estdkeyapplication14",			\
+        (TText*)L"estdkeyapplication15",			\
+        (TText*)L"estdkeyapplication16",			\
+        (TText*)L"estdkeyapplication17",			\
+        (TText*)L"estdkeyapplication18",			\
+        (TText*)L"estdkeyapplication19",			\
+        (TText*)L"estdkeyapplication1a",			\
+        (TText*)L"estdkeyapplication1b",			\
+        (TText*)L"estdkeyapplication1c",			\
+        (TText*)L"estdkeyapplication1d",			\
+        (TText*)L"estdkeyapplication1e",			\
+        (TText*)L"estdkeyapplication1f",			\
+        }
+
+/**
+ * Key scan codes definition macro.
+ */
+#define DefineKeyScanCodes( varName )		\
+	static TUint const varName[] = 			\
+		{									\
+        (TUint)EStdKeyNull,					\
+        (TUint)EStdKeyBackspace,			\
+        (TUint)EStdKeyTab,					\
+        (TUint)EStdKeyEnter,				\
+        (TUint)EStdKeyEscape,				\
+        (TUint)EStdKeySpace,				\
+        (TUint)EStdKeyPrintScreen,			\
+        (TUint)EStdKeyPause,				\
+        (TUint)EStdKeyHome,					\
+        (TUint)EStdKeyEnd,					\
+        (TUint)EStdKeyPageUp,				\
+        (TUint)EStdKeyPageDown,				\
+        (TUint)EStdKeyInsert,				\
+        (TUint)EStdKeyDelete,				\
+        (TUint)EStdKeyLeftArrow,			\
+        (TUint)EStdKeyRightArrow,			\
+        (TUint)EStdKeyUpArrow,				\
+        (TUint)EStdKeyDownArrow,			\
+        (TUint)EStdKeyLeftShift,			\
+        (TUint)EStdKeyRightShift,			\
+        (TUint)EStdKeyLeftAlt,				\
+        (TUint)EStdKeyRightAlt,				\
+        (TUint)EStdKeyLeftCtrl,				\
+        (TUint)EStdKeyRightCtrl,			\
+        (TUint)EStdKeyLeftFunc,				\
+        (TUint)EStdKeyRightFunc,			\
+        (TUint)EStdKeyCapsLock,				\
+        (TUint)EStdKeyNumLock,				\
+        (TUint)EStdKeyScrollLock,			\
+        (TUint)EStdKeyF1,					\
+        (TUint)EStdKeyF2,					\
+        (TUint)EStdKeyF3,					\
+        (TUint)EStdKeyF4,					\
+        (TUint)EStdKeyF5,					\
+        (TUint)EStdKeyF6,					\
+        (TUint)EStdKeyF7,					\
+        (TUint)EStdKeyF8,					\
+        (TUint)EStdKeyF9,					\
+        (TUint)EStdKeyF10,					\
+        (TUint)EStdKeyF11,					\
+        (TUint)EStdKeyF12,					\
+        (TUint)EStdKeyF13,					\
+        (TUint)EStdKeyF14,					\
+        (TUint)EStdKeyF15,					\
+        (TUint)EStdKeyF16,					\
+        (TUint)EStdKeyF17,					\
+        (TUint)EStdKeyF18,					\
+        (TUint)EStdKeyF19,					\
+        (TUint)EStdKeyF20,					\
+        (TUint)EStdKeyF21,					\
+        (TUint)EStdKeyF22,					\
+        (TUint)EStdKeyF23,					\
+        (TUint)EStdKeyF24,					\
+        (TUint)EStdKeyXXX,					\
+        (TUint)EStdKeyComma,				\
+        (TUint)EStdKeyFullStop,				\
+        (TUint)EStdKeyForwardSlash,			\
+        (TUint)EStdKeyBackSlash,			\
+        (TUint)EStdKeySemiColon,			\
+        (TUint)EStdKeySingleQuote,			\
+        (TUint)EStdKeyHash,					\
+        (TUint)EStdKeySquareBracketLeft,	\
+        (TUint)EStdKeySquareBracketRight,	\
+        (TUint)EStdKeyMinus,				\
+        (TUint)EStdKeyEquals,				\
+        (TUint)EStdKeyNkpForwardSlash,		\
+        (TUint)EStdKeyNkpAsterisk,			\
+        (TUint)EStdKeyNkpMinus,				\
+        (TUint)EStdKeyNkpPlus,				\
+        (TUint)EStdKeyNkpEnter,				\
+        (TUint)EStdKeyNkp1,					\
+        (TUint)EStdKeyNkp2,					\
+        (TUint)EStdKeyNkp3,					\
+        (TUint)EStdKeyNkp4,					\
+        (TUint)EStdKeyNkp5,					\
+        (TUint)EStdKeyNkp6,					\
+        (TUint)EStdKeyNkp7,					\
+        (TUint)EStdKeyNkp8,					\
+        (TUint)EStdKeyNkp9,					\
+        (TUint)EStdKeyNkp0,					\
+        (TUint)EStdKeyNkpFullStop,			\
+        (TUint)EStdKeyMenu,					\
+        (TUint)EStdKeyBacklightOn,			\
+        (TUint)EStdKeyBacklightOff,			\
+        (TUint)EStdKeyBacklightToggle,		\
+        (TUint)EStdKeyIncContrast,			\
+        (TUint)EStdKeyDecContrast,			\
+        (TUint)EStdKeySliderDown,			\
+        (TUint)EStdKeySliderUp,				\
+        (TUint)EStdKeyDictaphonePlay,		\
+        (TUint)EStdKeyDictaphoneStop,		\
+        (TUint)EStdKeyDictaphoneRecord,		\
+        (TUint)EStdKeyHelp,					\
+        (TUint)EStdKeyOff,					\
+        (TUint)EStdKeyDial,					\
+        (TUint)EStdKeyIncVolume,			\
+        (TUint)EStdKeyDecVolume,			\
+        (TUint)EStdKeyDevice0,				\
+        (TUint)EStdKeyDevice1,				\
+        (TUint)EStdKeyDevice2,				\
+        (TUint)EStdKeyDevice3,				\
+        (TUint)EStdKeyDevice4,				\
+        (TUint)EStdKeyDevice5,				\
+        (TUint)EStdKeyDevice6,				\
+        (TUint)EStdKeyDevice7,				\
+        (TUint)EStdKeyDevice8,				\
+        (TUint)EStdKeyDevice9,				\
+        (TUint)EStdKeyDeviceA,				\
+        (TUint)EStdKeyDeviceB,				\
+        (TUint)EStdKeyDeviceC,				\
+        (TUint)EStdKeyDeviceD,				\
+        (TUint)EStdKeyDeviceE,				\
+        (TUint)EStdKeyDeviceF,				\
+        (TUint)EStdKeyApplication0,			\
+        (TUint)EStdKeyApplication1,			\
+        (TUint)EStdKeyApplication2,			\
+        (TUint)EStdKeyApplication3,			\
+        (TUint)EStdKeyApplication4,			\
+        (TUint)EStdKeyApplication5,			\
+        (TUint)EStdKeyApplication6,			\
+        (TUint)EStdKeyApplication7,			\
+        (TUint)EStdKeyApplication8,			\
+        (TUint)EStdKeyApplication9,			\
+        (TUint)EStdKeyApplicationA,			\
+        (TUint)EStdKeyApplicationB,			\
+        (TUint)EStdKeyApplicationC,			\
+        (TUint)EStdKeyApplicationD,			\
+        (TUint)EStdKeyApplicationE,			\
+        (TUint)EStdKeyApplicationF,			\
+        (TUint)EStdKeyYes,					\
+        (TUint)EStdKeyNo,					\
+        (TUint)EStdKeyIncBrightness,		\
+        (TUint)EStdKeyDecBrightness,		\
+        (TUint)EStdKeyKeyboardExtend,		\
+        (TUint)EStdKeyDevice10,				\
+        (TUint)EStdKeyDevice11,				\
+        (TUint)EStdKeyDevice12,				\
+        (TUint)EStdKeyDevice13,				\
+        (TUint)EStdKeyDevice14,				\
+        (TUint)EStdKeyDevice15,				\
+        (TUint)EStdKeyDevice16,				\
+        (TUint)EStdKeyDevice17,				\
+        (TUint)EStdKeyDevice18,				\
+        (TUint)EStdKeyDevice19,				\
+        (TUint)EStdKeyDevice1A,				\
+        (TUint)EStdKeyDevice1B,				\
+        (TUint)EStdKeyDevice1C,				\
+        (TUint)EStdKeyDevice1D,				\
+        (TUint)EStdKeyDevice1E,				\
+        (TUint)EStdKeyDevice1F,				\
+        (TUint)EStdKeyApplication10,		\
+        (TUint)EStdKeyApplication11,		\
+        (TUint)EStdKeyApplication12,		\
+        (TUint)EStdKeyApplication13,		\
+        (TUint)EStdKeyApplication14,		\
+        (TUint)EStdKeyApplication15,		\
+        (TUint)EStdKeyApplication16,		\
+        (TUint)EStdKeyApplication17,		\
+        (TUint)EStdKeyApplication18,		\
+        (TUint)EStdKeyApplication19,		\
+        (TUint)EStdKeyApplication1A,		\
+        (TUint)EStdKeyApplication1B,		\
+        (TUint)EStdKeyApplication1C,		\
+        (TUint)EStdKeyApplication1D,		\
+        (TUint)EStdKeyApplication1E,		\
+        (TUint)EStdKeyApplication1F,		\
+        }
+
+/**
+ * Key modifier names definition macro.
+ */
+#define DefineModifiers( varName )			\
+	static TUint const varName[] = 			\
+		{									\
+        (TUint)EModifierAutorepeatable,		\
+        (TUint)EModifierKeypad,				\
+        (TUint)EModifierLeftAlt,			\
+        (TUint)EModifierRightAlt,			\
+        (TUint)EModifierAlt,				\
+        (TUint)EModifierLeftCtrl,			\
+        (TUint)EModifierRightCtrl,			\
+        (TUint)EModifierCtrl,				\
+        (TUint)EModifierLeftShift,			\
+        (TUint)EModifierRightShift,			\
+        (TUint)EModifierShift,				\
+        (TUint)EModifierLeftFunc,			\
+        (TUint)EModifierRightFunc,			\
+        (TUint)EModifierFunc,				\
+        (TUint)EModifierCapsLock,			\
+        (TUint)EModifierNumLock,			\
+        (TUint)EModifierScrollLock,			\
+        (TUint)EModifierKeyUp,				\
+        (TUint)EModifierSpecial,			\
+        (TUint)EModifierDoubleClick,		\
+        (TUint)EModifierPureKeycode,		\
+        (TUint)EModifierKeyboardExtend,		\
+        (TUint)EModifierCancelRotation,		\
+        (TUint)EModifierRotateBy90,			\
+        (TUint)EModifierRotateBy180,		\
+        (TUint)EModifierRotateBy270,		\
+        (TUint)EModifierPointer3DButton1,	\
+        (TUint)EModifierPointer3DButton2,	\
+        (TUint)EModifierPointer3DButton3,	\
+        (TUint)EAllModifiers,				\
+    }
+
+/**
+ * Key modifiers definition macro.
+ */
+#define DefineModifierNames( varName ) 				\
+	static TText* const varName[] =					\
+        {											\
+        (TText*)L"estdkeynull",						\
+        (TText*)L"emodifierautorepeatable",			\
+        (TText*)L"emodifierkeypad",					\
+        (TText*)L"emodifierleftalt",				\
+        (TText*)L"emodifierrightalt",				\
+        (TText*)L"emodifieralt",					\
+        (TText*)L"emodifierleftctrl",				\
+        (TText*)L"emodifierrightctrl",				\
+        (TText*)L"emodifierctrl",					\
+        (TText*)L"emodifierleftshift",				\
+        (TText*)L"emodifierrightshift",				\
+        (TText*)L"emodifiershift",					\
+        (TText*)L"emodifierleftfunc",				\
+        (TText*)L"emodifierrightfunc",				\
+        (TText*)L"emodifierfunc",					\
+        (TText*)L"emodifiercapslock",				\
+        (TText*)L"emodifiernumlock",				\
+        (TText*)L"emodifierscrolllock",				\
+        (TText*)L"emodifierkeyup",					\
+        (TText*)L"emodifierspecial",				\
+        (TText*)L"emodifierdoubleclick",			\
+        (TText*)L"emodifierpurekeycode",			\
+        (TText*)L"emodifierkeyboardextend",			\
+        (TText*)L"emodifiercancelrotation",			\
+        (TText*)L"emodifierrotateby90",				\
+        (TText*)L"emodifierrotateby180",			\
+        (TText*)L"emodifierrotateby270",			\
+        (TText*)L"emodifierpointer3dbutton1",		\
+        (TText*)L"emodifierpointer3dbutton2",		\
+        (TText*)L"emodifierpointer3dbutton3",		\
+        (TText*)L"eallmodifiers",					\
+        }
+        
+
+/**
+ * Pointer event type names definition macro
+ */
+#define DefinePointerEventTypeNames( varName ) 			\
+	static TText* const varName[] =						\
+        {												\
+        (TText*)L"epointermove",						\
+        (TText*)L"epointerswitchon",							\
+        (TText*)L"ebutton1down",						\
+        (TText*)L"ebutton1up",							\
+        (TText*)L"ebutton2down",						\
+        (TText*)L"ebutton2up",							\
+        (TText*)L"ebutton3down",						\
+        (TText*)L"ebutton3up",							\
+        (TText*)L"ebutton1",							\
+        (TText*)L"ebutton2",							\
+        (TText*)L"ebutton3",							\
+        }
+
+/**
+ * Pointer event type codes definition macro.
+ */
+#define DefinePointerEventTypes( varName )					\
+	static TInt const varName[] = 							\
+		{													\
+        (TUint)TRawEvent::EPointerMove,						\
+        (TUint)TRawEvent::EPointerSwitchOn,					\
+        (TUint)TRawEvent::EButton1Down,						\
+        (TUint)TRawEvent::EButton1Up,						\
+        (TUint)TRawEvent::EButton2Down,						\
+        (TUint)TRawEvent::EButton2Up,						\
+        (TUint)TRawEvent::EButton3Down,						\
+        (TUint)TRawEvent::EButton3Up,						\
+        (TUint)TEventUtil::EButton1,						\
+        (TUint)TEventUtil::EButton2,						\
+        (TUint)TEventUtil::EButton3,						\
+		}
+
+// LOCAL CONSTANTS AND MACROS
+// None
+
+// MODULE DATA STRUCTURES
+// None
+
+// LOCAL FUNCTION PROTOTYPES
+// None
+
+// FORWARD DECLARATIONS
+// None
+
+// ================= MEMBER FUNCTIONS =========================================
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: TEventUtil
+
+     Method: GetKeyCodeName
+
+     Description: Gets key name.
+
+     Returns selected key name. 
+
+     Parameters: TUint aKeyCode: out: Key code.
+     
+     Return Values: Key name.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+TPtrC TEventUtil::GetKeyCodeName( TUint aKeyCode )
+	{
+	DefineKeyCodeNames( keyCodeNames );
+	DefineKeyCodes( keyCodes );
+	int keyCodeNamesCount = (sizeof( keyCodeNames )/sizeof(TText*));
+	
+	for ( int i = 0; i < keyCodeNamesCount; i++ ) {
+		if ( keyCodes[ i ] == aKeyCode ) 
+			{
+			return keyCodeNames[ i ];
+			}
+	}
+
+	return NULL;
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: TEventUtil
+
+     Method: GetKeyScanCodeName
+
+     Description: Gets key scan code name.
+
+     Returns selected key scan code name. 
+
+     Parameters: TUint aKeyCode: out: Key scan code.
+     
+     Return Values: Key scan code name.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+TPtrC TEventUtil::GetKeyScanCodeName( TInt aKeyScanCode )
+	{	
+	DefineKeyScanCodeNames( keyScanCodeNames );
+	DefineKeyScanCodes( keyScanCodes );
+	int keyScanCodeNamesCount = (sizeof( keyScanCodeNames )/sizeof(TText*));
+	
+	for ( int i = 0; i < keyScanCodeNamesCount; i++ ) {
+		if ( keyScanCodes[ i ] == aKeyScanCode ) 
+			{
+			return keyScanCodeNames[ i ];
+			}
+	}
+	
+	return NULL;
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: TEventUtil
+
+     Method: GetModifierName
+
+     Description: Gets key modifier name.
+
+     Returns selected key modifier name. 
+
+     Parameters: TUint aModifier: out: Key modifier.
+     
+     Return Values: Key modifier name.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+TPtrC TEventUtil::GetModifierName( TUint aModifier )
+	{
+	DefineModifierNames( modifierNames );
+	DefineModifiers( modifiers );
+	int modifierNamesCount = (sizeof( modifierNames )/sizeof(TText*));
+	
+	for ( int i = 0; i < modifierNamesCount; i++ ) {
+		if ( modifiers[ i ] == aModifier ) 
+			{
+			return modifierNames[ i ];
+			}
+	}
+	
+	return NULL;	
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: TEventUtil
+
+     Method: ParseKeyCode
+
+     Description: Parses key code.
+
+     Parses key code. 
+
+     Parameters: TDesC& aKeyCodeName: in: Key code name.
+     			 TUint& aKeyCode: out: Parsed key code.
+     
+     Return Values: KErrNone if key code was parsed successfuly, 
+     				KErrNotFound in other case.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+TInt TEventUtil::ParseKeyCode( const TDesC& aKeyCodeName, TUint& aKeyCode )
+	{
+	DefineKeyCodeNames( keyCodeNames );
+	DefineKeyCodes( keyCodes );
+	int keyCodeNamesCount = (sizeof( keyCodeNames )/sizeof(TText*));
+	
+	TBuf<64> keyCodeNameLowerCase( aKeyCodeName );
+	keyCodeNameLowerCase.LowerCase();
+	for ( int i = 0; i < keyCodeNamesCount; i++ ) {
+		if ( TPtrC( keyCodeNames[ i ] ).Compare( keyCodeNameLowerCase ) == 0 ) 
+			{
+			aKeyCode = keyCodes[ i ];
+			return KErrNone;
+			}
+	}
+	
+	return KErrNotFound;
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: TEventUtil
+
+     Method: ParseKeyScanCode
+
+     Description: Parses key scan code.
+
+     Parses key scan code. 
+
+     Parameters: TDesC& aKeyScanCodeName: in: Key scan code name.
+     			 TUint& aKeyScanCode: out: Parsed key scan code.
+     
+     Return Values: KErrNone if key scan code was parsed successfuly, 
+     				KErrNotFound in other case.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+TInt TEventUtil::ParseKeyScanCode( const TDesC& aKeyScanCodeName, TInt& aKeyScanCode )
+	{
+	DefineKeyScanCodeNames( keyScanCodeNames );
+	DefineKeyScanCodes( keyScanCodes );
+	int keyScanCodeNamesCount = (sizeof( keyScanCodeNames )/sizeof(TText*));
+	
+	TBuf<64> keyScanCodeNameLowerCase( aKeyScanCodeName );
+	keyScanCodeNameLowerCase.LowerCase();
+	for ( int i = 0; i < keyScanCodeNamesCount; i++ ) {
+		if ( TPtrC( keyScanCodeNames[ i ] ).Compare( keyScanCodeNameLowerCase ) == 0 )
+			{
+			aKeyScanCode = keyScanCodes[ i ];
+			return KErrNone;
+			}
+	}
+	
+	return KErrNotFound;
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: TEventUtil
+
+     Method: ParseModifier
+
+     Description: Parses key modifier.
+
+     Parses key modifier. 
+
+     Parameters: TDesC& aModifierName: in: Key modifier name.
+     			 TUint& aModifier: out: Parsed key modifier.
+     
+     Return Values: KErrNone if key modifier was parsed successfuly, 
+     				KErrNotFound in other case.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+TInt TEventUtil::ParseModifier( const TDesC& aModifierName, TUint& aModifier )
+	{
+	DefineModifierNames( modifierNames );
+	DefineModifiers( modifiers );
+	int modifierNamesCount = (sizeof( modifierNames )/sizeof(TText*));
+	
+	TBuf<64> modifierNameLowerCase( aModifierName );
+	modifierNameLowerCase.LowerCase();
+	for ( int i = 0; i < modifierNamesCount; i++ ) {
+		if ( TPtrC( modifierNames[ i ] ).Compare( modifierNameLowerCase ) == 0 )
+			{
+			aModifier = modifiers[ i ];
+			return KErrNone;
+			}
+	}
+	
+	return KErrNotFound;	
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CAknUiEnvProxy
+
+     Method: ParsePointerEventType
+
+     Description: Parses pointer event type.
+
+     Parses key modifier.
+
+     Parameters: const TDesC& aPointerEventTypeName: in: Pointer event type.
+     			 TUint& aModifier: out: Parsed pointer event type.
+     
+     Return Values: KErrNone if no error occures during parsing.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+TInt TEventUtil::ParsePointerEventType( const TDesC& aPointerEventTypeName, TUint& aPointerEventType )
+	{
+	DefinePointerEventTypeNames( pointerEventTypeNames );
+	DefinePointerEventTypes( pointerEventTypes );
+	int pointerEventTypeNamesCount = (sizeof( pointerEventTypeNames )/sizeof(TText*));
+	
+	TBuf<64> pointerEventTypeNamesLowerCase( aPointerEventTypeName );
+	pointerEventTypeNamesLowerCase.LowerCase();
+	for ( int i = 0; i < pointerEventTypeNamesCount; i++ ) {
+		if ( TPtrC( pointerEventTypeNames[ i ] ).Compare( pointerEventTypeNamesLowerCase ) == 0 )
+			{
+			aPointerEventType = pointerEventTypes[ i ];
+			return KErrNone;
+			}
+	}
+	
+	return KErrNotFound;	
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/uitestserverstarter/src/TestServerThreadStarter.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,385 @@
+/*
+* 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: This module contains the implementation of 
+* CTestServerThreadStarter class member functions.
+*
+*/
+
+// INCLUDE FILES
+#include "TestServerThreadStarter.h"
+#include <stifinternal/TestServerClient.h>
+
+// EXTERNAL DATA STRUCTURES
+// None
+
+// EXTERNAL FUNCTION PROTOTYPES  
+// None
+
+// CONSTANTS
+// None
+
+// MACROS
+// None
+
+/**
+ * CTestServerThreadStarter thread heap size.
+ */
+const TUint KDefaultHeapSize = 0x10000;     // 64 K
+
+/**
+ * CTestServerThreadStarter thread max heap size.
+ */
+const TUint KMaxHeapSize     = 0x20000;     // 128 K 
+
+// LOCAL CONSTANTS AND MACROS
+// None
+
+// MODULE DATA STRUCTURES
+// None
+
+// LOCAL FUNCTION PROTOTYPES
+// None
+
+// FORWARD DECLARATIONS
+// None
+
+
+// ================= MEMBER FUNCTIONS =========================================
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CTestServerThreadStarter
+
+     Method: TestServerStarterThreadFunction
+
+     Description: CTestServerThreadStarter thread function.
+
+	 CTestServerThreadStarter thread function in which testserver creation code
+	 is executed.
+
+     Parameters: TAny* aParameters: in: Pointer to CTestServerThreadStarter object
+     
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+TInt CTestServerThreadStarter::TestServerStarterThreadFunction( TAny* aParameters )
+	{
+	RDebug::Printf( "UITESTING: CTestServerThreadStarter::TestServerStarterThreadFunction" );
+    
+    CTestServerThreadStarter* testServerStarter = (CTestServerThreadStarter*)aParameters;
+    TThreadId mainThreadId = testServerStarter->iMainThreadId;
+    CTestThreadContainerRunnerFactory* testThreadContainerRunnerFactory = 
+    	testServerStarter->iTestThreadContainerRunnerFactory;
+    
+   	// Signal that all needed data is copied and main thread can continue its execution 
+    testServerStarter->iServerThreadStartedSemaphore.Signal();
+    	
+    // Get module name from command line
+	const TInt length = User().CommandLineLength();
+
+    HBufC* cmdLine = HBufC::New( length );
+    
+    if ( cmdLine == NULL )
+        {
+        return KErrNoMemory;
+        }
+
+    TPtr moduleName = cmdLine->Des();
+
+	User().CommandLine( moduleName );
+
+    RDebug::Print (moduleName);
+
+    // Open start-up synchronization semaphore
+    RSemaphore startup;
+    RDebug::Print(_L(" Openingstart-up semaphore"));
+    TName semaphoreName = _L("startupSemaphore");
+    semaphoreName.Append( moduleName );
+    
+    TInt res = startup.OpenGlobal(semaphoreName);
+    RDebug::Print(_L("Opening result %d"), res);    
+
+
+    TFileName serverName;
+    TInt r = StartNewServer ( moduleName, serverName, EFalse, startup, true, testThreadContainerRunnerFactory );
+
+    if ( r ==   KErrAlreadyExists )
+        {        
+        // Ok, server was already started
+        RDebug::Print(_L("UI TestServer already started, signaling semaphore and existing"));
+        startup.Signal();        
+
+        delete cmdLine;
+
+        return KErrNone;
+        }
+    else
+        {       
+        RDebug::Print(_L("UI TestServer is finished, code %d"), r);
+        }
+
+    delete cmdLine;
+    
+    //delete testThreadContainerRunnerFactory;
+    testThreadContainerRunnerFactory = NULL;
+    
+    // Kill main thread to end UITestServerStarter application
+    // when testserver is finished    
+    RThread mainThread;
+    TInt ret = mainThread.Open( mainThreadId );
+	if( ret != KErrNone )
+		{
+		User::Panic( _L("ThreadHandleOpenError"), ret );
+		}
+    mainThread.Kill( KErrNone );
+    
+    return r;	
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CTestServerThreadStarter
+
+     Method: NewL
+
+     Description: NewL is first phase of two-phased constructor.
+
+	 NewL is first phase of two-phased constructor.
+
+     Parameters: None.
+     
+     Return Values: Pointer to new CTestServerThreadStarter object.
+
+     Errors/Exceptions: Leaves if new or ConstructL leaves.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+CTestServerThreadStarter* CTestServerThreadStarter::NewL( )
+	{
+	CTestServerThreadStarter* self = new(ELeave) CTestServerThreadStarter();
+	CleanupStack::PushL( self );
+	self->ConstructL();
+	CleanupStack::Pop( self );
+	return self;
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CTestServerThreadStarter
+
+     Method: CTestServerThreadStarter
+
+     Description: Default constructor.
+
+	 Default constructor.
+
+     Parameters: None.
+     
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+CTestServerThreadStarter::CTestServerThreadStarter()
+:CActive( EPriorityNormal )
+	{
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CTestServerThreadStarter
+
+     Method: NewL
+
+     Description: Default destructor.
+
+	 Default destructor.
+
+     Parameters: None.
+     
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+CTestServerThreadStarter::~CTestServerThreadStarter()
+	{
+	Cancel();
+	iTimer.Close();
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CTestServerThreadStarter
+
+     Method: ConstructL
+
+     Description: Second phase of two-phased constructor.
+
+	 Second phase of two-phased constructor.
+
+     Parameters: None.
+     
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CTestServerThreadStarter::ConstructL()
+	{
+	TInt ret = iTimer.CreateLocal();
+	if ( ret != KErrNone )
+		{
+		User::Leave( ret );
+		}
+
+	CActiveScheduler::Add( this );
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CTestServerThreadStarter
+
+     Method: RunTestServerThread
+
+     Description: Starts-up testserver.
+
+	 Starts-up testserver.
+
+     Parameters: None.
+     
+     Return Values: KErrNone when there was no error.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+TInt CTestServerThreadStarter::RunTestServerThread( CTestThreadContainerRunnerFactory* aTestThreadContainerRunnerFactory )
+	{
+	if ( IsActive() )
+		{
+		User::Panic( _L("E32USER-CBase"), 42 );
+		}
+		
+	TInt ret = iServerThreadStartedSemaphore.CreateLocal( 0 );
+	if ( ret != KErrNone )
+		{
+		User::Leave( ret );
+		}
+	
+	iTestThreadContainerRunnerFactory = aTestThreadContainerRunnerFactory;
+	iMainThreadId = RThread().Id();
+	iReturnCode = KErrNone;
+	
+	iStatus = KRequestPending;
+
+	SetActive();
+	iTimer.After( iStatus, 0 );
+	
+	return KErrNone;
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CTestServerThreadStarter
+
+     Method: RunL
+
+     Description: RunL derived from CActive handles the completed requests.
+
+	 RunL derived from CActive handles the completed requests.
+
+     Parameters: None.
+     
+     Return Values: None.
+
+     Errors/Exceptions: Leaves if one of the called method leavs.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CTestServerThreadStarter::RunL()
+	{
+	RThread testServerStarterThread;	
+	TInt ret = testServerStarterThread.Create( _L("testserverstarterthread"), 
+			TestServerStarterThreadFunction, 10 * KDefaultStackSize, 10 * KDefaultHeapSize, 10 * KMaxHeapSize, this );
+	
+	User::LeaveIfError( ret );
+		
+	testServerStarterThread.Resume();	
+	testServerStarterThread.Close();
+	
+	iServerThreadStartedSemaphore.Wait();
+	iServerThreadStartedSemaphore.Close();
+	
+	// Delete CTestServerThreadStarter after testserver is started
+	delete this;
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CTestServerThreadStarter
+
+     Method: DoCancel
+
+     Description: DoCancel derived from CActive handles the Cancel.
+
+	 DoCancel derived from CActive handles the Cancel.
+
+     Parameters: None.
+     
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CTestServerThreadStarter::DoCancel()
+	{
+	if ( IsActive() )
+		{
+		iTimer.Cancel();
+		}
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/uitestserverstarter/src/UITestServerStarter.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -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: This module contains the implementation of application  
+* main function.
+*
+*/
+
+// INCLUDE FILES
+#include <eikstart.h>
+#include "UITestServerStarterAppUi.h"
+#include "UITestServerStarterApplication.h"
+#include <eikenv.h>
+
+// EXTERNAL DATA STRUCTURES
+// None
+
+// EXTERNAL FUNCTION PROTOTYPES  
+// None
+
+// CONSTANTS
+// None
+
+// MACROS
+// None
+
+// LOCAL CONSTANTS AND MACROS
+// None
+
+// MODULE DATA STRUCTURES
+// None
+
+// LOCAL FUNCTION PROTOTYPES
+// None
+
+// FORWARD DECLARATIONS
+// None
+
+/**
+ * Application factory function.
+ */
+LOCAL_C CApaApplication* NewApplication()
+	{
+	return new CUITestServerStarterApplication;
+	}
+
+// ================= MEMBER FUNCTIONS =========================================
+/**
+ * Application main function.
+ */
+GLDEF_C TInt E32Main()
+	{
+	
+	RDebug::Printf( "UITESTING: UITestServerStarter - E32Main" );
+	
+	TInt ret = EikStart::RunApplication( NewApplication );
+	
+    RDebug::Printf( "UITESTING: UITestServerStarter - E32Main End" );
+    
+    return ret;
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/uitestserverstarter/src/UITestServerStarterAppContainer.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,291 @@
+/*
+* 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: This module contains the implementation of 
+* CUITestServerStarterAppContainer class member functions.
+*
+*/
+
+// INCLUDE FILES
+#include "UITestServerStarterAppContainer.h"
+#include <AknsDrawUtils.h>
+#include <AknsBasicBackgroundControlContext.h>
+#include <AknDef.h>
+#include <aknutils.h> 
+
+// EXTERNAL DATA STRUCTURES
+// None
+
+// EXTERNAL FUNCTION PROTOTYPES  
+// None
+
+// CONSTANTS
+// None
+
+// MACROS
+// None
+
+// LOCAL CONSTANTS AND MACROS
+// None
+
+// MODULE DATA STRUCTURES
+// None
+
+// LOCAL FUNCTION PROTOTYPES
+// None
+
+// FORWARD DECLARATIONS
+// None
+
+
+// ================= MEMBER FUNCTIONS =========================================
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppContainer
+
+     Method: NewL
+
+     Description: NewL is first phase of two-phased constructor.
+
+     NewL is first phase of two-phased constructor.
+
+     Parameters: const TRect& aRect: container rectangle.
+     
+     Return Values: Pointer to new CUITestServerStarterAppContainer object.
+
+     Errors/Exceptions: Leave if one of the called functions leaves.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+CUITestServerStarterAppContainer* CUITestServerStarterAppContainer::NewL( const TRect& aRect )
+	{
+	CUITestServerStarterAppContainer* self = NewLC( aRect );
+	CleanupStack::Pop( self );
+	return self;
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppContainer
+
+     Method: NewLC
+
+     Description: NewL is first phase of two-phased constructor.
+
+     NewL is first phase of two-phased constructor.
+
+     Parameters: const TRect& aRect: container rect
+     
+     Return Values: Pointer to new CUITestServerStarterAppContainer object.
+
+     Errors/Exceptions: Leave if one of the called functions leaves.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+CUITestServerStarterAppContainer* CUITestServerStarterAppContainer::NewLC( const TRect& aRect )
+	{
+	CUITestServerStarterAppContainer* self = 
+		new(ELeave)CUITestServerStarterAppContainer;
+	CleanupStack::PushL( self );
+	self->ConstructL( aRect );
+	return self;
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppContainer
+
+     Method: CUITestServerStarterAppContainer
+
+     Description: C++ constructor.
+
+     C++ constructor.
+
+     Parameters: None
+     
+     Return Values: None
+
+     Errors/Exceptions: None
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+CUITestServerStarterAppContainer::CUITestServerStarterAppContainer()
+	{	
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppContainer
+
+     Method: CUITestServerStarterAppContainer
+
+     Description: C++ destructor.
+
+     C++ destructor.
+
+     Parameters: None
+     
+     Return Values: None
+
+     Errors/Exceptions: None
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+CUITestServerStarterAppContainer::~CUITestServerStarterAppContainer()
+	{
+	delete iBgContext;
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppContainer
+
+     Method: ConstructL
+
+     Description: ConstructL is second phase of two-phased constructor.
+
+     ConstructL is second phase of two-phased constructor.
+
+     Parameters: const TRect& aRect: container rectangle.
+     
+     Return Values: None
+
+     Errors/Exceptions: Leave if one of the called functions leaves.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CUITestServerStarterAppContainer::ConstructL( const TRect& aRect )
+	{
+	CreateWindowL();
+	
+	iBgContext = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain, aRect, ETrue );	
+	
+	SetRect( aRect );
+	ActivateL();
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppContainer
+
+     Method: Draw
+
+     Description: Draws the control.
+
+     Draws the control.
+
+     Parameters: const TRect& aRect: rectangle which should be redrawn.
+     
+     Return Values: None
+
+     Errors/Exceptions: None
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CUITestServerStarterAppContainer::Draw( const TRect& aRect ) const
+	{
+	// Get the standard graphics context 
+	CWindowGc& gc = SystemGc();
+
+	// Redraw the background using the default skin
+	MAknsSkinInstance* skin = AknsUtils::SkinInstance();
+	MAknsControlContext* controlContext = AknsDrawUtils::ControlContext( this );
+	AknsDrawUtils::Background( skin, controlContext, this, gc, aRect );	
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppContainer
+
+     Method: SizeChanged
+
+     Description: Responds to changes to the size and position of the contents of this control
+
+     Responds to changes to the size and position of the 
+     contents of this control
+
+     Parameters: None
+     
+     Return Values: None
+
+     Errors/Exceptions: None
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CUITestServerStarterAppContainer::SizeChanged()
+	{
+	if ( iBgContext )
+		{
+		iBgContext->SetRect( Rect() );
+		if ( &Window() )
+			{
+			iBgContext->SetParentPos( PositionRelativeToScreen() );
+			}
+		}
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppContainer
+
+     Method: MopSupplyObject
+
+     Description: This function is used to allow controls to ask their owners for access to other objects that they own
+
+     This function is used to allow controls to ask their owners 
+	 for access to other objects that they own
+	 
+     Parameters: TTypeUid aId: requested object type id.
+     
+     Return Values: Pointer to requested object.
+
+     Errors/Exceptions: None
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+TTypeUid::Ptr CUITestServerStarterAppContainer::MopSupplyObject( TTypeUid aId )
+	{
+	if ( iBgContext )
+		{
+		return MAknsControlContext::SupplyMopObject( aId, iBgContext );
+		}
+	return CCoeControl::MopSupplyObject( aId );
+	}
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/uitestserverstarter/src/UITestServerStarterAppUi.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,508 @@
+/*
+* 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: This module contains the implementation of 
+* CUITestServerStarterAppUi class member functions.
+*
+*/
+
+// INCLUDE FILES
+#include <avkon.hrh>
+#include <aknmessagequerydialog.h>
+#include <aknnotewrappers.h>
+#include <stringloader.h>
+#include <f32file.h>
+#include <s32file.h>
+#include <hlplch.h>
+
+#include <UITestServerStarter.rsg>
+
+#include "UITestServerStarter.hrh"
+#include "UITestServerStarterAppUi.h"
+#include "UITestServerStarterAppView.h"
+
+#include "TestServerThreadStarter.h"
+#include <stifinternal/TestThreadContainerRunnerFactory.h>
+#include "AknUiEnvProxy.h"
+
+// EXTERNAL DATA STRUCTURES
+// None
+
+// EXTERNAL FUNCTION PROTOTYPES  
+// None
+
+// CONSTANTS
+// None
+
+// MACROS
+// None
+
+// LOCAL CONSTANTS AND MACROS
+// None
+
+// MODULE DATA STRUCTURES
+// None
+
+// LOCAL FUNCTION PROTOTYPES
+// None
+
+// FORWARD DECLARATIONS
+// None
+
+// ================= MEMBER FUNCTIONS =========================================
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppUi
+
+     Method: ConstructL
+
+     Description: ConstructL is second phase of two-phased constructor.
+
+     ConstructL is second phase of two-phased constructor.
+
+     Parameters: None
+     
+     Return Values: None.
+
+     Errors/Exceptions: Leaves if one of called functions leave.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CUITestServerStarterAppUi::ConstructL()
+	{
+	RDebug::Printf( "UITESTING: CUITestServerStarterAppUi::ConstructL - Begin" );
+
+	// Initialise app UI with standard value.
+	BaseConstructL( ENoAppResourceFile || CAknAppUi::EAknEnableSkin );
+
+	CEikonEnv::Static()->DisableExitChecks( true );
+	
+	// Create view object
+	iAppView = CUITestServerStarterAppView::NewL();
+	
+	AddViewL( iAppView );
+	SetDefaultViewL( *iAppView );
+		
+	CAknUiEnvProxy* uiEnvProxy = CAknUiEnvProxy::NewL( this );
+	
+	CTestThreadContainerRunnerFactory* testThreadContainerRunnerFactory = 
+		CTestThreadContainerRunnerFactory::NewL( RThread().Id(), CActiveScheduler::Current(), uiEnvProxy );
+	
+	RDebug::Printf( "UITESTING: CUITestServerStarterAppUi::ConstructL - Starting TestServer" );
+	CTestServerThreadStarter* testServerThreadStarter = CTestServerThreadStarter::NewL( );
+	testServerThreadStarter->RunTestServerThread( testThreadContainerRunnerFactory );
+		
+	RDebug::Printf( "UITESTING: CUITestServerStarterAppUi::ConstructL - Move to background" );
+	
+	TApaTask task( CCoeEnv::Static()->WsSession() );
+	task.SetWgId( CCoeEnv::Static()->RootWin().Identifier() ); 
+	task.SendToBackground();
+	
+	RDebug::Printf( "UITESTING: CUITestServerStarterAppUi::ConstructL - End" );
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppUi
+
+     Method: CUITestServerStarterAppUi
+
+     Description: C++ default constructor can NOT contain any code, that might leave.
+
+     C++ default constructor can NOT contain any code, that might leave.
+
+     Parameters: None.
+     
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+CUITestServerStarterAppUi::CUITestServerStarterAppUi()
+	{
+	// No implementation required
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppUi
+
+     Method: ~CUITestServerStarterAppUi
+
+     Description: C++ destructor.
+
+     C++ destructor.
+
+     Parameters: None.
+     
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+CUITestServerStarterAppUi::~CUITestServerStarterAppUi()
+	{
+	// No implementation required
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppUi
+
+     Method: HandleCommandL
+
+     Description: Handles user commands.
+
+     Derived from CCoeAppUi. Handles user commands.
+
+     Parameters: TInt aCommand: in: User command code.
+     
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CUITestServerStarterAppUi::HandleCommandL( TInt )
+	{
+	// No implementation required
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppUi
+
+     Method: HandleWsEventL
+
+     Description: Handles window server event.
+
+     Derived from CCoeAppUi. Handles window server event.
+
+     Parameters: const TWsEvent& aEvent: in: Event.
+     			 CCoeControl* aDestination: in: Destination control.
+     
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CUITestServerStarterAppUi::HandleWsEventL( const TWsEvent& aEvent, CCoeControl* aDestination )
+	{	
+	CAknAppUi::HandleWsEventL( aEvent, aDestination );
+
+	if ( ( aEvent.Type() == EEventKey ) )
+		{
+		switch( iEventType )
+			{
+			case EPressKey:
+				{
+				if ( iEventStatus != NULL )
+					{
+					KeyPressHandled();					
+					}
+				}
+				break;
+			case ETypeText:
+				{
+				iTypeTextLength--;
+				if ( ( iEventStatus != NULL ) && ( iTypeTextLength == 0 ) )
+					{
+					TextTypeHandled();
+					}
+				}
+				break;
+			}
+		}
+	else if ( aEvent.Type() == EEventPointer )
+		{
+		if ( iEventType == EPointerEvent )
+			{
+			PointerEventHandled();
+			}
+		}
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppUi
+
+     Method: PrepareToTypeText
+
+     Description: Prepares AppUi to recive type text event
+
+     Prepares AppUi to recive type text event
+
+     Parameters: TInt aTextLength: in: Text length.
+     
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CUITestServerStarterAppUi::PrepareToTypeText( TInt aTextLength )
+	{
+	iTypeTextLength = aTextLength;
+	iEventType = ETypeText;
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppUi
+
+     Method: PrepareToPressKey
+
+     Description: Prepares AppUi to recive key press event
+
+     Prepares AppUi to recive key press event
+
+     Parameters: None.
+     
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CUITestServerStarterAppUi::PrepareToPressKey()
+	{
+	iEventType = EPressKey;
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppUi
+
+     Method: PrepareToPointerEvent
+
+     Description: Prepares AppUi to recive pointer event
+
+     Prepares AppUi to recive key press event
+
+     Parameters: None.
+     
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CUITestServerStarterAppUi::PrepareToPointerEvent()
+	{
+	iEventType = EPointerEvent;
+	}
+
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppUi
+
+     Method: KeyPressHandled
+
+     Description: Sends notification that key press was handled.
+
+     Notifies client that key press was handled.
+
+     Parameters: None.
+     
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CUITestServerStarterAppUi::KeyPressHandled()
+	{
+	if ( ( iEventType == EPressKey ) && ( iEventStatus != NULL ) && ( iEventType == EPressKey ) )
+		{
+		iEventType = ENone;
+		User::RequestComplete( iEventStatus, KErrNone );
+		iEventStatus = NULL;
+		}
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppUi
+
+     Method: TextTypeHandled
+
+     Description: Sends notification that type text was handled.
+
+     Notifies client that type text was handled.
+
+     Parameters: None.
+     
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CUITestServerStarterAppUi::TextTypeHandled()
+	{
+	if ( ( iEventType == ETypeText ) && ( iEventStatus != NULL ) && ( iEventType == ETypeText ) )
+		{
+		iEventType = ENone;
+		iTypeTextLength = 0;
+		User::RequestComplete( iEventStatus, KErrNone );
+		iEventStatus = NULL;
+		}
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppUi
+
+     Method: PointerEventHandled
+
+     Description: Sends notification that pointer event was handled.
+
+     Notifies client that pointer event was handled.
+
+     Parameters: None.
+     
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CUITestServerStarterAppUi::PointerEventHandled()
+	{
+	if ( ( iEventType == EPointerEvent ) && ( iEventStatus != NULL ) )
+		{
+		iEventType = ENone;
+		User::RequestComplete( iEventStatus, KErrNone );
+		iEventStatus = NULL;
+		}
+	}
+
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppUi
+
+     Method: NotifyAboutHandledKeyPress
+
+     Description: Requests notification of press key completion.
+
+     Requests notification of press key completion.
+
+     Parameters: TRequestStatus* aStatus: in: Request status pointer.
+     
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CUITestServerStarterAppUi::NotifyAboutHandledKeyPress( TRequestStatus* aStatus )
+	{
+	iEventStatus = aStatus;
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppUi
+
+     Method: NotifyAboutHandledTextType
+
+     Description: Requests notification when text type event is handled.
+
+     Requests notification when text type event is handled.
+
+     Parameters: TRequestStatus* aStatus: in: Request status pointer.
+     
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CUITestServerStarterAppUi::NotifyAboutHandledTextType( TRequestStatus* aStatus )
+	{
+	iEventStatus = aStatus;
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppUi
+
+     Method: NotifyAboutHandledPointerEvent
+
+     Description: Requests notification when pointer event is handled.
+
+     Requests notification when pointer event is handled.
+
+     Parameters: TRequestStatus* aStatus: in: Request status pointer.
+     
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CUITestServerStarterAppUi::NotifyAboutHandledPointerEvent( TRequestStatus* aStatus )
+	{
+	iEventStatus = aStatus;
+	}
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/uitestserverstarter/src/UITestServerStarterAppView.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,345 @@
+/*
+* 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: This module contains the 
+* implementation of CUITestServerStarterAppView class member 
+* functions.
+*
+*/
+
+// INCLUDE FILES
+#include <coemain.h>
+#include <aknviewappui.h> 
+#include "UITestServerStarterAppView.h"
+#include "UITestServerStarterApplication.h"
+#include "UITestServerStarterAppContainer.h"
+
+// EXTERNAL DATA STRUCTURES
+// None
+
+// EXTERNAL FUNCTION PROTOTYPES  
+// None
+
+// CONSTANTS
+// None
+
+// MACROS
+// None
+
+// LOCAL CONSTANTS AND MACROS
+// None
+
+// MODULE DATA STRUCTURES
+// None
+
+// LOCAL FUNCTION PROTOTYPES
+// None
+
+// FORWARD DECLARATIONS
+// None
+
+
+// ================= MEMBER FUNCTIONS =========================================
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppView
+
+     Method: NewL
+
+     Description: NewL is first phase of two-phased constructor.
+
+     NewL is first phase of two-phased constructor.
+
+     Parameters: None
+     
+     Return Values: Pointer to new CUITestServerStarterAppView object.
+
+     Errors/Exceptions: Leave if one of the called functions leaves.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+CUITestServerStarterAppView* CUITestServerStarterAppView::NewL()
+	{
+	CUITestServerStarterAppView* self = CUITestServerStarterAppView::NewLC();
+	CleanupStack::Pop( self );
+	return self;
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppView
+
+     Method: NewLC
+
+     Description: NewL is first phase of two-phased constructor.
+
+     NewL is first phase of two-phased constructor.
+
+     Parameters: None
+     
+     Return Values: Pointer to new CUITestServerStarterAppView object.
+
+     Errors/Exceptions: Leave if one of the called functions leaves.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+CUITestServerStarterAppView* CUITestServerStarterAppView::NewLC()
+	{
+	CUITestServerStarterAppView* self = new ( ELeave ) CUITestServerStarterAppView;
+	CleanupStack::PushL( self );
+	self->ConstructL();
+	return self;
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppView
+
+     Method: ConstructL
+
+     Description: ConstructL is second phase of two-phased constructor.
+
+     ConstructL is second phase of two-phased constructor.
+
+     Parameters: None
+     
+     Return Values: None
+
+     Errors/Exceptions: Leave if one of the called functions leaves.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CUITestServerStarterAppView::ConstructL()
+	{
+	BaseConstructL( 0 );
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppView
+
+     Method: CUITestServerStarterAppView
+
+     Description: C++ constructor.
+
+     C++ constructor.
+
+     Parameters: None
+     
+     Return Values: None
+
+     Errors/Exceptions: None
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+CUITestServerStarterAppView::CUITestServerStarterAppView()
+	{
+	// No implementation required
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppView
+
+     Method: CUITestServerStarterAppView
+
+     Description: C++ destructor.
+
+     C++ destructor.
+
+     Parameters: None
+     
+     Return Values: None
+
+     Errors/Exceptions: None
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+CUITestServerStarterAppView::~CUITestServerStarterAppView()
+	{
+    if ( iContainer )
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        }
+
+    delete iContainer;
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppView
+
+     Method: Id
+
+     Description: Returns view Uid.
+
+     Returns view Uid.
+
+     Parameters: None
+     
+     Return Values: View Uid
+
+     Errors/Exceptions: None
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+TUid CUITestServerStarterAppView::Id() const
+	{
+	return KMainViewId;	
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppView
+
+     Method: HandleCommandL
+
+     Description: Handle Commands.
+
+     Handle Commands.
+
+     Parameters: TInt aCommand: command id
+     
+     Return Values: None
+
+     Errors/Exceptions: None
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CUITestServerStarterAppView::HandleCommandL( TInt aCommand )
+    {   
+    AppUi()->HandleCommandL( aCommand );
+    }
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppView
+
+     Method: HandleClientRectChange
+
+     Description: Handle size changes.
+
+     Handle size changes.
+
+     Parameters: None
+     
+     Return Values: None
+
+     Errors/Exceptions: None
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CUITestServerStarterAppView::HandleClientRectChange()
+    {
+    if ( iContainer )
+        {
+        iContainer->SetRect( ClientRect() );
+        }
+    }
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppView
+
+     Method: DoActivateL
+
+     Description: From AknView, Activates view.
+
+     From AknView, Activates view.
+
+     Parameters: const TVwsViewId& aPrevViewId: previouse view id
+     			 TUid aCustomMessageId: custom message id
+   				 const TDesC8& aCustomMessage: custom message data
+     
+     Return Values: None
+
+     Errors/Exceptions: None
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CUITestServerStarterAppView::DoActivateL(
+   const TVwsViewId& /*aPrevViewId*/, TUid /*aCustomMessageId*/,
+   const TDesC8& /*aCustomMessage*/)
+    {
+    if ( !iContainer )
+        {
+        // Create view container
+        iContainer = CUITestServerStarterAppContainer::NewL( ClientRect() );
+        iContainer->SetMopParent( this );
+        // Add container to view stack
+        AppUi()->AddToStackL( *this, iContainer );
+        } 
+   }
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterAppView
+
+     Method: DoDeactivate
+
+     Description: From AknView, Deactivates view.
+
+     From AknView, Deactivates view.
+
+     Parameters: None
+     
+     Return Values: None
+
+     Errors/Exceptions: None
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CUITestServerStarterAppView::DoDeactivate()
+    {
+    if ( iContainer )
+        {
+        // Remove container from view stack
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        }
+    
+    // Delete container since it's not longer needed.
+    delete iContainer;
+    iContainer = NULL;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/uitestserverstarter/src/UITestServerStarterApplication.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,131 @@
+/*
+* 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: This module contains the implementation of 
+* CUITestServerStarterApplication class member functions.
+*
+*/
+
+// INCLUDE FILES
+#include "UITestServerStarter.hrh"
+#include "UITestServerStarterDocument.h"
+#include "UITestServerStarterApplication.h"
+
+// EXTERNAL DATA STRUCTURES
+// None
+
+// EXTERNAL FUNCTION PROTOTYPES  
+// None
+
+// CONSTANTS
+// None
+
+// MACROS
+// None
+
+// LOCAL CONSTANTS AND MACROS
+// None
+
+// MODULE DATA STRUCTURES
+// None
+
+// LOCAL FUNCTION PROTOTYPES
+// None
+
+// FORWARD DECLARATIONS
+// None
+
+
+// ================= MEMBER FUNCTIONS =========================================
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterApplication
+
+     Method: CreateDocumentL 
+
+     Creates CUITestServerStarterDocument document object.
+
+	 Creates CUITestServerStarterDocument document object. The returned
+	 pointer in not owned by the CUITestServerStarterApplication object.
+
+     Parameters: None
+     
+     Return Values: A pointer to the created document object.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+CApaDocument* CUITestServerStarterApplication::CreateDocumentL ()
+	{
+	return (static_cast<CApaDocument*> (CUITestServerStarterDocument::NewL ( *this) ) );
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterApplication
+
+     Method: AppDllUid
+
+     Gets application Uid
+
+	 Gets application Uid
+
+     Parameters: None
+     
+     Return Values: Application Uid.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+TUid CUITestServerStarterApplication::AppDllUid() const
+	{
+	return KUidUITestServerStarterApp;
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: PreDocConstructL
+
+     Method: AppDllUid
+
+     Preconstructs document.
+
+     Preconstructs document.
+
+     Parameters: None
+     
+     Return Values: None
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CUITestServerStarterApplication::PreDocConstructL()
+	{
+	// This call allow us to run multiple instances of UI application in same time.
+	CEikApplication::PreDocConstructL();
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stifui/uitestserverstarter/src/UITestServerStarterDocument.cpp	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,214 @@
+/*
+* 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: This module contains the implementation of 
+* CUITestServerStarterDocument class member functions.
+*
+*/
+
+// INCLUDE FILES
+#include "UITestServerStarterAppUi.h"
+#include "UITestServerStarterDocument.h"
+
+
+// EXTERNAL DATA STRUCTURES
+// None
+
+// EXTERNAL FUNCTION PROTOTYPES  
+// None
+
+// CONSTANTS
+// None
+
+// MACROS
+// None
+
+// LOCAL CONSTANTS AND MACROS
+// None
+
+// MODULE DATA STRUCTURES
+// None
+
+// LOCAL FUNCTION PROTOTYPES
+// None
+
+// FORWARD DECLARATIONS
+// None
+
+
+// ================= MEMBER FUNCTIONS =========================================
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterDocument
+
+     Method: NewL
+
+     Description: NewL is first phase of two-phased constructor.
+
+     NewL is first phase of two-phased constructor.
+
+     Parameters: CEikApplication& aApp: in: Reference to application..
+     
+     Return Values: Pointer to new CUITestServerStarterDocument object.
+
+     Errors/Exceptions: Leave if one of the called functions leaves.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+CUITestServerStarterDocument* CUITestServerStarterDocument::NewL( CEikApplication& aApp )
+	{
+	CUITestServerStarterDocument* self = NewLC (aApp);
+	CleanupStack::Pop (self);
+	return self;
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterDocument
+
+     Method: NewLC
+
+     Description: NewL is first phase of two-phased constructor.
+
+     NewL is first phase of two-phased constructor.
+
+     Parameters: CEikApplication& aApp: in: Reference to application.
+     
+     Return Values: Pointer to new CUITestServerStarterDocument object.
+
+     Errors/Exceptions: Leave if one of the called functions leaves.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+CUITestServerStarterDocument* CUITestServerStarterDocument::NewLC (CEikApplication& aApp)
+	{
+	CUITestServerStarterDocument* self = new ( ELeave ) CUITestServerStarterDocument( aApp );
+
+	CleanupStack::PushL (self);
+	self->ConstructL ();
+	return self;
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterDocument
+
+     Method: ConstructL
+
+     Description: This is second phase of two-phased constructor.
+
+     This is second phase of two-phased constructor.
+
+     Parameters: None.
+     
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+void CUITestServerStarterDocument::ConstructL()
+	{
+	// No implementation required
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterDocument
+
+     Method: CUITestServerStarterDocument
+
+     Description: Constructor.
+
+     Constructor.
+
+     Parameters: None.
+     
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+CUITestServerStarterDocument::CUITestServerStarterDocument( CEikApplication& aApp ) :
+	CAknDocument(aApp)
+	{
+	// No implementation required
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterDocument
+
+     Method: ~CUITestServerStarterDocument
+
+     Description: Destructor.
+
+     Destructor.
+
+     Parameters: None.
+     
+     Return Values: None.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+CUITestServerStarterDocument::~CUITestServerStarterDocument ()
+	{
+	// No implementation required
+	}
+
+/*
+-------------------------------------------------------------------------------
+
+     Class: CUITestServerStarterDocument
+
+     Method: CreateAppUiL
+
+     Description: Creates AppUi object.
+
+     Creates AppUi object.
+
+     Parameters: None.
+     
+     Return Values: Pointer to AppUi object.
+
+     Errors/Exceptions: None.
+
+     Status: Draft
+    
+-------------------------------------------------------------------------------
+*/
+CEikAppUi* CUITestServerStarterDocument::CreateAppUiL ()
+	{
+	return ( static_cast <CEikAppUi*>( new ( ELeave ) CUITestServerStarterAppUi ) );
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysdef_1_4_0.dtd	Tue Feb 02 00:17:27 2010 +0200
@@ -0,0 +1,86 @@
+ <!ELEMENT SystemDefinition (systemModel?, build?)>
+ <!ATTLIST SystemDefinition
+  name CDATA #REQUIRED
+  schema CDATA #REQUIRED>
+ <!ELEMENT systemModel (layer+)>
+ <!ELEMENT layer (logicalset* | module*)*>
+ <!ATTLIST layer
+  name CDATA #REQUIRED
+  levels CDATA #IMPLIED
+  span CDATA #IMPLIED>
+ <!ELEMENT logicalset (logicalsubset* | module* | unit* | package* | prebuilt*)*>
+ <!ATTLIST logicalset name CDATA #REQUIRED>
+ <!ELEMENT logicalsubset (module* | unit* | package* | prebuilt*)*>
+ <!ATTLIST logicalsubset name CDATA #REQUIRED>
+ <!ELEMENT module (component* | unit* | package* | prebuilt*)*>
+ <!ATTLIST module
+  name CDATA #REQUIRED
+  level CDATA #IMPLIED>
+ <!ELEMENT component (unit* | package* | prebuilt*)*>
+ <!ATTLIST component name CDATA #REQUIRED>
+ <!ELEMENT unit EMPTY>
+ <!ATTLIST unit
+  unitID ID #REQUIRED
+  name CDATA #REQUIRED
+  mrp CDATA #REQUIRED
+  filter CDATA #IMPLIED
+  bldFile CDATA #REQUIRED
+  priority CDATA #IMPLIED
+  contract CDATA #IMPLIED>
+ <!ELEMENT package EMPTY>
+ <!ATTLIST package
+  name CDATA #REQUIRED
+  mrp CDATA #REQUIRED
+  filter CDATA #IMPLIED
+  contract CDATA #IMPLIED>
+ <!ELEMENT prebuilt EMPTY>
+ <!ATTLIST prebuilt
+  name CDATA #REQUIRED
+  version CDATA #REQUIRED
+  late (Y|N) #IMPLIED
+  filter CDATA #IMPLIED
+  contract CDATA #IMPLIED>
+ <!ELEMENT build (option* | target+ | targetList+ | unitList+ | configuration+)*>
+ <!ELEMENT unitList (unitRef+)>
+ <!ATTLIST unitList
+  name ID #REQUIRED
+  description CDATA #REQUIRED>
+ <!ELEMENT unitRef EMPTY>
+ <!ATTLIST unitRef unit IDREF #REQUIRED>
+ <!ELEMENT targetList EMPTY>
+ <!ATTLIST targetList
+  name ID #REQUIRED
+  description CDATA #REQUIRED
+  target IDREFS #REQUIRED>
+ <!ELEMENT target EMPTY>
+ <!ATTLIST target
+  name ID #REQUIRED
+  abldTarget CDATA #REQUIRED
+  description CDATA #REQUIRED>
+ <!ELEMENT option EMPTY>
+ <!ATTLIST option
+  name ID #REQUIRED
+  abldOption CDATA #REQUIRED
+  description CDATA #REQUIRED
+  enable (Y | N | y | n) #REQUIRED>
+ <!ELEMENT configuration (unitListRef+ | layerRef+ | task+)*>
+ <!ATTLIST configuration
+  name ID #REQUIRED
+  description CDATA #REQUIRED
+  filter CDATA #REQUIRED>
+ <!ELEMENT task ( unitListRef* , (buildLayer | specialInstructions))>
+ <!ELEMENT unitListRef EMPTY>
+ <!ATTLIST unitListRef unitList IDREF #REQUIRED>
+ <!ELEMENT layerRef EMPTY>
+ <!ATTLIST layerRef layerName CDATA #REQUIRED>
+ <!ELEMENT buildLayer EMPTY>
+ <!ATTLIST buildLayer
+  command CDATA #REQUIRED
+  targetList IDREFS #IMPLIED
+  unitParallel (Y | N | y | n) #REQUIRED
+  targetParallel (Y | N | y | n) #IMPLIED>
+ <!ELEMENT specialInstructions EMPTY>
+ <!ATTLIST specialInstructions
+  name CDATA #REQUIRED
+  cwd CDATA #REQUIRED
+  command CDATA #REQUIRED>