Revision: 201039 default PDK_4.0.a
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 04 Oct 2010 02:58:21 +0300
changeset 4 b8d1455fddc0
parent 2 73b88125830c
Revision: 201039 Kit: 201039
layers.sysdef.xml
package_definition.xml
testconns/statapi/common/inc/padpacket.h
testconns/statapi/common/inc/serialpacketsize.h
testconns/statapi/device/group/bld.inf
testconns/statapi/device/group/release.txt
testconns/statapi/device/group/stat.tdf
testconns/statapi/device/source/statapi/common/stat.cer
testconns/statapi/device/source/statapi/common/stat.key
testconns/statapi/device/source/statapi/common/statapi_common.mmp
testconns/statapi/device/source/statapi/console/bld.inf
testconns/statapi/device/source/statapi/console/export/base_statlite.iby
testconns/statapi/device/source/statapi/console/export/engtools_swicertstore.dat
testconns/statapi/device/source/statapi/console/export/stat.iby
testconns/statapi/device/source/statapi/console/export/stat.ini
testconns/statapi/device/source/statapi/console/export/stat_h2.ini
testconns/statapi/device/source/statapi/console/export/statapiconsole_armv5.pkg
testconns/statapi/device/source/statapi/console/export/statauto.iby
testconns/statapi/device/source/statapi/console/export/statcommon.iby
testconns/statapi/device/source/statapi/console/export/statlite.iby
testconns/statapi/device/source/statapi/console/export/techview_statapi.oby
testconns/statapi/device/source/statapi/console/export/testdriver.cert
testconns/statapi/device/source/statapi/console/export/testdriver.key
testconns/statapi/device/source/statapi/console/start.mbc
testconns/statapi/device/source/statapi/console/statapiconsole.mmp
testconns/statapi/device/source/statapi/group/bld.inf
testconns/statapi/device/source/statapi/inc/activeconnection.h
testconns/statapi/device/source/statapi/inc/activeconsole.h
testconns/statapi/device/source/statapi/inc/appinstall.h
testconns/statapi/device/source/statapi/inc/assert.h
testconns/statapi/device/source/statapi/inc/dataconsumer_file.h
testconns/statapi/device/source/statapi/inc/dataconsumer_memory.h
testconns/statapi/device/source/statapi/inc/datasupplier_file.h
testconns/statapi/device/source/statapi/inc/datasupplier_memory.h
testconns/statapi/device/source/statapi/inc/filedump.h
testconns/statapi/device/source/statapi/inc/keycodes.h
testconns/statapi/device/source/statapi/inc/modifiers.h
testconns/statapi/device/source/statapi/inc/msgwin.h
testconns/statapi/device/source/statapi/inc/ntoh.h
testconns/statapi/device/source/statapi/inc/stat.h
testconns/statapi/device/source/statapi/inc/stat_application.h
testconns/statapi/device/source/statapi/inc/stat_bt.h
testconns/statapi/device/source/statapi/inc/stat_console.h
testconns/statapi/device/source/statapi/inc/stat_controller.h
testconns/statapi/device/source/statapi/inc/stat_engine.h
testconns/statapi/device/source/statapi/inc/stat_interfaces.h
testconns/statapi/device/source/statapi/inc/stat_packetisation.h
testconns/statapi/device/source/statapi/inc/stat_serial.h
testconns/statapi/device/source/statapi/inc/stat_tcpip.h
testconns/statapi/device/source/statapi/inc/stat_usb.h
testconns/statapi/device/source/statapi/inc/stat_window.h
testconns/statapi/device/source/statapi/inc/statapi.hrh
testconns/statapi/device/source/statapi/inc/statapi_commanddecoder.h
testconns/statapi/device/source/statapi/inc/statapi_deviceinformation.h
testconns/statapi/device/source/statapi/inc/testsecurityinstuihandler.h
testconns/statapi/device/source/statapi/lib/bld.inf
testconns/statapi/device/source/statapi/lib/statlib.mmp
testconns/statapi/device/source/statapi/light/bld.inf
testconns/statapi/device/source/statapi/light/statapilight.mmp
testconns/statapi/device/source/statapi/light/statlightserial/bwins/serialdriveru.def
testconns/statapi/device/source/statapi/light/statlightserial/eabi/serialdriveru.def
testconns/statapi/device/source/statapi/light/statlightserial/group/bld.inf
testconns/statapi/device/source/statapi/light/statlightserial/group/serialdriver.mmp
testconns/statapi/device/source/statapi/light/statlightserial/src/serialdriver.cpp
testconns/statapi/device/source/statapi/light/statlightserial/src/serialdriver.h
testconns/statapi/device/source/statapi/light/statlightserial/src/serialdriverext.h
testconns/statapi/device/source/statapi/rsc/statapi_loc.rss
testconns/statapi/device/source/statapi/rsc/statapi_reg.rss
testconns/statapi/device/source/statapi/rsc/statapiicon_24x24i.bmp
testconns/statapi/device/source/statapi/rsc/statapiicon_24x24m.bmp
testconns/statapi/device/source/statapi/rsc/statapiicon_32x32i.bmp
testconns/statapi/device/source/statapi/rsc/statapiicon_32x32m.bmp
testconns/statapi/device/source/statapi/rsc/statapiicon_48x48i.bmp
testconns/statapi/device/source/statapi/rsc/statapiicon_48x48m.bmp
testconns/statapi/device/source/statapi/rsc/statgui_aif.rss
testconns/statapi/device/source/statapi/rsc/statgui_loc.rss
testconns/statapi/device/source/statapi/rsc/statgui_reg.rss
testconns/statapi/device/source/statapi/rsc/statgui_ui.rss
testconns/statapi/device/source/statapi/series60/bld.inf
testconns/statapi/device/source/statapi/series60/statapi.mmp
testconns/statapi/device/source/statapi/series60/statapi.rss
testconns/statapi/device/source/statapi/series60/statapi_buildsis.mmp
testconns/statapi/device/source/statapi/series60/statapi_series60.pkg
testconns/statapi/device/source/statapi/src/activeconnection.cpp
testconns/statapi/device/source/statapi/src/activeconsole.cpp
testconns/statapi/device/source/statapi/src/appinstall.cpp
testconns/statapi/device/source/statapi/src/asserte.cpp
testconns/statapi/device/source/statapi/src/dataconsumer_file.cpp
testconns/statapi/device/source/statapi/src/dataconsumer_memory.cpp
testconns/statapi/device/source/statapi/src/datasupplier_file.cpp
testconns/statapi/device/source/statapi/src/datasupplier_memory.cpp
testconns/statapi/device/source/statapi/src/filedump.cpp
testconns/statapi/device/source/statapi/src/msgwin.cpp
testconns/statapi/device/source/statapi/src/ntoh.cpp
testconns/statapi/device/source/statapi/src/stat_application.cpp
testconns/statapi/device/source/statapi/src/stat_bt.cpp
testconns/statapi/device/source/statapi/src/stat_comdecoder.cpp
testconns/statapi/device/source/statapi/src/stat_console.cpp
testconns/statapi/device/source/statapi/src/stat_controller.cpp
testconns/statapi/device/source/statapi/src/stat_engine.cpp
testconns/statapi/device/source/statapi/src/stat_main.cpp
testconns/statapi/device/source/statapi/src/stat_packetisation.cpp
testconns/statapi/device/source/statapi/src/stat_serial.cpp
testconns/statapi/device/source/statapi/src/stat_tcpip.cpp
testconns/statapi/device/source/statapi/src/stat_usb.cpp
testconns/statapi/device/source/statapi/src/stat_window.cpp
testconns/statapi/device/source/statapi/src/statapi.rss
testconns/statapi/device/source/statapi/src/testsecurityinstuihandler.cpp
testconns/statapi/device/source/statapi/techview/bld.inf
testconns/statapi/device/source/statapi/techview/export/statgui.iby
testconns/statapi/device/source/statapi/techview/export/statui.ini
testconns/statapi/device/source/statapi/techview/statapi.mmp
testconns/statapi/device/source/statapi/techview/statgui.rss
testconns/statapi/device/source/statapi/uiq/bld.inf
testconns/statapi/device/source/statapi/uiq/statapi.mmp
testconns/statapi/device/source/statapi/uiq/statapi.rss
testconns/statapi/device/source/statapi/uiq/statapi_buildsis.mmp
testconns/statapi/device/source/statapi/uiq/statapi_standard.pkg
testconns/statapi/group/release.txt
testconns/statapi/group/statsrv.mrp
testconns/statdesktop/common/inc/padpacket.h
testconns/statdesktop/common/inc/serialpacketsize.h
testconns/statdesktop/desktop/bin/dummy.txt
testconns/statdesktop/desktop/group/bld.inf
testconns/statdesktop/desktop/group/release.txt
testconns/statdesktop/desktop/group/stat.mrp
testconns/statdesktop/desktop/group/stat_desktop.tdf
testconns/statdesktop/desktop/lib/dummy.txt
testconns/statdesktop/desktop/source/common/inc/ini.h
testconns/statdesktop/desktop/source/common/src/ini.cpp
testconns/statdesktop/desktop/source/common/transport/inc/cclientsocket.h
testconns/statdesktop/desktop/source/common/transport/inc/cstatmessagecom.h
testconns/statdesktop/desktop/source/common/transport/inc/statsocket.h
testconns/statdesktop/desktop/source/common/transport/src/cclientsocket.cpp
testconns/statdesktop/desktop/source/common/transport/src/cstatmessagecom.cpp
testconns/statdesktop/desktop/source/common/transport/src/statsocket.cpp
testconns/statdesktop/desktop/source/desktop/group/bld.inf
testconns/statdesktop/desktop/source/desktop/group/statdesktop.mk
testconns/statdesktop/desktop/source/desktop/inc/logmessage.h
testconns/statdesktop/desktop/source/desktop/inc/messagereporterimp.h
testconns/statdesktop/desktop/source/desktop/inc/resource.h
testconns/statdesktop/desktop/source/desktop/inc/scriptprogressmonitorimp.h
testconns/statdesktop/desktop/source/desktop/inc/statdesktop.h
testconns/statdesktop/desktop/source/desktop/inc/statdesktopdlg.h
testconns/statdesktop/desktop/source/desktop/inc/statmanageconnection.h
testconns/statdesktop/desktop/source/desktop/inc/stdafx.h
testconns/statdesktop/desktop/source/desktop/inc/windowmessages.h
testconns/statdesktop/desktop/source/desktop/res/statdesktop.ico
testconns/statdesktop/desktop/source/desktop/res/statdesktop.rc2
testconns/statdesktop/desktop/source/desktop/src/statdesktop.cpp
testconns/statdesktop/desktop/source/desktop/src/statdesktop.rc
testconns/statdesktop/desktop/source/desktop/src/statdesktopdlg.cpp
testconns/statdesktop/desktop/source/desktop/src/statmanageconnection.cpp
testconns/statdesktop/desktop/source/desktop/src/stdafx.cpp
testconns/statdesktop/desktop/source/desktop/statdesktop.dep
testconns/statdesktop/desktop/source/desktop/statdesktop.dsp
testconns/statdesktop/desktop/source/desktop/statdesktop.mak
testconns/statdesktop/desktop/source/desktop/updatedesktop.bat
testconns/statdesktop/desktop/source/dll/group/bld.inf
testconns/statdesktop/desktop/source/dll/group/statdll.mk
testconns/statdesktop/desktop/source/dll/inc/resource.h
testconns/statdesktop/desktop/source/dll/inc/stdafx.h
testconns/statdesktop/desktop/source/dll/res/stat.rc2
testconns/statdesktop/desktop/source/dll/src/statdll.rc
testconns/statdesktop/desktop/source/dll/src/stdafx.cpp
testconns/statdesktop/desktop/source/dll/stat.def
testconns/statdesktop/desktop/source/dll/statd.def
testconns/statdesktop/desktop/source/dll/statdll.dep
testconns/statdesktop/desktop/source/dll/statdll.dsp
testconns/statdesktop/desktop/source/dll/statdll.mak
testconns/statdesktop/desktop/source/dll/updatedll.bat
testconns/statdesktop/desktop/source/lib/group/bld.inf
testconns/statdesktop/desktop/source/lib/group/statlib.mk
testconns/statdesktop/desktop/source/lib/inc/creporter.h
testconns/statdesktop/desktop/source/lib/inc/cstatdataformatconverter.h
testconns/statdesktop/desktop/source/lib/inc/cstatimageverify.h
testconns/statdesktop/desktop/source/lib/inc/cstatlogfile.h
testconns/statdesktop/desktop/source/lib/inc/cstatreturncodes.h
testconns/statdesktop/desktop/source/lib/inc/messagereporter.h
testconns/statdesktop/desktop/source/lib/inc/messagetypes.h
testconns/statdesktop/desktop/source/lib/inc/scriptprogressmonitor.h
testconns/statdesktop/desktop/source/lib/inc/stat.h
testconns/statdesktop/desktop/source/lib/inc/statbitmap.h
testconns/statdesktop/desktop/source/lib/inc/statcommon.h
testconns/statdesktop/desktop/source/lib/inc/statcomms.h
testconns/statdesktop/desktop/source/lib/inc/statengine.h
testconns/statdesktop/desktop/source/lib/inc/statexp.h
testconns/statdesktop/desktop/source/lib/inc/statlist.h
testconns/statdesktop/desktop/source/lib/inc/statmember.h
testconns/statdesktop/desktop/source/lib/inc/statscriptdecoder.h
testconns/statdesktop/desktop/source/lib/inc/statserial.h
testconns/statdesktop/desktop/source/lib/inc/statserialbluetooth.h
testconns/statdesktop/desktop/source/lib/inc/statsocket_block.h
testconns/statdesktop/desktop/source/lib/inc/stattransport.h
testconns/statdesktop/desktop/source/lib/inc/stdafx.h
testconns/statdesktop/desktop/source/lib/inc/windowmessages.h
testconns/statdesktop/desktop/source/lib/src/crepmisc.cpp
testconns/statdesktop/desktop/source/lib/src/creporter.cpp
testconns/statdesktop/desktop/source/lib/src/cstatdataformatconverter.cpp
testconns/statdesktop/desktop/source/lib/src/cstatimageverify.cpp
testconns/statdesktop/desktop/source/lib/src/cstatlogfile.cpp
testconns/statdesktop/desktop/source/lib/src/cstatreturncodes.cpp
testconns/statdesktop/desktop/source/lib/src/statbitmap.cpp
testconns/statdesktop/desktop/source/lib/src/statcomms.cpp
testconns/statdesktop/desktop/source/lib/src/statengine.cpp
testconns/statdesktop/desktop/source/lib/src/statexp.cpp
testconns/statdesktop/desktop/source/lib/src/statlist.cpp
testconns/statdesktop/desktop/source/lib/src/statmember.cpp
testconns/statdesktop/desktop/source/lib/src/statscriptdecoder.cpp
testconns/statdesktop/desktop/source/lib/src/statserial.cpp
testconns/statdesktop/desktop/source/lib/src/statserialbluetooth.cpp
testconns/statdesktop/desktop/source/lib/src/statsocket_block.cpp
testconns/statdesktop/desktop/source/lib/src/stdafx.cpp
testconns/statdesktop/desktop/source/lib/statlib.dep
testconns/statdesktop/desktop/source/lib/statlib.dsp
testconns/statdesktop/desktop/source/lib/statlib.mak
testconns/statdesktop/desktop/source/lib/updatelib.bat
testconns/statdesktop/desktop/source/perl/statapi.pm
testconns/statdesktop/desktop/source/stat.dsw
testconns/statdesktop/desktop/source/stat2perl/group/bld.inf
testconns/statdesktop/desktop/source/stat2perl/group/stat2perl.mk
testconns/statdesktop/desktop/source/stat2perl/inc/commandline.h
testconns/statdesktop/desktop/source/stat2perl/inc/stdafx.h
testconns/statdesktop/desktop/source/stat2perl/src/commandline.cpp
testconns/statdesktop/desktop/source/stat2perl/src/stat2perl.cpp
testconns/statdesktop/desktop/source/stat2perl/src/stdafx.cpp
testconns/statdesktop/desktop/source/stat2perl/stat2perl.dep
testconns/statdesktop/desktop/source/stat2perl/stat2perl.dsp
testconns/statdesktop/desktop/source/stat2perl/stat2perl.mak
testconns/statdesktop/desktop/source/stat2perl/updatestat2perl.bat
testconns/statdesktop/desktop/source/trgtest/group/bld.inf
testconns/statdesktop/desktop/source/trgtest/group/trgtest.mmp
testconns/statdesktop/desktop/source/trgtest/src/trgtest.cpp
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatcomms/include.h
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatcomms/resource.h
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatcomms/stdafx.cpp
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatcomms/stdafx.h
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatcomms/testcom.cpp
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatcomms/testcom.dsp
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatcomms/testcom.h
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatcomms/testcom.rc
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatcomms/testcomdlg.cpp
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatcomms/testcomdlg.h
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsasync/myclient.cpp
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsasync/myclient.dsp
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsasync/myclient.h
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsasync/myclient.rc
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsasync/myclientdlg.cpp
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsasync/myclientdlg.h
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsasync/resource.h
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsasync/stdafx.cpp
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsasync/stdafx.h
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsblock/myclient.cpp
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsblock/myclient.dsp
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsblock/myclient.h
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsblock/myclient.rc
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsblock/myclientdlg.cpp
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsblock/myclientdlg.h
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsblock/resource.h
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsblock/stdafx.cpp
testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsblock/stdafx.h
testconns/statdesktop/desktop/testsource/dlltester/dlltest.dep
testconns/statdesktop/desktop/testsource/dlltester/dlltest.dsp
testconns/statdesktop/desktop/testsource/dlltester/dlltest.mak
testconns/statdesktop/desktop/testsource/dlltester/dlltest.rc
testconns/statdesktop/desktop/testsource/dlltester/group/bld.inf
testconns/statdesktop/desktop/testsource/dlltester/group/statdlltester.mk
testconns/statdesktop/desktop/testsource/dlltester/inc/dlltest.h
testconns/statdesktop/desktop/testsource/dlltester/inc/dlltestdlg.h
testconns/statdesktop/desktop/testsource/dlltester/inc/resource.h
testconns/statdesktop/desktop/testsource/dlltester/inc/stdafx.h
testconns/statdesktop/desktop/testsource/dlltester/inc/utils.h
testconns/statdesktop/desktop/testsource/dlltester/res/dlltest.ico
testconns/statdesktop/desktop/testsource/dlltester/res/dlltest.rc2
testconns/statdesktop/desktop/testsource/dlltester/src/dlltest.cpp
testconns/statdesktop/desktop/testsource/dlltester/src/dlltestdlg.cpp
testconns/statdesktop/desktop/testsource/dlltester/src/stdafx.cpp
testconns/statdesktop/desktop/testsource/dlltester/src/utils.cpp
testconns/statdesktop/desktop/testsource/dlltestermt/dlltest_multithreaded.dep
testconns/statdesktop/desktop/testsource/dlltestermt/dlltest_multithreaded.dsp
testconns/statdesktop/desktop/testsource/dlltestermt/dlltest_multithreaded.mak
testconns/statdesktop/desktop/testsource/dlltestermt/group/bld.inf
testconns/statdesktop/desktop/testsource/dlltestermt/group/statdlltestermt.mk
testconns/statdesktop/desktop/testsource/dlltestermt/inc/dlltest_worker.h
testconns/statdesktop/desktop/testsource/dlltestermt/inc/stattask.h
testconns/statdesktop/desktop/testsource/dlltestermt/inc/stdafx.h
testconns/statdesktop/desktop/testsource/dlltestermt/src/dlltest_multithreaded.cpp
testconns/statdesktop/desktop/testsource/dlltestermt/src/dlltest_worker.cpp
testconns/statdesktop/desktop/testsource/dlltestermt/src/stattask.cpp
testconns/statdesktop/desktop/testsource/dlltestermt/src/stdafx.cpp
testconns/statdesktop/desktop/testsource/testsource.dsw
testconns/statdesktop/group/release.txt
testconns/statdesktop/scripts/perl/stat.pl
testconns/statdesktop/scripts/standard/file_transfer.txt
testconns/statdesktop/scripts/standard/hamlet.txt
testconns/statdesktop/scripts/standard/prepare.txt
testconns/statdesktop/scripts/standard/sample.txt
testconns/statdesktop/scripts/standard/simpleword.txt
testconns/statdesktop/scripts/standard/statdlltest.txt
testconns/statdesktop/scripts/standard/various.txt
testconns/statdesktop/scripts/standard/various_eka1.txt
testconns/statdesktop/scripts/standard/various_eka2.txt
testfws/burtestserver/Group/bld.inf
testfws/burtestserver/Group/burtestserver.iby
testfws/burtestserver/Group/burtestserver.mmp
testfws/burtestserver/Group/testtools_burtestserver.history.xml
testfws/burtestserver/Group/testtools_burtestserver.mrp
testfws/burtestserver/SampleTestScripts/test.ini
testfws/burtestserver/SampleTestScripts/test_backup.script
testfws/burtestserver/SampleTestScripts/test_backupasync.script
testfws/burtestserver/SampleTestScripts/test_restore.script
testfws/burtestserver/SampleTestScripts/test_restoreaysnc.script
testfws/burtestserver/TestServer/inc/t_asyncbackuptransferhandler.h
testfws/burtestserver/TestServer/inc/t_burcommon.h
testfws/burtestserver/TestServer/inc/t_burtestserver.h
testfws/burtestserver/TestServer/inc/t_storagemanager.h
testfws/burtestserver/TestServer/src/t_asyncbackuptransferhandler.cpp
testfws/burtestserver/TestServer/src/t_burtestserver.cpp
testfws/burtestserver/TestServer/src/t_storagemanager.cpp
testfws/burtestserver/TestSteps/inc/t_burteststepbase.h
testfws/burtestserver/TestSteps/inc/t_teststepbackup.h
testfws/burtestserver/TestSteps/inc/t_teststepbackupasync.h
testfws/burtestserver/TestSteps/inc/t_teststeprestore.h
testfws/burtestserver/TestSteps/inc/t_teststeprestoreasync.h
testfws/burtestserver/TestSteps/src/t_burteststepbase.cpp
testfws/burtestserver/TestSteps/src/t_teststepbackup.cpp
testfws/burtestserver/TestSteps/src/t_teststepbackupasync.cpp
testfws/burtestserver/TestSteps/src/t_teststeprestore.cpp
testfws/burtestserver/TestSteps/src/t_teststeprestoreasync.cpp
testfws/stif/Logger/src/StifLogger.cpp
testfws/stif/Parser/src/StifFileParser.cpp
testfws/stif/StifKernelTestClassBase/src/StifKernelTestClassBase.cpp
testfws/stif/StifTFwIf/src/UIStore.cpp
testfws/stif/TestScripter/src/TestScripter.cpp
testfws/stif/TestServer/inc/TestServer.h
testfws/stif/TestServer/src/TestExecutionThread.cpp
testfws/stif/TestServer/src/TestModuleContainer.cpp
testfws/stif/group/ReleaseNote.txt
testfws/stif/inc/TestThreadContainer.h
testfws/stif/inc/version.h
testfws/stif/rom/Stif.iby
testfws/stif/rom/Stif_rom.iby
testfws/stif/sis/Stif_31.sis
--- a/layers.sysdef.xml	Fri Sep 17 08:39:50 2010 +0300
+++ b/layers.sysdef.xml	Mon Oct 04 02:58:21 2010 +0300
@@ -12,6 +12,15 @@
       <module name="stif">
         <unit unitID="testtools.stif" mrp="" bldFile="&layer_real_source_path;/testfws/stif/group" name="stif" />
       </module>
+      <module name="burtestserver">
+        <unit unitID="testtools.burtestserver" mrp="" bldFile="&layer_real_source_path;/testfws/burtestserver/Group" name="burtestserver" />
+      </module>
+      <module name="statapi">
+        <unit unitID="testtools.statapi" mrp="" bldFile="&layer_real_source_path;/testconns/statapi/device/source/statapi/console" name="statapi" />
+      </module>
+      <module name="statdesktop">
+        <unit unitID="testtools.statdesktop" mrp="" bldFile="&layer_real_source_path;/testconns/statdesktop/desktop/group" name="statdesktop" />
+      </module>
     </layer>
     <layer name="os">
       <module name="testexecmdw">
@@ -22,4 +31,4 @@
       </module>
     </layer>
   </systemModel>
-</SystemDefinition>
\ No newline at end of file
+</SystemDefinition>
--- a/package_definition.xml	Fri Sep 17 08:39:50 2010 +0300
+++ b/package_definition.xml	Mon Oct 04 02:58:21 2010 +0300
@@ -5,16 +5,25 @@
     <component id="hti" filter="s60" name="Harmonized Test Interface" purpose="development">
       <unit bldFile="testconns/hti/group"/>
     </component>
+    <component id="statapi" filter="s60" name="STAT API" deprecated="^3" purpose="development" depends="sf:tef">
+      <unit bldFile="testconns/statapi/device/source/statapi/console"/>
+    </component>
+    <component id="statdesktop" filter="s60" name="STAT Desktop" deprecated="^3" purpose="development">
+      <unit bldFile="testconns/statdesktop/desktop/group"/>
+    </component>
   </collection>
   <collection id="testfws" name="Test Frameworks" level="fw">
     <component id="stif" filter="s60" name="STIF Test Framework" purpose="development">
       <unit bldFile="testfws/stif/group"/>
     </component>
-    <component id="tef" filter="s60" name="Test Execute Framework version 3" purpose="development">
+    <component id="tef" filter="s60" name="Test Execute Framework v3" purpose="development">
       <unit bldFile="testfws/testexecmdw/group"/>
     </component>
     <component id="symbianunittestfw" filter="s60" name="Symbian Unit Test Framework" introduced="^4" purpose="development">
       <unit bldFile="testfws/symbianunittestfw/group"/>
+		</component>
+    <component id="burtestserver" filter="s60" name="Backup and Restore Test Server" purpose="development">
+      <unit bldFile="testfws/burtestserver/Group"/>
     </component>
   </collection>
  </package>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/common/inc/padpacket.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Header file to help determine if a specific packet size
+* will result in the packet being padded.  This is to avoid a packet that*
+*/
+
+
+#ifndef PADPACKET_H_2B31B9BD_01D6_4f35_B525_4E07C03D7762
+#define PADPACKET_H_2B31B9BD_01D6_4f35_B525_4E07C03D7762
+
+#if ! defined __E32DEF_H__
+	// Win32 code.
+	typedef signed int TInt;
+	typedef int TBool;
+#endif // ! defined __E32DEF_H__
+
+static const int packetMultiple = 64;
+static const unsigned char packetPad = 'S';
+
+inline TBool PadPacket( TInt packetSize )
+{
+	return ( 0 == ( packetSize % packetMultiple ) );
+}
+
+#endif // defined PADPACKET_H_2B31B9BD_01D6_4f35_B525_4E07C03D7762
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/common/inc/serialpacketsize.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+#ifndef SERIALPACKETSIZE_H_D7CC307B_845C_4f9e_8079_C9C2C37A1B4D
+#define SERIALPACKETSIZE_H_D7CC307B_845C_4f9e_8079_C9C2C37A1B4D
+
+// The reference serial connection (with serial cable) has a
+// packet size of 4096 with an 8 bit header so we send 4088
+// bytes at a time.
+#define KMaxPacketSize								4088
+
+// The USB implementation has a packet size of 64k
+#define KMaxUSBPacketSize							0xFFFF
+
+// The Bluetooth implementation is implemented by virtual serial
+// port on the PC side but is socket based on the device side.
+// As far as the device goes there is no packet limit and messages
+// are not broken up in packet chunks.
+// Change the value from 1024 * 16 to 1024 * 4, testing proved 1024 * 16
+// is too large to communicate.
+#define KMaxBluetoothPacketSize					( 1024 * 4 )
+
+// The TCPIP transport is connection oriented and does not
+// need to packeted for transport at the application level.
+// However we do package it anyway so that the data can be 
+// collected in pieces and written to a file rather than a single
+// memory buffer.
+#define KMaxTCPIPPacketSize						( 1024 * 32 )
+
+#endif // defined SERIALPACKETSIZE_H_D7CC307B_845C_4f9e_8079_C9C2C37A1B4D
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/group/bld.inf	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,22 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description: 
+//
+
+PRJ_PLATFORMS 
+
+
+PRJ_MMPFILES
+#include "../source/statapi/group/bld.inf"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/group/release.txt	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,5 @@
+NOTESRC_RELEASER
+Nokia Ltd. 
+
+NOTESRC_RELEASE_REASON
+STAT release.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/group/stat.tdf	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<tool name="STAT" 
+	description="STAT"  
+	version="1.1.1001" 
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
+
+	<files>
+		<file source="\epoc32\release\armv5\udeb\statapi.exe" target="$EPOCROOT\epoc32\release\armv5\udeb" overwrite="true" />
+		<file source="\epoc32\release\armv5\urel\statapi.exe" target="$EPOCROOT\epoc32\release\armv5\urel" overwrite="true" />
+		<file source="\epoc32\release\armv5\lib\serialdriver.dso" target="$EPOCROOT\epoc32\release\armv5\lib" overwrite="true" />
+		<file source="\epoc32\release\armv5\lib\serialdriver{000a0000}.dso" target="$EPOCROOT\epoc32\release\armv5\lib" overwrite="true" />
+		<file source="\epoc32\release\armv5\udeb\serialdriver.dll" target="$EPOCROOT\epoc32\release\armv5\udeb" overwrite="true" />
+		<file source="\epoc32\release\armv5\udeb\statlite.exe" target="$EPOCROOT\epoc32\release\armv5\udeb" overwrite="true" />
+		<file source="\epoc32\release\armv5\urel\serialdriver.dll" target="$EPOCROOT\epoc32\release\armv5\urel" overwrite="true" />
+		<file source="\epoc32\release\armv5\urel\statlite.exe" target="$EPOCROOT\epoc32\release\armv5\urel" overwrite="true" />
+		<file source="\epoc32\release\winscw\udeb\serialdriver.dll" target="$EPOCROOT\epoc32\release\winscw\udeb" overwrite="true" />
+		<file source="\epoc32\release\winscw\udeb\statlite.exe" target="$EPOCROOT\epoc32\release\winscw\udeb" overwrite="true" />
+		<file source="\epoc32\release\winscw\urel\serialdriver.dll" target="$EPOCROOT\epoc32\release\winscw\urel" overwrite="true" />
+		<file source="\epoc32\release\winscw\urel\statlite.exe" target="$EPOCROOT\epoc32\release\winscw\urel" overwrite="true" />
+		<file source="\epoc32\release\winscw\udeb\statapi.exe" target="$EPOCROOT\epoc32\release\winscw\udeb" overwrite="true" />
+		<file source="\epoc32\release\winscw\urel\statapi.exe" target="$EPOCROOT\epoc32\release\winscw\urel" overwrite="true" />
+		<file source="\epoc32\rom\include\statcommon.iby" target="$EPOCROOT\epoc32\rom\include" overwrite="true" />
+		<file source="\epoc32\rom\include\stat.iby" target="$EPOCROOT\epoc32\rom\include" overwrite="true" />
+		<file source="\epoc32\rom\include\statauto.iby" target="$EPOCROOT\epoc32\rom\include" overwrite="true" />
+		<file source="\epoc32\rom\include\statlite.iby" target="$EPOCROOT\epoc32\rom\include" overwrite="true" />
+		<file source="\epoc32\rom\include\techview_statapi.oby" target="$EPOCROOT\epoc32\rom\include" overwrite="true" />	
+		<file source="\epoc32\rom\include\base_statlite.iby" target="$EPOCROOT\epoc32\rom\include" overwrite="true" />
+		<file source="\epoc32\data\z\system\data\stat.ini" target="$EPOCROOT\epoc32\data\z\system\data" overwrite="true" />
+		<file source="\epoc32\data\z\system\data\stat_h2.ini" target="$EPOCROOT\epoc32\data\z\system\data" overwrite="true" />
+		<file source="\epoc32\data\z\system\data\statapiconsole_armv5.pkg" target="$EPOCROOT\epoc32\data\z\system\data" overwrite="true" />
+		<file source="\epoc32\data\z\private\10003a3f\apps\statapi_reg.rsc" target="$EPOCROOT\epoc32\data\z\private\10003a3f\apps" overwrite="true" />
+		<file source="\epoc32\data\z\resource\apps\statapi_loc.rsc" target="$EPOCROOT\epoc32\data\z\resource\apps" overwrite="true" />
+		<file source="\epoc32\data\z\resource\apps\statapiicon.mbm" target="$EPOCROOT\epoc32\data\z\resource\apps" overwrite="true" />
+		<file source="\epoc32\include\statapiicon.mbg" target="$EPOCROOT\epoc32\include" overwrite="true" />
+		<file source="\epoc32\localisation\group\statapi_loc.info" target="$EPOCROOT\epoc32\localisation\group" overwrite="true" />
+		<file source="\epoc32\localisation\group\statapi_reg.info" target="$EPOCROOT\epoc32\localisation\group" overwrite="true" />
+		<file source="\epoc32\localisation\group\statapiicon.info" target="$EPOCROOT\epoc32\localisation\group" overwrite="true" />
+		<file source="\epoc32\localisation\statapi_loc\RSC\statapi_loc.rpp" target="$EPOCROOT\epoc32\localisation\statapi_loc\RSC" overwrite="true" />
+		<file source="\epoc32\localisation\statapi_reg\RSC\statapi_reg.rpp" target="$EPOCROOT\epoc32\localisation\statapi_reg\RSC" overwrite="true" />
+		<file source="\epoc32\localisation\statapiicon\mbm\statapiicon_24x24i.bmp" target="$EPOCROOT\epoc32\localisation\statapiicon\mbm" overwrite="true" />
+		<file source="\epoc32\localisation\statapiicon\mbm\statapiicon_24x24m.bmp" target="$EPOCROOT\epoc32\localisation\statapiicon\mbm" overwrite="true" />
+		<file source="\epoc32\localisation\statapiicon\mbm\statapiicon_32x32i.bmp" target="$EPOCROOT\epoc32\localisation\statapiicon\mbm" overwrite="true" />
+		<file source="\epoc32\localisation\statapiicon\mbm\statapiicon_32x32m.bmp" target="$EPOCROOT\epoc32\localisation\statapiicon\mbm" overwrite="true" />
+		<file source="\epoc32\release\winscw\udeb\z\private\10003a3f\apps\statapi_reg.rsc" target="$EPOCROOT\epoc32\release\winscw\udeb\z\private\10003a3f\apps" overwrite="true" />
+		<file source="\epoc32\release\winscw\udeb\z\resource\apps\statapi_loc.rsc" target="$EPOCROOT\epoc32\release\winscw\udeb\z\resource\apps" overwrite="true" />
+		<file source="\epoc32\release\winscw\udeb\z\resource\apps\statapiicon.mbm" target="$EPOCROOT\epoc32\release\winscw\udeb\z\resource\apps" overwrite="true" />
+		<file source="\epoc32\release\winscw\urel\z\private\10003a3f\apps\statapi_reg.rsc" target="$EPOCROOT\epoc32\release\winscw\urel\z\private\10003a3f\apps" overwrite="true" />
+		<file source="\epoc32\release\winscw\urel\z\resource\apps\statapi_loc.rsc" target="$EPOCROOT\epoc32\release\winscw\urel\z\resource\apps" overwrite="true" />
+		<file source="\epoc32\release\winscw\urel\z\resource\apps\statapiicon.mbm" target="$EPOCROOT\epoc32\release\winscw\urel\z\resource\apps" overwrite="true" />
+		<file source="\epoc32\data\z\resource\engtools_swicertstore.dat" target="$EPOCROOT\epoc32\data\z\resource" overwrite="true" />
+
+	</files>
+
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/common/stat.cer	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,17 @@
+-----BEGIN CERTIFICATE-----
+MIICwzCCAoGgAwIBAgIBADALBgcqhkjOOAQDBQAwRzELMAkGA1UEBhMCR0IxFDAS
+BgNVBAoTC1N5bWJpYW4gTHRjMSIwIAYDVQQDExlBbnRvbnkgRWR3YXJkcyAtIFRy
+dXN0IE1lMB4XDTAyMDkwMjEyMjExMloXDTAzMDkwMjEyMjExMlowRzELMAkGA1UE
+BhMCR0IxFDASBgNVBAoTC1N5bWJpYW4gTHRjMSIwIAYDVQQDExlBbnRvbnkgRWR3
+YXJkcyAtIFRydXN0IE1lMIIBtjCCASsGByqGSM44BAEwggEeAoGBAJtgP3xihBnY
+pHsjvt8qoYVP4kzJnPmHGuFI+yRzHPm4pNdxTHGXOi3sX5UIEG12dL6sV3W/1LIB
+vB3F6dauPTKbVA8TaC5yZEStuAOvFD5Cb/x4J0YwtLMdpqW1Jxzo0KJPDZJfH1WQ
+bIQAk31Dy2w5iuEzC0a/4c3FZEv3sNGvAhUAkr+ELor4aHKSK1Jy6kbgY8DNKgsC
+gYB7/NcDjdvbF+CVdMRA/ul3zyuFoaxZy4HRtZ85yj5LodxsV2cK6APasenMpDqM
+yjssx2AOeVl/88FQ9epej7vdlGKaLophqpiNpxKzgFC/a7XDtaWyx/CIsXlqjICt
+oLQLGdfqakPK01t44dXhyx7Ex6hAFUM4z4PqbIpLC0eXOQOBhAACgYAPTE+VHFbg
+NaZMfR/t8ijOxs0hnP/muY8oBLhL1fDFVLt04di+OxFxJKLQhTYyafxwkwwgRNwN
+V6HaSh2RvAmAduf4pBUH3+lPg4aqhaqijPFhhBSq/MEDV9ChogudBA/fc3Xy2SCV
+g0Hy+grG4n7uG5cl0jnFZEQTADA0XqC3hzALBgcqhkjOOAQDBQADLwAwLAIUfpOY
+aMsjToIYYUSDMWF6iEiCvGoCFGnJPHf37DUd5242gb4yXKIYJze/
+-----END CERTIFICATE-----
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/common/stat.key	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,12 @@
+-----BEGIN DSA PRIVATE KEY-----
+MIIBugIBAAKBgQCbYD98YoQZ2KR7I77fKqGFT+JMyZz5hxrhSPskcxz5uKTXcUxx
+lzot7F+VCBBtdnS+rFd1v9SyAbwdxenWrj0ym1QPE2gucmRErbgDrxQ+Qm/8eCdG
+MLSzHaaltScc6NCiTw2SXx9VkGyEAJN9Q8tsOYrhMwtGv+HNxWRL97DRrwIVAJK/
+hC6K+GhykitScupG4GPAzSoLAoGAe/zXA43b2xfglXTEQP7pd88rhaGsWcuB0bWf
+Oco+S6HcbFdnCugD2rHpzKQ6jMo7LMdgDnlZf/PBUPXqXo+73ZRimi6KYaqYjacS
+s4BQv2u1w7WlssfwiLF5aoyAraC0CxnX6mpDytNbeOHV4csexMeoQBVDOM+D6myK
+SwtHlzkCgYAPTE+VHFbgNaZMfR/t8ijOxs0hnP/muY8oBLhL1fDFVLt04di+OxFx
+JKLQhTYyafxwkwwgRNwNV6HaSh2RvAmAduf4pBUH3+lPg4aqhaqijPFhhBSq/MED
+V9ChogudBA/fc3Xy2SCVg0Hy+grG4n7uG5cl0jnFZEQTADA0XqC3hwIUQqBG64Kj
+ZwBu3t/z7VvyZXOe+qs=
+-----END DSA PRIVATE KEY-----
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/common/statapi_common.mmp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,106 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Build file
+*
+*/
+
+
+	TARGET        		statgui.exe
+	TARGETTYPE    		exe
+
+UID           		0x100039ce 0x10009B04
+VENDORID 0x70000001
+
+epocheapsize		4096	3000000
+epocstacksize		0x5000
+
+////////////////////////////////////////////////////////////////
+//
+// Definitions
+//
+////////////////////////////////////////////////////////////////
+
+CAPABILITY		AllFiles SwEvent NetworkServices LocalServices PowerMgmt ProtServ TrustedUI CommDD ReadDeviceData WriteDeviceData 
+
+////////////////////////////////////////////////////////////////
+//
+// Include	Paths
+//
+////////////////////////////////////////////////////////////////
+USERINCLUDE			..\.\inc
+APP_LAYER_SYSTEMINCLUDE_SYMBIAN 		\epoc32\include
+#ifdef SYMBIAN_DIST_TECHVIEW
+APP_LAYER_SYSTEMINCLUDE_SYMBIAN 		\epoc32\include\techview
+#endif
+
+////////////////////////////////////////////////////////////////
+//
+// Resource Files
+//
+////////////////////////////////////////////////////////////////
+
+
+START RESOURCE		statgui.rss
+	HEADER
+	TARGETPATH		\resource\apps
+END
+
+START BITMAP		statguiicon.mbm
+	HEADER
+	SOURCEPATH		..\rsc
+	SOURCE			C8 statapiicon_24x24i.bmp statapiicon_24x24m.bmp statapiicon_32x32i.bmp statapiicon_32x32m.bmp
+	TARGETPATH		\resource\apps
+END
+
+START RESOURCE		..\rsc\statgui_loc.rss
+	TARGETPATH		\resource\apps
+END
+
+START RESOURCE		..\rsc\statgui_reg.rss
+	TARGETPATH		\private\10003a3f\apps
+END
+
+
+////////////////////////////////////////////////////////////////
+//
+// Source files
+//
+////////////////////////////////////////////////////////////////
+SOURCEPATH			.././src
+SOURCE				stat_application.cpp
+//SOURCE				stat_engine.cpp
+//SOURCE				stat_controller.cpp
+//SOURCE				stat_tcpip.cpp
+//SOURCE				stat_bt.cpp
+//SOURCE				stat_serial.cpp
+//SOURCE				stat_packetisation.cpp
+//SOURCE				stat_comdecoder.cpp
+SOURCE				stat_window.cpp
+//SOURCE				ActiveConnection.cpp
+//SOURCE				filedump.cpp
+//SOURCE				ntoh.cpp
+SOURCE				MsgWin.cpp
+//SOURCE				AssertE.cpp
+
+LIBRARY			euser.lib apparc.lib cone.lib eikcore.lib esock.lib
+LIBRARY			sdpdatabase.lib
+LIBRARY			bluetooth.lib apgrfx.lib fbscli.lib ws32.lib 
+LIBRARY			eikcoctl.lib c32.lib hal.lib efsrv.lib bafl.lib
+LIBRARY			iniparser.lib estor.lib
+LIBRARY			insock.lib
+LIBRARY			commdb.lib
+
+LIBRARY			sishelper.lib
+
+STATICLIBRARY			stat.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/console/bld.inf	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,38 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description: 
+//
+
+#define EXPORTED_STATCONSOLE
+
+PRJ_EXPORTS
+.\Export\statcommon.iby   			\epoc32\rom\include\statcommon.iby
+.\Export\Stat.iby   			\epoc32\rom\include\stat.iby
+.\Export\statauto.iby   		\epoc32\rom\include\statauto.iby
+.\Export\Statlite.iby   		\epoc32\rom\include\statlite.iby
+.\Export\techview_statapi.oby		\epoc32\rom\include\techview_statapi.oby
+.\Export\stat.ini   			\epoc32\data\z\system\data\stat.ini
+.\Export\stat_h2.ini   			\epoc32\data\z\system\data\stat_h2.ini
+.\Export\statapiconsole_armv5.pkg   			\epoc32\data\z\system\data\statapiconsole_armv5.pkg
+.\Export\engtools_swicertstore.dat	\epoc32\data\z\resource\engtools_swicertstore.dat
+.\Export\base_statlite.iby   		\epoc32\rom\include\base_statlite.iby
+
+PRJ_PLATFORMS
+
+
+PRJ_MMPFILES
+#include "../lib/bld.inf"
+#include "../light/bld.inf"
+.\statapiconsole.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/console/export/base_statlite.iby	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,33 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description: 
+//
+
+#ifndef __BASE_STATLITE_IBY__
+#define __BASE_STATLITE_IBY__
+
+REM This file is intended to be included by oby files which are to be processed "rom.bat"
+
+
+#ifndef __BASE_INIPARSER__
+#define __BASE_INIPARSER__
+file=\epoc32\release\##MAIN##\##BUILD##\iniparser.dll	      Sys\Bin\iniparser.dll
+#endif
+                      
+file=\epoc32\release\##MAIN##\##BUILD##\statlite.exe	      Sys\Bin\statapi.exe
+file=\epoc32\release\##MAIN##\##BUILD##\serialdriver.dll      Sys\Bin\serialdriver.dll
+
+data=\epoc32\data\z\system\data\stat_H2.ini			system\data\stat.ini
+
+#endif __BASE_STATLITE_IBY__
Binary file testconns/statapi/device/source/statapi/console/export/engtools_swicertstore.dat has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/console/export/stat.iby	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,37 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description: 
+//
+
+#ifndef __STATAPI_IBY__
+#define __STATAPI_IBY__
+
+REM Statapi
+
+#include <statcommon.iby>
+
+#ifndef __ET_SWICERTSTORE__
+#define __ET_SWICERTSTORE__
+data=ZRESOURCE\engtools_swicertstore.dat		Resource\swicertstore.dat
+#endif
+
+#if defined(__H2_OBY__) || defined(__H4HRP_OBY__) || defined(__34XX_SDP_OBY__)
+ECHO Stat.iby is including the H2/H4 stat.ini file
+data=ZSYSTEM\data\stat_H2.ini		System\data\stat.ini
+#else // def __H2_OBY__
+ECHO Stat.iby is including the default stat.ini file
+data=ZSYSTEM\data\stat.ini		System\data\stat.ini
+#endif // def __H2_OBY__
+
+#endif
Binary file testconns/statapi/device/source/statapi/console/export/stat.ini has changed
Binary file testconns/statapi/device/source/statapi/console/export/stat_h2.ini has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/console/export/statapiconsole_armv5.pkg	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,38 @@
+;
+; Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: 
+;
+&EN
+
+; standard SIS file header
+; not same is mmp, or the icon will become same.
+#{"statapi"},(0x10210D4F),1,0,0
+
+;Localised Vendor name
+%{"Sybiman-EN"}
+
+;Unique Vendor name
+:"Symbian"
+
+;Files to install
+"\epoc32\release\armv5\urel\statapi.exe" -"!:\sys\bin\statapi.exe"
+if NOT exists("z:\sys\bin\iniparser.dll") AND NOT exists("c:\sys\bin\iniparser.dll")
+"\EPOC32\RELEASE\ARMV5\UREL\iniparser.dll"-"!:\sys\bin\iniparser.dll"
+endif
+
+"\epoc32\data\z\system\data\stat.ini" -"!:\system\data\stat.ini"
+
+"\epoc32\data\z\private\10003a3f\apps\statapi_reg.rsc" -"!:\private\10003a3f\import\apps\statapi_reg.rsc"
+"\epoc32\data\z\resource\apps\statapi_loc.rsc" -"!:\resource\apps\statapi_loc.rsc"
+"\epoc32\data\z\resource\apps\statapiicon.mbm" -"!:\resource\apps\statapiicon.mbm"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/console/export/statauto.iby	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,57 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description: 
+//
+
+#ifndef __STATAPI_IBY__
+#define __STATAPI_IBY__
+
+REM Statapi
+
+#include <statcommon.iby>
+
+//Engineering Tools Certificate Store
+#ifndef __ET_SWICERTSTORE__
+#define __ET_SWICERTSTORE__
+data=ZRESOURCE\engtools_swicertstore.dat		Resource\swicertstore.dat
+#endif
+
+#if defined(__H2_OBY__) || defined(__H4HRP_OBY__) || defined(__34XX_SDP_OBY__)
+ECHO StatAuto.iby is including the H2/H4 stat.ini file
+data=ZSYSTEM\data\stat_H2.ini		System\data\stat.ini
+#else // def __H2_OBY__
+ECHO StatAuto.iby is including the default stat.ini file
+data=ZSYSTEM\data\stat.ini		System\data\stat.ini
+#endif // def __H2_OBY__
+
+
+
+
+#ifdef __TECHVIEWBASE_IBY__
+// Override the Techview Start.rsc file with one that launches 
+// statapi.exe as well.
+
+#ifdef _NOSYSSTART 
+
+#ifdef _NAND
+rename resource\apps\Start.rsc resource\Apps\Techview_Start.rsc
+#else
+hide resource\Apps\Start.rsc
+#endif
+
+data=ZRESOURCE\Apps\Statauto_Start.rsc	resource\Apps\Start.rsc
+#endif
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/console/export/statcommon.iby	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,35 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description: 
+//
+
+#ifndef __STATCOMMON_IBY__
+#define __STATCOMMON_IBY__
+
+#include <iniparser.iby>
+
+// TestExecute Test Framework
+#ifdef STAT_LITE
+file=ABI_DIR\DEBUG_DIR\statlite.exe	Sys\Bin\statapi.exe
+//duplicate the file so that TV on 9.1 would fire-up stat on the device.
+file=ABI_DIR\DEBUG_DIR\statlite.exe      Sys\Bin\statauto.exe
+#else
+file=ABI_DIR\DEBUG_DIR\statapi.exe	Sys\Bin\statapi.exe
+//duplicate the file so that TV on 9.1 would fire-up stat on the device.
+file=ABI_DIR\DEBUG_DIR\statapi.exe      Sys\Bin\statauto.exe
+#endif
+
+file=ABI_DIR\DEBUG_DIR\SerialDriver.DLL	Sys\Bin\SerialDriver.DLL
+
+#endif // __STATCOMMON_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/console/export/statlite.iby	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,51 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description: 
+//
+
+#ifndef __STATLITE_IBY__
+#define __STATLITE_IBY__
+
+REM StatLite
+
+#define STAT_LITE
+#include <statcommon.iby>
+
+//file=ABI_DIR\DEBUG_DIR\SerialDriver.DLL	Sys\Bin\SerialDriver.DLL
+
+#if defined(__H2_OBY__) || defined(__H4HRP_OBY__) || defined(__34XX_SDP_OBY__)
+ECHO StatLite.iby is including the H2/H4 stat.ini file
+data=ZSYSTEM\data\stat_H2.ini		System\data\stat.ini
+#else // def __H2_OBY__
+ECHO StatLite.iby is including the default stat.ini file
+data=ZSYSTEM\data\stat.ini		System\data\stat.ini
+#endif // def __H2_OBY__
+
+#ifdef __TECHVIEWBASE_IBY__
+// Override the Techview Start.rsc file with one that launches 
+// statauto.exe as well.
+
+#ifdef _NOSYSSTART 
+
+#ifdef _NAND
+rename resource\apps\Start.rsc resource\Apps\Techview_Start.rsc
+#else
+hide resource\Apps\Start.rsc
+#endif
+
+data=ZRESOURCE\Apps\Statauto_Start.rsc	resource\Apps\Start.rsc
+#endif
+#endif
+
+#endif __STATLITE_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/console/export/techview_statapi.oby	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,25 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description: 
+//
+
+REM Use debug versions of selected components. UnComment this line if you want to create a debug ROM
+// #define _DEBUG	
+
+
+define OBEYFILE techview_statapi
+define ROMDATE	##TODAY##
+
+#include <techview.oby>
+#include <statauto.iby>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/console/export/testdriver.cert	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,12 @@
+-----BEGIN CERTIFICATE-----
+MIIBuTCCAWMCCQD+oPRqwdxT1DANBgkqhkiG9w0BAQQFADB1MQswCQYDVQQGEwJV
+SzELMAkGA1UECBMCVUsxDzANBgNVBAcTBkxvbmRvbjEdMBsGA1UEChMUU3ltYmlh
+biBTb2Z0d2FyZSBMdGQxGjAYBgNVBAsTEUVuZ2luZWVyaW5nIFRvb2xzMQ0wCwYD
+VQQDEwRTVEFUMB4XDTgwMDEwMTAwMDQyNFoXDTM4MDExODAwMDQyNFowUjELMAkG
+A1UEBhMCVUsxDzANBgNVBAcTBkxvbmRvbjETMBEGA1UEAxMKVGVzdERyaXZlcjEd
+MBsGA1UEChMUU3ltYmlhbiBTb2Z0d2FyZSBMdGQwXDANBgkqhkiG9w0BAQEFAANL
+ADBIAkEAwb+f9b1S4yyf7ZcSQqNVJnFJvP7SuaQGWE6vzYsIN5iqzQXsTymKM3Iw
+PFFLX5jaAt/Ny0VBHq6U6aBZepfETwIDAQABMA0GCSqGSIb3DQEBBAUAA0EAQ2Wd
+fsxqyE879CmE3twGdwLSALWqk4UQreYsIppqR4ZrflGQYaFqv/mOJOpmbbHjhpWK
+w628Eh8LK0CVp6bclQ==
+-----END CERTIFICATE-----
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/console/export/testdriver.key	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,9 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIBOgIBAAJBAMG/n/W9UuMsn+2XEkKjVSZxSbz+0rmkBlhOr82LCDeYqs0F7E8p
+ijNyMDxRS1+Y2gLfzctFQR6ulOmgWXqXxE8CAwEAAQJBAKTIUMjVM7jpDEArW6l3
+dwVSFu/6Hskq2waiLd14IQ3+enqUT3Y+x1sMSdfK+824yI1b3O2qCdzOXykDdIAe
+kiECIQD2wOZ7pcIJHuoZ9/edF2EkkF28rlxvyEilH17eT7zy0QIhAMkCP8q0z9K2
+yyELxs3FnPKG2QtssRTNZuyehksPNc0fAiBxwUpANJF4bPUVlbhkhnO1TIy6QFPD
+AL1kykqNCIueEQIgCx5FuwefSy9zMuO83lrk4IFW9gvQC6+E1ue50+MGfc8CIDI0
+2QI/ovF/go151aCUBPIWr02j/lQ0qMLFYuI0dlm9
+-----END RSA PRIVATE KEY-----
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/console/start.mbc	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,7 @@
+SECTION_COMMANDS
+bldmake bldfiles
+abld build winscw
+abld build arm4
+
+SECTION_DIRS
+\techview\toolkit\startup\group
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/console/statapiconsole.mmp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Build file for OS DISTGeneric
+*
+*/
+
+
+TARGETTYPE              exe
+
+// no target path specified
+
+TARGET        		statapi.exe
+UID		0x1000007A 0x10210D4E
+VENDORID 0x70000001
+epocheapsize		4096	3000000
+
+USERINCLUDE			..\.\inc
+APP_LAYER_SYSTEMINCLUDE_SYMBIAN 		\epoc32\include
+
+CAPABILITY		AllFiles SwEvent NetworkServices LocalServices PowerMgmt ProtServ TrustedUI CommDD ReadDeviceData WriteDeviceData
+
+////////////////////////////////////////////////////////////////
+//
+// Resource Files
+//
+////////////////////////////////////////////////////////////////
+
+
+//START RESOURCE		statapi.rss
+//	HEADER
+//	TARGETPATH		\resource\apps
+//END
+
+START BITMAP		statapiicon.mbm
+	HEADER
+	SOURCEPATH		..\rsc
+	SOURCE			C8 statapiicon_24x24i.bmp statapiicon_24x24m.bmp statapiicon_32x32i.bmp statapiicon_32x32m.bmp
+	TARGETPATH		\resource\apps
+END
+
+START RESOURCE		..\rsc\statapi_loc.rss
+	TARGETPATH		\resource\apps
+END
+
+START RESOURCE		..\rsc\statapi_reg.rss
+	TARGETPATH		\private\10003a3f\apps
+END
+
+
+SOURCEPATH			..\.\src
+SOURCE				stat_main.cpp
+SOURCE				stat_console.cpp
+SOURCE				activeconsole.cpp
+
+LIBRARY			euser.lib apparc.lib esock.lib apgrfx.lib 
+LIBRARY			fbscli.lib hal.lib efsrv.lib estor.lib
+LIBRARY			c32.lib insock.lib iniparser.lib 
+LIBRARY			sdpdatabase.lib ws32.lib
+LIBRARY			bluetooth.lib 
+LIBRARY			sishelper.lib
+LIBRARY			commdb.lib 
+
+
+STATICLIBRARY			stat.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/group/bld.inf	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,24 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description: 
+//
+
+PRJ_PLATFORMS 
+
+
+PRJ_MMPFILES
+#ifndef _STATLIB_BLD_INF_
+	#include "../lib/bld.inf"
+#endif
+#include "../Techview/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/activeconnection.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+#include <e32base.h> 
+#include <in_sock.h>
+#include <commdbconnpref.h>
+#include <commdb.h>
+
+//micro seconds to wait before attempting to connect
+//to allow NTRAS connection to be initialised (2 sec)
+#define KDelay 2000000
+
+class CActiveConnection : public CActive
+	{
+public:
+	enum TActiveConnectionMode { EModeIAP, EModeSnap };
+	 // Construction
+	static CActiveConnection* NewL(const TDesC& ipAddress, TInt port);
+	 // Destruction
+	~CActiveConnection();
+	void Start(TActiveConnectionMode aConnMode = EModeIAP, TInt aConnIndex = 0);
+	void DoCancel();
+	void CloseSocket();
+
+private:
+	CActiveConnection();
+	void ConstructL(const TDesC& ipAddress, TInt port);
+	void RunL();
+	void Connect(TActiveConnectionMode aConnMode = EModeIAP, TInt aConnIndex = 0);
+
+private:
+	RSocketServ iSocketServer;
+	RSocket iSocket; 
+	TInetAddr iDstAddr;
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/activeconsole.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+#include <e32base.h> 
+#include "stat_controller.h"
+#include "stat_console.h"
+
+#ifndef LIGHT_MODE
+    #include "apgtask.h"
+#endif
+_LIT( KTxtExampleCode, "STATMAIN" );
+
+class CActiveConsole : public CActive
+	{
+public:
+	 // Construction
+	static CActiveConsole* NewL(CConsoleBase*,CStatController*,CStatConsole*,TInt, MNotifyLogMessage *const aMsg);
+	 // Destruction
+	~CActiveConsole();
+	void Start();
+	void DoCancel();
+
+private:
+	CActiveConsole(CConsoleBase*,CStatController*,CStatConsole*,TInt, MNotifyLogMessage *const aMsg);
+	void ConstructL();
+	void RunL();
+	void PushToBack();
+
+protected:
+	CConsoleBase* iConsole;			//A console for reading from
+	CStatController *iController;	//Pointer to CStatController object
+	CStatConsole *iStatConsole;		//statconsole
+	TInt iSessionID;				//CStatController session id, used to close session
+	MNotifyLogMessage *iMsg;
+	};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/appinstall.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+
+#if (!defined __TEST_SECURITY_APPINSTALL_H__)
+#define __TEST_SECURITY_APPINSTALL_H__
+
+
+class CAppInstall 
+
+{
+public:
+	CAppInstall();
+
+	static TInt Install(const TDesC&);
+	static TInt Uninstall(const TDesC&);	
+	
+protected:
+	
+private:
+};
+
+#endif // __TEST_SECURITY_APPINSTALL_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/assert.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __ASSERT_H__
+#define __ASSERT_H__
+
+// asserte
+// Extend assert to raise a panic that features the source file and 
+// line number that caused the assert.
+#include <e32std.h>
+extern void AssertE( TPtrC8 _file, TInt _line );
+#define asserte(x)	if(!(x)) { AssertE( (TPtrC8(reinterpret_cast<const TText8*>(__FILE__))), __LINE__); }
+
+// assert
+// Exit the program and show the message "Assert Failed".
+#define assert(x)	__ASSERT_ALWAYS((x),User::Panic(_L("Assert Failed"),0))
+
+#endif //__ASSERT_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/dataconsumer_file.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,79 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+ /********************************************************************************
+ *
+ * CDataConsumerFile
+ *
+ ********************************************************************************/
+#ifndef __CDATACONSUMERFILE_H__
+#define __CDATACONSUMERFILE_H__
+
+ /*************************************************************************
+ *
+ * System Includes
+ *
+ *************************************************************************/
+
+#include <e32std.h>
+#include <e32base.h>
+#include <f32file.h>
+
+/********************************************************************************
+ *
+ * Local Includes
+ *
+ ********************************************************************************/
+
+#include "stat_interfaces.h"
+
+/********************************************************************************
+ *
+ * Types
+ *
+ ********************************************************************************/
+class CDataConsumerFile :  public CBase, public MDataConsumer
+{
+public:
+	// Construction and destruction
+	static CDataConsumerFile *NewL( void );
+
+	// from MDataConsumer
+	void	Delete( void );
+	TInt	GetTotalSize( TInt &aTotalSize );
+
+	// The data source is a buffer of memory which is
+	// copied to this object.
+	TInt	AddData( const TDesC8 &aSource );
+	TInt	GetData( HBufC8 &aDestination );
+	TInt	SaveData( const TDesC &filePath );
+	operator const TDesC8&( void ) const;
+
+private:
+	CDataConsumerFile( void );
+	virtual ~CDataConsumerFile();
+	void ConstructL( void );
+
+	TPath	iFilePath;
+	RFs		iFsSession;
+
+	RMutex iLock;
+};
+
+#endif // __CDATACONSUMERFILE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/dataconsumer_memory.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+ /********************************************************************************
+ *
+ * CDataConsumerMemory
+ *
+ ********************************************************************************/
+#ifndef __CDATACONSUMERMEMORY_H__
+#define __CDATACONSUMERMEMORY_H__
+
+ /*************************************************************************
+ *
+ * System Includes
+ *
+ *************************************************************************/
+
+#include <e32std.h>
+#include <e32base.h>
+
+/********************************************************************************
+ *
+ * Local Includes
+ *
+ ********************************************************************************/
+
+#include "stat_interfaces.h"
+
+/********************************************************************************
+ *
+ * Types
+ *
+ ********************************************************************************/
+class CDataConsumerMemory :  public CBase, public MDataConsumer
+{
+public:
+	// Construction and destruction
+	static CDataConsumerMemory *NewL( void );
+
+	// from MDataConsumer
+	void	Delete( void );
+	TInt	GetTotalSize( TInt &aTotalSize );
+
+	// The data source is a buffer of memory which is
+	// copied to this object.
+	TInt	AddData( const TDesC8 &aSource );
+	TInt	GetData( HBufC8 &aDestination );
+	TInt	SaveData( const TDesC &filePath );
+	operator const TDesC8&( void ) const;
+
+private:
+	CDataConsumerMemory( void );
+	virtual ~CDataConsumerMemory();
+	void ConstructL( void );
+
+	HBufC8 *iDataBuffer;
+
+	RMutex iLock;
+};
+
+#endif // __CDATACONSUMERMEMORY_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/datasupplier_file.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+ /********************************************************************************
+ *
+ * CDataSupplierFile
+ *
+ ********************************************************************************/
+#ifndef __CDATASUPPLIERFILE_H__
+#define __CDATASUPPLIERFILE_H__
+
+ /*************************************************************************
+ *
+ * System Includes
+ *
+ *************************************************************************/
+
+#include <e32std.h>
+#include <e32base.h>
+#include <f32file.h>
+
+/********************************************************************************
+ *
+ * Local Includes
+ *
+ ********************************************************************************/
+
+#include "stat_interfaces.h"
+
+/********************************************************************************
+ *
+ * Types
+ *
+ ********************************************************************************/
+class CDataSupplierFile :  public CBase, public MDataSupplier
+{
+public:
+	// Construction and destruction
+	static CDataSupplierFile *NewL( void );
+
+	// from MDataSupplier
+	void	Delete( void );
+	TInt	GetTotalSize( TInt &aTotalSize );
+	TInt	GetRemainingSize( TInt &aRemainingSize );
+
+	// The data source is a string representing a file path.
+	TInt 	SetData( const TDesC8 &aSource );
+	TInt	GetData( HBufC8 &aDestination,
+				TInt aLengthToCopy, TInt &aActuallyCopied );
+
+private:
+	CDataSupplierFile( void );
+	virtual ~CDataSupplierFile();
+	void ConstructL( void );
+
+	HBufC8	*iDataBuffer;
+	TInt	iCurrentLocation;
+
+	TPath	iFilePath;
+	RFs		iFsSession;
+
+	RMutex	iLock;
+};
+
+#endif // __CDATASUPPLIERFILE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/datasupplier_memory.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,79 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+ /********************************************************************************
+ *
+ * CDataSupplierMemory
+ *
+ ********************************************************************************/
+#ifndef __CDATASUPPLIERMEMORY_H__
+#define __CDATASUPPLIERMEMORY_H__
+
+ /*************************************************************************
+ *
+ * System Includes
+ *
+ *************************************************************************/
+
+#include <e32std.h>
+#include <e32base.h>
+
+/********************************************************************************
+ *
+ * Local Includes
+ *
+ ********************************************************************************/
+
+#include "stat_interfaces.h"
+
+/********************************************************************************
+ *
+ * Types
+ *
+ ********************************************************************************/
+class CDataSupplierMemory :  public CBase, public MDataSupplier
+{
+public:
+	// Construction and destruction
+	static CDataSupplierMemory *NewL( void );
+
+	// from MDataSupplier
+	void	Delete( void );
+	TInt	GetTotalSize( TInt &aTotalSize );
+	TInt	GetRemainingSize( TInt &aRemainingSize );
+
+	// The data source is a buffer of memory which is
+	// copied to this object.
+	TInt 	SetData( const TDesC8 &aSource );
+	TInt	GetData( HBufC8 &aDestination,
+				TInt aLengthToCopy, TInt &aActuallyCopied );
+	// TInt	GetDataPtr( TPtrC8 &aDestination );
+
+private:
+	CDataSupplierMemory( void );
+	virtual ~CDataSupplierMemory();
+	void ConstructL( void );
+
+	HBufC8 *iDataBuffer;
+	TInt iCurrentLocation;
+
+	RMutex iLock;
+};
+
+#endif // __CDATASUPPLIERMEMORY_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/filedump.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+#ifndef FILEDUMP_H
+#define FILEDUMP_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include <e32cons.h>
+
+#include "stat_interfaces.h"
+
+#define ST_MAXMESSAGELENGTH		510
+
+class FileDump : public MNotifyLogMessage
+{
+public:
+	FileDump():bInitialised(EFalse), pConsole(NULL){}
+
+	// from MNotifyLogMessage
+	GLDEF_C TInt Init(RFs &fsSession, TPtrC16 filename, CConsoleBase* console);
+	GLDEF_C TBool IsInitialised() const;
+	GLDEF_C void Msg(TPtrC16 text, ...);
+	GLDEF_C void CloseFile();
+
+private:
+	TBool bInitialised;
+	RFile file;
+	CConsoleBase* pConsole;
+	TBuf16<ST_MAXMESSAGELENGTH + 2> buf;	// temp buffer
+
+	GLDEF_C TBool WriteBuffer16ToFile(TDesC16 &buffer, RFile &handle);
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/keycodes.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,552 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#if !defined(__KEYCODES_H__)
+#define __KEYCODES_H__
+
+#include <e32keys.h>
+
+#define NO_MORE_KEYS	_S("NO_MORE_KEYS")	// end of array
+#define NO_MORE_SCANCODEKEYS _S("NO_MORE_SCANCODE_KEYS")
+
+//------------------------------------------------------------------------------
+//This section represents the textual KEY codes entered by the end user
+
+const TText* const ENUM_TEXTKEYArray[] = 
+{
+	_S("Null"),
+	_S("Bell"),
+	_S("Backspace"),
+	_S("Tab"),
+	_S("LineFeed"),
+	_S("VerticalTab"),
+	_S("FormFeed"),
+	_S("Enter"),
+	_S("Escape"),
+	_S("Space"),
+	_S("Delete"),
+	_S("PrintScreen"),
+	_S("Pause"),
+	_S("Home"),
+	_S("End"),
+	_S("PageUp"),
+	_S("PageDown"),
+	_S("Insert"),
+	_S("LeftArrow"),
+	_S("RightArrow"),
+	_S("UpArrow"),
+	_S("DownArrow"),
+	_S("LeftShift"),
+	_S("RightShift"),
+	_S("LeftAlt"),
+	_S("RightAlt"),
+	_S("LeftCtrl"),
+	_S("RightCtrl"),
+	_S("LeftFunc"),
+	_S("RightFunc"),
+	_S("CapsLock"),
+	_S("NumLock"),
+	_S("ScrollLock"),
+	_S("F1"),
+	_S("F2"),
+	_S("F3"),
+	_S("F4"),
+	_S("F5"),
+	_S("F6"),
+	_S("F7"),
+	_S("F8"),
+	_S("F9"),
+	_S("F10"),
+	_S("F11"),
+	_S("F12"),
+	_S("F13"),
+	_S("F14"),
+	_S("F15"),
+	_S("F16"),
+	_S("F17"),
+	_S("F18"),
+	_S("F19"),
+	_S("F20"),
+	_S("F21"),
+	_S("F22"),
+	_S("F23"),
+	_S("F24"),
+    _S("Off"),
+    _S("IncContrast"),
+    _S("DecContrast"),
+    _S("BacklightOn"),
+    _S("BacklightOff"),
+    _S("BacklightToggle"),
+    _S("SliderDown"),
+    _S("SliderUp"),
+    _S("Menu"),
+    _S("DictaphonePlay"),
+    _S("DictaphoneStop"),
+    _S("DictaphoneRecord"),
+    _S("Help"),
+    _S("Dial"),
+	_S("ScreenDimension0"),
+	_S("ScreenDimension1"),
+	_S("ScreenDimension2"),
+	_S("ScreenDimension3"),
+	_S("IncVolume"),
+	_S("DecVolume"),
+	_S("Device0"),
+	_S("Device1"),
+	_S("Device2"),
+	_S("Device3"),
+	_S("Device4"),
+	_S("Device5"),
+	_S("Device6"),
+	_S("Device7"),
+	_S("Device8"),
+	_S("Device9"),
+	_S("DeviceA"),
+	_S("DeviceB"),
+	_S("DeviceC"),
+	_S("DeviceD"),
+	_S("DeviceE"),
+	_S("DeviceF"),
+	_S("Application0"),
+	_S("Application1"),
+	_S("Application2"),
+	_S("Application3"),
+	_S("Application4"),
+	_S("Application5"),
+	_S("Application6"),
+	_S("Application7"),
+	_S("Application8"),
+	_S("Application9"),
+	_S("ApplicationA"),
+	_S("ApplicationB"),
+	_S("ApplicationC"),
+	_S("ApplicationD"),
+	_S("ApplicationE"),
+	_S("ApplicationF"),
+	_S("Yes"),
+	_S("No"),
+	_S("IncBrightness"),
+	_S("DecBrightness"),
+	NO_MORE_KEYS
+};
+
+//------------------------------------------------------------------------------
+//This section represents the TKeyCode values of the KEYS used by the end user
+
+const TKeyCode ENUM_VALKEYArray[] =
+{
+	EKeyNull,
+	EKeyBell,
+	EKeyBackspace,
+	EKeyTab,
+	EKeyLineFeed,
+	EKeyVerticalTab,
+	EKeyFormFeed,
+	EKeyEnter,
+	EKeyEscape,
+	EKeySpace,
+	EKeyDelete,
+	EKeyPrintScreen,
+	EKeyPause,
+	EKeyHome,
+	EKeyEnd,
+	EKeyPageUp,
+	EKeyPageDown,
+	EKeyInsert,
+	EKeyLeftArrow,
+	EKeyRightArrow,
+	EKeyUpArrow,
+	EKeyDownArrow,
+	EKeyLeftShift,
+	EKeyRightShift,
+	EKeyLeftAlt,
+	EKeyRightAlt,
+	EKeyLeftCtrl,
+	EKeyRightCtrl,
+	EKeyLeftFunc,
+	EKeyRightFunc,
+	EKeyCapsLock,
+	EKeyNumLock,
+	EKeyScrollLock,
+	EKeyF1,
+	EKeyF2,
+	EKeyF3,
+	EKeyF4,
+	EKeyF5,
+	EKeyF6,
+	EKeyF7,
+	EKeyF8,
+	EKeyF9,
+	EKeyF10,
+	EKeyF11,
+	EKeyF12,
+	EKeyF13,
+	EKeyF14,
+	EKeyF15,
+	EKeyF16,
+	EKeyF17,
+	EKeyF18,
+	EKeyF19,
+	EKeyF20,
+	EKeyF21,
+	EKeyF22,
+	EKeyF23,
+	EKeyF24,
+    EKeyOff,
+    EKeyIncContrast,
+    EKeyDecContrast,
+    EKeyBacklightOn,
+    EKeyBacklightOff,
+    EKeyBacklightToggle,
+    EKeySliderDown,
+    EKeySliderUp,
+    EKeyMenu,
+    EKeyDictaphonePlay,
+    EKeyDictaphoneStop,
+    EKeyDictaphoneRecord,
+    EKeyHelp,
+    EKeyDial,
+	EKeyScreenDimension0,
+	EKeyScreenDimension1,
+	EKeyScreenDimension2,
+	EKeyScreenDimension3,
+	EKeyIncVolume,
+	EKeyDecVolume,
+	EKeyDevice0,
+	EKeyDevice1,
+	EKeyDevice2,
+	EKeyDevice3,
+	EKeyDevice4,
+	EKeyDevice5,
+	EKeyDevice6,
+	EKeyDevice7,
+	EKeyDevice8,
+	EKeyDevice9,
+	EKeyDeviceA,
+	EKeyDeviceB,
+	EKeyDeviceC,
+	EKeyDeviceD,
+	EKeyDeviceE,
+	EKeyDeviceF,
+	EKeyApplication0,
+	EKeyApplication1,
+	EKeyApplication2,
+	EKeyApplication3,
+	EKeyApplication4,
+	EKeyApplication5,
+	EKeyApplication6,
+	EKeyApplication7,
+	EKeyApplication8,
+	EKeyApplication9,
+	EKeyApplicationA,
+	EKeyApplicationB,
+	EKeyApplicationC,
+	EKeyApplicationD,
+	EKeyApplicationE,
+	EKeyApplicationF,
+	EKeyYes,
+	EKeyNo,
+	EKeyIncBrightness,
+	EKeyDecBrightness
+};
+
+//------------------------------------------------------------------------------
+//This section represents the textual SCAN codes entered by the end user in sending system keypresses (L)
+
+const TText* const ENUM_TEXTSCANCODEArray[] = 
+{
+	_S("Null"),
+	_S("Backspace"),
+	_S("Tab"),
+	_S("Enter"),
+	_S("Escape"),
+	_S("Space"),
+	_S("PrintScreen"),
+	_S("Pause"),
+	_S("Home"),
+	_S("End"),
+	_S("PageUp"),
+	_S("PageDown"),
+	_S("Insert"),
+	_S("Delete"),
+	_S("LeftArrow"),
+	_S("RightArrow"),
+	_S("UpArrow"),
+	_S("DownArrow"),
+	_S("LeftShift"),
+	_S("RightShift"),
+	_S("LeftAlt"),
+	_S("RightAlt"),
+	_S("LeftCtrl"),
+	_S("RightCtrl"),
+	_S("LeftFunc"),
+	_S("RightFunc"),
+	_S("CapsLock"),
+	_S("NumLock"),
+	_S("ScrollLock"),
+	_S("F1"),
+	_S("F2"),
+	_S("F3"),
+	_S("F4"),
+	_S("F5"),
+	_S("F6"),
+	_S("F7"),
+	_S("F8"),
+	_S("F9"),
+	_S("F10"),
+	_S("F11"),
+	_S("F12"),
+	_S("F13"),
+	_S("F14"),
+	_S("F15"),
+	_S("F16"),
+	_S("F17"),
+	_S("F18"),
+	_S("F19"),
+	_S("F20"),
+	_S("F21"),
+	_S("F22"),
+	_S("F23"),
+	_S("F24"),
+	_S("XXX"),
+	_S("Comma"),
+	_S("FullStop"),
+	_S("ForwardSlash"),
+	_S("BackSlash"),
+	_S("SemiColon"),
+	_S("SingleQuote"),
+	_S("Hash"),
+	_S("SquareBracketLeft"),
+	_S("SquareBracketRight"),
+	_S("Minus"),
+	_S("Equals"),
+	_S("NkpForwardSlash"),
+	_S("NkpAsterisk"),
+	_S("NkpMinus"),
+	_S("NkpPlus"),
+	_S("NkpEnter"),
+	_S("Nkp1"),
+	_S("Nkp2"),
+	_S("Nkp3"),
+	_S("Nkp4"),
+	_S("Nkp5"),
+	_S("Nkp6"),
+	_S("Nkp7"),
+	_S("Nkp8"),
+	_S("Nkp9"),
+	_S("Nkp0"),
+	_S("NkpFullStop"),
+    _S("Menu"),
+    _S("BacklightOn"),
+    _S("BacklightOff"),
+    _S("BacklightToggle"),
+    _S("IncContrast"),
+    _S("DecContrast"),
+    _S("SliderDown"),
+    _S("SliderUp"),
+    _S("DictaphonePlay"),
+    _S("DictaphoneStop"),
+    _S("DictaphoneRecord"),
+    _S("Help"),
+    _S("Off"),
+    _S("Dial"),
+    _S("IncVolume"),
+    _S("DecVolume"),
+    _S("Device0"),
+    _S("Device1"),
+    _S("Device2"),
+    _S("Device3"),
+    _S("Device4"),
+    _S("Device5"),
+    _S("Device6"),
+    _S("Device7"),
+    _S("Device8"),
+    _S("Device9"),
+    _S("DeviceA"),
+    _S("DeviceB"),
+    _S("DeviceC"),
+    _S("DeviceD"),
+    _S("DeviceE"),
+    _S("DeviceF"),
+    _S("Application0"),
+    _S("Application1"),
+    _S("Application2"),
+    _S("Application3"),
+    _S("Application4"),
+    _S("Application5"),
+    _S("Application6"),
+    _S("Application7"),
+    _S("Application8"),
+    _S("Application9"),
+    _S("ApplicationA"),
+    _S("ApplicationB"),
+    _S("ApplicationC"),
+    _S("ApplicationD"),
+    _S("ApplicationE"),
+    _S("ApplicationF"),
+	_S("Yes"),
+	_S("No"),
+	_S("IncBrightness"),
+	_S("DecBrightness"),
+	NO_MORE_SCANCODEKEYS
+
+};
+
+//------------------------------------------------------------------------------
+//This section represents the TStdScanCode values of the SCANCODES used by the end user with the L command
+
+const TStdScanCode ENUM_VALSCANCODEArray[] =
+{
+	EStdKeyNull,
+	EStdKeyBackspace,
+	EStdKeyTab,
+	EStdKeyEnter,
+	EStdKeyEscape,
+	EStdKeySpace,
+	EStdKeyPrintScreen,
+	EStdKeyPause,
+	EStdKeyHome,
+	EStdKeyEnd,
+	EStdKeyPageUp,
+	EStdKeyPageDown,
+	EStdKeyInsert,
+	EStdKeyDelete,
+	EStdKeyLeftArrow,
+	EStdKeyRightArrow,
+	EStdKeyUpArrow,
+	EStdKeyDownArrow,
+	EStdKeyLeftShift,
+	EStdKeyRightShift,
+	EStdKeyLeftAlt,
+	EStdKeyRightAlt,
+	EStdKeyLeftCtrl,
+	EStdKeyRightCtrl,
+	EStdKeyLeftFunc,
+	EStdKeyRightFunc,
+	EStdKeyCapsLock,
+	EStdKeyNumLock,
+	EStdKeyScrollLock,
+	EStdKeyF1,
+	EStdKeyF2,
+	EStdKeyF3,
+	EStdKeyF4,
+	EStdKeyF5,
+	EStdKeyF6,
+	EStdKeyF7,
+	EStdKeyF8,
+	EStdKeyF9,
+	EStdKeyF10,
+	EStdKeyF11,
+	EStdKeyF12,
+	EStdKeyF13,
+	EStdKeyF14,
+	EStdKeyF15,
+	EStdKeyF16,
+	EStdKeyF17,
+	EStdKeyF18,
+	EStdKeyF19,
+	EStdKeyF20,
+	EStdKeyF21,
+	EStdKeyF22,
+	EStdKeyF23,
+	EStdKeyF24,
+	EStdKeyXXX,
+	EStdKeyComma,
+	EStdKeyFullStop,
+	EStdKeyForwardSlash,
+	EStdKeyBackSlash,
+	EStdKeySemiColon,
+	EStdKeySingleQuote,
+	EStdKeyHash,
+	EStdKeySquareBracketLeft,
+	EStdKeySquareBracketRight,
+	EStdKeyMinus,
+	EStdKeyEquals,
+	EStdKeyNkpForwardSlash,
+	EStdKeyNkpAsterisk,
+	EStdKeyNkpMinus,
+	EStdKeyNkpPlus,
+	EStdKeyNkpEnter,
+	EStdKeyNkp1,
+	EStdKeyNkp2,
+	EStdKeyNkp3,
+	EStdKeyNkp4,
+	EStdKeyNkp5,
+	EStdKeyNkp6,
+	EStdKeyNkp7,
+	EStdKeyNkp8,
+	EStdKeyNkp9,
+	EStdKeyNkp0,
+	EStdKeyNkpFullStop,
+    EStdKeyMenu,
+    EStdKeyBacklightOn,
+    EStdKeyBacklightOff,
+    EStdKeyBacklightToggle,
+    EStdKeyIncContrast,
+    EStdKeyDecContrast,
+    EStdKeySliderDown,
+    EStdKeySliderUp,
+    EStdKeyDictaphonePlay,
+    EStdKeyDictaphoneStop,
+    EStdKeyDictaphoneRecord,
+    EStdKeyHelp,
+    EStdKeyOff,
+    EStdKeyDial,
+    EStdKeyIncVolume,
+    EStdKeyDecVolume,
+    EStdKeyDevice0,
+    EStdKeyDevice1,
+    EStdKeyDevice2,
+    EStdKeyDevice3,
+    EStdKeyDevice4,
+    EStdKeyDevice5,
+    EStdKeyDevice6,
+    EStdKeyDevice7,
+    EStdKeyDevice8,
+    EStdKeyDevice9,
+    EStdKeyDeviceA,
+    EStdKeyDeviceB,
+    EStdKeyDeviceC,
+    EStdKeyDeviceD,
+    EStdKeyDeviceE,
+    EStdKeyDeviceF,
+    EStdKeyApplication0,
+    EStdKeyApplication1,
+    EStdKeyApplication2,
+    EStdKeyApplication3,
+    EStdKeyApplication4,
+    EStdKeyApplication5,
+    EStdKeyApplication6,
+    EStdKeyApplication7,
+    EStdKeyApplication8,
+    EStdKeyApplication9,
+    EStdKeyApplicationA,
+    EStdKeyApplicationB,
+    EStdKeyApplicationC,
+    EStdKeyApplicationD,
+    EStdKeyApplicationE,
+    EStdKeyApplicationF,
+	EStdKeyYes,
+	EStdKeyNo,
+	EStdKeyIncBrightness,
+	EStdKeyDecBrightness
+};
+
+//------------------------------------------------------------------------------
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/modifiers.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,83 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#if !defined(__MODIFIERS_H__)
+#define __MODIFIERS_H__
+
+#include <e32keys.h>
+
+//------------------------------------------------------------------------------
+
+#define NO_MORE_MODIFIERKEYS	_S("NO_MORE_MODIFIERKEYS")	// end of array
+
+const TText* const ENUM_TEXTMODIFIERSArray[] = 
+{
+	_S("Autorepeatable"),
+	_S("Keypad"),
+	_S("LeftAlt"),
+	_S("RightAlt"),
+	_S("Alt"),
+	_S("LeftCtrl"),
+	_S("RightCtrl"),
+	_S("Ctrl"),
+	_S("LeftShift"),
+	_S("RightShift"),
+	_S("Shift"),
+	_S("LeftFunc"),
+	_S("RightFunc"),
+	_S("Func"),
+	_S("CapsLock"),
+	_S("NumLock"),
+	_S("ScrollLock"),
+	_S("KeyUp"),
+	_S("Special"),
+	_S("DoubleClick"),
+    _S("PureKeycode"),
+	_S("EAllModifiers"),
+	NO_MORE_MODIFIERKEYS
+};
+
+//------------------------------------------------------------------------------
+
+const TEventModifier ENUM_VALMODIFIERSArray[] =
+{
+	EModifierAutorepeatable,
+	EModifierKeypad,
+	EModifierLeftAlt,
+	EModifierRightAlt,
+	EModifierAlt,
+	EModifierLeftCtrl,
+	EModifierRightCtrl,
+	EModifierCtrl,
+	EModifierLeftShift,
+	EModifierRightShift,
+	EModifierShift,
+	EModifierLeftFunc,
+	EModifierRightFunc,
+	EModifierFunc,
+	EModifierCapsLock,
+	EModifierNumLock,
+	EModifierScrollLock,
+	EModifierKeyUp,
+	EModifierSpecial,
+	EModifierDoubleClick,
+    EModifierPureKeycode,
+	EAllModifiers
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/msgwin.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+#ifndef __MSGWIN_H__
+#define __MSGWIN_H__
+
+class TMsgWin
+{
+public:
+	static void Show( TPtrC text, ... );
+};
+
+#endif // __MSGWIN_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/ntoh.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+/********************************************************************************
+ *
+ * Switches
+ *
+ *******************************************************************************/
+#ifndef __NTOH_H__
+#define __NTOH_H__
+
+/********************************************************************************
+ *
+ * Includes
+ *
+ *******************************************************************************/
+#include <e32std.h>
+
+/********************************************************************************
+ *
+ * Definitions
+ *
+ *******************************************************************************/
+#define LilEnd 0
+#define BigEnd 1
+
+/********************************************************************************
+ *
+ * Macro Functions
+ *
+ *******************************************************************************/
+
+/********************************************************************************
+ *
+ * Prototypes
+ *
+ *******************************************************************************/
+int DetectLocalEndian();
+long LittleToBigL( long src );
+long BigToLittleL( long src );
+short LittleToBigS( short src );
+short BigToLittleS( short src );
+long ntohl( long src );
+long htonl( long src );
+short ntohs( short src );
+short htons( short src );
+
+#endif // __NTOH_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/stat.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef __STAT_H__
+#define __STAT_H__
+
+const TUint KVersionMajor = 1; 
+const TUint KVersionMinor = 1;
+const TUint KVersionPatch = 1002;
+
+const char  OPT_DELIMITER	= '|';
+const char	RESYNC_ID		= '?';
+const char	FAILED_ID		= '*';
+const char  REFRESH_ID		= 'Q';
+
+_LIT(KFileSrvDll, "efsrv.dll");
+_LIT(KFileSeparator, "\\");
+_LIT(KStatLogFile, "statoutput.log");
+_LIT(KReDrive, "$:");
+
+#endif //__STAT_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/stat_application.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,121 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+/*************************************************************************
+ *
+ * Switches
+ *
+ ************************************************************************/
+#ifndef __STATAPPLICATION_H__
+#define __STATAPPLICATION_H__
+
+/*************************************************************************
+ *
+ * System Includes
+ *
+ ************************************************************************/
+#include <coeccntx.h>
+#include <eikenv.h>
+#include <eikappui.h>
+#include <eikapp.h>
+#include <eikdoc.h>
+#include <eikmenup.h>
+
+/*************************************************************************
+ *
+ * Local Includes
+ *
+ ************************************************************************/
+#include <statgui.rsg>
+#include "statapi.hrh"
+#include "stat_window.h"
+#include "stat_tcpip.h"
+#include "stat_controller.h"
+
+#ifdef SYMBIAN_DIST_SERIES60
+#include <aknappui.h>
+#endif
+
+/*************************************************************************
+ *
+ * Definitions
+ *
+ ************************************************************************/
+#ifdef SYMBIAN_DIST_SERIES60
+#define CPlatAppUi	CAknAppUi
+#else
+#define CPlatAppUi CEikAppUi
+#endif
+
+/*************************************************************************
+ *
+ * CStatApplication
+ *
+ ************************************************************************/
+class CStatApplication : public CEikApplication
+{
+private: 
+	CApaDocument* CreateDocumentL();
+	TUid AppDllUid() const;
+};
+
+/*************************************************************************
+ *
+ * CStatDocument
+ *
+ ************************************************************************/
+class CStatDocument : public CEikDocument
+{
+public:
+	static CStatDocument* NewL(CEikApplication& aApp);
+	CStatDocument(CEikApplication& aApp);
+	void ConstructL();
+
+private: 
+	CEikAppUi* CreateAppUiL();
+};
+
+/*************************************************************************
+ *
+ * CStatAppUi
+ *
+ ************************************************************************/
+class CStatAppUi : public CPlatAppUi, public MCoeControlObserver
+{
+public:	
+    void ConstructL();
+	~CStatAppUi();
+
+	// From CEikAppUi
+	TKeyResponse HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
+	void HandleCommandL( TInt aCommand );
+	void HandleForegroundEventL(TBool aForeground);
+
+	// From MCoeControlObserver
+	void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType );
+
+private:
+	CStatController *iController;
+	CStatWindow *iWindow;
+};
+
+
+
+#endif //__STATAPPLICATION_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/stat_bt.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,141 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+/********************************************************************************
+ *
+ * Stat Bletooth Transport
+ *
+ *******************************************************************************/
+#ifndef __STATBT_H__
+#define __STATBT_H__
+
+/********************************************************************************
+ *
+ * System Includes
+ *
+ *******************************************************************************/
+#include <es_sock.h>
+
+#include <btmanclient.h>
+#include <btsdp.h>
+#include <bt_sock.h>
+#include <btextnotifiers.h>
+
+/********************************************************************************
+ *
+ * Local Includes
+ *
+ *******************************************************************************/
+#include "stat_interfaces.h"
+
+/********************************************************************************
+ *
+ * Definitions
+ *
+ *******************************************************************************/
+const TUint KStatBTHeaderSize	= 8;
+const TUint KLittleStatBTListenQueue = 1;
+const TUint KLittleStatBTPort = 3;
+
+/********************************************************************************
+ *
+ * CStatTransportBT - Top-level of the transport. Creates and waits on the 
+ * listening socket. When a new data socket is created it creates the reader
+ * and writer passing the socket to them. After that, the object simply routes
+ * read/write calls/cancels to the appopriate objects.
+ *
+ *******************************************************************************/
+class CStatTransportBT : public CActive, public MStatNetwork
+{
+public:
+	// construction
+	static CStatTransportBT *NewL( void );
+	CStatTransportBT();
+	~CStatTransportBT();
+
+	// from MStatNetwork
+	TInt GetPacketSize();
+	TInt InitialiseL( MNotifyStatTransport *iTransport );
+	TInt ConnectL( TDesC *aRemoteHost );
+	TInt RequestSend( TDesC8 *aCommandData, const TUint aDataLength );
+	TInt RequestReceive( TUint aByteCount );
+	TInt Disconnect( void );
+	TInt Release( void );
+	TText8 *Error( void );
+	TUint NtoHl( TUint aValue ) const;
+	TUint HtoNl( TUint aValue ) const;
+	TBool PadPacket( TUint size ) const;
+
+	// from CActive 
+	void RunL( void );
+	void DoCancel();
+
+private:
+	void ConstructL( void );
+	
+	TInt RegWithSDPDatabaseL( void );
+	TInt StartSocketL( void );
+	void HandleAsyncDisconnect( void );
+
+public:
+	enum TStatTransportBTStatus { EIdle, EError, EInitialised, EConnectingSockets, EConnected, 
+								EConnectingRegisterMgr, EConnectingRegisterSDP, 
+								EDisconnectingData, EDisconnectingListen, 
+								EDisconnected, EDisconnectingUnregister };
+
+private:
+	TStatTransportBTStatus iBTTransportStatus;
+	TStatTransportBTStatus iBTTransportDisconnectStatusBeforeUnregister;
+	TReadWriteStatus iRWStatus;
+	MNotifyStatTransport *iTransport;
+	TInt iMaxPacketSize;
+
+	HBufC8 *iRecvBuffer;
+	TPtr8 *iRecvBufferPtr;
+
+ 	RSocket iListenSocket;
+	RSocket iDataSocket;
+ 	RSocketServ iSocketServ;
+ 	HBufC8 *iWrCommandData;
+ 	TUint iPort;							//	Assigned port number
+
+ 	TBTServiceSecurity iServiceSecurity;	//Service security object
+ 
+ 
+ 	RSdp iSdpSession;					//Service Discovery Session
+ 	RSdpDatabase iSdpDatabaseSession;	//Subsession to the SDP through which service record and their attributes can be added, deleted, and updated.
+ 	TSdpServRecordHandle iRecHandle;		//Session record handle
+};
+
+inline TUint CStatTransportBT::NtoHl( TUint aValue ) const
+{
+	return ( aValue );
+}
+
+inline TUint CStatTransportBT::HtoNl( TUint aValue ) const
+{
+	return ( aValue );
+}
+
+inline TBool CStatTransportBT::PadPacket( TUint ) const
+{
+	return ( EFalse );
+}
+
+#endif // __STATBT_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/stat_console.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+/*************************************************************************
+ *
+ * Switches
+ *
+ ************************************************************************/
+#ifndef __STATCONSOLE_H__
+#define __STATCONSOLE_H__
+
+/*************************************************************************
+ *
+ * System Includes
+ *
+ ************************************************************************/
+#include <e32base.h>
+#include <e32cons.h>
+
+/*************************************************************************
+ *
+ * Local Includes
+ *
+ ************************************************************************/
+#include "stat_interfaces.h"
+
+/*************************************************************************
+ *
+ * Definitions
+ *
+ ************************************************************************/
+
+/*************************************************************************
+ *
+ * CStatConsole
+ *
+ ************************************************************************/
+class CStatConsole : public CBase, public MNotifyUI
+{
+public:
+	// Construction
+	static CStatConsole *NewL( CConsoleBase *aConsole, MNotifyLogMessage *const aMsg );
+	void ConstructL( CConsoleBase *aConsole, MNotifyLogMessage *const aMsg ); 
+	~CStatConsole();
+
+	// MNotifyUI
+	void HandleStatusChange( TInt aSessionId, TCommStatus aNewStatus );
+	void HandleError( TInt aError, void *aErrorData );
+	void HandleInfo( const TDesC *aInfo );
+	void UserExitRequest();
+
+private:
+	CConsoleBase *iConsole;
+	TInt iUserExitRequest;
+
+	MNotifyLogMessage *iMsg;
+};
+
+#endif //__STATCONSOLE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/stat_controller.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,117 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+/*************************************************************************
+ *
+ * Switches
+ *
+ ************************************************************************/
+#ifndef __STATCONTROLLER_H__
+#define __STATCONTROLLER_H__
+
+/*************************************************************************
+ *
+ * System Includes
+ *
+ ************************************************************************/
+#include <e32std.h>
+#include <e32base.h>
+
+/*************************************************************************
+ *
+ * Local Includes
+ *
+ ************************************************************************/
+#include "stat_interfaces.h"
+#include "stat_engine.h"
+#include "stat_packetisation.h"
+#include "stat_serial.h"
+
+#ifndef LIGHT_MODE
+#include "stat_tcpip.h"
+#include "stat_bt.h"
+#include "stat_usb.h"
+#endif // ifndef LIGHT_MODE
+
+
+
+/*************************************************************************
+ *
+ * Definitions
+ *
+ ************************************************************************/
+#define KAddressTextLimit 16
+
+/*************************************************************************
+ *
+ * CStatController
+ *
+ ************************************************************************/
+class CStatController : public CActive, public MStatController, public MNotifyStatController
+{
+public:
+	~CStatController();
+	static CStatController *NewL();
+
+	// from MStatController
+	TInt StartSession( TStatConnectType aConnectType, TDesC *aConnectParams, MNotifyUI *aUI, RFs *const aSession, MNotifyLogMessage *const aMsg);
+	TInt StopSession( TInt aSessionId );
+	TInt SessionStatus( TInt aSessionId );
+
+	// from MNotifyStatController
+	void HandleStatusChange( TCommStatus aNewStatus );
+	void HandleError( TInt aError, void *aErrorData );
+	void HandleInfo( const TDesC *aInfo );
+
+	// from CActive
+	void RunL();
+	void DoCancel();
+
+private:
+	CStatController();
+	void ConstructL( void );
+	void SetStatus( TCommStatus aNewStatus );
+	void Notify( TInt aErrorStatus );
+	MStatApiTransport *StartTransportL( TStatConnectType aConnectType );
+	void KillTransport();
+
+	TCommStatus iSessionStatus;
+	MStatApiTransport *iTransport;
+	CStatEngine *iEngine;
+	MNotifyUI *iUI;
+
+	TStatConnectType iConnectType;
+	CStatTransportPacketisation *iPacketisationTransport;
+	CStatApiSerial *iSerialNetwork;
+#ifndef LIGHT_MODE
+	CStatTransportTCPIP *iTcpipTransport;
+
+	CStatApiUsb *iUsbNetwork;
+	CStatTransportBT *iBluetoothTransport;
+#endif
+
+	TBool iConnectedSuccessfully, iUserInitiatedExitRequest;
+	TBuf<KAddressTextLimit> iConnectParams;
+
+	RFs *iFs;
+	MNotifyLogMessage *iMsg;
+};
+
+
+#endif //__STATCONTROLLER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/stat_engine.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,109 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+ /********************************************************************************
+ *
+ * CStatEngine - central hub of stat
+ *
+ ********************************************************************************/
+#ifndef __CSTATENGINE_H__
+#define __CSTATENGINE_H__
+
+/********************************************************************************
+ *
+ * Local Includes
+ *
+ ********************************************************************************/
+#include "stat_interfaces.h"
+#include "statapi_commanddecoder.h"
+#include "filedump.h"
+
+/********************************************************************************
+ *
+ * Definitions
+ *
+ ********************************************************************************/
+//const char	RESYNC_ID		= '?';
+//const char	FAILED_ID		= '*';
+//const TUint	KSyncMax		= 5;
+
+typedef enum { KOpNone, KOpInitialise, KOpConnect, KOpDisconnect, KOpRelease } TStateOp;
+
+/********************************************************************************
+ *
+ * Types
+ *
+ ********************************************************************************/
+class CStatEngine :  public CBase, public MNotifyStatEngine, public MStatEngine
+{
+public:
+	// construction
+	static CStatEngine *NewL( MNotifyStatController *aController, RFs *const aSession, MNotifyLogMessage *const aMsg );
+	CStatEngine();
+	virtual ~CStatEngine();
+
+	// from MNotifyStatEngine
+	void HandleInitialise( TInt aResult );
+	void HandleConnect( TInt aResult );
+	void HandleSend( TInt aResult );
+	void HandleReceive( TInt aResult, const TUint aCommand,
+							MDataConsumer *const aDataConsumer );
+	void HandleDisconnect( TInt aResult );
+	void HandleRelease( TInt aResult );
+	void HandleError( TInt aError, void *aErrorData );
+	void HandleInfo( const TDesC *aInfo );
+
+	// from MStatEngine
+	void StartEngine( MStatApiTransport *aStatTransport, TStatConnectType aConnectType, TDesC *aRemoteHost );
+	void StopEngine( void );
+
+private:
+	// higher level transport interface functions
+	void OnConnect( void );
+	void OnRecvCommand( TUint aCommand, MDataConsumer *const aDataConsumer );
+
+	// internal
+	void ConstructL( MNotifyStatController *aController, RFs *const aSession, MNotifyLogMessage *const aMsg  );
+	void HandleStateChange( TStateOp aOperation, TInt aResult );
+	void HandleSingleStateChange( TStateOp *aOperation, TInt *aResult );
+	void SetState( TCommStatus aNewStatus );
+
+private:
+	TUint iResyncCount;
+	TCommStatus iEngineStatus;
+	TPtrC *iRemoteHost;
+	MStatApiTransport *iTransport;
+	MNotifyStatController *iController;
+	CStatApiCommandDecoder *iCommandDecoder;
+
+	MDataSupplier *iDataSupplier;	// The data supplier is 
+									// use to pass data from the
+									// command decoder to the
+									// transport layers.
+									// Each specific object is
+									// valid for the context of a 
+									// single command (and 
+									// destroyed).
+
+	MNotifyLogMessage *iMsg;
+	RFs	*iFs;
+	TBool iDeleteLastFile;  
+};
+
+#endif //__CSTATENGINE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/stat_interfaces.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,353 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+/********************************************************************************
+ *
+ * Stat interfaces
+ *
+ ********************************************************************************/
+#ifndef __MSTATAPITRANSPORT_H__
+#define __MSTATAPITRANSPORT_H__
+
+/********************************************************************************
+ *
+ * System Includes
+ *
+ ********************************************************************************/
+#include <e32std.h>
+#include <f32file.h>
+
+/********************************************************************************
+ *
+ * Types
+ *
+ ********************************************************************************/
+enum TTransportResult {
+	KSTErrSuccess,
+	KSTErrAsynchronous,
+	KSTErrGeneralFailure,
+	KSTErrReadFailure,
+	KSTErrWriteFailure,
+	KSTErrConnectFailure,
+	KSTErrUnexpectedFragmentCommand,
+	KSTErrResyncCommand
+};
+
+enum TCommStatus { 
+	EIdle,
+	EInitialising, 
+	EInitialised, 
+	EConnecting, 
+	EConnected,
+	EDisconnecting, 
+	EDisconnected, 
+	EReleasing, 
+	ESendPending,
+	EReceivePending,
+	ELast
+};
+
+enum TReadWriteStatus {
+		ENoRW,
+		EWritePending,
+		EReadPending
+};
+
+enum TStatConnectType { 
+		ETCPIP, 
+		ESerial, 
+		EInfrared,
+		EBluetooth,
+		EUsb,
+		// ...
+		ENumConnectTypes,
+};
+
+/********************************************************************************
+ *
+ * MNotifyStatTransport - callback interface given to network on transport
+ *
+ ********************************************************************************/
+class MNotifyStatTransport
+{
+public:
+	virtual void HandleInitialise( TInt aResult ) = 0;
+	virtual void HandleConnect( TInt aResult ) = 0;
+	virtual void HandleSend( TInt aResult ) = 0;
+	virtual void HandleReceive( TInt aResult, TDesC8 *aData, TUint aDataLength ) = 0;
+	virtual void HandleDisconnect( TInt aResult ) = 0;
+	virtual void HandleRelease( TInt aResult ) = 0;
+	virtual void HandleError( TInt aError, void *aErrorData ) = 0;
+	virtual void HandleInfo( const TDesC *aInfo ) = 0;
+};
+
+/********************************************************************************
+ *
+ * MDataSupplier - interface to contain a data buffer and means for users
+ *					to access the data through this object.
+ *					Its purpose is to prevent the need for many data buffers
+ *					to be created by each object that needs data (instead
+ *					one instance of this interface will be passed), and also
+ *					it will hide from the user certain implementations such
+ *					as reading data from a file when more data is needed 
+ *					(this prevents the need to read all the data from a 
+ *					file at one time).
+ *					For STAT the purpose of this is to buffer data sent from
+ *					the device to the PC.  The data is buffered when it is
+ *					sent to the PC.
+ *
+ ********************************************************************************/
+class MDataSupplier
+{
+public:
+	// Destroy this object.
+	// After this call the memory is deleted and any pointers to
+	// the object become invalid.
+	virtual void	Delete( void ) = 0;
+
+	// Return the total size of the data available through
+	// this data supplier.
+	// The return value is one of the standard error codes:
+	// 	KErrNone
+	virtual TInt	GetTotalSize( TInt &aTotalSize ) = 0;
+	// Return the size of the data that is remaining in this
+	// data supplier.
+	// The return value is one of the standard error codes:
+	// 	KErrNone
+	virtual TInt	GetRemainingSize( TInt &aRemainingSize ) = 0;
+
+	// Set data in this data supplier object.
+	// The nature of the source data buffer and the
+	// storage used will be implementation specific to 
+	// derived classes.
+	// The return value is one of the standard error codes:
+	// 	KErrNone
+	// 	KErrNoMemory
+	//	KErrNotFound
+	virtual TInt	SetData( const TDesC8 &aSource ) = 0;
+
+	// Retreives data from this data supplier and copies it to
+	// the supplied buffer.
+	// The implementattion will be specific to derived classes
+	// but should ensure that if the user wants all data then it
+	// should be available in one call.
+	// If the length requested was more than the data remaining
+	// the return value will indicate success and the out
+	// parameter aActuallyCopied will hold the number of bytes 
+	// copied.
+	// The return value is one of the standard error codes:
+	// 	KErrNone
+	// 	KErrNoMemory
+	//	KErrNotFound
+	virtual TInt	GetData( HBufC8 &aDestination, TInt aLengthToCopy,
+						TInt &aActuallyCopied ) = 0;
+
+protected:
+	MDataSupplier( void ) {;}
+	virtual ~MDataSupplier( ) {;}
+};
+
+/********************************************************************************
+ *
+ * MDataConsumer - interface to contain a data buffer and means for users
+ *					to access the data through this object.
+ *					Its purpose is to prevent the need for many data buffers
+ *					to be created by each object that needs data (instead
+ *					one instance of this interface will be passed), and also
+ *					it will hide from the user certain implementations such
+ *					as reading data from a file when more data is needed 
+ *					(this prevents the need to read all the data from a 
+ *					file at one time).
+ *					For STAT the purpose of this is to buffer recevied from
+ *					the PC to the device.  The data is buffered when it is
+ *					received on the device.
+ *
+ ********************************************************************************/
+class MDataConsumer
+{
+public:
+	// Destroy this object.
+	// After this call the memory is deleted and any pointers to
+	// the object become invalid.
+	virtual void	Delete( void ) = 0;
+
+	// Return the total size of the data available through
+	// this data supplier.
+	// The return value is one of the standard error codes:
+	// 	KErrNone
+	virtual TInt	GetTotalSize( TInt &aTotalSize ) = 0;
+
+	// Add data in this data consumer object.
+	// The nature of the source data buffer and the
+	// storage used will be implementation specific to 
+	// derived classes.
+	// The return value is one of the standard error codes:
+	// 	KErrNone
+	// 	KErrNoMemory
+	//	KErrNotFound
+	virtual TInt	AddData( const TDesC8 &aSource ) = 0;
+
+	// Retreives data from this data consumer and copies it to
+	// the supplied buffer.
+	// The return value is one of the standard error codes:
+	// 	KErrNone
+	// 	KErrNoMemory
+	//	KErrNotFound
+	virtual TInt	GetData( HBufC8 &aDestination ) = 0;
+
+	// Retreives data from the data consumer as a
+	// descriptor.  The data is not copied.
+	virtual operator const TDesC8&( void ) const = 0;
+
+	// Retreives data from this data consumer and copies it to
+	// the supplied buffer.
+	// The return value is one of the standard error codes:
+	// 	KErrNone
+	// 	KErrNoMemory
+	//	KErrNotFound
+	virtual TInt	SaveData( const TDesC &filePath ) = 0;
+
+protected:
+	MDataConsumer( void ) {;}
+	virtual ~MDataConsumer( ) {;}
+};
+
+/********************************************************************************
+ *
+ * MNotifyLogMessage - callback interface to allow callers to log messages
+ *
+ ********************************************************************************/
+class MNotifyLogMessage
+{
+public:
+	virtual TInt Init(RFs &fsSession, TPtrC16 filename, CConsoleBase* console) = 0;
+	virtual void Msg(TPtrC16 text, ...) = 0;
+	virtual TBool IsInitialised() const = 0;
+	virtual void CloseFile() = 0;
+};
+
+/********************************************************************************
+ *
+ * MNotifyStatEngine - callback interface given to transport on engine
+ *
+ ********************************************************************************/
+class MNotifyStatEngine
+{
+public:
+	virtual void HandleInitialise( TInt aResult ) = 0;
+	virtual void HandleConnect( TInt aResult ) = 0;
+	virtual void HandleSend( TInt aResult ) = 0;
+	virtual void HandleReceive( TInt aResult, const TUint aCommand,
+						MDataConsumer *const aDataConsumer ) = 0;
+	virtual void HandleDisconnect( TInt aResult ) = 0;
+	virtual void HandleRelease( TInt aResult ) = 0;
+	virtual void HandleError( TInt aError, void *aErrorData ) = 0;
+	virtual void HandleInfo( const TDesC *aInfo ) = 0;
+	
+};
+
+/********************************************************************************
+ *
+ * MNotifyStatController - callback interface given to engine on controller
+ *
+ ********************************************************************************/
+class MNotifyStatController
+{
+public:
+	virtual void HandleStatusChange( TCommStatus aNewStatus ) = 0;
+	virtual void HandleError( TInt aError, void *aErrorData ) = 0;
+	virtual void HandleInfo( const TDesC *aInfo ) = 0;
+};
+
+/********************************************************************************
+ *
+ * MNotifyUI - callback interface given to the controller on the UI
+ *
+ ********************************************************************************/
+class MNotifyUI
+{
+public:
+	virtual void HandleStatusChange( TInt aSessionId, TCommStatus aNewStatus ) = 0;
+	virtual void HandleError( TInt aError, void *aErrorData ) = 0;
+	virtual void HandleInfo( const TDesC *aInfo ) = 0;
+};
+
+/********************************************************************************
+ *
+ * MStatApiNetwork - network interface called by transport layer
+ *
+ ********************************************************************************/
+class MStatNetwork
+{
+public:
+	virtual TInt GetPacketSize() = 0;
+	virtual TInt InitialiseL( MNotifyStatTransport *transport ) = 0;
+	virtual TInt ConnectL( TDesC *aRemoteHost ) = 0;
+	virtual TInt RequestSend( TDesC8 *aData, const TUint aLength ) = 0;
+	virtual TInt RequestReceive( TUint aByteCount ) = 0;
+	virtual TInt Disconnect( void ) = 0;
+	virtual TInt Release( void ) = 0;
+	virtual TText8 *Error( void ) = 0;
+	virtual TUint NtoHl( TUint aValue ) const = 0 ;
+	virtual TUint HtoNl( TUint aValue ) const = 0;
+};
+	
+/********************************************************************************
+ *
+ * MStatApiTransport - transport interface called by engine
+ *
+ ********************************************************************************/
+class MStatApiTransport
+{
+public:
+	virtual TInt InitialiseL() = 0;
+	virtual TInt ConnectL( TDesC *aRemoteHost ) = 0;
+	virtual TInt RequestSend( const TUint aCommand, MDataSupplier *const aDataSupplier) = 0;
+	virtual TInt RequestReceive( void ) = 0;
+	virtual TInt Disconnect( void ) = 0;
+	virtual TInt Release( void ) = 0;
+	virtual TText8 *Error( void ) = 0;
+};
+
+/********************************************************************************
+ *
+ * MStatEngine - engine interface called by controller
+ *
+ ********************************************************************************/
+class MStatEngine
+{
+public:
+	virtual void StartEngine( MStatApiTransport *aStatTransport, TStatConnectType iConnectType, TDesC *aRemoteHost) = 0;
+	virtual void StopEngine() = 0;
+};
+
+/********************************************************************************
+ *
+ * MStatController - controller interface to app ui
+ *
+ ********************************************************************************/
+class MStatController
+{
+public:
+	virtual TInt StartSession( TStatConnectType aConnectType, TDesC *aConnectParams, MNotifyUI *aUI, RFs *const aSession, MNotifyLogMessage *const iMsg ) = 0;
+	virtual TInt StopSession( TInt aSessionId ) = 0;
+	virtual TInt SessionStatus( TInt aSessionId ) = 0;
+};
+
+#endif //__MSTATAPITRANSPORT_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/stat_packetisation.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,134 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+/********************************************************************************
+ *
+ * Stat Packetisation Transport
+ *
+ *******************************************************************************/
+#ifndef __STATPACKETISATION_H__
+#define __STATPACKETISATION_H__
+
+/********************************************************************************
+ *
+ * System Includes
+ *
+ *******************************************************************************/
+
+/********************************************************************************
+ *
+ * Local Includes
+ *
+ *******************************************************************************/
+#include "stat_interfaces.h"
+
+/********************************************************************************
+ *
+ * Definitions
+ *
+ *******************************************************************************/
+#define KIDSize				4
+#define KLengthSize			4
+#define KHeaderSize			(KIDSize + KLengthSize)
+
+/********************************************************************************
+ *
+ * Classes
+ *
+ *******************************************************************************/
+class CStatTransportPacketisation : public CBase, public MStatApiTransport, public MNotifyStatTransport
+{
+public:
+	// construction
+	static CStatTransportPacketisation *NewL( MNotifyStatEngine *aStatEngine, MStatNetwork *aStatNetwork, TUint aPacketSize );
+	CStatTransportPacketisation();
+	virtual ~CStatTransportPacketisation();
+
+	// from MStatApiTransport
+	TInt InitialiseL( void );
+	TInt ConnectL( TDesC *aRemoteHost );
+	TInt RequestSend( const TUint aCommand, MDataSupplier *const aDataSupplier);
+	TInt RequestReceive( void );
+	TInt Disconnect( void );
+	TInt Release( void );
+	TText8 *Error( void );
+
+	// from MNotifyStatTransport
+	void HandleInitialise( TInt aResult );
+	void HandleConnect( TInt aResult );
+	void HandleSend( TInt aResult );
+	void HandleReceive( TInt aResult, TDesC8 *aData, TUint aDataLength );
+	void HandleDisconnect( TInt aResult );
+	void HandleRelease( TInt aResult );
+	void HandleError( TInt aError, void *aErrorData );
+	void HandleInfo( const TDesC *aInfo );
+
+private:
+	// private helper functions
+	void ConstructL( MNotifyStatEngine *aStatEngine, MStatNetwork *aStatNetwork, TUint aPacketSize );
+	void SendHeaderPacket( TUint aCommand, TUint aDataLength );
+	void SendAckPacket( TUint aCommand );
+	void BuildHeader( TUint aCommand, TUint aDataLength );
+	void NotifyEngineSend( TUint aResult );
+	void NotifyEngineReceive( TUint aResult );
+
+private:
+	// status enums
+	enum TSendStatus { ESendIdle, ESendingInitialHeader, ESendingFragmentHeader, ESendingFragmentData, ESendingFragmentAck };
+	enum TReceiveStatus { EReceiveIdle, EReceivingInitialHeader, EReceivingFragmentHeader, EReceivingData, EReceivingFragmentAck };
+
+private:	
+	// general members
+	MNotifyStatEngine *iStatEngine;
+	MStatNetwork *iStatNetwork;
+	TCommStatus iTransportStatus;
+	TSendStatus iSendStatus;
+	TReceiveStatus iRecvStatus;
+	TUint iDataPacketSize;
+
+	// send buffers
+	TBuf8<KHeaderSize> iSendHeader;
+	HBufC8 *iSendFragment;
+	TUint iSendCommand;
+	TUint iSendDataLength;
+	TUint iSendDataWritten;
+	TUint iSendDataAcknowledged;
+
+	// receive buffers
+	TUint iRecvCommand;
+	TUint iRecvDataLength;
+	TUint iRecvDataReceived;
+	TUint iRecvDataAcknowledged;
+
+	MDataConsumer *iDataConsumer;	// The data consumer is 
+									// use to pass data from the
+									// transport layer to the 
+									// command decoder.
+									// Each specific object is
+									// valid for the context of a 
+									// single command (and 
+									// destroyed).
+
+	MDataSupplier *iDataSupplier;	// This is owned by other
+									// objects and we are passed
+									// a pointer for our own use
+									// but we do not maintain this.
+};
+
+#endif // __STATTCPIP_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/stat_serial.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,171 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+/********************************************************************************
+ *
+ * Stat Serial Transport
+ *
+ *******************************************************************************/
+#ifndef __STATSERIAL_H__
+#define __STATSERIAL_H__
+
+/********************************************************************************
+ *
+ * System Includes
+ *
+ *******************************************************************************/
+
+#ifndef LIGHT_MODE
+#include <c32comm.h>
+#else // ifndef LIGHT_MODE
+#include <serialdriverext.h>
+#endif // ifndef LIGHT_MODE
+
+#include <f32file.h>
+
+/********************************************************************************
+ *
+ * Local Includes
+ *
+ *******************************************************************************/
+#include "filedump.h"
+#include "stat_interfaces.h"
+
+/********************************************************************************
+ *
+ * Definitions
+ *
+ *******************************************************************************/
+#define KModuleSize									8
+
+/********************************************************************************
+ *
+ * Class
+ *
+ *******************************************************************************/
+class CStatApiSerial : public CActive, public MStatNetwork
+{
+public:
+	// construction
+	static CStatApiSerial* NewL( TPtrC16 aModule );
+	CStatApiSerial();
+	~CStatApiSerial();
+
+	// from MStatNetwork
+	TInt GetPacketSize();
+	TInt InitialiseL( MNotifyStatTransport *iTransport );
+	TInt ConnectL( TDesC *aRemoteHost );
+	TInt RequestSend( TDesC8 *aCommandData, const TUint aDataLength );
+	TInt RequestReceive( TUint aByteCount );
+	TInt Disconnect( void );
+	TInt Release( void );
+	TText8 *Error( void );
+	TUint NtoHl( TUint aValue ) const;
+	TUint HtoNl( TUint aValue ) const;
+
+	// from CActive
+	void RunL( void );
+	void DoCancel( void );
+
+public:
+	// Enumeration of different serial sub-types.
+	// There is an option of using serial sub-classes but the number of
+	// classes (three plus a base serial) is too great for the 
+	// very small number of special case changes we need.
+	// Leave the serial implementation as one class and continue 
+	// to handle special cases.  This ensure all the code we 
+	// need continues to be in one place.
+	enum TSerialSubtype {
+				EInvalid = 0,
+				ESerialCable,
+				EInfraRed, 
+				ENumberOfSubTypes
+				};
+
+private:
+	void ConstructL( TPtrC16 aModule );
+
+	void SetStatus( TCommStatus aNewStatus );
+	void ExtractOptions( TDesC *aRemoteHost, TDes& aPortNumber, TInt& aBaudCap, TBps& aBaudRate );
+
+	// Finalise the initialisation started by a call to InitialiseL.
+	// Called directly by InitialiseL in a synchronous
+	// initialisation; called from RunL in an asynchronous
+	// initialisation (such as USB).
+	TInt OnInitialiseL(TInt resultCode);
+
+	// Uses our iModule transport description text string to
+	// determine the sub-type.  This will leave if we
+	// are pass an unrecognised string in the constructor.
+	// The leave value will be KErrNotSupported.
+	void DetermineSubTypeL(void);
+
+	// Returns the sub-type that identifies the nature of
+	// our transport special case.
+	TSerialSubtype SubType(void) const;
+
+private:
+	TCommStatus iSerialStatus;
+	TReadWriteStatus iRWStatus;
+	TBuf16<KModuleSize> iModule;
+	MNotifyStatTransport *iTransport;
+	TBuf8<1> iDummyBuffer;
+	TInt iRetries;
+	// Store the packetsize.
+	// This depends upon our specific serial subtype.
+	TInt iMaxPacketSize;
+
+#ifndef LIGHT_MODE
+	RCommServ iCommServer;
+	RComm iCommPort;
+#else // ifndef LIGHT_MODE
+	SerialServer	iCommServer;
+	SerialPort		iCommPort;
+
+	RLibrary serialDriverLib;   // use for loading the serial driver lib
+
+#endif // ifndef LIGHT_MODE
+
+	TCommConfig iPortSettings, iOldPortSettings;
+
+	HBufC8 *iRecvBuffer;
+	TPtr8 *iRecvBufferPtr;
+	TInt iRecvLength, iCommOldSettingsValid;
+
+	// This is the sub-type that identifies the nature of
+	// our transport special case.
+	TSerialSubtype iSubType;
+};
+
+inline TUint CStatApiSerial::NtoHl( TUint aValue ) const
+{
+	return ( aValue );
+}
+
+inline TUint CStatApiSerial::HtoNl( TUint aValue ) const
+{
+	return ( aValue );
+}
+
+inline CStatApiSerial::TSerialSubtype CStatApiSerial::SubType(void) const
+{
+	return (iSubType);	
+}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/stat_tcpip.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,122 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+/********************************************************************************
+ *
+ * Stat TCP/IP Transport
+ *
+ *******************************************************************************/
+#ifndef __STATTCPIP_H__
+#define __STATTCPIP_H__
+
+/********************************************************************************
+ *
+ * System Includes
+ *
+ *******************************************************************************/
+#include <es_sock.h>
+
+/********************************************************************************
+ *
+ * Local Includes
+ *
+ *******************************************************************************/
+#include "stat_interfaces.h"
+#include "ntoh.h"
+
+/********************************************************************************
+ *
+ * Definitions
+ *
+ *******************************************************************************/
+const TUint KStatHeaderSize	= 8;
+const TUint KLittleStatPort = 3000;
+const TUint KLittleStatListenQueue = 1;
+
+/********************************************************************************
+ *
+ * CStatTransportTCPIP - Top-level of the transport. Creates and waits on the 
+ * listening socket. When a new data socket is created it creates the reader
+ * and writer passing the socket to them. After that, the object simply routes
+ * read/write calls/cancels to the appopriate objects.
+ *
+ *******************************************************************************/
+class CStatTransportTCPIP : public CActive, public MStatNetwork
+{
+public:
+	// construction
+	static CStatTransportTCPIP *NewL( void );
+	CStatTransportTCPIP();
+	~CStatTransportTCPIP();
+
+	// from MStatNetwork
+	TInt GetPacketSize();
+	TInt InitialiseL( MNotifyStatTransport *iTransport );
+	TInt ConnectL( TDesC *aRemoteHost );
+	TInt RequestSend( TDesC8 *aCommandData, const TUint aDataLength );
+	TInt RequestReceive( TUint aByteCount );
+	TInt Disconnect( void );
+	TInt Release( void );
+	TText8 *Error( void );
+	TUint NtoHl( TUint aValue ) const;
+	TUint HtoNl( TUint aValue ) const;
+	TBool PadPacket( TUint size ) const;
+
+	// from CActive 
+	void RunL( void );
+	void DoCancel( void );
+
+private:
+	void ConstructL( void );
+
+private:
+	enum TStatTransportStatus { EIdle, EError, EInitialised, EConnecting, EConnected, 
+			EDisconnectingData, EDisconnectingListen, EDisconnected };
+
+private:
+	TStatTransportStatus iTransportStatus;
+	TReadWriteStatus iRWStatus;
+	MNotifyStatTransport *iTransport;
+	TInt iMaxPacketSize;
+
+	HBufC8 *iBuffer;
+	TPtr8 *iBufferPtr;
+
+ 	RSocket iListenSocket;
+ 	RSocket iDataSocket;
+ 	RSocketServ iSocketServ;
+	
+};
+
+inline TUint CStatTransportTCPIP::NtoHl( TUint aValue ) const
+{
+	return ( ntohl( aValue ) );
+}
+
+inline TUint CStatTransportTCPIP::HtoNl( TUint aValue ) const
+{
+	return ( htonl( aValue ) );
+}
+
+inline TBool CStatTransportTCPIP::PadPacket( TUint ) const
+{
+	return ( EFalse );
+}
+
+#endif // __STATTCPIP_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/stat_usb.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,121 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+/********************************************************************************
+ *
+ * Stat USB Transport
+ *
+ *******************************************************************************/
+#ifndef __STATUSB_H__
+#define __STATUSB_H__
+
+/********************************************************************************
+ *
+ * System Includes
+ *
+ *******************************************************************************/
+#include <d32usbc.h>
+
+/********************************************************************************
+ *
+ * Local Includes
+ *
+ *******************************************************************************/
+#include "filedump.h"
+#include "../../../../common/inc/serialpacketsize.h"
+
+/********************************************************************************
+ *
+ * Class
+ *
+ *******************************************************************************/
+class CStatApiUsb : public CActive, public MStatNetwork
+{
+public:
+	// construction
+	static CStatApiUsb* NewL( void );
+	CStatApiUsb();
+	~CStatApiUsb();
+
+	// from MStatNetwork
+	TInt GetPacketSize();
+	TInt InitialiseL( MNotifyStatTransport *iTransport );
+	TInt ConnectL( TDesC *aRemoteHost );
+	TInt RequestSend( TDesC8 *aCommandData, const TUint aDataLength );
+	TInt RequestReceive( TUint aByteCount );
+	TInt Disconnect( void );
+	TInt Release( void );
+	TText8 *Error( void );
+	TUint NtoHl( TUint aValue ) const;
+	TUint HtoNl( TUint aValue ) const;
+	void Reset( void );
+	
+	// from CActive
+	void RunL( void );
+	void DoCancel( void );
+
+private:
+	void ConstructL(void);
+
+	void SetStatus( TCommStatus aNewStatus );
+
+	// Finalise the initialisation started by a call to InitialiseL.
+	// Called directly by InitialiseL in a synchronous
+	// initialisation; called from RunL in an asynchronous
+	// initialisation (such as USB).
+	TInt OnInitialiseL(TInt resultCode);
+
+private:
+	TBool iReEnum;
+	TCommStatus iUsbStatus;
+	TReadWriteStatus iRWStatus;
+	MNotifyStatTransport *iTransport;
+	
+	// Store the packetsize.
+	TInt iMaxPacketSize;
+	
+	//USB interface
+	TUsbcInterfaceInfoBuf ifc;
+	
+	//USB channel
+	RDevUsbcClient iPort;
+
+	//Timer to wait for device reenumeration
+	RTimer iTimer;
+	
+	typedef enum { EEnum, EWait, EConnect } TConnectingState;
+
+	TConnectingState iConnectingState;
+	
+	HBufC8 *iBuffer;
+	TInt iLength;
+
+};
+
+
+inline TUint CStatApiUsb::NtoHl( TUint aValue ) const
+{
+	return ( aValue );
+}
+
+inline TUint CStatApiUsb::HtoNl( TUint aValue ) const
+{
+	return ( aValue );
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/stat_window.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,205 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+/*************************************************************************
+ *
+ * Switches
+ *
+ ************************************************************************/
+#ifndef __STATUI_H__
+#define __STATUI_H__
+
+/*************************************************************************
+ *
+ * System Includes
+ *
+ ************************************************************************/
+#include <eikenv.h>
+#include <eikappui.h>
+#include <eikproc.h>
+#include <eikdialg.h>
+#include <eikmenub.h>
+#include <eikapp.h>
+#include <eikdoc.h>
+#include <eikedwin.h>
+#include <coeutils.h>
+#include <barsread.h>
+#include <eikfctry.h>
+#include <eiklabel.h>
+
+/*************************************************************************
+ *
+ * Local Includes
+ *
+ ************************************************************************/
+#include "stat_interfaces.h"
+#include "activeconnection.h"
+
+/*************************************************************************
+ *
+ * Definitions
+ *
+ ************************************************************************/
+
+// Control ID Constants
+#define KStatusLabel			0
+#define KErrorLabel				1
+#define KVersionLabel			2
+#define KTransportLabel			3
+#define KAddressLabel			4
+#define KTransportEdit			5
+#define KAddressEdit			6
+#define KActionButton			7
+#define KExitButton				8
+#define KInfoLabel				9
+#define KLogButton				10
+#define KControlCount			11
+
+#define		KMaxChoiceItemSize			16
+#define		KMaxChoiceItems				8
+
+/*************************************************************************
+ *
+ * CStatChoice - Multi-choice box. This control is based on a read-only 
+ * CEikEdwin. It is initialised with a set of strings. Users can cycle
+ * through the option either by tapping on the control or using the 
+ * left-right keys.
+ *
+ ************************************************************************/
+class CStatChoice : public CEikEdwin
+{
+public:
+	// Clean up
+	~CStatChoice();
+
+	// User interface to get and set items
+	TInt AddItemL( TDesC &aItemStr );
+	TDesC *CurrentItemStr();
+	void SetCurrentItem( TInt aIndex );
+	TInt CurrentItem();
+	void ClearAllItems();
+
+	// Handle User Input
+	TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
+	void HandlePointerEventL(const TPointerEvent& aPointerEvent);
+	void SetNextItem();
+	void SetPrevItem();
+
+private:
+	// Attributes
+	TInt iItemCount, iCurrentItem;
+	TBuf<KMaxChoiceItemSize> *iChoiceItems[KMaxChoiceItems];
+};
+
+/*************************************************************************
+ *
+ * CStatWindow - STAT GUI. Single window.
+ *
+ ************************************************************************/
+class CStatWindow : public CCoeControl, public MCoeControlObserver, public MNotifyUI
+{
+public:
+	// Constructors
+	CStatWindow *NewL( const TRect& rect, MStatController *aStatController );
+	CStatWindow();
+	~CStatWindow();
+	void ConstructL( const TRect& rect, MStatController *aStatController );
+
+	// Public Interface
+	void SetForeground( TBool aIsForeground );
+	TCommStatus GetCommStatus();
+
+	// Handle User Input
+	TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
+	void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType );
+	void HandlePointerEventL(const TPointerEvent& aPointerEvent);
+
+	// From MNotifyUI
+	void HandleStatusChange( TInt aSessionId, TCommStatus aNewStatus );
+	void HandleError( TInt aError, void *);//aErrorData);
+	void HandleInfo( const TDesC *aInfo );
+
+protected:
+	/*********************************************************************
+	 *
+	 * CStatIniData - Data structure used to write to and read from a user
+	 * preference file that stores interface options between sessions.
+	 *
+	 *********************************************************************/
+	class CStatIniData : public CBase
+	{
+	public:
+		CStatIniData(void);
+		~CStatIniData();
+
+	public:
+		TBool WriteIniData(const TDesC& aName) const;
+		TBool ReadIniData(const TDesC& aName);
+
+	public:
+		TStatConnectType iConnectType;
+		TInt iAddress;
+		TBool iIsRunning;
+		TBool iConnectAutomatically;
+
+	private:
+		HBufC* GetFileContents(const TDesC& aName) const;
+	};
+
+private:
+	// From CCoeControl
+	TInt CountComponentControls() const;
+	CCoeControl* ComponentControl( TInt aIndex ) const;
+	void Draw(const TRect& aRect) const;
+
+	// Helper Functions
+	TRect GetControlPosition( TInt aIndex ) const;
+	TInt PositionInRange( TPoint aPosition, TRect aArea ) const;
+	TInt GetControlFromPoint( TPoint aPosition ) const;
+	void OnTransportChange();
+	void HandleActionL( void );
+	void ClearControlPanel() const;
+	void DrawEditBorders() const; 
+	void	SetVersionLabelL();
+private:
+	// Controls
+	CEikCommandButton *iActionButton, *iExitButton, *iLogButton;
+	CEikLabel *iStatusLabel, *iErrorLabel, *iInfoLabel, *iVersionLabel;
+	CEikLabel *iTransportLabel, *iAddressLabel;
+	CStatChoice *iTransportEdit, *iAddressEdit;
+
+	// Attributes
+	TInt iLoggingEnabled;
+	TBool bIsForeground;
+	TCommStatus iStatStatus;
+	MStatController *iStatController;
+	mutable TInt iClearLabelsOnly;	// Ensure this is mutable and so can
+									// be updated from within the 'const'
+									// declared 'Draw' mehod.
+
+	CActiveConnection *iAOConnection;	// Active object whose
+										// only task is to open
+										// a TCP socket to initialise
+										// the socket server.
+
+	// Ini data that we retain for the lifetime of the window.
+	CStatIniData *iIniData;
+};
+
+#endif //__STATUI_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/statapi.hrh	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+enum {
+	EStatCmdAction = 0x1000,
+	EStatCmdToggleLogging,
+#ifndef SYMBIAN_DIST_SERIES60
+	EAknSoftkeyExit,
+#endif
+	EStatCmdLast
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/statapi_commanddecoder.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,106 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#if !defined(__STATAPI_COMMANDDECODER_H__)
+#define __STATAPI_COMMANDDECODER_H__
+
+#include "filedump.h"
+
+#ifndef LIGHT_MODE
+	#include <apgcli.h>
+	#include <eikappui.h>
+#endif
+
+class CStatApiCommandDecoder : public CBase
+{
+	public:
+		CStatApiCommandDecoder();
+		virtual ~CStatApiCommandDecoder();
+		static CStatApiCommandDecoder* NewL(RFs *const aSession, MNotifyLogMessage *const aMsg);
+		virtual TInt ExecuteCommand(TUint commandtype, MDataConsumer *const aDataConsumer, 
+						MDataSupplier **aDataSupplier);
+		virtual void ConstructL(RFs *const aSession, MNotifyLogMessage *const aMsg);
+		TInt DeleteLastFile();
+		void Reset() { iName = 1; }
+		
+
+	private:
+		TInt ConvertKeycodeToScancode( TDesC& key, TInt& scancode, TInt& modifiers );
+		TInt OpenIcon();
+		TInt SendText(MDataConsumer *const aDataConsumer, int commandLength);
+		TInt SendCombinationKeys();
+		TInt SendSystemKeys();
+		TInt SendKeyHold();
+		TInt StartApplicationL();
+		TInt StartProgramL(MDataSupplier **aDataSupplier);
+		void StopApplicationL();
+        void StopEShellL();
+		TInt ReadTEFSharedDataL(MDataSupplier **aDataSupplier);
+		TInt WriteTEFSharedDataL(MDataConsumer *const aDataConsumer, int commandLength);
+		TInt OpenFileL();
+		TInt DeleteFileL(TInt bDisplayMessage = TRUE);
+		TInt CreateFolder();
+		TInt RemoveFolder();
+		TInt CheckLocation(MDataConsumer *const aDataConsumer);
+		void ScreenCaptureL();
+		TInt TransferFile(MDataConsumer *const aDataConsumer);
+		TInt ReceiveFile(TUint commandtype, MDataConsumer *const aDataConsumer, MDataSupplier **aDataSupplier);
+		TInt RenameFileL(MDataConsumer *const aDataConsumer);
+		TInt DeviceInfo(MDataSupplier **aDataSupplier);
+		void StartEShellL();
+		TInt SaveLogFile(MDataSupplier **aDataSupplier);
+		TInt GetDiskDriveInformationL(MDataSupplier **aDataSupplier);
+		TInt GetDirectoryInformationL(MDataConsumer *const aDataConsumer, MDataSupplier **aDataSupplier);
+		TInt GetData(TInt i, TDes8& info);
+		void DoKeyEvent(TInt key);
+		void AppendErrorCode(TInt ret, MDataSupplier **aDataSupplier);
+		bool IsWindowServerAvailable(void) const;
+		TInt StopProgramL(const TDesC& aHandleNumber);
+		TInt ProgramStatusL(const TDesC& aHandleNumber, MDataSupplier **aDataSupplier);
+		void RefreshStatus(void);
+		void updatePathWithSysDrive(TBuf<1024>& pathToChange ) ; 
+		void updatePathWithSysDrive(TBuf<KMaxPath>& pathToChange ) ; 
+		TDriveName getSystemDrive();
+		
+#ifndef LIGHT_MODE
+		RWsSession iWs;			//session object used for keypress
+		RApaLsSession iApaS;	//session object for app name processing
+		CWsScreenDevice* iDevice;	// Data retained by the object
+	        CWsBitmap* screenBitmap;	// in order to optimise bitmap screen
+#endif // ifndef LIGHT_MODE
+		TInt iName;				// flag to see whether data is file name or contents
+		TBuf<256> filename;		// holds the name of the transferred file
+		TBuf<1024> command;		// holds our command data while we work with it - should not be used for raw data
+		RFs* iFs;				//file server session
+		MNotifyLogMessage *pMsg;			// logging
+
+        TInt iUIDValue;				// capture.
+        TBuf<3> iSystemDrive;
+};
+
+inline bool CStatApiCommandDecoder::IsWindowServerAvailable(void) const
+{
+#ifndef LIGHT_MODE
+	return (0 != iWs.WsHandle( ));
+#else // ifndef LIGHT_MODE
+	return (EFalse);
+#endif // ifndef LIGHT_MODE
+}
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/statapi_deviceinformation.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,151 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+#if !defined(__STATAPI_DEVICEINFORMATION_H__)
+#define __STATAPI_DEVICEINFORMATION_H__
+
+#include <hal_data.h>
+
+//------------------------------------------------------------------------------
+
+#define NO_MORE_DEVICE_INFORMATION			_S8("NO MORE DEVICE INFORMATION")	// end of array
+
+const TText8* const ENUM_DEVICEINFORMATIONArray[5][20] = 
+{
+	{
+		//UID Info
+		_S8("5mx"),
+		_S8("Brutus"),
+		_S8("Cogent"),
+		_S8("Win32 Emulator"),
+		_S8("WinC"),
+		_S8("CL7211 Evaluation"),
+		_S8("LinkUp"),
+		_S8("Assabet"),
+		_S8("IQ80310"),
+		_S8("Integrator"),
+		_S8("Helen"),
+		NO_MORE_DEVICE_INFORMATION
+	},
+	{
+		//CPU Type
+		_S8("ARM"),
+		_S8("MCORE"),
+		_S8("X86"),
+		NO_MORE_DEVICE_INFORMATION
+	},
+	{
+		//CPU ABI
+		_S8("ARM4"),
+		_S8("ARMI"),
+		_S8("THUMB"),
+		_S8("MCORE"),
+		_S8("MSVC"),
+		_S8("ARM5T"),
+		NO_MORE_DEVICE_INFORMATION
+	},
+	{
+		//DEVICE FAMILY
+		_S8("Crystal"),
+		_S8("Pearl"),
+		_S8("Quartz"),
+		NO_MORE_DEVICE_INFORMATION
+	},
+	{
+		//Manufacturer
+		_S8("Ericsson"),
+		_S8("Motorola"),
+		_S8("Nokia"),
+		_S8("Panasonic"),
+		_S8("Psion"),
+		_S8("Intel"),
+		_S8("Cogent"),
+		_S8("Cirrus"),
+		_S8("Linkup"),
+		_S8("Texas Instruments"),
+		NO_MORE_DEVICE_INFORMATION
+	}
+};
+
+//------------------------------------------------------------------------------
+
+const TUint ENUM_VALDEVICEINFORMATIONArray[5][20] =
+{
+	{
+		//UID Info
+		HALData::EMachineUid_Series5mx,
+		HALData::EMachineUid_Brutus,
+		HALData::EMachineUid_Cogent,
+		HALData::EMachineUid_Win32Emulator,
+		HALData::EMachineUid_WinC,
+		HALData::EMachineUid_CL7211_Eval,
+		HALData::EMachineUid_LinkUp,
+#ifndef SYMBIAN_DIST_SERIES60
+		HALData::EMachineUid_Assabet,
+		HALData::EMachineUid_IQ80310,
+		HALData::EMachineUid_Integrator,
+		HALData::EMachineUid_Helen,
+#endif
+		NULL
+	},
+	{
+		//CPU Type
+		HALData::ECPU_ARM,
+		HALData::ECPU_MCORE,
+		HALData::ECPU_X86,
+		NULL
+	},
+	{
+		//CPU ABI
+		HALData::ECPUABI_ARM4,
+		HALData::ECPUABI_ARMI,
+		HALData::ECPUABI_THUMB,
+		HALData::ECPUABI_MCORE,
+		HALData::ECPUABI_MSVC,
+#ifndef SYMBIAN_DIST_SERIES60
+		HALData::ECPUABI_ARM5T,
+#endif
+		NULL
+	},
+	{
+		//DEVICE FAMILY
+		HALData::EDeviceFamily_Crystal,
+		HALData::EDeviceFamily_Pearl,
+		HALData::EDeviceFamily_Quartz,
+		NULL
+	},
+	{
+		//Manufacturer
+		HALData::EManufacturer_Ericsson,
+		HALData::EManufacturer_Motorola,
+		HALData::EManufacturer_Nokia,
+		HALData::EManufacturer_Panasonic,
+		HALData::EManufacturer_Psion,
+		HALData::EManufacturer_Intel,
+		HALData::EManufacturer_Cogent,
+		HALData::EManufacturer_Cirrus,
+		HALData::EManufacturer_Linkup,
+#ifndef SYMBIAN_DIST_SERIES60
+		HALData::EManufacturer_TexasInstruments,
+#endif
+		NULL
+	}
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/inc/testsecurityinstuihandler.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,341 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include <msisuihandlers.h>
+
+/*@{*/
+///Macros
+#define KUserNameMaxLength	64
+#define KPassword			64
+/*@}*/
+
+enum KMyErrCode
+	{
+	KErrNothing,
+	KErrLanguage,        
+	KErrDrive,
+	KErrOptions,        
+	KErrAbortInstall,
+	KErrAbortUnInstall,        
+	KErrLeave,
+	KErrCannotOverwriteFile,
+	KErrError        
+	};
+	
+/**
+This represents the User Interface handler for the install engine
+The higher code should provide one of these interfaces for the engine
+to use for a UI.
+
+@publishedPartner
+@released
+*/
+using namespace Swi;
+
+class CTestSecurityInstUIHandler : public CBase, public Swi::MUiHandler
+// This represents the User Interface handler for the install engine
+// The higher code should provide one of these interfaces for the engine
+// to use for a UI
+	{
+	public:
+		static CTestSecurityInstUIHandler* NewL();
+		
+		~CTestSecurityInstUIHandler();
+
+		/**
+		 * Displays a dialog at the beginning of an installation with details about the SISX package
+	 	 * being installed. This dialog must be shown in TrustedUI mode.
+	 	 *
+	 	 * @param aAppInfo	Information about the application.
+	 	 * @param aLogo		The logo data in the SISX file. If no logo is present it will be NULL.
+		 * @param aCertificates An array of end entity certificates, one for each chain in the SISX file.
+		 *				If the SISX file is unsigned this array will have zero length.
+		 *
+		 * @note 		Trusted UI
+	   	 *
+		 * @return		ETrue if the user pressed the Yes button to continue the install,
+		 *				EFalse if the user pressed the No button, aborting the installation.
+		 */
+		TBool  DisplayInstallL (const CAppInfo& aAppInfo, 
+			const CApaMaskedBitmap* aLogo, 
+			const RPointerArray <CCertificateInfo> & aCertificates);
+		/**
+		 * Displays a dialog requesting that the user grants these capabilities to the SISX package 
+		 * being installed. This dialog must be shown in TrustedUI mode.
+		 *
+		 * @param aAppInfo	 Information about the application.
+		 * @param aCapabilitySet The capabilities requested by the SISX package.
+		 *
+		 * @note Trusted UI
+		 *
+		 * @return		ETrue to continue the installation, or EFalse to abort the installation.
+		 */
+		TBool DisplayGrantCapabilitiesL(const CAppInfo& aAppInfo, 
+						const TCapabilitySet& aCapabilitySet);
+										
+		/**
+		 * Requests preferred language and dialect information from the UI.
+		 *
+		 * @param aAppInfo	Information about the application.
+		 * @param aLanguages	Array of languages supported by the SIS file. 
+		 *
+		 * @return		Must return index in the passed array that corresponds to the user's selected 
+		 *			preferred language. If out-of-bounds value is returned, the engine will abort 
+		 *			installation.
+		 */
+		TInt DisplayLanguageL(const CAppInfo& aAppInfo, 
+				      const RArray<TLanguage>& aLanguages);
+	
+		/**
+		 * Requests the drive to install the package on, from the UI.
+		 *
+		 * @param aAppInfo	Information about the application.
+		 * @param aSize		Total size of the files that will be installed on the configurable drive.
+		 * @param aDriveLetters	Array of drive letters on which the package can be installed.
+		 * @param aDriveSpaces	Array of space free (in bytes) on each of the drives in the aDriveLetters array. 
+		 *
+		 * @return		An index in the drive array. If the index is out of range the engine will abort
+		 *                      the installation.
+		 */
+		TInt DisplayDriveL(const CAppInfo& aAppInfo, 
+				   TInt64 aSize,
+				   const RArray<TChar>& aDriveLetters,
+				   const RArray<TInt64>& aDriveSpaces);
+	
+		/**
+		 * Displays a dialog asking whether we want to upgrade an application present on the device.
+		 *
+		 * @param aAppInfo	        Information about the application being installed.
+		 * @param aExistingAppInfo	Information about the existing application.
+		 *
+		 * @return		ETrue if the user pressed the Yes button,
+		 *			EFalse if the user pressed the No button.
+		 */
+		TBool DisplayUpgradeL(const CAppInfo& aAppInfo, 
+				      const CAppInfo& aExistingAppInfo);
+	
+		/**
+		 * Displays a dialog box asking which options the user wishes to install.
+		 *
+		 * @param aAppInfo	Information about the application.
+		 * @param aOptions	An array of option names.
+		 * @param aSelections	An array of booleans, corresponding to the aOptions array.
+		 *
+		 * @return		ETrue on success, EFalse on error.
+		 */
+		TBool DisplayOptionsL(const CAppInfo& aAppInfo,
+				      const RPointerArray<TDesC>& aOptions,
+				      RArray<TBool>& aSelections);
+	
+		/**
+		 * Informs the UI of events occurring during installation.  
+		 *
+		 * @param aEvent	The event which has occurred.
+		 * @param aValue	The value associated with the event if applicable.
+		 * @param aDes          A descriptor associated with the event if applicable.
+		 */
+		TBool HandleInstallEventL(const CAppInfo& aAppInfo,
+						TInstallEvent aEvent, 
+						TInt aValue=0, 
+						const TDesC& aDes=KNullDesC);
+		/**
+		 * Informs the UI of cancellable events occurring during installation.  
+		 *
+		 * @param aEvent	 The event which has occurred.
+		 * @param aCancelHandler This mix-in is used to inform Software Install that the user has
+		 *			 pressed the cancel button on the dialog.
+		 * @param aValue	 The value associated with the event if applicable.
+		 * @param aDes           A descriptor associated with the event if applicable.
+		 */
+		void HandleCancellableInstallEventL(const CAppInfo& aAppInfo,
+						TInstallCancellableEvent aEvent, 
+						MCancelHandler& aCancelHandler,
+						TInt aValue=0, 
+						const TDesC& aDes=KNullDesC);
+		/**
+		 * Displays a dialog indicating that the package is unsigned, or that signature validation has failed.
+		 *
+		 * @param aAppInfo              Information about the application.
+		 * @param aSigValidationResult	The result of signature validation.
+		 * @param aPkixResult           Results of a validation of the PKIX  certificate chain.
+		 *                              Note that is can be NULL, in this case no validation results are available.
+		 * @param aCertificates         An array containing information about the certificates in the chain.
+		 * @param aInstallAnyway		ETrue if installation is allowed to continue.
+		 *
+		 * @return						ETrue to continue the installation, EFalse to abort.
+		 */
+		TBool DisplaySecurityWarningL(const CAppInfo& aAppInfo,
+						Swi::TSignatureValidationResult aSigValidationResult,
+						RPointerArray<CPKIXValidationResultBase>& aPkixResults,
+						RPointerArray<CCertificateInfo>& aCertificates,
+						TBool aInstallAnyway);
+	
+		/**
+		 * Displays a dialog indicating that there was an error carrying out online certificate status checking.
+		 *
+		 * @param aMessage	The error which occurred during online certificate status checking
+		 * @param aOutcome	The outcome of the OCSP check. If no outcome can be given, it will be NULL.
+		 * @param aWarningOnly	ETrue if the installation is allowed to continue after a warning, EFalse otherwise.
+		 *
+		 * @return		ETrue on success, EFalse on error.
+		 */
+		TBool DisplayOcspResultL(const CAppInfo& aAppInfo,
+						TRevocationDialogMessage aMessage, 
+						RPointerArray<TOCSPOutcome>& aOutcomes, 
+						RPointerArray<CCertificateInfo>& aCertificates,
+						TBool aWarningOnly);
+	
+		/**
+		 * Used to inform the user the installation they are attempting is trying to overwrite
+		 * a file that does not belong to it. Following this message installation is aborted.
+		 *
+		 * @param aAppInfo	        Information about the application.
+		 * @param aInstalledAppInfo	Information about the application that owns the file in question.
+		 * @param aFileName		The filename of the file in question
+		 */
+		void DisplayCannotOverwriteFileL(const CAppInfo& aAppInfo,
+						 const CAppInfo& aInstalledAppInfo,
+						 const TDesC& aFileName);
+						 
+		/**
+		 * Displays a dialog at the start of the uninstallation with information about the application
+		 * to be uninstalled. The user may cancel the uninstallation at this stage. This dialog must 
+		 * be shown in TrustedUI mode.
+		 *	
+		 * @param aAppInfo	Information about the application.
+		 *
+		 * @note Trusted UI
+		 *
+		 * @return			ETrue to continue the uninstallation, or EFalse to abort the uninstallation.
+		 */
+		TBool DisplayUninstallL(const CAppInfo& aAppInfo);
+
+
+		/**
+		 * Displays a dialog containing text. This dialog has only a Continue button if aOption is 
+		 * EInstFileTextOptionContinue, or Yes and No buttons otherwise.
+		 *
+		 * @param aAppInfo	Information about the application.
+		 * @param aOption	The type of dialog box to display.
+		 * @param aText		The text to display
+		 *
+		 * @return		ETrue is the user wants to go forward, EFalse otherwise.
+		 */
+		 TBool DisplayTextL(const CAppInfo& aAppInfo, 
+				    TFileTextOption aOption,
+				    const TDesC& aText);
+	 
+		/**
+		 * Displays a dialog showing an error message. 
+		 *
+		 * @param aAppInfo	    Information about the application.
+		 * @param aType		    The error message to display.
+		 * @param aParam	    An error specific parameter.
+		 */
+		void DisplayErrorL(const CAppInfo& aAppInfo,
+				   TErrorDialog aType, 
+				   const TDesC& aParam);
+
+		/**
+		 * Displays a dialog indicating that a component which is being uninstalled is a dependency
+		 * of another component installed.
+		 *
+		 * @param aAppInfo	Information about the application.
+		 * @param aComponents	An array of components which depend on components of the application
+		 *
+		 * @return		ETrue to continue the uninstallation, EFalse to abort.
+		 */
+		TBool DisplayDependencyBreakL(const CAppInfo& aAppInfo,
+					      const RPointerArray<TDesC>& aComponents);
+		
+		/**
+		 * Informs user that the applications are in use during an uninstallation.
+		 * Return ETrue if the user wishes to continue the removal process and 
+		 * close the applications anyway
+		 *
+		 * @param aAppNames		An array containing the name of the application in use.
+		 *
+		 * @return			ETrue if the user wishes to continue with removal.
+		 */
+		TBool DisplayApplicationsInUseL(const CAppInfo& aAppInfo, const RPointerArray<TDesC>& aAppNames);
+	
+		/**
+		 * Displays a generic question dialog with a Yes/No answer.
+		 *
+		 * @param aAppInfo	Information about the application.
+		 * @param aQuestion The question to ask.
+		 * @param aDes		A descriptor associated with the question if applicable. 
+		 *
+		 * @return			ETrue if the user pressed the Yes button,
+		 *				EFalse if the user pressed the No button.
+		 */
+		TBool DisplayQuestionL(const CAppInfo& aAppInfo, TQuestionDialog aQuestion, const TDesC& aDes=KNullDesC);
+	
+		/**
+	 	* Used to inform the user of a missing dependency needed to install the 
+	 	* current package. It is up to the UI implementors and/or the user whether
+	 	* or not this warning can be overridden.
+	 	*
+	 	* @param aAppInfo           Info about the current application.
+	 	* @param aDependencyName    Name of the missing dependency.
+	 	* @param aWantedVersionFrom Starting suitable version number of the mising
+	 	*                           dependency. Can be all zeros, meaning it is 
+	 	*                           unknown.
+		 * @param aWantedVersionFrom Ending suitable version number of the mising
+	 	*                           dependency. Can be all zeros, meaning it is 
+	 	*                           unknown.
+	 	* @param aInstalledVersion  The installed (unsuitable) version of the 
+	 	*                           missing dependency. Can be all zeros, meaning 
+	 	*                           the missing dependency is not installed.
+	 	*
+	 	* @return \e ETrue to continue installation, \e EFalse to abort.
+	 	*/
+		TBool DisplayMissingDependencyL(
+		const CAppInfo& aAppInfo,
+		const TDesC& aDependencyName,
+		TVersion aWantedVersionFrom,
+		TVersion aWantedVersionTo,
+		TVersion aInstalledVersion);
+	
+
+
+
+		TBool 	iDispInstall;
+		TBool	iDispGrantCapabilities;
+		TBool	iDispUnInstall;
+		TInt	iDispLanguage;
+		TInt	iDispDialect;
+		TChar	iDispDrive;
+		TBool	iDispUpgrade;
+		TBool	iDispDependencyBreak;
+		TBool	iDispQuestion;
+		TBool	iDispSecurityWarning;
+		TBool	iDispRevocationQuery;
+		TBool	iDispApplicationInUse;
+		TBool	iDispTextDialog;
+		TInt	iDispOptions;
+		TInt	iAppUID;
+		
+		KMyErrCode 	iErrCode;
+		
+	private:
+		CTestSecurityInstUIHandler();
+		void ConstructL();
+	};
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/lib/bld.inf	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,22 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description: 
+//
+
+// Specify we are building everything at this level as
+// we build dependencies in other files also.
+#define _STATLIB_BLD_INF_
+
+PRJ_MMPFILES
+.\statlib.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/lib/statlib.mmp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Build file STAT statically linked library
+*
+*/
+
+
+
+TARGETTYPE              lib
+
+TARGET        		stat.lib
+
+VENDORID 0x70000001
+UID		0x1000007A 0x10210D31
+
+USERINCLUDE			..\.\inc
+APP_LAYER_SYSTEMINCLUDE_SYMBIAN 		\epoc32\include
+APP_LAYER_SYSTEMINCLUDE_SYMBIAN 		\epoc32\include\test
+
+APP_LAYER_SYSTEMINCLUDE_SYMBIAN 		\epoc32\include\platform\mw\swi
+
+SOURCEPATH			..\.\src
+SOURCE				stat_engine.cpp
+SOURCE				stat_controller.cpp
+SOURCE				stat_tcpip.cpp
+SOURCE				stat_serial.cpp
+SOURCE				stat_usb.cpp
+SOURCE				Stat_bt.cpp
+SOURCE				stat_packetisation.cpp
+SOURCE				stat_comdecoder.cpp
+SOURCE				filedump.cpp
+SOURCE				ntoh.cpp
+SOURCE				asserte.cpp
+SOURCE				activeconnection.cpp
+SOURCE				datasupplier_file.cpp
+SOURCE				datasupplier_memory.cpp
+SOURCE				dataconsumer_file.cpp
+SOURCE				dataconsumer_memory.cpp
+
+SOURCE				appinstall.cpp
+SOURCE				testSecurityinstuihandler.cpp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/light/bld.inf	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,28 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description: 
+//
+#ifndef EXPORTED_STATCONSOLE
+PRJ_EXPORTS
+..\console\Export\statlite.iby   		\epoc32\rom\include\Statlite.iby
+..\console\Export\stat.ini   			\epoc32\data\z\system\data\stat.ini
+..\console\Export\stat_h2.ini   		\epoc32\data\z\system\data\stat_h2.ini
+#endif
+PRJ_PLATFORMS
+
+PRJ_MMPFILES
+#include "./statlightserial/group/bld.inf"
+.\statapilight.mmp
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/light/statapilight.mmp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Build file for OS DISTGeneric
+*
+*/
+
+
+
+MACRO LIGHT_MODE
+//Unpaged
+TARGETTYPE              exe
+
+// no target path specified
+
+TARGET        		statlite.exe
+UID			0
+VENDORID 0x70000001
+epocheapsize		4096	3000000
+
+USERINCLUDE			..\.\inc
+APP_LAYER_SYSTEMINCLUDE_SYMBIAN 		\epoc32\include
+APP_LAYER_SYSTEMINCLUDE_SYMBIAN 		\epoc32\include\test
+
+CAPABILITY		TCB AllFiles SwEvent NetworkServices LocalServices PowerMgmt CommDD
+
+SOURCEPATH			..\.\src
+SOURCE				stat_engine.cpp
+SOURCE				stat_controller.cpp
+SOURCE				stat_serial.cpp
+SOURCE				stat_packetisation.cpp
+SOURCE				stat_comdecoder.cpp
+SOURCE				filedump.cpp
+SOURCE				ntoh.cpp
+SOURCE				asserte.cpp
+SOURCE				datasupplier_file.cpp
+SOURCE				datasupplier_memory.cpp
+SOURCE				dataconsumer_file.cpp
+SOURCE				dataconsumer_memory.cpp
+
+SOURCE				stat_main.cpp
+SOURCE				stat_console.cpp
+SOURCE				activeconsole.cpp
+
+LIBRARY			euser.lib
+LIBRARY			hal.lib efsrv.lib 
+LIBRARY			iniparser.lib
+LIBRARY			serialdriver.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/light/statlightserial/bwins/serialdriveru.def	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,14 @@
+EXPORTS
+	?CloseSerialPort@@YAHPAX@Z @ 1 NONAME ; int CloseSerialPort(void *)
+	?CloseSerialServer@@YAXPAX@Z @ 2 NONAME ; void CloseSerialServer(void *)
+	?OpenSerialPortL@@YAPAXPAXI@Z @ 3 NONAME ; void * OpenSerialPortL(void *, unsigned int)
+	?OpenSerialServerL@@YAPAXXZ @ 4 NONAME ; void * OpenSerialServerL(void)
+	?Read@@YAHPAXAAVTRequestStatus@@VTTimeIntervalMicroSeconds32@@AAVTDes8@@H@Z @ 5 NONAME ; int Read(void *, class TRequestStatus &, class TTimeIntervalMicroSeconds32, class TDes8 &, int)
+	?ReadCancel@@YAHPAX@Z @ 6 NONAME ; int ReadCancel(void *)
+	?ReceiveBufferLength@@YAHPAXAAH@Z @ 7 NONAME ; int ReceiveBufferLength(void *, int &)
+	?SetConfig@@YAHPAXABV?$TPckgBuf@VTCommConfigV01@@@@@Z @ 8 NONAME ; int SetConfig(void *, class TPckgBuf<class TCommConfigV01> const &)
+	?SetReceiveBufferLength@@YAHPAXH@Z @ 9 NONAME ; int SetReceiveBufferLength(void *, int)
+	?Write@@YAHPAXAAVTRequestStatus@@VTTimeIntervalMicroSeconds32@@ABVTDesC8@@H@Z @ 10 NONAME ; int Write(void *, class TRequestStatus &, class TTimeIntervalMicroSeconds32, class TDesC8 const &, int)
+	?WriteCancel@@YAHPAX@Z @ 11 NONAME ; int WriteCancel(void *)
+	?GetPortConfig@@YAHPAXAAV?$TPckgBuf@VTCommConfigV01@@@@@Z @ 12 NONAME ; int GetPortConfig(void *, class TPckgBuf<class TCommConfigV01> &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/light/statlightserial/eabi/serialdriveru.def	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,18 @@
+EXPORTS
+	_Z10ReadCancelPv @ 1 NONAME
+	_Z11WriteCancelPv @ 2 NONAME
+	_Z15CloseSerialPortPv @ 3 NONAME
+	_Z15OpenSerialPortLPvj @ 4 NONAME
+	_Z17CloseSerialServerPv @ 5 NONAME
+	_Z17OpenSerialServerLv @ 6 NONAME
+	_Z19ReceiveBufferLengthPvRi @ 7 NONAME
+	_Z22SetReceiveBufferLengthPvi @ 8 NONAME
+	_Z4ReadPvR14TRequestStatus27TTimeIntervalMicroSeconds32R5TDes8i @ 9 NONAME
+	_Z5WritePvR14TRequestStatus27TTimeIntervalMicroSeconds32RK6TDesC8i @ 10 NONAME
+	_Z9SetConfigPvRK8TPckgBufI14TCommConfigV01E @ 11 NONAME
+	_ZTI11CSerialPort @ 12 NONAME ; #<TI>#
+	_ZTI13CSerialServer @ 13 NONAME ; #<TI>#
+	_ZTV11CSerialPort @ 14 NONAME ; #<VT>#
+	_ZTV13CSerialServer @ 15 NONAME ; #<VT>#
+	_Z13GetPortConfigPvR8TPckgBufI14TCommConfigV01E @ 16 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/light/statlightserial/group/bld.inf	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,31 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description: 
+//
+
+
+PRJ_PLATFORMS
+
+
+PRJ_EXPORTS
+
+..\src\serialdriverext.h		\epoc32\include\serialdriverext.h
+
+PRJ_TESTEXPORTS
+
+
+PRJ_MMPFILES
+
+serialdriver.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/light/statlightserial/group/serialdriver.mmp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+TARGET			serialdriver.dll
+
+TARGETTYPE		DLL
+
+SOURCEPATH		..\src
+SOURCE			serialdriver.cpp
+
+LIBRARY			euser.lib 
+
+USERINCLUDE		..\src
+
+APP_LAYER_SYSTEMINCLUDE_SYMBIAN 	\epoc32\include
+
+capability		all
+
+START WINS
+END
+
+START MARM
+END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/light/statlightserial/src/serialdriver.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,596 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+/**
+@file
+@internalComponent
+*/
+
+// System includes..
+#include <e32base.h>
+
+#include "serialdriverext.h"
+#include "serialdriver.h"			// our header
+
+// Some useful logical/physical driver names.
+#if defined (__WINS__)
+#define PDD_NAME 		_L("ECDRV.PDD")
+#define LDD_NAME 		_L("ECOMM.LDD")
+#define DEFAULT_PORT  	1
+#else
+#define PDD_NAME 		_L("EUART")
+#define LDD_NAME 		_L("ECOMM")
+#define DEFAULT_PORT  	0
+#endif
+
+// How many varaiants of the physical driver should we attempt to load before failing.
+#ifdef __WINS__
+	const TInt KMaxPdds=0;
+#else
+	const TInt KMaxPdds=10;
+#endif
+
+#define IGNORE_VALUE(val)		((val)=(val))
+
+class RSerialPort : public RBusDevComm
+	{
+	public:
+	
+	TBool TimedWrite(TRequestStatus & aStatus, 
+					 TTimeIntervalMicroSeconds32 aTimeout,
+					 const TDesC8 &aDes,
+					 TInt aLength);
+	
+	TBool TimedRead(TRequestStatus & aStatus, 
+					TTimeIntervalMicroSeconds32 aTimeout,
+					TDes8 &aDes,
+					TInt aLength);
+	
+	};
+
+TBool RSerialPort::TimedRead(TRequestStatus & aStatus, 
+							 TTimeIntervalMicroSeconds32 aTimeout,
+							 TDes8 &aDes,
+							 TInt aLength)
+	{
+	IGNORE_VALUE(aTimeout);
+
+					
+	// Do the actual read using the base class function...
+		
+	Read(aStatus, aDes, aLength);          // asynchronous				
+	
+	
+	// if the timer was still running when we cancelled it here, then all ok.
+	return (ETrue);
+	
+	}
+	
+TBool RSerialPort::TimedWrite(TRequestStatus & aStatus,
+							  TTimeIntervalMicroSeconds32 aTimeout,
+							  const TDesC8 &aDes,
+							  TInt aLength)
+	{
+	
+	IGNORE_VALUE(aTimeout);
+						
+	// Do the actual write using the base class function...
+	Write(aStatus, aDes, aLength);          // asynchronous				
+	
+	return (ETrue);	
+	
+	}	
+	
+	
+/////////////////////
+/// CSerialServer ///
+/////////////////////
+
+CSerialServer::CSerialServer()
+{
+
+	m_errLogicalLoad = KErrNone;
+	m_errPhysicalLoad = KErrNone;
+
+	for (TUint index = 0; index < MAX_PORTS; index++)
+		portsInUse[index] = NULL;
+
+}
+
+CSerialServer::~CSerialServer()
+	{
+	// Delete any ports that are still in use...
+	for (TUint index = 0; index < MAX_PORTS; index++)
+		{
+		if (portsInUse[index] != NULL)
+			{
+			delete portsInUse[index];
+			portsInUse[index]= NULL;    // just tidying up
+			}
+		}
+	}
+
+TBool CSerialServer::Open(void)
+	{
+
+	TBool bSuccess = EFalse;
+
+	// Load the logical driver.
+	m_errLogicalLoad = User::LoadLogicalDevice(LDD_NAME);
+
+	if (m_errLogicalLoad == KErrNone || m_errLogicalLoad == KErrAlreadyExists)
+		{
+
+		// Load the physical driver.
+		TInt loadErr;
+		TBuf<10> pddName=PDD_NAME;
+
+		// Try EUART as a driver name first, then EUART0, EUART1, EUART2...EUARTn.
+		TInt driver;
+		for (driver=-1; driver<KMaxPdds && bSuccess == EFalse; ++driver)
+			{
+			if (driver==0)
+				pddName.Append(TChar('0'));
+			else if (driver>0)
+				pddName[pddName.Length()-1] = (TText)('0'+driver);
+			loadErr = User::LoadPhysicalDevice(pddName);
+			if (loadErr == KErrNone || loadErr==KErrAlreadyExists)
+				bSuccess = ETrue;
+			}
+
+		// If failed to load physical driver, unload the logical if this wasn't originally present
+		if (bSuccess == EFalse)
+			{
+			if (m_errLogicalLoad == KErrNone)
+				User::FreeLogicalDevice(LDD_NAME);
+			}
+		}
+
+	return(bSuccess);
+	}
+
+TBool CSerialServer::Close(void)
+	{
+	TInt logUnloadError = KErrNone;
+	TInt phyUnloadError = KErrNone;
+	TBool bSuccess = EFalse;
+
+	// If not originally loaded, then unload the physical device.
+	if (m_errPhysicalLoad == KErrNone)
+		phyUnloadError = User::FreePhysicalDevice(PDD_NAME);
+
+	// If not originally loaded, then unload the logical device.
+	if (m_errLogicalLoad == KErrNone)
+		logUnloadError = User::FreeLogicalDevice(LDD_NAME);
+
+	if (phyUnloadError == KErrNone && logUnloadError == KErrNone)
+		bSuccess = ETrue;
+
+	return (bSuccess);
+
+	}
+
+
+RSerialPort * CSerialServer::GetPort(TUint aPortNum)
+	{	
+	RSerialPort * pRPort = (aPortNum < MAX_PORTS ? portsInUse[aPortNum] : NULL);
+	return (pRPort);	
+	}
+	
+	
+RSerialPort * CSerialServer::InitialisePort(TUint aPortNum)
+{
+	RSerialPort * newPort = NULL;
+	
+	if (aPortNum < MAX_PORTS && portsInUse[aPortNum] == NULL)
+	{
+	
+		// Create a new port...
+		newPort = new RSerialPort;   //RClass - so  can't leave.
+		
+		// Open the real port...
+		TInt error = newPort->Open(aPortNum);
+		
+		if (error != KErrNone )
+			{
+			// There was a problem, tidy up...
+			delete newPort;
+			newPort = NULL;
+			}
+		else
+			{			
+			// Record a pointer to our port for later use.
+			portsInUse[aPortNum] = newPort;
+			}
+	}
+	
+	return (newPort);
+}
+
+TBool CSerialServer::ClosePort (TUint aPortNum)
+{
+	TBool closed = EFalse;
+	
+	// if port is valid...
+	if (aPortNum < MAX_PORTS && portsInUse[aPortNum])
+		{
+		// Close the physical port!
+		portsInUse[aPortNum]->Close();
+		
+		// Delete the memory and update the pointer.
+		delete portsInUse[aPortNum];
+		portsInUse[aPortNum] = NULL;
+		
+		// Update flag to indicate all closed ok.
+		closed = ETrue;
+	
+		}
+	return (closed);
+	
+}
+
+///////////////////
+/// CSerialPort ///
+///////////////////
+
+
+CSerialPort::CSerialPort()
+{
+	m_pOurServer = NULL;
+}
+
+CSerialPort::~CSerialPort()
+{
+	
+}
+
+TBool CSerialPort::Open(CSerialServer & aServer, TUint aPort)
+	{
+	TBool bOpenedOk = EFalse;
+	
+	// The server holds the real port details, so call the server to do the business...
+	if (aServer.InitialisePort(aPort) != NULL)
+		{
+		m_pOurServer = &aServer;
+		
+		m_portId = aPort;
+						
+		bOpenedOk = ETrue;
+		}
+	
+	return (bOpenedOk);
+	}
+
+
+TBool CSerialPort::Close(void)
+	{
+	TBool bClosed = EFalse;
+		
+	// The server object holds all the real details, so call the appropriate
+	// server function.
+	if (m_pOurServer)		
+		bClosed = m_pOurServer->ClosePort(m_portId);
+	
+	return (bClosed);
+	}
+
+TBool CSerialPort::Read(TRequestStatus & aStatus, 
+						TTimeIntervalMicroSeconds32 aTimeout,
+						TDes8 &aDes,
+						TInt aLength)
+	{
+	TBool success = EFalse;
+
+	RSerialPort * pPort = GivePortDetails();
+	
+	if (pPort)
+		{
+		if (pPort->TimedRead(aStatus, aTimeout, aDes, aLength))
+			success = ETrue;
+		}
+		
+		// return success or otherwise!
+		return (success);
+	}
+
+
+TBool CSerialPort::Write(TRequestStatus & aStatus,
+				   TTimeIntervalMicroSeconds32 aTimeout,
+				   const TDesC8 &aDes,
+				   TInt aLength)
+	{
+	
+	TBool success = EFalse;
+
+	RSerialPort * pPort = GivePortDetails();
+	
+	if (pPort)
+		{
+		if (pPort->TimedWrite(aStatus, aTimeout, aDes, aLength))
+			success = ETrue;
+		}
+		
+	// return success or otherwise!
+	return (success);
+	}
+
+
+TInt CSerialPort::SetConfig(const TCommConfig & aRequiredConfig)
+	{
+	TInt errConfig = KErrUnknown;
+		
+	RSerialPort * pPort = GivePortDetails();
+
+	if (pPort)
+		{
+		errConfig = pPort->SetConfig(aRequiredConfig);
+		}
+		
+	return (errConfig);
+	}
+
+TBool CSerialPort::GetPortConfig(TCommConfig & aPortSettings)
+{
+	TBool validAction = EFalse;
+
+	RSerialPort * pPort = GivePortDetails();
+	
+	if (pPort)
+		{		
+		pPort->Config( aPortSettings );
+		validAction = ETrue;
+		}
+
+	return (validAction);
+}
+
+TBool CSerialPort::ReadCancel(void)
+	{
+	TBool validAction = EFalse;
+
+	RSerialPort * pPort = GivePortDetails();
+	
+	if (pPort)
+		{		
+		pPort->ReadCancel();		
+		validAction = ETrue;
+		}
+		
+	return (validAction);
+	}
+
+
+TBool CSerialPort::WriteCancel(void)
+	{
+	TBool validAction = EFalse;
+
+	RSerialPort * pPort = GivePortDetails();
+	
+	if (pPort)
+		{		
+		pPort->WriteCancel();		
+		validAction = ETrue;
+		}
+	return (validAction);
+	
+	}
+
+TBool CSerialPort::SetReceiveBufferLength(TInt aSize)
+	{
+	TBool validAction = EFalse;
+
+	RSerialPort * pPort = GivePortDetails();
+	
+	if (pPort)
+		{
+		pPort->SetReceiveBufferLength(aSize);
+		validAction = ETrue;		
+		}
+		
+	return (validAction);
+	
+	}
+
+TBool CSerialPort::ReceiveBufferLength(TInt & aSize)
+	{
+	TBool validAction = EFalse;
+
+	RSerialPort * pPort = GivePortDetails();
+	
+	if (pPort)
+		{
+		aSize = pPort->ReceiveBufferLength();
+		validAction = ETrue;		
+		}
+		
+	return (validAction);	
+	}
+
+
+
+RSerialPort * CSerialPort::GivePortDetails(void)
+	{	
+	RSerialPort * pPort = NULL;
+
+	if (m_pOurServer)	
+		pPort = m_pOurServer->GetPort(m_portId);
+	
+	return (pPort);	
+	}
+
+//////////////////////////////
+// The external interface
+// for users of the library
+//////////////////////////////
+	
+EXPORT_C SerialServer OpenSerialServerL(void)
+	{
+	CSerialServer * pServer;
+	pServer = new(ELeave) CSerialServer;
+
+	// Declare a server and open it.
+	if ( pServer->Open() == EFalse)
+		{			
+		delete pServer;
+		pServer = NULL;
+		}
+		
+	return (static_cast<SerialServer>(pServer));		
+	}
+
+EXPORT_C void CloseSerialServer(SerialServer aServer)
+	{
+	if (aServer)
+		{			
+		CSerialServer * pServer = static_cast<CSerialServer *>(aServer);
+		delete pServer;	
+		}
+	}
+
+EXPORT_C TAny * OpenSerialPortL(SerialServer aServer, TUint aPort)
+	{	
+	CSerialServer * pServer = static_cast<CSerialServer *>(aServer);	
+	
+	CSerialPort * pPort = new(ELeave) CSerialPort; 
+	
+	if (pPort->Open(*pServer, aPort) == EFalse)
+		{
+		delete pPort;
+		pPort = NULL;		
+		}
+	
+	return (static_cast<TAny *>(pPort));
+	}
+
+EXPORT_C TBool CloseSerialPort(SerialPort aPort)
+{
+	CSerialPort * pPort = static_cast<CSerialPort *>(aPort);
+	
+	TBool returnVal = pPort->Close();
+	
+	delete pPort;
+		
+	return (returnVal);	
+}
+
+EXPORT_C TBool Read(SerialPort aPort,
+			  		TRequestStatus & aStatus, 
+			  		TTimeIntervalMicroSeconds32 aTimeout,
+			  		TDes8 &aDes,
+			  		TInt aLength)
+	{
+	TBool ok = EFalse;
+	if (aPort)
+		{
+		CSerialPort * pPort = static_cast<CSerialPort *>(aPort);
+		ok = pPort->Read(aStatus, aTimeout, aDes, aLength);
+		}
+		
+	return ok;	 
+	}
+
+EXPORT_C TBool Write(SerialPort aPort,
+					 TRequestStatus & aStatus,
+				     TTimeIntervalMicroSeconds32 aTimeout,
+				     const TDesC8 &aDes,
+				     TInt aLength)
+	{
+	TBool ok = EFalse;
+	
+	if (aPort)
+		{			
+		CSerialPort * pPort = static_cast<CSerialPort *>(aPort);	
+		ok = pPort->Write(aStatus, aTimeout, aDes, aLength);			
+		}
+	return (ok);
+	}
+
+EXPORT_C TInt SetConfig(SerialPort aPort, const TCommConfig & aRequiredConfig )
+	{	
+	TInt error = KErrUnknown;
+
+	if (aPort)
+		{			
+		CSerialPort * pPort = static_cast<CSerialPort *>(aPort);	
+		error = pPort->SetConfig(aRequiredConfig);
+		}
+	return error;
+	}
+
+EXPORT_C TBool ReadCancel(SerialPort aPort)
+	{	
+	TBool ok = EFalse;
+
+	if (aPort)
+		{			
+		CSerialPort * pPort = static_cast<CSerialPort *>(aPort);	
+		ok = pPort->ReadCancel();
+		}
+	return (ok);
+	}
+
+
+EXPORT_C TBool WriteCancel(SerialPort aPort)
+	{	
+	TBool ok = EFalse;
+
+	if (aPort)
+		{			
+		CSerialPort * pPort = static_cast<CSerialPort *>(aPort);	
+		ok = pPort->WriteCancel();
+		}
+	return (ok);
+	}
+
+EXPORT_C TBool GetPortConfig (SerialPort aPort, TCommConfig & config)
+	{		
+	TBool ok = EFalse;
+
+	if (aPort)
+		{			
+		CSerialPort * pPort = static_cast<CSerialPort *>(aPort);	
+		ok = pPort->GetPortConfig(config);
+		}
+	return (ok);
+	}
+
+
+EXPORT_C TBool SetReceiveBufferLength(SerialPort aPort, TInt aSize)
+	{
+	TBool ok = EFalse;
+
+	if (aPort)
+		{			
+		CSerialPort * pPort = static_cast<CSerialPort *>(aPort);	
+		ok = pPort->SetReceiveBufferLength(aSize);
+		}
+	return (ok);
+	}
+
+EXPORT_C TBool ReceiveBufferLength(SerialPort aPort, TInt & aSize)
+	{
+	TBool ok = EFalse;
+
+	if (aPort)
+		{			
+		CSerialPort * pPort = static_cast<CSerialPort *>(aPort);	
+		ok = pPort->ReceiveBufferLength(aSize);
+		}
+	return (ok);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/light/statlightserial/src/serialdriver.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,108 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef __SERIAL_DRIVER_H
+#define __SERIAL_DRIVER_H
+
+#define MAX_PORTS					10     // randomly high value...
+
+#include <e32std.h>
+#include <e32cmn.h>
+
+class RSerialPort;            				// actually defined within the implementation
+
+
+class CSerialServer
+{
+
+friend class CSerialPort;  // declare CSerialPort our friemd
+
+public:
+	CSerialServer();
+	virtual ~CSerialServer();
+
+	TBool Open(void);
+	TBool Close(void);
+	
+private:
+
+	// These next methods are for friends and not intended
+	// as part of the truely public interface.	
+	RSerialPort * GetPort(TUint aPortNum);		
+	RSerialPort * InitialisePort(TUint aPortNum);
+	TBool ClosePort(TUint aPortNum);
+
+	// member variables
+
+	TInt m_errPhysicalLoad;
+	TInt m_errLogicalLoad;
+
+	RSerialPort * portsInUse[MAX_PORTS]; // array for holding set of port info
+};
+
+
+class CSerialPort
+{
+public:
+	CSerialPort();
+	virtual ~CSerialPort();
+
+	TBool Open(CSerialServer & aServer, TUint aPort);
+	TBool Close(void);
+
+	TBool Read(TRequestStatus & aStatus, 
+			   TTimeIntervalMicroSeconds32 aTimeout,
+			   TDes8 &aDes,
+			   TInt aLength);
+
+	TBool Write(TRequestStatus & aStatus,
+						 TTimeIntervalMicroSeconds32 aTimeout,
+						 const TDesC8 &aDes,
+						 TInt aLength);
+
+	TInt SetConfig(const TCommConfig & aRequiredConfig);
+
+	TBool GetPortConfig(TCommConfig & aPortSettings);
+	
+	TBool ReadCancel(void);
+
+	TBool WriteCancel(void);
+	
+	TBool SetReceiveBufferLength(TInt aSize);
+	
+	TBool ReceiveBufferLength(TInt & aSize);
+	
+	public:
+
+	//functions
+	RSerialPort * GivePortDetails(void);
+	
+	// Member variables	
+	CSerialServer * m_pOurServer;
+	
+	TUint m_portId;
+	
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/light/statlightserial/src/serialdriverext.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,98 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+/**
+@file
+@internalComponent
+
+The interface of the serial driver stuff for users of the serial
+driver library - not users of the class itself.
+
+*/
+
+#ifndef __SERIAL_DRIVER_EXT_H
+#define __SERIAL_DRIVER_EXT_H
+
+#include <d32comm.h>   // gives us 'TCommConfig'
+
+typedef TAny * SerialServer;
+typedef TAny * SerialPort;
+
+// The external interface to users of the library,
+			  		  
+IMPORT_C SerialServer OpenSerialServerL(void);
+
+IMPORT_C void CloseSerialServer(SerialServer aServer);
+
+IMPORT_C SerialPort OpenSerialPortL(SerialServer aServer, TUint aPort);
+
+IMPORT_C TBool CloseSerialPort(SerialPort aPort);
+
+IMPORT_C TBool Read(SerialPort aPort,
+			  		TRequestStatus & aStatus, 
+			  		TTimeIntervalMicroSeconds32 aTimeout,
+			  		TDes8 &aDes,
+			  		TInt aLength);
+
+IMPORT_C TBool Write(SerialPort aPort,
+					 TRequestStatus & aStatus,
+				     TTimeIntervalMicroSeconds32 aTimeout,
+				     const TDesC8 &aDes,
+				     TInt aLength);
+				     
+IMPORT_C TInt SetConfig(SerialPort aPort, const TCommConfig & aRequiredConfig);
+
+IMPORT_C TBool GetPortConfig (SerialPort aPort, TCommConfig & config);
+
+IMPORT_C TBool ReadCancel(SerialPort aPort);
+
+IMPORT_C TBool WriteCancel(SerialPort aPort);
+
+IMPORT_C TBool SetReceiveBufferLength(SerialPort aPort, TInt aSize);
+
+IMPORT_C TBool ReceiveBufferLength(SerialPort aPort, TInt & aSize);
+
+// typedef equivalents
+
+
+typedef SerialServer (*TLibOpenSerialServerL)(void);
+typedef void (*TLibCloseSerialServer)(SerialServer aServer);
+typedef SerialPort (*TLibOpenSerialPortL)(SerialServer aServer, TUint aPort);
+typedef TBool (*TLibCloseSerialPort)(SerialPort aPort);
+typedef TBool (*TLibRead)(SerialPort aPort,
+			  		  TRequestStatus & aStatus, 
+			  		  TTimeIntervalMicroSeconds32 aTimeout,
+			  		  TDes8 &aDes,
+			  		  TInt aLength);
+typedef TBool (*TLibWrite)(SerialPort aPort,
+					   TRequestStatus & aStatus,
+				       TTimeIntervalMicroSeconds32 aTimeout,
+				       const TDesC8 &aDes,
+				       TInt aLength);
+typedef TInt (*TLibSetConfig)(SerialPort aPort, const TCommConfig & aRequiredConfig );
+
+typedef TBool (*TLibReadCancel)(SerialPort aPort);
+
+typedef TBool (*TLibWriteCancel)(SerialPort aPort);
+
+typedef TBool (*TLibSetReceiveBufferLength)(SerialPort aPort, TInt aSize);
+
+typedef TBool (*TLibReceiveBufferLength)(SerialPort aPort, TInt & aSize);
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/rsc/statapi_loc.rss	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+/********************************************************************************
+ *
+ * System Headers
+ *
+ *******************************************************************************/
+#include <appinfo.rh>
+
+/********************************************************************************
+ *
+ * Local Headers
+ *
+ *******************************************************************************/
+
+/********************************************************************************
+ *
+ * Resources
+ *
+ *******************************************************************************/
+RESOURCE LOCALISABLE_APP_INFO
+	{
+	short_caption = "Stat";
+	caption_and_icon =
+		{
+		CAPTION_AND_ICON_INFO 
+			{
+			caption =			"StatApi";
+			number_of_icons =	2;
+			icon_file =			"c:\\resource\\apps\\statapiicon.mbm";
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/rsc/statapi_reg.rss	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+/********************************************************************************
+ *
+ * System Headers
+ *
+ *******************************************************************************/
+#include <appinfo.rh>
+
+/********************************************************************************
+ *
+ * Local Headers
+ *
+ *******************************************************************************/
+
+/********************************************************************************
+ *
+ * Resources
+ *
+ *******************************************************************************/
+UID2 KUidAppRegistrationResourceFile
+
+UID3 0x10210D4E
+
+RESOURCE APP_REGISTRATION_INFO
+	{
+	app_file					= "statapi";
+	localisable_resource_file	= "\\resource\\apps\\statapi_loc";
+	hidden						= KAppNotHidden;
+	embeddability				= KAppNotEmbeddable;
+	newfile						= KAppDoesNotSupportNewFile;
+	}
Binary file testconns/statapi/device/source/statapi/rsc/statapiicon_24x24i.bmp has changed
Binary file testconns/statapi/device/source/statapi/rsc/statapiicon_24x24m.bmp has changed
Binary file testconns/statapi/device/source/statapi/rsc/statapiicon_32x32i.bmp has changed
Binary file testconns/statapi/device/source/statapi/rsc/statapiicon_32x32m.bmp has changed
Binary file testconns/statapi/device/source/statapi/rsc/statapiicon_48x48i.bmp has changed
Binary file testconns/statapi/device/source/statapi/rsc/statapiicon_48x48m.bmp has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/rsc/statgui_aif.rss	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+/********************************************************************************
+ * 
+ * System Includes
+ *
+ *******************************************************************************/
+#include <aiftool.rh>
+
+/********************************************************************************
+ * 
+ * Application Information
+ *
+ *******************************************************************************/
+RESOURCE AIF_DATA
+{
+	app_uid = 0x10009B04;
+
+	caption_list=
+	{ 
+		CAPTION { code = ELangEnglish; caption = "StatGui"; }
+	};
+
+	num_icons=2;
+
+	embeddability = KAppNotEmbeddable;
+	hidden = KAppNotHidden ;
+	newfile = KAppDoesNotSupportNewFile;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/rsc/statgui_loc.rss	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+/********************************************************************************
+ *
+ * System Headers
+ *
+ *******************************************************************************/
+#include <appinfo.rh>
+
+/********************************************************************************
+ *
+ * Local Headers
+ *
+ *******************************************************************************/
+
+/********************************************************************************
+ *
+ * Resources
+ *
+ *******************************************************************************/
+RESOURCE LOCALISABLE_APP_INFO
+	{
+	short_caption = "Stat";
+	caption_and_icon =
+		{
+		CAPTION_AND_ICON_INFO 
+			{
+			caption =			"StatGui";
+			number_of_icons =	2;
+			icon_file =			"z:\\resource\\apps\\statguiicon.mbm";
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/rsc/statgui_reg.rss	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+/********************************************************************************
+ *
+ * System Headers
+ *
+ *******************************************************************************/
+#include <appinfo.rh>
+
+/********************************************************************************
+ *
+ * Local Headers
+ *
+ *******************************************************************************/
+
+/********************************************************************************
+ *
+ * Resources
+ *
+ *******************************************************************************/
+UID2 KUidAppRegistrationResourceFile
+
+UID3 0x10009B04
+
+RESOURCE APP_REGISTRATION_INFO
+	{
+	app_file					= "statgui";
+	localisable_resource_file	= "\\resource\\apps\\statgui_loc";
+	hidden						= KAppNotHidden;
+	embeddability				= KAppNotEmbeddable;
+	newfile						= KAppDoesNotSupportNewFile;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/rsc/statgui_ui.rss	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,79 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+NAME STAT
+
+/********************************************************************************
+ *
+ * System Headers
+ *
+ *******************************************************************************/
+#include <eikon.rh>
+#include <eikon.rsg>
+#include <eikon.hrh>
+#ifdef SYMBIAN_DIST_SERIES60
+#include <avkon.rsg>
+#include <avkon.hrh>
+#endif
+
+/********************************************************************************
+ *
+ * Local Headers
+ *
+ *******************************************************************************/
+#include "statapi.hrh"
+
+/********************************************************************************
+ *
+ * Resources
+ *
+ *******************************************************************************/
+RESOURCE RSS_SIGNATURE {}	
+RESOURCE TBUF { buf=""; }
+RESOURCE EIK_APP_INFO
+{	
+#ifdef SYMBIAN_DIST_SERIES60
+    menubar = r_stat_menubar;
+    cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
+#endif
+}
+
+
+/********************************************************************************
+ *
+ * Series 60 Menu
+ *
+ *******************************************************************************/
+#ifdef SYMBIAN_DIST_SERIES60
+RESOURCE MENU_BAR r_stat_menubar
+{
+    titles =
+	{
+        MENU_TITLE {menu_pane = r_stat_menu;}
+    };
+}
+
+RESOURCE MENU_PANE r_stat_menu
+{
+    items = 
+	{
+		MENU_ITEM {command = EStatCmdAction;			txt = "Start / Stop";},
+		MENU_ITEM {command = EStatCmdToggleLogging;		txt = "Logging";}
+	};
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/series60/bld.inf	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,18 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description: 
+//
+PRJ_MMPFILES
+.\statapi.mmp
+makefile .\statapi_buildsis.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/series60/statapi.mmp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Series 60 Buildfile
+*
+*/
+
+
+MACRO SYMBIAN_OS_61
+MACRO SYMBIAN_DIST_SERIES60
+
+#define SYMBIAN_OS_61
+#define SYMBIAN_DIST_SERIES60
+
+LIBRARY		avkon.lib
+
+////////////////////////////////////////////////////////////////
+//
+// GENERIC SECTION
+//
+////////////////////////////////////////////////////////////////
+#include "../common/statapi_common.mmp"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/series60/statapi.rss	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#define SYMBIAN_DIST_SERIES60
+
+#include "../rsc/statapi_ui.rss"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/series60/statapi_buildsis.mmp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#############################################################################################################
+#
+# BUILDSIS SERIES 60
+#
+#############################################################################################################
+!IF "$(CFG)" == "UREL" && ("$(PLATFORM)" == "WINS" || "$(PLATFORM)" == "WINSCW")
+
+FINAL:
+	makesis -v -d\epoc32\release\$(PLATFORM)\$(CFG)\z\system\apps\statapi statapi_series60.pkg statapi.Series60.$(PLATFORM).sis
+
+!ELSEIF "$(CFG)" == "UREL"
+
+FINAL:
+	makesis -v -d\epoc32\release\$(PLATFORM)\$(CFG) statapi_series60.pkg statapi.Series60.$(PLATFORM).sis
+
+!ENDIF
+
+#############################################################################################################
+#
+#
+#
+#############################################################################################################
+CLEAN FINAL MAKMAKE FREEZE LIB CLEANLIB RESOURCE RELEASABLES BLD SAVESPACE : 
+VENDORID 0x70000001
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/series60/statapi_series60.pkg	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,21 @@
+;
+; Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: 
+;
+
+#{"Statapi"},(0x10009B04),1,0,0
+*"..\cf_common\stat.key","..\cf_common\stat.cer"
+"statapi.app"-"!:\system\apps\statapi\statapi.app"
+"statapi.rsc"-"!:\system\apps\statapi\statapi.rsc"
+"statapi.aif"-"!:\system\apps\statapi\statapi.aif"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/src/activeconnection.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,201 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "activeconnection.h"
+
+CActiveConnection* CActiveConnection::NewL(const TDesC& ipAddress, TInt port)
+{
+	CActiveConnection* self=new(ELeave)CActiveConnection();
+	CleanupStack::PushL(self);
+	self->ConstructL(ipAddress,port);
+	CleanupStack::Pop();
+	return self;	
+}
+
+CActiveConnection::CActiveConnection(void) : CActive(0)
+{
+	;
+}
+
+void CActiveConnection::ConstructL(const TDesC& ipAddress, TInt port)
+{
+	iDstAddr.SetPort(port);		
+    iDstAddr.Input(ipAddress);
+    
+	CActiveScheduler::Add(this);
+}
+
+CActiveConnection::~CActiveConnection()
+{
+	Cancel();
+}
+
+//Checks for user input to console.
+void CActiveConnection::RunL()
+{
+	
+	if(iStatus==KErrInUse)
+	{
+		Connect();
+		SetActive();
+	}
+
+}
+
+void CActiveConnection::DoCancel()
+{
+}
+
+void CActiveConnection::Connect(TActiveConnectionMode aConnMode, TInt aConnIndex)
+{
+	//Wait 2 seconds before attempting to connect to NTRAS
+	//It solves 8, randomly failing to connect to NTRAS
+
+	User::After(KDelay);
+	
+#if defined(__WINS__)
+
+    // WinTap IAP
+	TUint32 lIAP = 0;
+	
+	_LIT16(KWIN_TAP, "WinTAP");
+	
+	/****************** CommsDat Soloution ************************
+		CMDBSession* iDb = CMDBSession::NewL(CMDBSession::LatestVersion());
+		CCDIAPRecord* ptrIAPRecord = static_cast<CCDIAPRecord *> (CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord));
+		
+		TPtrC recordname(KWIN_TAP);
+		ptrIAPRecord->iRecordName.SetMaxLengthL(recordname.Length());
+		ptrIAPRecord->iRecordName = recordname;
+
+		if(ptrIAPRecord->FindL(*iDb))
+	    {
+		    // Found a matching record
+	//	    ptrIAPRecord->iService.LoadL(*iDb);
+		    
+		    delete ptrIAPRecord;  
+	    }
+	***************************************************************/
+
+
+	if (aConnMode == EModeIAP && aConnIndex == 0)
+	{
+		// Open CommDB IAP table
+		CCommsDatabase* lCommsDb = CCommsDatabase::NewL();
+    	CleanupStack::PushL(lCommsDb);
+		CCommsDbTableView* lIapTable = lCommsDb->OpenTableLC(TPtrC(IAP));
+		
+		TBuf<52> lIapName;
+	
+		// Point to the first entry
+		User::LeaveIfError(lIapTable->GotoFirstRecord());
+		lIapTable->ReadTextL(TPtrC(COMMDB_NAME), lIapName);
+
+		if (lIapName.Find(KWIN_TAP) != KErrNotFound) 
+		{
+			lIapTable->ReadUintL(TPtrC(COMMDB_ID), lIAP);
+		}
+		else
+		{
+			// Point to the rest of the entries
+			TInt err = KErrNone;
+			while (err = lIapTable->GotoNextRecord(), err == KErrNone)
+			{
+				lIapTable->ReadTextL(TPtrC(COMMDB_NAME), lIapName);
+				if (lIapName.Find(KWIN_TAP) != KErrNotFound) 
+				{
+					lIapTable->ReadUintL(TPtrC(COMMDB_ID), lIAP);
+				}
+	
+			}
+		}
+		
+		CleanupStack::PopAndDestroy(lIapTable);
+    	CleanupStack::PopAndDestroy(lCommsDb);
+
+		aConnIndex = lIAP;
+	}
+
+#endif
+
+	// Create Connection with IAP
+	TInt lErr = iSocketServer.Connect();
+	if (lErr != KErrNone) 
+		return;
+	
+	RConnection lConn;
+    lErr = lConn.Open(iSocketServer);
+    
+    if (lErr == KErrNone && aConnIndex > 0)
+    {
+    	if (aConnMode == EModeIAP)
+    	{
+	    	// Set IAP Preferences
+			TCommDbConnPref lPrefs;
+			lPrefs.SetIapId(aConnIndex);
+			lPrefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
+			lErr = lConn.Start(lPrefs);
+    	}
+#ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
+    	else if (aConnMode == EModeSnap)
+    	{
+    		TConnSnapPref lPrefs(aConnIndex);
+    		lErr = lConn.Start(lPrefs);
+    	}
+#endif // SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
+    	else
+    	{
+    		// use default mode
+    		lErr = KErrNotSupported;
+    	}
+
+		if (lErr == KErrNone) 
+		{
+			RHostResolver lHostResolver;
+			lErr = lHostResolver.Open(iSocketServer, KAfInet, KProtocolInetTcp, lConn);
+			
+			if (lErr == KErrNone) 
+			{
+				lErr = iSocket.Open(iSocketServer, KAfInet, KSockStream, KProtocolInetTcp, lConn);
+			}
+		}
+    }
+    
+    if (aConnIndex == 0 || lErr != KErrNone)
+    {
+    	if(iSocket.Open(iSocketServer, KAfInet, KSockStream, KProtocolInetTcp) != KErrNone) {
+    		return;
+    	}
+    }
+   
+    // Connect
+	iSocket.Connect(iDstAddr, iStatus);
+}
+
+//Initial request
+void CActiveConnection::Start(TActiveConnectionMode aConnMode, TInt aConnIndex)
+{    
+	Connect(aConnMode, aConnIndex);
+	SetActive();
+}
+
+void CActiveConnection::CloseSocket()
+{    
+	iSocket.CancelConnect();
+	iSocket.Close();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/src/activeconsole.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,127 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "activeconsole.h"
+
+CActiveConsole* CActiveConsole::NewL(CConsoleBase* aConsole,CStatController *aController,CStatConsole* aStatConsole,TInt aSessionID, MNotifyLogMessage *const aMsg)
+{
+	CActiveConsole* self=new(ELeave)CActiveConsole(aConsole,aController,aStatConsole,aSessionID,aMsg);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop();
+	return self;	
+}
+
+CActiveConsole::CActiveConsole(CConsoleBase* aConsole,CStatController *aController,CStatConsole* aStatConsole,TInt aSessionID, MNotifyLogMessage *const aMsg) : CActive(0)
+{
+	iConsole=aConsole;	
+	iController=aController;
+	iSessionID=aSessionID;
+	iStatConsole=aStatConsole;
+	iMsg = aMsg;
+}
+
+void CActiveConsole::ConstructL()
+{
+	iMsg->Msg( _L("ACTIVECONSOLE: Adding self to scheduler.") );
+	CActiveScheduler::Add(this);
+}
+
+CActiveConsole::~CActiveConsole()
+{
+	Cancel();
+}
+
+//Checks for user input to console.
+void CActiveConsole::RunL()
+{
+	TChar gChar = TChar(iConsole->KeyCode());
+
+	switch (gChar)
+	{
+		case EKeyEscape:		//escape exits
+		case '2':				//2 exits
+			iConsole->Printf( _L("Processing escape request.") );
+			iMsg->Msg( _L("ACTIVECONSOLE: Processing escape request.") );
+			iStatConsole->UserExitRequest();
+			iController->StopSession(iSessionID);
+			return;
+		case '1':				//1 sets system to forground
+		case 'b':				//b or B sets system to forground
+		case 'B':
+			PushToBack();
+			break;
+		default:
+			break;
+	}
+
+	if(iStatus!=KErrNone)
+	{
+		iConsole->Printf(_L("** error reading from active console **"));
+		iConsole->Getch();
+	}
+	iConsole->Read(iStatus);
+	SetActive();
+}
+
+void CActiveConsole::DoCancel()
+{
+}
+
+//Initial request
+void CActiveConsole::Start()
+{
+	iConsole->Read(iStatus);
+	SetActive();
+}
+
+//Push statapi to background by switching to the system window
+void CActiveConsole::PushToBack()
+{
+#ifndef LIGHT_MODE
+	RWsSession Ws;
+	
+	//conect to windows server
+	if(Ws.Connect() != KErrNone) {
+		return;
+	}
+	TInt wsHandle = Ws.WsHandle();
+
+	if(0!=wsHandle)
+		{
+		TApaTaskList taskList(Ws);
+
+		//switch to system
+	    TApaTask newTask = taskList.FindApp(KTxtExampleCode);
+	 
+	    if( newTask.WgId() != KErrNotFound ) 
+	         newTask.SendToBackground();
+
+		//clean up RWsSession
+		Ws.Close();
+		}
+	else
+		{
+		iConsole->Printf(_L("Error: Unable to connect to windows server."));
+		}
+#endif // ifndef LIGHT_MODE
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/src/appinstall.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,90 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+#include <e32base.h>
+#include <e32cons.h>
+#include <hal.h>
+#include <iniparser.h>
+
+// Epoc Includes
+#include <swi/launcher.h>
+
+
+#include "appinstall.h"
+#include "testsecurityinstuihandler.h"
+
+
+CAppInstall::CAppInstall()
+	{
+	}
+
+TInt CAppInstall::Install(const TDesC& aFileName)
+	{
+	
+	TInt error = KErrNone;
+
+	TFileName fileName(aFileName);
+	
+	fileName.PtrZ();	
+	
+	Swi::CInstallPrefs* iInstallPrefs = Swi::CInstallPrefs::NewL();
+	
+	CTestSecurityInstUIHandler* iUIHandler = CTestSecurityInstUIHandler::NewL();
+	
+	error = Swi::Launcher::Install(*iUIHandler,fileName,*iInstallPrefs);
+
+	delete iUIHandler;
+	iUIHandler = 0;
+	delete iInstallPrefs;
+	iInstallPrefs = 0;
+	
+	return error;
+	
+	}
+
+TInt CAppInstall::Uninstall(const TDesC& aUid)
+	{
+	
+	TInt error = KErrNone;
+
+	TLex conv(aUid);
+	
+	TUint32 id;
+	
+	error = conv.Val(id,EHex);
+	
+	if(error!=KErrNone)
+		{
+		return error;
+		}
+		
+	TUid uid = TUid::Uid(id);
+		
+	
+	CTestSecurityInstUIHandler* iUIHandler = CTestSecurityInstUIHandler::NewL();
+
+	error = Swi::Launcher::Uninstall(*iUIHandler, uid);
+	
+	delete iUIHandler;
+	iUIHandler = 0;
+
+	return error;
+		
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/src/asserte.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,62 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+#include <e32std.h>
+
+#define ASSERT_BUFFER	256
+
+/********************************************************************************
+ *
+ * Assert_StripPath
+ *
+ * Remove the drive and folders from a full path and leave only 
+ * the filename.
+ ********************************************************************************/
+void Assert_StripPath( TDes8 & file )
+{
+	static const TUint8 backSlash = '\\';
+	TInt index = 0;
+	if(KErrNotFound != (index = file.LocateReverse(backSlash)))
+	{
+		TBuf8<ASSERT_BUFFER> temp = file.Right(file.Length() - (index + 1));
+		file = temp;
+	}
+}
+
+/********************************************************************************
+ *
+ * AssertE
+ *
+ ********************************************************************************/
+void AssertE( TPtrC8 _file, TInt _line )
+{
+	TBuf8<ASSERT_BUFFER> buffer8;
+	TBuf8<256> file( _file );
+	Assert_StripPath( file );
+	buffer8.Format( (TPtrC8(reinterpret_cast<const TText8*>("!%S"))), &(file) );
+
+#if defined (_UNICODE)
+	TBuf16<ASSERT_BUFFER> buffer16;
+	buffer16.Copy(buffer8);
+	User::Panic(buffer16, _line);
+#else // defined(_UNICODE)
+	User::Panic(buffer8, _line);
+#endif //defined(_UNICODE)
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/src/dataconsumer_file.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,283 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+ /*************************************************************************
+ *
+ * System Includes
+ *
+ *************************************************************************/
+
+#include <e32std.h>
+#include <e32base.h>
+#include <f32file.h>
+/*************************************************************************
+ *
+ * Local Includes
+ *
+ *************************************************************************/
+
+#include "dataconsumer_file.h"
+#include "stat.h"
+/*************************************************************************
+ *
+ * Definitions
+ *
+ *************************************************************************/
+_LIT( KTxtDiskError, "DiskError" );
+
+/*************************************************************************
+ *
+ * CDataConsumerFile - Construction
+ *
+ *************************************************************************/
+CDataConsumerFile *CDataConsumerFile::NewL()
+	{
+	CDataConsumerFile *self = new (ELeave) CDataConsumerFile();
+
+	CleanupStack::PushL(self);
+
+	self->ConstructL();
+
+	CleanupStack::Pop();
+
+	return self;
+	}
+
+CDataConsumerFile::CDataConsumerFile()
+	{
+	;
+	}
+
+void CDataConsumerFile::ConstructL( void ) 
+	{
+	
+	_LIT(KFileSrvDll, "efsrv.dll");
+	_LIT(KFileSeparator, "\\");
+	TBuf<8> systemDrive;
+
+	iLock.CreateLocal( EOwnerProcess );
+
+	User::LeaveIfError( iFsSession.Connect( ) );
+	
+	TDriveNumber defaultSysDrive(EDriveC);
+	RLibrary pluginLibrary;
+	TInt pluginErr = pluginLibrary.Load(KFileSrvDll);
+	
+	if (pluginErr == KErrNone)
+		{
+		typedef TDriveNumber(*fun1)();
+		fun1 sysdrive;
+	
+	#ifdef __EABI__
+		sysdrive = (fun1)pluginLibrary.Lookup(336);
+	#else
+		sysdrive = (fun1)pluginLibrary.Lookup(304);
+	#endif
+		
+		if(sysdrive!=NULL)
+			{
+			defaultSysDrive = sysdrive();
+			}
+		}
+	pluginLibrary.Close();
+	
+	systemDrive.Append(TDriveUnit(defaultSysDrive).Name());
+	systemDrive.Append(KFileSeparator);
+	
+
+	RFile	file;
+
+	TInt err = file.Temp( iFsSession, systemDrive,iFilePath, EFileShareExclusive );
+
+	file.Close( );
+
+	User::LeaveIfError( err );
+	}
+
+
+
+CDataConsumerFile::~CDataConsumerFile( )
+	{
+	iLock.Wait( );
+		{
+		iFsSession.Close();
+
+		iLock.Close( );
+		}
+	}
+
+/*************************************************************************
+ *
+ * CDataConsumerFile - Public interface
+ *
+ *************************************************************************/
+
+/*************************************************************************
+ *
+ * Delete
+ *
+ *************************************************************************/
+
+void CDataConsumerFile::Delete( void ) 
+	{
+	delete this;
+	}
+
+/*************************************************************************
+ *
+ * GetTotalSize
+ *
+ *************************************************************************/
+
+TInt CDataConsumerFile::GetTotalSize( TInt &aTotalSize )
+	{
+	TInt	err = KErrNone;
+	TInt	size = 0;
+
+	iLock.Wait( );
+		{
+		RFile	file;
+
+		err = file.Open( iFsSession, iFilePath, EFileRead | EFileStream | EFileShareReadersOnly );
+
+		if( err == KErrNone )
+			{
+			err = file.Size( size );
+
+			if( err == KErrNone )
+				{
+				aTotalSize = size;
+				}
+
+			file.Close( );
+			}
+
+        iLock.Signal( );
+		}
+
+	return ( err );
+	}
+
+/*************************************************************************
+ *
+ * AddData
+ *
+ *************************************************************************/
+
+TInt CDataConsumerFile::AddData( const TDesC8 &aSource )
+	{
+	TInt	err = KErrNone;
+
+	if( err == KErrNone )
+		{
+		iLock.Wait( );
+			{
+			RFile	file;
+			TInt	shareMode = EFileWrite | EFileStream | EFileShareExclusive;
+
+			err = file.Open( iFsSession, iFilePath, shareMode );
+
+			if( err == KErrNotFound )
+    			{
+    			err = file.Create( iFsSession, iFilePath, shareMode );
+    			}
+
+			if( err == KErrNone )
+				{
+				TInt pos = 0;
+				err = file.Seek( ESeekEnd, pos );
+	
+				if( err == KErrNone )
+					{
+					err = file.Write( aSource );
+					}
+
+				file.Flush( );
+				file.Close( );
+				}
+
+            if( err != KErrNone )
+                {
+                err = iFsSession.Delete(iFilePath);
+                User::Panic(KTxtDiskError, err);
+                }
+
+			iLock.Signal( );
+			}
+		}
+
+	return ( err );
+	}
+
+/*************************************************************************
+ *
+ * GetData
+ *
+ *************************************************************************/
+
+TInt CDataConsumerFile::GetData( HBufC8 & )
+	{
+	return ( KErrNotSupported );
+	}
+
+/*************************************************************************
+ *
+ * SaveData
+ *
+ *************************************************************************/
+
+TInt CDataConsumerFile::SaveData( const TDesC &filePath )
+	{
+	TInt	err = KErrNone;
+
+	if( err == KErrNone )
+		{
+		iLock.Wait( );
+			{
+			
+				CFileMan *theFile = CFileMan::NewL(iFsSession);
+				CleanupStack::PushL(theFile);
+				
+				err = theFile->Copy( iFilePath, filePath );
+				
+				if( err == KErrNone )
+					{
+					err = theFile->Delete(iFilePath);	
+					}
+				
+				CleanupStack::PopAndDestroy();
+
+			iLock.Signal( );
+			}
+		}
+
+	return ( err );
+	}
+
+/*************************************************************************
+ *
+ * operator const TDesC8&
+ *
+ *************************************************************************/
+
+CDataConsumerFile::operator const TDesC8&( void ) const
+	{
+	_LIT8( empty, "" );
+	return ( empty );
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/src/dataconsumer_memory.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,267 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+ /*************************************************************************
+ *
+ * System Includes
+ *
+ *************************************************************************/
+
+#include <e32std.h>
+#include <e32base.h>
+#include <f32file.h>
+
+/*************************************************************************
+ *
+ * Local Includes
+ *
+ *************************************************************************/
+
+#include "dataconsumer_memory.h"
+
+/*************************************************************************
+ *
+ * Definitions
+ *
+ *************************************************************************/
+
+/*************************************************************************
+ *
+ * CDataConsumerMemory - Construction
+ *
+ *************************************************************************/
+CDataConsumerMemory *CDataConsumerMemory::NewL()
+	{
+	CDataConsumerMemory *self = new (ELeave) CDataConsumerMemory();
+
+	CleanupStack::PushL(self);
+
+	self->ConstructL();
+
+	CleanupStack::Pop();
+
+	return self;
+	}
+
+CDataConsumerMemory::CDataConsumerMemory() : CBase(),
+	iDataBuffer( NULL )
+	{
+	;
+	}
+
+void CDataConsumerMemory::ConstructL( void ) 
+	{
+	iLock.CreateLocal( EOwnerProcess );
+	}
+
+CDataConsumerMemory::~CDataConsumerMemory( )
+	{
+	iLock.Wait( );
+		{
+		delete iDataBuffer;
+		iDataBuffer = NULL;
+
+		iLock.Close( );
+		}
+	}
+
+/*************************************************************************
+ *
+ * CDataConsumerMemory - Public interface
+ *
+ *************************************************************************/
+
+/*************************************************************************
+ *
+ * Delete
+ *
+ *************************************************************************/
+
+void CDataConsumerMemory::Delete( void ) 
+	{
+	delete this;
+	}
+
+/*************************************************************************
+ *
+ * GetTotalSize
+ *
+ *************************************************************************/
+
+TInt CDataConsumerMemory::GetTotalSize( TInt &aTotalSize )
+	{
+	TInt	err = KErrNone;
+	TInt	size = 0;
+
+	iLock.Wait( );
+		{
+		size = iDataBuffer->Length( );
+
+		aTotalSize = size;
+
+		iLock.Signal( );
+		}
+
+	return ( err );
+	}
+
+/*************************************************************************
+ *
+ * AddData
+ *
+ *************************************************************************/
+
+TInt CDataConsumerMemory::AddData( const TDesC8 &aSource )
+	{
+	TInt	err = KErrNone;
+
+	iLock.Wait( );
+		{
+		TInt currentLength = 0;
+
+		if(iDataBuffer)
+			{
+			currentLength = iDataBuffer->Length( );
+			}
+
+		HBufC8 *currentDataBuffer = iDataBuffer;
+
+		TInt srcLength = aSource.Length( );
+		TInt length = currentLength + srcLength;
+
+		iDataBuffer = HBufC8::New( length );
+
+		if(iDataBuffer)
+			{
+				TPtr8	destPtr( iDataBuffer->Des( ) );
+
+				if(currentDataBuffer)
+					{
+					destPtr.Copy( currentDataBuffer->Ptr( ),
+										currentLength );
+					delete currentDataBuffer;
+					currentDataBuffer = NULL;
+					}
+
+				destPtr.Append( aSource.Ptr( ), srcLength );
+			}
+		else
+			{
+			err = KErrNoMemory;
+			}
+
+		iLock.Signal( );
+		}
+
+#ifdef _DEBUG
+	{
+	TInt totalSize = 0;
+	GetTotalSize( totalSize );
+	}
+#endif
+
+	return ( err );
+	}
+
+/*************************************************************************
+ *
+ * GetData
+ *
+ *************************************************************************/
+
+TInt CDataConsumerMemory::GetData( HBufC8 &aDestination )
+	{
+	TInt	err = KErrNone;
+
+	iLock.Wait( );
+		{
+		TInt currentLength = 0;
+
+		if(iDataBuffer)
+			{
+			currentLength = iDataBuffer->Length( );
+
+			TPtr8 destPtr( aDestination.Des( ) );
+			destPtr.Copy( iDataBuffer->Ptr( ), currentLength );
+			}
+
+		iLock.Signal( );
+		}
+
+	return ( err );
+	}
+
+/*************************************************************************
+ *
+ * SaveData
+ *
+ *************************************************************************/
+
+TInt CDataConsumerMemory::SaveData( const TDesC &filePath )
+	{
+	TInt	err = KErrNone;
+	RFs		FsSession;
+
+	err = FsSession.Connect( );
+
+	if( err == KErrNone )
+		{
+		iLock.Wait( );
+			{
+			RFile	file;
+			TInt	shareMode = EFileWrite | EFileStream | EFileShareExclusive;
+
+			err = file.Open( FsSession, filePath, shareMode );
+
+			if( err == KErrNotFound )
+    			{
+    			err = file.Create( FsSession, filePath, shareMode );
+    			}
+
+			if( err == KErrNone )
+				{
+				
+				if( NULL != iDataBuffer )
+					{
+					err = file.Write( iDataBuffer->Des( ) );
+					}
+
+				file.Flush( );
+				file.Close( );
+				}
+
+			iLock.Signal( );
+			}
+
+		FsSession.Close( );
+		}
+
+	return ( err );
+	}
+
+/*************************************************************************
+ *
+ * operator const TDesC8&
+ *
+ *************************************************************************/
+
+CDataConsumerMemory::operator const TDesC8&( void ) const
+	{
+	return ( *iDataBuffer );
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/src/datasupplier_file.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,235 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+ /*************************************************************************
+ *
+ * System Includes
+ *
+ *************************************************************************/
+
+/*************************************************************************
+ *
+ * Local Includes
+ *
+ *************************************************************************/
+
+#include "datasupplier_file.h"
+
+/*************************************************************************
+ *
+ * Definitions
+ *
+ *************************************************************************/
+
+/*************************************************************************
+ *
+ * CDataSupplierFile - Construction
+ *
+ *************************************************************************/
+CDataSupplierFile *CDataSupplierFile::NewL()
+	{
+	CDataSupplierFile *self = new (ELeave) CDataSupplierFile();
+
+	CleanupStack::PushL(self);
+
+	self->ConstructL();
+
+	CleanupStack::Pop();
+
+	return self;
+	}
+
+CDataSupplierFile::CDataSupplierFile() : CBase(),
+	iDataBuffer( NULL ), iCurrentLocation( 0 )
+	{
+	;
+	}
+
+void CDataSupplierFile::ConstructL( void ) 
+	{
+	iLock.CreateLocal( EOwnerProcess );
+	}
+
+CDataSupplierFile::~CDataSupplierFile( )
+	{
+	iLock.Wait( );
+		{
+		iCurrentLocation = 0;
+
+		iFsSession.Close();
+
+		iLock.Close( );
+		}
+	}
+
+/*************************************************************************
+ *
+ * CDataSupplierFile - Public interface
+ *
+ *************************************************************************/
+
+/*************************************************************************
+ *
+ * Delete
+ *
+ *************************************************************************/
+
+void CDataSupplierFile::Delete( void ) 
+	{
+	delete this;
+	}
+
+/*************************************************************************
+ *
+ * GetTotalSize
+ *
+ *************************************************************************/
+
+TInt CDataSupplierFile::GetTotalSize( TInt &aTotalSize )
+	{
+	TInt	err = KErrNone;
+	TInt	size = 0;
+
+	iLock.Wait( );
+		{
+		RFile	file;
+
+		err = file.Open( iFsSession, iFilePath, EFileRead | EFileStream | EFileShareReadersOnly );
+
+		if( err == KErrNone )
+			{
+			err = file.Size( size );
+
+			if( err == KErrNone )
+				{
+				aTotalSize = size;
+				}
+
+			file.Close( );
+			}
+
+		iLock.Signal( );
+		}
+
+	return ( err );
+	}
+
+/*************************************************************************
+ *
+ * GetRemainingSize
+ *
+ *************************************************************************/
+
+TInt CDataSupplierFile::GetRemainingSize( TInt &aRemainingSize )
+	{
+	TInt	err = KErrNone;
+	TInt	remaining = 0;
+
+	iLock.Wait( );
+		{
+		TInt	totalSize =	0;
+
+		err = GetTotalSize( totalSize );
+
+		if( err == KErrNone )
+			{
+			remaining = totalSize - iCurrentLocation;
+
+			aRemainingSize = remaining;
+			}
+
+		iLock.Signal( );
+		}
+
+	return ( err );
+	}
+
+/*************************************************************************
+ *
+ * SetData
+ *
+ *************************************************************************/
+
+TInt CDataSupplierFile::SetData( const TDesC8 &aSource )
+	{
+	TInt	err = KErrNone;
+
+	err = iFsSession.Connect( );
+
+	if( err == KErrNone )
+		{
+		iLock.Wait( );
+			{
+			iFilePath.Copy( aSource );
+
+			// Do a query on the file size to check 
+			// we can access it.
+			TInt totalSize = 0;
+			err = GetTotalSize( totalSize );
+
+			iCurrentLocation = 0;
+			iLock.Signal( );
+			}
+		}
+
+	return ( err );
+	}
+
+/*************************************************************************
+ *
+ * GetData
+ *
+ *************************************************************************/
+
+TInt CDataSupplierFile::GetData( HBufC8 &aDestination, 
+				TInt aLengthToCopy, TInt &aActuallyCopied )
+	{
+	TInt	err = KErrNone;
+
+	iLock.Wait( );
+		{
+		TInt remainingSize = 0;
+		err = GetRemainingSize( remainingSize );
+
+		RFile	file;
+		err = file.Open( iFsSession, iFilePath, EFileRead | EFileStream | EFileShareReadersOnly );
+
+		if( err == KErrNone )
+			{
+			TInt toCopy = Min( aLengthToCopy, remainingSize );
+
+			TPtr8 pBuffer( aDestination.Des() );
+
+			err = file.Read( iCurrentLocation,
+								pBuffer, toCopy);
+
+			if( err == KErrNone )
+				{
+				iCurrentLocation += toCopy;
+				aActuallyCopied = toCopy;
+				}
+
+			file.Close( );
+			}
+
+		iLock.Signal( );
+		}
+
+	return ( err );
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/src/datasupplier_memory.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,229 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+ /*************************************************************************
+ *
+ * System Includes
+ *
+ *************************************************************************/
+
+/*************************************************************************
+ *
+ * Local Includes
+ *
+ *************************************************************************/
+
+#include "datasupplier_memory.h"
+
+/*************************************************************************
+ *
+ * Definitions
+ *
+ *************************************************************************/
+
+/*************************************************************************
+ *
+ * CDataSupplierMemory - Construction
+ *
+ *************************************************************************/
+CDataSupplierMemory *CDataSupplierMemory::NewL()
+	{
+	CDataSupplierMemory *self = new (ELeave) CDataSupplierMemory();
+
+	CleanupStack::PushL(self);
+
+	self->ConstructL();
+
+	CleanupStack::Pop();
+
+	return self;
+	}
+
+CDataSupplierMemory::CDataSupplierMemory() : CBase(),
+	iDataBuffer( NULL ), iCurrentLocation( 0 )
+	{
+	;
+	}
+
+void CDataSupplierMemory::ConstructL( void ) 
+	{
+	iLock.CreateLocal( EOwnerProcess );
+	}
+
+CDataSupplierMemory::~CDataSupplierMemory( )
+	{
+	iLock.Wait( );
+		{
+		delete iDataBuffer;
+		iDataBuffer = NULL;
+		iCurrentLocation = 0;
+
+		iLock.Close( );
+		}
+	}
+
+/*************************************************************************
+ *
+ * CDataSupplierMemory - Public interface
+ *
+ *************************************************************************/
+
+/*************************************************************************
+ *
+ * Delete
+ *
+ *************************************************************************/
+
+void CDataSupplierMemory::Delete( void ) 
+	{
+	delete this;
+	}
+
+/*************************************************************************
+ *
+ * GetTotalSize
+ *
+ *************************************************************************/
+
+TInt CDataSupplierMemory::GetTotalSize( TInt &aTotalSize )
+	{
+	TInt	err = KErrNone;
+	TInt	size = 0;
+
+	iLock.Wait( );
+		{
+		size = iDataBuffer->Length( );
+
+		aTotalSize = size;
+
+		iLock.Signal( );
+		}
+
+	return ( err );
+	}
+
+/*************************************************************************
+ *
+ * GetRemainingSize
+ *
+ *************************************************************************/
+
+TInt CDataSupplierMemory::GetRemainingSize( TInt &aRemainingSize )
+	{
+	TInt	err = KErrNone;
+	TInt	remaining = 0;
+
+	iLock.Wait( );
+		{
+		TInt	totalSize =	0;
+
+		err = GetTotalSize( totalSize );
+
+		if( err == KErrNone )
+			{
+			remaining = totalSize - iCurrentLocation;
+
+			aRemainingSize = remaining;
+			}
+
+		iLock.Signal( );
+		}
+
+	return ( err );
+	}
+
+/*************************************************************************
+ *
+ * SetData
+ *
+ *************************************************************************/
+
+TInt CDataSupplierMemory::SetData( const TDesC8 &aSource )
+	{
+	TInt	err = KErrNone;
+
+	iLock.Wait( );
+		{
+		delete iDataBuffer;
+		iDataBuffer = NULL;
+
+		TInt length = aSource.Length( );
+		iDataBuffer = HBufC8::New( length );
+
+		if(iDataBuffer)
+			{
+			*iDataBuffer = aSource;
+			}
+		else
+			{
+			err = KErrNoMemory;
+			}
+
+		iCurrentLocation = 0;
+		iLock.Signal( );
+		}
+
+#ifdef _DEBUG
+	{
+	TInt totalSize = 0;
+	GetTotalSize( totalSize );
+	TInt remainingSize = 0;
+	GetRemainingSize( remainingSize );
+	}
+#endif
+
+	return ( err );
+	}
+
+/*************************************************************************
+ *
+ * GetData
+ *
+ *************************************************************************/
+
+TInt CDataSupplierMemory::GetData( HBufC8 &aDestination, 
+				TInt aLengthToCopy, TInt &aActuallyCopied )
+	{
+	TInt	err = KErrNone;
+
+	iLock.Wait( );
+		{
+		TInt remainingSize = 0;
+		err = GetRemainingSize( remainingSize );
+
+		if( err == KErrNone )
+			{
+			TInt toCopy = Min( aLengthToCopy, remainingSize );
+
+			TPtr8 destPtr( aDestination.Des( ) );
+			destPtr.Copy( iDataBuffer->Ptr( ) + iCurrentLocation,
+							toCopy );
+
+			if( err == KErrNone )
+				{
+				iCurrentLocation += toCopy;
+				aActuallyCopied = toCopy;
+				}
+			}
+
+		iLock.Signal( );
+		}
+
+	return ( err );
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/src/filedump.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,151 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+#include "filedump.h"
+
+//////////////////////////////////////////////////////////////////////////
+// Open the output file
+//////////////////////////////////////////////////////////////////////////
+GLDEF_C TInt 
+FileDump::Init(RFs &fsSession, TPtrC16 filename, CConsoleBase* console)
+{
+	/*
+	// To determine the date and create a string.
+	static const TInt defLength = 256;
+	int exception = KErrNone;
+	TBuf<defLength> fileDateName( _L("") );
+	TTime date;
+	date.HomeTime();	
+	TRAP( exception, date.FormatL(fileDateName, (_L("%F%Y%M%D"))) );
+	*/
+
+	/*
+	// To either open an existing file or create a new file.
+	TFileMode shareMode = static_cast<TFileMode>(EFileShareAny|EFileStream|EFileWrite);
+
+	TInt err = file.Open( fsSession, fileDateName, shareMode );
+	if ( err == KErrNotFound )
+	    {
+	    err = file.Create( fsSession, fileDateName, shareMode );
+	    }
+	*/
+
+   	if (file.Replace(fsSession, filename, EFileShareAny|EFileStream|EFileWrite) == KErrNone)
+	{
+		pConsole = console;
+		bInitialised = ETrue;
+		return ETrue;
+	}
+
+	return EFalse;
+}
+
+GLDEF_C void
+FileDump::Msg(TPtrC16 text, ...)
+{
+	int exception = KErrNone;
+
+	if (bInitialised && text.Length())
+	{
+		// create date/time string for filename
+		TBuf<10> datestring( _L("") );
+		TTime DateAndTime;
+		DateAndTime.HomeTime();	
+		TRAP( exception, DateAndTime.FormatL(datestring, (_L("%H:%T:%S "))) );
+		if( exception == KErrNone ) {
+			buf.Zero();
+			buf.Append(datestring);
+			buf.ZeroTerminate();
+			WriteBuffer16ToFile(buf, file);
+		}
+
+		VA_LIST list;
+		VA_START(list, text);
+
+		buf.Zero();
+		buf.FormatList(text, list);
+		buf.Append(_L("\r\n"));
+		buf.ZeroTerminate();
+
+		if (pConsole)
+			pConsole->Printf(buf);
+
+		WriteBuffer16ToFile(buf, file);
+
+		VA_END(list);
+	}
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Close the file
+//////////////////////////////////////////////////////////////////////////
+GLDEF_C void 
+FileDump::CloseFile()
+{
+	if( bInitialised ) {
+		file.Close();
+	}
+	bInitialised = EFalse;
+}
+
+
+GLDEF_C TBool
+FileDump::WriteBuffer16ToFile(TDesC16 &buffer, RFile &handle)
+{
+	// keep buffer small to reduce memory usage
+	TBuf8<5> outputBuffer;
+	TPtrC16 ptr;
+	TInt consumed;
+	TInt remainder = 0;
+
+	TBool valid = EFalse;
+
+	if (buffer.Length())
+	{
+		ptr.Set(buffer);
+		do
+		{
+			// get something to write
+			consumed = Min(outputBuffer.MaxLength(), ptr.Length());
+
+			// write it
+			outputBuffer.Copy(ptr.Left(consumed));
+			if (handle.Write(outputBuffer) != KErrNone)
+				return EFalse;
+
+			handle.Flush();
+
+			// get the next chunk
+			remainder = ptr.Length() - consumed;
+			if (remainder > 0)
+				ptr.Set(ptr.Right(remainder));
+
+		}while (remainder > 0);
+
+		valid = ETrue;
+	}
+
+	return valid;
+}
+
+GLDEF_C TBool
+FileDump::IsInitialised() const
+{
+	return bInitialised;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/src/msgwin.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,100 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+ /********************************************************************************
+ *
+ * System Includes
+ *
+ ********************************************************************************/
+#include <e32std.h>
+#include <e32base.h>
+#include <eikenv.h>
+
+/********************************************************************************
+ *
+ * Local Includes
+ *
+ ********************************************************************************/
+#include "MsgWin.h"
+
+/********************************************************************************
+ *
+ * TMsgWinDesOverflow
+ *
+ * Locally defined class to allow us to handle a text buffer overflow
+ * within the call to 'AppendFormat' used to format the text for
+ * the message window.
+ *
+ * If the overflow occurs the overridden method 'Overflow' is called.
+ *
+ ********************************************************************************/
+class TMsgWinDesOverflow : public TDesOverflow
+{
+public:
+	// From base interface class TDesOverflow.
+	/* virtual */ void Overflow( TDes &aDes );
+};
+
+/********************************************************************************
+ *
+ * TMsgWinDesOverflow -- Overflow implementation
+ *
+ * Called if the buffer overflowed in the call to AppendFormat.
+ * We replace the last few character with ellipses to indicate there
+ * was more text that could not be shown.
+ * The user has lost the end of their text anyway so changing the last few
+ * characters will not make things worse.
+ *
+ ********************************************************************************/
+void TMsgWinDesOverflow::Overflow( TDes &aDes )
+{
+	_LIT( ellipses, "..." );
+	const TInt ellipsesLength = ellipses.operator const TDesC&().Length();
+
+	TInt textLength = aDes.MaxLength();
+	aDes.Replace( textLength - ellipsesLength, ellipsesLength, ellipses );
+}
+
+/********************************************************************************
+ *
+ * TMsgWin::Show
+ *
+ * Format the text the user passed and show a simple message window.
+ * If the text was too long for our fixed buffer then we handle
+ * the buffer overflow.
+ *
+ ********************************************************************************/
+void TMsgWin::Show( TPtrC text, ... )
+{
+	static const TInt defLength = 64;
+	TBuf<defLength> buffer(  _L("") );
+
+	VA_LIST list;
+	VA_START( list, text );
+
+	buffer.Zero();
+
+	// Use locally defined call for handling overflows.
+	TMsgWinDesOverflow	overflowHandler;
+	buffer.AppendFormatList( text, list, &overflowHandler);
+
+	VA_END(list);
+
+	CEikonEnv::Static()->AlertWin( buffer, _L("") );
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/src/ntoh.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,147 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+/********************************************************************************
+ *
+ * Local Includes
+ *
+ *******************************************************************************/
+#include "ntoh.h"
+#include "assert.h"
+
+/********************************************************************************
+ *
+ * Implementation
+ *
+ *******************************************************************************/
+int DetectLocalEndian()
+{
+	/* put a long onto the stack */
+	long integer_value = 0x11223344;
+	char *stack_value = (char*)&integer_value;
+	int iType = LilEnd;
+
+	/* see how it's layed out */
+	if( stack_value[0] == 0x11 ) 
+	{
+		asserte( stack_value[1] == 0x22 );
+		asserte( stack_value[2] == 0x33 );
+		asserte( stack_value[3] == 0x44 );
+		iType = BigEnd;
+	}
+	else if( stack_value[0] == 0x44 )
+	{
+		asserte( stack_value[1] == 0x33 );
+		asserte( stack_value[2] == 0x22 );
+		asserte( stack_value[3] == 0x11 );
+	}
+	else
+	{
+		;
+	}
+
+	return iType;
+}
+
+long LittleToBigL( long src )
+{
+	long dst;
+	char *psrc = (char*)&src, *pdst = (char*)&dst;
+	pdst[0] = psrc[3];
+	pdst[1] = psrc[2];
+	pdst[2] = psrc[1];
+	pdst[3] = psrc[0];
+	return dst;
+}
+
+long BigToLittleL( long src )
+{
+	long dst;
+	char *psrc = (char*)&src, *pdst = (char*)&dst;
+	pdst[0] = psrc[3];
+	pdst[1] = psrc[2];
+	pdst[2] = psrc[1];
+	pdst[3] = psrc[0];
+	return dst;
+}
+
+short LittleToBigS( short src )
+{
+	short dst;
+	char *psrc = (char*)&src, *pdst = (char*)&dst;
+	pdst[0] = psrc[1];
+	pdst[1] = psrc[0];
+	return src;
+}
+
+short BigToLittleS( short src )
+{
+	short dst;
+	char *psrc = (char*)&src, *pdst = (char*)&dst;
+	pdst[0] = psrc[1];
+	pdst[1] = psrc[0];
+	return src;
+}
+
+long ntohl( long src )
+{
+	// get the endianess of this machine -- if bigendian then it is the
+	// same as network byte order and nothing needs 
+	int thisMachine = DetectLocalEndian();
+	if( thisMachine == BigEnd ) 
+		return src;
+
+	// otherwise we have to convert from bigendian to little
+	return BigToLittleL( src );
+}
+
+long htonl( long src )
+{
+	// get the endianess of this machine -- if bigendian then it is the
+	// same as network byte order and nothing needs 
+	int thisMachine = DetectLocalEndian();
+	if( thisMachine == BigEnd ) 
+		return src;
+
+	// otherwise we have to convert from littleendian to big
+	return LittleToBigL( src );
+}
+
+short ntohs( short src )
+{
+	// get the endianess of this machine -- if bigendian then it is the
+	// same as network byte order and nothing needs 
+	int thisMachine = DetectLocalEndian();
+	if( thisMachine == BigEnd ) 
+		return src;
+
+	// otherwise we have to convert from bigendian to little
+	return BigToLittleS( src );}
+
+short htons( short src )
+{
+	// get the endianess of this machine -- if bigendian then it is the
+	// same as network byte order and nothing needs 
+	int thisMachine = DetectLocalEndian();
+	if( thisMachine == BigEnd ) 
+		return src;
+
+	// otherwise we have to convert from littleendian to big
+	return LittleToBigS( src );
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/src/stat_application.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,158 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+ /*************************************************************************
+ *
+ * System Includes
+ *
+ *************************************************************************/
+#include <e32std.h> 
+#include <eikstart.h> 
+
+/*************************************************************************
+ *
+ * Local Includes
+ *
+ *************************************************************************/
+#include <statgui.rsg>
+#include "stat_application.h"
+#include "stat_window.h"
+#ifdef SYMBIAN_DIST_SERIES60
+#include <avkon.hrh>
+#endif
+
+/*************************************************************************
+ *
+ * Definitions
+ *
+ *************************************************************************/
+const TUid KUidStat = { 0x10009B04 }; 
+#define IS_COMMAND_CHAR(c) ((c == 'A') || (c == 'C'))
+
+/*************************************************************************
+ *
+ * Prototypes
+ *
+ *************************************************************************/
+char *lstrchr( char *str, char chr );
+
+/*************************************************************************
+ *
+ * Application entry-point
+ *
+ *************************************************************************/
+LOCAL_C CApaApplication* NewApplication()
+{
+	return new CStatApplication;
+}
+
+GLDEF_C TInt E32Main()
+{
+	return EikStart::RunApplication(NewApplication);
+}
+
+
+/*************************************************************************
+ *
+ * Top-level Application Implementation
+ *
+ *************************************************************************/
+TUid CStatApplication::AppDllUid() const
+{
+	return KUidStat;
+}
+
+CApaDocument* CStatApplication::CreateDocumentL()
+{
+	return new (ELeave) CStatDocument(*this);
+}
+
+/*************************************************************************
+ *
+ * Document Class - no real work in this application
+ *
+ *************************************************************************/
+CStatDocument::CStatDocument(CEikApplication& aApp) : CEikDocument(aApp)
+{
+}
+
+CEikAppUi* CStatDocument::CreateAppUiL()
+{
+	return new(ELeave) CStatAppUi;
+}
+
+/*************************************************************************
+ *
+ * CStatAppUI
+ *
+ *************************************************************************/
+void CStatAppUi::ConstructL()
+{
+    BaseConstructL();
+
+	// create the STAT controller
+	iController = CStatController::NewL(); 
+	iWindow = new(ELeave) CStatWindow();
+	iWindow->ConstructL( ClientRect(), iController );
+	iWindow->SetObserver( this );
+}
+
+CStatAppUi::~CStatAppUi()
+{
+	delete iWindow;
+	iWindow = NULL;
+	delete iController;
+	iController = NULL;
+}
+
+TKeyResponse CStatAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
+{
+	return iWindow->OfferKeyEventL( aKeyEvent, aType );
+}
+
+void CStatAppUi::HandleControlEventL( CCoeControl* /*aControl*/, TCoeEvent aEventType )
+{
+	if( aEventType == EEventRequestExit )
+		Exit();
+}
+
+void CStatAppUi::HandleCommandL( TInt aCommand )
+{
+	switch( aCommand ) {
+
+	case EStatCmdAction:
+		iWindow->HandleControlEventL( (CCoeControl*)KActionButton, MCoeControlObserver::EEventStateChanged );
+		break;
+	
+	case EAknSoftkeyExit:
+		iWindow->HandleControlEventL( (CCoeControl*)KExitButton, MCoeControlObserver::EEventStateChanged );
+		break;
+
+	case EStatCmdToggleLogging:
+		iWindow->HandleControlEventL( (CCoeControl*)KLogButton, MCoeControlObserver::EEventStateChanged );
+		break;
+	}
+}
+
+void CStatAppUi::HandleForegroundEventL( TBool aForeground )
+{
+	iWindow->SetForeground( aForeground );
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/src/stat_bt.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,695 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+/********************************************************************************
+ *
+ * System Includes
+ *
+ *******************************************************************************/
+#include <in_sock.h>
+#include <e32std.h>
+
+/********************************************************************************
+ *
+ * Local Includes
+ *
+ *******************************************************************************/
+#include "assert.h"
+#include "ntoh.h"
+#include "stat_bt.h"
+#include "../../../../common/inc/serialpacketsize.h"
+
+/********************************************************************************
+ *
+ * Macro functions
+ *
+ ********************************************************************************/
+#define NOTISDISCONNECTING(s)	(((s) != EDisconnectingData) && ((s) != EDisconnectingListen) && ((s) != EDisconnected) && ((s) != EDisconnectingUnregister))
+#define STANDARDBUFVALUE	4
+
+/********************************************************************************
+ *
+ * CStatTransportBT -- Constructor
+ *
+ *******************************************************************************/
+CStatTransportBT *CStatTransportBT::NewL( void )
+{
+    CStatTransportBT *self = new (ELeave) CStatTransportBT();
+    CleanupStack::PushL(self);
+	self->ConstructL( );
+	CleanupStack::Pop();
+    return self;
+}
+
+CStatTransportBT::CStatTransportBT() : CActive(EPriorityStandard)
+{
+}
+
+void CStatTransportBT::ConstructL( void )
+{
+	// add this to active scheduler
+	CActiveScheduler::Add(this); 
+
+	// initialise all params	
+
+	iWrCommandData = NULL;
+	iRecvBuffer = NULL;
+	iRecvBufferPtr = NULL;
+	iTransport = NULL;
+	iBTTransportStatus = EIdle;
+	iBTTransportDisconnectStatusBeforeUnregister = EIdle;
+	iRWStatus = ENoRW;
+
+	iMaxPacketSize = KMaxBluetoothPacketSize;
+}
+
+CStatTransportBT::~CStatTransportBT()
+{
+	// this will call cancel and remove the active object -- this will call cancel
+	Deque(); 
+
+	// cleanup the sockets
+	switch( iBTTransportStatus ) {
+
+	case EIdle:
+	case EInitialised:
+	case EDisconnected:
+	case EError:
+		break;
+
+	case EConnected:
+		iDataSocket.Shutdown( RSocket::EImmediate, iStatus );
+		/* fall through */
+
+	case EConnecting:
+		iDataSocket.Close();
+		iListenSocket.Shutdown( RSocket::EImmediate, iStatus );
+		iListenSocket.Close();
+		iSocketServ.Close();
+		break;
+
+	case EDisconnectingData:
+	case EDisconnectingListen:
+		;
+		break;
+	default:
+		break;
+	}
+
+	if( iWrCommandData )
+		{
+		delete iWrCommandData;
+		iWrCommandData = NULL;
+		}
+
+	if( iRecvBuffer )
+		{
+		delete iRecvBuffer;
+		iRecvBuffer = NULL;
+		}
+
+	if( iRecvBufferPtr )
+		{
+		delete iRecvBufferPtr;
+		iRecvBufferPtr = NULL;
+		}
+}
+
+/********************************************************************************
+ *
+ * CStatTransportBT -- MStatApiTransport
+ *
+ *******************************************************************************/
+TInt CStatTransportBT::InitialiseL( MNotifyStatTransport *aTransport )
+{
+	// save the transport interface
+	iTransport = aTransport;
+
+	// everything here is done in connect
+	iBTTransportStatus = EInitialised;
+	iRecHandle = NULL;
+	return KSTErrSuccess;
+}
+
+TInt CStatTransportBT::Release( void )
+{
+	// release has nothing to do (disconnecting unregister is in here in case the original connection failed)
+	asserte( (iBTTransportStatus == EDisconnected) || (iBTTransportStatus == EInitialised) || (iBTTransportStatus == EDisconnectingUnregister) );
+	iBTTransportStatus = EIdle;
+	return KSTErrSuccess;
+}
+
+//Register with the Security Manager then goes on and does other stuff in the RunL
+TInt CStatTransportBT::ConnectL( TDesC* /*aRemoteHost*/ )
+{
+	// make sure we are in the correct state
+	asserte( iBTTransportStatus == EInitialised );
+
+
+	// update the state
+	iBTTransportStatus = EConnectingRegisterMgr;
+
+	//	Force a call to RunL instead of waiting for a call back (CAcitve) after registering 
+	//	with the security manager as in V1
+	SetActive();
+	TRequestStatus* status=&iStatus;
+	User::RequestComplete(status,KErrNone);
+	// tell the client to wait for an asynchronous response
+	return KSTErrAsynchronous;
+}
+	
+TInt CStatTransportBT::StartSocketL()
+{
+	TUint error;
+
+	//make sure we are in the correct state
+	asserte( iBTTransportStatus == EConnectingRegisterMgr );
+
+	// connect to the socket server (as we are the receiver and not the initiator), create a socket, bind, listen, accept
+	User::LeaveIfError( iSocketServ.Connect() );
+
+	//now select the protocol to use (RFCOMM (serial emulation - boo.  Problems with demultiplexing if 1 generic serial port is used for multiple BT connections) or L2CAP)
+	TProtocolDesc pInfo;	
+	User::LeaveIfError( iSocketServ.FindProtocol(_L("RFCOMM"),pInfo ) ); 
+
+	//open the listener socket
+	User::LeaveIfError( iListenSocket.Open(iSocketServ, pInfo.iAddrFamily, pInfo.iSockType, pInfo.iProtocol) );
+
+
+	//	RFComm Socket
+	TRfcommSockAddr addr;
+	
+	//	Get First available server channel
+	addr.SetPort(KRfcommPassiveAutoBind);
+
+	//	Set the service security	
+	//Set user defined EPOC TUid to internally represent the service
+	iServiceSecurity.SetUid( TUid::Uid( 0x1234 ) );
+	
+	//Define security requirements
+	iServiceSecurity.SetAuthentication( EFalse );
+	iServiceSecurity.SetEncryption( EFalse ); 
+	iServiceSecurity.SetAuthorisation( EFalse );
+	addr.SetSecurity(iServiceSecurity);
+	
+	//bind
+	User::LeaveIfError( iListenSocket.Bind( addr ) );
+
+	//	Get the assigned port
+	iPort=iListenSocket.LocalPort();
+		
+	// register with the SDP database
+	error = RegWithSDPDatabaseL();
+	
+	if( error != KSTErrSuccess ) 
+	{
+		iTransport->HandleError( error, (void*)iStatus.Int() );
+		return KSTErrGeneralFailure;
+	}
+
+	//listen
+	User::LeaveIfError( iListenSocket.Listen( KLittleStatBTListenQueue ) );
+
+	// create a blank socket which is used as the data socket
+	User::LeaveIfError( iDataSocket.Open(iSocketServ) );
+
+	// everything should now be set up, we just wait for a stat connection
+	asserte( !IsActive() );
+	iListenSocket.Accept( iDataSocket, iStatus );
+	SetActive();
+	return KSTErrSuccess;
+}
+
+//------------------------------------------------------------------------------
+
+TInt CStatTransportBT::Disconnect( void )
+{
+	// must be connected 
+	asserte( (iBTTransportStatus == EInitialised) || 
+			(iBTTransportStatus == EConnected)   || 
+			(iBTTransportStatus == EConnectingSockets)  ||
+			(iBTTransportStatus == EDisconnectingData) ||
+			(iBTTransportStatus == EDisconnectingListen) ||
+            (iBTTransportStatus == EConnectingRegisterMgr) );
+
+	// cancel any pending ops 
+	Cancel();
+
+	iBTTransportDisconnectStatusBeforeUnregister = iBTTransportStatus;
+	iBTTransportStatus = EDisconnectingUnregister;
+	
+	//	Force call to RunL instead of waiting for a return from unregistring security service as in bluetooth V1
+	SetActive();
+	TRequestStatus* iDisconnectStatus=&iStatus;
+	User::RequestComplete(iDisconnectStatus,KErrNone);
+	
+	return KSTErrAsynchronous;
+}
+
+TInt CStatTransportBT::RequestSend( TDesC8 *aData, const TUint aDataLength )
+{
+	// make sure the state is correct
+	asserte( iBTTransportStatus == EConnected );
+	asserte( iRWStatus == ENoRW );
+	iRWStatus = EWritePending;
+
+	// copy the data to members to local members
+	if( aDataLength > 0 )
+	{
+		if( iWrCommandData && ( aDataLength != static_cast<TUint>(iWrCommandData->Length( )) ) )
+		{
+			delete iWrCommandData;
+			iWrCommandData = NULL;
+		}
+
+		if( ! iWrCommandData )
+		{
+			iWrCommandData = HBufC8::New( aDataLength );
+
+			if( ! iWrCommandData )
+			{
+				User::Leave(KErrNoMemory);
+			}
+		}
+		
+		TPtr8 dataPointer( iWrCommandData->Des() );
+		dataPointer.Copy( aData->Ptr(), aDataLength );
+	}
+
+	// do the send
+	asserte( !IsActive() );
+	asserte( (unsigned)aData->Length() == aDataLength );
+	iDataSocket.Write( *iWrCommandData, iStatus );
+	SetActive();
+	
+	// tell the caller to wait for an asynchronous response
+	return KSTErrAsynchronous;
+}
+
+TInt CStatTransportBT::RequestReceive( TUint aByteCount )
+{
+	// ensure that there are no reads in progress
+	asserte( iBTTransportStatus == EConnected );
+	asserte( !IsActive() );
+	asserte( iRWStatus == ENoRW );
+	iRWStatus = EReadPending;
+
+	asserte( aByteCount <= static_cast<TUint>(iMaxPacketSize) );
+	asserte( !IsActive() );
+	
+	if( iRecvBuffer && ( aByteCount != static_cast<TUint>(iRecvBuffer->Length( )) ) )
+	{
+		delete iRecvBuffer;
+		iRecvBuffer = NULL;
+		delete iRecvBufferPtr;
+		iRecvBufferPtr = NULL;
+	}
+
+	if( ! iRecvBuffer )
+	{
+		iRecvBuffer = HBufC8::New( aByteCount );
+
+		if( ! iRecvBuffer )
+		{
+			User::Leave(KErrNoMemory);
+		}
+
+		iRecvBufferPtr = new TPtr8(
+					const_cast<unsigned char*>(iRecvBuffer->Ptr( )),
+										aByteCount, aByteCount );
+
+		if( ! iRecvBufferPtr )
+		{
+			User::Leave(KErrNoMemory);
+		}
+
+#ifdef _DEBUG
+		// Check the size of the pointer is the same
+		// as the size of the buffer.
+		TInt length = iRecvBufferPtr->Length( );
+		length = 0;	// Extra likne to remove compiler warning.
+#endif // def _DEBUG
+	}
+
+	iDataSocket.Read( *iRecvBufferPtr, iStatus );
+	SetActive();
+
+	// return to the caller
+	return KSTErrAsynchronous;
+}
+
+TText8 *CStatTransportBT::Error( void )
+{
+	return NULL;
+}
+
+TInt CStatTransportBT::GetPacketSize()
+{
+	// The packet size is configured when we initialise the port.
+	return iMaxPacketSize;
+}
+
+
+//Register it in the SDP database - determine attribs, construct the record and then add attribs to new record
+TInt CStatTransportBT::RegWithSDPDatabaseL( void )
+{
+	asserte( iBTTransportStatus == EConnectingRegisterMgr );
+
+	//Connect and open to the session and the DB
+	//User::LeaveIfError( iSdpSession.Connect() );
+
+     TInt ret2;
+	 ret2 = iSdpSession.Connect();
+
+     if(ret2!=KErrNone)
+     {
+         User::Leave(ret2);
+     }
+
+	User::LeaveIfError( iSdpDatabaseSession.Open( iSdpSession ) );
+	TBuf8<STANDARDBUFVALUE> value1;
+
+	TBuf8<STANDARDBUFVALUE> value2;
+	CSdpAttrValue* attrVal = 0;
+	CSdpAttrValueDES* attrValDES = 0;
+
+	//initialise
+	value1.FillZ(STANDARDBUFVALUE);
+	value2.FillZ(STANDARDBUFVALUE);
+
+	// Set Attr 1 (service class list) to list with UUID = 0x1101 (serial port)
+	iSdpDatabaseSession.CreateServiceRecordL(TUUID(0x1101), iRecHandle);
+
+	// Set Service name
+	iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdBasePrimaryLanguage + 
+												 KSdpAttrIdOffsetServiceName, 
+												 _L("STATAPI") ); 
+
+	// Set Service description
+	iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdBasePrimaryLanguage + 
+												 KSdpAttrIdOffsetServiceDescription, 
+												 _L("Symbian Test Automation Tool using Serial BT") );
+
+	attrVal = CSdpAttrValueString::NewStringL( _L8( "Test Solutions Dept Symbian Ltd." ) );
+	CleanupStack::PushL(attrVal);
+	iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdBasePrimaryLanguage + 
+													 KSdpAttrIdOffsetProviderName, *attrVal);
+	CleanupStack::PopAndDestroy(); //attrVal
+	attrVal = 0;
+
+	// Set Attr 2 (service record state) to 0
+	attrVal = CSdpAttrValueUint::NewUintL(value1);
+	CleanupStack::PushL(attrVal);
+	iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdServiceRecordState, *attrVal);
+	CleanupStack::PopAndDestroy(); //attrVal
+	attrVal = 0;
+
+	// Set attr 4 (protocol list) to RFCOMM
+	//initialise
+	TBuf8<1> serverChannel;
+	serverChannel.FillZ(1);
+	serverChannel[0] = (unsigned char)iPort;
+
+	attrValDES = CSdpAttrValueDES::NewDESL(0);
+	CleanupStack::PushL(attrValDES);
+	
+	attrValDES->StartListL()
+			->BuildDESL()->StartListL()
+				->BuildUUIDL( TUUID( TUint16( 0x0003 ) ) ) // RFCOMM
+				->BuildUintL( serverChannel )	//Channel ID = 3 (listening port)
+			->EndListL()
+	->EndListL();
+
+	//update attr 4
+	iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdProtocolDescriptorList, *attrValDES);
+	CleanupStack::PopAndDestroy(); //attrValDES
+	attrValDES = 0;
+
+	// Set Attr 5 (browse group list) to list with one UUID
+	// 0x1101 (serial port class)
+	// this should be updated with other service classes when other services are added.
+	attrValDES = CSdpAttrValueDES::NewDESL(0);
+	CleanupStack::PushL(attrValDES);
+
+	attrValDES->StartListL()
+			->BuildUUIDL( TUUID( 0x1002 ) )
+	->EndListL();
+	
+	iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdBrowseGroupList, *attrValDES);
+	CleanupStack::PopAndDestroy();
+	attrValDES = 0;
+
+	// Set Attr 0x006 (language base)
+	value1.FillZ(4);
+	value1[2] = 0x65;
+	value1[3] = 0x6e;
+	TBuf8<STANDARDBUFVALUE> val2;
+	TBuf8<STANDARDBUFVALUE> val3;
+	val2.FillZ(STANDARDBUFVALUE);
+	val3.FillZ(STANDARDBUFVALUE);
+	val2[3] = 0x6a;
+	val3[2] = 0x01;
+
+	attrValDES = CSdpAttrValueDES::NewDESL(0);
+	CleanupStack::PushL(attrValDES);
+
+	attrValDES->StartListL()
+			->BuildUintL( value1 ) // speka de english
+			->BuildUintL( val2 )   // UTF-8
+			->BuildUintL( val3 )   // language base
+	->EndListL();
+
+	iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdLanguageBaseAttributeIDList, *attrValDES);
+	CleanupStack::PopAndDestroy();
+	attrValDES = 0;
+
+	// Set Attr 0x007 (time to live) to 600 (0x258) seconds (10 minutes)
+	//initialise buffer
+	value1.FillZ(4);
+	value1[2]=2;
+	value1[3]=0x58;
+
+	attrVal = CSdpAttrValueUint::NewUintL( value1 );
+	CleanupStack::PushL( attrVal );
+	iSdpDatabaseSession.UpdateAttributeL( iRecHandle, KSdpAttrIdServiceInfoTimeToLive, *attrVal );
+	CleanupStack::PopAndDestroy(); //attrVal 
+	attrVal = 0;
+
+	//Set Attr 0x08 (availability) to 0xff - fully available - not in use
+	//initialise
+	TBuf8<1> val4;
+	val4.FillZ(1);
+	val4[0]=0xff;
+	
+	attrVal = CSdpAttrValueUint::NewUintL(val4);
+	CleanupStack::PushL(attrVal);
+	iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdServiceAvailability, *attrVal);
+	CleanupStack::PopAndDestroy(); //attrVal 
+	attrVal = 0;
+
+	//Set Attr 0x201 (service database state) to 0
+	//initialise
+	value1.FillZ(4);
+	
+	attrVal = CSdpAttrValueUint::NewUintL(value1);
+	CleanupStack::PushL(attrVal);
+	iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdSdpServerServiceDatabaseState, *attrVal);
+	CleanupStack::PopAndDestroy(); //attrVal
+	attrVal = 0;
+
+	return KSTErrSuccess;
+}
+
+/********************************************************************************
+ *
+ * CStatTransportBT -- Active Object
+ *
+ *******************************************************************************/
+void CStatTransportBT::RunL( void )
+{
+	TInt error = KErrNone;
+
+	// if there was an error during connecting then tell the engine this
+	if( (iBTTransportStatus == EConnectingSockets) && (iStatus != KErrNone) ) {
+
+		iTransport->HandleError( KSTErrConnectFailure, (void*)iStatus.Int() );
+		return;
+	}
+
+    // the other end have disconnected. just cleanup the resource by calling Disconnect function.
+    if(iStatus == KErrDisconnected && iBTTransportStatus == EConnected) {
+
+        Disconnect();
+        return;
+    }
+
+	// if there was any other error then also tell the engine about it
+	if( (iStatus != KErrNone) && NOTISDISCONNECTING(iBTTransportStatus) ) {
+
+		iTransport->HandleError( KSTErrGeneralFailure, (void*)iStatus.Int() );
+		return;
+	}
+
+	// Now we are registered with the security manager, reg with the SDP
+	if( iBTTransportStatus == EConnectingRegisterMgr ) 
+	{
+		// start the socket and make it listen (async call)
+		error = StartSocketL();
+		if( error != KSTErrSuccess ) 
+		{
+			iTransport->HandleError( error, (void*)iStatus.Int() );
+			return;
+		}
+
+		iBTTransportStatus = EConnectingSockets;
+		return;
+	}
+
+	// We are now connected
+	if( iBTTransportStatus == EConnectingSockets ) 
+	{
+		iBTTransportStatus = EConnected;
+		iTransport->HandleConnect( KErrNone );
+		return;
+	}
+
+	// handle unregister service
+	if( iBTTransportStatus == EDisconnectingUnregister ) {
+		HandleAsyncDisconnect();
+		return;
+	}
+		
+	// handle shutdown data socket
+	if( iBTTransportStatus == EDisconnectingData ) {
+		iDataSocket.Close();
+		iListenSocket.Shutdown( RSocket::ENormal, iStatus );
+		SetActive();
+		iBTTransportStatus = EDisconnectingListen;
+		return;
+	}
+
+	// handle shutdown listen
+	if( iBTTransportStatus == EDisconnectingListen ) {
+		iListenSocket.Close();
+		iBTTransportStatus = EDisconnected;
+		iSocketServ.Close();
+		iTransport->HandleDisconnect( KErrNone );
+		return;
+	}
+
+	// if we are writing then notify of the write
+	if( iRWStatus == EWritePending ) {
+		iRWStatus = ENoRW;
+		asserte( iWrCommandData != NULL );
+		iTransport->HandleSend( KErrNone );
+		return;
+	}
+
+	// if we are reading then notify of the read
+	if( iRWStatus == EReadPending ) {
+		iRWStatus = ENoRW;
+		TInt length = iRecvBufferPtr->Length( );
+		iTransport->HandleReceive( KErrNone, iRecvBufferPtr, length );
+		return;
+	}
+}
+
+//------------------------------------------------------------------------------
+
+void CStatTransportBT::DoCancel( void )
+{
+	// if we are connecting then cancel the connect() call
+	if( iBTTransportStatus == EConnectingSockets )
+		{
+		iListenSocket.CancelAccept();
+		}
+
+	if( iRWStatus == EReadPending )
+		{
+		iDataSocket.CancelRead();
+		}
+
+	if( iRWStatus == EWritePending )
+		{
+		iDataSocket.CancelWrite();
+		}
+
+	iRWStatus = ENoRW;
+}
+
+
+//------------------------------------------------------------------------------
+//
+// Handle async disconnect is called by the RunL when we get a successful response 
+// to the unregister service request. We can now shutdown the transport normally,
+// but we have to know which state it had reached.
+//
+//------------------------------------------------------------------------------
+void CStatTransportBT::HandleAsyncDisconnect( void )
+{
+	TInt tv = KErrNone;
+
+	if(iRecHandle != NULL)
+	{
+		//Close the SDP database objects and delete the record
+		TRAP( tv, iSdpDatabaseSession.DeleteRecordL( iRecHandle) );
+		if( tv != KErrNone ) 
+		{
+			_LIT(KErrDelRecord,"An error occured while deleting the SDP record.");
+
+			iTransport->HandleInfo(&KErrDelRecord);
+		}
+	}
+	
+	iSdpDatabaseSession.Close();
+	iSdpSession.Close();
+	iRecHandle = NULL;
+
+	// clean up the sockets depending on the state
+	switch( iBTTransportDisconnectStatusBeforeUnregister ) {
+
+	case EConnected:
+		iDataSocket.Shutdown( RSocket::ENormal, iStatus );
+		SetActive();
+		iBTTransportStatus = EDisconnectingData;
+		break;
+
+	case EConnecting:
+	case EDisconnectingData:
+		iDataSocket.Close();
+		iListenSocket.Shutdown( RSocket::ENormal, iStatus );
+		SetActive();
+		iBTTransportStatus = EDisconnectingListen;
+		break;
+
+	case EInitialised:
+	case EDisconnectingListen:
+    case EConnectingRegisterMgr:
+		// initialised may mean that ConnectL threw an error -- so close the resources
+		iDataSocket.Close();
+		iListenSocket.Close();
+		iSocketServ.Close();
+		iTransport->HandleDisconnect( KErrNone );
+		break;
+
+	default:
+		;
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/src/stat_comdecoder.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,2700 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+#include <hal.h>
+
+#ifndef LIGHT_MODE
+	#include <eikenv.h>
+	#include <apgtask.h>	//for TApaTask usage
+	#include <apgwgnam.h>	//for CApaWindowGroupName usage
+#endif
+#include "assert.h"
+#include "stat.h"
+#include "statapi_commanddecoder.h"
+#include "keycodes.h"
+#include "modifiers.h"
+#include "statapi_deviceinformation.h"
+#include "datasupplier_memory.h"
+#include "datasupplier_file.h"
+#include "dataconsumer_memory.h"
+#include "test/testshareddata.h"
+#include "test/tefshareddata.h"
+
+#ifndef LIGHT_MODE
+#include <s32mem.h>
+#include "appinstall.h"
+#endif // ifndef LIGHT_MODE
+// This redefinition is because CTRL ends in an L and so is picked up (incorrectly) by leavescan
+#define	  CTRLA CTRL
+
+#define   ESTATNoMoreKeys (EStdKeyDecBrightness+1)
+
+#define	  ESMLShift		1
+#define	  ESMRShift		2
+#define	  ESMLAlt		4
+#define   ESMRAlt		8
+#define   ESMLCtrl	    16
+#define   ESMRCtrl	    32
+#define   ESMLFunc		64
+#define	  ESMRFunc		128
+
+const TInt KMaxSharedDataName	= 128;
+const TInt KMaxSharedDataString	= 1048;
+
+#ifndef LIGHT_MODE
+_LIT8( newLine, "\r\n" );
+_LIT8( driveFormat, "%c,%S,%Ld%S" );
+_LIT8( entryFormat, "%S,%d,%S,%d%S" );
+_LIT8( dateFormat, "%02d/%02d/%04d %02d:%02d" );
+
+#endif // ifndef LIGHT_MODE
+
+//-----------------------------------------------------------------------------------
+//constructor
+CStatApiCommandDecoder::CStatApiCommandDecoder()
+: iFs( NULL ), pMsg(NULL)
+{
+}
+
+//-----------------------------------------------------------------------------------
+
+CStatApiCommandDecoder* CStatApiCommandDecoder::NewL(RFs *const aSession, MNotifyLogMessage *const aMsg)
+{	
+	CStatApiCommandDecoder* self = new(ELeave) CStatApiCommandDecoder();
+
+	CleanupStack::PushL(self);
+	
+	self -> ConstructL(aSession, aMsg);
+	
+	CleanupStack::Pop();
+	
+	return self;
+}
+
+//-----------------------------------------------------------------------------------
+
+void CStatApiCommandDecoder::ConstructL(RFs *const aSession, MNotifyLogMessage *const aMsg)
+{
+#ifndef LIGHT_MODE
+	// Try to connect to the window session server.
+	// Do not leave if there is an error as we may be in a
+	// text only mode (text shell) and the window server is not
+	// available.
+	// We carry on for now but certain features of the command
+	// decoder will become 'unsupported' and will fail.
+	//creation of a new windows server session
+	if(iWs.Connect() != KErrNone) {
+		return;
+	}
+	// This line is for debug purposes.
+	// It is replicated in the function 'IsWindowServerAvailable'.
+	// TInt wsHandle = iWs.WsHandle();
+#endif // ifndef LIGHT_MODE
+
+	iFs = aSession;
+	pMsg = aMsg;
+
+#ifndef LIGHT_MODE
+	if(IsWindowServerAvailable())
+		{
+		// Only start the font and bitmap server if we are in
+		// window shell mode.
+		User::LeaveIfError(FbsStartup());
+		User::LeaveIfError(RFbsSession::Connect());	//font and bitmap server
+
+		// Create the data we use for screen capture.
+		// Do this just once and re-use for each screen image.
+	    iDevice = new(ELeave) CWsScreenDevice(iWs);	//Create new bitmap
+	    iDevice -> Construct();
+
+		// create new bitmap
+		screenBitmap = new(ELeave) CWsBitmap(iWs);	//Create new bitmap
+
+		// set the display mode for the bitmap
+		TInt gray;	
+		TInt color;
+		TDisplayMode mode = iWs.GetDefModeMaxNumColors(color, gray);
+
+		TSize size = iDevice -> SizeInPixels();
+
+		TInt ret = screenBitmap->Create(size, mode);
+
+		if (ret != KErrNone)
+			{
+			User::Leave(ret);
+			}
+		}
+#endif // ifndef LIGHT_MODE
+
+    HAL::Get(HALData::EMachineUid, iUIDValue);;
+    
+    //set system drive
+   
+	TDriveNumber defaultSysDrive(EDriveC);
+	RLibrary pluginLibrary;
+	TInt pluginErr = pluginLibrary.Load(KFileSrvDll);
+	
+	if (pluginErr == KErrNone)
+		{
+		typedef TDriveNumber(*fun1)();
+		fun1 sysdrive;
+	
+	#ifdef __EABI__
+		sysdrive = (fun1)pluginLibrary.Lookup(336);
+	#else
+		sysdrive = (fun1)pluginLibrary.Lookup(304);
+	#endif
+		if(sysdrive!=NULL)
+			{
+			defaultSysDrive = sysdrive();			
+			}
+		}
+	pluginLibrary.Close();
+	
+	iSystemDrive.Append(TDriveUnit(defaultSysDrive).Name());
+	iSystemDrive.Append(KFileSeparator);
+
+    
+    
+
+	RefreshStatus( );
+}
+
+//-----------------------------------------------------------------------------------
+//destructor
+CStatApiCommandDecoder::~CStatApiCommandDecoder()
+{
+#ifndef LIGHT_MODE
+	// Clean-up objects created for screen capture.
+     if(iDevice != NULL)
+     {
+         delete iDevice;
+     }
+ 
+    if(screenBitmap != NULL)
+     {
+         delete screenBitmap;
+     }
+
+     RFbsSession::Disconnect();
+     iWs.Close();
+#endif // ifndef LIGHT_MODE
+}
+
+//------------------------------------------------------------------------------
+//
+// Do whatever the user requested
+//
+TInt CStatApiCommandDecoder::ExecuteCommand(TUint commandtype,
+	MDataConsumer *const aDataConsumer, MDataSupplier **aDataSupplier)
+{
+	TInt ret = KErrNone;
+	TInt exp = KErrNone;
+
+	TInt commandLength = 0;
+
+	if (aDataConsumer)
+		{
+		aDataConsumer->GetTotalSize(commandLength);
+		pMsg->Msg (_L("DECODER: Decoding [%c] with [%d] bytes of data"), commandtype, commandLength);
+		}
+	else
+        {
+		pMsg->Msg (_L("DECODER: Decoding [%c]"), commandtype);
+        }
+
+	// make local copy but not for raw data (Transfer file command), Keypress or WriteTEFSharedData
+	command.Zero();
+	if (commandtype != 'T' && commandtype != 'K' && commandtype != 'O' &&
+		aDataConsumer && commandLength)
+		{
+		command.Copy( *(aDataConsumer) );
+		}
+
+	// Screen saver activates regardless of activity.
+	// Will check for navigation and keypresses here and reset the 
+	// inactivity timer.
+	// Ultimately, this should be handled by lower layer key 
+	// event processing.
+	if (commandtype == 'K' || commandtype == 'L' || 
+		commandtype == 'M' || commandtype == 'H')
+	{
+		User::ResetInactivityTime();
+	}
+
+	// Check if we are doing a command that depends upon the
+	// window session server or the application architecture
+	// (which may not be available if we are in text shell mode).
+	// If there is no window server or application architecture
+	// then we do not support:
+	// SendText, SendSystemKey, SendCombinationKeys,
+	// SendKeyHold, StopApplicationL, OpenIcon,
+	// OpenFile, StartESHell, Screenshot and
+	// StartApplication.
+	if (commandtype == 'K' || commandtype == 'L' || 
+		commandtype == 'M' || commandtype == 'H' ||
+		commandtype == 'C' || commandtype == 'I' ||
+		commandtype == 'F' || commandtype == '!' ||
+		commandtype == 'A' || commandtype == 'S' )
+		{
+
+		if( ! IsWindowServerAvailable())
+			{
+			ret = KErrNotSupported;
+			}
+		}	
+
+	if(ret == KErrNone)
+		{
+		//check message header type
+		switch (commandtype)
+			{
+
+			case ('K'):
+				{
+                if (aDataConsumer && commandLength)
+                    {
+					ret = SendText(aDataConsumer, commandLength);
+                    }
+				}
+				break;
+			case ('L'):
+				ret = SendSystemKeys();
+				break;
+			case ('M'):
+				ret = SendCombinationKeys();
+				break;
+			case ('H'):
+				ret = SendKeyHold();
+				break;
+			case ('A'):
+				TRAP( exp, (ret = StartApplicationL()) );
+				ret = ((exp != KErrNone) ? exp : ret);
+				break;
+			case ('J'):
+				TRAP( exp, (ret = StartProgramL(aDataSupplier)) );
+				ret = ((exp != KErrNone) ? exp : ret);
+				break;
+			case ('C'):
+				TRAP(ret, StopApplicationL());
+				break;
+			case ('F'):
+				TRAP( exp, (ret = OpenFileL()) );
+				ret = ((exp != KErrNone) ? exp : ret);
+				break;
+			case ('I'):
+				ret = OpenIcon();
+				break;
+			case ('!'):
+                if(command.Length() == 0)
+                    {
+                    TRAP(ret, StartEShellL());
+                    }
+                else
+                    {
+                    if(command == _L("!"))
+                        {
+                        TRAP(ret, StopEShellL());
+                        }
+                    }
+				break;
+			case ('U'):
+				TRAP( exp, ret = DeleteFileL() );
+				ret = ((exp != KErrNone) ? exp : ret);
+				break;
+			case ('2'):
+                if(aDataConsumer) 
+                    {
+                    TRAP( exp, ret = RenameFileL(aDataConsumer) );
+                    ret = ((exp != KErrNone) ? exp : ret);
+                    }
+				break;
+			case ('1'):
+                if(aDataConsumer)
+                    {
+                    ret = CheckLocation(aDataConsumer);
+                    }
+				break;
+			case ('Y'):
+				ret = CreateFolder();
+				break;
+			case ('Z'):
+				ret = RemoveFolder();
+				break;
+			case ('T'):
+                if(aDataConsumer)
+                    {
+                    ret = TransferFile(aDataConsumer);
+                    }
+				break;
+			case ('R'):
+                if(aDataConsumer)
+                    {
+                    ret = ReceiveFile(commandtype, aDataConsumer, aDataSupplier);
+                    }
+				break;
+			case ('X'):
+			case ('S'):
+                if(aDataConsumer)
+                    {
+                    ret = ReceiveFile(commandtype, aDataConsumer, aDataSupplier);
+                    }
+				//DeleteLastFile();
+				break;
+			case ('D'):
+				ret = DeviceInfo(aDataSupplier);
+				break;
+			case ('G'):
+				SaveLogFile(aDataSupplier);
+				break;
+			case ('W'):
+				ret = GetDiskDriveInformationL(aDataSupplier);
+				break;
+			case ('V'):
+                if(aDataConsumer)
+                    {
+                    ret = GetDirectoryInformationL(aDataConsumer, aDataSupplier);
+                    }
+				break;
+			case ('B'):
+				RefreshStatus( );
+				break;
+			case ('E'):	// end of script
+				break;
+			case ('?'):	// resync command
+				break;
+			case ('N'): // Retrieve TEF shared data
+				TRAP( exp, ret = ReadTEFSharedDataL( aDataSupplier ) );
+				ret = ((exp != KErrNone) ? exp : ret);
+				break;
+			case ('O'): // Update TEF shared data
+                if(aDataConsumer)
+                    {
+                    TRAP( exp, ret = WriteTEFSharedDataL(aDataConsumer, commandLength) );
+                    ret = ((exp != KErrNone) ? exp : ret);
+                    }
+				break;
+			case ('|'):
+				//emulator restart
+				HAL::Set(HAL::ECustomRestart,1);
+				break;
+			case ('3'):
+				TRAP( exp, (ret = ProgramStatusL(command, aDataSupplier)));
+				ret = ((exp != KErrNone) ? exp : ret);
+				break;
+			case ('~'):
+				TRAP( exp, (ret = StopProgramL(command)) );
+				ret = ((exp != KErrNone) ? exp : ret);
+				break;
+				
+#ifndef LIGHT_MODE
+			case ('+'):	// install command
+				//modify the name in case doesn't contain drive
+				//if the filname starts with a back slash.
+//				if(	command.Find(KFileSeparator)== 0 )
+//					{
+//					//replace the filename with one refering to system drive
+//					command.Delete(0,1);
+//					command.Insert(0, iSystemDrive);
+//					}
+				updatePathWithSysDrive(command) ; 
+				ret = CAppInstall::Install(command);
+				break;	
+			case ('-'):	// uninstall command
+				ret = CAppInstall::Uninstall(command);
+				break;	
+#endif // ifndef LIGHT_MODE
+			
+			default:
+				ret = KErrNotSupported;     
+			}
+		}
+
+	// put the error code into the response
+	if(ret != KErrNone)
+		{
+		if(*aDataSupplier)
+			{
+			(*aDataSupplier)->Delete( );
+			*aDataSupplier = NULL;
+			}
+		AppendErrorCode(ret, aDataSupplier);
+		}
+
+	return ret;
+}
+
+//------------------------------------------------------------------------------
+//
+// Initialise our command handling status.
+//
+void CStatApiCommandDecoder::RefreshStatus(void)
+{
+	iName = 1;
+}
+
+
+//------------------------------------------------------------------------------
+//
+// Delete a file once we've finished with it
+//
+TInt CStatApiCommandDecoder::DeleteLastFile()
+{
+	TInt exp = KErrNone;
+	command = filename;
+	TRAP( exp, DeleteFileL(FALSE) );
+	return exp;
+}
+
+
+//------------------------------------------------------------------------------
+// Function used to decode data received and send text to an app
+// We need to avoid using 'command' buffer because we don't know
+// how big the actual data will be whereas the other commands all fit
+// easily into the 1024 length limit...
+//
+TInt CStatApiCommandDecoder::SendText(
+		MDataConsumer *const aDataConsumer, int commandLength)
+{
+	// Check we have a window server because it is needed by
+	// DoKeyEvent.
+	// If this assert triggers it is because we are running in
+	// text shell mode without a window server and the call
+	// requires the window server to be available.
+	// A command filter in ExecuteCommand should have prevented
+	// this call from being made.
+	assert(IsWindowServerAvailable());
+
+	TInt err = KErrNone;
+	TInt i = 0;
+
+	HBufC8	*keyData = HBufC8::New( commandLength );
+
+	if( ! keyData )
+		{
+		err = KErrNoMemory;
+		}
+
+	if( err == KErrNone )
+		{
+		err = aDataConsumer->GetData( *keyData );
+		}
+
+	if( err == KErrNone )
+		{
+		TBuf16<1> x;
+
+		for(i=0;i<commandLength;i++)
+			{
+			x.Zero();
+			x.Append((*keyData)[i]);
+			DoKeyEvent(static_cast<TInt>(x[0]));
+
+			// Do not delay this thread for any time but simply
+			// give up the rest of our time-slice to allow
+			// the system to process the key event.
+			User::After(0);
+			}
+
+		// Yield here to give the OS time to actually complete this command.
+		User::After(0);
+		}
+
+	if( keyData )
+		{
+		delete keyData;
+		keyData = NULL;
+		}
+
+	return (err);
+}
+
+
+//------------------------------------------------------------------------------
+//
+//Function used to decode data received and send system keys to an app (ie - Menu, LeftArrow etc)
+//
+
+TInt CStatApiCommandDecoder::SendSystemKeys()
+{
+#ifndef LIGHT_MODE
+	// If this assert triggers it is because we are running in
+	// text shell mode without a window server and the call
+	// requires the window server to be available.
+	// A command filter in ExecuteCommand should have prevented
+	// this call from being made.
+	assert(IsWindowServerAvailable());
+
+	TInt ret = KErrArgument;
+	TInt i = 0;
+	TBuf<140> scancodevalue = ENUM_TEXTSCANCODEArray[i];	//scancode strings stored here
+	TBuf<100> keycodevalue = ENUM_TEXTKEYArray[i];			//keycode strings entered here
+
+	// look for correct system command from scancodes first
+	while (scancodevalue.Compare(TPtrC(NO_MORE_SCANCODEKEYS)) != 0)
+	{
+		if (command.Compare(scancodevalue) == 0)
+		{
+			//send using SimulateRawEvent...
+			TRawEvent rawEventa;
+			rawEventa.Set(TRawEvent::EKeyDown, ENUM_VALSCANCODEArray[i]);
+			iWs.SimulateRawEvent(rawEventa);
+			iWs.Flush();
+			
+			rawEventa.Set(TRawEvent::EKeyUp, ENUM_VALSCANCODEArray[i]);
+			iWs.SimulateRawEvent(rawEventa);
+			iWs.Flush();
+
+			ret = KErrNone;
+			break;
+		}
+			
+		i++;	
+		scancodevalue = ENUM_TEXTSCANCODEArray[i];
+	}
+
+	//if there is no scancode then now try the remaining key codes...
+	if(ret != KErrNone)
+	{
+		i = 0;	//reinitialise
+		
+		while (keycodevalue.Compare(TPtrC(NO_MORE_KEYS)) != 0)
+		{
+			if (command.Compare(keycodevalue) == 0)
+			{
+				// set the event
+				DoKeyEvent(ENUM_VALKEYArray[i]);
+				ret = KErrNone;
+				break;
+			}
+				
+			i++;	
+			keycodevalue = ENUM_TEXTKEYArray[i];
+		}
+	}
+
+	return (ret);
+#else // ifndef LIGHT_MODE
+	return (KErrNotSupported);
+#endif // ifndef LIGHT_MODE
+}
+
+
+//------------------------------------------------------------------------------
+//
+//Function used to decode data received and send combination keys to the device (ie - Ctrl+S)
+//
+
+TInt CStatApiCommandDecoder::SendCombinationKeys()
+{
+#ifndef LIGHT_MODE
+	// If this assert triggers it is because we are running in
+	// text shell mode without a window server and the call
+	// requires the window server to be available.
+	// A command filter in ExecuteCommand should have prevented
+	// this call from being made.
+	assert(IsWindowServerAvailable());
+
+	TInt plusposition = 0;					//used for combination key data
+	TInt i = 0;
+	TInt counter = 0;
+	TInt index = 0;
+
+	TBuf<100> input = _L("");
+	
+	TBuf<20> myModifierKey[4];		//there are 4 maximum combination keys that can be used for one command - they will be stored here
+	
+	TKeyEvent event;		//the key event structure
+	TEventModifier em[5];	//modifier keys required for each of the modifiers available (shift, ctrl, func)
+	TKeyCode kp = EKeyNull;
+	
+	//*****Initialisation section*****
+	
+	int a = 0;
+	for (a=0;a<4;a++)
+	{
+		myModifierKey[a] = _L("");
+		myModifierKey[a].SetLength(0);
+	}
+
+	int b = 0;
+	for (b=0;b<5;b++)
+	{
+		em[b] = (TEventModifier)0;
+	}
+	
+	//********************************
+	
+	TInt DataLength = command.Length();	//copy passed data length into local variable
+
+	//The following section splits the data up and puts them into the array
+	while ((DataLength >= 1) && (counter <= 4))		//while length > 1
+	{
+		plusposition = command.Locate('+');	//search for this char
+
+		if (plusposition != KErrNotFound)
+		{
+			myModifierKey[counter] = command.Left(plusposition);	//chars left of plus are stored
+			command.Delete(0, (plusposition + 1));					//delete all chars from pos 0 up to and including '+' with null terminator
+			counter++;
+		}
+		else	//no more '+' in string
+		{
+			myModifierKey[counter] = command.Left(command.Length());//store remaining string into array
+			command.Delete(0, plusposition + 1);					//delete remaining string
+			counter = 5;										//make sure exits
+		}
+	}
+	
+	counter = 0;
+	event.iCode = 0;
+	event.iScanCode = 0;
+	event.iRepeats = 0;
+	event.iModifiers = 0;	//initialisation
+	
+	//now check the new data in each of the elements in the array
+	while (counter <= 4)
+	{
+		input = myModifierKey[counter];	//assign value from string
+
+		if (input == _L("Ctrl")  || input == _L("LeftCtrl")  || input == _L("RightCtrl") 
+			|| input == _L("Shift") || input == _L("LeftShift") || input == _L("RightShift") 
+			|| input == _L("Func") || input == _L("LeftFunc") ||  input == _L("RightFunc") 
+			|| input == _L("Alt") ||  input == _L("LeftAlt") || input == _L("RightAlt"))
+		{
+			TBuf<100> value;
+			value = ENUM_TEXTMODIFIERSArray[i];	//assign initial data in array to value (element 0)
+
+			while (value.Compare(TPtrC(NO_MORE_MODIFIERKEYS)) != 0)	//make sure not end of array
+			{
+				if (input.Compare(value) == 0)	//if the string has been found in the text array
+				{
+					em[counter] = ENUM_VALMODIFIERSArray[i];	//assign em element with the same value from the val array by comparing counter num (location)
+					i = 0;	//reinitialise so that the search can restart at the beginning of the enumerated type list
+					break;
+				}
+				
+				i++;
+				value = ENUM_TEXTMODIFIERSArray[i];	//update contents of value for the next pass
+			}	//end while
+		}
+		else	//no combination keys left
+		{
+			if (input.Length() > 1)	//if the remaining data is longer than 1 char (ie - could be 'LeftArrow')
+			{
+				TBuf<100> valuekey;
+				valuekey = ENUM_TEXTKEYArray[i];	//assign initial data in array to value (element 0)
+
+				while (valuekey.Compare(TPtrC(NO_MORE_KEYS)) != 0)	//make sure not end of array
+				{
+					if (input.Compare(valuekey) == 0)	//if the string has been found in the text array
+					{
+						//kp.iScanCode = ENUM_VALKEYArray[i]; 
+						kp = ENUM_VALKEYArray[i]; //assign kp with the same value from the val array
+
+						if(kp < ENonCharacterKeyBase)
+						{
+							event.iCode = kp;
+							em[2] = EModifierPureKeycode;
+							index = 3;
+							counter = 5;
+						}
+						else
+						{
+							event.iCode = kp;
+							index = 3;
+							counter = 5;
+						}
+
+						break;
+
+					}	//end if
+				
+					i++;	
+					valuekey = ENUM_TEXTKEYArray[i];	//update contents of value for the next pass
+				}
+			}
+			else	//must be single char combination, so pass into iCode and set counter to four to exit!
+			{
+				input.LowerCase();
+
+				while (index < 3)	//need to check array and see if need to send CTRL or not
+				{
+					if ((em[index] == EModifierLeftCtrl) || (em[index] == EModifierRightCtrl) || (em[index] == EModifierCtrl))
+					{
+						event.iCode = CTRLA(input.Ptr()[0]);
+						counter = 4;
+						break;
+					}
+					else
+					{
+						event.iCode = input.Ptr()[0];
+						index++;
+						counter = 4;
+					}
+				}
+			}
+
+			event.iModifiers = em[0] | em[1] | em[2];	//used to set up Ctrl+Shift+...etc
+		
+		}	//end else
+
+		counter++;
+		input = _L("");	//reinitialise for next pass
+	
+	}	//end while
+
+
+	iWs.SimulateKeyEvent(event);		// send keystroke
+	iWs.Flush();						// flush client-side window server buffer
+
+	return KErrNone;
+#else // ifndef LIGHT_MODE
+	return (KErrNotSupported);
+#endif // ifndef LIGHT_MODE
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+//
+//Function used to hold down keys
+//
+////////////////////////////////////////////////////////////////////////////////////////////
+TInt CStatApiCommandDecoder::ConvertKeycodeToScancode( TDesC& key, TInt& scancode, TInt& modifiers )
+{
+	TInt i, j;
+	TBuf<20> base_punctuation( _L("`,./\\;'#[]-=/*-") );
+	TBuf<20> shift_punctuation( _L("?>?|:@~{}_+XX_") );
+	TBuf<20> numeric_punctuation( _L(")!\"?%^&*(") );
+
+	// clear the modifiers field
+	modifiers = 0;
+
+	// make sure the key is not completely empty
+	if( key.Length() == 0 ) {
+		return -1;
+	}
+
+	// If the key is longer than one char then it must be a special key that we need to
+	// lookup in the table. If it's not in the table then return error
+	if( key.Length() > 1 ) {
+		for( i = 0; ENUM_TEXTSCANCODEArray[i] != NO_MORE_SCANCODEKEYS; i++ ) {
+			if( key.Compare(TPtrC(ENUM_TEXTSCANCODEArray[i])) == 0 ) {
+				scancode = ENUM_VALSCANCODEArray[i];
+				return 0;
+			}
+		}
+		return -1;
+	}
+
+	// get the first key (saves getting it heaps of times)
+	TChar keycode( key.Ptr()[0] );
+
+	// handle lowercase alpha characters
+	if( keycode.IsAlpha() && keycode.IsLower() ) {
+		keycode.UpperCase();
+		scancode = keycode;
+		return 0;
+	}
+
+	// handle uppercase alpha characters
+	if( keycode.IsAlpha() && keycode.IsUpper() ) {
+		scancode = keycode;
+		modifiers = ESMLShift;
+		return 0;
+	}
+
+	// handle numbers
+	if( keycode.IsDigit() ) {
+		scancode = keycode;
+		return 0;
+	}
+
+	// handle punctuation -- just offset by 36 for some unknown reason
+	if( keycode.IsPunctuation() ) {
+
+		j = base_punctuation.Locate( keycode );
+		if( j != KErrNotFound ) {
+			scancode = 120 + j;
+			return 0;
+		}
+
+		j = shift_punctuation.Locate( keycode );
+		if( j != KErrNotFound ) {
+			scancode = 120 + j;
+			modifiers = ESMLShift;
+			return 0;
+		}
+
+		j = numeric_punctuation.Locate( keycode );
+		if( j != KErrNotFound ) {
+			scancode = '0' + j;
+			modifiers = ESMLShift;
+			return 0;
+		}
+
+		scancode = keycode;
+		return 0;
+	}
+
+	// For some reason certain characters are not recognized as punctuation though they
+	// should be. These are handled specifically here.
+	bool found = false;
+	switch( keycode ) {
+
+	case 0x24:
+		scancode = 0x34;
+		modifiers = ESMLShift;
+		found = true;
+		break;
+
+	case 0xa3:
+		scancode = 0x33;
+		modifiers = ESMLShift;
+		found = true;
+		break;
+
+	case 0x80:
+		scancode = 0x34;
+//		modifiers = ESMRFunc | ESMLCtrl;
+		modifiers = ESMRAlt;
+		found = true;
+		break;
+
+	case 0xa6:
+		scancode = 0x78;
+		modifiers = ESMRFunc;
+		found = true;
+		break;
+	}
+
+	if (found)
+		return 0;
+	else
+	// key not found
+		return -1;
+}
+
+TInt CStatApiCommandDecoder::SendKeyHold()
+{
+#ifndef LIGHT_MODE
+	// If this assert triggers it is because we are running in
+	// text shell mode without a window server and the call
+	// requires the window server to be available.
+	// A command filter in ExecuteCommand should have prevented
+	// this call from being made.
+	assert(IsWindowServerAvailable());
+
+	TLex Lexcounter;
+	TInt key_action = 0;
+	TRawEvent rawEventa;
+	TInt scancodefound;
+	TInt scancode;
+	TInt modifiers;
+
+	// H commands must have the format <HC,N> where 'C' is the command to be executed and
+	// N is either -1 (key up) or 0 (key down)
+	TInt commaposition = command.Locate(',');
+	if( commaposition == KErrNotFound ) {
+		return KErrArgument;
+	}
+
+	// convert the key action from a string to an integer	
+	Lexcounter = command.Mid( commaposition + 1 );
+	Lexcounter.Val( key_action );
+
+	// get the scancode for the key
+	command.SetLength( commaposition );
+	scancodefound = ConvertKeycodeToScancode( command, scancode, modifiers );
+	if( scancodefound == -1 ) {
+		return KErrArgument;
+	}
+
+	// set the appropriate modifier keys
+	if( modifiers & ESMLShift ) {
+		rawEventa.Set(TRawEvent::EKeyDown, EStdKeyLeftShift);
+		iWs.SimulateRawEvent(rawEventa);
+		iWs.Flush();
+	}
+	if( modifiers & ESMRFunc ) {
+		rawEventa.Set(TRawEvent::EKeyDown, EStdKeyRightFunc);
+		iWs.SimulateRawEvent(rawEventa);
+		iWs.Flush();
+	}
+	if( modifiers & ESMRAlt ) {
+		rawEventa.Set(TRawEvent::EKeyDown, EStdKeyRightAlt);
+		iWs.SimulateRawEvent(rawEventa);
+		iWs.Flush();
+	}
+	if( modifiers & ESMLCtrl ) {
+		rawEventa.Set(TRawEvent::EKeyDown, EStdKeyLeftCtrl);
+		iWs.SimulateRawEvent(rawEventa);
+		iWs.Flush();
+	}
+
+	// now handle the key_action -1 == key_up, 0 == key_down, > 0 == milliseconds to hold the key down
+	switch( key_action ) {
+
+	case -1:
+		rawEventa.Set(TRawEvent::EKeyUp, scancode);
+		iWs.SimulateRawEvent(rawEventa);
+		iWs.Flush();
+		break;
+
+	case 0:
+		rawEventa.Set(TRawEvent::EKeyDown, scancode);
+		iWs.SimulateRawEvent(rawEventa);
+		iWs.Flush();
+		break;
+
+	default:
+		rawEventa.Set(TRawEvent::EKeyDown, scancode);
+		iWs.SimulateRawEvent(rawEventa);
+		iWs.Flush();
+
+		key_action *= 1000;
+		User::After(TTimeIntervalMicroSeconds32(key_action));
+		
+		rawEventa.Set(TRawEvent::EKeyUp, scancode);
+		iWs.SimulateRawEvent(rawEventa);
+		iWs.Flush();
+		break;
+	}
+
+	// release appropriate function keys
+	if( modifiers & ESMLShift ) {
+		rawEventa.Set(TRawEvent::EKeyUp, EStdKeyLeftShift);
+		iWs.SimulateRawEvent(rawEventa);
+		iWs.Flush();
+	}
+	if( modifiers & ESMRFunc ) {
+		rawEventa.Set(TRawEvent::EKeyUp, EStdKeyRightFunc);
+		iWs.SimulateRawEvent(rawEventa);
+		iWs.Flush();
+	}
+	if( modifiers & ESMRAlt ) {
+		rawEventa.Set(TRawEvent::EKeyUp, EStdKeyRightAlt);
+		iWs.SimulateRawEvent(rawEventa);
+		iWs.Flush();
+	}
+	if( modifiers & ESMLCtrl ) {
+		rawEventa.Set(TRawEvent::EKeyUp, EStdKeyLeftCtrl);
+		iWs.SimulateRawEvent(rawEventa);
+		iWs.Flush();
+	}
+
+	return KErrNone;
+#else // ifndef LIGHT_MODE
+	return (KErrNotSupported);
+#endif // ifndef LIGHT_MODE
+}
+
+
+//------------------------------------------------------------------------------
+//
+//Function used to start application(s)
+//
+TInt CStatApiCommandDecoder::StartApplicationL()
+{	
+#ifndef LIGHT_MODE
+	// If this assert triggers it is because we are running in
+	// text shell mode without a window server and the call
+	// requires the window server to be available.
+	// A command filter in ExecuteCommand should have prevented
+	// this call from being made.
+	assert(IsWindowServerAvailable());
+
+	TInt ret = KErrNone;
+
+	TBuf<KMaxFileName> docName;
+	CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
+
+	TInt commaposition = command.Locate(',');
+	if (commaposition != KErrNotFound)
+	{
+		// set the application name
+		cmdLine -> SetExecutableNameL(command.Mid(0, commaposition));
+
+		// use document name supplied in command string
+		docName = command.Mid(commaposition + 1);
+	}
+	else
+	{
+		TBuf<10> timestring;
+		TTime DateAndTime;
+		DateAndTime.HomeTime();
+		DateAndTime.FormatL(timestring, (_L("%J%T%S%*B")));
+
+		// create a default document name based on the system date and time
+		
+		docName.Append(iSystemDrive);
+		docName.Append(timestring);
+
+		// set the application name
+		cmdLine -> SetExecutableNameL(command);
+	}
+
+	cmdLine -> SetDocumentNameL(docName);
+	cmdLine -> SetCommandL(EApaCommandCreate);
+
+	if( ret == KErrNone )
+		{
+		//initialise
+		ret = iApaS.Connect();
+		if(ret != KErrNone)
+			pMsg->Msg (_L("DECODER: Application Architecture server error [%c]"), ret);
+		}
+
+	if( ret == KErrNone )
+		{
+		// startup
+		ret = iApaS.StartApp(*cmdLine);
+		if(ret != KErrNone)
+			pMsg->Msg (_L("DECODER: Unable to start application [%c]"), ret);
+		}
+
+	//cleanup
+	iApaS.Close();
+	CleanupStack::PopAndDestroy();
+
+	if( ret == KErrNone )
+		{
+		// need to sleep a bit here to give the OS time to actually start the application
+		User::After(3000000);
+		}
+
+	return (ret);
+#else // ifndef LIGHT_MODE
+	return (KErrNotSupported);
+#endif // ifndef LIGHT_MODE
+}
+
+//------------------------------------------------------------------------------
+//
+//Function used to start executables(s)
+//
+TInt CStatApiCommandDecoder::StartProgramL(MDataSupplier **aDataSupplier)
+{	
+	TInt ret = KErrNone;
+
+	TBuf<KMaxFileName> programName;
+	TBuf<KMaxFileName> parameters;
+
+	TInt commaposition = command.Locate(',');
+	if (commaposition != KErrNotFound)
+	{
+		// set the program name
+		programName = command.Mid(0, commaposition);
+
+		// set the parameters
+		parameters = command.Mid(commaposition + 1);
+	}
+	else
+	{
+		programName = command;
+	}
+
+	updatePathWithSysDrive(programName) ; 
+	updatePathWithSysDrive(parameters) ; 
+	RProcess newProcess;
+	ret = newProcess.Create(programName,parameters);
+	
+	if(ret == KErrNone)
+		{
+		
+		TProcessId handle = newProcess.Id();
+		
+		if(ret == KErrNone)
+		{
+			newProcess.Resume();
+			newProcess.Close(); // get rid of our handle
+		}
+		
+		// Return the PID
+		
+		CDataSupplierMemory	*pDataSupplier = CDataSupplierMemory::NewL( );
+		
+		TBuf8<50> handleNumber;
+		
+		handleNumber.Num(handle.Id());
+		
+		TInt err;
+
+		if (pDataSupplier)
+			{
+			// Set the data in the data supplier.
+			err = pDataSupplier->SetData( handleNumber );
+
+			if (err != KErrNone)
+				{
+				pMsg->Msg(_L("Failed to set data in data supplier") );
+				}
+			}
+		else
+			{
+			err = KErrNoMemory;
+			pMsg->Msg(_L("Failed to create data supply object") );
+			}
+
+		if (err == KErrNone)
+			{
+			*aDataSupplier =	pDataSupplier;
+			}
+		else
+			{
+			if (pDataSupplier)
+				{
+				pDataSupplier->Delete( );
+				pDataSupplier = NULL;
+				}
+			}
+		}
+	
+	return ret;
+}
+
+//------------------------------------------------------------------------------
+//
+//Function used to close application in foreground
+//
+void CStatApiCommandDecoder::StopApplicationL()
+{
+#ifndef LIGHT_MODE
+	// If this assert triggers it is because we are running in
+	// text shell mode without a window server and the call
+	// requires the window server to be available.
+	// A command filter in ExecuteCommand should have prevented
+	// this call from being made.
+	assert(IsWindowServerAvailable());
+
+	TInt AppIdentifier = 0;
+	TThreadId ThreadIdentifier;
+
+	AppIdentifier = iWs.GetFocusWindowGroup();	//retrieves identifier of the window group that currently has the keyboard focus
+	
+	TInt ret = iWs.GetWindowGroupClientThreadId(AppIdentifier, ThreadIdentifier);
+	if(ret == KErrNone)
+	{
+		TInt prev = 0;
+		TInt winGid = iWs.FindWindowGroupIdentifier(prev, ThreadIdentifier); //Get identifier by thread ID
+		
+		TApaTask task(iWs);
+		task.SetWgId(winGid);
+		
+		if (task.Exists())
+		{
+			CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(iWs, winGid);
+
+			// check if application is busy
+			if (wgName -> IsSystem() || wgName -> IsBusy() || !wgName -> RespondsToShutdownEvent())
+				ret = KErrAccessDenied;
+
+			CleanupStack::PopAndDestroy(); // wgName
+			
+			if(ret == KErrNone)
+				task.SendSystemEvent(EApaSystemEventShutdown);	//close app
+		}
+		else
+		{
+			ret = KErrNotFound;	//return error if task is non-existent
+		}
+	}
+
+	User::Leave(ret);
+#endif // ifndef LIGHT_MODE
+}
+
+//
+//Function used to close application in foreground
+//
+void CStatApiCommandDecoder::StopEShellL()
+{
+#ifndef LIGHT_MODE
+	// If this assert triggers it is because we are running in
+	// text shell mode without a window server and the call
+	// requires the window server to be available.
+	// A command filter in ExecuteCommand should have prevented
+	// this call from being made.
+	assert(IsWindowServerAvailable());
+
+	TInt AppIdentifier = 0;
+	TThreadId ThreadIdentifier;
+
+	AppIdentifier = iWs.GetFocusWindowGroup();	//retrieves identifier of the window group that currently has the keyboard focus
+	
+	TInt ret = iWs.GetWindowGroupClientThreadId(AppIdentifier, ThreadIdentifier);
+	if(ret == KErrNone)
+	{
+		TInt prev = 0;
+		TInt winGid = iWs.FindWindowGroupIdentifier(prev, ThreadIdentifier); //Get identifier by thread ID
+		
+		TApaTask task(iWs);
+		task.SetWgId(winGid);
+		
+		if (task.Exists())
+		{
+			CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(iWs, winGid);
+
+			// check if application is busy
+			if (wgName -> IsSystem())
+				ret = KErrAccessDenied;
+			else
+				{
+				RThread newThread;
+				RProcess newProcess;
+
+				ret = newThread.Open(ThreadIdentifier);
+				if(ret == KErrNone)
+					{
+					ret = newThread.Process(newProcess);
+					if(ret == KErrNone)
+						{
+                        if(newProcess.FileName().Right(10).CompareF(_L("eshell.exe")) == 0)
+                            {
+                            newProcess.Kill(1);
+                            }
+                        else
+                            {
+                            ret = KErrNotFound;
+                            }
+                        newProcess.Close();	
+						}
+					newThread.Close();
+					}
+				}
+
+			CleanupStack::PopAndDestroy(); // wgName
+		}
+		else
+		{
+			ret = KErrNotFound;	//return error if task is non-existent
+		}
+	}
+
+	User::Leave(ret);
+#endif // ifndef LIGHT_MODE
+}
+
+//------------------------------------------------------------------------------
+//
+//Function used to read some TEF shared data
+//
+
+TInt CStatApiCommandDecoder::ReadTEFSharedDataL( MDataSupplier **aDataSupplier )
+	{
+	TInt ret = KErrNone;
+	
+	TBuf<KMaxSharedDataName>	sharedDataName;
+
+	// Set the shared data name
+	TInt length = command.Length();
+	if( length > 0 && length < KMaxSharedDataName )
+		{
+		sharedDataName.Zero();
+		sharedDataName.Copy( command );	
+		sharedDataName.ZeroTerminate();
+		}
+	else
+		{
+		ret = KErrArgument;
+		}
+	
+	// Now read the shared data area
+	if( ret == KErrNone )
+		{
+		// Read the shared data from the global RChunk
+		HBufC*	buffer = NULL;
+		CTestSharedData* sharedDataObject = NULL;
+		CTEFSharedData<CTestSharedData> *tefSharedData = CTEFSharedData<CTestSharedData>::NewLC(	sharedDataObject,
+																									sharedDataName );
+		if( sharedDataObject != NULL )
+			{
+			tefSharedData->EnterCriticalSection();
+			TRAP( ret, buffer = HBufC::NewL(sharedDataObject->TextLength()) );
+			if( ret == KErrNone )
+				{
+				TPtr bufferPtr( buffer->Des() );
+				sharedDataObject->GetText( bufferPtr );
+				tefSharedData->ExitCriticalSection();
+
+				// Create the response data supplier
+				CDataSupplierMemory	*pDataSupplier = NULL;
+				TRAP( ret, pDataSupplier = CDataSupplierMemory::NewL() );
+				if( pDataSupplier && ret == KErrNone )
+					{
+					HBufC8 *buffer8 = NULL;
+					TRAP( ret, buffer8 = HBufC8::NewL(buffer->Length()) );
+					if( ret == KErrNone )
+						{
+						TPtr8 buffer8Ptr( buffer8->Des() );
+						buffer8Ptr.Copy( buffer->Des() );
+						
+						// Set the data in the data supplier.
+						ret = pDataSupplier->SetData( *buffer8 );
+
+						// Cleanup
+						delete buffer8;
+						}
+
+					if( ret != KErrNone )
+						{
+						pMsg->Msg(_L("Failed to set data in data supplier") );
+						}
+					}
+				else
+					{
+					ret = KErrNoMemory;
+					pMsg->Msg(_L("Failed to create data supply object") );
+					}
+
+				if (ret == KErrNone)
+					{
+					*aDataSupplier =	pDataSupplier;
+					}
+				else
+					{
+					if (pDataSupplier)
+						{
+						pDataSupplier->Delete( );
+						pDataSupplier = NULL;
+						}
+					}
+				}
+
+			delete buffer;
+			}
+		else
+			{
+			ret = KErrNotFound;
+			}
+		CleanupStack::PopAndDestroy(tefSharedData);
+		}
+
+	return ret;
+	}
+
+//------------------------------------------------------------------------------
+//
+//Function used to write some TEF shared data
+//
+
+TInt CStatApiCommandDecoder::WriteTEFSharedDataL( MDataConsumer *const aDataConsumer, int commandLength )
+	{
+	TInt ret = KErrNone;
+	
+	// Retrieve the data
+	if( commandLength <= KMaxSharedDataString )
+		{
+		HBufC8* sharedDataString = HBufC8::NewLC( commandLength );
+		if( aDataConsumer != NULL )
+			{
+			ret = aDataConsumer->GetData( *sharedDataString );
+
+			// Set the shared data name
+			if( ret == KErrNone )
+				{
+				TBuf<KMaxSharedDataName>	sharedDataName;
+				TInt commaposition = sharedDataString->Locate(',');
+				if( commaposition != KErrNotFound )
+					{
+					if( commaposition < KMaxSharedDataName )
+						{
+						sharedDataName.Zero();
+						sharedDataName.Copy(sharedDataString->Mid(0, commaposition));
+						sharedDataName.ZeroTerminate();
+
+						// Set the shared data value
+						HBufC* sharedDataValue = HBufC::NewLC(commandLength-commaposition+1);
+						TPtr ptrSharedDataValue(sharedDataValue->Des());
+						ptrSharedDataValue.Zero();
+						ptrSharedDataValue.Copy(sharedDataString->Mid(commaposition+1));
+						ptrSharedDataValue.ZeroTerminate();
+
+						// Now update the shared data area
+						if( ret == KErrNone )
+							{
+							// Update the shared data with the data passed in
+							CTestSharedData* sharedDataObject = NULL;
+							CTEFSharedData<CTestSharedData> *tefSharedData = CTEFSharedData<CTestSharedData>::NewLC(	sharedDataObject,
+																													sharedDataName );
+							if( sharedDataObject != NULL )
+								{
+								tefSharedData->EnterCriticalSection();
+								// Copy the data contents across
+								// No need to check the data length as it was checked above
+								sharedDataObject->SetText( *sharedDataValue );
+								tefSharedData->ExitCriticalSection();
+								}
+							else
+								{
+								ret = KErrNotFound;
+								}
+
+							CleanupStack::PopAndDestroy(tefSharedData);
+							}
+						
+						// Cleanup
+						CleanupStack::PopAndDestroy(sharedDataValue);	
+						}
+					else
+						{
+						ret = KErrArgument;
+						}
+					}
+				else
+					{
+					ret = KErrArgument;
+					}
+				}			
+			}
+		else
+			{
+			ret = KErrArgument;
+			}
+		CleanupStack::PopAndDestroy(sharedDataString);
+		}
+	else
+		{
+		ret = KErrTooBig;
+		}
+	
+	return ret;
+	}
+
+//------------------------------------------------------------------------------
+//
+//Function used to open file(s)
+//
+
+TInt CStatApiCommandDecoder::OpenFileL()
+{
+#ifndef LIGHT_MODE
+	TInt ret = KErrArgument;
+
+	TBuf<KMaxFileName> docName;
+	CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
+
+	TInt commaposition = command.Locate(',');
+	if (commaposition != KErrNotFound)
+	{
+		// set the application name
+		cmdLine -> SetExecutableNameL(command.Mid(0, commaposition));
+
+		// use document name supplied in command string
+		docName = command.Mid(commaposition + 1);
+
+		updatePathWithSysDrive(docName);
+		cmdLine -> SetDocumentNameL(docName);
+		cmdLine -> SetCommandL(EApaCommandOpen);
+
+		//initialise
+		TRAP(ret, iApaS.Connect())
+		if(ret != KErrNone)
+			pMsg->Msg(_L("DECODER: Application Architecture server error...%d"), ret);
+
+		// startup
+		TRAP(ret, iApaS.StartApp(*cmdLine))
+		if(ret != KErrNone)
+			pMsg->Msg(_L("DECODER: Unable to start application...%d"), ret);
+
+		//cleanup
+		iApaS.Close();
+
+		// need to sleep a bit here to give the OS time to actually start the application
+		User::After(3000000);
+	}
+
+	CleanupStack::PopAndDestroy();
+	return ret;
+#else // ifndef LIGHT_MODE
+	return (KErrNotSupported);
+#endif // ifndef LIGHT_MODE
+}
+//------------------------------------------------------------------------------
+//
+//Function used to capture screens
+//
+
+void CStatApiCommandDecoder::ScreenCaptureL()
+{
+#ifndef LIGHT_MODE
+		
+	//_LIT(KDriveD,  "d:\\");
+
+	// Optimize screen captures by only creating device objects 
+	// once and re-using them.
+	// Create screen device object is now done in 
+	// CStatApiCommandDecoder::ConstructL and removed 
+	// in CStatApiCommandDecoder::~CStatApiCommandDecoder().
+
+    User::LeaveIfError(iDevice->CopyScreenToBitmap(screenBitmap));
+
+	// retrieve machine id information
+	TBuf<20> buffer;
+    buffer.Num(iUIDValue);
+
+    TBuf<KMaxFileName> tempfilename;
+    
+    tempfilename.Append(iSystemDrive); 
+	tempfilename.Append(buffer);
+	tempfilename.Append(_L("00"));				//substation id
+
+	// create date/time string for filename
+	TBuf<25> datestring;
+	TTime DateAndTime;
+	DateAndTime.HomeTime();
+	DateAndTime.FormatL(datestring, (_L("%D%M%*Y%1%2%3%J%T%S")));
+	tempfilename.Append(datestring);
+
+	//bitmap image extension
+	tempfilename.Append(_L(".mbm"));
+
+	// save the image to file
+    User::LeaveIfError(screenBitmap->Save(tempfilename));
+    {
+		filename = tempfilename;
+    }
+#endif // ifndef LIGHT_MODE
+}
+
+//------------------------------------------------------------------------------
+//function used to simulate a screen press using stylus
+
+TInt CStatApiCommandDecoder::OpenIcon()
+{
+#ifndef LIGHT_MODE
+	// If this assert triggers it is because we are running in
+	// text shell mode without a window server and the call
+	// requires the window server to be available.
+	// A command filter in ExecuteCommand should have prevented
+	// this call from being made.
+	assert(IsWindowServerAvailable());
+
+	TInt ret = KErrArgument;
+
+	TInt commaposition = command.Locate(',');
+	if (commaposition != KErrNotFound)
+	{
+		// get x coord
+		TInt x = 0;
+		TLex Lexcoord = command.Mid(0, commaposition);
+		Lexcoord.Val(x);
+
+		// get y coord
+		TInt y = 0;
+		Lexcoord = command.Mid(commaposition + 1);
+		Lexcoord.Val(y);
+
+		//mouse click down
+		TRawEvent rawEventa;
+		rawEventa.Set(TRawEvent::EButton1Down, x, y);
+		iWs.SimulateRawEvent(rawEventa);
+		iWs.Flush();
+		User::After(TTimeIntervalMicroSeconds32(100000));
+
+		//mouse click up
+		rawEventa.Set(TRawEvent::EButton1Up, x, y);
+		iWs.SimulateRawEvent(rawEventa);
+		iWs.Flush();
+		User::After(TTimeIntervalMicroSeconds32(100000));
+		ret = KErrNone;
+	}
+
+	return (ret);
+#else // ifndef LIGHT_MODE
+	return (KErrNotSupported);
+#endif // ifndef LIGHT_MODE
+}
+
+
+//------------------------------------------------------------------------------
+//function used to invoke the ESHELL command interpreter
+//
+// This is done alternatively to starting an app because the ESHELL
+// cannot be invoked from it's current location in z:
+//
+// So we copy it first to C: then start it...
+//
+void CStatApiCommandDecoder::StartEShellL()
+{
+#ifndef LIGHT_MODE
+	// If this assert triggers it is because we are running in
+	// text shell mode without a window server and the call
+	// requires the window server to be available.
+	// A command filter in ExecuteCommand should have prevented
+	// this call from being made.
+	assert(IsWindowServerAvailable());
+
+	_LIT(KNewFile, "z:\\sys\\bin\\EShell.exe");
+	
+
+	// set command line
+	CApaCommandLine* cmdLine = CApaCommandLine::NewLC();	//creation of command line structure
+	cmdLine -> SetExecutableNameL(KNewFile);
+	
+	// call it
+	User::LeaveIfError(iApaS.Connect());					//initialise
+	User::LeaveIfError(iApaS.StartApp(*cmdLine));			//start the app
+	iApaS.Close();
+	
+	// clean up
+	CleanupStack::PopAndDestroy(1);	// cmdLine
+
+	// need to sleep a bit here to give the OS time to actually start the application
+	User::After(3000000);
+
+	User::Leave(KErrNone);
+#endif // ifndef LIGHT_MODE
+}
+
+//------------------------------------------------------------------------------
+//function used to delete file from the device
+//
+TInt CStatApiCommandDecoder::DeleteFileL(TInt bDisplayMessage)
+{
+	CFileMan *theFile = CFileMan::NewL(*iFs);
+	CleanupStack::PushL(theFile);
+
+	updatePathWithSysDrive(command) ; 
+	TInt err = theFile->Delete(command);
+	if (err!= KErrNone && err!= KErrNotFound)
+	{
+		if (bDisplayMessage)
+			pMsg->Msg(_L("DECODER: Error deleting file %S...%d"), &command, err);
+	}
+	
+	CleanupStack::PopAndDestroy();
+	return err;
+}
+
+//------------------------------------------------------------------------------
+//function used to rename file from the device
+//
+TInt CStatApiCommandDecoder::RenameFileL(MDataConsumer *const aDataConsumer)
+{
+
+	TInt err = KErrNone;
+
+	CFileMan *theFile = CFileMan::NewL(*iFs);
+	CleanupStack::PushL(theFile);
+
+    TBuf<KMaxPath>	dataFiles;
+
+	TBuf<KMaxPath>	dataFileNameFrom;
+	TBuf<KMaxPath>	dataFileNameTo;
+
+	dataFiles.Copy( *aDataConsumer );
+
+	if( err == KErrNone )
+		{
+		// locate the destination part of the filename
+		TInt commaposition = dataFiles.Locate(',');
+		if (commaposition != KErrNotFound)
+			{
+			//name of existing file
+			dataFileNameFrom.Zero();
+			dataFileNameFrom.Copy(dataFiles.Left(commaposition));
+			filename.ZeroTerminate();
+				
+			//name of destination file
+			dataFileNameTo.Zero();
+			dataFileNameTo.Copy(dataFiles.Right(dataFiles.Length()-commaposition-1));
+			dataFileNameTo.ZeroTerminate();
+			
+			updatePathWithSysDrive(dataFileNameFrom) ; 
+			updatePathWithSysDrive(dataFileNameTo) ; 
+			err = theFile->Copy( dataFileNameFrom, dataFileNameTo );
+				
+			if( err == KErrNone )
+				{
+				err = theFile->Delete(dataFileNameFrom);	
+				}
+				
+			}
+		else
+			{
+			err = KErrNotFound;
+			}
+		}
+
+	CleanupStack::PopAndDestroy();
+	return err;
+}
+
+
+
+//------------------------------------------------------------------------------
+//function used to check if a location exists on the device
+//
+TInt CStatApiCommandDecoder::CheckLocation(MDataConsumer *const aDataConsumer)
+{
+
+	TInt err = KErrNone;
+	TEntry aEntry;
+	TVolumeInfo aVolume;
+	TInt aDrive;
+	TBuf<KMaxPath> aPath;
+	
+	aPath.Copy(*aDataConsumer);
+	updatePathWithSysDrive(aPath);
+		
+ 	iFs->CharToDrive((char)aPath[0],aDrive);
+
+	//try to get drive info
+	err = iFs->Volume(aVolume,aDrive);
+	
+	if(err == KErrNone && aPath.Length() > 3)
+		{
+		//try to get file info
+		err = iFs->Entry(aPath,aEntry);
+		}
+	
+	return err;
+	
+}
+
+
+
+
+//------------------------------------------------------------------------------
+//function used to create a folder on the device
+//
+TInt CStatApiCommandDecoder::CreateFolder()
+{
+	updatePathWithSysDrive(command);
+	TInt err = iFs->MkDirAll(command);
+
+	// no error or already exists are acceptable return codes
+	if (err == KErrAlreadyExists)
+		err = KErrNone;
+
+	return err;
+}
+
+//------------------------------------------------------------------------------
+//function used to remove a folder from the device
+//
+TInt CStatApiCommandDecoder::RemoveFolder()
+{
+
+	updatePathWithSysDrive(command) ; 
+	TInt err = iFs->RmDir(command);
+
+	// no error or not found are acceptable return codes
+	if (err == KErrNotFound)
+		err = KErrNone;
+
+	return err;
+}
+
+//------------------------------------------------------------------------------
+
+TInt CStatApiCommandDecoder::TransferFile(MDataConsumer *const aDataConsumer)
+{
+	TInt err = KErrNone;
+
+	// the Transfer command comes in 2 parts - first the name, then the contents
+	if (iName)
+		{
+		pMsg->Msg(_L("DECODER: Saving filename..."));
+
+		TBuf<KMaxPath>	dataFileName;
+		dataFileName.Copy(*aDataConsumer ) ; 
+		updatePathWithSysDrive(dataFileName) ; 
+		
+		if( err == KErrNone )
+			{
+			// locate the destination part of the filename
+			TInt commaposition = dataFileName.Locate(',');
+			if (commaposition != KErrNotFound)
+				{
+				// use document name supplied in command string
+				filename.Zero();
+				filename.Copy(dataFileName.Mid(commaposition + 1));
+				filename.ZeroTerminate();
+				pMsg->Msg(_L("DECODER: File name (%S)."), &filename);
+				iName = 0;
+				err = KErrNone;
+				}
+			}
+		}
+	else
+		{
+		// save the file
+		pMsg->Msg(_L("DECODER: Saving file %S"), &filename);
+
+		if( aDataConsumer != NULL )
+			{
+			err = aDataConsumer->SaveData( filename );
+			}
+			else
+			{
+			CDataConsumerMemory	*dataConsumer = NULL;
+			TRAP(err, dataConsumer = CDataConsumerMemory::NewL( ));
+			
+			if( err == KErrNone )
+				{
+				err = dataConsumer->SaveData( filename );
+				}
+
+			if( NULL != dataConsumer )
+				{
+				dataConsumer->Delete();
+				dataConsumer = NULL;
+				}
+			}
+
+		iName = 1;
+		}
+
+	return err;
+}
+
+
+//------------------------------------------------------------------------------
+
+TInt CStatApiCommandDecoder::ReceiveFile(TUint commandtype, 
+		MDataConsumer *const aDataConsumer, MDataSupplier **aDataSupplier)
+{
+	TInt err = KErrNone;
+
+	// take screenshot first?  filename will be generated automatically
+	if (commandtype == 'S')
+	{
+		// If this assert triggers it is because we are running in
+		// text shell mode without a window server and the call
+		// requires the window server to be available.
+		// A command filter in ExecuteCommand should have prevented
+		// this call from being made.
+		assert(IsWindowServerAvailable());
+
+		TRAP(err, ScreenCaptureL());
+	}
+	else
+	{
+		TPath	dataFileName;
+
+		dataFileName.Copy( *aDataConsumer );
+		updatePathWithSysDrive(dataFileName) ; 
+		if( err == KErrNone )
+			{
+			// get the filename from the command
+			TInt commaposition = dataFileName.Locate(',');
+			if (commaposition != KErrNotFound)
+				filename.Copy(dataFileName.Mid(0, commaposition));
+			else
+				filename.Copy(dataFileName);
+			}
+	}
+
+	MDataSupplier	*pDataSupplier = NULL;
+
+	// Use a data supplier class.
+	// Initialise it with the file name and allocate
+	// an initial data buffer.
+
+	if (err == KErrNone)
+	{
+		// Create the data supplier.
+		pDataSupplier = CDataSupplierFile::NewL( );
+
+		if (pDataSupplier)
+		{
+			// Set the data in the data supplier.
+			TBuf8<KMaxPath>	filePath;
+			filePath.Copy( filename );
+
+			err = pDataSupplier->SetData( filePath );
+
+			if (err != KErrNone)
+			{
+				TBuf16<KMaxPath>	wFilePath;
+				wFilePath.Copy( filePath );
+				pMsg->Msg(_L("Failed to set data in data supplier, (%d)."), err );
+				pMsg->Msg(_L("File path %S."), &wFilePath );
+			}
+		}
+		else
+		{
+			err = KErrNoMemory;
+			pMsg->Msg(_L("Failed to create data supply object") );
+		}
+	}
+
+	// If we are sending a screen image file then we 
+	// use another data supplier class as the file is to be deleted.
+	if (commandtype == 'S')
+	{
+		TInt	size = 0;
+		HBufC8	*buffer = NULL;
+
+		if (err == KErrNone)
+		{
+			err = pDataSupplier->GetTotalSize( size );
+
+			if( err != KErrNone )
+			{
+				pMsg->Msg(_L("Failed to get total size of screen image file") );
+			}
+		}
+
+		if (err == KErrNone)
+		{
+			buffer = HBufC8::New(size);
+
+			if( ! buffer )
+			{
+				err = KErrNoMemory;
+				pMsg->Msg(_L("Failed to allocate buffer for screen image file") );
+			}
+		}
+
+		if (err == KErrNone)
+		{
+			err = pDataSupplier->GetData( *buffer, size, size );
+
+			if (err != KErrNone)
+			{
+				pMsg->Msg(_L("Failed to read data from screen image data supplier") );
+			}
+		}
+
+		if (err == KErrNone)
+		{
+			pDataSupplier->Delete( );
+
+			pDataSupplier = CDataSupplierMemory::NewL( );
+
+			if( ! pDataSupplier )
+			{
+				err = KErrNoMemory;
+				pMsg->Msg(_L("Failed to create data supply object") );
+			}
+		}
+
+		if (err == KErrNone)
+		{
+			err = pDataSupplier->SetData( *buffer );
+
+			if (err != KErrNone)
+			{
+				pMsg->Msg(_L("Failed to set data in data supplier") );
+			}
+		}
+	
+		if( NULL != buffer )
+		{
+			delete buffer;
+			buffer = NULL;
+		}
+	}
+
+	if (err == KErrNone)
+		{
+		*aDataSupplier =	pDataSupplier;
+		}
+	else
+		{
+		if (pDataSupplier)
+			{
+			pDataSupplier->Delete( );
+			pDataSupplier = NULL;
+			}
+		}
+
+	return err;
+}
+
+
+//------------------------------------------------------------------------------
+
+TInt CStatApiCommandDecoder::DeviceInfo(MDataSupplier **aDataSupplier)
+{
+	TBuf8<20> buffer = _L8("");
+	TBuf8<150> finalbuffer = _L8("\r\n");
+
+	TInt DeviceInfoValue;
+	TInt err = KErrNone;
+	TInt i = 0;
+
+	//device info required: UID, manufacturer, ROM, RAM, etc
+	HALData::TAttribute AttribArray[14] =	{
+											 HALData::EMachineUid, 
+											 HALData::ECPU,
+											 HALData::ECPUABI,
+											 HALData::EDeviceFamily, 
+											 HALData::EManufacturer,
+
+											 HALData::EModel, 
+											 HALData::EDeviceFamilyRev, 
+											 HALData::EManufacturerHardwareRev,
+											 HALData::EManufacturerSoftwareRev,
+											 HALData::EManufacturerSoftwareBuild,
+											 HALData::EMemoryPageSize,
+											 HALData::EMemoryRAM,
+											 HALData::EMemoryRAMFree,
+											 HALData::EMemoryROM
+											};
+
+	finalbuffer.Append(_L("STAT Version "));
+	
+	buffer.Num(KVersionMajor);
+	finalbuffer.Append(buffer);
+	finalbuffer.Append(_L("."));
+	
+	buffer.Num(KVersionMinor);
+	finalbuffer.Append(buffer);
+	finalbuffer.Append(_L("."));
+	
+	buffer.Num(KVersionPatch);
+	finalbuffer.Append(buffer);
+	finalbuffer.Append(_L("\r\n"));
+		
+	while(i < 14)	//retrieve all the information and write to a buffer
+	{
+		// get the attribute value
+		HAL::Get(AttribArray[i], DeviceInfoValue);
+		buffer.Num(DeviceInfoValue);
+
+		// need to convert the value to a meaningful string
+		if (i < 5)
+		{
+			GetData(i, buffer);
+		}
+			
+		finalbuffer.Append(buffer);		
+		finalbuffer.Append(_L8("\r\n"));
+		i++;
+	}
+
+	CDataSupplierMemory	*pDataSupplier = CDataSupplierMemory::NewL( );
+
+	if (pDataSupplier)
+		{
+		// Set the data in the data supplier.
+		err = pDataSupplier->SetData( finalbuffer );
+
+		if (err != KErrNone)
+			{
+			pMsg->Msg(_L("Failed to set data in data supplier") );
+			}
+		}
+	else
+		{
+		err = KErrNoMemory;
+		pMsg->Msg(_L("Failed to create data supply object") );
+		}
+
+	if (err == KErrNone)
+		{
+		*aDataSupplier =	pDataSupplier;
+		}
+	else
+		{
+		if (pDataSupplier)
+			{
+			pDataSupplier->Delete( );
+			pDataSupplier = NULL;
+			}
+		}
+
+	return err;
+}
+
+//------------------------------------------------------------------------------
+
+TInt CStatApiCommandDecoder::SaveLogFile(MDataSupplier **aDataSupplier)
+{
+	TInt err = KErrNone;
+
+	CDataConsumerMemory	*data = NULL;
+
+	// if the log file is not enabled then we return an empty buffer
+	if( pMsg->IsInitialised() == EFalse )
+		{
+		return KErrNone;
+		}
+
+	//open the file an copy it into the return buffer
+	data = CDataConsumerMemory::NewL( );
+
+	if( ! data )
+		{
+		err = KErrNoMemory;
+		}
+	
+	if( err == KErrNone )
+		{
+		pMsg->CloseFile();
+		}
+
+
+
+	TBuf<KMaxPath>	filePath;
+	TBuf<17> statLogFile;
+	statLogFile.Append(iSystemDrive);
+	statLogFile.Append(KStatLogFile);
+	if( err == KErrNone )
+		{
+		
+		RFile	file;
+
+		err = file.Temp( *iFs, iSystemDrive,
+							filePath, EFileShareExclusive );
+
+		if( err == KErrNone )
+			{
+			file.Close( );
+
+	    	CFileMan* fileMan = CFileMan::NewL( *iFs );
+	    	err =	fileMan->Copy(statLogFile,filePath);
+			delete fileMan;
+			fileMan =	NULL;
+			}
+		}
+
+	if( err == KErrNone )
+		{
+		TBuf8<KMaxPath>	cFilePath;
+		cFilePath.Copy( filePath );
+		err = data->AddData( cFilePath );
+		}
+
+	if( err == KErrNone )
+		{
+		err = ReceiveFile('R', data, aDataSupplier);
+		}
+
+	
+	if( err == KErrNone )
+		{
+		// reset the logger 
+		pMsg->Init( *iFs, statLogFile, NULL );
+		}
+
+	if( data )
+		{
+		data->Delete( );
+		data = NULL;
+		}
+
+	return err;
+}
+
+//------------------------------------------------------------------------------
+
+#ifndef LIGHT_MODE
+TInt CStatApiCommandDecoder::GetDiskDriveInformationL(MDataSupplier **aDataSupplier)
+#else // ifndef LIGHT_MODE
+TInt CStatApiCommandDecoder::GetDiskDriveInformationL(MDataSupplier **)
+#endif // ifndef LIGHT_MODE
+{
+#ifndef LIGHT_MODE
+	TInt err = KErrNone;
+
+	// Get the disk drive information and save to the data supplier object
+	// as a text string.
+
+	static const TInt	bufferGrow =	(4*1024);
+	RBufWriteStream	strWrite;
+	CBufFlat*	dynBuffer =	NULL;
+
+	if( err == KErrNone )
+		{
+		dynBuffer =	CBufFlat::NewL(bufferGrow);
+
+		if( dynBuffer == NULL )
+			{
+			err =	KErrNoMemory;
+			}
+		}
+
+	if( err == KErrNone )
+		{
+		strWrite.Open( *dynBuffer, 0 );
+		}
+
+	if( err == KErrNone )
+		{
+		RFs fileSystem;
+
+		err = fileSystem.Connect();
+
+		if( err == KErrNone )
+			{
+			TDriveList	driveList;
+
+			if( err == KErrNone )
+				{
+				err = fileSystem.DriveList( driveList );
+				}
+
+			if( err == KErrNone )
+				{
+				TBuf8<KMaxFileName> name;		// Store volume name
+												// in 8 bit format.
+				TBuf8<KMaxFileName*2> buffer;	// Store volume information.
+
+				TVolumeInfo	volumeInfo;
+				TInt	drive = 0;
+				for( drive = 0; drive < KMaxDrives; drive++ )
+					{
+					if( driveList[drive] )
+						{
+						err = fileSystem.Volume( volumeInfo, drive );
+
+						if( err == KErrNone )
+							{
+								// Copy the volume name to an 8 bit buffer.
+								name.Copy( volumeInfo.iName );
+								// Format the text string.
+								buffer.Format( driveFormat, drive + 'A',
+									&name, volumeInfo.iSize, &newLine );
+								// Add details of the current drive to our
+								// buffer.
+								TRAP( err, strWrite.WriteL( buffer ) );
+							}
+						}
+					}	
+				}
+			fileSystem.Close();
+			}
+		}
+
+	if( err == KErrNone || err == KErrNotReady )
+		{
+		TRAP( err, strWrite.WriteL( newLine ) );
+
+		CDataSupplierMemory	*pDataSupplier = CDataSupplierMemory::NewL( );
+
+		if (pDataSupplier)
+			{
+			// Set the data in the data supplier.
+			err = pDataSupplier->SetData( dynBuffer->Ptr( 0 ) );
+
+			if (err != KErrNone)
+				{
+				pMsg->Msg(_L("Failed to set data in data supplier") );
+				}
+			}
+		else
+			{
+			err = KErrNoMemory;
+			pMsg->Msg(_L("Failed to create data supply object") );
+			}
+
+		if (err == KErrNone)
+			{
+			*aDataSupplier =	pDataSupplier;
+			}
+		else
+			{
+			if (pDataSupplier)
+				{
+				pDataSupplier->Delete( );
+				pDataSupplier = NULL;
+				}
+			}
+		}
+
+	strWrite.Close( );
+
+	if( dynBuffer != NULL )
+		{
+		delete dynBuffer;
+		dynBuffer = NULL;
+		}
+
+	return err;
+#else // ifndef LIGHT_MODE
+	return (KErrNotSupported);
+#endif // ifndef LIGHT_MODE
+}
+
+//------------------------------------------------------------------------------
+
+#ifndef LIGHT_MODE
+TInt CStatApiCommandDecoder::GetDirectoryInformationL(MDataConsumer *const aDataConsumer, 
+					MDataSupplier **aDataSupplier)
+#else // ifndef LIGHT_MODE
+TInt CStatApiCommandDecoder::GetDirectoryInformationL(MDataConsumer *const, 
+					MDataSupplier **)
+#endif // ifndef LIGHT_MODE
+{
+#ifndef LIGHT_MODE
+	TInt err = KErrNone;
+
+	// Get the directory entries for a specified directory 
+	// and save to the data supplier object as a text string.
+
+	TBuf<KMaxPath>	directoryName;
+
+	static const TInt	bufferGrow =	(4*1024);
+	RBufWriteStream	strWrite;
+	CBufFlat*	dynBuffer =	NULL;
+
+	if( err == KErrNone )
+		{
+		directoryName.Copy( *aDataConsumer );
+		}
+
+	if( err == KErrNone )
+		{
+		dynBuffer =	CBufFlat::NewL(bufferGrow);
+
+		if( dynBuffer == NULL )
+			{
+			err =	KErrNoMemory;
+			}
+		}
+
+	if( err == KErrNone )
+		{
+		strWrite.Open( *dynBuffer, 0 );
+		}
+
+	if( err == KErrNone )
+		{
+		RFs fileSystem;
+
+		err = fileSystem.Connect();
+
+		if( err == KErrNone )
+			{
+			CDir *entryList = NULL;
+
+			if( err == KErrNone )
+				{
+				err = fileSystem.GetDir( directoryName, KEntryAttMaskSupported, EDirsFirst | ESortByName,
+								entryList );
+				}
+
+			if( err == KErrNone )
+				{
+				TBuf8<KMaxFileName> name;		// Store entry name
+												// in 8 bit format.
+				TBuf8<KMaxFileName*2> buffer;	// Store entry information.
+
+				static const TInt	maxDateLength = 32;
+				TBuf8<maxDateLength> dateBuffer;
+
+				TDateTime	dateTime;
+
+				TInt	count = entryList->Count();
+				TInt	entry = 0;
+				for( entry = 0; (entry < count) && (err == KErrNone); entry++ )
+					{
+					const TEntry &anEntry = entryList->operator[](entry);
+
+					// Format the date into readable text.
+					dateTime = anEntry.iModified.DateTime();
+					dateBuffer.Format( dateFormat, dateTime.Day() + 1, dateTime.Month() + 1,
+									dateTime.Year(), dateTime.Hour(), dateTime.Minute() );
+
+					// Copy the volume name to an 8 bit buffer.
+					name.Copy( anEntry.iName );
+					// Format the text string.
+					buffer.Format( entryFormat, &name,
+							anEntry.iAtt, &dateBuffer, anEntry.iSize, &newLine );
+					// Add details of the current drive to our
+					// buffer.
+					TRAP( err, strWrite.WriteL( buffer ) );
+					}
+				}
+
+			if( entryList != NULL )
+				{
+					delete entryList;
+					entryList = NULL;
+				}
+			fileSystem.Close();
+			}
+		}
+
+	if( err == KErrNone )
+		{
+		TRAP( err, strWrite.WriteL( newLine ) );
+
+		CDataSupplierMemory	*pDataSupplier = CDataSupplierMemory::NewL( );
+
+		if (pDataSupplier)
+			{
+			// Set the data in the data supplier.
+			err = pDataSupplier->SetData( dynBuffer->Ptr( 0 ) );
+
+			if (err != KErrNone)
+				{
+				pMsg->Msg(_L("Failed to set data in data supplier") );
+				}
+			}
+		else
+			{
+			err = KErrNoMemory;
+			pMsg->Msg(_L("Failed to create data supply object") );
+			}
+
+		if (err == KErrNone)
+			{
+			*aDataSupplier =	pDataSupplier;
+			}
+		else
+			{
+			if (pDataSupplier)
+				{
+				pDataSupplier->Delete( );
+				pDataSupplier = NULL;
+				}
+			}
+		}
+
+	strWrite.Close( );
+
+	if( dynBuffer != NULL )
+		{
+		delete dynBuffer;
+		dynBuffer = NULL;
+		}
+
+	return err;
+#else // ifndef LIGHT_MODE
+	return (KErrNotSupported);
+#endif // ifndef LIGHT_MODE
+}
+
+//------------------------------------------------------------------------------
+
+#ifndef LIGHT_MODE
+void CStatApiCommandDecoder::DoKeyEvent(TInt key)
+#else // ifndef LIGHT_MODE
+void CStatApiCommandDecoder::DoKeyEvent(TInt)
+#endif // ifndef LIGHT_MODE
+{
+#ifndef LIGHT_MODE
+	// If this assert triggers it is because we are running in
+	// text shell mode without a window server and the call
+	// requires the window server to be available.
+	// A command filter in ExecuteCommand should have prevented
+	// this call from being made.
+	assert(IsWindowServerAvailable());
+
+	TKeyEvent event;				//the key event structure
+	event.iCode = key;				// pass character code into the struct value
+	event.iScanCode = 0;
+	event.iModifiers = 0;
+	event.iRepeats = 0;				// no repeats for keypress
+
+	iWs.SimulateKeyEvent(event);	// send keystroke
+	iWs.Flush();					// flush client-side window server buffer
+#endif // ifndef LIGHT_MODE
+}
+
+//------------------------------------------------------------------------------
+//Get the required device information
+TInt CStatApiCommandDecoder::GetData(TInt i, TDes8& info)
+{
+	TInt err = KErrNone;
+	TInt a = 0;
+	TBuf8<150> devicevalue = _L8("");
+	TBool found = EFalse;
+
+	devicevalue.Num(ENUM_VALDEVICEINFORMATIONArray[i][a]);	//assign initial data in array to value (element 0)
+	while (ENUM_DEVICEINFORMATIONArray[i][a] != NULL)
+	{
+		if (info.Compare(devicevalue) == 0)	//if the string has been found in the value array
+		{
+			info = ENUM_DEVICEINFORMATIONArray[i][a];	//set the value to the string equivalent
+			found = ETrue;
+			break;
+		}
+
+		a++;
+		devicevalue.Num(ENUM_VALDEVICEINFORMATIONArray[i][a]);	//update contents of value for the next pass
+	}	//end while
+
+	if (!found)
+		info = _L8("Not available");
+
+	return err;
+}
+
+//------------------------------------------------------------------------------
+void CStatApiCommandDecoder::AppendErrorCode(TInt ret, MDataSupplier **aDataSupplier)
+{
+	HBufC8 *buffer = HBufC8::New(10);
+	if (buffer)
+	{
+		// add the error code
+		TPtr8 pBuffer(buffer->Des());
+		pBuffer.Zero();
+		pBuffer.Num(ret);
+		pBuffer.ZeroTerminate();
+
+		*aDataSupplier = CDataSupplierMemory::NewL( );
+		if (*aDataSupplier)
+		{
+			// Set the data in the data supplier.
+			(*aDataSupplier)->SetData( *buffer );
+		}
+
+		delete buffer;
+		buffer = NULL;
+	}
+}
+
+TInt CStatApiCommandDecoder::StopProgramL(const TDesC& aHandleNumber)
+{
+	TLex conv(aHandleNumber);
+	
+	TInt64 handleNumber;
+	
+	TInt err = conv.Val(handleNumber);
+	
+	if(err==KErrNone)
+		{
+		RProcess newProcess;
+		err = newProcess.Open(TProcessId(handleNumber));
+		if(err==KErrNone)
+			{
+			newProcess.Kill(1);
+			}
+		newProcess.Close();	
+		}
+	
+	return err;
+}
+
+
+TInt CStatApiCommandDecoder::ProgramStatusL(const TDesC& aHandleNumber, MDataSupplier **aDataSupplier)
+{
+	
+	CDataSupplierMemory	*pDataSupplier = CDataSupplierMemory::NewL( );
+	
+	TBuf8<50> exitData;
+
+	TLex conv(aHandleNumber);
+	
+	TInt64 handleNumber;
+	
+	TInt err = conv.Val(handleNumber);
+	
+	if(err==KErrNone)
+		{
+		RProcess newProcess;
+		TInt status = newProcess.Open(TProcessId(handleNumber));
+		
+		switch(status)
+			{
+			case KErrNone:
+				exitData.Num(ETrue);
+				break;
+			default:
+				exitData.Num(EFalse);
+			}
+			
+		if (pDataSupplier)
+			{
+			// Set the data in the data supplier.
+			err = pDataSupplier->SetData( exitData );
+
+			if (err != KErrNone)
+				{
+				pMsg->Msg(_L("Failed to set data in data supplier") );
+				}
+			}
+		else
+			{
+			err = KErrNoMemory;
+			pMsg->Msg(_L("Failed to create data supply object") );
+			}
+		
+		if (err == KErrNone)
+			{
+			*aDataSupplier =	pDataSupplier;
+			}
+		else
+			{
+			if (pDataSupplier)
+				{
+				pDataSupplier->Delete( );
+				pDataSupplier = NULL;
+				}
+			}
+		
+		newProcess.Close();	
+		}
+	
+	return err;
+}
+
+
+void CStatApiCommandDecoder::updatePathWithSysDrive(TBuf<1024>& pathToChange )
+{
+	//try it here...
+   	//check for the sysdrive being diff from C:
+	TBufC<KMaxPath> workingPath(pathToChange) ; 
+	TInt indx = workingPath.Des().Find(KReDrive) ; 
+	while(	indx > KErrNotFound )
+	 	{
+		workingPath.Des().Replace(indx,2,getSystemDrive());
+		pathToChange = workingPath.Des() ; 
+		indx = workingPath.Des().Find(KReDrive) ; 
+	 	}
+	
+}
+
+void CStatApiCommandDecoder::updatePathWithSysDrive(TBuf<KMaxPath>& pathToChange )
+	{
+	TBufC<KMaxPath> workingPath(pathToChange) ; 
+	TInt indx = workingPath.Des().Find(KReDrive) ; 
+	while(	indx > KErrNotFound )
+	 	{
+		workingPath.Des().Replace(indx,2,getSystemDrive());
+		pathToChange = workingPath.Des() ; 
+		indx = workingPath.Des().Find(KReDrive) ; 
+	 	}
+	
+	}
+
+TDriveName CStatApiCommandDecoder::getSystemDrive()
+{
+
+	TDriveNumber defaultSysDrive(EDriveC);
+	RLibrary pluginLibrary;
+	TInt pluginErr = pluginLibrary.Load(KFileSrvDll);
+	if (pluginErr == KErrNone)
+		{
+		typedef TDriveNumber(*fun1)();
+		fun1 sysdrive;
+	
+	#ifdef __EABI__
+		sysdrive = (fun1)pluginLibrary.Lookup(336);
+	#else
+		sysdrive = (fun1)pluginLibrary.Lookup(304);
+	#endif
+		
+		if(sysdrive!=NULL)
+			{
+			defaultSysDrive = sysdrive();
+			}
+		}
+	pluginLibrary.Close();
+	
+	//TDriveName drive( TDriveUnit(defaultSysDrive).Name()) ;
+	return TDriveUnit(defaultSysDrive).Name() ; 
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/src/stat_console.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,141 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+/*************************************************************************
+ *
+ * Switches
+ *
+ ************************************************************************/
+
+/*************************************************************************
+ *
+ * System Includes
+ *
+ ************************************************************************/
+
+/*************************************************************************
+ *
+ * Local Includes
+ *
+ ************************************************************************/
+#include "assert.h"
+#include "stat_console.h"
+#include "stat.h"
+
+/*************************************************************************
+ *
+ * Definitions
+ *
+ ************************************************************************/
+#define KConnectingStatusStr		_L("STAT is connecting.")
+#define KWaitingForDataStatusStr	_L("STAT is waiting for data.")
+
+/*************************************************************************
+ *
+ * CStatConsole
+ *
+ ************************************************************************/
+CStatConsole *CStatConsole::NewL( CConsoleBase *aConsole, MNotifyLogMessage *const aMsg )
+{
+    CStatConsole *self = new (ELeave) CStatConsole();
+    CleanupStack::PushL(self);
+	self->ConstructL( aConsole, aMsg );
+	CleanupStack::Pop();
+    return self;
+}
+
+void CStatConsole::ConstructL( CConsoleBase *aConsole, MNotifyLogMessage *const aMsg )
+{
+	asserte( aConsole != NULL );
+
+	iConsole = aConsole;
+	iUserExitRequest=0;
+	iMsg = aMsg;
+}
+
+CStatConsole::~CStatConsole( void )
+{
+}
+
+void CStatConsole::HandleStatusChange( TInt /*aSessionId*/, TCommStatus aNewStatus )
+{
+	TPtrC status[] = {
+		_L( "STAT is not running." ),
+		_L( "STAT is initialising." ),
+		_L( "STAT is initialised." ),
+		KConnectingStatusStr,
+		_L( "STAT is connected." ),
+		_L( "STAT is disconnecting." ),
+		_L( "STAT is disconnected." ),
+		_L( "STAT is releasing." ),
+		_L( "STAT is sending data."),
+		KWaitingForDataStatusStr,
+		_L( "<error>" )
+	};
+	if(aNewStatus==0 && iUserExitRequest==1){  //only closes down if user requested to.
+		CActiveScheduler::Stop();
+	}
+
+	if( aNewStatus <= 9 ) {
+//		iConsole->Printf( _L("%S\n"), status[aNewStatus] );
+		iConsole->Printf( status[aNewStatus] );
+		iConsole->Printf( _L("\n") );
+	} else {
+		iConsole->Printf( _L("Unknown status returned.\n") );
+	}
+}
+
+void CStatConsole::HandleError( TInt aError, void * /*aErrorData*/ )
+{
+	// If aError is < 0 then it is an EPOC error code, if it is > 0 then
+	// it is one of my error codes. aErrorData is defined for each code
+	switch( aError ) 
+	{
+		case KErrAccessDenied:
+			iConsole->Printf( _L("Comm port access denied.\n") );
+			break;
+	
+		case KErrNotSupported:
+			iConsole->Printf( _L("Unsupported comm port.\n") );
+			break;
+
+		case KErrCancel:
+			iConsole->Printf( _L("Operation cancelled.\n") );
+			break;
+			
+		case KErrDisconnected:
+			break;
+
+		default:
+			iConsole->Printf( _L("Error occurred - %d.\n"), aError );
+			break;
+	}
+}
+
+void CStatConsole::HandleInfo( const TDesC *aInfo )
+{
+	if( aInfo != NULL ) {
+		iConsole->Printf( _L("%S\n"), aInfo );
+	}
+}
+
+void CStatConsole::UserExitRequest( )
+{
+	iUserExitRequest=1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/src/stat_controller.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,350 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+ /************************************************************************* 
+ *
+ * System Includes
+ *
+ *************************************************************************/
+
+/*************************************************************************
+ *
+ * Local Includes
+ *
+ *************************************************************************/
+#include "assert.h"
+#include "stat.h"
+#include "stat_interfaces.h"
+#include "stat_controller.h"
+#include "stat_engine.h"
+
+
+/*************************************************************************
+ *
+ * Definitions
+ *
+ *************************************************************************/
+
+/*************************************************************************
+ *
+ * CStatController - Construction
+ *
+ *************************************************************************/
+CStatController *CStatController::NewL()
+{
+    CStatController *self = new (ELeave) CStatController();
+    CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop();
+    return self;
+}
+
+CStatController::CStatController() : CActive(EPriorityHigh), iFs( NULL ), iMsg( NULL )
+{
+}
+
+void CStatController::ConstructL( void ) 
+{
+	// add me to the active scheduler
+	CActiveScheduler::Add(this); 
+
+	// params
+	iEngine = NULL;
+	iSessionStatus = EIdle;
+	iTransport = NULL;
+	iUI = NULL;
+	iConnectedSuccessfully = EFalse;
+	iUserInitiatedExitRequest = EFalse;
+	iFs =	NULL;
+	iMsg = NULL;
+
+	// wait for notifications
+	iStatus = KRequestPending;
+	SetActive();
+}
+
+CStatController::~CStatController()
+{
+	// clear notification -- deque (and CActive destructor) will fail otherwise
+	Notify( KErrCancel );
+	Deque();
+
+	// make sure the session is closed
+	asserte( iSessionStatus == EIdle );
+	asserte( iEngine == NULL );
+	asserte( iTransport == NULL );
+}
+
+/*************************************************************************
+ *
+ * CStatController - public interface
+ *
+ *************************************************************************/
+TInt CStatController::StartSession( TStatConnectType aConnectType, TDesC *aConnectParams, MNotifyUI *aUI, RFs *const aSession, MNotifyLogMessage *const aMsg )
+{
+	TInt exp =	KErrNone;
+
+	iFs =	aSession;
+	iMsg =	aMsg;
+
+    if(!aConnectParams) {
+        return -1;
+    }
+
+	// this is the notification sink for this session
+	iUI = aUI;
+	iConnectType = aConnectType;
+	asserte( aConnectParams->Length() <= KAddressTextLimit );
+    iConnectParams.Copy( *aConnectParams );
+		
+	// create the engine with a callback interface to the controller, create the 
+	// appropriate transport, and start the engine
+	iConnectedSuccessfully = EFalse;
+	TRAP( exp, (iEngine = CStatEngine::NewL(this, iFs, iMsg)) );
+	if( exp != KErrNone ) {
+		return -1;
+	}
+
+	// if the start transport leaves then its because it failed to create an object. This
+	// is either because the network or transport creation failed left. If it was the
+	// transport then the network may still have memory allocated.
+	TRAP( exp, (iTransport = StartTransportL(iConnectType)) );
+	if( exp != KErrNone ) {
+		if( iSerialNetwork != NULL ) {
+			delete iSerialNetwork;
+			iSerialNetwork = 0;
+		}
+		return -1;
+	}
+
+	iEngine->StartEngine( iTransport, iConnectType, &iConnectParams );
+
+	// this controller only supports one session which always has ID = 1
+	return 1;
+}
+
+TInt CStatController::StopSession( TInt aSessionId )
+{
+	// make sure this is a valid, active, session
+	if( (aSessionId != 1) || (iSessionStatus == EIdle) )
+	{
+		// If the session is valid and idle then it is not
+		// initialised and connected correctly.
+		// Call Notify to cancel the outstanding asynchronous events
+		// we are registered for.
+		// This fixes a problem that appears when the engine fails to
+		// start correctly (due to COM port failures for example) and
+		// caused the CActiveScheduler never to stop as this object
+		// never received a callback when it needs one to remove
+		// itself from the active state.
+		// If the CActiveScheduler does not shut down then the
+		// program never exits and blocks.
+		Notify( KErrNone );
+		//
+		return KErrBadHandle;
+	}
+
+	iMsg->Msg( _L("CONTROLLER: Stopping session.") );
+
+	// tell the engine to stop and then wait for an asynchronous response
+	iUserInitiatedExitRequest = ETrue;
+	iEngine->StopEngine();
+	return KErrNone;
+}
+
+TInt CStatController::SessionStatus( TInt aSessionId )
+{
+	if( aSessionId != 1 )
+		return KErrBadHandle;
+	return iSessionStatus;
+}
+
+void CStatController::SetStatus( TCommStatus aNewStatus )
+{
+	iSessionStatus = aNewStatus;
+	if( iUI != NULL )
+		iUI->HandleStatusChange( 1, iSessionStatus );
+	if( aNewStatus == EConnected ) 
+		iConnectedSuccessfully = ETrue;
+}
+
+/*************************************************************************
+ *
+ * CStatController - MNotifyStatController
+ *
+ *************************************************************************/
+void CStatController::HandleStatusChange( TCommStatus aNewStatus )
+{
+	// If the engine has gone idle then everything is done and we can kill
+	// everything off. But, this function was called by the engine, so we
+	// can't kill it here -- send self an event to clean things up.
+	if( aNewStatus == EIdle ) {
+		Notify( KErrNone );
+		return;
+	}
+	
+	// update the status
+	SetStatus( aNewStatus );
+}
+
+// The engine deals with the transports in the face of errors itself, and the 
+// interaction with the engine is really handled via HandleStatusChange. This
+// function is mainly here to be able to pass information up from the transport
+// and the engine to the UI / user
+void CStatController::HandleError( TInt aError, void *aErrorData )
+{
+	if( iUI != NULL ) 
+		iUI->HandleError( aError, aErrorData );
+}
+
+// Info is for end-user consumption only and is sent directly to the UI.
+void CStatController::HandleInfo( const TDesC *aInfo )
+{
+	if( iUI != NULL )
+		iUI->HandleInfo( aInfo );
+}
+
+/*************************************************************************
+ *
+ * CStatController - CActive
+ *
+ *************************************************************************/
+void CStatController::RunL()
+{
+	// delete the engine and the transport
+	delete iEngine;
+	iEngine = NULL;
+	KillTransport();
+
+	// now change the status to idle
+	SetStatus( EIdle );
+
+	// wait again
+	iStatus = KRequestPending;
+	SetActive();
+
+	// But if this wasn't a user requested exit -- and the last connection
+	// did connect successfully, then restart. Otherwise clear the flags.
+	if( (iConnectedSuccessfully) && (!iUserInitiatedExitRequest) ) {
+		iConnectedSuccessfully = EFalse;
+		iEngine = CStatEngine::NewL( this, iFs, iMsg );
+		iTransport = StartTransportL( iConnectType );
+		iEngine->StartEngine( iTransport, iConnectType, &iConnectParams );
+	} else {
+		iUserInitiatedExitRequest = EFalse;
+		iConnectedSuccessfully = EFalse;
+	}
+}		
+
+void CStatController::DoCancel()
+{
+}
+
+void CStatController::Notify( TInt aErrorStatus )
+{
+	TRequestStatus *pstatus;
+	pstatus = &iStatus;
+	TRequestStatus *&rstatus = pstatus;
+	User::RequestComplete( rstatus, aErrorStatus );
+}
+
+/*************************************************************************
+ *
+ * CStatController - Private
+ *
+ *************************************************************************/
+MStatApiTransport *CStatController::StartTransportL( TStatConnectType aConnectType )
+{
+	switch( aConnectType ) {
+
+#ifndef LIGHT_MODE
+	case ETCPIP:
+		iTcpipTransport = CStatTransportTCPIP::NewL( );
+		iPacketisationTransport = CStatTransportPacketisation::NewL( iEngine, iTcpipTransport, iTcpipTransport->GetPacketSize() );
+		return iPacketisationTransport;
+
+	case EInfrared:
+		iSerialNetwork = CStatApiSerial::NewL( _L("IrCOMM") );
+		iPacketisationTransport = CStatTransportPacketisation::NewL( iEngine, iSerialNetwork, iSerialNetwork->GetPacketSize() );
+		return iPacketisationTransport;
+
+	case EBluetooth:
+		iBluetoothTransport = CStatTransportBT::NewL();
+		iPacketisationTransport = CStatTransportPacketisation::NewL( iEngine, iBluetoothTransport, iBluetoothTransport->GetPacketSize() );
+		return iPacketisationTransport;
+	
+	case EUsb:
+		iUsbNetwork = CStatApiUsb::NewL();
+		iPacketisationTransport = CStatTransportPacketisation::NewL( iEngine, iUsbNetwork, iUsbNetwork->GetPacketSize() );
+		return iPacketisationTransport;
+
+		
+		
+#endif // ifndef LIGHT_MODE
+
+	case ESerial:
+		iSerialNetwork = CStatApiSerial::NewL( _L("ECUART") );
+		iPacketisationTransport = CStatTransportPacketisation::NewL( iEngine, iSerialNetwork, iSerialNetwork->GetPacketSize() );
+		return iPacketisationTransport;
+
+	default:
+		;
+	}
+	return NULL;
+}
+
+void CStatController::KillTransport()
+{
+	switch( iConnectType ) {
+
+#ifndef LIGHT_MODE
+	case ETCPIP:
+		delete iTcpipTransport;
+		delete iPacketisationTransport;
+		iPacketisationTransport = NULL;
+		iTcpipTransport = NULL;
+		break;
+
+	case EBluetooth:
+		delete iBluetoothTransport;
+		delete iPacketisationTransport;
+		iBluetoothTransport = NULL;
+		iPacketisationTransport = NULL;
+		break;
+
+	case EInfrared:
+		delete iSerialNetwork;
+		delete iPacketisationTransport;
+		iSerialNetwork = NULL;
+		iPacketisationTransport = NULL;
+		break;
+#endif // ifndef LIGHT_MODE
+
+	case ESerial:
+		delete iSerialNetwork;
+		delete iPacketisationTransport;
+		iSerialNetwork = NULL;
+		iPacketisationTransport = NULL;
+		break;
+
+	default:
+		;
+	}
+	iTransport = NULL;	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/src/stat_engine.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,428 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+ /********************************************************************************
+ *
+ * System Includes
+ *
+ ********************************************************************************/
+#include <e32std.h>
+#include <e32base.h>
+
+/********************************************************************************
+ *
+ * Local Includes
+ *
+ ********************************************************************************/
+#include "assert.h"
+#include "stat.h"
+#include "stat_engine.h"
+
+/********************************************************************************
+ *
+ * Macro functions
+ *
+ ********************************************************************************/
+
+/********************************************************************************
+ *
+ * Definitions
+ *
+ ********************************************************************************/
+const TUint	KSyncMax		= 5;
+
+/********************************************************************************
+ *
+ * CStatEngine -- construction
+ *
+ ********************************************************************************/
+CStatEngine *CStatEngine::NewL( MNotifyStatController *aController, RFs *const aSession, MNotifyLogMessage *const aMsg )
+{
+	CStatEngine *self = new (ELeave) CStatEngine();
+	CleanupStack::PushL( self );
+	self->ConstructL( aController, aSession, aMsg );
+	CleanupStack::Pop();
+	return self;
+}
+
+void CStatEngine::ConstructL( MNotifyStatController *aController, RFs *const aSession, MNotifyLogMessage *const aMsg )
+{	
+	// check params
+	asserte( aController != NULL );
+
+	// setup all params
+	iController = aController;
+	iEngineStatus = EIdle;
+	iRemoteHost = NULL;
+	iResyncCount = 0;
+	iFs =	aSession;
+	iMsg = aMsg;
+	iCommandDecoder = CStatApiCommandDecoder::NewL( iFs, iMsg );
+}
+
+CStatEngine::CStatEngine() : iDataSupplier( NULL ), iMsg( NULL ), iFs( NULL ), iDeleteLastFile(EFalse)
+{
+}
+
+CStatEngine::~CStatEngine()
+{
+	// clean up all params
+	if( iRemoteHost != NULL ) {
+		delete iRemoteHost;
+	}
+	delete iCommandDecoder;
+
+	if(iDataSupplier)
+		{
+		iDataSupplier->Delete( );
+		iDataSupplier = NULL;
+		}
+}
+
+/********************************************************************************
+ *
+ * CStatEngine -- MStatEngine implementation
+ *
+ ********************************************************************************/
+void CStatEngine::StartEngine( MStatApiTransport *aStatTransport, 
+	TStatConnectType aConnectType, TDesC *aRemoteHost )
+{
+	TInt exception, ret = KErrNone;
+	iTransport = aStatTransport;
+
+	// save the remote host address string
+	iRemoteHost = new TPtrC( *aRemoteHost );
+
+	// create the message log 
+
+	// start the initialisation procedure the ugly second line means that if an
+	// exception is thrown the ret will have the exception, otherwise it will have
+	// the return code. Exceptions are always -ve and return values are always +ve
+	// so the two number spaces don't overlap (as zero means success in both).
+	iMsg->Msg( _L("ENGINE: Calling InitialiseL, %d (%S)."), aConnectType, aRemoteHost );
+	SetState( EInitialising );
+	TRAP( exception, (ret = iTransport->InitialiseL()) );
+	ret = ((exception == KErrNone) ? ret : exception);
+	HandleStateChange( KOpInitialise, ret );
+}
+
+// the controller calls stop whenever he (yes the controller is male) wants the engine
+// to arrange itself and the transport into a state where he can safetly shut it down. It
+// can be called at any time -- i.e. when the engine is in any state.
+void CStatEngine::StopEngine( void )
+{
+	TInt exception, ret = KErrNone;
+
+	switch( iEngineStatus ) {
+		
+	case EIdle:
+		;
+		break;
+
+	case EConnecting:
+	case EConnected:
+	case EReceivePending:
+	case ESendPending:
+		iMsg->Msg( _L("ENGINE: Calling Disconnect.") );
+		SetState( EDisconnecting );
+		TRAP( exception, (ret = iTransport->Disconnect()) );
+		ret = ((exception == KErrNone) ? ret : exception);
+		HandleStateChange( KOpDisconnect, ret );
+		break;
+
+	case EDisconnecting:
+	case EDisconnected:
+	case EReleasing:
+		// nothing I can really do -- there is already a disconnect call
+		// pending -- just return and wait for notification -- or force
+		// disconnect by just deleting the object
+		break;
+
+	case EInitialising:
+	case EInitialised:
+		;
+		break;
+	case ELast:
+		;
+		break;
+	}
+}
+
+/********************************************************************************
+ *
+ * CStatEngine - Higher level transport handling code. All errors and startup
+ * shutdown issues are handled by the MNotifyStatEngine implementation.
+ *
+ ********************************************************************************/
+void CStatEngine::OnConnect( void )
+{	
+	iMsg->Msg( _L("ENGINE: Waiting for next command.") );
+	SetState( EReceivePending );
+	TInt err = iTransport->RequestReceive();
+	asserte( err == KSTErrAsynchronous );
+}
+
+void CStatEngine::OnRecvCommand( TUint aCommand, MDataConsumer *const aDataConsumer )
+{
+	TInt err = KErrNone;
+	TInt dataLength = 0;
+
+	if (aCommand == 'B')
+		iDeleteLastFile = EFalse;
+	else if (aCommand == 'S' || aCommand == 'X')
+		iDeleteLastFile = ETrue;
+	
+	// Clean up the old data supplier.
+	// If we are getting a command then it is safe to assume
+	// that everyone has finished with the old data supplier as
+	// they are valid only for the context of the current
+	// command.
+	if(iDataSupplier)
+		{
+		iDataSupplier->Delete( );
+		iDataSupplier = NULL;
+		}
+	
+	// if this is a resync command then we have already done all we need to do so
+	// just return and wait for the next command. If we reach the maximum of 
+	// resync commands disconnect and reset.
+	if( aCommand == RESYNC_ID ) {
+		iResyncCount++;
+		if( iResyncCount > KSyncMax ) {
+			iMsg->Msg( _L("ENGINE: Resync limit reached, calling Disconnect().") );
+			SetState( EDisconnecting );
+			err = iTransport->Disconnect();
+			iMsg->Msg( _L("ENGINE: Synchronous response from Disconnect(%d)."), err );
+			HandleStateChange( KOpDisconnect, err );
+		}
+		SetState( ESendPending );
+		return;
+	}
+	iResyncCount = 0;
+
+	if(aCommand == REFRESH_ID)
+	{
+		SetState( EDisconnecting );
+		err = iTransport->Disconnect();
+		HandleStateChange( KOpDisconnect, err );
+		SetState( ESendPending );
+
+		return;
+	}
+
+	// otherwise execute the command
+	err = iCommandDecoder->ExecuteCommand( aCommand, aDataConsumer, &iDataSupplier );
+
+	if( err == KErrNone )
+		{
+		if(iDataSupplier)
+			{
+			err = iDataSupplier->GetTotalSize( dataLength );
+			}
+		}
+
+	// if there was an error then the result code is FAILED_ID
+	if( err != KErrNone )
+		{
+		aCommand = FAILED_ID;
+		}
+
+	// now send the response and return
+	iMsg->Msg( _L("ENGINE: Sending reply (%c, %d)."), (char)aCommand, dataLength );
+	SetState( ESendPending );
+	err = iTransport->RequestSend( aCommand, iDataSupplier );
+	asserte( err == KSTErrAsynchronous );
+
+	return;
+}
+
+/********************************************************************************
+ *
+ * CStatEngine -- MNotifyStatEngine implementation -- this is the lower level 
+ * which maintains the startup / shutdown protocol with the transport to keep 
+ * them happy and deal with the asynchronous behaviour. 
+ *
+ ********************************************************************************/
+void CStatEngine::HandleStateChange( TStateOp aOperation, TInt aResult ) 
+{
+	TPtrC opname[] = {	_L("ENGINE: <null> - response (%d)."), 
+						_L("ENGINE: InitialiseL - response (%d)."),
+						_L("ENGINE: ConnectL - response (%d)."),
+						_L("ENGINE: Disconnect - response (%d)."),
+						_L("ENGINE: Release - response (%d).") };
+
+	iMsg->Msg( opname[aOperation], aResult );
+	while( (aResult != KSTErrAsynchronous) ) {
+		if( aResult != KSTErrSuccess )
+			iController->HandleError( aResult, NULL );
+		HandleSingleStateChange( &aOperation, &aResult );
+		iMsg->Msg( opname[aOperation], aResult );
+	}
+}
+
+void CStatEngine::HandleSingleStateChange( TStateOp *aOperation, TInt *aResult )
+{
+	TStateOp thisOperation = *aOperation;
+	TInt exception, ret = KErrNone, thisResult = *aResult;
+
+	// should never get in here with a result of async
+	asserte( *aResult != KSTErrAsynchronous );
+
+	// set the operation to none by default and asynchronous which will break out of the above loop
+	*aOperation = KOpNone;
+	*aResult = KSTErrAsynchronous;
+
+	// handle each operation
+	switch( thisOperation ) {
+
+	// if initialise failed then call release, otherwise call connect
+	case KOpInitialise:			
+		if( thisResult == KSTErrSuccess ) {
+			SetState( EInitialised );
+			*aOperation = KOpConnect;
+			SetState( EConnecting );
+			TRAP( exception, (ret = iTransport->ConnectL(iRemoteHost)) );
+			*aResult = ((exception == KErrNone) ? ret : exception);
+		} else {
+			*aOperation = KOpRelease;
+			SetState( EReleasing );
+			*aResult = iTransport->Release();
+		}
+		break;
+
+	// if connect failed call disconnect, otherwise call the internal OnConnect function
+	case KOpConnect:
+		if( thisResult != KSTErrSuccess ) {
+			SetState( EDisconnecting );
+			*aOperation = KOpDisconnect;
+			*aResult = iTransport->Disconnect();
+		} else { 
+			SetState( EConnected );
+			OnConnect();
+		}
+		break;
+
+	// call release after disconnect regardless of result
+	case KOpDisconnect:
+		*aOperation = KOpRelease;
+		SetState( EReleasing );
+		*aResult = iTransport->Release();
+		break;
+
+	// exit after release
+	case KOpRelease:
+		SetState( EIdle );
+		break;
+
+	case KOpNone:
+		;
+		break;
+	}
+}
+
+void CStatEngine::HandleInitialise( TInt aResult )
+{
+	HandleStateChange( KOpInitialise, aResult );
+}
+
+void CStatEngine::HandleConnect( TInt aResult )
+{
+	HandleStateChange( KOpConnect, aResult );
+}
+
+void CStatEngine::HandleDisconnect( TInt aResult )
+{
+	HandleStateChange( KOpDisconnect, aResult );
+}
+
+void CStatEngine::HandleRelease( TInt aResult )
+{
+	HandleStateChange( KOpRelease, aResult );
+}
+
+void CStatEngine::HandleSend( TInt aResult )
+{
+	TInt err;
+
+	// we must either be sending an ack or a response 
+	asserte( iEngineStatus == ESendPending );
+	
+	if (iDeleteLastFile)
+		{
+		iCommandDecoder->DeleteLastFile();
+		iDeleteLastFile = EFalse;
+		}
+	// now that the reply has been sent wait for the next command
+	iMsg->Msg( _L("ENGINE: Reply sent (%d)."), aResult );
+	iMsg->Msg( _L("ENGINE: Waiting for next command.") );
+	asserte( iEngineStatus == ESendPending );
+	SetState( EReceivePending );
+	err = iTransport->RequestReceive();
+	asserte( err == KSTErrAsynchronous );
+}
+
+void CStatEngine::HandleReceive( TInt aResult, const TUint aCommand,
+		MDataConsumer *const aDataConsumer )
+{
+	// log the receipt
+	TInt dataLength = 0;
+	
+	if(aDataConsumer)
+		{
+		aDataConsumer->GetTotalSize( dataLength );
+		}
+	iMsg->Msg( _L("ENGINE: Command Received (%d, %c, %d)."), aResult, (char)(aCommand), dataLength );
+
+	// verify that the engine state is as expected
+	asserte( iEngineStatus == EReceivePending );
+
+	// process the command
+	iMsg->Msg( _L("ENGINE: Processing command (%c)."), (char)(aCommand) );
+	OnRecvCommand( aCommand, aDataConsumer );
+}
+
+void CStatEngine::HandleError( TInt aError, void* aErrorData )
+{
+	// log the error
+	iMsg->Msg( _L("ENGINE: Error encountered (%d)."), aError );
+
+	// call the upper layers so that the UI can notify the user that an error has
+	// occured.
+	iController->HandleError( aError, aErrorData );
+	
+	// on an error the engine takes the responsibility of closing itself down -- and 
+	// then informing the controller than it can clean up the objects.
+	SetState( EDisconnecting );
+	TInt err = iTransport->Disconnect();
+	HandleStateChange( KOpDisconnect, err );
+}
+
+void CStatEngine::HandleInfo( const TDesC *aInfo )
+{
+	iController->HandleInfo( aInfo );
+}
+
+void CStatEngine::SetState( TCommStatus aNewStatus )
+{
+	// change the internal status and notify the controller of the change
+	iEngineStatus = aNewStatus;
+	asserte( iController != NULL );
+	iController->HandleStatusChange( iEngineStatus );
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/src/stat_main.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,657 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+/********************************************************************************
+ *
+ * System Includes
+ *
+ ********************************************************************************/
+#include <e32base.h>
+#include <e32cons.h>
+#include <hal.h>
+#include <iniparser.h>
+
+
+/********************************************************************************
+ *
+ * Local Includes
+ *
+ ********************************************************************************/
+#include "stat.h"
+#include "stat_controller.h"
+#include "stat_console.h"
+#include "assert.h"
+#include "activeconsole.h"
+#include "filedump.h"
+
+#ifndef LIGHT_MODE
+#include "activeconnection.h"
+#endif // ifndef LIGHT_MODE
+
+/********************************************************************************
+ *
+ * Macro functions
+ *
+ ********************************************************************************/
+
+/********************************************************************************
+ *
+ * Definitions
+ *
+ ********************************************************************************/
+_LIT( KTxtEPOC32EX, "EPOC32EX" );
+_LIT( KFormatFailed, "failed: leave code=%d" );
+
+_LIT( KSerialBaudRate, "115200" );
+
+_LIT( KIniFile, "stat.ini" );
+_LIT( KOff, "off" );
+_LIT( KOn, "on" );
+
+// Labels used in the ini file.
+_LIT( KIniLogging, "logging" );
+_LIT( KIniTransport, "transport" );
+_LIT( KIniComPort, "comport" );
+_LIT( KIniDebugPort, "debugport" );
+#ifndef LIGHT_MODE
+_LIT( KIniTransIAP,  "iap" );
+_LIT( KIniTransSnap, "snap" );
+#endif // ifndef LIGHT_MODE
+
+// Default parameters we use if there is no ini file.
+static const TInt defaultLogging = 0;
+static const TStatConnectType defaultTransport = ESerial;
+#ifdef __WINS__
+	_LIT(KDefaultPort,"1");
+#else // def __WINS__
+	_LIT(KDefaultPort,"2");
+#endif // def __WINS__
+
+// General value for unset or incorrect data.
+static const TInt invalidValue = -1;
+
+// Test string descriptions of the transport types.
+// The choice specified in the ini file should match one
+// of these.
+static const TPtrC transportText[ENumConnectTypes] = { 
+			_L("tcpip"),
+			_L("serial"),
+			_L("ir"),
+			_L("bt"),
+			_L("usb")
+			};
+
+LOCAL_D MNotifyLogMessage *iMsg = NULL;
+LOCAL_D	RFs iFsSession;
+
+/********************************************************************************
+ *
+ * Prototypes
+ *
+ ********************************************************************************/
+LOCAL_D CConsoleBase* console;
+void callExampleL();
+void statmainL( void );
+
+/********************************************************************************
+ *
+ * Implementation
+ *
+ ********************************************************************************/
+GLDEF_C TInt E32Main()
+{
+	__UHEAP_MARK;
+	CTrapCleanup* cleanup=CTrapCleanup::New(); 
+	TRAPD(error,callExampleL()); 
+	__ASSERT_ALWAYS(!error,User::Panic(KTxtEPOC32EX,error));
+	delete cleanup; 
+	__UHEAP_MARKEND;
+	return 0; 
+}
+
+
+void callExampleL()
+{
+	console=Console::NewL( KTxtExampleCode, TSize(KConsFullScreen,KConsFullScreen) );
+	CleanupStack::PushL(console);
+	TRAPD(error,statmainL());
+	if (error)
+		console->Printf( KFormatFailed, error);
+	CleanupStack::PopAndDestroy();
+}
+
+TInt SetDebugPort(TInt aPort)
+{
+	TInt lError=KErrNone;
+
+#ifndef SYMBIAN_DIST_SERIES60
+	lError=HAL::Set(HALData::EDebugPort, aPort);
+#endif
+
+	return lError;
+}
+
+
+TInt getLogging(CIniData* aIniFile,TInt *aLogging)
+{
+	TPtrC result;
+	TBool ret=TRUE;
+
+	if(ret==TRUE)
+	{
+		//read logging
+		ret=aIniFile->FindVar(KIniLogging,result);
+	}
+
+	if(ret==TRUE)
+	{
+		TLex lLex(result);
+		TInt lLogging;
+		lLex.Val(lLogging);
+	
+		*aLogging = (lLogging)?1:0;
+	}
+
+	return (ret==TRUE)?0:1;
+}
+
+TInt getTransport(CIniData* aIniFile,TInt *aTransport)
+{
+	TPtrC result;
+	TBool ret=TRUE;
+
+	if(ret==TRUE)
+	{
+		//read transport that will be used
+		ret=aIniFile->FindVar(KIniTransport,result);
+	}
+
+	if(ret==TRUE)
+	{
+		*aTransport = invalidValue;
+		TInt count;
+		for( count = 0; ( *aTransport == invalidValue ) && ( count < ENumConnectTypes ); count++ )
+		{
+			if( 0 == ( result.Compare( transportText[count] ) ) )
+			{
+				*aTransport = count;
+			}
+		}
+
+		ret = (*aTransport != invalidValue);
+	}
+
+	return (ret==TRUE)?0:1;
+}
+
+#ifndef LIGHT_MODE
+
+TInt getIAP(CIniData* aIniFile, TDes *aIAP, CActiveConnection::TActiveConnectionMode *mode, TInt *index)
+{
+	TPtrC result;
+	TBool ret=TRUE;
+	
+	//read IAP
+	ret=aIniFile->FindVar(KIniTransIAP,result);
+	if(ret==FALSE)
+		return KErrNotFound;
+	
+	TLex lNum = TLex(result);
+	TInt lInt; 
+	TInt err = lNum.Val(lInt);
+	if (err != KErrNone)
+		return err;
+	
+	*mode = CActiveConnection::EModeIAP;
+	*index = lInt;
+	
+	aIAP->Copy(KIniTransIAP);
+	aIAP->Append(_L("|"));
+	aIAP->Append(result);
+	return KErrNone;
+}
+
+TInt getSnap(CIniData* aIniFile, TDes *aSnap, CActiveConnection::TActiveConnectionMode *mode, TInt *index)
+{
+	TPtrC result;
+	TBool ret=TRUE;
+	
+	//read snap
+	ret=aIniFile->FindVar(KIniTransSnap,result);
+	if(ret==FALSE)
+		return KErrNotFound;
+	
+	TLex lNum = TLex(result);
+	TInt lInt; 
+	TInt err = lNum.Val(lInt);
+	if (err != KErrNone)
+		return err;
+	
+#ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
+	*mode = CActiveConnection::EModeSnap;
+	*index = lInt;
+	
+	aSnap->Copy(KIniTransSnap);
+	aSnap->Append(_L("|"));
+	aSnap->Append(result);
+	return KErrNone;
+#else
+	_LIT(KError,"INFO: Access Point selection is not supported..\n");
+	console->Printf(KError);
+
+	// use default IAP connection
+	aSnap->Zero();
+	*mode = CActiveConnection::EModeIAP;
+	*index = 0;
+
+	return KErrNotSupported;
+#endif // SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
+}
+
+#endif // ifndef LIGHT_MODE
+
+TInt getPort(CIniData* aIniFile,TDes *AtbAddress)
+{
+	TPtrC result;
+	TBool ret=TRUE;
+	TInt lError=KErrNone;
+	
+	if(ret==TRUE)
+	{
+		//read comport setting
+		ret=aIniFile->FindVar(KIniComPort,result);
+	}
+
+	if(ret==TRUE)
+	{
+		
+		if(lError==KErrNone)
+		{
+			AtbAddress->Append( result );
+		}
+		else
+		{
+			ret = FALSE;
+		}
+	}
+
+	return (ret==TRUE)?0:1;
+}
+
+TInt getDebugPort(CIniData* aIniFile,TInt *aDebugPort)
+{
+	TPtrC result;
+	TBool ret=TRUE;
+	TInt lError=KErrNone;
+	
+	if(ret==TRUE)
+	{
+		//read debug port setting
+
+		// If we have found an entry for the debug
+		// port then extract it.
+		// If there is no debug port specified then there
+		// is no error (and no 'else').
+		if(aIniFile->FindVar(KIniDebugPort,result))
+		{
+			TLex lLexPort(result); //retrive integer value for comport 
+			TInt lPort;
+			lError=lLexPort.Val(lPort);
+
+			if(lError==KErrNone)
+			{
+				*aDebugPort = lPort;
+			}
+			else
+			{
+				ret = FALSE;
+			}
+		}
+	}
+	
+	return (ret==TRUE)?0:1;
+}
+
+#ifdef LIGHT_MODE
+TInt getparams( TInt *logging, TInt *transport, TDes *tbAddress )
+#else
+TInt getparams( TInt *logging, TInt *transport, TDes *tbAddress, CActiveConnection::TActiveConnectionMode *mode, TInt *index )
+#endif // ifndef LIGHT_MODE
+{
+	// validate params 
+	asserte( logging != NULL );
+	asserte( transport != NULL );
+	asserte( tbAddress != NULL );
+#ifndef LIGHT_MODE
+	asserte( mode != NULL );
+	asserte( index != NULL );
+#endif // ifndef LIGHT_MODE
+	TInt lError=KErrNone;
+	TInt debugPort = invalidValue;
+
+	// open cinidata object
+	CIniData* lIniFile=NULL;
+
+	TRAPD(r,lIniFile=CIniData::NewL(KIniFile));
+	if(r!=KErrNone)	//ini file not found, use defaults
+	{
+		_LIT(KMsg,"stat.ini file not found, using defaults...\n");
+		console->Printf(KMsg);
+		
+		*logging = defaultLogging;
+		*transport = defaultTransport;
+		(*tbAddress) = KDefaultPort;
+	}
+	else
+	{
+		if(lError==KErrNone)
+		{
+			lError=getLogging(lIniFile,logging);
+
+			if(lError!=KErrNone)
+			{
+				_LIT(KError,"ERROR: Failed to read logging setting in stat.ini file.\n");
+				console->Printf(KError);
+			}
+		}
+
+		if(lError==KErrNone)
+		{
+			lError=getTransport(lIniFile,transport);
+
+			if(lError!=KErrNone)
+			{
+				_LIT(KError,"ERROR: Failed to read transport setting in stat.ini file.\n");
+				console->Printf(KError);
+			}
+		}
+
+		if(lError==KErrNone)
+		{
+			lError=getPort(lIniFile,tbAddress);
+
+			if(lError!=KErrNone)
+			{
+				_LIT(KError,"ERROR: Failed to read COM port address setting in stat.ini file.\n");
+				console->Printf(KError);
+			}
+		}
+
+		if(lError==KErrNone)
+		{
+			lError=getDebugPort(lIniFile,&debugPort);
+
+			if(lError!=KErrNone)
+			{
+				_LIT(KError,"ERROR: Failed to read debug port address setting in stat.ini file.\n");
+				console->Printf(KError);
+			}
+		}
+	}
+
+	// Handle any special cases with data.
+	if(lError==KErrNone)
+	{
+		if((*transport==ESerial)||(*transport==EInfrared))
+		{
+			// Append the baud rate to the COM port text string.
+			tbAddress->Append( _L("|") );
+			tbAddress->Append( KSerialBaudRate );
+		}
+#ifndef LIGHT_MODE
+		else if (*transport == ETCPIP)
+		{
+			// Load TCPIP specific parameters
+			lError = getIAP(lIniFile, tbAddress, mode, index);
+			if (lError!=KErrNone)
+				getSnap(lIniFile, tbAddress, mode, index);
+			
+			// reset error
+			lError = KErrNone;
+		}
+#endif // ifndef LIGHT_MODE
+	}
+
+	delete lIniFile;
+	lIniFile = NULL;
+
+	// Set the debug port to the value from the ini file
+	// of the default value.
+	if(lError==KErrNone)
+	{
+		// Only set the debug port if the user
+		// specified a value.
+		if(debugPort!=invalidValue)
+		{
+			lError = SetDebugPort(debugPort);
+
+			if(lError!=KErrNone)
+			{
+				_LIT(KError,"ERROR: Failed to set the debug port.\n");
+				console->Printf(KError);
+			}
+		}
+	}
+
+	// Display data to the user.
+	if(lError==KErrNone)
+	{
+		// Logging.
+		console->Printf(_L("logging is %S.\n\r"),
+					(0==(*logging))?&KOff:&KOn);
+
+		// Transport.
+		console->Printf(_L("transport = %S.\n\r"), &(transportText[*transport]));
+
+		// Port or address.
+		console->Printf(_L("port = %S.\n\r"), tbAddress);
+
+		// Debug port.
+		if(debugPort!=invalidValue)
+		{
+			console->Printf(_L("debugport = %d.\n\r"), debugPort);
+		}
+		else
+		{
+			console->Printf(_L("debugport is unchanged.\n\r"));
+		}
+	}
+
+	return lError;
+}
+
+void NotifyStarted()
+{
+	RNotifier notifier;
+	if(notifier.Connect() != KErrNone) {
+		return;
+	}
+    notifier.InfoPrint(_L("Starting STAT..."));
+    notifier.Close();
+}
+
+
+
+
+void statmainL( void )
+{
+	CActiveScheduler *iActiveScheduler = NULL;
+	CStatController *iController = NULL;
+	TInt sessionid = 0;
+	TInt err = 0;
+	TInt logging = 0;
+	TInt transport = 0;
+	CStatConsole *iConsole = NULL;
+
+#ifndef LIGHT_MODE
+	CActiveConnection::TActiveConnectionMode mode = CActiveConnection::EModeIAP;
+	TInt index = 0;
+#endif // ifndef LIGHT_MODE
+
+	TBuf<KAddressTextLimit> tbAddress;
+
+	User::LeaveIfError( iFsSession.Connect() );
+	iMsg = new FileDump();
+	
+	NotifyStarted(); //print a notification to the screen
+	
+#ifdef LIGHT_MODE	//lite version can't be hide to background
+	console->Printf( _L("** STAT Lite Version %u.%u.%u **\n\n"),KVersionMajor,KVersionMinor,KVersionPatch);	
+	console->Printf( _L("Press ESC to exit\n") );
+#else
+	console->Printf( _L("** STAT Version %u.%u.%u **\n\n"),KVersionMajor,KVersionMinor,KVersionPatch);
+	console->Printf( _L("Press ESC to exit, or 'b' to switch to the background\n") );
+#endif
+
+	// get the params for STAT
+#ifndef LIGHT_MODE
+	err = getparams( &logging, &transport, &tbAddress, &mode, &index );
+#else
+	err = getparams( &logging, &transport, &tbAddress );
+#endif // ifndef LIGHT_MODE
+	if( err != KErrNone ) {
+		console->Printf( _L("ERROR: Couldn't retrieve parameters.\n") );
+		console->Printf( _L("Please check stat.ini file.\n") );
+		console->Printf( _L("Press any key to exit.\n\r") );
+		console->Getch();
+		return;
+	}
+	
+#ifdef LIGHT_MODE	//lite version can't be hide to background
+	if (transport != ESerial){
+		console->Printf( _L("\nERROR: STAT lite only support serial connection.\n") );
+		console->Printf( _L("Press any key to exit.\n\r") );
+		console->Getch();
+		return;
+	}
+#endif
+	TBuf<KMaxFileName> statLogFile;
+	
+	TDriveNumber defaultSysDrive(EDriveC);
+	RLibrary pluginLibrary;
+	TInt pluginErr = pluginLibrary.Load(KFileSrvDll);
+	
+	if (pluginErr == KErrNone)
+		{
+		typedef TDriveNumber(*fun1)();
+		fun1 sysdrive;
+	
+	#ifdef __EABI__
+		sysdrive = (fun1)pluginLibrary.Lookup(336);
+	#else
+		sysdrive = (fun1)pluginLibrary.Lookup(304);
+	#endif
+		
+		if(sysdrive!=NULL)
+			{
+			defaultSysDrive = sysdrive();			
+			}
+		}
+	pluginLibrary.Close();
+	
+	statLogFile.Append(TDriveUnit(defaultSysDrive).Name());
+	statLogFile.Append(KFileSeparator);
+	statLogFile.Append(KStatLogFile);
+
+	if( logging )
+		{
+		iMsg->Init( iFsSession, statLogFile, console );
+		}
+
+	// create an active scheduler
+	iActiveScheduler= new(ELeave) CActiveScheduler;
+	CActiveScheduler::Install( iActiveScheduler );
+
+#ifndef LIGHT_MODE
+	// active object used to start ppp connection, only started if using tcpip 
+	CActiveConnection* lAOConnection=CActiveConnection::NewL(_L("81.89.143.203"),80);
+	// if we are using tcpip
+	if(transport == ETCPIP)
+	{
+		lAOConnection->Start(mode, index); 
+	}
+#else
+	if( transport != ESerial )
+	{
+		console->Printf( _L("ERROR: statlite supports only serial connection.\n") );
+		console->Printf( _L("Please check stat.ini file.\n") );
+		console->Printf( _L("Press any key to exit.\n\r") );
+		console->Getch();
+		return;
+	}
+#endif // ifndef LIGHT_MODE
+
+	// create the console object to receive notifications from the controller
+	iConsole = CStatConsole::NewL(console, iMsg);
+	
+	// create and run the controller
+	iController = CStatController::NewL(); 
+	sessionid = iController->StartSession( (enum TStatConnectType)transport, &tbAddress, iConsole, &iFsSession, iMsg );
+
+	if(-1 == sessionid)
+		{
+		console->Printf( _L("Initialisation failed.  Press ESC to exit.\n") );
+		}
+
+	// create active object to monitor console for escape(exit) and b(push to background) 
+	CActiveConsole* lAOConsole=CActiveConsole::NewL(console,iController,iConsole,sessionid,iMsg);
+	lAOConsole->Start(); 
+
+	// now wait for events -- there MUST be a read outstanding here
+	// Issue the first request
+	iActiveScheduler->Start();
+
+	delete lAOConsole;
+
+#ifndef LIGHT_MODE
+	//cancel and destroy activeconsole
+	if(transport == ETCPIP)
+	{
+		lAOConnection->CloseSocket();
+	}
+	delete lAOConnection;
+#endif // ifndef LIGHT_MODE
+
+	// cleanup the controller
+	delete iController;
+
+	// cleanup the console thing	
+	delete iConsole;
+
+	// cleanup the active scheduler
+	delete iActiveScheduler;
+
+	if( iMsg->IsInitialised() )
+		{
+		iMsg->CloseFile();
+		}
+
+	iFsSession.Close();
+
+	delete iMsg;
+	iMsg =	NULL;
+}
+
+/********************************************************************************
+ *
+ * Notification object
+ *
+ ********************************************************************************/
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/src/stat_packetisation.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,600 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+ /**************************************************************************************
+ *
+ * Packetisation transport for STAT -- for packet based network layers
+ *
+ *************************************************************************************/
+#include <e32std.h>
+#include <e32base.h>
+
+/**************************************************************************************
+ *
+ * Local Includes
+ *
+ *************************************************************************************/
+#include "assert.h"
+#include "stat.h"
+#include "stat_packetisation.h"
+#include "dataconsumer_memory.h"
+#include "dataconsumer_file.h"
+
+/*************************************************************************
+ *
+ * Definitions
+ *
+ *************************************************************************/
+#define KMinDataSize		64
+#define KMinPacketSize		KHeaderSize + KMinDataSize
+
+ /**************************************************************************************
+ *
+ * CStatTransportPacketisation - Construction
+ *
+ *************************************************************************************/
+CStatTransportPacketisation *CStatTransportPacketisation::NewL( MNotifyStatEngine *aStatEngine, MStatNetwork *aStatNetwork, TUint aPacketSize )
+{
+    CStatTransportPacketisation *self = new (ELeave) CStatTransportPacketisation();
+    CleanupStack::PushL(self);
+	self->ConstructL( aStatEngine, aStatNetwork, aPacketSize );
+	CleanupStack::Pop();
+    return self;
+}
+
+CStatTransportPacketisation::CStatTransportPacketisation() :
+	iDataSupplier( NULL )
+{
+}
+
+void CStatTransportPacketisation::ConstructL( MNotifyStatEngine *aStatEngine, MStatNetwork *aStatNetwork, TUint aPacketSize )
+{
+	// check params
+	asserte( aStatEngine != NULL );
+	asserte( aStatNetwork != NULL );
+	asserte( aPacketSize >= KMinPacketSize );
+
+	// setup general members
+	iStatEngine = aStatEngine;
+	iStatNetwork = aStatNetwork;
+	iTransportStatus = EIdle;
+	iSendStatus = ESendIdle;
+	iRecvStatus = EReceiveIdle;
+	iDataPacketSize = aPacketSize;
+
+	// setup send buffer members
+	iSendFragment = NULL;
+	iSendCommand = 0;
+	iSendDataLength = 0;
+	iSendDataWritten = 0;
+	iSendDataAcknowledged = 0;
+
+	// setup recv buffer members
+	iRecvCommand = 0;
+	iRecvDataLength = 0;
+	iRecvDataReceived = 0;
+}
+
+CStatTransportPacketisation::~CStatTransportPacketisation()
+{
+	if( iSendFragment != NULL )
+		{
+		delete iSendFragment;
+		iSendFragment = NULL;
+		}
+	if( iDataConsumer )
+		{
+		iDataConsumer->Delete( );
+		iDataConsumer = NULL;
+		}
+}
+
+/**************************************************************************************
+ *
+ * CStatTransportPacketisation - MStatApiTransport - all calls except for send are 
+ * passed straight through to the network layer (a flag is recorded for receive as
+ * well). See the STAT design spec doc for the packetisation protocol.
+ *
+ *************************************************************************************/
+TInt CStatTransportPacketisation::InitialiseL( void )
+{
+	return iStatNetwork->InitialiseL( this );
+}
+
+TInt CStatTransportPacketisation::ConnectL( TDesC *aRemoteHost )
+{
+	return iStatNetwork->ConnectL( aRemoteHost );
+}
+
+TInt CStatTransportPacketisation::RequestReceive( void )
+{
+	// set the state and wait for the header
+	iTransportStatus = EReceivePending;
+	iRecvStatus = EReceivingInitialHeader;
+	return iStatNetwork->RequestReceive( KHeaderSize );
+}
+
+TInt CStatTransportPacketisation::Disconnect( void )
+{
+	return iStatNetwork->Disconnect();
+}
+
+TInt CStatTransportPacketisation::Release( void )
+{
+	return iStatNetwork->Release();
+}
+
+TText8 *CStatTransportPacketisation::Error( void )
+{
+	return iStatNetwork->Error();
+}
+
+
+TInt CStatTransportPacketisation::RequestSend( const TUint aCommand, MDataSupplier *const aDataSupplier)
+	{
+	TInt err = KErrNone;
+
+	// make sure a packet can fit the header and at least some data -- otherwise it's useless
+	asserte( iDataPacketSize >= KMinPacketSize );
+
+	// check the state is as expected
+	asserte( iTransportStatus == EIdle );
+	asserte( iSendStatus == ESendIdle );
+
+	// Take a copy of the pointer to the data supplier.
+	iDataSupplier = aDataSupplier;
+
+	// save the command and its data
+	iSendCommand = aCommand;
+	iSendDataLength = 0;
+	if(iDataSupplier)
+		{
+		TInt dataLength = 0;
+		err = iDataSupplier->GetTotalSize( dataLength );
+
+		if( err == KErrNone )
+			{
+				iSendDataLength = static_cast<TUint>(dataLength);
+			}
+		}
+	iSendDataWritten = 0;
+
+	if( err == KErrNone )
+	{
+		// create and send the initial header
+		SendHeaderPacket( iSendCommand, iSendDataLength );
+		err = KSTErrAsynchronous;
+	}
+
+	return (err);
+}
+
+
+
+/**************************************************************************************
+ *
+ * CStatTransportPacketisation - MNotifyStatTransport - all events except HandleSend
+ * and HandleReceive are sent straight through to the engine.  
+ *
+ *************************************************************************************/
+void CStatTransportPacketisation::HandleInitialise( TInt aResult )
+{
+	iStatEngine->HandleInitialise( aResult );
+}
+
+void CStatTransportPacketisation::HandleConnect( TInt aResult )
+{
+	iStatEngine->HandleConnect( aResult );
+}
+
+void CStatTransportPacketisation::HandleDisconnect( TInt aResult )
+{
+	iStatEngine->HandleDisconnect( aResult );
+}
+
+void CStatTransportPacketisation::HandleRelease( TInt aResult )
+{
+	iStatEngine->HandleRelease( aResult );
+}
+
+void CStatTransportPacketisation::HandleError( TInt aError, void *aErrorData )
+{
+	iStatEngine->HandleError( aError, aErrorData );
+}
+
+void CStatTransportPacketisation::HandleInfo( const TDesC *aInfo )
+{
+	iStatEngine->HandleInfo( aInfo );
+}
+
+/**************************************************************************************
+ *
+ * CStatTransportPacketisation - HandleSend
+ *
+ *************************************************************************************/
+void CStatTransportPacketisation::HandleSend( TInt aResult )
+{
+	TUint remainingBytes, packetSize, err;
+	
+	// handle each state
+	switch( iSendStatus ) {
+
+	case ESendingInitialHeader:
+
+		// wait for an acknowledgement for the header
+		iTransportStatus = EReceivePending;
+		iRecvStatus = EReceivingFragmentAck;
+		iSendStatus = ESendIdle;
+		err = iStatNetwork->RequestReceive( KHeaderSize );
+		asserte( err == KSTErrAsynchronous );                   
+		break;
+
+	case ESendingFragmentHeader:
+
+		// if there is data left to send then send it -- otherwise we have completed a send
+		if( iSendDataWritten == iSendDataLength ) {
+			NotifyEngineSend( aResult );
+		} else {
+			remainingBytes = iSendDataLength - iSendDataWritten;
+			packetSize = ((remainingBytes < iDataPacketSize) ? remainingBytes : iDataPacketSize);
+
+			asserte( packetSize <= iDataPacketSize );
+
+			iSendFragment = HBufC8::NewMax(packetSize);
+			if(iSendFragment)
+			{
+				TInt dataCopied = 0;
+				iDataSupplier->GetData( *iSendFragment, packetSize, dataCopied );
+
+				// When we do the sending the data we send
+				// is of size 'bufferSize' but we must only
+				// add 'packetSize' to the running total of
+				// data written.
+				iTransportStatus = ESendPending;
+				iSendStatus = ESendingFragmentData;
+				iSendDataWritten += packetSize;
+				err = iStatNetwork->RequestSend( iSendFragment, packetSize );
+				asserte( err == KSTErrAsynchronous );
+			}
+		}
+		break;
+
+	case ESendingFragmentData:
+
+		// if we have just sent some data then free the buffer
+		asserte( iSendFragment != NULL );
+		delete iSendFragment;
+		iSendFragment = NULL;
+
+		// if we are not packetising data then we have completed the send otherwise we are 
+		// packetising data then the remote host will send an acknowledgement
+		if( iSendDataLength <= iDataPacketSize ) {
+			NotifyEngineSend( aResult );
+		} else {
+			iTransportStatus = EReceivePending;
+			iRecvStatus = EReceivingFragmentAck;
+			iSendStatus = ESendIdle;
+			err = iStatNetwork->RequestReceive( KHeaderSize );
+			asserte( err == KSTErrAsynchronous );
+		}
+		break;
+		
+	case ESendingFragmentAck:
+
+		// if we have just sent a fragment ack then wait for the next fragment header
+		iTransportStatus = EReceivePending;
+		iRecvStatus = EReceivingFragmentHeader;
+		iSendStatus = ESendIdle;
+		err = iStatNetwork->RequestReceive( KHeaderSize );
+		asserte( err == KSTErrAsynchronous );
+		break;
+
+	case ESendIdle:
+		;
+		break;
+	}
+}
+
+/**************************************************************************************
+ *
+ * CStatTransportPacketisation - HandleReceive
+ *
+ *************************************************************************************/
+void CStatTransportPacketisation::HandleReceive( TInt aResult, TDesC8 *aData, TUint aDataLength )
+{
+	TUint *pData, packetSize, remainingBytes, recvCommand, recvLength = 0;
+	TInt err;
+
+	
+	
+	// make sure that we thought we were waiting to receive
+	asserte( aResult == KErrNone );
+	asserte( iTransportStatus == EReceivePending );
+	asserte( iRecvStatus != EReceiveIdle );
+	
+	
+	// Handle a special case where we receive a modem query
+	// from the (Windows) system.  There is a chance that we
+	// will recieve a series of modem query strings of three
+	// lots of 'AT'.  When that happens we need to ignore it.
+	// Usually we use the 'L' macro and let the preprocessor
+	// sort out the length of the character but we have to
+	// force it here because in a UNICODE build the serial
+	// port still delivers 8 bit characters.
+	static const TInt modemQueryLength = 8;
+	static const TLitC8<modemQueryLength + 1> modemQuery = { modemQueryLength, "AT\rAT\rAT" };
+
+	if( (static_cast<TInt>(aDataLength) == modemQueryLength) && 
+			(0 == aData->Compare(modemQuery.operator const TDesC8&()) ))
+	{
+		return;
+	}
+	// End special case of modem query.
+	
+	// STEP 1: process the incoming message
+	switch( iRecvStatus ) {
+
+	case EReceivingInitialHeader:
+
+		// extract the header info and setup the local receive state 
+		pData = (TUint*)aData->Ptr();
+		iRecvCommand = iStatNetwork->NtoHl( pData[0] );
+		iRecvDataLength = iStatNetwork->NtoHl( pData[1] );
+
+		// if this is a resync then abort the connection
+		if( iRecvCommand == RESYNC_ID ) {
+			iStatEngine->HandleError( KSTErrResyncCommand, (void*)0 );
+			iSendStatus = ESendIdle;
+			iRecvStatus = EReceiveIdle;
+			iTransportStatus = EIdle;
+			return;
+		}
+
+		// allocate the data buffers 
+		asserte( iRecvDataReceived == 0 );
+		if( iRecvDataLength > 0 )
+			{
+			// Determine if we use a memory receive buffer
+			// or a temporary file.  Purely arbitary size.
+			static const unsigned int maxSizeOfMemoryConsumer = (1024 * 4);
+
+			if( iRecvDataLength < maxSizeOfMemoryConsumer )
+				{
+				iDataConsumer = CDataConsumerMemory::NewL( );
+				}
+			else
+				{
+				iDataConsumer = CDataConsumerFile::NewL( );
+				}
+			}
+
+		// If the data length is greater that iDataPacketSize then the desktop will
+		// packetise the data into fragments each with a header. If the data is not
+		// packetised then the initial header is equivalent to a fragment header.
+		if( iRecvDataLength <= iDataPacketSize ) {
+			iRecvStatus = EReceivingFragmentHeader;
+			recvCommand = iRecvCommand;
+			recvLength = iRecvDataLength;
+		}
+		break;
+
+	case EReceivingFragmentHeader:
+		
+		// check that this is a fragment header as expected
+		asserte( aDataLength == KHeaderSize );
+		pData = (TUint*)aData->Ptr();
+		recvCommand = iStatNetwork->NtoHl( pData[0] );
+		recvLength = iStatNetwork->NtoHl( pData[1] );
+
+		// if this is not the expected command (e.g. a resync) then throw an error 
+		if( (recvCommand != iRecvCommand) ) {
+			iStatEngine->HandleError( KSTErrUnexpectedFragmentCommand, (void*)recvCommand );
+			iSendStatus = ESendIdle;
+			iRecvStatus = EReceiveIdle;
+			iTransportStatus = EIdle;
+			return;
+		}
+		break;
+
+	case EReceivingData:
+		{
+		// received data is placed into the receive buffer
+		asserte( (iRecvDataReceived + aDataLength) <= iRecvDataLength );
+		iDataConsumer->AddData( *aData );
+		iRecvDataReceived += aDataLength;
+		break;
+		}
+	case EReceivingFragmentAck:
+		
+		// check that this is a fragment ack as expected
+		asserte( aDataLength == KHeaderSize );
+		pData = (TUint*)aData->Ptr();
+		recvCommand = iStatNetwork->NtoHl( pData[0] );
+		recvLength = iStatNetwork->NtoHl( pData[1] );
+
+		// if this is not the expected command (e.g. a resync) then throw an error 
+		if( (recvCommand != iSendCommand) ) {
+			iStatEngine->HandleError( KSTErrUnexpectedFragmentCommand, (void*)recvCommand );
+			iSendStatus = ESendIdle;
+			iRecvStatus = EReceiveIdle;
+			iTransportStatus = EIdle;
+			return;
+		}
+		asserte( recvLength == 0 );
+
+		// update the number of bytes acknowledged
+		iSendDataAcknowledged = iSendDataWritten;
+		break;
+
+	case EReceiveIdle:
+		;
+		break;
+	}
+
+	// STEP 2: decide what to do next
+	switch( iRecvStatus ) {
+
+	case EReceivingInitialHeader:
+
+		// send an acknowledgement for the initial header
+		SendAckPacket( iRecvCommand );
+		break;
+
+	case EReceivingFragmentHeader:
+
+		// if there is more data then wait for it -- otherwise the receive is complete
+		if( recvLength > 0 ) {
+			iTransportStatus = EReceivePending;
+			iRecvStatus = EReceivingData;
+			err = iStatNetwork->RequestReceive( recvLength );	
+			asserte( err == KSTErrAsynchronous );
+		} else {
+			NotifyEngineReceive( aResult );
+		}
+		break;
+
+	case EReceivingData:
+
+		// If we have received some packetised data then we have to acknowledge it. Otherwise
+		// we have completed a receive and should notify the engine and clean up.
+		if( iRecvDataLength > iDataPacketSize)
+			SendAckPacket( iRecvCommand );
+		else
+			NotifyEngineReceive( aResult );
+		break;
+
+	case EReceivingFragmentAck:
+
+		// if the desktop has just acknowledged a fragment then we send the next fragment header,
+		// even if there are no more bytes to send.	
+		remainingBytes = iSendDataLength - iSendDataWritten;
+		packetSize = ((remainingBytes < iDataPacketSize) ? remainingBytes : iDataPacketSize);
+		SendHeaderPacket( iSendCommand, packetSize );
+		break;
+
+	case EReceiveIdle:
+		;
+		break;
+	}
+}
+
+/**************************************************************************************
+ *
+ * Helper functions
+ *
+ *************************************************************************************/
+void CStatTransportPacketisation::SendHeaderPacket( TUint aCommand, TUint aDataLength )
+{
+	TUint err;
+
+	// construct the header in iSendHeader
+	BuildHeader( aCommand, aDataLength );
+
+	// set the state
+	iTransportStatus = ESendPending;
+	iRecvStatus = EReceiveIdle;
+	iSendStatus = ((aDataLength > iDataPacketSize) ? ESendingInitialHeader : ESendingFragmentHeader);
+
+	// send it
+	err = iStatNetwork->RequestSend( &iSendHeader, KHeaderSize );
+	asserte( err == KSTErrAsynchronous );
+}
+
+void CStatTransportPacketisation::SendAckPacket( TUint aCommand )
+{
+	TUint err;
+
+	// construct the header in iSendHeader
+	BuildHeader( aCommand, 0 );
+
+	// set the state
+	iTransportStatus = ESendPending;
+	iRecvStatus = EReceiveIdle;
+	iSendStatus = ESendingFragmentAck;
+
+	// send it
+	err = iStatNetwork->RequestSend( &iSendHeader, KHeaderSize );
+	asserte( err == KSTErrAsynchronous );
+}
+
+void CStatTransportPacketisation::BuildHeader( TUint aCommand, TUint aDataLength )
+{
+	TInt nbCommand, nbLength;
+	TUint *buff;
+
+	// create the header
+	nbCommand = iStatNetwork->HtoNl( aCommand );
+	nbLength = iStatNetwork->HtoNl( aDataLength );
+	iSendHeader.SetLength( 0 );
+	buff = (TUint*)iSendHeader.Ptr();
+	buff[0] = nbCommand;
+	buff[1] = nbLength;
+	iSendHeader.SetLength( KHeaderSize );
+}
+
+void CStatTransportPacketisation::NotifyEngineSend( TUint aResult )
+{
+	// check the state is as expected
+	asserte( iSendDataWritten == iSendDataLength );
+	asserte( (iSendDataLength <= iDataPacketSize) || (iSendDataAcknowledged == iSendDataLength) );
+	
+	// clear the state
+	iSendCommand = 0;
+	iSendDataLength = 0;
+	iSendDataWritten = 0;
+	iSendDataAcknowledged = 0;
+
+	iTransportStatus = EIdle;
+	iSendStatus = ESendIdle;
+
+	// notify the engine
+	iStatEngine->HandleSend( aResult );
+}
+
+void CStatTransportPacketisation::NotifyEngineReceive( TUint aResult )
+{
+	// check the state is as expected
+	asserte( iRecvDataLength == iRecvDataReceived || iRecvDataLength==(unsigned long)-1);
+	asserte( (iRecvDataLength == 0) || (iDataConsumer != NULL) );
+	
+	// clear the send state (allows sending from the receive handler) but don't clear
+	// the recvstatus since the buffers are still in use. This could be solved by 
+	// creating multiple buffers but there is no need now and this would be slow
+	iTransportStatus = EIdle;
+	iSendStatus = ESendIdle;
+
+	// notify the engine 
+	iStatEngine->HandleReceive( aResult, iRecvCommand, iDataConsumer );
+
+	// clear the status state
+	iRecvStatus = EReceiveIdle;
+
+	// clear the recv buffer state
+	iRecvCommand = 0;
+	iRecvDataLength = 0;
+	iRecvDataReceived = 0;
+	iRecvDataAcknowledged = 0;
+
+	if(iDataConsumer)
+		{
+		iDataConsumer->Delete( );
+		iDataConsumer = NULL;
+		}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/src/stat_serial.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,727 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+ /**************************************************************************************
+ *
+ * Packetisation transport for STAT -- for packet based network layers
+ *
+ *************************************************************************************/
+
+/**************************************************************************************
+ *
+ * Local Includes
+ *
+ *************************************************************************************/
+#include "assert.h"
+#include "stat.h"
+#include "stat_serial.h"
+#include "msgwin.h"
+#include "../../../../common/inc/serialpacketsize.h"
+
+/**************************************************************************************
+ *
+ * Definitions
+ *
+ *************************************************************************************/
+#ifndef LIGHT_MODE
+_LIT(LDD_NAME,"ECOMM");
+#ifdef __WINS__
+_LIT(PDD_NAME,"ECDRV");
+#else
+_LIT(PDD_NAME,"EUART1");
+#endif
+#endif // ifndef LIGHT_MODE
+
+#define KMaxTimeoutRetries	(0x0FFFFFFF)
+#define KWriteTimeout		50000000
+
+// Moved this data definitions to the source file where they are
+// less public.
+#define KReadTimeout								30000000
+
+/********************************************************************************
+ *
+ * Macro functions
+ *
+ ********************************************************************************/
+
+/**************************************************************************************
+ *
+ * CStatApiSerial - Construction
+ *
+ *************************************************************************************/
+CStatApiSerial* CStatApiSerial::NewL( TPtrC16 aModule )
+{
+    CStatApiSerial *self = new (ELeave) CStatApiSerial();
+    CleanupStack::PushL(self);
+	self->ConstructL( aModule );
+	CleanupStack::Pop();
+    return self;
+}
+
+CStatApiSerial::CStatApiSerial() : CActive(EPriorityStandard)
+{
+}
+
+CStatApiSerial::~CStatApiSerial()
+{
+	// remove from active scheduler
+	Deque();
+
+	// clean up params
+	if( iRecvBuffer != NULL )
+		delete iRecvBuffer;
+	if( iRecvBufferPtr != NULL )
+		delete iRecvBufferPtr;
+
+#ifndef LIGHT_MODE
+	iCommPort.Close();
+	iCommServer.Close();
+#else // ifndef LIGHT_MODE
+	if( NULL != iCommPort )
+		{
+		CloseSerialPort( iCommPort );
+		iCommPort =	NULL;
+		}
+	if( NULL != iCommServer )
+		{
+		CloseSerialServer( iCommServer );
+		iCommServer =	NULL;
+		}
+#endif // ifndef LIGHT_MODE
+}
+
+void CStatApiSerial::ConstructL( TPtrC16 aModule )
+{
+	// add to active scheduler
+	CActiveScheduler::Add(this);
+
+	// set parameters
+	asserte( aModule.Length() <= KModuleSize );
+	iModule.Copy( aModule );
+	iRecvBuffer = NULL;
+	iRecvBufferPtr = NULL;
+	iRecvLength = 0;
+	iRWStatus = ENoRW;
+	iSerialStatus = EIdle;
+	iTransport = NULL;
+	iRetries = 0;
+	iCommOldSettingsValid = 0;
+
+#ifdef LIGHT_MODE
+	iCommServer =	NULL;
+	iCommPort =	NULL;
+#endif // ifdef LIGHT_MODE
+
+	// Initialise the sub-type.  We have the iModule text string
+	// and we use it below determine the subtype.
+	iSubType = EInvalid;
+	iMaxPacketSize = KMaxPacketSize;
+
+	// Check the iModule text string to determine our serial
+	// transport sub-type.
+	DetermineSubTypeL();
+	asserte( EInvalid != iSubType );
+}
+
+/**************************************************************************************
+ *
+ * CStatApiSerial - MStatNetwork - Initialise and Release
+ *
+ *************************************************************************************/
+TInt CStatApiSerial::InitialiseL( MNotifyStatTransport *aTransport )
+{
+	TInt r = KErrNone;
+
+	// save the transport interface
+	iTransport = aTransport;
+
+	// set the state
+	SetStatus( EInitialising );
+
+#ifndef LIGHT_MODE
+	// Under WINS we must force a link to the file server so that we're sure we'll be 
+	// able to load the device drivers. On a MARM implementation, this code would not
+	// be required because higher level components (EIKON) will automatically have started 
+	// the services. NOTE: this is now no longer required since we are an app and so even
+	// on WINS everything else should have started up by now.
+
+	// Load up the physical and the logical device drivers. If they are already loaded 
+	// then it won't make any difference.
+	r = User::LoadPhysicalDevice( PDD_NAME );
+	if( (r != KErrNone) && (r != KErrAlreadyExists) ) {
+		User::Leave( r );
+	}
+	r = User::LoadLogicalDevice( LDD_NAME );	
+	if( (r != KErrNone) && (r != KErrAlreadyExists) ) {
+		User::Leave( r );
+	}
+	
+	// Both WINS and EIKON will have started the comms server process.
+	// (this is only really needed for ARM hardware development racks)
+#ifndef __WINS__
+	r = StartC32();
+	if( (r != KErrNone) && (r != KErrAlreadyExists) )
+		User::Leave( r );
+#endif
+#else // ifndef LIGHT_MODE
+
+	// Do a specific load of the library at this point.	
+	r = serialDriverLib.Load(_L("SerialDriver.dll"));
+	if (r != KErrNone)
+		User::Leave( r );
+
+	iCommServer =	OpenSerialServerL( );
+	
+	if (iCommServer == NULL)
+		User::Leave( KErrNotFound );
+		
+#endif // ifndef LIGHT_MODE
+
+	r = OnInitialiseL(r);
+
+	return (r);
+}
+
+/**************************************************************************************
+ *
+ * CStatApiSerial - OnInitialiseL
+ * 
+ * Method added to allow for the seperation of InitialiseL into two parts.
+ * The first part is still InitialiseL.  The second part is here and
+ * is either called directly or from the RunL callback.
+ *************************************************************************************/
+TInt CStatApiSerial::OnInitialiseL(TInt resultCode)
+{
+	TInt r = resultCode;
+
+	if (r >= 0 )
+	{
+#ifndef LIGHT_MODE
+		// Now connect to the comm server
+		
+		User::LeaveIfError( iCommServer.Connect() );
+
+		// Load the CSY module
+		r = iCommServer.LoadCommModule( iModule );
+		User::LeaveIfError( r );
+
+		// check we loaded correctly
+		TInt numPorts;
+		r = iCommServer.NumPorts( numPorts );
+		User::LeaveIfError( r );
+#endif // ifndef LIGHT_MODE
+
+		// set the state
+		SetStatus( EInitialised );
+	}
+
+	return r;
+}
+
+TInt CStatApiSerial::Release(void)
+{
+	// make sure the status is as expected
+	asserte( (iSerialStatus == EInitialising) || (iSerialStatus == EInitialised) || (iSerialStatus == EDisconnected) );
+	SetStatus( EReleasing );
+
+	// disconnect from the comms server
+#ifndef LIGHT_MODE
+	iCommServer.Close();
+#else // ifndef LIGHT_MODE
+	if( NULL != iCommServer )
+		{
+		CloseSerialServer( iCommServer );
+		iCommServer =	NULL;
+
+		// Here is an appropriate spot for releasing the library we need for stat-light
+		serialDriverLib.Close();
+
+		}
+#endif // ifndef LIGHT_MODE
+
+	// update state and finish
+	SetStatus( EIdle );
+	return KSTErrSuccess;
+}
+
+/**************************************************************************************
+ *
+ * CStatApiSerial - MStatNetwork - Connect and Close
+ *
+ *************************************************************************************/
+static int atoi( const short *str )
+{
+	int ret = 0;
+	for( int i = 0; str[i] != NULL; i++ ) {
+		ret *= 10;
+		ret += str[i] - '0';
+	}
+	return ret;
+}
+
+void CStatApiSerial::ExtractOptions( TDesC *aRemoteHost, TDes& aPortNumber, TInt& aBaudCap, TBps& aBaudRate )
+{
+	TInt baud;
+	short *delim;
+
+	// get the character array for the remote host (note that this is in unicode)
+	short *opt = (short*)aRemoteHost->Ptr();
+
+	int loop = 0;
+	while(opt[loop] != OPT_DELIMITER)
+	{
+		aPortNumber.Append(opt[loop]);
+		loop++;
+	}
+	
+	
+	// now search for the next delimiter and NULL it
+	for( delim = &opt[loop+1]; (*delim != NULL) && (*delim != OPT_DELIMITER); delim++ )
+		;
+
+	// if this is a delim then NULL it
+	if( *delim == OPT_DELIMITER ) {
+		*delim = NULL;
+	}
+
+	// extract the baud -- and set the correct constants for the given baud
+	baud = atoi( &(opt[loop+1]) ); 
+	switch( baud ) {
+	case 115200:
+		aBaudRate = EBps115200;
+		aBaudCap = KCapsBps115200;
+		break;
+	case 38400:
+		aBaudRate = EBps38400;
+		aBaudCap = KCapsBps38400;
+		break;
+	case 19200:
+		aBaudRate = EBps19200;
+		aBaudCap = KCapsBps19200;
+		break;
+	case 9600:
+		aBaudRate = EBps9600;
+		aBaudCap = KCapsBps9600;
+		break;
+	default:
+		;
+		break;
+	}
+}
+
+TInt CStatApiSerial::ConnectL( TDesC *aRemoteHost )
+{
+	TBuf<100> portNumber;
+	TInt baudCap;
+	TBps baudRate;
+	
+#ifdef LIGHT_MODE
+	static const TInt	KMaxPortName =	8;
+	TBool	result =	EFalse;
+#endif // ifndef LIGHT_MODE
+
+	// verify state 
+	asserte( iSerialStatus == EInitialised );
+	SetStatus( EConnecting );
+
+	// I used to verify the address was valid here -- but this has now been moved
+	// to the UI. If it is nonsense then it will just throw an error so it's not
+	// dangerous. Error reporting is now good enough that I can remove this.
+	
+	// extract the options from the string
+	ExtractOptions( aRemoteHost, portNumber, baudCap, baudRate ); 
+
+	// construct the address -- aRemoteHost should provide the COM port number
+	
+	TBuf16<KMaxPortName + 4> portName;
+	
+	//TInt err = portName.Num( portNumber );
+	
+	TLex lNum = TLex(portNumber);
+	TInt lInt; 
+	
+	TInt err = lNum.Val(lInt);
+	
+	if(err == KErrNone)
+		{
+		
+		portName.Insert( 0, portNumber);		
+		portName.Insert( 0, _L("::") );
+
+		asserte( EInvalid != iSubType );
+		if( SubType() == ESerialCable )
+			{
+			portName.Insert( 0, _L("COMM") );
+			}
+		else if( SubType() == EInfraRed )
+			{
+			portName.Insert( 0, _L("IrCOMM") );
+			}
+		}
+	else
+		{
+		//the port already contains the Type	
+		portName.Insert( 0, portNumber);
+		
+		}
+		
+	
+	// open the serial port
+#ifndef LIGHT_MODE
+	
+	TInt r = iCommPort.Open( iCommServer, portName, ECommExclusive );
+	User::LeaveIfError( r );
+	
+#else // ifndef LIGHT_MODE
+	iCommPort =	OpenSerialPortL( iCommServer, portNumber[0]-'0' );
+	
+	if( NULL == iCommPort )
+		{
+		User::Leave( KErrCouldNotConnect );
+		}
+#endif // ifndef LIGHT_MODE
+
+#ifndef LIGHT_MODE
+	// save port settings for restoring later
+	iCommPort.Config( iOldPortSettings );
+	iCommOldSettingsValid = 1;
+
+	// check our configuration is supported
+	TCommCaps ourCapabilities;
+	iCommPort.Caps( ourCapabilities );
+	if (((ourCapabilities ().iRate & baudCap) == 0) ||
+		 ((ourCapabilities ().iDataBits & KCapsData8) == 0) ||
+		 ((ourCapabilities ().iStopBits & KCapsStop1) == 0) ||
+		 ((ourCapabilities ().iParity & KCapsParityNone) == 0)) 
+	{
+			User::Leave( KErrNotSupported );
+	}
+#endif // ifndef LIGHT_MODE
+
+	// set new port settings
+#ifndef LIGHT_MODE
+	iCommPort.Config( iPortSettings );
+#else
+	GetPortConfig (iCommPort, iPortSettings);
+#endif // ifndef LIGHT_MODE
+
+	iPortSettings().iRate = baudRate;
+	iPortSettings().iParity = EParityNone;
+	iPortSettings().iDataBits = EData8;
+	iPortSettings().iStopBits = EStop1;
+	iPortSettings().iFifo = EFifoEnable;
+//	iPortSettings().iHandshake = KConfigFreeRTS | KConfigFreeDTR;
+	iPortSettings().iHandshake = KConfigObeyCTS;
+	iPortSettings().iTerminatorCount = 0;
+
+	// cancel any pending reads / writes to be safe and set the config
+#ifndef LIGHT_MODE
+	iCommPort.Cancel();
+#else // ifndef LIGHT_MODE
+	ReadCancel( iCommPort );
+	WriteCancel( iCommPort );
+	
+#endif // ifndef LIGHT_MODE
+
+#ifndef LIGHT_MODE
+	r = iCommPort.SetConfig( iPortSettings );	
+#else // ifndef LIGHT_MODE
+	TInt r = SetConfig( iCommPort, iPortSettings );	
+#endif // ifndef LIGHT_MODE
+
+	if( r != KErrNone )
+		{
+		User::Leave(r);
+		}
+
+	// now turn on DTR and RTS, and set our buffer size
+//		commPort.SetSignals (KSignalDTR, 0);
+//		commPort.SetSignals (KSignalRTS, 0);
+
+	// set the receive buffer length then check it did it ok
+#ifndef LIGHT_MODE
+	iCommPort.SetReceiveBufferLength( 2*iMaxPacketSize );
+#else // ifndef LIGHT_MODE
+	result =	SetReceiveBufferLength( iCommPort, 2*iMaxPacketSize );
+	if( ! result ) {
+		User::Leave(KErrUnknown);
+	}
+#endif // ifndef LIGHT_MODE
+
+	// check buffer size (use a relative check rather than
+	// an absolute check - if we get a bigger buffer than
+	// we asked for then that is no problem)
+	TInt	size =	0;
+
+#ifndef LIGHT_MODE
+	size =	iCommPort.ReceiveBufferLength();
+#else // ifndef LIGHT_MODE
+	result =	ReceiveBufferLength( iCommPort, size );
+	if( ! result ) {
+		User::Leave(KErrUnknown);
+	}
+#endif // ifndef LIGHT_MODE
+
+	if( size < 2*iMaxPacketSize )
+	{
+		User::Leave( KErrTooBig );
+	}
+
+	// allocate enough memory to hold a data read
+	iRecvBuffer = HBufC8::New(iMaxPacketSize);
+	if( !iRecvBuffer ) {
+		User::Leave(KErrNoMemory);
+	}
+	iRecvBufferPtr = new TPtr8( iRecvBuffer->Des() );
+
+	// power up the serial port by doing a null read on the port
+	iRWStatus = EReadPending;
+#ifndef LIGHT_MODE
+	iCommPort.Read( iStatus, iDummyBuffer, 0);
+#else // ifndef LIGHT_MODE
+	Read( iCommPort, iStatus, KReadTimeout, iDummyBuffer, 0 );
+#endif // ifndef LIGHT_MODE
+	SetActive();
+
+	// return asynchronous 
+	return KSTErrAsynchronous;
+}
+
+TInt CStatApiSerial::Disconnect(void)
+{
+	// verify the status
+	asserte( (iSerialStatus == EConnected) || (iSerialStatus == EConnecting) );
+	SetStatus( EDisconnecting );
+
+	// clean up the port
+#ifndef LIGHT_MODE
+	TInt sessionHandle = iCommPort.SubSessionHandle();
+	if( sessionHandle )
+	{
+		iCommPort.Cancel();
+	}
+	if( iCommOldSettingsValid )
+		iCommPort.SetConfig( iOldPortSettings );
+	if( sessionHandle )
+	{
+		iCommPort.Close();
+	}
+	sessionHandle = iCommPort.SubSessionHandle();
+	asserte(0 == sessionHandle);
+	iCommOldSettingsValid = 0;
+#else // ifndef LIGHT_MODE
+	if( NULL != iCommPort )
+		{
+		CloseSerialPort( iCommPort );
+		iCommPort =	NULL;
+		}
+#endif // ifndef LIGHT_MODE
+
+	// release the data buffer
+	delete iRecvBufferPtr;
+	iRecvBufferPtr = NULL;
+	delete iRecvBuffer;
+	iRecvBuffer = NULL;
+
+	// done
+	SetStatus( EDisconnected );
+	
+	return KSTErrSuccess;
+}
+
+/**************************************************************************************
+ *
+ * CStatApiSerial - MStatNetwork - Receive and Send. The ID / Length / Data nonsense 
+ * is handled by the packetisation layer. All serial has to do here is send data -- 
+ * serial is also assuming that the upper layer will keep the data until the response
+ *
+ *************************************************************************************/
+TInt CStatApiSerial::RequestSend( TDesC8 *aData, const TUint aDataLength )
+{
+	// make sure we are in the appropriate state 
+	asserte( iSerialStatus == EConnected );
+	asserte( iRWStatus == ENoRW );
+	iRWStatus = EWritePending;
+
+	// do the send
+	asserte( !IsActive() );
+	asserte( (unsigned)aData->Length() == aDataLength );
+#ifndef LIGHT_MODE
+	iCommPort.Write( iStatus, KWriteTimeout, (*aData), aDataLength );
+#else // ifndef LIGHT_MODE
+	Write( iCommPort, iStatus, KWriteTimeout, (*aData), aDataLength );
+#endif // ifndef LIGHT_MODE
+	SetActive();
+	return KSTErrAsynchronous;
+}
+
+TInt CStatApiSerial::RequestReceive( TUint aByteCount )
+{
+	// make sure we are in the appropriate state
+	asserte( iSerialStatus == EConnected );
+	asserte( iRWStatus == ENoRW );
+	iRWStatus = EReadPending;
+
+	// allocate a buffer for the read
+	asserte( aByteCount <= static_cast<TUint>(iMaxPacketSize) );
+	asserte( !IsActive() );
+	iRecvLength = aByteCount;
+	iRecvBufferPtr->SetLength( 0 );
+#ifndef LIGHT_MODE
+	iCommPort.ReadCancel();
+	iCommPort.Read( iStatus, KReadTimeout, *iRecvBufferPtr, aByteCount );
+#else // ifndef LIGHT_MODE
+	ReadCancel( iCommPort );
+	Read( iCommPort, iStatus, KReadTimeout, *iRecvBufferPtr, aByteCount );
+#endif // ifndef LIGHT_MODE
+	SetActive();
+	return KSTErrAsynchronous;
+}
+
+TInt CStatApiSerial::GetPacketSize()
+{
+	// The packet size is configured when we initialise the port.
+	return iMaxPacketSize;
+}
+
+TText8 *CStatApiSerial::Error( void )
+{
+	return NULL;
+}
+
+/**************************************************************************************
+ *
+ * CStatApiSerial - Active Object
+ *
+ *************************************************************************************/
+void CStatApiSerial::RunL( void )
+{
+	// cancels don't require any handling
+	if( iStatus == KErrCancel )
+		return;
+
+	// if timed out then reissue the read
+	if( (iStatus == KErrTimedOut) && (iRWStatus == EReadPending) ) {
+		asserte( iSerialStatus == EConnected );
+		asserte( iRWStatus == EReadPending );
+		iRetries++;
+#ifndef LIGHT_MODE
+		iCommPort.Read( iStatus, KReadTimeout, *iRecvBufferPtr, iRecvLength );
+#else // ifndef LIGHT_MODE
+		Read( iCommPort, iStatus, KReadTimeout, *iRecvBufferPtr, iRecvLength );
+#endif // ifndef LIGHT_MODE
+		SetActive();
+		return;
+	}
+	iRetries = 0;
+
+	// throw an error
+	if( iStatus != KErrNone ) {
+		iRWStatus = ENoRW;
+		iTransport->HandleError( iStatus.Int(), NULL );
+	}
+
+	// if we are in connecting state and have just done the null read then
+	// we are done and have connected
+	if( (iSerialStatus == EConnecting) && (iRWStatus == EReadPending) ) {
+		iRWStatus = ENoRW;
+		SetStatus( EConnected );
+		iTransport->HandleConnect( KErrNone );
+		return;
+	}
+
+
+	// if we are writing then notify of the write
+	if( iRWStatus == EWritePending ) {
+		iRWStatus = ENoRW;
+		iTransport->HandleSend( KErrNone );
+		return;
+	}
+
+	// if we are reading then notify of the read
+	if( iRWStatus == EReadPending ) {
+		TInt length = iRecvLength;
+		iRWStatus = ENoRW;
+		iRecvLength = 0;
+		iTransport->HandleReceive( KErrNone, iRecvBufferPtr, length );
+		return;
+	}
+}
+
+void CStatApiSerial::DoCancel( void )
+{
+	if( (iSerialStatus == EConnected) || (iSerialStatus == EConnecting) )
+		{
+#ifndef LIGHT_MODE
+		iCommPort.Cancel();
+#else // ifndef LIGHT_MODE
+		ReadCancel( iCommPort );
+		WriteCancel( iCommPort );
+#endif // ifndef LIGHT_MODE
+		}
+}
+
+/**************************************************************************************
+ *
+ * CStatApiSerial - Private Functions
+ *
+ *************************************************************************************/
+void CStatApiSerial::SetStatus( TCommStatus aNewStatus )
+{
+	iSerialStatus = aNewStatus;
+}
+
+/**************************************************************************************
+ *
+ * CStatApiSerial - DetermineSubTypeL
+ *
+ *************************************************************************************/
+void CStatApiSerial::DetermineSubTypeL()
+{
+	
+	
+	const TPtrC subTypes[ENumberOfSubTypes] = { 
+				_L(""),			// Invalid
+				_L("ECUART"), 	// Serial cable
+				_L("IrCOMM")	// Infra-red
+				};
+
+	const TInt packetSize[ENumberOfSubTypes] = { 
+				0,
+				KMaxPacketSize,
+				KMaxPacketSize
+				};
+
+	TInt count;
+	for( count = 0; ( EInvalid == iSubType ) && ( count < ENumberOfSubTypes ); count++ )
+	{
+		if( 0 == ( iModule.Compare( subTypes[count] ) ) )
+		{
+			iSubType = static_cast<TSerialSubtype>(count);
+			iMaxPacketSize = packetSize[count];
+		}
+	}
+
+	if( EInvalid == iSubType )
+	{
+		User::Leave( KErrNotSupported );
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/src/stat_tcpip.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,370 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+/********************************************************************************
+ *
+ * System Includes
+ *
+ *******************************************************************************/
+#include <es_sock.h>
+#include <in_sock.h>
+
+/********************************************************************************
+ *
+ * Local Includes
+ *
+ *******************************************************************************/
+#include "assert.h"
+#include "ntoh.h"
+#include "stat_tcpip.h"
+#include "../../../../common/inc/serialpacketsize.h"
+
+/********************************************************************************
+ *
+ * Macro functions
+ *
+ ********************************************************************************/
+
+/********************************************************************************
+ *
+ * CStatTransportTCPIP -- Constructor
+ *
+ *******************************************************************************/
+CStatTransportTCPIP *CStatTransportTCPIP::NewL( void )
+{
+	CStatTransportTCPIP *self = new (ELeave) CStatTransportTCPIP();
+    CleanupStack::PushL(self);
+	self->ConstructL( );
+	CleanupStack::Pop();
+    return self;
+}
+
+CStatTransportTCPIP::CStatTransportTCPIP() : CActive(EPriorityStandard)
+{
+}
+
+void CStatTransportTCPIP::ConstructL( void )
+{
+	// add this to active scheduler
+	CActiveScheduler::Add(this); 
+
+	// initialise all params	
+
+	iBufferPtr = NULL;
+	iTransport = NULL;
+	iTransportStatus = EIdle;
+	iRWStatus = ENoRW;
+
+	iMaxPacketSize = KMaxTCPIPPacketSize;
+	
+	iBuffer = HBufC8::New( iMaxPacketSize );
+	
+}
+
+CStatTransportTCPIP::~CStatTransportTCPIP()
+{
+	// this will call cancel and remove the active object -- this will call cancel
+	Deque(); 
+
+	// cleanup the sockets
+	switch( iTransportStatus ) {
+
+	case EIdle:
+	case EInitialised:
+	case EDisconnected:
+	case EError:
+		break;
+
+	case EConnected:
+		iDataSocket.Shutdown( RSocket::EImmediate, iStatus );
+		/* fall through */
+
+	case EConnecting:
+		iDataSocket.Close();
+		iListenSocket.Shutdown( RSocket::EImmediate, iStatus );
+		iListenSocket.Close();
+		iSocketServ.Close();
+		break;
+
+	case EDisconnectingData:
+	case EDisconnectingListen:
+		;
+		break;
+	}
+
+	if( iBuffer )
+		{
+			delete iBuffer;
+			iBuffer = NULL;
+		}
+
+	if( iBufferPtr )
+		{
+			delete iBufferPtr;
+			iBufferPtr = NULL;
+		}
+}
+
+/********************************************************************************
+ *
+ * CStatTransportTCPIP -- MStatApiTransport
+ *
+ *******************************************************************************/
+TInt CStatTransportTCPIP::InitialiseL( MNotifyStatTransport *aTransport )
+{
+	// save the transport interface
+	iTransport = aTransport;
+
+	// everything here is done in connect
+	iTransportStatus = EInitialised;
+	return KSTErrSuccess;
+}
+
+TInt CStatTransportTCPIP::Release( void )
+{
+	// release has nothing to do
+	asserte( (iTransportStatus == EDisconnected) || (iTransportStatus == EInitialised) );
+	iTransportStatus = EIdle;
+	return KSTErrSuccess;
+}
+
+TInt CStatTransportTCPIP::ConnectL( TDesC* /*aRemoteHost*/ )
+{
+	// make sure we are in the correct state
+	asserte( iTransportStatus == EInitialised );
+
+	// connect to the socket server, create a socket, bind, listen, accept
+	User::LeaveIfError( iSocketServ.Connect() );
+	User::LeaveIfError( iListenSocket.Open(iSocketServ, KAfInet, KSockStream, KProtocolInetTcp) );
+	User::LeaveIfError( iListenSocket.SetLocalPort( KLittleStatPort) );
+	User::LeaveIfError( iListenSocket.Listen(KLittleStatListenQueue) );
+
+	// create a blank socket which is used as the data socket
+	User::LeaveIfError( iDataSocket.Open(iSocketServ) );
+
+	// everything should now be set up, we just wait for a stat connection
+	asserte( !IsActive() );
+	iListenSocket.Accept( iDataSocket, iStatus );
+	SetActive();
+	iTransportStatus = EConnecting;
+
+	// tell the client to wait for an asynchronous response
+	return KSTErrAsynchronous;
+}
+
+TInt CStatTransportTCPIP::Disconnect( void )
+{
+	// must be connected 
+	asserte( (iTransportStatus == EInitialised) || 
+			(iTransportStatus == EConnected)   || 
+			(iTransportStatus == EConnecting)  ||
+			(iTransportStatus == EDisconnectingData) ||
+			(iTransportStatus == EDisconnectingListen) );
+
+	// cancel any pending ops 
+	Cancel();
+
+	// clean up the sockets depending on the state
+	switch( iTransportStatus ) {
+
+	case EConnected:
+		iDataSocket.Shutdown( RSocket::ENormal, iStatus );
+		SetActive();
+		iTransportStatus = EDisconnectingData;
+		return KSTErrAsynchronous;
+
+	case EConnecting:
+	case EDisconnectingData:
+		iDataSocket.Close();
+		iListenSocket.Shutdown( RSocket::ENormal, iStatus );
+		SetActive();
+		iTransportStatus = EDisconnectingListen;
+		return KSTErrAsynchronous;
+
+	case EInitialised:
+	case EDisconnectingListen:
+		// initialised may mean that ConnectL threw an error -- so close the resources
+		iDataSocket.Close();
+		iListenSocket.Close();
+		iSocketServ.Close();
+		return KSTErrSuccess;
+
+	default:
+		;
+	}
+	return KSTErrSuccess;
+}
+
+TInt CStatTransportTCPIP::RequestSend( TDesC8 *aData, const TUint /*aDataLength*/ )
+{
+
+	// make sure the state is correct
+	asserte( iTransportStatus == EConnected );
+	asserte( iRWStatus == ENoRW );
+	iRWStatus = EWritePending;
+	
+	iDataSocket.Write( *aData, iStatus );
+	SetActive();
+	
+	// tell the caller to wait for an asynchronous response
+	return KSTErrAsynchronous;
+
+
+}
+
+TInt CStatTransportTCPIP::RequestReceive( TUint aByteCount )
+{
+
+	// ensure that there are no reads in progress
+	asserte( iTransportStatus == EConnected );
+	asserte( !IsActive() );
+	asserte( iRWStatus == ENoRW );
+	iRWStatus = EReadPending;
+
+	asserte( aByteCount <= static_cast<TUint>(iMaxPacketSize) );
+	asserte( !IsActive() );
+	
+	if(!iBufferPtr)
+		{
+		iBufferPtr = new TPtr8(const_cast<unsigned char*>(iBuffer->Ptr( )),aByteCount);	
+		}
+	else
+		if(iBufferPtr->MaxLength()!=aByteCount)
+			{
+			delete iBufferPtr;
+			iBufferPtr = new TPtr8(const_cast<unsigned char*>(iBuffer->Ptr( )),aByteCount);
+			}
+	
+	iDataSocket.Read( *iBufferPtr, iStatus );
+	SetActive();
+
+	// return to the caller
+	return KSTErrAsynchronous;
+	
+}
+
+TText8 *CStatTransportTCPIP::Error( void )
+{
+	return NULL;
+}
+
+TInt CStatTransportTCPIP::GetPacketSize()
+{
+	// The packet size is configured when we initialise the port.
+	return iMaxPacketSize;
+}
+
+/********************************************************************************
+ *
+ * CStatTransportTCPIP -- Active Object
+ *
+ *******************************************************************************/
+void CStatTransportTCPIP::RunL( void )
+{
+	// if there was an error during connectiong then tell the engine this
+	if( (iTransportStatus == EConnecting) && (iStatus != KErrNone) ) {
+		iTransport->HandleError( KSTErrConnectFailure, (void*)iStatus.Int() );
+		return;
+	}
+
+	//reconnect without restarting STAT
+	if(iStatus != KErrNone)
+		{
+		//if no error due to end of socket connection
+		if(iStatus != KErrDisconnected && iStatus != KErrEof)
+			{
+			_LIT(KFormat,"Error during TCPIP: %d\n");
+			TBuf<50> lBuf;
+			lBuf.Format(KFormat,iStatus.Int());
+			iTransport->HandleInfo(&lBuf);	
+			}
+		
+		// close and reopen the socket
+		iDataSocket.Close();  
+		User::LeaveIfError(iDataSocket.Open(iSocketServ));
+
+		// wait for a new connection
+		iTransportStatus = EConnecting;
+		iRWStatus = ENoRW;
+		iListenSocket.Accept( iDataSocket, iStatus );
+		SetActive();
+		return;
+		}
+
+	// handle connection response 
+	if( iTransportStatus == EConnecting ) {
+		asserte( iStatus == KErrNone );
+		iTransportStatus = EConnected;
+		iTransport->HandleConnect( KErrNone );
+		return;
+	}
+
+	// handle shutdown data socket
+	if( iTransportStatus == EDisconnectingData ) {
+		iDataSocket.Close();
+		iListenSocket.Shutdown( RSocket::ENormal, iStatus );
+		SetActive();
+		iTransportStatus = EDisconnectingListen;
+		return;
+	}
+
+	// handle shutdown listen
+	if( iTransportStatus == EDisconnectingListen ) {
+		iListenSocket.Close();
+		iTransportStatus = EDisconnected;
+		iSocketServ.Close();
+		iTransport->HandleDisconnect( KErrNone );
+		return;
+	}
+
+	// if we are writing then notify of the write
+	if( iRWStatus == EWritePending ) {
+		iRWStatus = ENoRW;
+		iTransport->HandleSend( KErrNone );
+		return;
+	}
+
+	// if we are reading then notify of the read
+	if( iRWStatus == EReadPending ) {
+		iRWStatus = ENoRW;
+		iTransport->HandleReceive( KErrNone, iBufferPtr, iBufferPtr->Length( ) );
+		return;
+	}
+}
+
+void CStatTransportTCPIP::DoCancel( void )
+{
+	if( iTransportStatus == EConnecting )
+		{
+		iListenSocket.CancelAccept();
+		}
+
+	if( iRWStatus == EReadPending )
+		{
+		iDataSocket.CancelRead();
+		}
+
+	if( iRWStatus == EWritePending )
+		{
+		iDataSocket.CancelWrite();
+		}
+
+	iRWStatus = ENoRW;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/src/stat_usb.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,428 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+ /**************************************************************************************
+ *
+ * USB Packetisation transport for STAT -- for packet based network layers
+ *
+ *************************************************************************************/
+
+/**************************************************************************************
+ *
+ * Local Includes
+ *
+ *************************************************************************************/
+#include "assert.h"
+#include "stat_usb.h"
+
+/**************************************************************************************
+ *
+ * Definitions
+ *
+ *************************************************************************************/
+
+#define KReEnumerationDelay		500000 //0.5 seconds
+
+/********************************************************************************
+ *
+ * Macro functions
+ *
+ ********************************************************************************/
+  
+ _LIT(KLddName, "eusbc");
+ 
+/**************************************************************************************
+ *
+ * CStatApiUsb - Construction
+ *
+ *************************************************************************************/
+CStatApiUsb* CStatApiUsb::NewL()
+{
+    CStatApiUsb *self = new (ELeave) CStatApiUsb();
+    CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop();
+    return self;
+}
+
+CStatApiUsb::CStatApiUsb() : CActive(EPriorityStandard)
+{
+}
+
+CStatApiUsb::~CStatApiUsb()
+{
+	
+	// clean up params
+	if( iBuffer != NULL )
+		delete iBuffer;
+}
+
+void CStatApiUsb::ConstructL( void )
+{
+	
+	iTimer.CreateLocal();
+	
+	// add to active scheduler
+	CActiveScheduler::Add(this);
+		
+	// set parameters
+	iBuffer = NULL;
+	iLength = 0;
+	iRWStatus = ENoRW;
+	iUsbStatus = EIdle;
+	iTransport = NULL;
+	
+	iConnectingState = EEnum;
+	
+	iMaxPacketSize = KMaxUSBPacketSize;
+	
+	iBuffer = HBufC8::New(iMaxPacketSize);
+	
+	if( !iBuffer ) {
+		User::Leave(KErrNoMemory);
+	}
+	
+}
+
+/**************************************************************************************
+ *
+ * CStatApiUsb - MStatNetwork - Initialise and Release
+ *
+ *************************************************************************************/
+TInt CStatApiUsb::InitialiseL( MNotifyStatTransport *aTransport )
+{
+
+	TInt r = KErrNone;
+
+	// save the transport interface
+	iTransport = aTransport;
+
+	// set the state
+	SetStatus( EInitialising );
+
+	r = User::LoadLogicalDevice(KLddName);
+
+	if( (r != KErrNone) && (r != KErrAlreadyExists) ) {
+		User::Leave( r );
+	}
+	
+	if(r == KErrAlreadyExists)
+		r = KErrNone;
+	
+	SetStatus( EInitialised );
+		
+	return (r);
+}
+
+
+
+
+TInt CStatApiUsb::Release(void)
+{
+
+	// remove from active scheduler
+	Deque();
+	
+	// close timer
+	iTimer.Close();
+	
+	//close port
+	iPort.Close();	
+	
+	// update state and finish
+	SetStatus( EIdle );
+	
+	return KSTErrSuccess;
+}
+
+
+
+TInt CStatApiUsb::ConnectL(TDesC */*aRemoteHost*/)
+{
+	
+	SetStatus( EConnecting );
+
+	User::LeaveIfError( iPort.Open(0) );
+	
+	// Set the active interface
+
+	TUsbDeviceCaps d_caps;
+	User::LeaveIfError( iPort.DeviceCaps(d_caps) );
+	
+	TInt n = d_caps().iTotalEndpoints;
+	
+	TUsbcEndpointData data[KUsbcMaxEndpoints];
+	TPtr8 dataptr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data));
+	
+	User::LeaveIfError( iPort.EndpointCaps(dataptr) );
+
+	TUsbcInterfaceInfoBuf ifc;
+	TInt ep_found = 0;
+	TBool foundBulkIN = EFalse;
+	TBool foundBulkOUT = EFalse;
+
+	for (TInt i = 0; i < n; i++)
+		{
+		const TUsbcEndpointCaps* caps = &data[i].iCaps;
+		const TInt mps = caps->MaxPacketSize();
+		if (!foundBulkIN &&
+			(caps->iTypesAndDir & (KUsbEpTypeBulk | KUsbEpDirIn)) == (KUsbEpTypeBulk | KUsbEpDirIn))
+			{
+			// EEndpoint1 is going to be our TX (IN, write) endpoint
+			ifc().iEndpointData[0].iType = KUsbEpTypeBulk;
+			ifc().iEndpointData[0].iDir	 = KUsbEpDirIn;
+			ifc().iEndpointData[0].iSize =  mps;
+			
+			foundBulkIN = ETrue;
+			if (++ep_found == 2)
+				break;
+			continue;
+			}
+		if (!foundBulkOUT &&
+			(caps->iTypesAndDir & (KUsbEpTypeBulk | KUsbEpDirOut)) == (KUsbEpTypeBulk | KUsbEpDirOut))
+			{
+			// EEndpoint2 is going to be our RX (OUT, read) endpoint
+			ifc().iEndpointData[1].iType = KUsbEpTypeBulk;
+			ifc().iEndpointData[1].iDir	 = KUsbEpDirOut;
+			ifc().iEndpointData[1].iSize = mps;
+			
+			foundBulkOUT = ETrue;
+			if (++ep_found == 2)
+				break;
+			continue;
+			}
+		}
+	
+	//check enough IO endpoints	
+	asserte( ep_found == 2 );
+			
+	_LIT16(ifcname, "STAT USB Test Interface");
+	HBufC16* string = ifcname().AllocL();
+    CleanupStack::PushL(string);
+
+	ifc().iString = string;
+	ifc().iTotalEndpointsUsed = 2;
+	ifc().iClass.iClassNum	  = 0xff;
+	ifc().iClass.iSubClassNum = 0xff;
+	ifc().iClass.iProtocolNum = 0xff;
+
+	User::LeaveIfError( iPort.SetInterface(0, ifc, EUsbcBandwidthINMaximum | EUsbcBandwidthOUTMaximum) );
+
+    CleanupStack::PopAndDestroy();
+
+	//force a call to RunL
+	SetActive();
+	TRequestStatus* status=&iStatus;
+	User::RequestComplete(status,KErrNone);
+	
+	return KSTErrAsynchronous;
+
+}
+
+
+TInt CStatApiUsb::Disconnect(void)
+{
+	return KSTErrSuccess;
+}
+
+/**************************************************************************************
+ *
+ * CStatApiUsb - MStatNetwork - Receive and Send. The ID / Length / Data nonsense 
+ * is handled by the packetisation layer. All Usb has to do here is send data -- 
+ * Usb is also assuming that the upper layer will keep the data until the response
+ *
+ *************************************************************************************/
+TInt CStatApiUsb::RequestSend( TDesC8 *aData, const TUint aDataLength )
+{
+	// make sure we are in the appropriate state 
+	asserte( iUsbStatus == EConnected );
+	asserte( iRWStatus == ENoRW );
+	iRWStatus = EWritePending;
+
+	// do the send
+	asserte( !IsActive() );
+	asserte( (unsigned)aData->Length() == aDataLength );
+	
+	iPort.Write(iStatus, EEndpoint1, *aData, aDataLength);
+	SetActive();
+	
+	return KSTErrAsynchronous;
+}
+
+TInt CStatApiUsb::RequestReceive( TUint aByteCount )
+{
+	
+	// make sure we are in the appropriate state
+	asserte( iUsbStatus == EConnected );
+	asserte( iRWStatus == ENoRW );
+	asserte( !IsActive() );
+	iRWStatus = EReadPending;
+
+	// allocate a buffer for the read
+	asserte( aByteCount <= static_cast<TUint>(iMaxPacketSize) );
+	iLength = aByteCount;
+	
+	TPtr8 lPtr = iBuffer->Des();
+	
+	iPort.Read(iStatus, EEndpoint2 , lPtr , aByteCount );	
+	SetActive();	
+
+	return KSTErrAsynchronous;
+}
+
+TInt CStatApiUsb::GetPacketSize()
+{
+	// The packet size is configured when we initialise the port.
+	return iMaxPacketSize;
+}
+
+TText8 *CStatApiUsb::Error( void )
+{
+	return NULL;
+}
+
+/**************************************************************************************
+ *
+ * CStatApiUsb - Active Object
+ *
+ *************************************************************************************/
+
+ void CStatApiUsb::RunL( void )
+{
+	asserte( !IsActive() );
+			
+	if( iStatus == KErrCancel )
+		return;
+	
+	switch( iStatus.Int() )
+	{
+		
+		case KErrCancel:
+		return;
+		
+		case KErrNone:
+		break;
+		
+		// the USB device has been released, move to the EConnecting state
+		
+		// USB error
+		 case KErrUsbInterfaceNotReady:
+ 		// port is released by the PC
+ 		 case KErrUsbDeviceNotConfigured:
+		 iRWStatus = ENoRW;
+		 SetStatus(EConnecting);
+		 break;
+		
+		// in other cases, we have an error to report to the upper layers
+		default: 
+		iRWStatus = ENoRW;
+		iTransport->HandleError( iStatus.Int(), NULL );
+	}
+	
+	
+	// Status change
+	if(iUsbStatus == EConnecting)
+		{
+		
+		iRWStatus = ENoRW;
+				
+ 		switch(iConnectingState)
+	 		{
+		 	//ReEnumerate
+		 	case EEnum:
+			 	iPort.ReEnumerate(iStatus);
+				SetActive();
+			 	iConnectingState = EWait;
+			 	break;
+		 	
+		 	//Wait enough to complete the reenumeration
+		 	case EWait:
+		 	 	iTimer.After(iStatus,KReEnumerationDelay);
+			 	SetActive();
+			 	iConnectingState = EConnect;
+				break;
+		 	
+		 	case EConnect:
+		 		iConnectingState = EEnum;
+		 		
+		 		//Set DMA
+			 	iPort.AllocateEndpointResource(EEndpoint1, EUsbcEndpointResourceDMA);
+				iPort.AllocateEndpointResource(EEndpoint2, EUsbcEndpointResourceDMA);
+			 	iPort.QueryEndpointResourceUse(EEndpoint1, EUsbcEndpointResourceDMA);
+			 	iPort.QueryEndpointResourceUse(EEndpoint2, EUsbcEndpointResourceDMA);
+			
+				//Set double buffering
+				iPort.AllocateEndpointResource(EEndpoint1, EUsbcEndpointResourceDoubleBuffering);
+			 	iPort.AllocateEndpointResource(EEndpoint2, EUsbcEndpointResourceDoubleBuffering);
+				iPort.QueryEndpointResourceUse(EEndpoint1, EUsbcEndpointResourceDoubleBuffering);
+				iPort.QueryEndpointResourceUse(EEndpoint2, EUsbcEndpointResourceDoubleBuffering);
+		 		
+				//change status to connected	 		
+			 	SetStatus( EConnected );
+				iTransport->HandleConnect( KErrNone );
+			 	break;
+		 	}
+ 		
+		return;
+		}
+	
+		
+	// if we are writing then notify of the write
+	if( iRWStatus == EWritePending ) 
+		{
+		iRWStatus = ENoRW;
+		iTransport->HandleSend( KErrNone );
+		return;
+		}
+
+	// if we are reading then notify of the read
+	if( iRWStatus == EReadPending )
+		{
+		TInt length = iLength;
+		iRWStatus = ENoRW;
+		iLength = 0;
+		
+		TPtr8 lPtr = iBuffer->Des();
+		
+		iTransport->HandleReceive( KErrNone, &lPtr, length );
+		return;
+		}
+	
+}
+
+void CStatApiUsb::DoCancel( void )
+{
+	
+	iPort.ReEnumerateCancel();
+	iPort.ReadCancel(EEndpoint2);
+	iPort.WriteCancel(EEndpoint1);
+	
+}
+
+/**************************************************************************************
+ *
+ * CStatApiUsb - Private Functions
+ *
+ *************************************************************************************/
+void CStatApiUsb::SetStatus( TCommStatus aNewStatus )
+{
+	iUsbStatus = aNewStatus;
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/src/stat_window.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,1660 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+ /*************************************************************************
+ *
+ * Switches
+ *
+ ************************************************************************/
+//#define ENABLE_INFO
+
+ /*************************************************************************
+ *
+ * System Includes
+ *
+ ************************************************************************/
+#include <eikcmbut.h>
+#include <bautils.h>
+#include <iniparser.h>
+#include <s32file.h>
+
+/*************************************************************************
+ *
+ * Local Includes
+ *
+ ************************************************************************/
+
+#include "stat_window.h"
+#include "assert.h"
+#include "filedump.h"
+#include "stat.h"
+
+/*************************************************************************
+ *
+ * Local Includes
+ *
+ ************************************************************************/
+
+/*************************************************************************
+ *
+ * Definitions - COMMON
+ *
+ ************************************************************************/
+
+// Control sections
+#define KControlPanel			100
+#define KVersionPanel			101
+#define KConnectPanel			102
+
+// Position Constants
+#define KButtonBorderOffset		4
+#define KConnectLabelWidth		100
+
+// Background Colours
+#define KBackgroundColour		KMistyGray
+#define KButtonColour			KLightGray
+#define KLightGray				TRgb(0xC0C0C0)
+#define KMistyGray				TRgb(0xFFC0C0)
+
+// Addresses Contants
+#define KDefaultAddressSerial		0
+#define KDefaultAddressInfraRed		0
+#define KSerialPortCount			6
+#define KInfraRedPortCount			4
+
+// Maximum address field length
+#define KAddressTextLimit 16
+#define MAXMESSAGESIZE 128
+
+// Hardcoded comms parameters
+//#define KSerialBaudRate			_L("38400")
+//#define KIRBaudRate				_L("38400")
+#define KSerialBaudRate			_L("115200")
+#define KIRBaudRate				_L("115200")
+
+//version info
+#define KVersionNotKnown		_L("Version not known.")
+#define KBuildInfoFilePath		_L("Z:\\system\\data\\BuildInfo.txt")
+#define KBuildNumberFlag		_L8("ManufacturerSoftwareBuild")
+const TInt KOffsetToBuildNumber = 27; // Length of ManufacturerSoftwareBuild + 2 spaces 
+
+// Stored comms data
+// This is a hard coded choice of drive depending uopn the
+// target platform.  See CStatApiCommandDecoder::ScreenCapture
+// for code whch determines if a drive is available.
+#if defined __WINSCW__
+	_LIT( KIniFile, "C:\\statui.ini" );
+#else // defined __WINSCW__
+	_LIT( KIniFile, "D:\\statui.ini" );
+#endif // defined __WINSCW__
+
+// Coms fields in ini file
+_LIT( KIniFormat, "%S= %d\r\n" );
+_LIT( KIniConnectType, "ConnectType" );
+_LIT( KIniAddress, "Address" );
+_LIT( KIniRunning, "Running" );
+_LIT( KIniConnectAutomatically, "ConnectAutomatically" );
+
+LOCAL_D MNotifyLogMessage *iMsg = NULL;
+LOCAL_D	RFs iFsSession;
+
+#define UndefinedData				(-1)
+#define DefaultConnect				ESerial
+#define DefaultAddress				1
+#define DefaultRunning				0
+#define DefaultConnectAutomatically	1
+
+/*************************************************************************
+ *
+ * Definitions - SERIES 60
+ *
+ ************************************************************************/
+#ifdef SYMBIAN_DIST_SERIES60
+
+#define KButtonHeight				18
+#define KButtonWidth				82
+#define KStatusLabelWidth			(KButtonBorderOffset)
+
+#define KConnectPanelTop			(3*KButtonBorderOffset + 2*KButtonHeight)
+#define KEditControlFudgeTop		1
+#define KConnectPanelFudge			6
+
+#define KEditControlFlags			(CEikEdwin::ELineCursor | CEikEdwin::EAvkonEditor | CEikEdwin::EAvkonDisableCursor)
+
+#define KConnectingStatusStr		_L("STAT is connecting.")
+#define KWaitingForDataStatusStr	_L("STAT is waiting for data.")
+
+#define KButtonsVisible				EFalse
+#endif
+
+/*************************************************************************
+ *
+ * Definitions - TECHVIEW
+ *
+ ************************************************************************/
+#ifdef SYMBIAN_DIST_TECHVIEW
+
+#define KButtonHeight				24
+#define KButtonWidth				82
+#define KStatusLabelWidth			(2*KButtonBorderOffset + KButtonWidth)
+
+#define KConnectPanelTop			(4*KButtonBorderOffset + 3*KButtonHeight)
+#define KEditControlFudgeTop		0
+#define KConnectPanelFudge			0
+
+#define KEditControlFlags			(CEikEdwin::ELineCursor)
+
+#define KConnectingStatusStr		_L("STAT is waiting for a connection.")
+#define KWaitingForDataStatusStr	_L("STAT is waiting to receive data.")
+
+#define KButtonsVisible				ETrue
+#endif
+
+/*************************************************************************
+ *
+ * Definitions - UIQ
+ *
+ ************************************************************************/
+#ifdef SYMBIAN_DIST_UIQ
+
+#define KButtonHeight				20
+#define KButtonWidth				60
+
+#define KStatusLabelWidth			(2*KButtonBorderOffset + KButtonWidth)
+
+#define KConnectPanelTop			(4*KButtonBorderOffset + 3*KButtonHeight)
+#define KEditControlFudgeTop		0
+#define KConnectPanelFudge			0
+
+#define KEditControlFlags			(CEikEdwin::ELineCursor)
+
+#define KConnectingStatusStr		_L("STAT is waiting for a connection.")
+#define KWaitingForDataStatusStr	_L("STAT is waiting to receive data.")
+
+#define KButtonsVisible				ETrue
+#endif
+
+/*************************************************************************
+ *
+ * CStatWindow - Construction
+ *
+ ************************************************************************/
+CStatWindow *CStatWindow::NewL( const TRect& rect, MStatController *aStatController )
+{
+	CStatWindow* self = new(ELeave) CStatWindow();
+	CleanupStack::PushL( self );
+	self->ConstructL( rect, aStatController );
+	CleanupStack::Pop();
+	return self;
+}
+
+CStatWindow::CStatWindow()
+{
+	iStatusLabel = NULL;
+	iErrorLabel = NULL;
+	iVersionLabel = NULL;
+	iTransportLabel = NULL;
+	iAddressLabel = NULL;
+	iTransportEdit = NULL;
+	iAddressEdit = NULL;
+	iActionButton = NULL;
+	iExitButton = NULL;
+	iInfoLabel = NULL;
+	iLogButton = NULL;
+	iClearLabelsOnly = 0;
+	bIsForeground = EFalse;
+	iIniData = NULL;
+	iAOConnection = NULL;
+}
+
+CStatWindow::~CStatWindow()
+{
+	delete iIniData;
+	delete iStatusLabel;
+	delete iErrorLabel;
+	delete iVersionLabel;
+	delete iTransportLabel;
+	delete iAddressLabel;
+	delete iTransportEdit;
+	delete iAddressEdit;
+	delete iActionButton;
+	delete iExitButton;
+	delete iInfoLabel;
+	delete iLogButton;
+
+	if( iMsg->IsInitialised() )
+		{
+		iMsg->CloseFile();
+		}
+
+	iFsSession.Close();
+
+	delete iMsg;
+	iMsg =	NULL;
+
+	asserte(NULL==iAOConnection);
+}
+
+void CStatWindow::ConstructL( const TRect& rect, MStatController *aStatController )
+{
+	TBuf<16> choiceItem;
+
+	User::LeaveIfError( iFsSession.Connect() );
+	iMsg = new FileDump();
+	
+	
+	RFs fileServer;
+	TVersionName version(fileServer.Version().Name());
+	
+	TBuf<KMaxFileName> statLogFile;
+	
+	TDriveNumber defaultSysDrive(EDriveC);
+	RLibrary pluginLibrary;
+	TInt pluginErr = pluginLibrary.Load(KFileSrvDll);
+	
+	if (pluginErr == KErrNone)
+		{
+		typedef TDriveNumber(*fun1)();
+		fun1 sysdrive;
+	
+	#ifdef __EABI__
+		sysdrive = (fun1)pluginLibrary.Lookup(336);
+	#else
+		sysdrive = (fun1)pluginLibrary.Lookup(304);
+	#endif
+		
+		if(sysdrive!=NULL)
+			{
+			defaultSysDrive = sysdrive();
+			}
+		}
+	pluginLibrary.Close();
+	
+	statLogFile.Append(TDriveUnit(defaultSysDrive).Name());
+	statLogFile.Append(KFileSeparator);
+	statLogFile.Append(KStatLogFile);
+	
+	iMsg->Init( iFsSession, statLogFile, NULL );
+
+	// Store the pointer to the STAT controller
+	iStatController = aStatController;
+
+	// create a window and set the size to the full screen
+	CreateWindowL();
+	SetRect(rect);
+
+	// create all sub components -- note that I should push stuff onto the cleanup stack
+	iStatusLabel = new(ELeave) CEikLabel();
+	iStatusLabel->SetContainerWindowL(*this);
+	iStatusLabel->SetRect( GetControlPosition(KStatusLabel) );
+	iStatusLabel->SetAlignment( EHLeftVCenter );
+	iStatusLabel->SetFont( iEikonEnv->AnnotationFont() );
+	iStatusLabel->SetBufferReserveLengthL( 200 );
+	iStatusLabel->SetTextL( _L("STAT is not running") );
+	iStatusLabel->ActivateL( );
+
+	iErrorLabel = new(ELeave) CEikLabel();
+	iErrorLabel->SetContainerWindowL(*this);
+	iErrorLabel->SetRect( GetControlPosition(KErrorLabel) );
+	iErrorLabel->SetAlignment( EHLeftVCenter );
+	iErrorLabel->SetFont( iEikonEnv->AnnotationFont() );
+	iErrorLabel->SetBufferReserveLengthL( 200 );
+	iErrorLabel->SetTextL( _L("No errors") );
+	iErrorLabel->ActivateL( );
+
+	// The info-label is only for debugging. It prints strings sent up to the
+	// UI from the transport and engine. It's too much code to take the control 
+	// out completely so I'm just disabling it (making it invisible).
+	iInfoLabel = new(ELeave) CEikLabel();
+	iInfoLabel->SetContainerWindowL(*this);
+	iInfoLabel->SetRect( GetControlPosition(KInfoLabel) );
+	iInfoLabel->SetAlignment( EHLeftVCenter );
+	iInfoLabel->SetFont( iEikonEnv->AnnotationFont() );
+	iInfoLabel->SetBufferReserveLengthL( 200 );
+	iInfoLabel->SetTextL( _L("") );
+	iInfoLabel->ActivateL( );
+	// iInfoLabel->MakeVisible( EFalse );
+	iInfoLabel->MakeVisible( ETrue );
+
+	iActionButton = new(ELeave) CEikCommandButton();
+	iActionButton->SetContainerWindowL(*this);
+	iActionButton->SetDisplayContent( CEikCommandButton::ETextOnly );
+	iActionButton->SetTextL( _L("Start") );
+	iActionButton->SetRect( GetControlPosition(KActionButton) );
+	iActionButton->SetObserver( this );
+	iActionButton->SetButtonLayout( (CEikCommandButton::TLayout)CEikCommandButton::EDenseFont );
+	iActionButton->MakeVisible( KButtonsVisible );
+	iActionButton->OverrideColorL( EColorButtonFaceClear, KButtonColour );
+	iActionButton->OverrideColorL( EColorButtonFaceSet, KButtonColour );
+	iActionButton->OverrideColorL( EColorButtonFaceSetPressed, KButtonColour );
+	iActionButton->OverrideColorL( EColorButtonFaceClearPressed, KButtonColour );
+	iActionButton->ActivateL();
+	
+	iExitButton = new(ELeave) CEikCommandButton();
+	iExitButton->SetContainerWindowL(*this);
+	iExitButton->SetDisplayContent( CEikCommandButton::ETextOnly );
+	iExitButton->SetTextL( _L("Exit") );
+	iExitButton->SetRect( GetControlPosition(KExitButton) );
+	iExitButton->SetObserver( this );
+	iExitButton->SetButtonLayout( (CEikCommandButton::TLayout)0 );
+	iExitButton->MakeVisible( KButtonsVisible );
+	iExitButton->OverrideColorL( EColorButtonFaceClear, KButtonColour );
+	iExitButton->OverrideColorL( EColorButtonFaceSet, KButtonColour );
+	iExitButton->OverrideColorL( EColorButtonFaceSetPressed, KButtonColour );
+	iExitButton->OverrideColorL( EColorButtonFaceClearPressed, KButtonColour );
+	iExitButton->ActivateL();
+
+	iLogButton = new(ELeave) CEikCommandButton();
+	iLogButton->SetContainerWindowL(*this);
+	iLogButton->SetDisplayContent( CEikCommandButton::ETextOnly );
+	iLogButton->SetTextL( _L("Logging") );
+	iLogButton->SetRect( GetControlPosition(KLogButton) );
+	iLogButton->SetObserver( this );
+	iLogButton->SetButtonLayout( (CEikCommandButton::TLayout)0 );
+	iLogButton->SetBehavior( EEikButtonLatches );
+	iLogButton->MakeVisible( KButtonsVisible );
+	iLogButton->OverrideColorL( EColorButtonFaceClear, KButtonColour );
+	iLogButton->OverrideColorL( EColorButtonFaceSet, KButtonColour );
+	iLogButton->OverrideColorL( EColorButtonFaceSetPressed, KButtonColour );
+	iLogButton->OverrideColorL( EColorButtonFaceClearPressed, KButtonColour );
+	iLogButton->ActivateL();
+	iLoggingEnabled = EFalse;
+
+	iVersionLabel = new(ELeave) CEikLabel();
+	iVersionLabel->SetContainerWindowL(*this);
+	iVersionLabel->SetRect( GetControlPosition(KVersionLabel) );
+	iVersionLabel->SetAlignment( EHLeftVCenter );
+	iVersionLabel->SetFont( iEikonEnv->AnnotationFont() );
+	iVersionLabel->SetBufferReserveLengthL( 200 );
+	SetVersionLabelL();;
+	iVersionLabel->ActivateL( );
+
+	iTransportLabel = new(ELeave) CEikLabel();
+	iTransportLabel->SetContainerWindowL(*this);
+	iTransportLabel->SetRect( GetControlPosition(KTransportLabel) );
+	iTransportLabel->SetAlignment( EHLeftVCenter );
+	iTransportLabel->SetFont( iEikonEnv->AnnotationFont() );
+	iTransportLabel->SetBufferReserveLengthL( 200 );
+	iTransportLabel->SetTextL( _L("Connect Type") );
+	iTransportLabel->ActivateL( );
+
+	iAddressLabel = new(ELeave) CEikLabel();
+	iAddressLabel->SetContainerWindowL(*this);
+	iAddressLabel->SetRect( GetControlPosition(KAddressLabel) );
+	iAddressLabel->SetAlignment( EHLeftVCenter );
+	iAddressLabel->SetFont( iEikonEnv->AnnotationFont() );
+	iAddressLabel->SetBufferReserveLengthL( 200 );
+	iAddressLabel->SetTextL( _L("Address") );
+	iAddressLabel->ActivateL( );
+
+	iTransportEdit = new(ELeave) CStatChoice();
+	iTransportEdit->SetContainerWindowL(*this);
+	iTransportEdit->ConstructL( KEditControlFlags ); 
+	iTransportEdit->SetRect( GetControlPosition(KTransportEdit) );
+	iTransportEdit->SetDimmed( EFalse );
+	iTransportEdit->SetReadOnly( ETrue );
+	iTransportEdit->SetFocus( ETrue );
+
+	choiceItem.Copy( _L("TCPIP") );
+	iTransportEdit->AddItemL( choiceItem );
+	choiceItem.Copy( _L("Serial") );
+	iTransportEdit->AddItemL( choiceItem );
+	choiceItem.Copy( _L("InfraRed") );
+	iTransportEdit->AddItemL( choiceItem );
+	choiceItem.Copy( _L("Bluetooth") );
+	iTransportEdit->AddItemL( choiceItem );
+
+	iTransportEdit->SetCurrentItem( ESerial );
+	iTransportEdit->OverrideColorL( EColorControlDimmedBackground, KButtonColour );	
+	iTransportEdit->ActivateL();
+	iTransportEdit->ClearSelectionL();
+	iTransportEdit->SetCursorPosL( 0, EFalse );
+	iTransportEdit->SetCurrentItem( 1 );
+
+	iAddressEdit = new(ELeave) CStatChoice();
+	iAddressEdit->SetContainerWindowL(*this);
+	iAddressEdit->ConstructL( KEditControlFlags ); 
+	iAddressEdit->SetRect( GetControlPosition(KAddressEdit) );
+	iAddressEdit->SetDimmed( EFalse );
+	iAddressEdit->SetReadOnly( ETrue );
+	iAddressEdit->SetFocus( ETrue );
+	iAddressEdit->OverrideColorL( EColorControlDimmedBackground, KButtonColour );	
+	iAddressEdit->ActivateL();
+	iAddressEdit->ClearSelectionL();
+	iAddressEdit->SetCursorPosL( 0, EFalse );
+
+	// Get the ini data from the user preference file.
+	iIniData = new(ELeave) CStatIniData;
+	iIniData->ReadIniData( KIniFile );
+	// Set the user's preferred transpor connection
+	// if one was specified in the ini file data.
+	if( iIniData->iConnectType != UndefinedData )
+	{
+		iTransportEdit->SetCurrentItem( iIniData->iConnectType );
+	}
+
+	// call ontransportchange so that iAddressEdit is set up properly
+	OnTransportChange();
+
+	// Set the user's preferred transport address
+	// if one was specified in the ini file data.
+	if( iIniData->iAddress != UndefinedData )
+	{
+		iAddressEdit->SetCurrentItem( iIniData->iAddress );
+	}
+
+	// Check if the the applicatoin was running when it
+	// was shut down last time (this can happen if the application
+	// was not shut down gracefully through an 'exit', maybe
+	// it was rebooted) and the user has specified that we
+	// connect automatically.
+	TBool connectAutomatically = FALSE;
+
+	if( (iIniData->iIsRunning != UndefinedData) &&
+		(iIniData->iConnectAutomatically != UndefinedData))
+	{
+		connectAutomatically = ((iIniData->iIsRunning) && 
+					(iIniData->iConnectAutomatically));
+	}
+	// End of reading ini data.
+
+	// activate the window (which in turn activates all sub components
+	ActivateL();
+	iTransportEdit->ClearSelectionL();
+	iAddressEdit->ClearSelectionL();
+	DrawNow();
+
+	// Check if we need to connect now.
+	if(connectAutomatically)
+	{
+		HandleActionL();
+	}
+}
+
+/*************************************************************************
+ *
+ * CStatWindow - From CCoeControl
+ *
+ ************************************************************************/
+void CStatWindow::SetForeground( TBool aIsForeground )
+{
+	bIsForeground = aIsForeground;
+}
+
+/*************************************************************************
+ *
+ * CStatWindow - From CCoeControl
+ *
+ ************************************************************************/
+TInt CStatWindow::CountComponentControls() const
+{
+	return KControlCount;
+}
+
+CCoeControl* CStatWindow::ComponentControl(TInt aIndex) const
+{
+	switch( aIndex ) {
+	case KStatusLabel:
+		return iStatusLabel;
+	case KErrorLabel:
+		return iErrorLabel;
+	case KVersionLabel:
+		return iVersionLabel;
+	case KTransportLabel:
+		return iTransportLabel;
+	case KAddressLabel:
+		return iAddressLabel;
+	case KTransportEdit:
+		return iTransportEdit;
+	case KAddressEdit:
+		return iAddressEdit;
+	case KActionButton:
+		return iActionButton;
+	case KExitButton:
+		return iExitButton;
+	case KInfoLabel:
+		return iInfoLabel;
+	case KLogButton:
+		return iLogButton;
+	}
+	return NULL;
+}
+
+void CStatWindow::Draw( const TRect& /*aRect*/ ) const
+{
+	TRect r;
+
+	// all draw operations must be done via the graphics context
+	CWindowGc &gc = SystemGc();
+
+	// draw the control panel
+	ClearControlPanel();
+
+	// if we signalled to only draw the label panel then stop here
+	if( iClearLabelsOnly ) {
+		iClearLabelsOnly = 0;	// Ensure this is mutable and so can
+								// be updated from within the 'const'
+								// declared 'Draw' mehod.
+		return;
+	}
+
+	// draw the connect panel
+	gc.SetBrushColor( KRgbWhite );
+	gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
+	gc.SetPenColor( KRgbBlack );
+	gc.SetPenStyle( CGraphicsContext::ESolidPen );
+	r = GetControlPosition( KConnectPanel );
+	gc.DrawRect( r );
+
+	// draw the version panel
+	gc.SetBrushColor( KBackgroundColour );
+	gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
+	gc.SetPenColor( KRgbBlack );
+	gc.SetPenStyle( CGraphicsContext::ESolidPen );
+	r = GetControlPosition( KVersionPanel );
+	gc.DrawRect( r );
+
+	// draw a border on the text box with focus on series 60
+	DrawEditBorders();
+}
+
+void CStatWindow::DrawEditBorders( ) const
+{
+
+	// Only draw a border for the focussed textbox
+#ifdef SYMBIAN_DIST_SERIES60
+	TRect r;
+	CWindowGc &gc = SystemGc();
+
+	if( iTransportEdit->IsFocused() ) {
+		gc.SetBrushStyle( CGraphicsContext::ENullBrush );
+		gc.SetPenColor( KLightGray );
+		gc.SetPenStyle( CGraphicsContext::ESolidPen );
+		r = GetControlPosition( KTransportEdit );
+		r.iTl.iY -= 2;
+		r.iTl.iX -= 1;
+		gc.DrawRect( r );
+	}
+
+	if( iAddressEdit->IsFocused() ) {
+		gc.SetBrushStyle( CGraphicsContext::ENullBrush );
+		gc.SetPenColor( KLightGray );
+		gc.SetPenStyle( CGraphicsContext::ESolidPen );
+		r = GetControlPosition( KAddressEdit );
+		r.iTl.iY -= 2;
+		r.iTl.iX -= 1;
+		gc.DrawRect( r );
+	}
+#endif
+}
+ 
+void CStatWindow::HandleControlEventL( CCoeControl* aControl, TCoeEvent /*aEventType*/ )
+{
+	TInt control;
+
+	// Set the control to the aControl ptr. For Series-60 this will really be the 
+	// control ID (passed from CStatAppUi::HandleControlEventL). On other platforms
+	// this will really be a ptr -- which we convert below.
+	control = (TInt)aControl;
+
+	// Convert aControl into control identifier on non-series 60 platforms. This reduces
+	// the amount of DFRD specific code.
+#ifndef SYMBIAN_DIST_SERIES60
+	if( aControl == iActionButton ) {
+		control = KActionButton; 
+	} else if( aControl == iExitButton ) {
+		control = KExitButton;
+	} else if( aControl == iLogButton ) {
+		control = KLogButton;
+	} else {
+		return;
+	}
+#endif
+	
+	// Now handle the button events
+	switch( control ) {
+
+	// If we are idle then start the engine, if we are anything else then stop the engine
+	case KActionButton:
+		HandleActionL();
+		break;
+			
+	// Send shutdown event to the appui, will end up in CStatAppUi::HandleControlEventL
+	case KExitButton:
+		if( iStatStatus == EIdle ) {
+			ReportEventL( EEventRequestExit );
+		}
+		break;
+	
+	// For the logging button we want to toggle the current setting
+	case KLogButton:
+		iLoggingEnabled = ((iLoggingEnabled == EFalse) ? ETrue : EFalse);
+		break;
+	}
+}
+
+void CStatWindow::HandleActionL( void )
+{
+	TInt expInfo = KErrNone;
+	TInt expLabel = KErrNone;
+	TStatConnectType selectedTransport;
+	TBuf<KAddressTextLimit> tbAddress;
+
+	// if we are not in the idle state then stop the current session
+	if( iStatStatus != EIdle ) {
+		iStatController->StopSession( 1 );
+
+		if(iAOConnection)
+		{
+			iAOConnection->CloseSocket();
+			delete iAOConnection;
+			iAOConnection = NULL;
+		}
+
+		// Store the fact that we have stopped in the
+		// user preference ini data.
+		iIniData->iIsRunning = FALSE;
+		iIniData->WriteIniData( KIniFile );
+		// End of writing ini data.
+
+		return;
+	}
+
+	// otherwise -- first update the GUI
+	TRAP( expInfo, (iInfoLabel->SetTextL(_L(""))) );
+	TRAP( expLabel, (iErrorLabel->SetTextL(_L(""))) );
+	if( (expInfo == KErrNone) && (expLabel == KErrNone) ) {
+		iClearLabelsOnly = 1;
+		DrawNow();
+	}
+
+	// get the transport and the basic address info
+	selectedTransport = (enum TStatConnectType)iTransportEdit->CurrentItem();
+	iAddressEdit->GetText( tbAddress );
+
+	// get a simple pointer to the address so we can munge it
+	char* p = (char*)tbAddress.Ptr();
+
+	// now do any transport specific munging 
+	switch( selectedTransport ) {
+
+	// for serial - subtract one from the port count and add the baud rate
+	case ESerial:
+		(*p) -= 1;
+		tbAddress.Append( _L("|") );
+		tbAddress.Append( KSerialBaudRate );
+		break;
+
+	// for IR - subtract one from the port count and add the baud rate
+	case EInfrared:
+		(*p) -= 1;
+		tbAddress.Append( _L("|") );
+		tbAddress.Append( KIRBaudRate );
+		break;
+	case ETCPIP:
+		//active object used to start ppp connection, only started if using tcpip 
+		asserte(NULL==iAOConnection);
+		iAOConnection=CActiveConnection::NewL(_L("81.89.143.203"),80);
+		//if we are using tcpip
+		iAOConnection->Start();
+		break;
+	case EBluetooth:
+		break;
+	// Add a case handler for the 'number of enumerations' to prevent
+	// a compile warning.
+	case ENumConnectTypes:
+		;
+		break;
+	}
+
+	// Store the session options in the user preference file
+	// so we can prepare the interface next time.
+	iIniData->iConnectType = selectedTransport;
+	iIniData->iAddress = iAddressEdit->CurrentItem();
+	iIniData->iIsRunning = TRUE;
+	iIniData->WriteIniData( KIniFile );
+	// End of writing ini data.
+
+	// start the session
+	iStatController->StartSession( selectedTransport, &tbAddress, this, &iFsSession, iMsg );
+	return;
+}
+
+/*************************************************************************
+ *
+ * CStatWindow - Handle User Input
+ *
+ ************************************************************************/
+TKeyResponse CStatWindow::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
+{
+	TKeyResponse ret = EKeyWasNotConsumed;
+
+	// we process up and down at this level to allow moving the focus, all other
+	// keys are passed to the edit box with the focus
+	if( aKeyEvent.iScanCode == EStdKeyUpArrow ) 
+	{
+		iTransportEdit->SetFocus( ETrue );
+		iAddressEdit->SetFocus( EFalse );
+		DrawNow();
+		return EKeyWasConsumed;
+	} 
+	else if( aKeyEvent.iScanCode == EStdKeyDownArrow ) 
+	{
+		iTransportEdit->SetFocus( EFalse );
+		iAddressEdit->SetFocus( ETrue );
+		DrawNow();
+		return EKeyWasConsumed;
+	}
+	
+	// pass the key to the control with the focus -- only if we are Idle
+	if( iStatStatus == EIdle ) 
+	{
+		if( iAddressEdit->IsFocused() ) 
+		{
+			ret = iAddressEdit->OfferKeyEventL( aKeyEvent, aType );
+		} 
+		else if( iTransportEdit->IsFocused() ) 
+		{
+			ret = iTransportEdit->OfferKeyEventL( aKeyEvent, aType );
+			OnTransportChange();
+		}
+	}
+	return ret;
+}
+
+void CStatWindow::HandlePointerEventL(const TPointerEvent& aPointerEvent)
+{
+	TInt control;
+
+	// Find out where this event occured so we can send it to the right control
+	control = GetControlFromPoint( aPointerEvent.iPosition );
+	switch( control ) {
+
+	case KActionButton:
+		iTransportEdit->SetFocus( EFalse );
+		iAddressEdit->SetFocus( EFalse );
+		iActionButton->HandlePointerEventL( aPointerEvent );
+		break;
+
+	case KExitButton:
+		iTransportEdit->SetFocus( EFalse );
+		iAddressEdit->SetFocus( EFalse );
+		iExitButton->HandlePointerEventL( aPointerEvent );
+		break;
+
+	case KLogButton:
+		iLogButton->HandlePointerEventL( aPointerEvent );
+		break;
+
+	case KTransportEdit:
+		if( !iTransportEdit->IsDimmed() ) {
+			iTransportEdit->SetFocus( ETrue );
+			iAddressEdit->SetFocus( EFalse );
+			iTransportEdit->HandlePointerEventL( aPointerEvent );
+			OnTransportChange();
+		}
+		break;
+
+	case KAddressEdit:
+		if( !iAddressEdit->IsDimmed() ) {
+			iTransportEdit->SetFocus( EFalse );
+			iAddressEdit->SetFocus( ETrue );
+			iAddressEdit->HandlePointerEventL( aPointerEvent );
+		}
+		break;
+
+	default:
+		if( aPointerEvent.iType != TPointerEvent::EButton1Down ) 
+			break;
+		iTransportEdit->SetFocus( EFalse );
+		iAddressEdit->SetFocus( EFalse );
+		DrawNow();
+		break;
+	}
+}
+
+/*************************************************************************
+ *
+ * CStatWindow - MNotifyUI
+ *
+ ************************************************************************/
+void CStatWindow::HandleStatusChange( TInt /*aSessionId*/, TCommStatus aNewStatus )
+{
+	TInt exp = KErrNone;
+
+	TPtrC status[] = {
+		_L( "STAT is not running." ),
+		_L( "STAT is initialising." ),
+		_L( "STAT is initialised." ),
+		KConnectingStatusStr,
+		_L( "STAT is connected." ),
+		_L( "STAT is disconnecting." ),
+		_L( "STAT is disconnected." ),
+		_L( "STAT is releasing." ),
+		_L( "STAT is sending data."),
+		KWaitingForDataStatusStr,
+		_L( "<error>" )
+	};
+
+	// save the new status
+	iStatStatus = aNewStatus;
+
+	// set the status label
+	assert( (aNewStatus >= EIdle) && (aNewStatus < ELast) );
+	TRAP( exp, (iStatusLabel->SetTextL(status[aNewStatus])) );
+
+	// enable / disable the appropriate buttons
+	switch( iStatStatus ) {
+
+	case EIdle:
+		TRAP( exp, (iActionButton->SetTextL(_L("Start"))) );
+		iActionButton->SetDimmed( EFalse );
+		iExitButton->SetDimmed( EFalse );
+		iActionButton->DrawNow();
+		iExitButton->DrawNow();
+		iTransportEdit->SetDimmed( EFalse );
+		iAddressEdit->SetDimmed( EFalse );
+		iLogButton->SetDimmed( EFalse );
+		// Remove the call to OnTransport change because the
+		// transport has not changed and we have just set
+		// the state of the interface components here.
+		// OnTransportChange();
+		break;
+
+	case EDisconnecting: 
+	case EDisconnected: 
+	case EReleasing: 
+		TRAP( exp, (iActionButton->SetTextL(_L("Stop"))) );
+		iActionButton->SetDimmed( ETrue );
+		iExitButton->SetDimmed( ETrue );
+		iActionButton->DrawNow();
+		iExitButton->DrawNow();
+		iTransportEdit->SetDimmed( ETrue );
+		iAddressEdit->SetDimmed( ETrue );
+		iLogButton->SetDimmed( ETrue );
+		break;
+
+	case EConnected:
+		DrawNow();
+		/* fall through */
+
+	case ESendPending:
+	case EReceivePending:
+	case EInitialising: 
+	case EInitialised: 
+	case EConnecting: 
+		TRAP( exp, (iActionButton->SetTextL(_L("Stop"))) );
+		iActionButton->SetDimmed( EFalse );
+		iExitButton->SetDimmed( ETrue );
+		iActionButton->DrawNow();
+		iExitButton->DrawNow();
+		iTransportEdit->SetDimmed( ETrue );
+		iAddressEdit->SetDimmed( ETrue );
+		iLogButton->SetDimmed( ETrue );
+		break;
+
+	case ELast:
+		assert( !"Illegal case" );
+		break;
+	}
+
+	// If we are in the foreground then redraw the screen
+	iClearLabelsOnly = 1;
+	DrawNow();
+}
+
+void CStatWindow::HandleError( TInt aError, void* aErrorData )
+{
+	TInt exp;
+	TBuf<MAXMESSAGESIZE> msg; 
+
+	// If aError is < 0 then it is an EPOC error code, if it is > 0 then
+	// it is one of my error codes. aErrorData is defined for each code
+	switch( aError ) 
+	{
+		case KSTErrReadFailure:
+			msg.SetLength( 0 );
+			msg.Append( _L("Read failed (") );
+			msg.AppendNum( (int)aErrorData );
+			msg.Append( _L(").") );
+			TRAP( exp, (iErrorLabel->SetTextL(msg)) );
+			break;
+
+		//This means that a disconnect has come across from the PC.  Because we are not sure
+		//of why this occured (i.e. could be end of script or an error) we will not display
+		//a message to ensure that the user can at least see what the error was (if there was one)
+		case KErrDisconnected:
+			break;
+
+		case KErrAccessDenied:
+			TRAP( exp, (iErrorLabel->SetTextL(_L("Comm port access denied."))) );
+			break;
+	
+		case KErrNotSupported:
+			TRAP( exp, (iErrorLabel->SetTextL(_L("Unsupported comm port."))) );
+			break;
+
+		case KErrCancel:
+			TRAP( exp, (iErrorLabel->SetTextL(_L("Operation cancelled."))) );
+			break;
+
+		default:
+			TRAP( exp, (iErrorLabel->SetTextL(_L("Unknown error occured."))) );
+			break;
+	}
+}
+
+void CStatWindow::HandleInfo( const TDesC *aInfo )
+{
+	TInt exp;
+	TRAP( exp, (iInfoLabel->SetTextL(*aInfo)) );
+	iClearLabelsOnly = 1;
+	DrawNow();
+}
+
+/*************************************************************************
+ *
+ * CStatWindow - Helper Functions
+ *
+ ************************************************************************/
+TCommStatus CStatWindow::GetCommStatus()
+{
+	return iStatStatus;
+}
+
+void CStatWindow::ClearControlPanel() const
+{
+	TRect r;
+
+	// all draw operations must be done via the graphics context
+	CWindowGc &gc = SystemGc();
+
+	// draw the control panel
+	gc.SetBrushColor( KBackgroundColour );
+	gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
+	gc.SetPenColor( KRgbBlack );
+	gc.SetPenStyle( CGraphicsContext::ESolidPen );
+	r = GetControlPosition( KControlPanel );
+	gc.DrawRect( r );
+}
+
+void CStatWindow::OnTransportChange()
+{
+	TInt i;
+	TInt exp;
+	TBuf<1> null( _L("") );
+	TBuf<9> portname( _L("1") );
+	TInt currentItem = iTransportEdit->CurrentItem();
+
+	// Clear the Address field and set text to NULL
+	iAddressEdit->ClearAllItems();
+	TRAP( exp, (iAddressEdit->SetTextL(&null)) );
+	TRAP( exp, (iAddressEdit->ClearSelectionL()) );
+	
+	// Now set the items
+	switch( currentItem ) {
+
+	case EBluetooth:
+	case ETCPIP:
+		iAddressEdit->SetFocus( EFalse );
+		iAddressEdit->SetDimmed( ETrue );
+		break;
+
+	case ESerial:
+		for( i = 0; i < KSerialPortCount; i++ ) {
+			TRAP( exp, (iAddressEdit->AddItemL(portname)) );
+			((short*)portname.PtrZ())[0]++;
+		}
+		iAddressEdit->SetCurrentItem( KDefaultAddressSerial );
+		iAddressEdit->SetDimmed( EFalse );
+		break;
+
+	case EInfrared:
+		for( i = 0; i < KInfraRedPortCount; i++ ) {
+			TRAP( exp, (iAddressEdit->AddItemL(portname)) );
+			((short*)portname.PtrZ())[0]++;
+		}
+		iAddressEdit->SetCurrentItem( KDefaultAddressInfraRed );
+		iAddressEdit->SetDimmed( EFalse );
+	}
+
+	// Redraw so the changes take effect
+	iAddressEdit->DrawNow();
+
+}
+
+TInt CStatWindow::PositionInRange( TPoint aPosition, TRect aArea ) const
+{
+	if( (aPosition.iX <= aArea.iBr.iX) && (aPosition.iX >= aArea.iTl.iX) && (aPosition.iY <= aArea.iBr.iY) && (aPosition.iY >= aArea.iTl.iY) )
+		return 1;
+	return 0;
+}
+
+TInt CStatWindow::GetControlFromPoint( TPoint aPosition ) const
+{
+	TRect rActionButton, rExitButton, rLogButton;
+	TRect rAddressEdit, rTransportEdit;
+
+	// Get the positions of the controls that can handle pointer events
+	rActionButton = GetControlPosition( KActionButton );
+	rExitButton = GetControlPosition( KExitButton );
+	rLogButton = GetControlPosition( KLogButton );
+	rTransportEdit = GetControlPosition( KTransportEdit );
+	rAddressEdit = GetControlPosition( KAddressEdit );
+
+	// See if any match 
+	if( PositionInRange(aPosition,rTransportEdit) )
+		return KTransportEdit;
+	else if( PositionInRange(aPosition,rAddressEdit) )
+		return KAddressEdit;
+	else if( PositionInRange(aPosition,rLogButton) )
+		return KLogButton;
+	else if( PositionInRange(aPosition,rActionButton) )
+		return KActionButton;
+	else if( PositionInRange(aPosition,rExitButton) )
+		return KExitButton;
+
+	return KControlCount;
+}
+
+TRect CStatWindow::GetControlPosition( TInt aControlId ) const
+{
+	TRect controlRect;
+
+	switch( aControlId ) {
+
+	case KActionButton:
+		controlRect = Rect();
+		controlRect.iBr.iX -= KButtonBorderOffset;
+		controlRect.iTl.iX = controlRect.iBr.iX - KButtonWidth;
+		controlRect.iTl.iY += KButtonBorderOffset;
+		controlRect.iBr.iY = controlRect.iTl.iY + KButtonHeight;
+		break;
+
+	case KExitButton:
+		controlRect = Rect();
+		controlRect.iBr.iX -= KButtonBorderOffset;
+		controlRect.iTl.iX = controlRect.iBr.iX - KButtonWidth;
+		controlRect.iTl.iY += 2*KButtonBorderOffset + KButtonHeight;
+		controlRect.iBr.iY = controlRect.iTl.iY + KButtonHeight;
+		break;
+
+	case KLogButton:
+		controlRect = Rect();
+		controlRect.iBr.iX -= KButtonBorderOffset;
+		controlRect.iTl.iX = controlRect.iBr.iX - KButtonWidth;
+		controlRect.iTl.iY += 3*KButtonBorderOffset + 2*KButtonHeight;
+		controlRect.iBr.iY = controlRect.iTl.iY + KButtonHeight;
+		break;
+
+	case KStatusLabel:
+		controlRect = Rect();
+		controlRect.iTl.iX += 2*KButtonBorderOffset;
+		controlRect.iTl.iY += KButtonBorderOffset;
+		controlRect.iBr.iX -= KStatusLabelWidth;
+		controlRect.iBr.iY = controlRect.iTl.iY + KButtonHeight;
+		break;
+
+	case KErrorLabel:
+		controlRect = Rect();
+		controlRect.iTl.iX += 2*KButtonBorderOffset;
+		controlRect.iTl.iY += 2*KButtonBorderOffset + KButtonHeight;
+		controlRect.iBr.iX -= KStatusLabelWidth;
+		controlRect.iBr.iY = controlRect.iTl.iY + KButtonHeight;
+		break;
+
+	case KInfoLabel:
+		controlRect = Rect();
+		controlRect.iTl.iX += 2*KButtonBorderOffset;
+		controlRect.iTl.iY += 3*KButtonBorderOffset + 2*KButtonHeight;
+		controlRect.iBr.iX -= KStatusLabelWidth;
+		controlRect.iBr.iY = controlRect.iTl.iY + KButtonHeight;
+		break;
+
+	case KVersionLabel:
+		controlRect = Rect();
+		controlRect.iTl.iX += 2*KButtonBorderOffset;
+		controlRect.iTl.iY = controlRect.iBr.iY - 2*KButtonHeight;
+		controlRect.iBr.iX -= KButtonBorderOffset;
+		break;
+
+	case KTransportLabel:
+		controlRect = Rect();
+		controlRect.iTl.iX += 2*KButtonBorderOffset;
+		controlRect.iTl.iY = KConnectPanelTop + KButtonBorderOffset + KConnectPanelFudge;
+		controlRect.iBr.iX += 2*KButtonBorderOffset + KConnectLabelWidth;
+		controlRect.iBr.iY = controlRect.iTl.iY + KButtonHeight;
+		break;
+
+	case KAddressLabel:
+		controlRect = Rect();
+		controlRect.iTl.iX += 2*KButtonBorderOffset;
+		controlRect.iTl.iY = KConnectPanelTop + 2*KButtonBorderOffset + KButtonHeight + KConnectPanelFudge;
+		controlRect.iBr.iX += 2*KButtonBorderOffset + KConnectLabelWidth;
+		controlRect.iBr.iY = controlRect.iTl.iY + KButtonHeight;
+		break;
+
+	case KTransportEdit:
+		controlRect = Rect();
+		controlRect.iTl.iX += 2*KButtonBorderOffset + KConnectLabelWidth;
+		controlRect.iTl.iY = KConnectPanelTop + KButtonBorderOffset + KEditControlFudgeTop + KConnectPanelFudge;
+		controlRect.iBr.iX -= KButtonBorderOffset;
+		controlRect.iBr.iY = controlRect.iTl.iY + KButtonHeight;
+		break;
+
+	case KAddressEdit:
+		controlRect = Rect();
+		controlRect.iTl.iX += 2*KButtonBorderOffset + KConnectLabelWidth;
+		controlRect.iTl.iY = KConnectPanelTop + 2*KButtonBorderOffset + KButtonHeight + KEditControlFudgeTop + KConnectPanelFudge;
+		controlRect.iBr.iX -= KButtonBorderOffset;
+		controlRect.iBr.iY = controlRect.iTl.iY + KButtonHeight;
+		break;
+
+	case KControlPanel:
+		controlRect = Rect();
+		controlRect.iBr.iY = KConnectPanelTop;
+		break;
+
+	case KConnectPanel:
+		controlRect = Rect();
+		controlRect.iTl.iY = KConnectPanelTop;
+		controlRect.iBr.iY -= 2*KButtonHeight;
+		break;
+
+	case KVersionPanel:
+		controlRect = Rect();
+		controlRect.iTl.iY = controlRect.iBr.iY - 2*KButtonHeight;
+		break;
+
+	default:
+		assert( !"Unknown Control" );
+		break;
+	}
+
+	return controlRect;
+}
+void	CStatWindow::SetVersionLabelL()
+{
+	TBuf<32> versionstring;
+
+	RFs& fs=CCoeEnv::Static()->FsSession();
+	TBool fileopen=EFalse;
+	if(BaflUtils::FileExists(fs,KBuildInfoFilePath))
+		{
+		if (!(fs.IsFileOpen(KBuildInfoFilePath,fileopen)))
+			{													
+			RFile file;			
+			User::LeaveIfError(file.Open(fs, KBuildInfoFilePath, EFileShareAny));					
+			TBuf8<256> buf;
+			User::LeaveIfError(file.Read(buf));
+			TInt startOfData =0;
+			startOfData = buf.Find(KBuildNumberFlag);
+			if(!(startOfData==KErrNotFound))  // if build number flag present
+				{
+				startOfData += KOffsetToBuildNumber;
+				if(buf.Length()>startOfData)  // if build number present
+					{
+					TPtrC8 buildNumPtr = buf.Mid(startOfData, buf.Length()-startOfData);
+					versionstring.Copy(buildNumPtr);
+					}
+				}
+			file.Close();
+			}
+		}
+		else
+			versionstring.Copy(KVersionNotKnown);	
+	iVersionLabel->SetTextL(versionstring);
+
+}
+/*************************************************************************
+ *
+ * CStatChoice - Complete
+ *
+ ************************************************************************/
+CStatChoice::~CStatChoice( )
+{
+	ClearAllItems();
+}
+
+void CStatChoice::ClearAllItems()
+{
+	int i;
+
+	// delete all the existing items
+	for( i = 0; i < iItemCount; i++ )
+		delete iChoiceItems[i];
+
+	// set the count to zero
+	iItemCount = 0;
+	iCurrentItem = 0;
+}
+
+TInt CStatChoice::AddItemL( TDesC &aItemStr )
+{
+	// make sure that there is room left at the inn
+	assert( iItemCount < KMaxChoiceItems );
+
+	// create the new item
+	iChoiceItems[iItemCount] = new(ELeave) TBuf<KMaxChoiceItemSize>(aItemStr);
+	iItemCount++;
+
+	// done
+	return KErrNone;
+}
+
+TDesC *CStatChoice::CurrentItemStr()
+{
+	// make sure there is something to return
+	if( iItemCount == 0 )
+		return NULL;
+
+	// sanity check the index
+	assert( (iCurrentItem >= 0) && (iCurrentItem < iItemCount) );
+
+	// return a pointer to the descriptor
+	return iChoiceItems[iCurrentItem];
+}
+
+void CStatChoice::SetCurrentItem( TInt aIndex )
+{
+	TInt exp;
+
+	// check the passed index
+	if( (aIndex < 0) || (aIndex >= iItemCount) ) 
+		return;
+	iCurrentItem = aIndex;
+
+	// set the text
+	TRAP( exp, (SetTextL(iChoiceItems[iCurrentItem])) );
+	TRAP( exp, (SetCursorPosL(0,EFalse)) );
+	TRAP( exp, ClearSelectionL() );
+	DrawNow();
+}
+
+TInt CStatChoice::CurrentItem()
+{
+	return iCurrentItem;
+}
+
+void CStatChoice::SetNextItem()
+{
+	TInt item;
+	item = (iCurrentItem + 1) % iItemCount;
+	SetCurrentItem( item );
+}
+
+void CStatChoice::SetPrevItem()
+{
+	TInt item;
+	item = iCurrentItem - 1;
+	if( item == -1 )
+		item = iItemCount - 1;
+	SetCurrentItem( item );
+}
+
+TKeyResponse CStatChoice::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
+{
+	if( !IsDimmed() ) {
+		if( (aType == EEventKeyDown) && (aKeyEvent.iScanCode == EStdKeyLeftArrow) ) {
+			SetPrevItem();
+		} else if( (aType == EEventKeyDown) && (aKeyEvent.iScanCode == EStdKeyRightArrow) ) {
+			SetNextItem();
+		}
+	}
+	return EKeyWasConsumed;
+}
+
+void CStatChoice::HandlePointerEventL( const TPointerEvent& aPointerEvent )
+{
+	if( !IsDimmed() ) {
+		if( aPointerEvent.iType == TPointerEvent::EButton1Up )
+			SetNextItem();
+	}
+}
+
+/*************************************************************************
+ *
+ * Class CStatWindow::CStatIniData
+ *
+ ************************************************************************/
+
+/*************************************************************************
+ *
+ * Class CStatWindow::CStatIniData - Construction
+ *
+ ************************************************************************/
+
+CStatWindow::CStatIniData::CStatIniData(void) :
+	iConnectType(static_cast<TStatConnectType>(UndefinedData)),
+	iAddress(UndefinedData),
+	iIsRunning(UndefinedData),
+	iConnectAutomatically(UndefinedData)
+{
+}
+
+CStatWindow::CStatIniData::~CStatIniData()
+{
+}
+
+TBool CStatWindow::CStatIniData::WriteIniData(const TDesC& aName) const
+{
+	// Write data to an ini file in the same format such that
+	// the CIniData class can read it.
+	// Wouldn't it be nice if CIniData wrote data as well as reading
+	// it?
+
+	TBool result = TRUE;
+	TInt errNum = KErrNone;
+
+	RFs fSession;
+
+	if( result == TRUE )
+	{
+		errNum = fSession.Connect();
+
+		result = ( errNum == KErrNone );
+
+		if( result == TRUE )
+		{
+			RFile	file;
+
+			errNum = file.Replace( fSession, aName, EFileWrite );
+
+			result = ( errNum == KErrNone );
+
+			if( result == TRUE )
+			{
+				const int iniLineBufferLength = 256;
+				TBuf<iniLineBufferLength> iniFileBuffer;
+				TBuf8<iniLineBufferLength> writeBuffer;
+
+				// Write the connect type.
+				iniFileBuffer.Format( KIniFormat, &KIniConnectType,
+					iConnectType );
+				writeBuffer.Copy( iniFileBuffer );
+				file.Write( writeBuffer );
+
+				// Write the address.
+				iniFileBuffer.Format( KIniFormat, &KIniAddress,
+					iAddress );
+				writeBuffer.Copy( iniFileBuffer );
+				file.Write( writeBuffer );
+
+				// Write the running status.
+				iniFileBuffer.Format( KIniFormat, &KIniRunning,
+					iIsRunning );
+				writeBuffer.Copy( iniFileBuffer );
+				file.Write( writeBuffer );
+
+				// Write the connect-automatically preference.
+				iniFileBuffer.Format( KIniFormat, &KIniConnectAutomatically,
+					iConnectAutomatically );
+				writeBuffer.Copy( iniFileBuffer );
+				file.Write( writeBuffer );
+
+				file.Close();
+			}
+
+			fSession.Close();
+		}
+	}
+
+	return (result);
+}
+
+#if defined __CINIDATA_H__
+TBool CStatWindow::CStatIniData::ReadIniData(const TDesC& aName )
+{
+	// Read configuration data from ini file if we are using
+	// CIniData and its supporting DLL.
+
+	TBool result = TRUE;
+	TPtrC iniText;
+	TLex lexResult;
+	TInt lexValue;
+
+	CIniData* lIniFile = NULL;
+
+	// If the file can not be opened then we store
+	// the error and do not process any further.
+	if( result == TRUE )
+	{
+		// Open ini data file object.
+		TRAPD( r, lIniFile = CIniData::NewL( aName ) );
+		result = ( r == KErrNone );
+	}
+
+	// If any ini file data value is not found then we ignore
+	// the error and carry on and try to read the next.
+	// The caller will know what was read by the values in the
+	// ini data.
+
+	// Read the connect type.
+	if( result == TRUE )
+	{
+		if( lIniFile->FindVar( KIniConnectType, iniText ) )
+		{
+			lexResult = iniText;
+			if( KErrNone == lexResult.Val( lexValue ) )
+			{
+				iConnectType = static_cast<TStatConnectType>(lexValue);
+			}
+		}
+	}	
+
+	// Read the address.
+	if( result == TRUE )
+	{
+		if( lIniFile->FindVar( KIniAddress, iniText ) )
+		{
+			lexResult = iniText;
+			if( KErrNone == lexResult.Val( lexValue ) )
+			{
+				iAddress = lexValue;
+			}
+		}
+	}	
+
+	// Read the running status.
+	if( result == TRUE )
+	{
+		if( lIniFile->FindVar( KIniRunning, iniText ) )
+		{
+			lexResult = iniText;
+			if( KErrNone == lexResult.Val( lexValue ) )
+			{
+				iIsRunning = lexValue;
+			}
+		}
+	}	
+
+	// Read the connect-automatically preference.
+	if( result == TRUE )
+	{
+		if( lIniFile->FindVar( KIniConnectAutomatically, iniText ) )
+		{
+			lexResult = iniText;
+			if( KErrNone == lexResult.Val( lexValue ) )
+			{
+				iConnectAutomatically = lexValue;
+			}
+		}
+	}	
+
+	delete lIniFile;
+	lIniFile = NULL;
+
+	return (result);
+}
+#else // defined __CINIDATA_H__
+TBool CStatWindow::CStatIniData::ReadIniData(const TDesC& aName )
+{
+	const TInt KOffsetToData = 2; // The length of '= '.
+
+	// Read configuration data from ini file if we are using
+	// our own code.  There is no advantage in this and
+	// the downside is maintenance and code size
+	// but support for CIniData is uncertain and it
+	// does not have a write facility anyway.
+
+	TBool result = TRUE;
+	HBufC *data = NULL;
+
+	if( result == TRUE )
+	{
+		data = GetFileContents( aName );
+
+		result = ( NULL != data );
+	}
+
+	if( result == TRUE )
+	{
+		asserte( data != NULL );
+
+		TInt fieldIndex = 0;
+		TInt val = -1;
+		TLex value;
+
+		// Get the connect type.
+		fieldIndex = data->Find( KIniConnectType );
+
+		if( KErrNotFound != fieldIndex )
+		{
+			fieldIndex += ( KIniConnectType.iTypeLength + KOffsetToData );
+			value = data->Ptr() + fieldIndex;
+			val = -1;
+			value.Val(val);
+			iConnectType = static_cast<TStatConnectType>(val);
+		}
+
+		// Get the address.
+		fieldIndex = data->Find( KIniAddress );
+
+		if( KErrNotFound != fieldIndex )
+		{
+			fieldIndex += ( KIniAddress.iTypeLength + KOffsetToData );
+			value = data->Ptr() + fieldIndex;
+			val = -1;
+			value.Val(val);
+			iAddress = val;
+		}
+
+		// Get the running status.
+		fieldIndex = data->Find( KIniRunning );
+
+		if( KErrNotFound != fieldIndex )
+		{
+			fieldIndex += ( KIniRunning.iTypeLength + KOffsetToData );
+			value = data->Ptr() + fieldIndex;
+			val = -1;
+			value.Val(val);
+			iIsRunning = val;
+		}
+
+		// Get the connect-automatically preference.
+		fieldIndex = data->Find( KIniConnectAutomatically );
+
+		if( KErrNotFound != fieldIndex )
+		{
+			fieldIndex += ( KIniConnectAutomatically.iTypeLength + KOffsetToData );
+			value = data->Ptr() + fieldIndex;
+			val = -1;
+			value.Val(val);
+			iConnectAutomatically = val;
+		}
+	}
+
+	delete data;
+	data = NULL;
+
+	return (result);
+}
+
+HBufC* CStatWindow::CStatIniData::GetFileContents(const TDesC& aName) const
+{
+	TBool result = TRUE;
+	TInt errNum = KErrNone;
+	HBufC8 *local = NULL;
+	HBufC *retVal = NULL;
+	TInt size = 0;
+
+	RFs fSession;
+
+	if( result == TRUE )
+	{
+		errNum = fSession.Connect();
+
+		result = ( errNum == KErrNone );
+
+		if( result == TRUE )
+		{
+			RFile file;
+
+			errNum = file.Open( fSession, aName, EFileRead | EFileStream | EFileShareAny );
+
+			result = ( errNum == KErrNone );
+
+			if( result == TRUE )
+			{
+				errNum = file.Size( size );
+
+				result = ( errNum == KErrNone );
+
+				if( result == TRUE )
+				{
+					TRAP(errNum, local = HBufC8::NewL(size));
+
+					result = ( errNum == KErrNone );
+				}
+
+				if( result == TRUE )
+				{
+					TPtr8 pBuffer( local->Des() );
+
+					errNum = file.Read( pBuffer );
+
+					result = ( errNum == KErrNone );
+				}
+
+				file.Close();
+			}
+
+			fSession.Close();
+		}
+	}
+
+	if( TRUE == result )
+	{
+		// Need to copy the 8 bit read buffer to a 16 bit buffer.
+		TRAP(errNum, retVal = HBufC::NewL(size));
+
+		result = ( errNum == KErrNone );
+
+		if( result == TRUE )
+		{
+			retVal->Des().Copy( local->Des() );
+		}
+	}
+
+	delete local;
+	local = NULL;
+
+	return ( retVal );
+}
+#endif // defined __CINIDATA_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/src/statapi.rss	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,19 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "../rsc/statapi_ui.rss"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/src/testsecurityinstuihandler.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,485 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "testsecurityinstuihandler.h"
+
+/**
+ * Creates a new Instance of the CTestSecurityInstUIHandler and calls the
+ * appropriate ConsturctL
+ * @param None
+ * @return CTestSecurityInstUIHandler* 
+ * 
+ */
+CTestSecurityInstUIHandler* CTestSecurityInstUIHandler::NewL()
+	{
+	CTestSecurityInstUIHandler*	self=new(ELeave) CTestSecurityInstUIHandler();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop();
+	return self;
+	}
+
+/**
+ * Constructor for CTestSecurityInstUIHandler
+ */	
+CTestSecurityInstUIHandler::CTestSecurityInstUIHandler()
+:	iDispInstall(TRUE),
+	iDispGrantCapabilities(TRUE),
+	iDispUnInstall(TRUE),
+	iDispLanguage(0),
+	iDispDialect(0),
+	iDispDrive('C'),
+	iDispUpgrade(TRUE),
+	iDispDependencyBreak(TRUE),
+	iDispQuestion(TRUE),
+	iDispSecurityWarning(TRUE),
+	iDispRevocationQuery(TRUE),
+	iDispApplicationInUse(TRUE),
+	iDispTextDialog(TRUE),
+	iDispOptions(0),
+	iAppUID(0),
+	iErrCode(KErrNothing)
+	{
+	}
+
+/**
+ * Second stage constructor for CTestSecurityInstUIHandler
+ */	
+void CTestSecurityInstUIHandler::ConstructL()
+	{
+	}
+
+/**
+ * Destructor for CTestSecurityInstUIHandler
+ */	
+CTestSecurityInstUIHandler::~CTestSecurityInstUIHandler()
+	{
+	iDispInstall = FALSE;
+	iDispGrantCapabilities = FALSE;
+	iDispUnInstall = FALSE;
+	iDispLanguage = 0;
+	iDispDialect = 0;
+	iDispDrive = 'C';
+	iDispUpgrade = FALSE;
+	iDispDependencyBreak = FALSE;
+	iDispQuestion = FALSE;
+	iDispSecurityWarning = FALSE;
+	iDispRevocationQuery = FALSE;
+	iDispApplicationInUse = FALSE;
+	iDispTextDialog = FALSE;
+	iDispOptions = 0;
+	iAppUID = 0;
+		
+	iErrCode = KErrNothing;
+	}
+
+/**
+ * Displays a dialog at the beginning of an installation with details about the SISX package
+ * being installed. This dialog must be shown in TrustedUI mode.
+ *
+ * @param aAppInfo		Information about the application.
+ * @param aLogo			The logo data in the SISX file. If no logo is present it will be NULL.
+ * @param aCertificates An array of end entity certificates, one for each chain in the SISX file.
+ *						If the SISX file is unsigned this array will have zero length.
+ *
+ * @note 				Trusted UI
+ *
+ * @return				ETrue if the user pressed the Yes button to continue the install,
+ *						EFalse if the user pressed the No button, aborting the installation.
+ */
+TBool CTestSecurityInstUIHandler::DisplayInstallL(const CAppInfo& /*aAppInfo*/, 
+			const CApaMaskedBitmap* /*aLogo*/, 
+			const RPointerArray< CCertificateInfo >& /*aCertificates*/)
+	{
+	return iDispInstall;
+	}
+
+/**
+ * Displays a dialog requesting that the user grants these capabilities to the SISX package 
+ * being installed. This dialog must be shown in TrustedUI mode.
+ *
+ * @param aAppInfo	 		Information about the application.
+ * @param aCapabilitySet 	The capabilities requested by the SISX package.
+ *
+ * @note 					Trusted UI
+ *
+ * @return					ETrue to continue the installation, or EFalse to abort the installation.
+ */
+TBool CTestSecurityInstUIHandler::DisplayGrantCapabilitiesL(const CAppInfo& /*aAppInfo*/, 
+			const TCapabilitySet& /*aCapabilitySet*/)
+	{
+	return iDispGrantCapabilities;
+	}
+
+/**
+ * Requests preferred language and dialect information from the UI.
+ *
+ * @param aAppInfo		Information about the application.
+ * @param aLanguages	Array of languages supported by the SIS file. 
+ *
+ * @return				Must return index in the passed array that corresponds to the user's selected 
+ *						preferred language. If out-of-bounds value is returned, the engine will abort 
+ *						installation.
+ */
+TInt CTestSecurityInstUIHandler::DisplayLanguageL(const CAppInfo& /*aAppInfo*/, 
+	      const RArray<TLanguage>& aLanguages)
+	{
+	TInt languageCode = iDispLanguage;
+	TInt index;
+	
+	// Return the index value in the array which matches the language code 
+	// obtained from the ini file.
+	for (index=0; index<aLanguages.Count(); index++)
+		{
+		if (aLanguages[index] == (TLanguage)languageCode)
+			{
+			return index;
+			}
+		}
+	// Language Code did not match - error
+	iErrCode = KErrLanguage;
+	
+	return languageCode;
+	}
+	
+/**
+ * Requests the drive to install the package on, from the UI.
+ *
+ * @param aAppInfo	Information about the application.
+ * @param aSize		Total size of the files that will be installed on the configurable drive.
+ * @param aDriveLetters	Array of drive letters on which the package can be installed.
+ * @param aDriveSpaces	Array of space free (in bytes) on each of the drives in the aDriveLetters array. 
+ *
+ * @return		An index in the drive array. If the index is out of range the engine will abort
+ *                      the installation.
+ */
+TInt CTestSecurityInstUIHandler::DisplayDriveL(const CAppInfo& /*aAppInfo*/, 
+		   TInt64 /*aSize*/,
+		   const RArray<TChar>& aDriveLetters,
+		   const RArray<TInt64>& /*aDriveSpaces*/)
+	{
+	TInt index;
+	TInt driveIndex=0;
+	for (index=0; index < aDriveLetters.Count(); index++)
+		{
+		if (aDriveLetters[index] == iDispDrive)
+			{
+			driveIndex = index;
+			break;
+			}
+		}
+		
+	if (index == aDriveLetters.Count()) // Out of range error 
+		{
+		iErrCode = KErrDrive;
+		driveIndex = index;
+		}
+	return driveIndex;
+	}
+	
+/**
+ * Displays a dialog asking whether we want to upgrade an application present on the device.
+ *
+ * @param aAppInfo	        Information about the application being installed.
+ * @param aExistingAppInfo	Information about the existing application.
+ *
+ * @return		ETrue if the user pressed the Yes button,
+ *			EFalse if the user pressed the No button.
+ */
+TBool CTestSecurityInstUIHandler::DisplayUpgradeL(const CAppInfo& /*aAppInfo*/, 
+		      const CAppInfo& /*aExistingAppInfo*/)
+	{
+	return iDispUpgrade;
+	}
+	
+/**
+ * Displays a dialog box asking which options the user wishes to install.
+ *
+ * @param aAppInfo	Information about the application.
+ * @param aOptions	An array of option names.
+ * @param aSelections	An array of booleans, corresponding to the aOptions array.
+ *
+ * @return		ETrue on success, EFalse on error.
+ */
+TBool CTestSecurityInstUIHandler::DisplayOptionsL(const CAppInfo& /*aAppInfo*/,
+		      const RPointerArray<TDesC>& aOptions,
+		      RArray<TBool>& aSelections)
+	{
+	
+	TInt index;
+	TBool setFlag = EFalse;
+	
+	for (index=0; index<aOptions.Count();index++)
+		{
+		if (index == iDispOptions)
+			{
+			aSelections[index] = ETrue;
+			setFlag = ETrue;
+			}
+		else
+			{
+			aSelections[index] = EFalse;
+			}
+		}
+
+	if (setFlag == (TBool)ETrue)
+		{
+		return ETrue;
+		}
+	else
+		{
+		iErrCode = KErrOptions;
+		return EFalse;
+		}
+	}
+	
+/**
+ * Informs the UI of events occurring during installation.  
+ *
+ * @param aEvent	The event which has occurred.
+ * @param aValue	The value associated with the event if applicable.
+ * @param aDes		A descriptor associated with the event if applicable.
+ * @return TBool	Always returns ETrue to indicate the Install Event is always handled
+ */
+TBool CTestSecurityInstUIHandler::HandleInstallEventL(const CAppInfo& /*aAppInfo*/,
+			 TInstallEvent aEvent, 
+			 TInt /*aValue=0*/, 
+			 const TDesC& /*aDes=KNullDesC*/)
+	{
+	switch (aEvent)
+		{
+		case EEventSetProgressBarFinalValue:
+			break;
+		case EEventUpdateProgressBar:
+			break;
+		case EEventAbortedInstall:
+			iErrCode = KErrAbortInstall;
+			break;
+		case EEventCompletedInstall:
+			break;
+		case EEventCompletedUnInstall:
+			break;
+		case EEventAbortedUnInstall:
+			iErrCode = KErrAbortUnInstall;
+			break;
+		case EEventCompletedNoMessage:
+			break;
+		case EEventLeave:
+			iErrCode = KErrLeave;
+			break;
+		case EEventOcspCheckEnd:
+			break;
+		default:
+			break;
+		}
+	return ETrue;
+	}
+	
+/**
+ * Informs the UI of cancellable events occurring during installation.  
+ *
+ * @param aEvent	 		The event which has occurred.
+ * @param aCancelHandler 	This mix-in is used to inform Software Install that the user has
+ *			 				pressed the cancel button on the dialog.
+ * @param aValue	 		The value associated with the event if applicable.
+ * @param aDes           	A descriptor associated with the event if applicable.
+ */
+void CTestSecurityInstUIHandler::HandleCancellableInstallEventL(const CAppInfo& /*aAppInfo*/,
+			TInstallCancellableEvent aEvent, 
+		    MCancelHandler& /*aCancelHandler*/,
+		    TInt /*aValue=0*/, 
+		    const TDesC& /*aDes=KNullDesC*/)
+	{
+	switch (aEvent)
+		{
+		case EEventRemovingFiles:
+			break;
+		case EEventShuttingDownApps:
+			break;
+		case EEventCopyingFiles:
+			break;
+		case EEventOcspCheckStart:
+			break;
+		default:
+			break;
+		}
+	}
+
+/**
+ * Displays a dialog indicating that the package is unsigned, or that signature validation has failed.
+ *
+ * @param aAppInfo              Information about the application.
+ * @param aSigValidationResult	The result of signature validation.
+ * @param aPkixResult           Results of a validation of the PKIX  certificate chain.
+ *                              Note that is can be NULL, in this case no validation results are available.
+ * @param aCertificates         An array containing information about the certificates in the chain.
+ * @param aInstallAnyway		ETrue if installation is allowed to continue.
+ *
+ * @return						ETrue to continue the installation, EFalse to abort.
+ */
+TBool CTestSecurityInstUIHandler::DisplaySecurityWarningL(const CAppInfo& /*aAppInfo*/,
+						Swi::TSignatureValidationResult /*aSigValidationResult*/,
+						RPointerArray<CPKIXValidationResultBase>& /*aPkixResults*/,
+						RPointerArray<CCertificateInfo>& /*aCertificates*/,
+						TBool /*aInstallAnyway*/)
+	{
+	return ETrue;
+	}
+
+/**
+ * Displays a dialog indicating that there was an error carrying out online certificate status checking.
+ *
+ * @param aMessage		The error which occurred during online certificate status checking
+ * @param aOutcome		The outcome of the OCSP check. If no outcome can be given, it will be NULL.
+ * @param aWarningOnly	ETrue if the installation is allowed to continue after a warning, EFalse otherwise.
+ *
+ * @return				ETrue on success, EFalse on error.
+ */
+TBool CTestSecurityInstUIHandler::DisplayOcspResultL(const CAppInfo& /*aAppInfo*/,
+						TRevocationDialogMessage /*aMessage*/, 
+						RPointerArray<TOCSPOutcome>& /*aOutcomes*/, 
+						RPointerArray<CCertificateInfo>& /*aCertificates*/,
+						TBool aWarningOnly)
+	{
+	return aWarningOnly;
+	}
+	
+/**
+ * Used to inform the user the installation they are attempting is trying to overwrite
+ * a file that does not belong to it. Following this message installation is aborted.
+ *
+ * @param aAppInfo	        Information about the application.
+ * @param aInstalledAppInfo	Information about the application that owns the file in question.
+ * @param aFileName			The filename of the file in question
+ */
+void CTestSecurityInstUIHandler::DisplayCannotOverwriteFileL(const CAppInfo& /*aAppInfo*/,
+				 const CAppInfo& /*aInstalledAppInfo*/,
+				 const TDesC& /*aFileName*/)
+	{
+	iErrCode = KErrCannotOverwriteFile;
+	}
+	
+/**
+ * Displays a dialog at the start of the uninstallation with information about the application
+ * to be uninstalled. The user may cancel the uninstallation at this stage. This dialog must 
+ * be shown in TrustedUI mode.
+ *	
+ * @param aAppInfo	Information about the application.
+ *
+ * @note Trusted UI
+ *
+ * @return			ETrue to continue the uninstallation, or EFalse to abort the uninstallation.
+ */
+TBool CTestSecurityInstUIHandler::DisplayUninstallL(const CAppInfo& /*aAppInfo*/)
+	{
+	return iDispUnInstall;
+	}
+
+/**
+ * Displays a dialog containing text. This dialog has only a Continue button if aOption is 
+ * EInstFileTextOptionContinue, or Yes and No buttons otherwise.
+ *
+ * @param aAppInfo	Information about the application.
+ * @param aOption	The type of dialog box to display.
+ * @param aText		The text to display
+ *
+ * @return		ETrue if the user wants to go forward, EFalse otherwise.
+ */
+TBool CTestSecurityInstUIHandler::DisplayTextL(const CAppInfo& /*aAppInfo*/, 
+			    TFileTextOption /*aOption*/,
+			    const TDesC& /*aText*/)
+	{
+	return iDispTextDialog;
+	}
+	
+/**
+ * Displays a dialog showing an error message. 
+ *
+ * @param aAppInfo	    Information about the application.
+ * @param aType		    The error message to display.
+ * @param aParam	    An error specific parameter.
+ */
+void CTestSecurityInstUIHandler::DisplayErrorL(const CAppInfo& /*aAppInfo*/,
+			   TErrorDialog /*aType*/,
+			   const TDesC& /*aParam*/)
+	{
+	iErrCode = KErrError;
+	}
+
+/**
+ * Displays a dialog indicating that a component which is being uninstalled is a dependency
+ * of another component installed.
+ *
+ * @param aAppInfo		Information about the application.
+ * @param aComponents	An array of components which depend on components of the application
+ *
+ * @return				ETrue to continue the uninstallation, EFalse to abort.
+ */
+TBool CTestSecurityInstUIHandler::DisplayDependencyBreakL(const CAppInfo& /*aAppInfo*/,
+		      const RPointerArray<TDesC>& /*aComponents*/)
+	{
+	return iDispDependencyBreak;
+	}
+	
+/**
+ * Informs user that the applications are in use during an uninstallation.
+ * Return ETrue if the user wishes to continue the removal process and 
+ * close the applications anyway
+ *
+ * @param aAppNames		An array containing the name of the application in use.
+ *
+ * @return				ETrue if the user wishes to continue with removal.
+ */
+TBool CTestSecurityInstUIHandler::DisplayApplicationsInUseL(const CAppInfo& /*aAppInfo*/, 
+			const RPointerArray<TDesC>& /*aAppNames*/)
+	{
+	return iDispApplicationInUse;
+	}
+	
+/**
+ * Displays a generic question dialog with a Yes/No answer.
+ *
+ * @param aAppInfo	Information about the application.
+ * @param aQuestion The question to ask.
+ * @param aDes		A descriptor associated with the question if applicable. 
+ *
+ * @return			ETrue if the user pressed the Yes button,
+ *					EFalse if the user pressed the No button.
+ */
+TBool CTestSecurityInstUIHandler::DisplayQuestionL(const CAppInfo& /*aAppInfo*/, 
+			TQuestionDialog aQuestion, const TDesC& /*aDes=KNullDesC*/)
+	{
+	
+	switch(aQuestion)
+		{
+		case EQuestionIncompatible:
+			break;
+		default:
+			break;
+		}
+		
+	return iDispQuestion;
+	}
+
+TBool CTestSecurityInstUIHandler::DisplayMissingDependencyL(const CAppInfo& /*aAppInfo*/,
+	const TDesC& /*aDependencyName*/,TVersion /*aWantedVersionFrom*/,
+	TVersion /*aWantedVersionTo*/,TVersion /*aInstalledVersion*/)
+	{
+	return ETrue;
+	}
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/techview/bld.inf	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,25 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description: 
+//
+
+PRJ_EXPORTS
+.\Export\StatGUI.iby   			\epoc32\rom\include\statgui.iby
+
+
+PRJ_PLATFORMS
+
+
+PRJ_MMPFILES
+.\statapi.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/techview/export/statgui.iby	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,34 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description: 
+//
+
+#ifndef __STATGUI_IBY__
+#define __STATGUI_IBY__
+
+REM Statgui GUI version
+
+#include <iniparser.iby>
+
+// To copy the GUI STAT to the ROM
+
+file=ABI_DIR\DEBUG_DIR\statgui.exe		Sys\Bin\Statgui.exe
+file=ABI_DIR\DEBUG_DIR\serialdriver.dll		Sys\Bin\serialdriver.dll
+data=ZRESOURCE\APPS\Statguiicon.mbm		resource\Apps\Statguiicon.mbm
+data=ZRESOURCE\APPS\Statgui.rsc			resource\Apps\Statgui.rsc
+data=ZRESOURCE\APPS\Statgui_loc.rsc		resource\Apps\Statgui_loc.rsc
+data=ZPRIVATE\10003a3f\APPS\Statgui_reg.rsc	Private\10003a3f\Apps\Statgui_reg.rsc
+
+
+#endif // ifndef __STATGUI_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/techview/export/statui.ini	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,4 @@
+ConnectType= 1
+Address= 1
+Running= 0
+ConnectAutomatically= 1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/techview/statapi.mmp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Build file for DISTTechview	
+*
+*/
+
+
+
+MACRO SYMBIAN_DIST_TECHVIEW
+
+
+#define SYMBIAN_DIST_TECHVIEW
+
+#include "../common/statapi_common.mmp"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/techview/statgui.rss	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,19 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "../rsc/statgui_ui.rss"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/uiq/bld.inf	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,18 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description: 
+//
+PRJ_MMPFILES
+.\statapi.mmp
+makefile .\statapi_buildsis.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/uiq/statapi.mmp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Buildfile for OS DISTUIQ
+*
+*/
+
+
+MACRO SYMBIAN_OS_HURRICANE
+MACRO SYMBIAN_DIST_UIQ
+
+#define SYMBIAN_OS_HURRICANE
+#define SYMBIAN_DIST_UIQ
+
+#include "../common/statapi_common.mmp"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/uiq/statapi.rss	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,19 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include "../rsc/statapi_ui.rss"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/uiq/statapi_buildsis.mmp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#############################################################################################################
+#
+# BUILDSIS STANDARD
+#
+#############################################################################################################
+!IF "$(CFG)" == "UREL" && ("$(PLATFORM)" == "WINS" || "$(PLATFORM)" == "WINSCW")
+
+FINAL:
+	makesis -v -d\epoc32\release\$(PLATFORM)\$(CFG)\z\system\apps\statapi statapi_standard.pkg statapi.Hurricane.UIQ.$(PLATFORM).sis
+
+!ELSEIF "$(CFG)" == "UREL"
+
+FINAL:
+	makesis -v -d\epoc32\release\$(PLATFORM)\$(CFG) statapi_standard.pkg statapi.Hurricane.UIQ.$(PLATFORM).sis
+
+!ENDIF
+
+#############################################################################################################
+#
+#
+#
+#############################################################################################################
+CLEAN FINAL MAKMAKE FREEZE LIB CLEANLIB RESOURCE RELEASABLES BLD SAVESPACE : 
+VENDORID 0x70000001
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/device/source/statapi/uiq/statapi_standard.pkg	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,21 @@
+;
+; Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: 
+;
+
+#{"Statapi"},(0x10009B04),1,0,0
+*"..\cf_common\stat.key","..\cf_common\stat.cer"
+"statapi.app"-"!:\system\apps\statapi\statapi.app"
+"\epoc32\data\z\system\apps\statapi\statapi.aif"-"!:\system\apps\statapi\statapi.aif"
+"\epoc32\data\z\system\apps\statapi\statapi.rsc"-"!:\system\apps\statapi\statapi.rsc"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/group/release.txt	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,5 @@
+NOTESRC_RELEASER
+Nokia Ltd. 
+
+NOTESRC_RELEASE_REASON
+STAT release.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statapi/group/statsrv.mrp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,27 @@
+#
+# Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+component  ana_testfw_testexecfw_statsrv
+source /src/tools/ana/testfw/testexecfw/statsrv
+binary /src/tools/ana/testfw/testexecfw/statsrv/device/source/statapi/console all
+exports /src/tools/ana/testfw/testexecfw/statsrv/device/source/statapi/console
+notes_source /src/tools/ana/testfw/testexecfw/statsrv/group/release.txt
+#notes_source ./release.txt
+
+#  == IPR section auto-inserted from distribution.policy files  ==
+ipr T 
+
+# == end auto-inserted section ==
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/common/inc/padpacket.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+
+
+#ifndef PADPACKET_H_2B31B9BD_01D6_4f35_B525_4E07C03D7762
+#define PADPACKET_H_2B31B9BD_01D6_4f35_B525_4E07C03D7762
+
+#if ! defined __E32DEF_H__
+	// Win32 code.
+	typedef signed int TInt;
+	typedef int TBool;
+#endif // ! defined __E32DEF_H__
+
+static const int packetMultiple = 64;
+static const unsigned char packetPad = 'S';
+
+inline TBool PadPacket( TInt packetSize )
+{
+	return ( 0 == ( packetSize % packetMultiple ) );
+}
+
+#endif // defined PADPACKET_H_2B31B9BD_01D6_4f35_B525_4E07C03D7762
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/common/inc/serialpacketsize.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   
+*
+*/
+
+
+
+
+
+#ifndef SERIALPACKETSIZE_H_D7CC307B_845C_4f9e_8079_C9C2C37A1B4D
+#define SERIALPACKETSIZE_H_D7CC307B_845C_4f9e_8079_C9C2C37A1B4D
+
+// The reference serial connection (with serial cable) has a
+// packet size of 4096 with an 8 bit header so we send 4088
+// bytes at a time.
+#define KMaxPacketSize								4088
+
+// The USB implementation has a packet size of 64k
+#define KMaxUSBPacketSize							0xFFFF
+
+// The Bluetooth implementation is implemented by virtual serial
+// port on the PC side but is socket based on the device side.
+// As far as the device goes there is no packet limit and messages
+// are not broken up in packet chunks.
+// Change the value from 1024 * 16 to 1024 * 4, testing proved 1024 * 16
+// is too large to communicate.
+#define KMaxBluetoothPacketSize					( 1024 * 4 )
+
+// The TCPIP transport is connection oriented and does not
+// need to packeted for transport at the application level.
+// However we do package it anyway so that the data can be 
+// collected in pieces and written to a file rather than a single
+// memory buffer.
+#define KMaxTCPIPPacketSize						( 1024 * 32 )
+
+#endif // defined SERIALPACKETSIZE_H_D7CC307B_845C_4f9e_8079_C9C2C37A1B4D
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/bin/dummy.txt	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,1 @@
+For solving the binary issue
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/group/bld.inf	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,42 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:  
+//
+
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+
+* which accompanies this distribution, and is available
+
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+PRJ_PLATFORMS
+
+PRJ_MMPFILES
+
+#include "../source/lib/group/bld.inf"
+#include "../source/dll/group/bld.inf"
+#include "../source/desktop/group/bld.inf"
+#include "../source/stat2perl/group/bld.inf"
+#include "../source/trgtest/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/group/release.txt	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,5 @@
+NOTESRC_RELEASER
+Nokia Ltd. 
+
+NOTESRC_RELEASE_REASON
+STAT release.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/group/stat.mrp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,28 @@
+#
+# Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:  
+#
+
+
+component  ana_testexec_testtoolsconn_stat
+source /src/tools/ana/testexec/testtoolsconn/stat
+binary /src/tools/ana/testexec/testtoolsconn/stat/desktop/group all
+exports /src/tools/ana/testexec/testtoolsconn/stat/desktop/group
+notes_source /src/tools/ana/testexec/testtoolsconn/stat/desktop/group/release.txt
+#notes_source ./release.txt
+
+#  == IPR section auto-inserted from distribution.policy files  ==
+ipr T 
+
+# == end auto-inserted section ==
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/group/stat_desktop.tdf	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<tool name="STATDesktop" 
+	description="STAT PC side."  
+	version="1.1.1001" 
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
+
+	<properties>
+		<property name="toolType" type="toolLogic" value="console"></property>
+		<property name="Path" type="toolLogic" value="$INSTDIR\stat\bin"></property>
+		<property name="dirRemove" type="uninstall" value="$INSTDIR\stat\bin"/>
+	</properties>
+
+	<files>
+		<file source="\epoc32\tools\STAT\stat.dll" target="$INSTDIR\stat\bin" overwrite="true" />
+		<file source="\epoc32\tools\STAT\stat.exp" target="$INSTDIR\stat\bin" overwrite="true" />
+		<file source="\epoc32\tools\STAT\stat.lib" target="$INSTDIR\stat\bin" overwrite="true" />
+		<file source="\epoc32\tools\STAT\STAT2PERL.exe" target="$INSTDIR\stat\bin" overwrite="true" />
+		<file source="\epoc32\tools\STAT\STATDesktop.exe" target="$INSTDIR\stat\bin" overwrite="true" />
+		<file source="\EPOC32\tools\stat\symbianusb.dll" target="$INSTDIR\stat\bin" overwrite="true" />
+		<file source="\EPOC32\tools\stat\symbianusb.inf" target="$INSTDIR\stat\bin" overwrite="true" />
+		<file source="\EPOC32\tools\stat\symbianusb.sys" target="$INSTDIR\stat\bin" overwrite="true" />
+		<file source="\EPOC32\tools\stat\symbianusb98.sys" target="$INSTDIR\stat\bin" overwrite="true" />
+	</files>
+
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/lib/dummy.txt	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,1 @@
+For solving the lib issue
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/common/inc/ini.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#ifndef INI_H
+#define INI_H
+
+#include <afxcoll.h>
+
+class CStatIniFile  
+{
+public:
+	CStatIniFile();
+	~CStatIniFile();
+	void SetIniFileName(const CString& strName);
+	BOOL SectionExists(const CString& strSection) const;
+	BOOL DeleteSection(const CString& strSection) const;
+	BOOL WriteKey(const CString& strValue, const CString& strKey, const CString& strSection) const;
+	CString GetKeyValue(const CString& strKey, const CString& strSection) const;
+private:
+	CString istrIniFileName;
+};
+
+#endif // __INI.H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/common/src/ini.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,72 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#include <afxwin.h>
+
+#include "INI.h"
+#include <afxcoll.h>
+
+#ifdef _DEBUG
+#undef THIS_FILE
+static char THIS_FILE[]=__FILE__;
+#define new DEBUG_NEW
+#endif
+
+
+CStatIniFile::CStatIniFile()
+	{
+	}
+	
+CStatIniFile::~CStatIniFile()
+	{
+	}
+
+// return an empty string if section or key does not exist
+CString CStatIniFile::GetKeyValue(const CString& strKey,const CString& strSection) const
+{
+	TCHAR result[255];
+	GetPrivateProfileString((LPCTSTR)strSection,(LPCTSTR)strKey,_T(	""),result, 255, (LPCTSTR)istrIniFileName);	
+	CString strResult(result);
+	return strResult;
+}
+
+
+BOOL CStatIniFile::WriteKey(const CString& strValue, const CString& strKey, const CString& strSection) const
+{
+	return WritePrivateProfileString (strSection, strKey, strValue, istrIniFileName);
+
+}
+BOOL CStatIniFile::DeleteSection(const CString& strSection) const
+{
+	return WritePrivateProfileString(strSection,NULL,NULL,istrIniFileName);
+}
+
+BOOL CStatIniFile::SectionExists(const CString& strSection) const
+{
+	TCHAR result[255];	
+	long lRetValue = GetPrivateProfileString((LPCTSTR)strSection,NULL,_T(	""),result, 255, (LPCTSTR)istrIniFileName);
+	return (lRetValue > 0); //true if section exists
+}
+
+void CStatIniFile::SetIniFileName(const CString& strName)
+{
+	istrIniFileName = strName;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/common/transport/inc/cclientsocket.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef STATCLIENTSOCKET_H
+#define STATCLIENTSOCKET_H
+
+#include <afxsock.h>
+
+class CSTATSocket;
+
+class CClientSocket : public CSocket
+{
+	DECLARE_DYNAMIC(CClientSocket);
+
+	public:
+		CClientSocket(CSTATSocket* pSoc);
+		CSTATSocket* m_pSoc;
+
+	protected:
+		virtual void OnReceive(int nErrorCode);
+		virtual void OnAccept(int nErrorCode);
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/common/transport/inc/cstatmessagecom.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef CSTATMessageCOM_H
+#define CSTATMessageCOM_H
+
+#include <mpsdrc.h>
+#include <mpsdrc_i.c>
+#include <ECENG.H>
+#include "CSTATLogFile.h"
+
+class CSTATMessageCOM : public CCmdTarget
+{
+	DECLARE_DYNCREATE(CSTATMessageCOM)
+	
+	public :
+		CSTATMessageCOM();
+		virtual ~CSTATMessageCOM();
+		int Connect(CString& platformtype, CSTATLogFile *theLog);
+		bool Disconnect();
+		HRESULT SendMsg(BYTE id);
+		HRESULT SendMsg(BYTE id, VARIANT data);
+
+		//pointers to interfaces - need to be public so that CommandDecoderCOM can access and send the messages
+		LPECENGINES m_pIECEngineS;
+		LPECMACHINE m_pIECMachine;
+		LPECDRIVE m_pIECDrive;
+		EDFILEREQ From;
+		EDFILEREQ To;
+		EDDRIVEREQ Drive;
+		
+		bool Connected;
+
+	private :	
+		DECLARE_INTERFACE_MAP()
+			BEGIN_INTERFACE_PART(CommonSink, ICommonSink)
+				STDMETHOD(ProcessResponse)(BYTE* Response, DWORD bufsize);
+			END_INTERFACE_PART(CommonSink)
+		DECLARE_MESSAGE_MAP()
+
+		//non-interface part, called from interface
+		STDMETHOD(ProcessResponse)(BYTE* Response, DWORD bufsize);
+
+		void CopyResponseData(BYTE* pResponse, DWORD bufsize);
+
+		//used for processing device response data
+		BYTE* m_pResponseData;
+
+		// COM interfaces for EPOC Connect
+		ISendRequest* m_pISendReq;
+		ICommonSink* m_pICommonSink;		
+
+		CSTATLogFile *pLog;
+		bool bExternalInterface;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/common/transport/inc/statsocket.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#ifndef STATSOCKET_H
+#define STATSOCKET_H
+
+#include "statcommon.h"
+#include "stattransport.h"
+#include "CClientSocket.h"
+
+class CSTATSocket : public CSTATTransport
+{
+public:
+	CSTATSocket();
+	~CSTATSocket();
+	int Initialise(void);
+	int Connect(const char *pAddress = NULL);
+	int Send(const char cIdentifier, const char *pCommand = NULL, const unsigned long ulLength = 0);
+	int Receive(char *cIdentifier, char **ppData = NULL, unsigned long *pLength = NULL);
+	int Disconnect(void);
+	int Release(void);
+
+	int Listen(const char *pPort);
+	int ReceiveData();
+
+private:
+
+	CClientSocket* m_pSocket;
+	CClientSocket* m_pListen;
+	CSocketFile* m_pFile;
+	CArchive* m_pArchiveIn;
+	CArchive* m_pArchiveOut;
+
+	char ID;
+	char *pData;
+	unsigned long Length;
+	bool IsRecvData;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/common/transport/src/cclientsocket.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include "stdafx.h"
+
+#include "CClientSocket.h"
+#include "statsocket.h"
+
+#include <stddef.h>
+
+#ifdef _DEBUG
+#undef THIS_FILE
+static char BASED_CODE THIS_FILE[] = __FILE__;
+#endif
+
+IMPLEMENT_DYNAMIC(CClientSocket, CSocket)
+
+CClientSocket::CClientSocket(CSTATSocket* pSoc)
+{
+	m_pSoc = pSoc;
+}
+
+// callback function when data is waiting
+void CClientSocket::OnReceive(int nErrorCode)
+{
+	CSocket::OnReceive(nErrorCode);
+
+	while (!m_pSoc->ReceiveData())
+		Sleep(100);
+}
+
+// callback function when connection is waiting
+void CClientSocket::OnAccept(int nErrorCode)
+{
+	CSocket::OnAccept(nErrorCode);
+	m_pSoc->Connect(NULL);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/common/transport/src/cstatmessagecom.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,282 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include "CSTATMessageCOM.h"
+#include <initguid.h>
+#include "ECGUID.H"
+#include <statcommon.h>
+
+//-------------------------------------------------------------------------------
+//MESSAGE MAP
+
+BEGIN_MESSAGE_MAP(CSTATMessageCOM, CCmdTarget)
+	//{{AFX_MSG_MAP(CSTATMessageCOM)
+	//}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+//-------------------------------------------------------------------------------
+IMPLEMENT_DYNCREATE(CSTATMessageCOM, CCmdTarget)
+
+
+//constructor
+CSTATMessageCOM::CSTATMessageCOM()
+: 	m_pISendReq(NULL), m_pICommonSink(NULL), m_pResponseData(NULL), m_pIECEngineS(NULL),
+	m_pIECMachine(NULL), m_pIECDrive(NULL), Connected(false), bExternalInterface(false)
+{}
+
+//----------------------------------------------------------------------------
+//destructor
+CSTATMessageCOM::~CSTATMessageCOM()
+{
+	Disconnect();
+}
+
+//-------------------------------------------------------------------------------
+
+BEGIN_INTERFACE_MAP(CSTATMessageCOM, CCmdTarget)
+	INTERFACE_PART(CSTATMessageCOM, IID_ICommonSink, CommonSink)
+END_INTERFACE_MAP()
+
+//-------------------------------------------------------------------------------
+// IUnknown Interface 
+
+//memory management functions
+STDMETHODIMP_(ULONG) CSTATMessageCOM::XCommonSink::AddRef()
+{
+	METHOD_PROLOGUE(CSTATMessageCOM, CommonSink)
+	ASSERT(pThis);
+ 
+	TRACE(_T("Info::AddRef %d\n") ,pThis -> m_dwRef);
+	return pThis -> ExternalAddRef(); 
+}
+
+STDMETHODIMP_(ULONG) CSTATMessageCOM::XCommonSink::Release()
+{
+	METHOD_PROLOGUE(CSTATMessageCOM, CommonSink)
+	ASSERT(pThis);
+
+	TRACE(_T("Info::Release %d\n"),pThis -> m_dwRef);
+	return pThis -> ExternalRelease();
+}
+
+STDMETHODIMP CSTATMessageCOM::XCommonSink::QueryInterface(REFIID riid, void** ppv)
+{
+	METHOD_PROLOGUE(CSTATMessageCOM, CommonSink);
+	TRACE(_T("CSTATMessageCOM::XPWBKInfoQueryInterface\n"));
+
+	return pThis -> ExternalQueryInterface(&riid, ppv);
+}
+//-------------------------------------------------------------------------------
+// ICommonSink Interface
+STDMETHODIMP CSTATMessageCOM::XCommonSink::ProcessResponse(BYTE* Response, DWORD bufsize)
+{
+	METHOD_PROLOGUE(CSTATMessageCOM, CommonSink);
+	ASSERT(pThis);
+
+	pThis -> ProcessResponse(Response, bufsize);
+
+	return S_OK;
+}
+//----------------------------------------------------------------------------
+//Connection
+int CSTATMessageCOM::Connect(CString& platformtype, CSTATLogFile *theLog)
+{
+	pLog = theLog;
+
+	// convert to uppercase
+	platformtype.MakeUpper();
+
+	//select DLL to be initialised
+	CString STATServer;
+	if(platformtype == _T("ARM") || platformtype == _T("ARM4"))
+		STATServer = _T("STATApiARM4.DLL");
+	else if(platformtype == _T("WINS"))
+		STATServer = _T("STATApiWINS.DLL");
+	else if(platformtype == _T("THUMB"))
+		STATServer = _T("STATApiTHUMB.DLL");
+	else if(platformtype == _T("WINSCW"))
+		STATServer = _T("STATApiWINSCW.DLL");
+	else
+		return E_BADPLATFORM;
+
+	// disconnect if already connected
+	Disconnect();
+
+	// create an instance of the EPOC Connect Engine
+	if (FAILED(CoCreateInstance(CLSID_ECEngineS, NULL, CLSCTX_INPROC_SERVER, IID_IECEngineS, (void **)&m_pIECEngineS))) 
+	{
+		Disconnect();
+		return E_ENGINEOBJECTFAILURE;
+	}
+		
+	// get ISendReq interface
+	if (FAILED(ExternalQueryInterface(&IID_ICommonSink, (void**)&m_pICommonSink)))
+	{
+		Disconnect();
+		return E_BADREQUESTINTERFACE;
+	}
+	
+	IFileSystemInfoS *pFSInfo;
+	LPVOID *ppFSInfo = (LPVOID *)&pFSInfo;
+
+	// get an interface pointer to the FileSystemInfo struct
+	if (!bExternalInterface)
+	{
+		ExternalQueryInterface(&IID_IFileSystemInfoS, ppFSInfo);
+		bExternalInterface = true;
+	}
+
+	// initialise the EPOC Connect engine
+	m_pIECEngineS -> Init(pFSInfo);
+	if (m_pIECEngineS->Connect(15000) != S_OK) // connect, giving 15 seconds as maximum wait
+	{
+		Disconnect();
+		return E_ENGINECONNECTFAILURE;
+	}
+
+	// create an instance of the EPOC send request
+	if (FAILED(CoCreateInstance(CLSID_SendRequest, NULL, CLSCTX_INPROC_SERVER, IID_ISendRequest, (void**) &m_pISendReq)))
+	{
+		Disconnect();
+		return E_REQUESTOBJECTFAILURE;
+	}
+
+	BSTR bSTATstrServer = STATServer.AllocSysString();	//converts from CString to BSTR
+
+	//The 'Initialise' function starts up the generic custom server, copying it to the remote 
+	//EPOC machine if it is not there. It then checks that the application-specific server DLL 
+	//is loaded and up to date and, if not, copies it over to C:/system/libs. Finally, it 
+	//checks that the generic custom server found the interface.
+	if (FAILED(m_pISendReq -> Initialise(bSTATstrServer)))
+	{
+		Disconnect();
+		SysFreeString(bSTATstrServer);
+		return E_REQUESTINITFAILURE;
+	}
+
+	SysFreeString(bSTATstrServer);
+	Connected = true;	//flagged
+	return ITS_OK;
+}
+
+//-------------------------------------------------------------------------------
+//Disconnection
+bool CSTATMessageCOM::Disconnect()
+{
+	Connected = false;	//flagged as disconnected
+
+	if (m_pIECEngineS)
+	{
+		m_pIECEngineS->Release();
+		m_pIECEngineS = NULL;
+	}
+
+	// make sure tell EPOC side to close
+	if (m_pISendReq)
+	{
+		m_pISendReq->Release();
+		m_pISendReq = NULL;
+	}
+
+	if (bExternalInterface)
+	{
+		ExternalRelease();
+		bExternalInterface = false;
+	}
+
+	if(m_pResponseData)
+	{
+		delete[] m_pResponseData;
+		m_pResponseData = NULL;
+	}
+	
+	return true;
+}
+
+//-------------------------------------------------------------------------------
+//Send Message to device - no data
+HRESULT CSTATMessageCOM::SendMsg(BYTE id)
+{
+	HRESULT hr = S_OK;
+
+	for (int i=0;i<STAT_MAXRETRIES;i++)
+	{
+		if (SUCCEEDED(hr = m_pISendReq -> BuildNewRequest(1, id)))	//BuildNewRequest needed for creating header of message
+			if (SUCCEEDED(hr = m_pISendReq -> SendRequest(m_pICommonSink)))
+				return hr;
+
+		pLog->Set(E_COMMANDRETRY);
+		Sleep(STAT_RETRYDELAY);
+	}
+
+	pLog->Set(E_COMMANDFAILED);
+	return hr;
+}
+
+//-------------------------------------------------------------------------------
+//send message with data
+HRESULT CSTATMessageCOM::SendMsg(BYTE id, VARIANT data)
+{
+	HRESULT hr = S_OK;
+	
+	for (int i=0;i<STAT_MAXRETRIES;i++)
+	{
+		//will send data that has already been created in calling function
+		if (SUCCEEDED(hr = m_pISendReq -> BuildNewRequest(1, id)))
+			if (SUCCEEDED(hr = m_pISendReq -> AddBody(data)))		//adds body to the header (newly converted data)
+		{
+			if (SUCCEEDED(hr = m_pISendReq -> SendRequest(m_pICommonSink)))
+				return hr;
+		}
+
+		pLog->Set(E_COMMANDRETRY);
+		Sleep(STAT_RETRYDELAY);
+	}
+
+	pLog->Set(E_COMMANDFAILED);
+	return hr;
+}
+
+//-------------------------------------------------------------------------------
+// Retrieves a response from EPOC device
+STDMETHODIMP CSTATMessageCOM::ProcessResponse(BYTE* pResponse, DWORD bufsize)
+{
+	CopyResponseData(pResponse + 11, bufsize - 11);	//function called, removing the first 11 bytes (header info)
+	return S_OK;
+}
+
+//-------------------------------------------------------------------------------
+//function used to store newly formatted data into new variable
+void CSTATMessageCOM::CopyResponseData(BYTE* pResponse, DWORD bufsize)
+{
+	if(m_pResponseData)
+	{
+		delete[] m_pResponseData;
+		m_pResponseData = NULL;
+	}
+	
+	if(bufsize)
+	{
+		m_pResponseData = new BYTE[bufsize];
+		memcpy(m_pResponseData, pResponse, bufsize);
+	}
+}
+
+//-----------------------------------------------------------------------------
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/common/transport/src/statsocket.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,280 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include "stdafx.h"
+#include "statsocket.h"
+
+////////////////////////////////////////////////////////////////////////////////////////
+// 
+CSTATSocket::CSTATSocket()
+: m_pSocket((CClientSocket*)NULL),
+  m_pFile((CSocketFile*)NULL),
+  m_pArchiveIn((CArchive*)NULL),
+  m_pArchiveOut((CArchive*)NULL),
+  m_pListen((CClientSocket*)NULL),
+  IsRecvData(false),
+  ID(0), Length(0), pData(NULL)
+{
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// 
+CSTATSocket::~CSTATSocket()
+{
+	Disconnect();
+	Release();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// 
+int CSTATSocket::Initialise(void)
+{
+	return ITS_OK;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// 
+int CSTATSocket::Connect(const char *pAddress)
+{
+	m_pSocket = new CClientSocket(this);
+
+	if (m_pSocket)
+	{
+		// if address supplied then we are attempting a connection
+		// else we are listening for a connection
+		if (pAddress && (*pAddress))
+		{
+			if (!m_pSocket->Create())
+			{
+				Disconnect();
+				return GENERAL_FAILURE;
+			}
+
+			char *p = strrchr(pAddress, ':');
+			int iPort = 700;
+			if (p)
+			{
+				(*p) = (char)0;
+
+				p++;
+				if (p && *p)
+					iPort = atoi(p);
+			}
+			int iRetry = 0;
+			while (!m_pSocket->Connect(pAddress, iPort))
+			{
+				iRetry++;
+				if (iRetry > 5)
+				{
+					Disconnect();
+					return E_TOOMANYERRORS;
+				}
+
+				Sleep(250);
+			}
+		}
+		else
+		{
+			if (!m_pListen->Accept(*m_pSocket))
+			{
+				Disconnect();
+				return E_CONNECTIONFAILED;
+			}
+
+			// don't need this object anymore
+			BYTE Buffer[50];
+			m_pListen->ShutDown();
+
+			while(m_pListen->Receive(Buffer,50) > 0);
+
+			delete m_pListen;
+			m_pListen = NULL;
+		}
+
+		m_pFile = new CSocketFile(m_pSocket);
+		m_pArchiveIn = new CArchive(m_pFile,CArchive::load);
+		m_pArchiveOut = new CArchive(m_pFile,CArchive::store);
+
+		// send acknowledgement message
+		Send('A', "Connected", 9);
+	}
+	else
+		return E_OUTOFMEM;
+
+	return ITS_OK;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// 
+int CSTATSocket::Listen(const char *pPort)
+{
+	m_pListen = new CClientSocket(this);
+
+	if (m_pListen)
+	{
+		if (!m_pListen->Create(atoi(pPort)))
+			return E_CONNECTIONFAILED;
+
+		if (!m_pListen->Listen())
+			return E_CONNECTIONFAILED;
+	}
+	else
+		return E_OUTOFMEM;
+
+	return ITS_OK;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// 
+int CSTATSocket::Send(const char cIdentifier, const char *pData, const unsigned long ulLength)
+{
+	if (m_pArchiveOut != NULL)
+	{
+		TRY
+		{
+			(*m_pArchiveOut) << cIdentifier;
+			(*m_pArchiveOut) << ulLength;
+
+			if (ulLength)
+				m_pArchiveOut->Write(pData, ulLength);
+
+			m_pArchiveOut->Flush();
+		}
+		CATCH(CFileException, e)
+		{
+			Disconnect();
+			return E_WRITEFAILED;
+		}
+		END_CATCH
+	}
+
+	return ITS_OK;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// External: passed received data back to calling function
+int CSTATSocket::Receive(char *cIdentifier, char **ppData, unsigned long *pLength)
+{
+	int ret = NO_DATA_AT_PORT;
+
+	if (IsRecvData)
+	{
+		(*cIdentifier) = ID;
+		(*pLength) = Length;
+		(*ppData) = pData;
+
+		IsRecvData = false;
+		ret = ITS_OK;
+	}
+
+	return ret;
+}
+	
+	
+////////////////////////////////////////////////////////////////////////////////////////
+// Internal: Receives data from the socket
+int CSTATSocket::ReceiveData()
+{
+	if (!IsRecvData)
+	{
+		unsigned long ActualRead = 0;
+
+		(*m_pArchiveIn) >> ID;
+		(*m_pArchiveIn) >> Length;
+
+		if(pData)
+		{
+			delete [] pData;
+		}
+
+		if (Length)
+		{
+			pData = new char [Length + 1];
+			if (pData)
+			{
+				ActualRead = m_pArchiveIn->Read(pData, Length);
+				*(pData + Length) = (char)0;
+			}
+			else
+				Length = 0;
+		}
+
+		IsRecvData = true;
+		return true;
+	}
+
+	return false;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// 
+int CSTATSocket::Disconnect(void)
+{
+	if (m_pArchiveOut)
+	{
+		delete m_pArchiveOut;
+		m_pArchiveOut = NULL;
+	}
+
+	if (m_pArchiveIn)
+	{
+		delete m_pArchiveIn;
+		m_pArchiveIn = NULL;
+	}
+
+	if (m_pFile)
+	{
+		delete m_pFile;
+		m_pFile = NULL;
+	}
+
+	if (m_pSocket)
+	{
+		BYTE Buffer[50];
+		m_pSocket->ShutDown();
+
+		while(m_pSocket->Receive(Buffer,50) > 0);
+
+		delete m_pSocket;
+		m_pSocket = NULL;
+	}
+
+	return ITS_OK;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// 
+int CSTATSocket::Release(void)
+{
+	return ITS_OK;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+//	PRIVATE FUNCTIONS
+////////////////////////////////////////////////////////////////////////////////////////
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/desktop/group/bld.inf	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,41 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:  
+//
+
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+
+* which accompanies this distribution, and is available
+
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+PRJ_PLATFORMS
+
+TOOLS
+
+PRJ_MMPFILES
+// Extension Makefile
+makefile statdesktop.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/desktop/group/statdesktop.mk	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,83 @@
+#
+# Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:  
+#
+
+# which accompanies this distribution, and is available
+
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+# Typically C:\apps\MSVC6\VC98\Bin
+COMPILER=nmake
+
+# Called with
+#
+# $(PLATFORM) = TOOLS
+# $(CFG)      = DEB, REL
+
+BLD	:  
+	@echo BLD called with $(PLATFORM)$(CFG)
+	
+# release version
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "REL"
+	-mkdir "$(EPOCROOT)epoc32\tools\STAT"
+
+# Go up one level to access the makefile
+	cd ".."
+
+# Execute the command line compiler (Desktop)
+	"$(COMPILER)" /A /NOLOGO /f "STATDesktop.mak" CFG="STATDesktop - Win32 Release"
+	
+	echo ** STAT Desktop (RELEASE) compiled successfully
+
+!endif
+
+# debug version
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "DEB"
+
+# Go up one level to access the makefile
+	cd ".."
+
+# Execute the command line compiler (Desktop)
+	"$(COMPILER)" /A /NOLOGO /f "STATDesktop.mak" CFG="STATDesktop - Win32 Debug"
+	
+	echo ** STAT Desktop (DEBUG) compiled successfully
+
+!endif
+
+CLEAN :
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "REL"
+	-rmdir "..\Release" /q /s
+!endif
+
+CLEAN :
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "DEB"
+	-rmdir "..\Debug" /q /s
+!endif
+
+RELEASABLES :
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "REL"
+	@echo $(EPOCROOT)epoc32\tools\STAT\STATDesktop.exe
+!endif
+
+SAVESPACE : BLD
+
+MAKMAKE LIB CLEANLIB RESOURCE FREEZE FINAL : 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/desktop/inc/logmessage.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#if ! defined (LOGMESSAGE_H_F2E497DD_F98B_43c1_826E_AF7D49D40161)
+#define LOGMESSAGE_H_F2E497DD_F98B_43c1_826E_AF7D49D40161
+
+/////////////////////////////////////////////////////////////////////////////
+// LogMessage
+// Passed from the logging object to a window through the use of a window
+// message.  This will be the lParam data object.  The message will be 
+// passed asynchronously and the structure will be allocated on the heap
+// by the sender (probably the log file object).  The receiving window must
+// delete this object when it processes the message.
+/////////////////////////////////////////////////////////////////////////////
+
+class LogMessage
+{
+public:
+	LogMessage( void );
+	~LogMessage();
+
+public:
+
+	const LogMessage& operator = ( const LogMessage& logMessage );
+
+	bool iMessageBox;
+	bool iScreenShot;
+
+	CString iMessage;
+	CString iText;
+};
+
+inline LogMessage::LogMessage( void ) :
+	iMessageBox( false ),
+	iScreenShot( false )
+{
+	;
+}
+
+inline LogMessage::~LogMessage()
+{
+	iMessage.Empty( );
+	iText.Empty( );
+}
+
+inline const LogMessage& LogMessage::operator = ( const LogMessage& logMessage )
+{
+	iMessage =	logMessage.iMessage.operator LPCTSTR( );
+	iText =	logMessage.iText.operator LPCTSTR( );
+
+	iMessageBox =	logMessage.iMessageBox;
+	iScreenShot =	logMessage.iScreenShot;
+
+	return (*this);
+}
+
+#endif // ! defined (LOGMESSAGE_H_F2E497DD_F98B_43c1_826E_AF7D49D40161)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/desktop/inc/messagereporterimp.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,104 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#if ! defined (MESSAGEREPORTER_H_118AA138_CDA6_46e1_9805_F9367915D3F7)
+#define MESSAGEREPORTER_H_118AA138_CDA6_46e1_9805_F9367915D3F7
+
+#pragma warning ( disable : 4100 4245 )
+
+#include <Statexp.h>
+#include "LogMessage.h"
+#include "WindowMessages.h"
+#include <list>
+
+/////////////////////////////////////////////////////////////////////////////
+// MessageReporterImp
+// Concrete implementation of the class MessageReporter.
+// This class knows about the dialog window and uses Windows messages
+// to call the dialog call-back update methods.
+// Even though this class knows of the dialog class it is not wise to
+// call methods in the MFC Window class directly as we may (probably are)
+// in a different thread and calling MFC methods across treads is a bad
+// thing to do.
+/////////////////////////////////////////////////////////////////////////////
+
+class MessageReporterImp : public MessageReporter
+{
+public:
+	MessageReporterImp(HWND hWnd);
+	~MessageReporterImp();
+
+protected:
+	HWND m_hWnd;
+
+	std::list<LogMessage*>	logMessages;
+
+public:
+	virtual void OnMessage( const char* message, const char* newtext,
+										bool bMsgBox, bool bScrshot );
+};
+
+// These will not be implemented in-line as we are using virtual
+// meothds but putting them here saves the use of a seperate
+// source file.
+
+inline MessageReporterImp::MessageReporterImp( HWND hWnd )
+	: m_hWnd(hWnd)
+{
+	;
+}
+
+inline MessageReporterImp::~MessageReporterImp()
+{
+	std::list<LogMessage*>::iterator	it;
+	LogMessage	*logMessage =	NULL;
+	for( it = logMessages.begin(); it != logMessages.end(); it++ )
+	{
+		logMessage = *it;
+		logMessage->iMessage.Empty();
+		logMessage->iText.Empty();
+		delete logMessage;
+	}
+	logMessages.clear();
+}
+
+inline void MessageReporterImp::OnMessage( const char* message, const char* text,
+										bool bMsgBox, bool bScrshot )
+{
+	LogMessage *logMessage = new LogMessage;
+
+	logMessage->iMessageBox = bMsgBox;
+	logMessage->iScreenShot = bScrshot;
+	logMessage->iMessage = message;
+	logMessage->iText = text;
+
+	::PostMessage(	m_hWnd,
+					WM_SHOW_LOG_MESSAGE,
+					0,
+					reinterpret_cast<LPARAM>(logMessage)
+					);
+
+	logMessages.push_back(logMessage);
+}
+
+#pragma warning ( default : 4100 4245 )
+
+#endif // ! defined (MESSAGEREPORTER_H_118AA138_CDA6_46e1_9805_F9367915D3F7)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/desktop/inc/resource.h	Mon Oct 04 02:58:21 2010 +0300
@@ -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: 
+*
+*/
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by M:\D\P4work\DP\development\project\2008\preq2582\sf\ana\testexec\testtoolsconn\stat\Desktop\source\desktop\src\STATDesktop.rc
+//
+#define IDM_ABOUTBOX                    0x0010
+#define IDD_ABOUTBOX                    100
+#define IDS_ABOUTBOX                    101
+#define IDD_STATDESKTOP_DIALOG          102
+#define IDS_USBPORTPROMPT               102
+#define IDS_PORTPROMPT                  102
+#define IDS_SYMBIAN                     103
+#define IDS_APPNAME                     104
+#define IDR_MAINFRAME                   128
+#define IDR_SYMBIANICON                 128
+#define IDD_SOURCESELECT                130
+#define IDD_MANAGECONNECTION            132
+#define IDC_SCRIPT                      1001
+#define IDC_BROWSE                      1002
+#define IDC_OUTPUT                      1003
+#define IDC_SCONNECT                    1004
+#define IDC_TCPIP                       1005
+#define IDC_CONNECTBORDER               1006
+#define IDC_ARM                         1007
+#define IDC_WINS                        1008
+#define IDC_THUMB                       1009
+#define IDC_PLATBORDER                  1010
+#define IDC_SPEEDBORDER                 1014
+#define IDEXIT                          1016
+#define IDRUN                           1017
+#define IDEDITSCRIPT                    1018
+#define IDC_IMAGEBOX                    1019
+#define IDC_SCREENSHOT                  1020
+#define IDC_IMAGEVERIFY                 1021
+#define IDC_IMAGEVERIFYBORDER           1022
+#define IDSTOP                          1023
+#define IDC_COPYRIGHT                   1024
+#define IDC_SPEEDSLIDER                 1025
+#define IDC_MAXSPEEDTXT                 1026
+#define IDC_MINSPEEDTXT                 1027
+#define IDC_LOCATIONEDITBOX             1027
+#define IDC_RANGEOFERROR                1028
+#define IDC_LOCATIONBROWSEBUTTON        1029
+#define IDC_RADIOLEV1                   1033
+#define IDC_RADIOLEV2                   1034
+#define IDC_RADIOLEV3                   1035
+#define IDC_EDITLOGNAME                 1036
+#define IDC_WINSCW                      1037
+#define IDC_STATICLOGLEVEL              1038
+#define IDC_STATICLOGNAME               1039
+#define IDC_DIFFLOGNAME                 1040
+#define IDC_TIMEDELAY                   1041
+#define IDC_RADIO1                      1044
+#define IDC_HEADER                      1045
+#define IDC_INFO                        1046
+#define IDC_ABOUTHEADING                1047
+#define IDC_CONNECTION                  1048
+#define IDC_PLATFORM                    1049
+#define IDC_LOCATION                    1050
+#define IDC_BROWSEIMAGE                 1051
+#define IDC_PERCENTAGE                  1052
+#define IDC_ADDRESS                     1053
+#define IDC_APPEND                      1054
+#define IDC_BROWSELOG                   1055
+#define IDC_PERCENTAGEDIFF              1059
+#define IDC_PROGRESS                    1060
+#define IDC_VIEW                        1061
+#define IDC_MANAGE                      1062
+#define IDC_REMOVE                      1063
+#define IDC_ADD                         1065
+#define IDC_LISTCONNECTIONS             1066
+#define IDC_TRANSPORT                   1067
+
+// Next default values for new objects
+// 
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE        134
+#define _APS_NEXT_COMMAND_VALUE         32771
+#define _APS_NEXT_CONTROL_VALUE         1071
+#define _APS_NEXT_SYMED_VALUE           101
+#endif
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/desktop/inc/scriptprogressmonitorimp.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,82 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#if ! defined (SCRIPTPROGRESSMONITORIMP_H_045CF869_6A0F_4447_B5CF_393C4C419BDE)
+#define SCRIPTPROGRESSMONITORIMP_H_045CF869_6A0F_4447_B5CF_393C4C419BDE
+
+#include <Statexp.h>
+
+/////////////////////////////////////////////////////////////////////////////
+// ScriptProgressMonitorImp
+// Concrete implementation of the class ScriptProgressMonitor.
+// This class knows about the dialog window and uses Windows messages
+// to call the dialog call-back update methods.
+// Even though this class knows of the dialog class it is not wise to
+// call methods in the MFC Window class directly as we may (probably are)
+// in a different thread and calling MFC methods across treads is a bad
+// thing to do.
+/////////////////////////////////////////////////////////////////////////////
+
+class ScriptProgressMonitorImp : public ScriptProgressMonitor
+{
+public:
+	ScriptProgressMonitorImp(HWND hWnd);
+	~ScriptProgressMonitorImp();
+
+protected:
+	HWND m_hWnd;
+
+public:
+	// Override in a derived class to call-back when a single
+	// command of the current script is processed.
+	virtual void OnCompleteCommand( int command );
+
+	// Override in a derived class to call-back when the
+	// whole of current script is processed.
+	virtual void OnCompleteScript( int scriptExitCode );
+};
+
+// These will not be implemented in-line as we are using virtual
+// meothds but putting them here saves the use of a seperate
+// source file.
+
+inline ScriptProgressMonitorImp::ScriptProgressMonitorImp( HWND hWnd )
+	: m_hWnd(hWnd)
+{
+	;
+}
+
+inline ScriptProgressMonitorImp::~ScriptProgressMonitorImp()
+{
+	;
+}
+
+inline void ScriptProgressMonitorImp::OnCompleteCommand( int command )
+{
+	::PostMessage( m_hWnd, WM_DONE_COMMAND, command, 0 );
+}
+
+inline void ScriptProgressMonitorImp::OnCompleteScript( int scriptExitCode )
+{
+	::PostMessage( m_hWnd, WM_DONE_SCRIPT, scriptExitCode, 0 );
+}
+
+#endif // ! defined (SCRIPTPROGRESSMONITORIMP_H_045CF869_6A0F_4447_B5CF_393C4C419BDE)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/desktop/inc/statdesktop.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#if !defined(AFX_STATDESKTOP_H__3BAC3E07_6B00_11D5_B4C5_00C04F437BB4__INCLUDED_)
+#define AFX_STATDESKTOP_H__3BAC3E07_6B00_11D5_B4C5_00C04F437BB4__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#ifndef __AFXWIN_H__
+	#error include 'stdafx.h' before including this file for PCH
+#endif
+
+#include "resource.h"			// main symbols
+
+/////////////////////////////////////////////////////////////////////////////
+// CSTATDesktopApp:
+// See STATDesktop.cpp for the implementation of this class
+//
+
+class CSTATDesktopApp : public CWinApp
+{
+public:
+
+// Overrides
+	// ClassWizard generated virtual function overrides
+	//{{AFX_VIRTUAL(CSTATDesktopApp)
+	public:
+	virtual BOOL InitInstance();
+	//}}AFX_VIRTUAL
+
+// Implementation
+
+	//{{AFX_MSG(CSTATDesktopApp)
+	//}}AFX_MSG
+	DECLARE_MESSAGE_MAP()
+};
+
+
+/////////////////////////////////////////////////////////////////////////////
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STATDESKTOP_H__3BAC3E07_6B00_11D5_B4C5_00C04F437BB4__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/desktop/inc/statdesktopdlg.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,159 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#if !defined(AFX_STATDESKTOPDLG_H__3BAC3E09_6B00_11D5_B4C5_00C04F437BB4__INCLUDED_)
+#define AFX_STATDESKTOPDLG_H__3BAC3E09_6B00_11D5_B4C5_00C04F437BB4__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include <STATExp.h>
+
+#include "ini.h"
+
+#include "MessageReporterImp.h"
+
+/////////////////////////////////////////////////////////////////////////////
+// CSTATDesktopDlg dialog
+
+class CSTATDesktopDlg : public CDialog
+{
+// Construction
+public:
+	CSTATDesktopDlg(CWnd* pParent = NULL);	// standard constructor
+
+// Dialog Data
+	//{{AFX_DATA(CSTATDesktopDlg)
+	enum { IDD = IDD_STATDESKTOP_DIALOG };
+	CEdit	m_Connection;
+	CButton	m_ViewLog;
+	CProgressCtrl	m_Progress;
+	CButton	m_BrowseLog;
+	CButton	m_Append;
+	CButton	m_BrowseImage;
+	CEdit	m_Delay;
+	CListBox	m_Output;
+	CButton	m_VerifyImage;
+	CEdit	m_LogFileName;
+	CButton	m_LogToFile;
+	CEdit	m_ImageBox;
+	CEdit	m_Script;
+	CEdit	m_ImageLocation;
+	CSliderCtrl	m_SliderPos;
+	CSliderCtrl	m_PercentageDiff;
+	//}}AFX_DATA
+
+	// ClassWizard generated virtual function overrides
+	//{{AFX_VIRTUAL(CSTATDesktopDlg)
+	protected:
+	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
+	//}}AFX_VIRTUAL
+
+// Implementation
+protected:
+	HICON m_hIcon;
+
+	// Generated message map functions
+	//{{AFX_MSG(CSTATDesktopDlg)
+	virtual BOOL OnInitDialog();
+	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
+	afx_msg void OnPaint();
+	afx_msg HCURSOR OnQueryDragIcon();
+	afx_msg void OnBrowse();
+	afx_msg void OnEditscript();
+	afx_msg void OnExit();
+	afx_msg void OnRun();
+	afx_msg void OnLogToFile();
+	afx_msg void OnReleasedcaptureSpeedslider(NMHDR* pNMHDR, LRESULT* pResult);
+	afx_msg void OnChangeTimedelay();
+	afx_msg void OnBrowseimage();
+	virtual void OnCancel();
+	afx_msg void OnImageverify();
+	afx_msg void OnBrowseLog();
+	afx_msg void OnView();
+	afx_msg void OnManage();
+	afx_msg void OnDestroy();
+	afx_msg LRESULT OnDoneCommand(WPARAM command, LPARAM );
+	afx_msg LRESULT OnDoneScript(WPARAM iScriptExitCode, LPARAM );
+	afx_msg LRESULT OnLogMesage(WPARAM, LPARAM pLogMessage );
+	//}}AFX_MSG
+	DECLARE_MESSAGE_MAP()
+
+private:
+	void ReadSettings();
+	void SaveSettings();
+	bool CallProcess(LPCTSTR szApplication, LPTSTR szCommandLine, LPCTSTR szDirectory);
+	int SetImageVerification();
+	void Message(const char* message);
+	void MessageFormat(const char *message, ...);
+	void EnableFields(bool bEnable);
+	int ConnectToEngine();
+	bool ShowScreenshot(const CString& filename);				//displays last screenshot in window
+	void CleanUp(const CString& message, bool bEnableFields = true);
+	void CleanUp(LPCTSTR message, bool bEnableFields = true);
+	void OpenFile(LPTSTR file);
+	void RunIt();
+
+	//variables
+	HMODULE	ihLib;
+	int iHandle;
+	PROC_VERSION	iptrVersion;
+	PROC_GETERROR	iptrGetError;
+	PROC_GETERRORTEXT	iptrGetErrorText;
+	PROC_SETCONNECTIONLOGGING	iptrSetConnectionLogging;
+	PROC_CLOSECONNECTIONLOGGING	iptrCloseConnectionLogging;
+	PROC_CONNECT	iptrConnect;
+	PROC_DISCONNECT	iptrDisconnect;
+	PROC_SETCOMMANDDELAY	iptrSetCommandDelay;
+	PROC_SETCOMMANDLOGGING	iptrSetCommandLogging;
+	PROC_SETIMAGEVERIFICATION	iptrSetImageVerification;
+	PROC_OPENSCRIPTFILE	iptrOpenScriptFile;
+	PROC_RUNSCRIPT	iptrRunScript;
+	PROC_SENDRAWCOMMAND	iptrSendRawCommand;
+	PROC_SENDCOMMANDFILE	iptrSendCommandFile;
+	PROC_GETCOMMANDCOUNT	iptrGetCommandCount;
+	PROC_GETCURRENTCOMMANDNUMBER	iptrGetCurrentCommandNumber;
+	PROC_STOPPROCESSING	iptrStopProcessing;
+	PROC_GETSNAPSHOT	iptrGetSnapShot;
+
+	MessageReporterImp	*iMessageReporter;
+
+	CStatIniFile statIniFile;
+	TCHAR szBuffer[2048];		// global buffer for strings
+	HANDLE hThreadHandle;
+	int iLastVerify;			// stores the state of verify checkbox
+	int iLastLog;				// stores the state of log checkbox
+	bool bRunning;				// flag whether processing or not
+
+	/****BITMAP STUFF****/
+	CPalette m_Palette;
+	unsigned char *m_pDib, *m_pDibBits;
+	DWORD m_dwDibSize;
+	BITMAPINFOHEADER *m_pBIH;
+	RGBQUAD *m_pPalette;
+	int m_nPaletteEntries;
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STATDESKTOPDLG_H__3BAC3E09_6B00_11D5_B4C5_00C04F437BB4__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/desktop/inc/statmanageconnection.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,88 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#if !defined(AFX_STATMANAGECONNECTION_H__49661E91_DF72_11D6_BC83_00B0D065107F__INCLUDED_)
+#define AFX_STATMANAGECONNECTION_H__49661E91_DF72_11D6_BC83_00B0D065107F__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// STATManageConnection.h : header file
+//
+
+#include <STATExp.h>
+
+#include "ini.h"
+
+/////////////////////////////////////////////////////////////////////////////
+// STATManageConnection dialog
+
+class STATManageConnection : public CDialog
+{
+// Construction
+public:
+	STATManageConnection(CWnd* pParent = NULL);   // standard constructor
+
+// Dialog Data
+	//{{AFX_DATA(STATManageConnection)
+	enum { IDD = IDD_MANAGECONNECTION };
+	CEdit	m_Address;
+	CComboBox	m_Transport;
+	CListBox	m_ListConnections;
+	//}}AFX_DATA
+
+
+// Overrides
+	// ClassWizard generated virtual function overrides
+	//{{AFX_VIRTUAL(STATManageConnection)
+	protected:
+	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+	//}}AFX_VIRTUAL
+
+// Implementation
+protected:
+
+	// Generated message map functions
+	//{{AFX_MSG(STATManageConnection)
+	afx_msg void OnRemove();
+	virtual BOOL OnInitDialog();
+	virtual void OnOK();
+	afx_msg void OnAdd();
+	virtual void OnCancel();
+	afx_msg void OnSelchangeListconnections();
+	afx_msg void OnSelchangeTransport();
+	//}}AFX_MSG
+	DECLARE_MESSAGE_MAP()
+
+private:
+	bool InList(CString & Entry);
+	static LPTSTR ToUnicode(const char *string);					// convert ANSI to Unicode
+	static char * ToAnsi(LPCTSTR string);							// convert Unicode to ANSI
+
+	CStatIniFile statIniFile;
+	long lCount;
+};
+
+extern CString cConnectionInfo;
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STATMANAGECONNECTION_H__49661E91_DF72_11D6_BC83_00B0D065107F__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/desktop/inc/stdafx.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#if !defined(AFX_STDAFX_H__3BAC3E0B_6B00_11D5_B4C5_00C04F437BB4__INCLUDED_)
+#define AFX_STDAFX_H__3BAC3E0B_6B00_11D5_B4C5_00C04F437BB4__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define VC_EXTRALEAN		// Exclude rarely-used stuff from Windows headers
+
+#include <afxwin.h>         // MFC core and standard components
+#include <afxext.h>         // MFC extensions
+#include <afxdtctl.h>		// MFC support for Internet Explorer 4 Common Controls
+#include <assert.h>
+#ifndef _AFX_NO_AFXCMN_SUPPORT
+#include <afxcmn.h>			// MFC support for Windows Common Controls
+#endif // _AFX_NO_AFXCMN_SUPPORT
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__3BAC3E0B_6B00_11D5_B4C5_00C04F437BB4__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/desktop/inc/windowmessages.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#if ! defined (WINDOW_MESSAGES_H_0731AB35_7D26_459d_9A0E_1AFB32883064)
+#define WINDOW_MESSAGES_H_0731AB35_7D26_459d_9A0E_1AFB32883064
+
+/////////////////////////////////////////////////////////////////////////////
+// WM_DONE_COMMAND
+// Passed from the script progress monitor to the main UI window (this is
+// the desktop dialog) to indicate that a single command of the current
+// scipt has been processed.
+/////////////////////////////////////////////////////////////////////////////
+#define WM_DONE_COMMAND	(WM_USER + 0x0001)
+
+/////////////////////////////////////////////////////////////////////////////
+// WM_DONE_SCRIPT
+// Passed from the script progress monitor to the main UI window (this is
+// the desktop dialog) to indicate that the current  script has 
+// been processed.
+/////////////////////////////////////////////////////////////////////////////
+#define WM_DONE_SCRIPT	(WM_USER + 0x0002)
+
+/////////////////////////////////////////////////////////////////////////////
+// WM_SHOW_LOG_MESSAGE
+// Passed from the log file to the application main window.
+// There is a data structure passed in this message (as the lParam) and 
+// the receiving window must delete it.
+/////////////////////////////////////////////////////////////////////////////
+#define WM_SHOW_LOG_MESSAGE	(WM_USER + 0x0003)
+
+#endif // ! defined (WINDOW_MESSAGES_H_0731AB35_7D26_459d_9A0E_1AFB32883064)
Binary file testconns/statdesktop/desktop/source/desktop/res/statdesktop.ico has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/desktop/res/statdesktop.rc2	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,13 @@
+//
+// STATDESKTOP.RC2 - resources Microsoft Visual C++ does not edit directly
+//
+
+#ifdef APSTUDIO_INVOKED
+	#error this file is not editable by Microsoft Visual C++
+#endif //APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Add manually edited resources here...
+
+/////////////////////////////////////////////////////////////////////////////
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/desktop/src/statdesktop.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,54 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#include "stdafx.h"
+#include "STATDesktop.h"
+#include "STATDesktopDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CSTATDesktopApp
+
+BEGIN_MESSAGE_MAP(CSTATDesktopApp, CWinApp)
+	//{{AFX_MSG_MAP(CSTATDesktopApp)
+	//}}AFX_MSG
+	ON_COMMAND(ID_HELP, CWinApp::OnHelp)
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// The one and only CSTATDesktopApp object
+
+CSTATDesktopApp theApp;
+
+/////////////////////////////////////////////////////////////////////////////
+// CSTATDesktopApp initialization
+
+BOOL CSTATDesktopApp::InitInstance()
+{
+	CSTATDesktopDlg dlg;
+	dlg.DoModal();
+	return FALSE;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/desktop/src/statdesktop.rc	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,374 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "../inc/resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.K.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_ABOUTBOX DIALOG DISCARDABLE  0, 0, 257, 74
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "About STAT Desktop"
+FONT 8, "MS Sans Serif"
+BEGIN
+    LTEXT           "Copyright (C) 2005-2009 Nokia Corporation",
+                    IDC_COPYRIGHT,86,19,155,8
+    DEFPUSHBUTTON   "OK",IDOK,103,53,50,14,WS_GROUP
+    ICON            IDR_SYMBIANICON,IDC_STATIC,19,7,20,20
+    EDITTEXT        IDC_ABOUTHEADING,85,7,111,12,ES_AUTOHSCROLL | 
+                    ES_READONLY | NOT WS_BORDER
+END
+
+IDD_STATDESKTOP_DIALOG DIALOGEX 0, 0, 402, 327
+STYLE DS_MODALFRAME | DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | 
+    WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_ACCEPTFILES | WS_EX_APPWINDOW
+CAPTION "Nokia Test Automation Tool"
+FONT 8, "MS Sans Serif", 0, 0, 0x1
+BEGIN
+    EDITTEXT        IDC_SCRIPT,14,18,236,14,ES_AUTOHSCROLL
+    PUSHBUTTON      "&Edit...",IDEDITSCRIPT,258,18,61,14
+    PUSHBUTTON      "&Browse...",IDC_BROWSE,329,18,56,14
+    CONTROL         "Slider1",IDC_SPEEDSLIDER,"msctls_trackbar32",TBS_VERT | 
+                    TBS_BOTH | TBS_ENABLESELRANGE | WS_TABSTOP,24,104,26,63
+    EDITTEXT        IDC_TIMEDELAY,54,129,40,14,ES_AUTOHSCROLL | NOT 
+                    WS_TABSTOP,WS_EX_DLGMODALFRAME
+    CONTROL         "",IDC_IMAGEVERIFY,"Button",BS_AUTOCHECKBOX | WS_GROUP | 
+                    WS_TABSTOP,14,191,12,8
+    CONTROL         "Slider2",IDC_PERCENTAGEDIFF,"msctls_trackbar32",
+                    TBS_BOTH | TBS_NOTICKS | TBS_ENABLESELRANGE,50,187,71,22
+    PUSHBUTTON      "Brow&se...",IDC_BROWSEIMAGE,186,189,56,14
+    EDITTEXT        IDC_LOCATION,54,209,188,14,ES_AUTOHSCROLL
+    CONTROL         "",IDC_DIFFLOGNAME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
+                    14,246,11,13
+    CONTROL         "Append",IDC_APPEND,"Button",BS_AUTOCHECKBOX | 
+                    WS_TABSTOP,54,246,41,13
+    PUSHBUTTON      "&View...",IDC_VIEW,120,246,58,14
+    PUSHBUTTON      "Br&owse...",IDC_BROWSELOG,186,246,56,14
+    EDITTEXT        IDC_EDITLOGNAME,54,265,188,14,ES_AUTOHSCROLL | 
+                    WS_DISABLED
+    DEFPUSHBUTTON   "&Run",IDRUN,258,297,61,14
+    PUSHBUTTON      "&Close",IDEXIT,329,297,56,14
+    GROUPBOX        "Log To File",IDC_STATIC,7,233,243,55
+    GROUPBOX        "",IDC_IMAGEVERIFYBORDER,7,176,243,54,WS_GROUP
+    GROUPBOX        "Speed",IDC_SPEEDBORDER,7,98,135,73,WS_GROUP
+    EDITTEXT        IDC_IMAGEBOX,258,218,127,69,NOT WS_TABSTOP,
+                    WS_EX_DLGMODALFRAME
+    GROUPBOX        "Image Verification",IDC_STATIC,7,176,388,144
+    GROUPBOX        "Script",IDC_STATIC,7,5,388,315
+    LISTBOX         IDC_OUTPUT,150,38,235,133,LBS_NOINTEGRALHEIGHT | 
+                    LBS_DISABLENOSCROLL | LBS_NOSEL | WS_VSCROLL | 
+                    WS_HSCROLL
+    LTEXT           "Fast (100ms)",IDC_MAXSPEEDTXT,54,113,50,10
+    LTEXT           "Slow (30000ms)",IDC_MINSPEEDTXT,54,152,54,10
+    LTEXT           "Location:",IDC_STATIC,14,209,29,8
+    LTEXT           "% Error:",IDC_STATIC,142,191,25,8
+    LTEXT           "File Name:",IDC_STATIC,14,265,36,8
+    LTEXT           "0",IDC_STATIC,42,191,8,8
+    LTEXT           "100",IDC_STATIC,120,191,13,8
+    CONTROL         "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER,
+                    14,297,236,14
+    CTEXT           "Last Captured Screenshot",IDC_STATIC,274,195,90,8,
+                    SS_CENTERIMAGE
+    GROUPBOX        "",IDC_STATIC,258,187,127,23
+    PUSHBUTTON      "Select",IDC_MANAGE,50,72,50,14
+    GROUPBOX        "Connection",IDC_STATIC,7,35,135,57
+    EDITTEXT        IDC_CONNECTION,14,49,122,14,ES_AUTOHSCROLL | ES_READONLY
+END
+
+IDD_SOURCESELECT DIALOG DISCARDABLE  0, 0, 230, 111
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Image Verification - Source Select"
+FONT 8, "MS Sans Serif"
+BEGIN
+    DEFPUSHBUTTON   "OK",IDOK,168,64,50,14
+    PUSHBUTTON      "Cancel",IDCANCEL,168,87,50,14
+    EDITTEXT        IDC_LOCATIONEDITBOX,11,27,150,14,ES_AUTOHSCROLL
+    EDITTEXT        IDC_RANGEOFERROR,12,81,50,14,ES_AUTOHSCROLL
+    PUSHBUTTON      "Browse...",IDC_LOCATIONBROWSEBUTTON,168,27,50,14
+    GROUPBOX        "Permitted Range Of Error (%)",IDC_STATIC,7,61,132,43
+    GROUPBOX        "Location Of Reference Images",IDC_STATIC,7,7,216,50
+END
+
+IDD_MANAGECONNECTION DIALOG DISCARDABLE  0, 0, 264, 135
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Manage Device Connections"
+FONT 8, "MS Sans Serif"
+BEGIN
+    COMBOBOX        IDC_TRANSPORT,15,16,84,86,CBS_DROPDOWNLIST | WS_VSCROLL | 
+                    WS_TABSTOP
+    EDITTEXT        IDC_ADDRESS,105,16,85,14,ES_UPPERCASE | ES_AUTOHSCROLL
+    PUSHBUTTON      "Add",IDC_ADD,198,16,50,14
+    LISTBOX         IDC_LISTCONNECTIONS,15,54,233,44,LBS_SORT | 
+                    LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
+    PUSHBUTTON      "Remove",IDC_REMOVE,15,107,50,14
+    PUSHBUTTON      "Select",IDOK,106,107,50,14
+    PUSHBUTTON      "Cancel",IDCANCEL,198,107,50,14
+    GROUPBOX        "",IDC_STATIC,7,39,250,89
+    GROUPBOX        "",IDC_STATIC,7,3,250,35
+END
+
+
+#ifndef _MAC
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,1,0,0
+ PRODUCTVERSION 1,1,0,0
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "080904b0"
+        BEGIN
+            VALUE "Comments", "Nokia Test Automation Tool\0"
+            VALUE "CompanyName", "Nokia Limited\0"
+            VALUE "FileDescription", "STAT Desktop Version\0"
+            VALUE "FileVersion", "5.0\0"
+            VALUE "InternalName", "STATDesktop\0"
+            VALUE "LegalCopyright", "Copyright (C) 2005-2009 Nokia Corporation\0"
+            VALUE "LegalTrademarks", "STAT\0"
+            VALUE "OriginalFilename", "STATDesktop.exe\0"
+            VALUE "PrivateBuild", "\0"
+            VALUE "ProductName", "Nokia Test Automation Tool Desktop Version\0"
+            VALUE "ProductVersion", "5.0\0"
+            VALUE "SpecialBuild", "\0"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x809, 1200
+    END
+END
+
+#endif    // !_MAC
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE 
+BEGIN
+    IDD_ABOUTBOX, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 250
+        TOPMARGIN, 7
+        HORZGUIDE, 7
+        HORZGUIDE, 39
+    END
+
+    IDD_STATDESKTOP_DIALOG, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 395
+        VERTGUIDE, 14
+        VERTGUIDE, 24
+        VERTGUIDE, 37
+        VERTGUIDE, 50
+        VERTGUIDE, 54
+        VERTGUIDE, 120
+        VERTGUIDE, 136
+        VERTGUIDE, 142
+        VERTGUIDE, 178
+        VERTGUIDE, 186
+        VERTGUIDE, 209
+        VERTGUIDE, 242
+        VERTGUIDE, 250
+        VERTGUIDE, 258
+        VERTGUIDE, 319
+        VERTGUIDE, 329
+        VERTGUIDE, 356
+        VERTGUIDE, 385
+        TOPMARGIN, 5
+        BOTTOMMARGIN, 320
+        HORZGUIDE, 18
+        HORZGUIDE, 20
+        HORZGUIDE, 35
+        HORZGUIDE, 38
+        HORZGUIDE, 49
+        HORZGUIDE, 92
+        HORZGUIDE, 98
+        HORZGUIDE, 104
+        HORZGUIDE, 113
+        HORZGUIDE, 143
+        HORZGUIDE, 162
+        HORZGUIDE, 167
+        HORZGUIDE, 171
+        HORZGUIDE, 176
+        HORZGUIDE, 180
+        HORZGUIDE, 187
+        HORZGUIDE, 191
+        HORZGUIDE, 195
+        HORZGUIDE, 209
+        HORZGUIDE, 230
+        HORZGUIDE, 233
+        HORZGUIDE, 246
+        HORZGUIDE, 260
+        HORZGUIDE, 265
+        HORZGUIDE, 297
+    END
+
+    IDD_SOURCESELECT, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 223
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 104
+    END
+
+    IDD_MANAGECONNECTION, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 257
+        VERTGUIDE, 15
+        VERTGUIDE, 248
+        TOPMARGIN, 3
+        BOTTOMMARGIN, 128
+        HORZGUIDE, 16
+        HORZGUIDE, 121
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog Info
+//
+
+IDD_MANAGECONNECTION DLGINIT
+BEGIN
+    IDC_TRANSPORT, 0x403, 14, 0
+0x7953, 0x626d, 0x6169, 0x536e, 0x636f, 0x656b, 0x0074, 
+    IDC_TRANSPORT, 0x403, 14, 0
+0x7953, 0x626d, 0x6169, 0x536e, 0x7265, 0x6169, 0x006c, 
+    IDC_TRANSPORT, 0x403, 16, 0
+0x7953, 0x626d, 0x6169, 0x496e, 0x666e, 0x6172, 0x6572, 0x0064, 
+    IDC_TRANSPORT, 0x403, 17, 0
+0x7953, 0x626d, 0x6169, 0x426e, 0x756c, 0x7465, 0x6f6f, 0x6874, "\000" 
+    0
+END
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "..\\inc\\resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "#include ""afxres.h""\r\n"
+    "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
+    "#define _AFX_NO_OLE_RESOURCES\r\n"
+    "#define _AFX_NO_TRACKER_RESOURCES\r\n"
+    "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
+    "\r\n"
+    "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
+    "#ifdef _WIN32\r\n"
+    "LANGUAGE 9, 1\r\n"
+    "#pragma code_page(1252)\r\n"
+    "#endif //_WIN32\r\n"
+    "#include ""res\\STATDesktop.rc2""  // non-Microsoft Visual C++ edited resources\r\n"
+    "#include ""afxres.rc""         // Standard components\r\n"
+    "#endif\r\n"
+    "\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDR_SYMBIANICON         ICON    DISCARDABLE     "..\\res\\STATDesktop.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE 
+BEGIN
+    IDS_ABOUTBOX            "&About STATDesktop..."
+    IDS_PORTPROMPT          "%s %s uses virtual serial port for this connection.\n\nPlease enter the port number in the address field."
+    IDS_SYMBIAN             "Nokia"
+    IDS_APPNAME             "Desktop STAT"
+END
+
+#endif    // English (U.K.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+#define _AFX_NO_SPLITTER_RESOURCES
+#define _AFX_NO_OLE_RESOURCES
+#define _AFX_NO_TRACKER_RESOURCES
+#define _AFX_NO_PROPERTY_RESOURCES
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE 9, 1
+#pragma code_page(1252)
+#endif //_WIN32
+#include "res/STATDesktop.rc2"  // non-Microsoft Visual C++ edited resources
+#include "afxres.rc"         // Standard components
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+#endif    // not APSTUDIO_INVOKED
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/desktop/src/statdesktopdlg.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,1374 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#include "stdafx.h"
+#include "STATDesktop.h"
+#include "STATDesktopDlg.h"
+#include "STATManageConnection.h"
+#include "ScriptProgressMonitorImp.h"
+
+#include <afxdlgs.h>	//required for CFileDialog
+
+#include <process.h>
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+//////////////////////////////////////////////////////////////////////////
+// our thread-safe mechanism
+CRITICAL_SECTION CriticalSection;
+
+//////////////////////////////////////////////////////////////////////////
+
+typedef struct _THREADPROC_DATA
+{
+	HWND windowHandle;
+	int handle;
+	PROC_RUNSCRIPT ptrRunScript;
+}
+	THREADPROC_DATA;
+
+////////////////////////////////////////////////
+// thread entry point
+
+UINT WINAPI ThreadProc(LPVOID lpParameter)
+{
+	THREADPROC_DATA *data = reinterpret_cast<THREADPROC_DATA*>(lpParameter);
+
+	HWND windowHandle = data->windowHandle;
+	int handle = data->handle;
+	PROC_RUNSCRIPT iptrRunScript = data->ptrRunScript;
+
+	delete data;
+	data = NULL;
+
+	int	err =	GENERAL_FAILURE;
+
+	{
+		// Place this code in scope braces such that the
+		// object is cleaned up before the end of the 
+		// function.  The endthread methods will not call
+		// destructors.
+		ScriptProgressMonitorImp scriptMonitor( windowHandle );
+
+		// We do not use the error but it is useful to get it for debugging
+		// purposes.
+		err =	(iptrRunScript)(handle, &scriptMonitor);
+	}
+
+	::_endthreadex(0);	// Use _endthreadex so as not to close thread handle.
+
+	// Never get here.
+
+	return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// CAboutDlg dialog used for App About
+
+class CAboutDlg : public CDialog
+{
+public:
+	CAboutDlg(const char* aVersion);
+
+// Dialog Data
+	//{{AFX_DATA(CAboutDlg)
+	enum { IDD = IDD_ABOUTBOX };
+	//}}AFX_DATA
+
+	// ClassWizard generated virtual function overrides
+	//{{AFX_VIRTUAL(CAboutDlg)
+	protected:
+	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+	//}}AFX_VIRTUAL
+
+// Implementation
+protected:
+	//{{AFX_MSG(CAboutDlg)
+	virtual BOOL OnInitDialog();
+	//}}AFX_MSG
+	DECLARE_MESSAGE_MAP()
+
+private:
+	CString iVersion;
+
+
+};
+
+CAboutDlg::CAboutDlg(const char* aVersion) : CDialog(CAboutDlg::IDD)
+{
+	iVersion = CString(aVersion);
+
+
+	//{{AFX_DATA_INIT(CAboutDlg)
+	//}}AFX_DATA_INIT
+}
+
+void CAboutDlg::DoDataExchange(CDataExchange* pDX)
+{
+	CDialog::DoDataExchange(pDX);
+	//{{AFX_DATA_MAP(CAboutDlg)
+	//}}AFX_DATA_MAP
+}
+
+CAboutDlg::OnInitDialog()
+{
+	CDialog::OnInitDialog();
+
+	// set About Box details
+	TCHAR tHeading[25];
+	_stprintf(tHeading, _T("STAT Version: %s"), iVersion);
+
+	GetDlgItem(IDC_ABOUTHEADING)->SetWindowText(tHeading);
+
+	return TRUE;
+}
+
+BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
+	//{{AFX_MSG_MAP(CAboutDlg)
+		// No message handlers
+	//}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CSTATDesktopDlg dialog
+
+CSTATDesktopDlg::CSTATDesktopDlg(CWnd* pParent /*=NULL*/)
+: CDialog(CSTATDesktopDlg::IDD, pParent),
+	ihLib(NULL), iHandle(0), hThreadHandle((HANDLE)0), bRunning(false),
+	iptrVersion(NULL), iptrGetError(NULL), iptrGetErrorText(NULL), iptrSetConnectionLogging(NULL),
+	iptrCloseConnectionLogging(NULL), iptrConnect(NULL), iptrDisconnect(NULL),
+	iptrSetCommandDelay(NULL), iptrSetCommandLogging(NULL),
+	iptrSetImageVerification(NULL), iptrSendRawCommand(NULL),
+	iptrOpenScriptFile(NULL), iptrRunScript(NULL),
+	iptrSendCommandFile(NULL), iptrGetCommandCount(NULL), iptrGetCurrentCommandNumber(NULL),
+	iptrStopProcessing(NULL),
+	iptrGetSnapShot(NULL), iMessageReporter(NULL)
+{
+	//{{AFX_DATA_INIT(CSTATDesktopDlg)
+	//}}AFX_DATA_INIT
+	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
+}
+
+//----------------------------------------------------------------------------
+
+void CSTATDesktopDlg::DoDataExchange(CDataExchange* pDX)
+{
+	CDialog::DoDataExchange(pDX);
+	//{{AFX_DATA_MAP(CSTATDesktopDlg)
+	DDX_Control(pDX, IDC_CONNECTION, m_Connection);
+	DDX_Control(pDX, IDC_VIEW, m_ViewLog);
+	DDX_Control(pDX, IDC_PROGRESS, m_Progress);
+	DDX_Control(pDX, IDC_BROWSELOG, m_BrowseLog);
+	DDX_Control(pDX, IDC_APPEND, m_Append);
+	DDX_Control(pDX, IDC_BROWSEIMAGE, m_BrowseImage);
+	DDX_Control(pDX, IDC_TIMEDELAY, m_Delay);
+	DDX_Control(pDX, IDC_OUTPUT, m_Output);
+	DDX_Control(pDX, IDC_IMAGEVERIFY, m_VerifyImage);
+	DDX_Control(pDX, IDC_EDITLOGNAME, m_LogFileName);
+	DDX_Control(pDX, IDC_DIFFLOGNAME, m_LogToFile);
+	DDX_Control(pDX, IDC_IMAGEBOX, m_ImageBox);
+	DDX_Control(pDX, IDC_SCRIPT, m_Script);
+	DDX_Control(pDX, IDC_LOCATION, m_ImageLocation);
+	DDX_Control(pDX, IDC_SPEEDSLIDER, m_SliderPos);
+	DDX_Control(pDX, IDC_PERCENTAGEDIFF, m_PercentageDiff);
+	//}}AFX_DATA_MAP
+}
+
+BEGIN_MESSAGE_MAP(CSTATDesktopDlg, CDialog)
+	//{{AFX_MSG_MAP(CSTATDesktopDlg)
+	ON_WM_SYSCOMMAND()
+	ON_WM_PAINT()
+	ON_WM_QUERYDRAGICON()
+	ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
+	ON_BN_CLICKED(IDEDITSCRIPT, OnEditscript)
+	ON_BN_CLICKED(IDEXIT, OnExit)
+	ON_BN_CLICKED(IDRUN, OnRun)
+	ON_BN_CLICKED(IDC_DIFFLOGNAME, OnLogToFile)
+	ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SPEEDSLIDER, OnReleasedcaptureSpeedslider)
+	ON_EN_CHANGE(IDC_TIMEDELAY, OnChangeTimedelay)
+	ON_BN_CLICKED(IDC_BROWSEIMAGE, OnBrowseimage)
+	ON_BN_CLICKED(IDC_IMAGEVERIFY, OnImageverify)
+	ON_BN_CLICKED(IDC_BROWSELOG, OnBrowseLog)
+	ON_BN_CLICKED(IDC_VIEW, OnView)
+	ON_BN_CLICKED(IDC_MANAGE, OnManage)
+	ON_WM_DESTROY()
+	ON_MESSAGE(WM_DONE_COMMAND, OnDoneCommand)
+	ON_MESSAGE(WM_DONE_SCRIPT, OnDoneScript)
+	ON_MESSAGE(WM_SHOW_LOG_MESSAGE, OnLogMesage)
+	//}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CSTATDesktopDlg message handlers
+
+BOOL CSTATDesktopDlg::OnInitDialog()
+{
+	CDialog::OnInitDialog();
+
+	// IDM_ABOUTBOX must be in the system command range.
+	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
+	ASSERT(IDM_ABOUTBOX < 0xF000);
+
+	CMenu* pSysMenu = GetSystemMenu(FALSE);
+	if (pSysMenu != NULL)
+	{
+		CString strAboutMenu;
+		strAboutMenu.LoadString(IDS_ABOUTBOX);
+		if (!strAboutMenu.IsEmpty())
+		{
+			pSysMenu->AppendMenu(MF_SEPARATOR);
+			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
+		}
+	}
+
+	SetIcon(m_hIcon, TRUE);			// Set big icon
+	SetIcon(m_hIcon, FALSE);		// Set small icon
+	
+	// Load the STAT DLL library.
+	static char	DLLPath[MAX_PATH];
+
+#ifdef _DEBUG
+	// Load the debug DLL from our current working folder.
+	sprintf( DLLPath, "statd.dll" );
+#else // _DEBUG
+	// Load the current build of STAT DLL from the default 
+	// STAT folder (probably '\epoc32\tools\STAT').
+	sprintf( DLLPath, "%s\\%s", DLLFolder, DLLName );
+#endif // _DEBUG
+
+	ihLib =	::LoadLibrary( DLLPath );
+
+	if( ihLib  == NULL )
+	{
+		::AfxMessageBox( "Failed to load dynamic library.", MB_ICONERROR );
+		PostMessage( WM_CLOSE, 0, 0 );
+	}
+	else
+	{
+		iptrVersion =	reinterpret_cast<PROC_VERSION>(::GetProcAddress( ihLib, ProcVersion ));
+		iptrGetError =	reinterpret_cast<PROC_GETERROR>(::GetProcAddress( ihLib, ProcGetError ));
+		iptrGetErrorText =	reinterpret_cast<PROC_GETERRORTEXT>(::GetProcAddress( ihLib, ProcGetErrorText ));
+		iptrSetConnectionLogging =	reinterpret_cast<PROC_SETCONNECTIONLOGGING>(::GetProcAddress( ihLib, ProcSetConnectionLogging ));
+		iptrCloseConnectionLogging =	reinterpret_cast<PROC_CLOSECONNECTIONLOGGING>(::GetProcAddress( ihLib, ProcCloseConnectionLogging ));
+		iptrConnect =	reinterpret_cast<PROC_CONNECT>(::GetProcAddress( ihLib, ProcConnect ));
+		iptrDisconnect =	reinterpret_cast<PROC_DISCONNECT>(::GetProcAddress( ihLib, ProcDisconnect ));
+		iptrSetCommandDelay =	reinterpret_cast<PROC_SETCOMMANDDELAY>(::GetProcAddress( ihLib, ProcSetCommandDelay ));
+		iptrSetCommandLogging =	reinterpret_cast<PROC_SETCOMMANDLOGGING>(::GetProcAddress( ihLib, ProcSetCommandLogging ));
+		iptrSetImageVerification =	reinterpret_cast<PROC_SETIMAGEVERIFICATION>(::GetProcAddress( ihLib, ProcSetImageVerification ));
+		iptrOpenScriptFile =	reinterpret_cast<PROC_OPENSCRIPTFILE>(::GetProcAddress( ihLib, ProcOpenScriptFile ));
+		iptrRunScript =	reinterpret_cast<PROC_RUNSCRIPT>(::GetProcAddress( ihLib, ProcRunScript ));
+		iptrSendRawCommand =	reinterpret_cast<PROC_SENDRAWCOMMAND>(::GetProcAddress( ihLib, ProcSendRawCommand ));
+		iptrSendCommandFile =	reinterpret_cast<PROC_SENDCOMMANDFILE>(::GetProcAddress( ihLib, ProcSendCommandFile ));
+		iptrGetCommandCount =	reinterpret_cast<PROC_GETCOMMANDCOUNT>(::GetProcAddress( ihLib, ProcGetCommandCount ));
+		iptrGetCurrentCommandNumber =	reinterpret_cast<PROC_GETCURRENTCOMMANDNUMBER>(::GetProcAddress( ihLib, ProcGetCurrentCommandNumber ));
+		iptrStopProcessing =	reinterpret_cast<PROC_STOPPROCESSING>(::GetProcAddress( ihLib, ProcStopProcessing ));
+		iptrGetSnapShot =	reinterpret_cast<PROC_GETSNAPSHOT>(::GetProcAddress( ihLib, ProcGetSnapShot ));
+
+		if( ( NULL == iptrVersion ) ||
+			( NULL == iptrGetError ) ||
+			( NULL == iptrGetErrorText ) ||
+			( NULL == iptrSetConnectionLogging ) ||
+			( NULL == iptrCloseConnectionLogging ) ||
+			( NULL == iptrConnect ) ||
+			( NULL == iptrDisconnect ) ||
+			( NULL == iptrSetCommandDelay ) ||
+			( NULL == iptrSetCommandLogging ) ||
+			( NULL == iptrSetImageVerification ) ||
+			( NULL == iptrOpenScriptFile ) ||
+			( NULL == iptrRunScript ) ||
+			( NULL == iptrSendRawCommand ) ||
+			( NULL == iptrSendCommandFile ) ||
+			( NULL == iptrGetCommandCount ) ||
+			( NULL == iptrGetCurrentCommandNumber ) ||
+			( NULL == iptrStopProcessing ) )
+		{
+			::AfxMessageBox( "Failed to load a function address.", MB_ICONERROR );
+			PostMessage( WM_CLOSE, 0, 0 );
+		}
+	}
+
+	iMessageReporter =	new MessageReporterImp( GetSafeHwnd() );
+
+	iLastVerify = 0;
+	iLastLog = 0;
+	statIniFile.SetIniFileName(STAT_INI_NAME);
+	// read in previous settings
+	ReadSettings();
+
+	InitializeCriticalSection(&CriticalSection);
+
+	return TRUE;  // return TRUE  unless you set the focus to a control
+}
+
+//----------------------------------------------------------------------------
+void CSTATDesktopDlg::OnSysCommand(UINT nID, LPARAM lParam)
+{
+	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
+	{
+		CAboutDlg dlgAbout(iptrVersion());
+		dlgAbout.DoModal();
+	}
+	else
+		CDialog::OnSysCommand(nID, lParam);
+}
+
+//----------------------------------------------------------------------------
+
+// If you add a minimize button to your dialog, you will need the code below
+//  to draw the icon.  For MFC applications using the document/view model,
+//  this is automatically done for you by the framework.
+
+void CSTATDesktopDlg::OnPaint() 
+{
+	if (IsIconic())
+	{
+		CPaintDC dc(this); // device context for painting
+
+		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
+
+		// Center icon in client rectangle
+		int cxIcon = GetSystemMetrics(SM_CXICON);
+		int cyIcon = GetSystemMetrics(SM_CYICON);
+		CRect rect;
+		GetClientRect(&rect);
+		int x = (rect.Width() - cxIcon + 1) / 2;
+		int y = (rect.Height() - cyIcon + 1) / 2;
+
+		// Draw the icon
+		dc.DrawIcon(x, y, m_hIcon);
+	}
+	else
+		CDialog::OnPaint();
+}
+
+//----------------------------------------------------------------------------
+
+HCURSOR CSTATDesktopDlg::OnQueryDragIcon()
+{
+	return (HCURSOR) m_hIcon;
+}
+
+//----------------------------------------------------------------------------
+
+void CSTATDesktopDlg::OnBrowse() 
+{
+	// use the folder of the current script as a starting point
+	m_Script.GetWindowText(szBuffer, sizeof(szBuffer));
+	CString buf = szBuffer;
+	if (!buf.IsEmpty())
+	{
+		int index = buf.ReverseFind('\\');
+		if (index != -1)
+		{
+			CString folder = buf.Left(index);
+			SetCurrentDirectory(folder.GetBuffer(0));
+		}
+	}
+
+	CFileDialog dlgStatFileOpen(TRUE, 
+								NULL, 
+								NULL, 
+								OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST, 
+								_T("Script Files (*.txt)|*.txt|All Files (*.*)|*.*||"));
+
+	// new script file to use
+	if (dlgStatFileOpen.DoModal() == IDOK)	//when ok is pressed
+		m_Script.SetWindowText(dlgStatFileOpen.GetPathName());
+}
+
+//----------------------------------------------------------------------------
+//Frees memory and releases COM stuff etc...
+void CSTATDesktopDlg::OnCancel() 
+{
+	OnOK();
+}
+
+void CSTATDesktopDlg::OnExit() 
+{
+	SaveSettings();
+	OnOK();
+}
+
+
+//----------------------------------------------------------------------------
+//when the Run button is pressed
+void CSTATDesktopDlg::OnRun()
+{
+	if (bRunning)
+	{
+		CWaitCursor oWait;
+
+		Message("Signalling current script to stop.  Please wait...");
+		(iptrStopProcessing)(iHandle);
+	}
+	else
+	{
+		m_Output.ResetContent();
+		Message("*** STAT LOG ***");
+		RunIt();
+	}
+}
+
+
+//----------------------------------------------------------------------------
+// main work happens here
+void CSTATDesktopDlg::RunIt()
+{
+	// We should use GetData( true ) here to update all the internal data with the
+	// text in the dialog controls instead of GetWindowText.
+
+	CWaitCursor oWait;
+	int ret = ITS_OK;
+	bRunning = true;
+
+	// make sure we have something to work with
+	(*szBuffer) = (TCHAR)0;
+	m_Script.GetWindowText(szBuffer, sizeof(szBuffer));
+	if (!(*szBuffer))
+	{
+		CleanUp(_T("One or more required fields in the dialog are empty"));
+		return;
+	}
+
+	// initialise back end
+	if((ret = ConnectToEngine()) != ITS_OK)
+	{
+		CString msg;
+		if (ret == E_NOCONNECTION)
+			msg = _T("No connection specified");
+		else
+			msg = (iptrGetError)(iHandle);
+
+		CleanUp(msg);
+		return;
+	}
+
+	// turn on logging
+	if(m_LogToFile.GetCheck())
+	{
+		m_LogFileName.GetWindowText(szBuffer, sizeof(szBuffer));
+		CString cBuffer = szBuffer;
+
+		if (!cBuffer.IsEmpty() && (_tcscmp(szBuffer, _T("<date-time>")) != 0))
+			MessageFormat("Logging to %s Append: %d...", szBuffer, m_Append.GetCheck());
+		else
+		{
+			if (cBuffer.IsEmpty())
+				m_LogFileName.SetWindowText(_T("<date-time>"));
+			else
+				cBuffer.Empty();
+
+			MessageFormat("Logging to default file, Append: %d...", m_Append.GetCheck());
+		}
+
+		ret = (iptrSetCommandLogging)(iHandle, cBuffer, iMessageReporter,
+										EVerbose, (m_Append.GetCheck() > 0), NULL, NULL );
+		if (ret != LOG_FILE_OK)
+		{
+			CleanUp(_T("Logging could not be set"));
+			return;
+		}
+	}
+	else
+	{
+		CString cBuffer;
+		ret = (iptrSetCommandLogging)(iHandle, NULL, iMessageReporter,
+										EVerbose, (m_Append.GetCheck() > 0), NULL, NULL );
+		if (ret != LOG_FILE_OK)
+		{
+			CleanUp(_T("Logging could not be set"));
+			return;
+		}
+	}
+
+	// set the script execution speed
+	GetDlgItem(IDC_TIMEDELAY)->GetWindowText(szBuffer, sizeof(szBuffer));
+	(iptrSetCommandDelay)(iHandle, _ttoi(szBuffer));
+	MessageFormat("Command delay set to %d...", _ttoi(szBuffer));
+
+	// image verification
+	if(m_VerifyImage.GetCheck() && !SetImageVerification())
+	{
+		CleanUp(_T("Image verification could not be set"));
+		return;
+	}
+
+	// get list of commands in script
+	m_Script.GetWindowText(szBuffer, sizeof(szBuffer));
+	int iCount = 0;
+	ret = (iptrGetCommandCount)(iHandle, szBuffer, &iCount);
+	if(ret != ITS_OK)	//attempt to open as commands if file cannot be opened
+	{
+		CleanUp((iptrGetErrorText)(iHandle, ret));
+		return;
+	}
+
+	// set the progress bar
+	m_Progress.SetRange(0, (short)iCount);
+	m_Progress.SetPos(0);
+
+	//open script file
+	ret = (iptrOpenScriptFile)(iHandle, szBuffer, true);
+	if(ret != ITS_OK)	//attempt to open as commands if file cannot be opened
+	{
+		ret = (iptrOpenScriptFile)(iHandle, szBuffer, false);
+	}
+	if(ret != ITS_OK)
+	{
+		CleanUp((iptrGetErrorText)(iHandle, ret));
+		return;
+	}
+
+	EnableFields(FALSE);
+	oWait.Restore();
+
+	// event attributes for the child process - used to kill the thread if required
+	SECURITY_ATTRIBUTES eventAttr;
+	eventAttr.nLength = sizeof(eventAttr);
+	eventAttr.lpSecurityDescriptor = NULL;
+	eventAttr.bInheritHandle = TRUE;
+
+	THREADPROC_DATA *data = new THREADPROC_DATA;
+	data->windowHandle = GetSafeHwnd( );
+	data->handle = iHandle;
+	data->ptrRunScript = iptrRunScript;
+
+	// Would be nice to use MFC thread methods here but we want to be specific
+	// about using _beginthreadex and _endthreadex so we can manage the
+	// thread handle ourselves.  The MFC will neatly auto-close the handle but
+	// we do not want that.
+	// CWinThread *thread = ::AfxBeginThread( ThreadProc, &data );
+	// hThreadHandle = thread;
+	UINT dwThreadID = 0;
+	hThreadHandle = reinterpret_cast<HANDLE>(::_beginthreadex( NULL, 0, ThreadProc, data, 0, &dwThreadID ));
+
+	// Give the new thread chance to start.
+	// This is of no practical value in application operation.
+	// However, it is very useful in debugging and if we add this code we know
+	// the new thread will start now.
+	::Sleep(0);
+}
+
+//----------------------------------------------------------------------------
+//  Display a message
+void CSTATDesktopDlg::MessageFormat(const char *message, ...)
+{
+	char szText[1024] = {0};
+	va_list pMsg;
+
+	va_start (pMsg, message);
+	vsprintf (szText, message, pMsg);
+	va_end (pMsg);
+
+	CString temp = szText;
+	Message(temp);
+}
+
+
+//-----------------------------------------------------------------------------
+//  Display a message and (maybe) write to log file
+void CSTATDesktopDlg::Message(const char* message)
+{
+	int nCount = 0;
+	
+	m_Output.InsertString(-1, message);	
+	nCount = m_Output.GetCount();
+	if (nCount > 0)
+		m_Output.SetTopIndex(nCount - 1);	//The list view control is scrolled if necessary
+	
+	m_Output.UpdateWindow();
+}
+
+//----------------------------------------------------------------------------
+bool CSTATDesktopDlg::ShowScreenshot(const CString &filename)
+{
+	CFile cf;
+	m_pDib = NULL;
+	
+	// Attempt to open the Dib file for reading.
+	if( !cf.Open(filename, CFile::modeRead ) )
+		return false;
+
+	// Get the size of the file and store
+	// in a local variable. Subtract the
+	// size of the BITMAPFILEHEADER structure
+	// since we won't keep that in memory.
+	DWORD dwDibSize;
+	dwDibSize =	cf.GetLength() - sizeof( BITMAPFILEHEADER );
+
+	// Attempt to allocate the Dib memory.
+	unsigned char *pDib;
+	pDib = new unsigned char [dwDibSize];
+	if(!pDib)
+	{
+		cf.Close();
+		return false;
+	}
+
+	BITMAPFILEHEADER BFH;
+
+	// Read in the Dib header and data.
+	try
+	{
+
+		// Did we read in the entire BITMAPFILEHEADER?
+		if( cf.Read( &BFH, sizeof( BITMAPFILEHEADER ) )
+			!= sizeof( BITMAPFILEHEADER ) ||
+
+			// Is the type 'MB'?
+			BFH.bfType != 'MB' ||
+
+			// Did we read in the remaining data?
+			cf.Read( pDib, dwDibSize ) != dwDibSize )
+		{
+
+			// Delete the memory if we had any
+			// errors and return FALSE.
+			delete [] pDib;
+			cf.Close();
+			return false;
+		}
+	}
+
+	// If we catch an exception, delete the
+	// exception, the temporary Dib memory,
+	// and return FALSE.
+	catch( CFileException *e )
+	{
+		e->Delete();
+		delete [] pDib;
+		cf.Close();
+		return false;
+	}
+	
+	cf.Close();
+
+	// If we got to this point, the Dib has been
+	// loaded. If a Dib was already loaded into
+	// this class, we must now delete it.
+	if( m_pDib)
+		delete [] m_pDib;
+
+	// Store the local Dib data pointer and
+	// Dib size variables in the class member
+	// variables.
+	m_pDib = pDib;
+	m_dwDibSize = dwDibSize;
+
+	// Pointer our BITMAPINFOHEADER and RGBQUAD
+	// variables to the correct place in the Dib data.
+	m_pBIH = (BITMAPINFOHEADER *) m_pDib;
+	m_pPalette =
+		(RGBQUAD *) &m_pDib[sizeof(BITMAPINFOHEADER)];
+
+	// Calculate the number of palette entries.
+	m_nPaletteEntries = 1 << m_pBIH->biBitCount;
+	if( m_pBIH->biBitCount > 8 )
+		m_nPaletteEntries = 0;
+	else if( m_pBIH->biClrUsed != 0 )
+		m_nPaletteEntries = m_pBIH->biClrUsed;
+
+	// Point m_pDibBits to the actual Dib bits data.
+	m_pDibBits =
+		&m_pDib[sizeof(BITMAPINFOHEADER)+
+			m_nPaletteEntries*sizeof(RGBQUAD)];
+
+	// If we have a valid palette, delete it.
+	if( m_Palette.GetSafeHandle() != NULL )
+		m_Palette.DeleteObject();
+
+	// If there are palette entries, we'll need
+	// to create a LOGPALETTE then create the
+	// CPalette palette.
+	if(m_nPaletteEntries)
+	{
+		// Allocate the LOGPALETTE structure.
+		LOGPALETTE *pLogPal = (LOGPALETTE *) new char
+				[sizeof(LOGPALETTE) +
+				 m_nPaletteEntries * sizeof(PALETTEENTRY)];
+
+		if(pLogPal)
+		{
+			// Set the LOGPALETTE to version 0x300
+			// and store the number of palette
+			// entries.
+			pLogPal->palVersion = 0x300;
+			pLogPal->palNumEntries = (unsigned short)m_nPaletteEntries;
+
+			// Store the RGB values into each
+			// PALETTEENTRY element.
+			for( int i=0; i<m_nPaletteEntries; i++ ){
+				pLogPal->palPalEntry[i].peRed =
+					m_pPalette[i].rgbRed;
+				pLogPal->palPalEntry[i].peGreen =
+					m_pPalette[i].rgbGreen;
+				pLogPal->palPalEntry[i].peBlue =
+					m_pPalette[i].rgbBlue;
+				}
+
+			// Create the CPalette object and
+			// delete the LOGPALETTE memory.
+			m_Palette.CreatePalette( pLogPal );
+			delete [] pLogPal;
+		}
+		else
+			return false;
+	}
+	
+	// If we have not data we can't draw.
+	if(!m_pDib)
+		return false;
+	
+	// set the value that's in the BITMAPINFOHEADER.
+	
+	int nWidth = m_pBIH->biWidth;
+	int nHeight = m_pBIH->biHeight;
+
+	//HDC hdc, hImageBoxDC;
+	//HBITMAP hImageBoxBitmap;
+	
+	CDC* pDC = m_ImageBox.GetDC();
+	CDC ImageBoxDC;
+
+	ImageBoxDC.CreateCompatibleDC(pDC);
+	
+	CBitmap ImageBoxBitmap;
+	ImageBoxBitmap.CreateCompatibleBitmap(pDC, nWidth, nHeight);
+
+	//select the bitmap
+	ImageBoxDC.SelectObject(&ImageBoxBitmap);
+	ImageBoxDC.SetBkColor(OPAQUE);
+
+	//set MaskBitmap pixel data to that of the original DDB (on screen)
+	SetDIBits(ImageBoxDC.m_hDC, (HBITMAP)ImageBoxBitmap.GetSafeHandle(), 0L, nHeight, m_pDibBits, (BITMAPINFO *)m_pBIH, (DWORD)DIB_RGB_COLORS);
+
+	RECT Rect;
+	m_ImageBox.GetClientRect(&Rect);
+	
+	StretchDIBits(pDC -> m_hDC, 0, 0,
+			Rect.right, Rect.bottom,
+			0, 0,
+			m_pBIH -> biWidth, m_pBIH -> biHeight,
+			m_pDibBits,
+			(BITMAPINFO *) m_pBIH,
+			BI_RGB, SRCCOPY);
+
+	
+	m_ImageBox.ReleaseDC(pDC);
+
+	//release memory originally allocated
+	if(pDib)
+		delete [] pDib;
+
+	return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////
+//used to adjust speed execution time information
+void CSTATDesktopDlg::OnReleasedcaptureSpeedslider(NMHDR* pNMHDR, LRESULT* pResult) 
+{
+	(void)pNMHDR;
+	TCHAR buffer[10];
+	SetDlgItemText(IDC_TIMEDELAY, _itot(m_SliderPos.GetPos(), buffer, 10));
+	(*pResult) = 0;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////
+//adjusts slider according 
+void CSTATDesktopDlg::OnChangeTimedelay() 
+{
+	CString usertimer;
+	GetDlgItemText(IDC_TIMEDELAY, usertimer);
+	m_SliderPos.SetPos(_ttoi(usertimer));
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////
+// Call Notepad to view/edit script
+void CSTATDesktopDlg::OnEditscript() 
+{
+	CString file;
+	GetDlgItemText(IDC_SCRIPT, file);
+
+	if (!file.IsEmpty())
+	{
+		int index = file.ReverseFind('\\');
+		if (index != -1)
+		{
+			OpenFile(file.GetBuffer(0));
+		}
+	}
+
+}
+
+void CSTATDesktopDlg::OnView() 
+{
+	CString file;
+	GetDlgItemText(IDC_EDITLOGNAME, file);
+
+	if (file.IsEmpty() || (file.Compare(_T("<date-time>")) == 0))
+	{
+
+		CString setting=STAT_LOGFILEPATH_VALUE;
+		SetCurrentDirectory(setting);
+
+		CFileDialog dlgStatFileOpen(TRUE, 
+									NULL, 
+									NULL, 
+									OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST, 
+									_T("Log Files (*.log)|*.log|All Files (*.*)|*.*||"));
+
+		// log file to use
+		if (dlgStatFileOpen.DoModal() == IDOK)	//when ok is pressed
+		{
+			file = dlgStatFileOpen.GetPathName();
+		}
+	}
+
+	if (!file.IsEmpty() && (file.Compare(_T("<date-time>")) != 0))
+		OpenFile(file.GetBuffer(0));
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////
+// Open a text file in Notepad
+void CSTATDesktopDlg::OpenFile(LPTSTR file)
+{
+	TCHAR szCurrentDir[MAX_PATH + 1];
+	if (GetWindowsDirectory(szCurrentDir, sizeof(szCurrentDir)))
+	{
+		CString cBuf;
+		cBuf = _T("\"");
+		cBuf += szCurrentDir;
+		cBuf += _T("\\Notepad.exe\" ");
+		cBuf += file;
+
+		if (!CallProcess(NULL, cBuf.GetBuffer(0), NULL))
+			AfxMessageBox(_T("Could not invoke Notepad.exe to view script file"), MB_OK, NULL);
+	}
+	else
+		AfxMessageBox(_T("Could not locate Windows directory"), MB_OK, NULL);
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////
+// Invoke a process
+bool CSTATDesktopDlg::CallProcess(LPCTSTR szApplication, LPTSTR szCommandLine, LPCTSTR szDirectory)
+{
+	bool valid = false;
+	STARTUPINFO startInfo = {0};
+	startInfo.cb = sizeof(STARTUPINFO);
+
+	PROCESS_INFORMATION procInfo = {0};
+
+	// event attributes for the child process
+	SECURITY_ATTRIBUTES eventAttr;
+	eventAttr.nLength = sizeof(eventAttr);
+	eventAttr.lpSecurityDescriptor = NULL;
+	eventAttr.bInheritHandle = TRUE;
+
+	if (CreateProcess(szApplication, szCommandLine, NULL, NULL, FALSE, NULL, NULL,
+					  szDirectory, &startInfo, &procInfo))
+	{
+		valid = true;
+		CloseHandle(procInfo.hThread);
+		CloseHandle(procInfo.hProcess);
+	}
+
+	return valid;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////
+// Browse for Reference images folder
+void CSTATDesktopDlg::OnBrowseimage() 
+{
+	TCHAR chName[MAX_PATH];
+
+	BROWSEINFO bi = {0};
+	bi.hwndOwner = m_hWnd;
+	bi.lpszTitle = _T("Please select folder where the reference bitmap files are stored...");
+
+	LPITEMIDLIST lpIDList = ::SHBrowseForFolder(&bi); //now display dialog box 
+
+	::SHGetPathFromIDList(lpIDList, chName); //Converts an item identifier list to a file system path
+
+	m_ImageLocation.SetWindowText(chName);	//pastes location into edit box
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////
+// Read previous STAT settings
+void CSTATDesktopDlg::ReadSettings()
+{
+	//set slider text
+	m_SliderPos.SetRangeMax(30000, TRUE);	//max delay time
+	m_SliderPos.SetRangeMin(100, TRUE);		//minimum delay time
+
+	if(statIniFile.SectionExists(ST_TEST_KEY) )
+	{
+		CString setting;
+		setting.Empty();
+		setting=statIniFile.GetKeyValue(ST_DELAY,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			int iPos = _ttoi(setting);
+			if (iPos < 100)
+				setting= _T("100");
+
+			if (iPos > 30000)
+				setting= _T("30000");
+
+			m_Delay.SetWindowText(setting);
+			m_SliderPos.SetPos(iPos);
+		}
+
+		setting.Empty();
+		setting=statIniFile.GetKeyValue(ST_CUST_LOGFILE,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+			m_LogFileName.SetWindowText(setting);
+
+		setting.Empty();
+		setting=statIniFile.GetKeyValue(ST_FUDGE,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+			m_PercentageDiff.SetPos(_ttoi(setting));
+
+		setting.Empty();
+		setting=statIniFile.GetKeyValue(ST_REFDIR,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+			m_ImageLocation.SetWindowText(setting);
+
+		setting.Empty();
+		setting=statIniFile.GetKeyValue(ST_SCRIPT,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+			m_Script.SetWindowText(setting);
+
+		long lCount = 0;
+		setting.Empty();
+		setting=statIniFile.GetKeyValue(ST_VERIFYIMAGE,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			lCount=_ttol(setting);
+			if (lCount)
+			{
+				m_VerifyImage.SetCheck(lCount);
+				m_ImageLocation.EnableWindow(TRUE);
+				m_PercentageDiff.EnableWindow(TRUE);
+			}
+			else
+			{
+				m_ImageLocation.EnableWindow(FALSE);
+				m_PercentageDiff.EnableWindow(FALSE);
+			}
+		}
+		setting.Empty();
+		setting=statIniFile.GetKeyValue(ST_LOGTOFILE,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			lCount=_ttol(setting);
+			if (lCount)
+			{
+				m_LogToFile.SetCheck(lCount);
+				m_LogFileName.EnableWindow(TRUE);
+			}
+			else
+				m_LogFileName.EnableWindow(FALSE);
+		}
+
+		setting.Empty();
+		setting=statIniFile.GetKeyValue(ST_CONNECTION,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			m_Connection.SetWindowText(setting);
+		}
+
+		setting.Empty();
+		lCount=0;
+		setting=statIniFile.GetKeyValue(ST_APPEND,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			lCount=_ttol(setting);
+		}
+		m_Append.SetCheck(lCount);
+
+		setting.Empty();
+		lCount=0;
+		setting=statIniFile.GetKeyValue(ST_PLATFORM,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			lCount=_ttol(setting);
+		}
+	}
+	OnImageverify();
+	OnLogToFile();
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////
+// Save STAT settings
+void CSTATDesktopDlg::SaveSettings()
+{
+	// script
+	(*szBuffer) = (TCHAR)0;
+	m_Script.GetWindowText(szBuffer, sizeof(szBuffer));
+	statIniFile.WriteKey(szBuffer,ST_SCRIPT,ST_TEST_KEY);
+
+	// address
+	(*szBuffer) = (char)0;
+	m_Connection.GetWindowText(szBuffer, sizeof(szBuffer));
+	statIniFile.WriteKey(szBuffer,ST_CONNECTION,ST_TEST_KEY);
+
+	// delay
+	(*szBuffer) = (char)0;
+	m_Delay.GetWindowText(szBuffer, sizeof(szBuffer));
+	statIniFile.WriteKey(szBuffer,ST_DELAY,ST_TEST_KEY);
+
+	// percentage
+	(*szBuffer) = (char)0;
+	_itot(m_PercentageDiff.GetPos(), szBuffer, 10);
+	statIniFile.WriteKey(szBuffer,ST_FUDGE,ST_TEST_KEY);
+
+	// ref dir
+	(*szBuffer) = (char)0;
+	m_ImageLocation.GetWindowText(szBuffer, sizeof(szBuffer));
+	statIniFile.WriteKey(szBuffer,ST_REFDIR,ST_TEST_KEY);
+
+	(*szBuffer) = (char)0;
+	m_LogFileName.GetWindowText(szBuffer, sizeof(szBuffer));
+	statIniFile.WriteKey(szBuffer,ST_CUST_LOGFILE,ST_TEST_KEY);
+
+	_ltot( m_Append.GetCheck(), szBuffer, 10);
+	statIniFile.WriteKey(szBuffer,ST_APPEND,ST_TEST_KEY);
+
+	_ltot(m_VerifyImage.GetCheck(), szBuffer, 10);
+	statIniFile.WriteKey(szBuffer,ST_VERIFYIMAGE,ST_TEST_KEY);
+
+	_ltot(m_LogToFile.GetCheck(), szBuffer, 10);
+	statIniFile.WriteKey(szBuffer,ST_LOGTOFILE,ST_TEST_KEY);
+
+  }
+
+
+//////////////////////////////////////////////////////////////////////////////////////
+// Actions to perform when image verify checked/unchecked
+void CSTATDesktopDlg::OnImageverify()
+{
+	if (m_VerifyImage.GetCheck())
+	{
+		m_ImageLocation.EnableWindow(TRUE);
+		m_PercentageDiff.EnableWindow(TRUE);
+		m_BrowseImage.EnableWindow(TRUE);
+	}
+	else
+	{
+		m_ImageLocation.EnableWindow(FALSE);
+		m_PercentageDiff.EnableWindow(FALSE);
+		m_BrowseImage.EnableWindow(FALSE);
+	}
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////
+// Actions to perform when log to file checked/unchecked
+void CSTATDesktopDlg::OnLogToFile()
+{
+	if(m_LogToFile.GetCheck())
+	{
+		m_LogFileName.EnableWindow(TRUE);
+		m_Append.EnableWindow(TRUE);
+		m_BrowseLog.EnableWindow(TRUE);
+		m_ViewLog.EnableWindow(TRUE);
+	}
+	else
+	{
+		m_LogFileName.EnableWindow(FALSE);
+		m_Append.EnableWindow(FALSE);
+		m_BrowseLog.EnableWindow(FALSE);
+		m_ViewLog.EnableWindow(FALSE);
+	}
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////
+// Browse for a log file to write to
+void CSTATDesktopDlg::OnBrowseLog() 
+{
+	CFileDialog dlgStatFileOpen(TRUE, 
+								NULL, 
+								NULL, 
+								OFN_PATHMUSTEXIST, 
+								_T("Log Files (*.log)|*.log|Script Files (*.txt)|*.txt|All Files (*.*)|*.*||"));
+
+	// new script file to use
+	if (dlgStatFileOpen.DoModal() == IDOK)	//when ok is pressed
+		m_LogFileName.SetWindowText(dlgStatFileOpen.GetPathName());
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////
+// Make connection to the back end
+int CSTATDesktopDlg::ConnectToEngine() 
+{
+	int	retCode =	ITS_OK;
+
+	STATCONNECTTYPE type = SymbianInvalid;
+	char szConnection[512] = {0};
+
+	m_Connection.GetWindowText(szBuffer, sizeof(szBuffer));
+	strcpy(szConnection, szBuffer);
+
+	char *p = strchr(szConnection, ':');
+	if (p)
+	{
+		(*p) = (char)0;
+		if (stricmp(szConnection, "SymbianSocket") == 0)
+		{
+			type = SymbianSocket;
+		}
+		else if (stricmp(szConnection, "SymbianSerial") == 0)
+		{
+			type = SymbianSerial;
+		}
+		else if (stricmp(szConnection, "SymbianInfrared") == 0)
+		{
+			type = SymbianInfrared;
+		}
+		else if (stricmp(szConnection, "SymbianBluetooth") == 0)
+		{
+			type = SymbianBluetooth;
+		}
+		else if (stricmp(szConnection, "SymbianUsb") == 0)
+		{
+			type = SymbianUsb;
+		}
+
+		MessageFormat("Connecting over %s to %s...", szConnection, p + 1);
+
+		// initialise back end
+		iHandle =	(iptrConnect)(type, p + 1, NULL, NULL);
+
+		if( NULL != iHandle )
+		{
+			retCode =	ITS_OK;
+		}
+		else
+		{
+			retCode =	GENERAL_FAILURE;
+		}
+	}
+
+	return (retCode);
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////
+// Set up image verification
+int CSTATDesktopDlg::SetImageVerification()
+{
+	(*szBuffer) = (char)0;
+	m_ImageLocation.GetWindowText(szBuffer, sizeof(szBuffer));
+
+	int iErrorCode = (iptrSetImageVerification)(iHandle, szBuffer,
+						true, m_PercentageDiff.GetPos());
+
+	// success?
+	if(iErrorCode)
+	{
+		Message("Image verification set");
+		return true;
+	}
+	else
+	{
+		iErrorCode = GENERAL_FAILURE;
+		Message("ERROR: No images available for verification");
+	}
+
+	return false;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+// Set up image verification
+void CSTATDesktopDlg::EnableFields(bool bEnable)
+{
+	// store
+	if (!bEnable)
+	{
+		iLastVerify = m_VerifyImage.GetCheck();
+		iLastLog = m_LogToFile.GetCheck();
+
+		GetDlgItem(IDRUN)->SetWindowText(_T("Stop"));
+	}
+
+	GetDlgItem(IDC_SCRIPT)->EnableWindow(bEnable);
+	GetDlgItem(IDC_BROWSE)->EnableWindow(bEnable);
+	GetDlgItem(IDEDITSCRIPT)->EnableWindow(bEnable);
+	GetDlgItem(IDC_TIMEDELAY)->EnableWindow(bEnable);
+	GetDlgItem(IDC_SPEEDSLIDER)->EnableWindow(bEnable);
+	GetDlgItem(IDC_IMAGEVERIFY)->EnableWindow(bEnable);
+	GetDlgItem(IDC_LOCATION)->EnableWindow(bEnable);
+	GetDlgItem(IDC_BROWSEIMAGE)->EnableWindow(bEnable);
+	GetDlgItem(IDC_DIFFLOGNAME)->EnableWindow(bEnable);
+	GetDlgItem(IDC_EDITLOGNAME)->EnableWindow(bEnable);
+	GetDlgItem(IDC_APPEND)->EnableWindow(bEnable);
+	GetDlgItem(IDC_BROWSELOG)->EnableWindow(bEnable);
+	GetDlgItem(IDC_EDITLOGNAME)->EnableWindow(bEnable);
+	GetDlgItem(IDEXIT)->EnableWindow(bEnable);
+	GetDlgItem(IDC_PERCENTAGEDIFF)->EnableWindow(bEnable);
+
+	// restore
+	if (bEnable)
+	{
+		m_VerifyImage.SetCheck(iLastVerify);
+		m_LogToFile.SetCheck(iLastLog);
+		OnImageverify();
+		OnLogToFile();
+		GetDlgItem(IDRUN)->SetWindowText(_T("Run"));
+	}
+
+	UpdateWindow();
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////
+// Release resources at finish
+void CSTATDesktopDlg::CleanUp(LPCTSTR message, bool bEnableFields)
+{
+	CString cMsg = message;
+	CleanUp(cMsg, bEnableFields);
+}
+
+void CSTATDesktopDlg::CleanUp(const CString &message, bool bEnableFields)
+{
+	m_Progress.SetPos(0);
+
+	if (bEnableFields)
+		EnableFields(TRUE);
+
+	if (!message.IsEmpty())
+	{
+		Message(message);
+	}
+
+	// close the handle to our thread
+  	if (hThreadHandle)
+  	{
+  		CloseHandle(hThreadHandle);
+  		hThreadHandle = (HANDLE)0;
+  	}
+
+	// release the back end
+	if( iHandle != 0 )
+	{
+		(iptrDisconnect)(iHandle);
+		iHandle = 0;
+	}
+
+	bRunning = false;
+}
+
+void CSTATDesktopDlg::OnManage() 
+{
+	STATManageConnection oManage;
+	if (IDOK == oManage.DoModal())
+	{
+		m_Connection.SetWindowText(cConnectionInfo);
+	}
+}
+
+void CSTATDesktopDlg::OnDestroy() 
+{
+	CleanUp(_T(""), false);
+
+	if( iMessageReporter != NULL )
+	{
+		delete iMessageReporter;
+		iMessageReporter =	NULL;
+	}
+
+	if( ihLib != NULL )
+	{
+		::FreeLibrary( ihLib );
+		ihLib =	NULL;
+	}
+
+	DeleteCriticalSection(&CriticalSection);
+
+	CDialog::OnDestroy();
+}
+
+LRESULT CSTATDesktopDlg::OnDoneCommand(WPARAM command, LPARAM )
+{
+	command;
+
+	int currentCommand = 0;
+	if( ITS_OK == (iptrGetCurrentCommandNumber)(iHandle, &currentCommand) )
+	{
+		m_Progress.SetPos(currentCommand);
+	}
+
+	return (0L );
+}
+
+LRESULT CSTATDesktopDlg::OnDoneScript(WPARAM iScriptExitCode, LPARAM )
+{
+	CleanUp((iptrGetErrorText)(iHandle, iScriptExitCode));
+
+	return (0L );
+}
+
+LRESULT CSTATDesktopDlg::OnLogMesage(WPARAM, LPARAM pLogMessage )
+{
+	LogMessage *logMessage = reinterpret_cast<LogMessage*>(pLogMessage);
+
+	ASSERT( FALSE == ::IsBadWritePtr( logMessage, sizeof(*logMessage) ) );
+
+	if( NULL != logMessage )
+	{
+		if (logMessage->iMessage.GetLength() != 0)
+		{
+			Message(logMessage->iMessage);
+		}
+
+		if (logMessage->iText.GetLength() != 0)
+		{
+			Message(logMessage->iText);
+		}
+
+		if (logMessage->iScreenShot)
+		{
+			ShowScreenshot(logMessage->iText);
+		}
+
+		if (logMessage->iMessageBox)
+		{
+			::AfxMessageBox(logMessage->iMessage, MB_OK, NULL);
+		}
+	}
+
+	return (0L);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/desktop/src/statmanageconnection.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,335 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#include "stdafx.h"
+#include "statdesktop.h"
+#include "STATManageConnection.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+// global var to hold our selection when we exit the dialog
+CString cConnectionInfo;
+
+/////////////////////////////////////////////////////////////////////////////
+// STATManageConnection dialog
+
+
+STATManageConnection::STATManageConnection(CWnd* pParent /*=NULL*/)
+	: CDialog(STATManageConnection::IDD, pParent)
+{
+	//{{AFX_DATA_INIT(STATManageConnection)
+	//}}AFX_DATA_INIT
+}
+
+
+void STATManageConnection::DoDataExchange(CDataExchange* pDX)
+{
+	CDialog::DoDataExchange(pDX);
+	//{{AFX_DATA_MAP(STATManageConnection)
+	DDX_Control(pDX, IDC_ADDRESS, m_Address);
+	DDX_Control(pDX, IDC_TRANSPORT, m_Transport);
+	DDX_Control(pDX, IDC_LISTCONNECTIONS, m_ListConnections);
+	//}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(STATManageConnection, CDialog)
+	//{{AFX_MSG_MAP(STATManageConnection)
+	ON_BN_CLICKED(IDC_REMOVE, OnRemove)
+	ON_BN_CLICKED(IDC_ADD, OnAdd)
+	ON_LBN_SELCHANGE(IDC_LISTCONNECTIONS, OnSelchangeListconnections)
+	ON_CBN_SELCHANGE(IDC_TRANSPORT, OnSelchangeTransport)
+	//}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// STATManageConnection message handlers
+
+BOOL STATManageConnection::OnInitDialog()
+{
+	CDialog::OnInitDialog();
+
+	cConnectionInfo.ReleaseBuffer();
+	m_Transport.SetCurSel(2);
+	statIniFile.SetIniFileName(STAT_INI_NAME);
+		CString setting;
+//	lCount = 0;
+	if(statIniFile.SectionExists(ST_TEST_KEY) )
+	{
+
+		lCount = 0;
+		setting.Empty();
+		setting=statIniFile.GetKeyValue(ST_CONNECTIONIDX,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			lCount = _ttol(setting);
+			m_ListConnections.SetCurSel(lCount);
+			OnSelchangeListconnections();
+		}
+	}
+
+	if(statIniFile.SectionExists(ST_CONNECTION_LIST) )
+	{
+		for( int i=0;i<lCount;++i)
+		{
+			TCHAR buf[6];
+			_ltot(i+1, buf, 10);
+			setting.Empty();
+			setting=statIniFile.GetKeyValue(buf,ST_CONNECTION_LIST);
+			if(!setting.IsEmpty())
+				m_ListConnections.AddString(setting);
+		}
+	}
+	return TRUE;
+}
+
+
+void STATManageConnection::OnAdd() 
+{
+	CString transport;
+	CString address;
+	switch(m_Transport.GetCurSel())
+	{
+	case 0:	// socket
+		transport = "SymbianSocket:";
+		break;
+	case 1:	// serial
+		transport = "SymbianSerial:";
+		break;
+	case 2:	// infra-red
+		transport = "SymbianInfrared:";
+		break;
+	case 3:	// bluetooth
+		transport = "SymbianBluetooth:";
+		break;
+	case 4:	// usb
+
+		//break;
+	default:
+		return;
+	}
+
+	m_Address.GetWindowText(address);
+	transport += address;
+
+	if (!transport.IsEmpty() && !InList(transport))
+	{
+		m_ListConnections.AddString(transport);
+		// highlight it in the list
+		m_ListConnections.SetCurSel(m_ListConnections.FindStringExact(0, transport.GetBuffer(0)));
+	}
+	else
+		AfxMessageBox(_T("This configuration already exists in the list."));
+}
+
+void STATManageConnection::OnRemove() 
+{
+	int index = m_ListConnections.GetCurSel();
+	if (index != LB_ERR)
+	{
+		m_ListConnections.DeleteString(index);
+		m_ListConnections.SetCurSel(0);
+		OnSelchangeListconnections();
+	}
+}
+
+void STATManageConnection::OnOK() 
+{
+	int index = m_ListConnections.GetCurSel();
+	if (index != LB_ERR)
+	{
+		CString item;
+		TCHAR buf[16];
+		CWaitCursor oWait;
+		m_ListConnections.GetText(index, cConnectionInfo);
+		lCount=m_ListConnections.GetCount();
+		_ltot(lCount, buf, 10);
+		statIniFile.WriteKey(buf,ST_CONNECTIONIDX,ST_TEST_KEY);
+		//empty connection list
+		statIniFile.DeleteSection(ST_CONNECTION_LIST);
+		for( int i=0;i<lCount;++i)
+		{
+			_ltot(i+1, buf, 10);
+			m_ListConnections.GetText(i, item);
+			statIniFile.WriteKey(item,buf,ST_CONNECTION_LIST);
+		}
+		CDialog::OnOK();
+	}
+}
+
+void STATManageConnection::OnCancel() 
+{
+	cConnectionInfo.ReleaseBuffer();
+	CDialog::OnCancel();
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// 
+bool STATManageConnection::InList(CString & Entry)
+{
+	CString item;
+	int iCount = m_ListConnections.GetCount();
+	for (int i=0;i<iCount;i++)
+	{
+		m_ListConnections.GetText(i, item);
+
+		if (item.Compare(Entry.GetBuffer(0)) == 0)
+		{
+			return true;
+		}
+	}
+
+	return false;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Converts a char * to it's Unicode equivalent
+//
+LPTSTR STATManageConnection::ToUnicode(const char *string)
+{
+#ifdef UNICODE
+	static TCHAR szBuffer[MAX_UNICODE_LEN + 1] = {0};
+	szBuffer[0] = (TCHAR)0;
+
+    // Convert to UNICODE.
+    if (!MultiByteToWideChar(CP_ACP,					// conversion type
+							 0,							// flags
+							 string,					// source
+							 -1,						// length
+							 szBuffer,					// dest
+							 MAX_UNICODE_LEN))			// length
+    {
+        return _T("Could not convert");
+    }
+
+    return szBuffer;
+#else
+	return (LPTSTR)string;
+#endif
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Converts a Unicode to it's char * equivalent
+//
+char * STATManageConnection::ToAnsi(LPCTSTR string)
+{
+#ifdef UNICODE
+	static char szBuffer[MAX_UNICODE_LEN + 1] = {0};
+	szBuffer[0] = (char)0;
+
+    // Convert to ANSI.
+    if (!WideCharToMultiByte(CP_ACP,					// conversion type
+							 0,							// flags
+							 string,					// source
+							 -1,						// length
+							 szBuffer,					// dest
+							 MAX_UNICODE_LEN,			// length
+							 NULL,
+							 NULL ))
+    {
+        return "Could not convert";
+    }
+
+    return szBuffer;
+#else
+	return (char *)string;
+#endif
+}
+
+
+void STATManageConnection::OnSelchangeListconnections() 
+{
+	CString item;
+	int index = m_ListConnections.GetCurSel();
+	if (index != LB_ERR)
+	{
+		m_ListConnections.GetText(index, item);
+
+		int i = item.Find(_T(':'));
+		if (i != -1)
+		{
+			CString transport = item.Left(i);
+
+			if (transport.CompareNoCase(_T("SymbianSocket")) == 0)
+			{
+				m_Transport.SetCurSel(SymbianSocket - 1);
+			}
+			else if (transport.CompareNoCase(_T("SymbianSerial")) == 0)
+			{
+				m_Transport.SetCurSel(SymbianSerial - 1);
+			}
+			else if (transport.CompareNoCase(_T("SymbianInfrared")) == 0)
+			{
+				m_Transport.SetCurSel(SymbianInfrared - 1);
+			}
+			else if (transport.CompareNoCase(_T("SymbianBluetooth")) == 0)
+			{
+				m_Transport.SetCurSel(SymbianBluetooth - 1);
+			}
+			else if (transport.CompareNoCase(_T("SymbianUsb")) == 0)
+			{
+
+			}
+
+			m_Address.SetWindowText(item.Mid(i + 1));
+		}
+	}
+}
+
+void STATManageConnection::OnSelchangeTransport() 
+{
+	// If the user has clicked to a selection of the transport
+	// list then we warn them if they selected 'USB'.
+
+	CString item;
+	int index = m_Transport.GetCurSel();
+	if (index != LB_ERR)
+	{
+		m_Transport.GetLBText(index, item);
+
+		if ((item.CompareNoCase(_T("SymbianInfrared")) == 0) ||
+			(item.CompareNoCase(_T("SymbianBluetooth")) == 0))
+		{
+			// If the transport selection is infrared we show a 
+			// warning that infrared is treated the same as 
+			// serial and specify that the user should enter a 
+			// port number in the address field.
+			CString	symbian;
+			CString	appName;
+			CString	prompt;
+
+			if( ( symbian.LoadString( IDS_SYMBIAN ) ) &&
+				( appName.LoadString( IDS_APPNAME ) ) &&
+				( prompt.LoadString( IDS_PORTPROMPT ) ) )
+			{
+				CString	msg;
+				msg.Format( prompt, symbian, appName );
+
+				::AfxMessageBox( msg );
+			}
+		}
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/desktop/src/stdafx.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#include "stdafx.h"
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/desktop/statdesktop.dep	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,59 @@
+# Microsoft Developer Studio Generated Dependency File, included by STATDesktop.mak
+
+..\common\src\INI.cpp : \
+	"..\common\inc\INI.h"\
+	
+
+.\src\STATDesktop.cpp : \
+	"..\lib\inc\cstatreturncodes.h"\
+	"..\lib\inc\messagereporter.h"\
+	"..\lib\inc\scriptprogressmonitor.h"\
+	"..\lib\inc\statcommon.h"\
+	"..\lib\inc\statexp.h"\
+	"..\common\inc\INI.h"\
+	".\inc\LogMessage.h"\
+	".\inc\MessageReporterImp.h"\
+	".\inc\resource.h"\
+	".\inc\STATDesktop.h"\
+	".\inc\STATDesktopDlg.h"\
+	".\inc\WindowMessages.h"\
+	
+
+.\src\statdesktop.rc : \
+	".\inc\resource.h"\
+	".\res\STATDesktop.ico"\
+	".\res\STATDesktop.rc2"\
+	
+
+.\src\STATDesktopDlg.cpp : \
+	"..\lib\inc\cstatreturncodes.h"\
+	"..\lib\inc\messagereporter.h"\
+	"..\lib\inc\scriptprogressmonitor.h"\
+	"..\lib\inc\statcommon.h"\
+	"..\lib\inc\statexp.h"\
+	"..\common\inc\INI.h"\
+	".\inc\LogMessage.h"\
+	".\inc\MessageReporterImp.h"\
+	".\inc\resource.h"\
+	".\inc\ScriptProgressMonitorImp.h"\
+	".\inc\STATDesktop.h"\
+	".\inc\STATDesktopDlg.h"\
+	".\inc\STATManageConnection.h"\
+	".\inc\WindowMessages.h"\
+	
+
+.\src\STATManageConnection.cpp : \
+	"..\lib\inc\cstatreturncodes.h"\
+	"..\lib\inc\messagereporter.h"\
+	"..\lib\inc\scriptprogressmonitor.h"\
+	"..\lib\inc\statcommon.h"\
+	"..\lib\inc\statexp.h"\
+	"..\common\inc\INI.h"\
+	".\inc\resource.h"\
+	".\inc\STATDesktop.h"\
+	".\inc\STATManageConnection.h"\
+	
+
+.\src\StdAfx.cpp : \
+	".\inc\StdAfx.h"\
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/desktop/statdesktop.dsp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,193 @@
+# Microsoft Developer Studio Project File - Name="STATDesktop" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Application" 0x0101
+
+CFG=STATDesktop - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "STATDesktop.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "STATDesktop.mak" CFG="STATDesktop - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "STATDesktop - Win32 Release" (based on "Win32 (x86) Application")
+!MESSAGE "STATDesktop - Win32 Debug" (based on "Win32 (x86) Application")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName "STATDesktop"
+# PROP Scc_LocalPath "."
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "STATDesktop - Win32 Release"
+
+# PROP BASE Use_MFC 5
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 5
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Yu".\inc\stdafx.h" /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I ".\inc" /I "\epoc32\tools\stat\headers" /I "..\common\inc" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "WINDOWS" /FR /Yu"stdafx.h" /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
+# ADD LINK32 Ws2_32.lib /nologo /subsystem:windows /machine:I386 /out:"..\..\bin\STATDesktop.exe"
+# SUBTRACT LINK32 /pdb:none /debug
+# Begin Special Build Tool
+ProjDir=.
+SOURCE="$(InputPath)"
+PostBuild_Desc=Performing Custom Build Step on STATDesktop
+PostBuild_Cmds=$(ProjDir)\UpdateDesktop.bat
+# End Special Build Tool
+
+!ELSEIF  "$(CFG)" == "STATDesktop - Win32 Debug"
+
+# PROP BASE Use_MFC 5
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 5
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /Yu".\inc\stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I ".\inc" /I "\epoc32\tools\stat\headers" /I "..\common\inc" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "WINDOWS" /FR /FD /GZ /c
+# SUBTRACT CPP /YX /Yc /Yu
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 WS2_32.lib /nologo /subsystem:windows /incremental:no /debug /machine:I386 /out:"..\..\bin\STATDesktopd.exe" /pdbtype:sept
+
+!ENDIF 
+
+# Begin Target
+
+# Name "STATDesktop - Win32 Release"
+# Name "STATDesktop - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\common\src\INI.cpp
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\STATDesktop.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\STATDesktop.dep
+# End Source File
+# Begin Source File
+
+SOURCE=.\STATDesktop.mak
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\statdesktop.rc
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\STATDesktopDlg.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\STATManageConnection.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\StdAfx.cpp
+# ADD CPP /Yc"stdafx.h"
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\common\inc\INI.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\LogMessage.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\MessageReporterImp.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\resource.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\ScriptProgressMonitorImp.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\STATDesktop.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\STATDesktopDlg.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\STATManageConnection.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\StdAfx.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\WindowMessages.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# Begin Source File
+
+SOURCE=.\res\STATDesktop.ico
+# End Source File
+# Begin Source File
+
+SOURCE=.\res\STATDesktop.rc2
+# End Source File
+# End Group
+# End Target
+# End Project
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/desktop/statdesktop.mak	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,304 @@
+# Microsoft Developer Studio Generated NMAKE File, Based on STATDesktop.dsp
+!IF "$(CFG)" == ""
+CFG=STATDesktop - Win32 Debug
+!MESSAGE No configuration specified. Defaulting to STATDesktop - Win32 Debug.
+!ENDIF 
+
+!IF "$(CFG)" != "STATDesktop - Win32 Release" && "$(CFG)" != "STATDesktop - Win32 Debug"
+!MESSAGE Invalid configuration "$(CFG)" specified.
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "STATDesktop.mak" CFG="STATDesktop - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "STATDesktop - Win32 Release" (based on "Win32 (x86) Application")
+!MESSAGE "STATDesktop - Win32 Debug" (based on "Win32 (x86) Application")
+!MESSAGE 
+!ERROR An invalid configuration is specified.
+!ENDIF 
+
+!IF "$(OS)" == "Windows_NT"
+NULL=
+!ELSE 
+NULL=nul
+!ENDIF 
+
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "STATDesktop - Win32 Release"
+
+OUTDIR=.\Release
+INTDIR=.\Release
+# Begin Custom Macros
+OutDir=.\Release
+# End Custom Macros
+
+ALL : "..\..\bin\STATDesktop.exe" "$(OUTDIR)\STATDesktop.bsc"
+
+
+CLEAN :
+	-@erase "$(INTDIR)\INI.obj"
+	-@erase "$(INTDIR)\INI.sbr"
+	-@erase "$(INTDIR)\STATDesktop.obj"
+	-@erase "$(INTDIR)\STATDesktop.pch"
+	-@erase "$(INTDIR)\statdesktop.res"
+	-@erase "$(INTDIR)\STATDesktop.sbr"
+	-@erase "$(INTDIR)\STATDesktopDlg.obj"
+	-@erase "$(INTDIR)\STATDesktopDlg.sbr"
+	-@erase "$(INTDIR)\STATManageConnection.obj"
+	-@erase "$(INTDIR)\STATManageConnection.sbr"
+	-@erase "$(INTDIR)\StdAfx.obj"
+	-@erase "$(INTDIR)\StdAfx.sbr"
+	-@erase "$(INTDIR)\vc60.idb"
+	-@erase "$(OUTDIR)\STATDesktop.bsc"
+	-@erase "..\..\bin\STATDesktop.exe"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MT /W3 /GX /O2 /I ".\inc" /I "..\common\inc" /I "..\lib\inc" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "WINDOWS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\STATDesktop.pch" /Yu"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
+RSC_PROJ=/l 0x809 /fo"$(INTDIR)\statdesktop.res" /d "NDEBUG" 
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\STATDesktop.bsc" 
+BSC32_SBRS= \
+	"$(INTDIR)\INI.sbr" \
+	"$(INTDIR)\STATDesktop.sbr" \
+	"$(INTDIR)\STATDesktopDlg.sbr" \
+	"$(INTDIR)\STATManageConnection.sbr" \
+	"$(INTDIR)\StdAfx.sbr"
+
+"$(OUTDIR)\STATDesktop.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+    $(BSC32) @<<
+  $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=Ws2_32.lib /nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)\STATDesktop.pdb" /machine:I386 /out:"..\..\bin\STATDesktop.exe" 
+LINK32_OBJS= \
+	"$(INTDIR)\INI.obj" \
+	"$(INTDIR)\STATDesktop.obj" \
+	"$(INTDIR)\STATDesktopDlg.obj" \
+	"$(INTDIR)\STATManageConnection.obj" \
+	"$(INTDIR)\StdAfx.obj" \
+	"$(INTDIR)\statdesktop.res"
+
+"..\..\bin\STATDesktop.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+    $(LINK32) @<<
+  $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+ProjDir=.
+SOURCE="$(InputPath)"
+PostBuild_Desc=Performing Custom Build Step on STATDesktop
+DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep
+
+ALL : $(DS_POSTBUILD_DEP)
+
+# Begin Custom Macros
+OutDir=.\Release
+# End Custom Macros
+
+$(DS_POSTBUILD_DEP) : "..\..\bin\STATDesktop.exe" "$(OUTDIR)\STATDesktop.bsc"
+   .\UpdateDesktop.bat
+	echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)"
+
+!ELSEIF  "$(CFG)" == "STATDesktop - Win32 Debug"
+
+OUTDIR=.\Debug
+INTDIR=.\Debug
+# Begin Custom Macros
+OutDir=.\Debug
+# End Custom Macros
+
+ALL : "..\..\bin\STATDesktopd.exe" "$(OUTDIR)\STATDesktop.bsc"
+
+
+CLEAN :
+	-@erase "$(INTDIR)\INI.obj"
+	-@erase "$(INTDIR)\INI.sbr"
+	-@erase "$(INTDIR)\STATDesktop.obj"
+	-@erase "$(INTDIR)\STATDesktop.pch"
+	-@erase "$(INTDIR)\statdesktop.res"
+	-@erase "$(INTDIR)\STATDesktop.sbr"
+	-@erase "$(INTDIR)\STATDesktopDlg.obj"
+	-@erase "$(INTDIR)\STATDesktopDlg.sbr"
+	-@erase "$(INTDIR)\STATManageConnection.obj"
+	-@erase "$(INTDIR)\STATManageConnection.sbr"
+	-@erase "$(INTDIR)\StdAfx.obj"
+	-@erase "$(INTDIR)\StdAfx.sbr"
+	-@erase "$(INTDIR)\vc60.idb"
+	-@erase "$(INTDIR)\vc60.pdb"
+	-@erase "$(OUTDIR)\STATDesktop.bsc"
+	-@erase "$(OUTDIR)\STATDesktopd.pdb"
+	-@erase "..\..\bin\STATDesktopd.exe"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MTd /W3 /Gm /GX /Zi /Od /I ".\inc"  /I "..\common\inc" /I "..\lib\inc" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "WINDOWS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\STATDesktop.pch" /Yu"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c 
+MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
+RSC_PROJ=/l 0x809 /fo"$(INTDIR)\statdesktop.res" /d "_DEBUG" 
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\STATDesktop.bsc" 
+BSC32_SBRS= \
+	"$(INTDIR)\INI.sbr" \
+	"$(INTDIR)\STATDesktop.sbr" \
+	"$(INTDIR)\STATDesktopDlg.sbr" \
+	"$(INTDIR)\STATManageConnection.sbr" \
+	"$(INTDIR)\StdAfx.sbr"
+
+"$(OUTDIR)\STATDesktop.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+    $(BSC32) @<<
+  $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=WS2_32.lib /nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)\STATDesktopd.pdb" /debug /machine:I386 /out:"..\..\bin\STATDesktopd.exe" /pdbtype:sept 
+LINK32_OBJS= \
+	"$(INTDIR)\INI.obj" \
+	"$(INTDIR)\STATDesktop.obj" \
+	"$(INTDIR)\STATDesktopDlg.obj" \
+	"$(INTDIR)\STATManageConnection.obj" \
+	"$(INTDIR)\StdAfx.obj" \
+	"$(INTDIR)\statdesktop.res"
+
+"..\..\bin\STATDesktopd.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+    $(LINK32) @<<
+  $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ENDIF 
+
+.c{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cpp{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cxx{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.c{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cpp{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cxx{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+
+!IF "$(NO_EXTERNAL_DEPS)" != "1"
+!IF EXISTS("STATDesktop.dep")
+!INCLUDE "STATDesktop.dep"
+!ELSE 
+!MESSAGE Warning: cannot find "STATDesktop.dep"
+!ENDIF 
+!ENDIF 
+
+
+!IF "$(CFG)" == "STATDesktop - Win32 Release" || "$(CFG)" == "STATDesktop - Win32 Debug"
+SOURCE=..\common\src\INI.cpp
+
+!IF  "$(CFG)" == "STATDesktop - Win32 Release"
+
+CPP_SWITCHES=/nologo /MT /W3 /GX /O2 /I ".\inc" /I "..\common\inc" /I "..\lib\inc" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "WINDOWS" /FR"$(INTDIR)\\" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+
+"$(INTDIR)\INI.obj"	"$(INTDIR)\INI.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) @<<
+  $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ELSEIF  "$(CFG)" == "STATDesktop - Win32 Debug"
+
+CPP_SWITCHES=/nologo /MTd /W3 /Gm /GX /Zi /Od /I ".\inc" /I "..\common\inc" /I "..\lib\inc" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "WINDOWS" /FR"$(INTDIR)\\" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c 
+
+"$(INTDIR)\INI.obj"	"$(INTDIR)\INI.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) @<<
+  $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ENDIF 
+
+SOURCE=.\src\STATDesktop.cpp
+
+"$(INTDIR)\STATDesktop.obj"	"$(INTDIR)\STATDesktop.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\STATDesktop.pch"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=.\src\statdesktop.rc
+
+!IF  "$(CFG)" == "STATDesktop - Win32 Release"
+
+
+"$(INTDIR)\statdesktop.res" : $(SOURCE) "$(INTDIR)"
+	$(RSC) /l 0x809 /fo"$(INTDIR)\statdesktop.res" /i "src" /d "NDEBUG" $(SOURCE)
+
+
+!ELSEIF  "$(CFG)" == "STATDesktop - Win32 Debug"
+
+
+"$(INTDIR)\statdesktop.res" : $(SOURCE) "$(INTDIR)"
+	$(RSC) /l 0x809 /fo"$(INTDIR)\statdesktop.res" /i "src" /d "_DEBUG" $(SOURCE)
+
+
+!ENDIF 
+
+SOURCE=.\src\STATDesktopDlg.cpp
+
+"$(INTDIR)\STATDesktopDlg.obj"	"$(INTDIR)\STATDesktopDlg.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\STATDesktop.pch"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=.\src\STATManageConnection.cpp
+
+"$(INTDIR)\STATManageConnection.obj"	"$(INTDIR)\STATManageConnection.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\STATDesktop.pch"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=.\src\StdAfx.cpp
+
+!IF  "$(CFG)" == "STATDesktop - Win32 Release"
+
+CPP_SWITCHES=/nologo /MT /W3 /GX /O2 /I ".\inc"  /I "..\common\inc" /I "..\lib\inc" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "WINDOWS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\STATDesktop.pch" /Yc"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+
+"$(INTDIR)\StdAfx.obj"	"$(INTDIR)\StdAfx.sbr"	"$(INTDIR)\STATDesktop.pch" : $(SOURCE) "$(INTDIR)"
+	$(CPP) @<<
+  $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ELSEIF  "$(CFG)" == "STATDesktop - Win32 Debug"
+
+CPP_SWITCHES=/nologo /MTd /W3 /Gm /GX /Zi /Od /I ".\inc"  /I "..\common\inc" /I "..\lib\inc" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "WINDOWS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\STATDesktop.pch" /Yc"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c 
+
+"$(INTDIR)\StdAfx.obj"	"$(INTDIR)\StdAfx.sbr"	"$(INTDIR)\STATDesktop.pch" : $(SOURCE) "$(INTDIR)"
+	$(CPP) @<<
+  $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ENDIF 
+
+
+!ENDIF 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/desktop/updatedesktop.bat	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,34 @@
+@rem
+@rem Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description: 
+@rem
+@@rem
+
+rem
+rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+
+rem which accompanies this distribution, and is available
+
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+copy ..\..\bin\statdesktop.exe \epoc32\tools\stat\statdesktop.exe
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/dll/group/bld.inf	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,50 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:  
+//
+
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+
+* which accompanies this distribution, and is available
+
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+PRJ_PLATFORMS
+
+TOOLS
+
+PRJ_EXPORTS
+
+..\..\lib\inc\cstatreturncodes.h	\epoc32\tools\stat\headers\cstatreturncodes.h
+..\..\lib\inc\ScriptProgressMonitor.h	\epoc32\tools\stat\headers\scriptprogressmonitor.h
+..\..\lib\inc\MessageReporter.h	\epoc32\tools\stat\headers\messagereporter.h
+..\..\lib\inc\stat.h			\epoc32\tools\stat\headers\stat.h
+..\..\lib\inc\statcommon.h		\epoc32\tools\stat\headers\statcommon.h
+..\..\lib\inc\statexp.h			\epoc32\tools\stat\headers\statexp.h
+
+PRJ_MMPFILES
+// Extension Makefile
+makefile statdll.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/dll/group/statdll.mk	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,85 @@
+#
+# Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:  
+#
+
+# which accompanies this distribution, and is available
+
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+# Typically C:\apps\MSVC6\VC98\Bin
+COMPILER=nmake
+
+# Called with
+#
+# $(PLATFORM) = TOOLS
+# $(CFG)      = DEB, REL
+
+BLD	:  
+	@echo BLD called with $(PLATFORM)$(CFG)
+	
+# release version
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "REL"
+	-mkdir "$(EPOCROOT)epoc32\tools\STAT"
+
+# Go up one level to access the makefile
+	cd ".."
+
+# Execute the command line compiler (DLL)
+	"$(COMPILER)" /A /NOLOGO /f "STATdll.mak" CFG="STATDll - Win32 Release"
+	
+	echo ** STAT DLL (RELEASE) compiled successfully
+
+!endif
+
+# debug version
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "DEB"
+
+# Go up one level to access the makefile
+	cd ".."
+
+# Execute the command line compiler (DLL)
+	"$(COMPILER)" /A /NOLOGO /f "STATdll.mak" CFG="STATDll - Win32 Debug"
+	
+	echo ** STAT DLL (DEBUG) compiled successfully
+
+!endif
+
+CLEAN :
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "REL"
+	-rmdir "..\Release" /q /s
+!endif
+
+CLEAN :
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "DEB"
+	-rmdir "..\Debug" /q /s
+!endif
+
+RELEASABLES :
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "REL"
+	@echo $(EPOCROOT)epoc32\tools\STAT\stat.dll
+	@echo $(EPOCROOT)epoc32\tools\STAT\stat.exp
+	@echo $(EPOCROOT)epoc32\tools\STAT\stat.lib
+!endif
+
+SAVESPACE : BLD
+
+MAKMAKE LIB CLEANLIB RESOURCE FREEZE FINAL : 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/dll/inc/resource.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by M:\D\P4work\DP\development\project\2008\preq2582\sf\ana\testexec\testtoolsconn\stat\Desktop\source\dll\src\STATDll.rc
+//
+
+// Next default values for new objects
+// 
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE        1000
+#define _APS_NEXT_COMMAND_VALUE         32771
+#define _APS_NEXT_CONTROL_VALUE         1000
+#define _APS_NEXT_SYMED_VALUE           1000
+#endif
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/dll/inc/stdafx.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#if !defined(AFX_STDAFX_H__8550F158_DA78_11D5_BC49_00B0D065107F__INCLUDED_)
+#define AFX_STDAFX_H__8550F158_DA78_11D5_BC49_00B0D065107F__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define VC_EXTRALEAN		// Exclude rarely-used stuff from Windows headers
+
+#include <assert.h>
+
+//#include <afxwin.h>         // MFC core and standard components
+//#include <afxext.h>         // MFC extensions
+
+//#ifndef _AFX_NO_OLE_SUPPORT
+//#include <afxole.h>         // MFC OLE classes
+//#include <afxodlgs.h>       // MFC OLE dialog classes
+//#include <afxdisp.h>        // MFC Automation classes
+//#endif // _AFX_NO_OLE_SUPPORT
+
+
+//#ifndef _AFX_NO_DB_SUPPORT
+//#include <afxdb.h>			// MFC ODBC database classes
+//#endif // _AFX_NO_DB_SUPPORT
+
+//#ifndef _AFX_NO_DAO_SUPPORT
+//#include <afxdao.h>			// MFC DAO database classes
+//#endif // _AFX_NO_DAO_SUPPORT
+
+#include <afxdtctl.h>		// MFC support for Internet Explorer 4 Common Controls
+//#ifndef _AFX_NO_AFXCMN_SUPPORT
+//#include <afxcmn.h>			// MFC support for Windows Common Controls
+//#endif // _AFX_NO_AFXCMN_SUPPORT
+
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__8550F158_DA78_11D5_BC49_00B0D065107F__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/dll/res/stat.rc2	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,13 @@
+//
+// STAT.RC2 - resources Microsoft Visual C++ does not edit directly
+//
+
+#ifdef APSTUDIO_INVOKED
+	#error this file is not editable by Microsoft Visual C++
+#endif //APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Add manually edited resources here...
+
+/////////////////////////////////////////////////////////////////////////////
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/dll/src/statdll.rc	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,145 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "../inc/resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifndef _MAC
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,0,0,1
+ PRODUCTVERSION 1,0,0,1
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904b0"
+        BEGIN
+            VALUE "Comments", "Test Automation DLL\0"
+            VALUE "CompanyName", "Nokia Corporation\0"
+            VALUE "FileDescription", "Nokia Test Automation Tool Dynamic Link Library\0"
+            VALUE "FileVersion", "4.0\0"
+            VALUE "InternalName", "STAT\0"
+            VALUE "LegalCopyright", "Copyright (C) 2005-2009 Nokia Corporation\0"
+            VALUE "LegalTrademarks", "STAT\0"
+            VALUE "OriginalFilename", "STAT.DLL\0"
+            VALUE "PrivateBuild", "\0"
+            VALUE "ProductName", "Nokia Test Automation Tool Dynamic Link Library\0"
+            VALUE "ProductVersion", "4.0\0"
+            VALUE "SpecialBuild", "\0"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x409, 1200
+    END
+END
+
+#endif    // !_MAC
+
+#endif    // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.K.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "..\\inc\\resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "#include ""afxres.h""\r\n"
+    "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
+    "#define _AFX_NO_OLE_RESOURCES\r\n"
+    "#define _AFX_NO_TRACKER_RESOURCES\r\n"
+    "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
+    "\r\n"
+    "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
+    "#ifdef _WIN32\r\n"
+    "LANGUAGE 9, 1\r\n"
+    "#pragma code_page(1252)\r\n"
+    "#endif //_WIN32\r\n"
+    "#include ""..\\res\\stat.rc2""  // non-Microsoft Visual C++ edited resources\r\n"
+    "#include ""afxres.rc""         // Standard components\r\n"
+    "#endif\r\n"
+    "\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+#endif    // English (U.K.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+#define _AFX_NO_SPLITTER_RESOURCES
+#define _AFX_NO_OLE_RESOURCES
+#define _AFX_NO_TRACKER_RESOURCES
+#define _AFX_NO_PROPERTY_RESOURCES
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE 9, 1
+#pragma code_page(1252)
+#endif //_WIN32
+#include "../res/stat.rc2"  // non-Microsoft Visual C++ edited resources
+#include "afxres.rc"         // Standard components
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+#endif    // not APSTUDIO_INVOKED
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/dll/src/stdafx.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#include "stdafx.h"
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/dll/stat.def	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,45 @@
+LIBRARY stat
+EXPORTS
+	Version
+	GetError
+	GetErrorText
+	SetConnectionLogging
+	CloseConnectionLogging
+	Connect
+	ConnectMT
+	Disconnect
+	SetCommandDelay
+	SetCommandLogging
+	SetImageVerification
+	GetCommandCount
+	GetCurrentCommandNumber
+	OpenScriptFile
+	RunScript
+	SendRawCommand
+	SendCommandFile
+	StopProcessing
+	GetSnapshot
+	GetTEFSharedData
+	GetReceivedData
+
+	StdVersion 							= _StdVersion@0
+	StdSetConnectionLogging				= _StdSetConnectionLogging@4
+	StdCloseConnectionLogging			= _StdCloseConnectionLogging@0
+	StdDisconnect 						= _StdDisconnect@4
+	StdGetCommandCount					= _StdGetCommandCount@12
+	StdGetCurrentCommandNumber			= _StdGetCurrentCommandNumber@8
+	StdOpenScriptFile					= _StdOpenScriptFile@12
+	StdRunScript						= _StdRunScript@8
+	StdSendRawCommand 					= _StdSendRawCommand@12
+	StdSendCommandFile 					= _StdSendCommandFile@12
+	StdStopProcessing					= _StdStopProcessing@4
+	StdGetError							= _StdGetError@4
+	StdGetErrorText						= _StdGetErrorText@8
+	StdConnect							= _StdConnect@16
+	StdConnectMT						= _StdConnectMT@8
+	StdSetCommandDelay					= _StdSetCommandDelay@8
+	StdSetCommandLogging				= _StdSetCommandLogging@28
+	StdSetImageVerification 			= _StdSetImageVerification@16
+	StdGetSnapshot						= _StdGetSnapshot@20
+	StdGetTEFSharedData					= _StdGetTEFSharedData@4
+	StdGetReceivedData					= _StdGetReceivedData@4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/dll/statd.def	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,45 @@
+LIBRARY statd
+EXPORTS
+	Version
+	GetError
+	GetErrorText
+	SetConnectionLogging
+	CloseConnectionLogging
+	Connect
+	ConnectMT
+	Disconnect
+	SetCommandDelay
+	SetCommandLogging
+	SetImageVerification
+	GetCommandCount
+	GetCurrentCommandNumber
+	OpenScriptFile
+	RunScript
+	SendRawCommand
+	SendCommandFile
+	StopProcessing
+	GetSnapshot
+	GetTEFSharedData
+	GetReceivedData
+
+	StdVersion 							= _StdVersion@0
+	StdSetConnectionLogging				= _StdSetConnectionLogging@4
+	StdCloseConnectionLogging			= _StdCloseConnectionLogging@0
+	StdDisconnect 						= _StdDisconnect@4
+	StdGetCommandCount					= _StdGetCommandCount@12
+	StdGetCurrentCommandNumber			= _StdGetCurrentCommandNumber@8
+	StdOpenScriptFile					= _StdOpenScriptFile@12
+	StdRunScript						= _StdRunScript@8
+	StdSendRawCommand 					= _StdSendRawCommand@12
+	StdSendCommandFile 					= _StdSendCommandFile@12
+	StdStopProcessing					= _StdStopProcessing@4
+	StdGetError							= _StdGetError@4
+	StdGetErrorText						= _StdGetErrorText@8
+	StdConnect							= _StdConnect@16
+	StdConnectMT						= _StdConnectMT@8
+	StdSetCommandDelay					= _StdSetCommandDelay@8
+	StdSetCommandLogging				= _StdSetCommandLogging@28
+	StdSetImageVerification 			= _StdSetImageVerification@16
+	StdGetSnapshot						= _StdGetSnapshot@20
+	StdGetTEFSharedData					= _StdGetTEFSharedData@4
+	StdGetReceivedData					= _StdGetReceivedData@4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/dll/statdll.dep	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,10 @@
+# Microsoft Developer Studio Generated Dependency File, included by STATdll.mak
+
+.\src\statdll.rc : \
+	".\inc\resource.h"\
+	".\res\stat.rc2"\
+	
+
+.\src\StdAfx.cpp : \
+	".\inc\StdAfx.h"\
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/dll/statdll.dsp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,142 @@
+# Microsoft Developer Studio Project File - Name="STATDll" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=STATDll - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "STATdll.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "STATdll.mak" CFG="STATDll - Win32 Release"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "STATDll - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "STATDll - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName "STATDll"
+# PROP Scc_LocalPath "."
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "STATDll - Win32 Release"
+
+# PROP BASE Use_MFC 5
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 5
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "\epoc32\tools\stat"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WINDLL" /Yu".\inc\stdafx.h" /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I ".\inc" /I "..\lib\inc" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "WINDOWS" /D "_WINDLL" /D "_USRDLL" /FR /Yu"stdafx.h" /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo /o"Release/STATdll.bsc"
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:windows /dll /machine:I386
+# ADD LINK32 Ws2_32.lib ..\..\lib\Stat.lib /nologo /subsystem:windows /dll /pdb:none /machine:I386 /nodefaultlib:"libcmtd.lib" /def:".\stat.def" /out:"..\..\bin\STAT.dll" /implib:"..\..\lib\STATDll.lib" /OPT:NOREF
+# Begin Special Build Tool
+ProjDir=.
+SOURCE="$(InputPath)"
+PostBuild_Desc=Copying browse data...
+PostBuild_Cmds=$(ProjDir)\UpdateDll.bat	copy release\statdll.bsc \epoc32\tools\stat\statdll.bsc
+# End Special Build Tool
+
+!ELSEIF  "$(CFG)" == "STATDll - Win32 Debug"
+
+# PROP BASE Use_MFC 5
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 5
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_WINDLL" /Yu".\inc\stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I ".\inc" /I "..\lib\inc" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "WINDOWS" /D "_WINDLL" /D "_USRDLL" /FR /FD /GZ /c
+# SUBTRACT CPP /YX /Yc /Yu
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 Ws2_32.lib ..\..\lib\Statd.lib /nologo /subsystem:windows /dll /incremental:no /debug /machine:I386 /def:".\statd.def" /out:"..\..\bin\STATd.dll" /implib:"..\..\lib\STATDlld.lib" /pdbtype:sept
+# SUBTRACT LINK32 /pdb:none
+
+!ENDIF 
+
+# Begin Target
+
+# Name "STATDll - Win32 Release"
+# Name "STATDll - Win32 Debug"
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\inc\resource.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\StdAfx.h
+# End Source File
+# End Group
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\stat.def
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=.\statd.def
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=.\STATdll.dep
+# End Source File
+# Begin Source File
+
+SOURCE=.\STATdll.mak
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\statdll.rc
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\StdAfx.cpp
+# ADD CPP /Yc"stdafx.h"
+# End Source File
+# End Group
+# End Target
+# End Project
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/dll/statdll.mak	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,231 @@
+# Microsoft Developer Studio Generated NMAKE File, Based on STATdll.dsp
+!IF "$(CFG)" == ""
+CFG=STATDll - Win32 Release
+!MESSAGE No configuration specified. Defaulting to STATDll - Win32 Release.
+!ENDIF 
+
+!IF "$(CFG)" != "STATDll - Win32 Release" && "$(CFG)" != "STATDll - Win32 Debug"
+!MESSAGE Invalid configuration "$(CFG)" specified.
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "STATdll.mak" CFG="STATDll - Win32 Release"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "STATDll - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "STATDll - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE 
+!ERROR An invalid configuration is specified.
+!ENDIF 
+
+!IF "$(OS)" == "Windows_NT"
+NULL=
+!ELSE 
+NULL=nul
+!ENDIF 
+
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "STATDll - Win32 Release"
+
+OUTDIR=\epoc32\tools\stat
+INTDIR=.\Release
+
+ALL : "..\..\bin\STAT.dll" ".\Release\STATdll.pch" ".\Release\STATdll.bsc"
+
+
+CLEAN :
+	-@erase "$(INTDIR)\STATdll.pch"
+	-@erase "$(INTDIR)\statdll.res"
+	-@erase "$(INTDIR)\StdAfx.obj"
+	-@erase "$(INTDIR)\StdAfx.sbr"
+	-@erase "$(INTDIR)\vc60.idb"
+	-@erase "..\..\bin\STAT.dll"
+	-@erase "..\..\lib\STATDll.exp"
+	-@erase "..\..\lib\STATDll.lib"
+	-@erase ".\Release\STATdll.bsc"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+"$(INTDIR)" :
+    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
+
+CPP_PROJ=/nologo /MT /W3 /GX /O2 /I ".\inc" /I "..\lib\inc" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "WINDOWS" /D "_WINDLL" /D "_USRDLL" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\STATdll.pch" /Yu"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
+RSC_PROJ=/l 0x809 /fo"$(INTDIR)\statdll.res" /d "NDEBUG" 
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"Release/STATdll.bsc" 
+BSC32_SBRS= \
+	"$(INTDIR)\StdAfx.sbr"
+
+".\Release\STATdll.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+    $(BSC32) @<<
+  $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=Ws2_32.lib ..\..\lib\Stat.lib /nologo /subsystem:windows /dll /pdb:none /machine:I386 /nodefaultlib:"libcmtd.lib" /def:".\stat.def" /out:"..\..\bin\STAT.dll" /implib:"..\..\lib\STATDll.lib" /OPT:NOREF 
+LINK32_OBJS= \
+	"$(INTDIR)\StdAfx.obj" \
+	"$(INTDIR)\statdll.res"
+
+"..\..\bin\STAT.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+    $(LINK32) @<<
+  $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+ProjDir=.
+SOURCE="$(InputPath)"
+PostBuild_Desc=Copying browse data...
+DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep
+
+ALL : $(DS_POSTBUILD_DEP)
+
+$(DS_POSTBUILD_DEP) : "..\..\bin\STAT.dll" ".\Release\STATdll.pch" ".\Release\STATdll.bsc"
+   .\UpdateDll.bat
+	copy release\statdll.bsc \epoc32\tools\stat\statdll.bsc
+	echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)"
+
+!ELSEIF  "$(CFG)" == "STATDll - Win32 Debug"
+
+OUTDIR=.\Debug
+INTDIR=.\Debug
+# Begin Custom Macros
+OutDir=.\Debug
+# End Custom Macros
+
+ALL : "..\..\bin\STATd.dll" "$(OUTDIR)\STATdll.pch" "$(OUTDIR)\STATdll.bsc"
+
+
+CLEAN :
+	-@erase "$(INTDIR)\STATdll.pch"
+	-@erase "$(INTDIR)\statdll.res"
+	-@erase "$(INTDIR)\StdAfx.obj"
+	-@erase "$(INTDIR)\StdAfx.sbr"
+	-@erase "$(INTDIR)\vc60.idb"
+	-@erase "$(INTDIR)\vc60.pdb"
+	-@erase "$(OUTDIR)\STATd.pdb"
+	-@erase "$(OUTDIR)\STATdll.bsc"
+	-@erase "..\..\bin\STATd.dll"
+	-@erase "..\..\lib\STATDlld.exp"
+	-@erase "..\..\lib\STATDlld.lib"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MTd /W3 /Gm /GX /Zi /Od /I ".\inc" /I "..\lib\inc" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "WINDOWS" /D "_WINDLL" /D "_USRDLL" /FR"$(INTDIR)\\" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c 
+MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
+RSC_PROJ=/l 0x809 /fo"$(INTDIR)\statdll.res" /d "_DEBUG" 
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\STATdll.bsc" 
+BSC32_SBRS= \
+	"$(INTDIR)\StdAfx.sbr"
+
+"$(OUTDIR)\STATdll.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+    $(BSC32) @<<
+  $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=Ws2_32.lib ..\..\lib\Statd.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\STATd.pdb" /debug /machine:I386 /def:".\statd.def" /out:"..\..\bin\STATd.dll" /implib:"..\..\lib\STATDlld.lib" /pdbtype:sept 
+LINK32_OBJS= \
+	"$(INTDIR)\StdAfx.obj" \
+	"$(INTDIR)\statdll.res"
+
+"..\..\bin\STATd.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+    $(LINK32) @<<
+  $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ENDIF 
+
+.c{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cpp{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cxx{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.c{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cpp{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cxx{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+
+!IF "$(NO_EXTERNAL_DEPS)" != "1"
+!IF EXISTS("STATdll.dep")
+!INCLUDE "STATdll.dep"
+!ELSE 
+!MESSAGE Warning: cannot find "STATdll.dep"
+!ENDIF 
+!ENDIF 
+
+
+!IF "$(CFG)" == "STATDll - Win32 Release" || "$(CFG)" == "STATDll - Win32 Debug"
+SOURCE=.\src\statdll.rc
+
+!IF  "$(CFG)" == "STATDll - Win32 Release"
+
+
+"$(INTDIR)\statdll.res" : $(SOURCE) "$(INTDIR)"
+	$(RSC) /l 0x809 /fo"$(INTDIR)\statdll.res" /i "src" /d "NDEBUG" $(SOURCE)
+
+
+!ELSEIF  "$(CFG)" == "STATDll - Win32 Debug"
+
+
+"$(INTDIR)\statdll.res" : $(SOURCE) "$(INTDIR)"
+	$(RSC) /l 0x809 /fo"$(INTDIR)\statdll.res" /i "src" /d "_DEBUG" $(SOURCE)
+
+
+!ENDIF 
+
+SOURCE=.\src\StdAfx.cpp
+
+!IF  "$(CFG)" == "STATDll - Win32 Release"
+
+CPP_SWITCHES=/nologo /MT /W3 /GX /O2 /I ".\inc" /I "..\lib\inc" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "WINDOWS" /D "_WINDLL" /D "_USRDLL" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\STATdll.pch" /Yc"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+
+"$(INTDIR)\StdAfx.obj"	"$(INTDIR)\StdAfx.sbr"	"$(INTDIR)\STATdll.pch" : $(SOURCE) "$(INTDIR)"
+	$(CPP) @<<
+  $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ELSEIF  "$(CFG)" == "STATDll - Win32 Debug"
+
+CPP_SWITCHES=/nologo /MTd /W3 /Gm /GX /Zi /Od /I ".\inc" /I "..\lib\inc" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "WINDOWS" /D "_WINDLL" /D "_USRDLL" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\STATdll.pch" /Yc"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c 
+
+"$(INTDIR)\StdAfx.obj"	"$(INTDIR)\StdAfx.sbr"	"$(INTDIR)\STATdll.pch" : $(SOURCE) "$(INTDIR)"
+	$(CPP) @<<
+  $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ENDIF 
+
+
+!ENDIF 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/dll/updatedll.bat	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,40 @@
+@rem
+@rem Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description: 
+@rem
+@@rem
+
+rem
+rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+
+rem which accompanies this distribution, and is available
+
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+copy ..\lib\inc\statexp.h \epoc32\tools\stat\headers\statexp.h
+copy ..\lib\inc\stat.h \epoc32\tools\stat\headers\stat.h
+
+copy ..\..\lib\statdll.lib \epoc32\tools\stat\stat.lib
+copy ..\..\lib\statdll.exp \epoc32\tools\stat\stat.exp
+
+copy ..\..\bin\stat.dll \epoc32\tools\stat\stat.dll
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/group/bld.inf	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,41 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:  
+//
+
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+
+* which accompanies this distribution, and is available
+
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+PRJ_PLATFORMS
+
+TOOLS
+
+PRJ_MMPFILES
+// Extension Makefile
+makefile statlib.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/group/statlib.mk	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,83 @@
+#
+# Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:  
+#
+
+# which accompanies this distribution, and is available
+
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+# Typically C:\apps\MSVC6\VC98\Bin
+COMPILER=nmake
+
+# Called with
+#
+# $(PLATFORM) = TOOLS
+# $(CFG)      = DEB, REL
+
+BLD	:  
+	@echo BLD called with $(PLATFORM)$(CFG)
+
+# release version
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "REL"
+	-mkdir "$(EPOCROOT)epoc32\tools\STAT"
+
+# Go up one level to access the makefile
+	cd ".."
+
+# Execute the command line compiler (LIB)
+	"$(COMPILER)" /A /NOLOGO /f "statlib.mak" CFG="STATLib - Win32 Release"
+	
+	echo ** STAT LIB (RELEASE) compiled successfully
+
+!endif
+
+# debug version
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "DEB"
+
+# Go up one level to access the makefile
+	cd ".."
+
+# Execute the command line compiler (LIB)
+	"$(COMPILER)" /A /NOLOGO /f "statlib.mak" CFG="STATLib - Win32 Debug"
+	
+	echo ** STAT LIB (DEBUG) compiled successfully
+
+!endif
+
+CLEAN :
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "REL"
+	-rmdir "..\Release" /q /s
+!endif
+
+CLEAN :
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "DEB"
+	-rmdir "..\Debug" /q /s
+!endif
+
+RELEASABLES :
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "REL"
+	@echo $(EPOCROOT)epoc32\tools\STAT\stat.lib
+!endif
+
+SAVESPACE : BLD
+
+MAKMAKE LIB CLEANLIB RESOURCE FREEZE FINAL : 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/inc/creporter.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,168 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:     Header file for functions for the Reporter logging mechanism*
+*/
+
+
+
+
+#ifndef CPO_REPORT_HPP
+#define CPO_REPORT_HPP
+
+#include <windows.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+// Comment out this line for release version ...
+// #define RPT_DEBUG_PROG
+
+#define CPO_GARBAGE_CHAR               0xDB    // decimal value ( 3339 )
+#define CPO_TRUE                       1
+#define CPO_FALSE                      0
+#define CPO_BOOL                        unsigned int
+
+#define BITFIELD                       unsigned long
+#define CPO_MAX_FILENAME_LEN           255
+
+// status values
+#define CPO_CLEAR                      0
+#define CPO_CONNECTED                  1  // component currently initiated
+#define CPO_ACTIVATED                  2  // component currently active
+
+
+// Max values for messages
+#define RPT_OPEN_MSG_LEN               2048
+#define RPT_MAX_MSG_LEN                  256
+#define RPT_MAX_PROGRAM_LEN              15
+
+// Max values for message file contents
+#define RPT_MAX_LIST_ENTRIES           1000
+#define RPT_MAX_LINE_LEN                200
+
+// Bit values for the current state 
+#define RPT_CLEAR                         0
+#define RPT_FILE                          4   // Output to file
+#define RPT_STDOUT                        8   // Output to stdout
+#define RPT_STDERR                       16   // Output to stderr
+#define RPT_DEBUG_ON                     32   // Are debug messages processed ?
+#define RPT_OUTPUT_MASK        ( RPT_FILE | \
+                               RPT_STDOUT | \
+                               RPT_STDERR )
+
+// Bit values for the prefix mask
+#define RPT_MSG_ONLY                      1
+#define RPT_MSG_TYPE                      2
+#define RPT_APPNAME                       4
+#define RPT_DATE                          8
+#define RPT_TIME                         16
+#define RPT_ALL            ( RPT_MSG_TYPE | \
+                              RPT_APPNAME | \
+                                 RPT_DATE | \
+                                 RPT_TIME )
+
+// Different kinds of Reporter messages
+#define RPT_DEBUG                       'D'
+#define RPT_INFO                        'I'
+#define RPT_WARN                        'W'
+#define RPT_ERROR                       'E'
+#define RPT_MSG                         'M'
+#define RPT_HEADER                      'H'
+#define RPT_TEXT                        'T'
+
+class Reporter
+{
+public:
+  Reporter ();
+   ~Reporter ();
+    
+  // connection methods
+  CPO_BOOL  init ( const char * appName,
+                             const BITFIELD prefixMask,
+                             const BITFIELD destination );
+  CPO_BOOL  init ( const char * appName,
+                             const BITFIELD prefixMask,
+                             const BITFIELD destination,
+                             const char * path );
+  CPO_BOOL  init ( const char * appName,
+                             const BITFIELD prefixMask,
+                             const BITFIELD destination,
+                             const char * path,
+                             const char * file,
+							 const unsigned long ulOpenAttributes = OPEN_ALWAYS);
+
+  CPO_BOOL  connected ( void );
+  CPO_BOOL  active ( void );
+  void     debugON ( void );
+  void     debugOFF ( void );
+  void     sleep ( void );
+  void     wake ( void );
+  void     load ( const char * filename );
+  void     kill ( void );
+  
+  // display methods
+  void     dash ( void );
+  void     star ( void );
+  void     blank ( void );
+  void     header ( char * message, ... );
+  void     msg ( char * message, ... );
+  void     debug ( char * message, ... );
+  void     info  ( char * message, ... );
+  void     warn  ( char * message, ... );
+  void     error ( char * message, ... );
+  char *   text ( char * message, ... );
+
+  void     header ( int code, ... );
+  void     msg ( int code, ... );
+  void     debug ( int code, ... );
+  void     info  ( int code, ... );
+  void     warn  ( int code, ... );
+  void     error ( int code, ... );
+  char *   text ( int code, ... );
+
+private:
+
+  // variables
+  va_list pCurrent;                               // pointer to arg list
+  BITFIELD state;                                 // current state flags
+  BITFIELD prefix;                                // info to prepend to message
+  HANDLE hFile;		                              // handle to log file
+  char filename [ CPO_MAX_FILENAME_LEN + 1 ];     // name of log file
+  char progname [ RPT_MAX_PROGRAM_LEN + 1 ];      // name of calling process
+  int fileRead;                                   // valid list entries ?
+  char *messageList [ RPT_MAX_LIST_ENTRIES ]; // list of messages
+  char buffer [ RPT_OPEN_MSG_LEN ];               // common temp buffer
+
+  // methods
+  void        prepare ( void );
+  CPO_BOOL     setup ( const char * appName, 
+                       const BITFIELD prefixMask,
+					   const unsigned long ulOpenAttributes = OPEN_ALWAYS );
+  void        actOnCode ( int code, char messType );
+  void        extractName ( char * file, const char * path, 
+                                       const int length );
+  void        generateFilename ( char * validName, 
+                                            const char * appName );
+  int         openFile ( unsigned long ulOpenAttributes = OPEN_ALWAYS );
+  void        closeFile ( void );
+  void        validateText ( char * text, const int length );
+  void        addHeaderInfo ( char * prefixInfo );
+  void        addLogInfo ( char * prefixInfo, const char msgType );
+  void        buildMessage ( const char * message, 
+                                        const char messType );
+  void        writeToStream ( const char * str );
+  void        readMessageFile ( const char * file );
+  void        addMessage ( void );
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/inc/cstatdataformatconverter.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,152 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef CSTATDataFormatConverter_H
+#define CSTATDataFormatConverter_H
+
+#include <oaidl.h>
+#include <statcommon.h>
+#include "CSTATLogfile.h"
+
+const long int KWriteOnceFileStoreUid=268435511;
+const long int KMultiBitmapFileImageUid=268435522;
+const long int KMultiBitmapFileImageChecksum=1194943545;
+
+enum TBitmapColor
+{
+	EMonochromeBitmap,
+	EColorBitmap
+};
+
+enum TBitmapfileCompression
+{
+	ENoBitmapCompression=0,
+	EByteRLECompression,
+	ETwelveBitRLECompression,
+	ESixteenBitRLECompression,
+	ETwentyFourBitRLECompression
+};
+
+struct SEpocBitmapHeader
+{
+	long iBitmapSize;
+	long iStructSize;
+	long iWidthInPixels;
+	long iHeightInPixels;
+	long iWidthInTwips;
+	long iHeightInTwips;
+	long iBitsPerPixel;
+	TBitmapColor iColor;
+	long iPaletteEntries;	// always 0 in current implementations
+	TBitmapfileCompression iCompression;
+};
+
+#include <pshpack2.h>
+struct TRgbTriple
+{
+	unsigned char rgbtBlue;
+	unsigned char rgbtGreen;
+	unsigned char rgbtRed;
+};
+#include <poppack.h>
+
+struct TRgbQuad
+{
+	unsigned char iBlue;
+	unsigned char iGreen;
+	unsigned char iRed;
+	unsigned char iReserved;
+};
+
+class TRgb
+{
+public:
+	TRgb();
+	TRgb(long unsigned int val);
+	TRgb(int aRed,int aGreen,int aBlue);
+	TRgb &operator=(const TRgb& aColor);
+	int operator==(const TRgb& aColor);
+	int Difference(const TRgb& col) const;
+	int Gray2() const;
+	int Gray4() const;
+	int Gray16() const;
+	int Gray256() const;
+	int Color16() const;
+	int Color256() const;
+	int Color4K() const;
+	int Color64K() const;
+	long int Color16M() const;
+	static TRgb Gray2(int aGray2);
+	static TRgb Gray4(int aGray4);
+	static TRgb Gray16(int aGray16);
+	static TRgb Gray256(int aGray256);
+	static TRgb Color16(int aColor16);
+	static TRgb Color256(int aColor256);
+	static TRgb Color4K(int aColor64K);
+	static TRgb Color64K(int aColor64K);
+	static TRgb Color16M(long int aColor16M);
+public:
+	unsigned char iRed;
+	unsigned char iGreen;
+	unsigned char iBlue;
+	unsigned char iSpare;
+};
+
+class CSTATDataFormatConverter : public VARIANT
+{
+	public:
+		CSTATDataFormatConverter(CSTATLogFile *pLog);
+		virtual ~CSTATDataFormatConverter();
+		bool ConvertStringToUnicode(CString& data);
+		int ConvertScreenShot(CString &mbmdirectory, CString &destptr);
+		void GetScreenshotData(TBitmapFileHeader **ppFHeader, TBitmapInfoHeader **ppBMPHeader, char **ppBits, unsigned long *pSize)
+		{
+			*ppFHeader = &fileheader;
+			*ppBMPHeader = &bmpHeader;
+			*ppBits = bmpBits;
+			*pSize = lDataSize;
+		}
+
+		bool bWriteToFile;						// flag to write bitmap out to disk or not
+
+	private:
+		void EnsureBufSize(int size);
+		int LoadBitmap(CString &file);
+		int SaveBitmap(CString &file);
+		bool ExpandByteRLEData(char* aDest,int aDestSize,char* aSrce,int aSrceSize);
+		bool ExpandTwelveBitRLEData(char* aDest,int aDestSizeInBytes,char* aSrce,int aSrceSizeInBytes);
+		bool ExpandSixteenBitRLEData(char* aDest,int aDestSizeInBytes,char* aSrce,int aSrceSizeInBytes);
+		bool ExpandTwentyFourBitRLEData(char* aDest,int aDestSizeInBytes,char* aSrce,int aSrceSizeInBytes);
+		TRgb GetPixel(int aXCoord,int aYCoord);
+		int ByteWidth(int aPixelWidth,int aBitsPerPixel);
+
+		CSTATLogFile *pLogFile;					// pointer to our logging class
+		BYTE* m_index;							// command buffer access
+		int m_bufsize;							// command buffer size
+
+		SEpocBitmapHeader iPbmHeader;			// EPOC screenshot header info
+		char* pPbmBits;							// EPOC screenshot data
+		TBitmapFileHeader fileheader;			// converted screenshot header info
+		TBitmapInfoHeader bmpHeader;			// converted screenshot bitmap info
+		char* bmpBits;							// converted screenshot data
+		unsigned long lDataSize;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/inc/cstatimageverify.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef CSTATImageVerify_H
+#define CSTATImageVerify_H
+
+#include "CSTATLogFile.h"
+
+#define VERIFY_MAX_IMAGES	250
+
+//class to be used to store names of reference images in time ascending order
+//Verification will then take place according to current location in the array
+class CSTATReferenceImages
+{
+	public :
+		CString completefilenamepath;
+		ULONGLONG lCreationTime;
+};
+
+class CSTATImageVerify
+{
+	public :
+		CSTATImageVerify(CSTATLogFile *pLog);
+		~CSTATImageVerify();
+
+		int Initialise(const CString& path);							// sets the location of the reference images
+		int CopyReferenceImages(LPTSTR refimagelocation);	// copy new ref images
+		int DeleteReferenceImages();						// remove existing reference images
+		int EnableVerification(int fudge);					//will load ref file names into array and sort them accroding to creation time
+		int VerifyImage(CString& lastscreenshot);			//image verification function (blitting)
+		int IsActive() { return iImageCount; }				// are we using verification?
+		void DisableVerification() { iImageCount = 0; }		// turn it off
+
+	private :
+		bool ImagesRemaining() { return (lastrefimageloaded < iImageCount); }
+		bool LoadNewImage(CString& newimage);				//image loading for reference and new images
+		bool LoadRefImage();								// ...
+		
+		CSTATReferenceImages refimagearray[250];			// array of images to verify against
+		int lastrefimageloaded;								// position of last image
+		int margin;											// percentage error allowed on images
+		int iImageCount;									// total images for verification
+		CString referenceimagedir;							// location of reference images
+		CSTATLogFile *pLogFile;								// pointer to our logging class
+
+		CPalette m_Palette;
+		unsigned char *m_pDib, *m_pDib2, *m_pDibBits, *m_pDibBits2;
+		DWORD m_dwDibSize, m_dwDibSize2;
+		BITMAPINFOHEADER *m_pBIH, *m_pBIH2;
+		RGBQUAD *m_pPalette, *m_pPalette2;
+		int m_nPaletteEntries, m_nPaletteEntries2;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/inc/cstatlogfile.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,72 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef CSTATLogFile_H
+#define CSTATLogFile_H
+
+#include <afxmt.h>
+#include "CSTATReturnCodes.h"
+#include "MessageReporter.h"
+
+class CSTATLogFile
+{
+public :
+	// logging
+	CSTATLogFile();
+	~CSTATLogFile();
+	int CreateLogFile(const CString& newlogfilename,const CString& defaultPath ,const char* prefix, bool append, bool bMessages, bool bFile);
+	void SetMessageReporter(MessageReporter *const messageReporter);
+	void WriteTimeToLog();					// write the current date/time to log
+	void Write(char *szText, ...);			// write standard text to log
+	void Write(CString cBuf);				// write CString text to log
+	void CloseLogFile();					// close
+
+	// messaging
+	int Set(const char* newtext);													// write CString to storage buffer and to log
+	int Set(int iMsgCode, const char* newtext = NULL, bool bMsgBox = false, bool bScrshot = false);
+	// bool Get(CString &msg, CString &newtext, bool &bMsgBox, bool &bScrshot);  // get log message from storage buffer
+	const char* Text(int iMsgCode) { return ReturnCodes.GetRetMsg(iMsgCode); }    // get error text
+
+	int ToAnsi(LPCTSTR szUnicode, LPSTR szBuffer, int nBufLen);
+	LPCTSTR ToUnicode(const char *string);
+
+private :
+	char* FormatText(const char* message);
+
+	CSTATReturnCodes ReturnCodes;			// return codes for use within STAT
+
+	// logging
+	CFile logfile;							// log file object
+	CString Logfilename;					// the name of our log file
+	char szLogPrefix[51];					// holds a prefix to all log messages
+
+	MessageReporter	*iMessageReporter;
+
+	// messages
+	bool bWriteToScreen;					// flag for writing to dialog box
+	bool bWriteToFile;						// flag for writing to log file
+	bool bMessage;							// flag for waiting message
+	bool bMessageBox;						// display in a MessageBox
+	bool bScreenshot;						// display associated screenshot bitmap
+	CString message;						// basic message
+	CString text;							// associated error text
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/inc/cstatreturncodes.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,214 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef CSTATReturnCodes_H
+#define CSTATReturnCodes_H
+
+#define GENERAL_FAILURE						0
+#define EXPIRED_VERSION						1
+#define TIME_DELAY_INIT_FAILURE				2
+#define DLL_INIT_FAILURE					3
+#define OPEN_SCRIPT_FILE_FAILURE			4
+#define INTERPRET_COMMANDS_FAILURE			5
+#define COMMANDDECODER_INIT_FAILURE			6
+#define DATACONVERTER_INIT_FAILURE			7
+#define DIRMANAGER_INIT_FAILURE				8
+#define RETCODES_INIT_FAILURE				9
+#define COMLIB_INIT_FAILURE					10
+#define COPYING								11
+#define REFDIR_FOUND						12
+#define ITS_OK								13
+#define TIME_DELAY_INIT_SUCCESS				14
+#define ALMOST								15
+#define ERROR_REGISTRY						16
+#define LOG_DIR_FAILURE						17
+#define LOG_DIR_FOUND						18
+#define LOG_DIR_DUPLICATE_FOUND				19
+#define LOG_DIR_CREATE_REG_FAILURE			20
+#define LOG_DIR_CREATE_FAILURE				21
+#define LOG_DIR_INFORM						22
+#define LOG_DIR_REG_FAILURE					23
+#define LOG_FILE_FAILURE					24
+#define LOG_FILE_OK							25
+#define OPEN_SCRIPT_FILE_OK					26
+#define OPEN_SCRIPT_FILE_COMPLETE_FAILURE	27
+#define CLEANUP_FAILURE						28
+#define END_COMMAND_FAILURE					29
+#define END_SCRIPT							30
+#define BEGIN_COMMAND_FAILURE				31
+#define CONNECT_FIRST						32
+#define COM_MEM_FAILURE						33
+#define CONNECTED							34
+#define INVALID_HASH_COMMAND				35
+#define NEW_IMAGE_DIRECTORY					36
+#define CURRENT_IMAGE_DIRECTORY_OK			37
+#define NO_END_TO_COMMENT_COMMAND			38
+#define COMMENT_COMMAND						39
+#define INVALID_COMMENT_COMMAND				40
+#define LOGFILE_INIT_FAILURE				41
+#define PAUSE_TIME							42
+#define DEVINFO_RECEIVED					43
+#define DEVINFO_TRYING						44
+#define DEVINFO_FAILURE						45
+#define MACHINEINFO_RECEIVED				46
+#define MACHINEINFO_TRYING					47
+#define MACHINEINFO_FAILURE					48
+#define KEYDATA_INFORM						49
+#define KEYDATA_OK							50
+#define KEYDATA_FAILURE						51
+#define SYSKEYDATA_INFORM					52
+#define SYSKEYDATA_OK						53
+#define SYSKEYDATA_FAILURE					54
+#define COMBOKEYDATA_INFORM					55
+#define COMBOKEYDATA_OK						56
+#define COMBOKEYDATA_FAILURE				57
+#define COMBOKEYDATA_INVALID				58
+#define APPSTART_INFORM						59
+#define APPSTART_OK							60
+#define APPSTART_FAILURE					61
+#define FILEOPEN_INFORM						62
+#define FILEOPEN_OK							63
+#define FILEOPEN_FAILURE					64
+#define FILETRANSFER_INFORM					65
+#define FILETRANSFER_OK						66
+#define FILETRANSFER_FAILURE				67
+#define E_ENGINEOBJECTFAILURE				68
+#define FILERETRIEVE_INFORM					69
+#define FILERETRIEVE_OK						70
+#define FILERETRIEVE_FAILURE				71
+#define TOUCHSCREEN_INFORM					72
+#define TOUCHSCREEN_OK						73
+#define TOUCHSCREEN_FAILURE					74
+#define APPCLOSE_INFORM						75
+#define APPCLOSE_OK							76
+#define APPCLOSE_FAILURE					77
+#define ESHELL_START_INFORM					78
+#define ESHELL_START_OK						79
+#define ESHELL_START_FAILURE				80
+#define ESHELL_STOP_INFORM					81
+#define ESHELL_STOP_OK						82
+#define ESHELL_STOP_FAILURE					83
+#define SCREENSHOT_INFORM					84 
+#define SCREENSHOT_OK						85
+#define SCREENSHOT_FAILURE					86
+#define SCREENSHOT_MOVETOPC_INFORM			87
+#define SCREENSHOT_MOVETOPC_OK				88
+#define SCREENSHOT_MOVETOPC_FAILURE			89
+#define SCREENSHOT_CONVERSION_FAILURE		90
+#define SCREENSHOT_CONVERSION_OK			91
+#define IMAGEVERIFY_INIT_FAILURE			92
+#define DELETEIMAGES_FAILURE				93
+#define REFIMAGELOAD_OK						94
+#define REFIMAGELOAD_FAILURE				95
+#define REFIMAGELOAD_FAILURE_LIMIT			96
+#define NEWIMAGELOAD_OK						97
+#define NEWIMAGELOAD_FAILURE				98
+#define VERIFICATION_PASS					99
+#define VERIFICATION_FAILURE				100
+#define START_VERIFICATION					101
+#define CREATE_DIR_FAILURE					102
+#define NO_BITMAPS							103
+#define TOUCHSCREEN_INVALID_COMMAND			104
+#define KEYHOLD_INFORM						105
+#define KEYHOLD_OK							106
+#define KEYHOLD_FAILURE						107
+#define KEYHOLD_INVALID_COMMAND				108
+#define KEYHOLD_STRING_INVALID				109
+#define ERR_INVALID_IMAGE_DIRECTORY			110
+#define ERR_FILE_COPY_FAILED				111
+#define E_BADPLATFORM						112
+#define E_BADFILESYSINTERFACE				113
+#define E_BADREQUESTINTERFACE				114
+#define E_ENGINECONNECTFAILURE				115
+#define E_REQUESTOBJECTFAILURE				116
+#define E_REQUESTINITFAILURE				117
+#define E_NOREFERENCEIMAGES					118
+#define FILE_DELETE_INFORM					119
+#define FILE_DELETE_OK						120
+#define FILE_DELETE_FAILURE					121
+#define CREATE_FOLDER_INFORM				122
+#define CREATE_FOLDER_OK					123
+#define CREATE_FOLDER_FAILURE				124
+#define REMOVE_FOLDER_INFORM				125
+#define REMOVE_FOLDER_OK					126
+#define REMOVE_FOLDER_FAILURE				127
+#define E_NOT_SUPPORTED						128
+#define E_USERCANCEL						129
+#define E_OUTOFMEM							130
+#define INVALID_COMMAND_FORMAT				131
+#define E_MESSAGE_INIT_FAILURE				132
+#define E_BADFORMAT							133
+#define E_FILE_OPEN_READ_FAILED				134
+#define E_NOIMAGEFOLDER						135
+#define E_NOIMAGESTOCONVERT					136
+#define E_BITMAPLOADFAILED					137
+#define E_BITMAPSAVEFAILED					138
+#define E_BADWRITE							139
+#define E_FILE_OPEN_WRITE_FAILED			140
+#define E_BADCOMPRESSION					141
+#define E_SCREENSHOT_LEFTOVERFILES			142
+#define CONVERTINGIMAGE						143
+#define TO									144
+#define FILERETRIEVE_COPY					145
+#define E_INVALIDCMDSYNTAX					146
+#define READINGIMAGE						147
+#define SCREENSHOT_INTOMEMORY_OK			148
+#define E_COMMANDRETRY						149
+#define E_COMMANDFAILED						150
+#define E_CONNECTIONFAILED					151
+#define E_WRITEFAILED						152
+#define E_READFAILED						153
+#define NO_DATA_AT_PORT						154
+#define E_TOOMUCHTIME						155
+#define E_TOOMANYERRORS						156
+#define E_BADID								157
+#define E_BADFILENAME						158
+#define E_BADNUMBERBYTES					159
+#define E_OUTOFMEMNOTSUPPORTED				160
+#define RETRIEVETO							161
+#define E_INVALIDMESSAGETYPE				162
+#define E_RESYNCCOMMAND						163
+#define E_NOFILEDATA						164
+#define E_SOCKETSTARTUP						165
+#define E_SOCKETCREATE						166
+#define E_SOCKETCONNECT						167
+#define E_SOCKETBIND						168
+#define E_SOCKETLISTEN						169
+#define E_SOCKETHOSTNAME					170
+#define E_SOCKETSEND						171
+#define E_SOCKETRECV						172
+#define E_PROCESSTERMINATED					173
+#define E_SOCKETCLOSE						174
+#define E_SOCKETSHUTDOWN					175
+#define USE_EXISTING_IMAGES					176
+#define E_NOCONNECTION						177
+
+
+class CSTATReturnCodes
+{
+	public:
+		CSTATReturnCodes();
+		const char* GetRetMsg(const DWORD codenum);
+
+	private:
+		DWORD iMaxCodes;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/inc/messagereporter.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#if ! defined (MESSAGEREPORTER_H_356396A9_4FCA_44bc_90BB_A4826F5F82EA)
+#define MESSAGEREPORTER_H_356396A9_4FCA_44bc_90BB_A4826F5F82EA
+
+class MessageReporter
+{
+protected:
+	MessageReporter(void);
+	~MessageReporter();
+
+public:
+	// Override in a derived class to call-back when a log message
+	// is available.
+	virtual void OnMessage( const char* message, const char* text,
+										bool bMsgBox, bool bScrshot ) = 0;
+};
+
+inline MessageReporter::MessageReporter( void )
+{
+	;
+}
+
+inline MessageReporter::~MessageReporter()
+{
+	;
+}
+
+#endif // ! defined (MESSAGEREPORTER_H_356396A9_4FCA_44bc_90BB_A4826F5F82EA)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/inc/messagetypes.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#if !defined(__MESSAGETYPES_H__)
+#define __MESSAGETYPES_H__
+
+// messages sent by PC
+enum TSTATPCMsg 
+	{
+		ESTATPCMsgHello,
+		ESTATPCMsgStartApp,
+		ESTATPCMsgOpenFile,
+		ESTATPCMsgScreenCapture,
+		ESTATPCMsgStopApp,
+		ESTATPCMsgIconPress,
+		ESTATPCMsgReady,
+		ESTATPCMsgSelectDrive,
+		ESTATPCMsgSelectLanguage,
+		ESTATPCMsgSelectQuestion,
+		ESTATPCMsgSelectOptions,
+		ESTATPCMsgSelectDelDepend,
+		ESTATPCMsgSelectText,
+		ESTATPCMsgSelectAbortRetrySkip,
+		ESTATPCMsgSelectInUse,
+		ESTATPCMsgSelectSecWarning,
+		ESTATPCMsgTypeText,
+		ESTATPCMsgTypeSysText,
+		ESTATPCMsgTypeCombinationText,
+		ESTATPCMsgEShell,
+		ESTATPCMsgKeyHold,
+		ESTATPCMsgDeleteFile,
+		ESTATPCMsgCreateFolder,
+		ESTATPCMsgRemoveFolder,
+		ESTATPCMsgGoodBye,
+		ESTATPCMsgInvalidCommand
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/inc/scriptprogressmonitor.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#if ! defined (SCRIPTPROGRESSMONITOR_H_523472E4_3321_4496_9000_3D8878255FD3)
+#define SCRIPTPROGRESSMONITOR_H_523472E4_3321_4496_9000_3D8878255FD3
+
+class ScriptProgressMonitor
+{
+protected:
+	ScriptProgressMonitor(void);
+	~ScriptProgressMonitor();
+
+public:
+	// Override in a derived class to call-back when a single
+	// command of the current script is processed.
+	virtual void OnCompleteCommand( int command ) = 0;
+
+	// Override in a derived class to call-back when the
+	// whole of current script is processed.
+	virtual void OnCompleteScript( int scriptExitCode ) = 0;
+};
+
+inline ScriptProgressMonitor::ScriptProgressMonitor( void )
+{
+	;
+}
+
+inline ScriptProgressMonitor::~ScriptProgressMonitor()
+{
+	;
+}
+
+#endif // ! defined (SCRIPTPROGRESSMONITOR_H_523472E4_3321_4496_9000_3D8878255FD3)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/inc/stat.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,70 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef STAT_H
+#define STAT_H
+
+// possible connection types supported
+typedef enum STATConnectType
+{
+	SymbianInvalid	 = 0,	
+	SymbianSocket    = 1,
+	SymbianSerial    = 2,
+	SymbianInfrared	 = 3,
+	SymbianBluetooth = 4,
+	SymbianUsb = 5,
+} STATCONNECTTYPE;
+
+// possible logging levels
+typedef enum STATLogLevel
+{
+	ETerse   = 0,
+	ENormal  = 1,
+	EVerbose = 2
+} STATLOGLEVEL;
+
+// bitmap access structures
+#include <pshpack2.h>
+struct TBitmapFileHeader
+{
+	unsigned short bfType;
+	unsigned long bfSize;
+	unsigned short bfReserved1;
+	unsigned short bfReserved2;
+	unsigned long bfOffBits;
+};
+#include <poppack.h>
+
+struct TBitmapInfoHeader
+{
+	unsigned long biSize;
+	long biWidth;
+	long biHeight;
+	unsigned short biPlanes;
+	unsigned short biBitCount;
+	unsigned long biCompression;
+	unsigned long biSizeImage;
+	long biXPelsPerMeter;
+	long biYPelsPerMeter;
+	unsigned long biClrUsed;
+	unsigned long biClrImportant;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/inc/statbitmap.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,374 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+const long unsigned int color16array[16]= {
+	0x00000000,	0x00555555,	0x00000080,	0x00008080,
+	0x00008000,	0x000000ff,	0x0000ffff,	0x0000ff00,
+	0x00ff00ff,	0x00ff0000,	0x00ffff00,	0x00800080,
+	0x00800000,	0x00808000,0x00aaaaaa,	0x00ffffff	};
+
+const unsigned char color16inverse[512] = {
+	0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x05, 0x05,	0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x05, 0x05,
+	0x04, 0x04, 0x01, 0x03, 0x03, 0x03, 0x05, 0x05,	0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x05,
+	0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x06,	0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x06, 0x06,
+	0x07, 0x07, 0x07, 0x03, 0x03, 0x06, 0x06, 0x06,	0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x06, 0x06,
+	0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x05, 0x05,	0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x05, 0x05,
+	0x04, 0x01, 0x01, 0x01, 0x03, 0x03, 0x05, 0x05,	0x04, 0x04, 0x01, 0x03, 0x03, 0x03, 0x03, 0x05,
+	0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x06,	0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x06, 0x06,
+	0x07, 0x07, 0x07, 0x03, 0x03, 0x06, 0x06, 0x06,	0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x06, 0x06,
+	0x0c, 0x0c, 0x01, 0x0b, 0x0b, 0x0b, 0x05, 0x05,	0x0c, 0x01, 0x01, 0x01, 0x0b, 0x0b, 0x05, 0x05,
+	0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05,	0x0d, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05,
+	0x0d, 0x0d, 0x01, 0x01, 0x03, 0x0e, 0x0e, 0x06,	0x0d, 0x0d, 0x01, 0x01, 0x0e, 0x0e, 0x0e, 0x06,
+	0x07, 0x07, 0x01, 0x01, 0x0e, 0x0e, 0x06, 0x06,	0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x06, 0x06,
+	0x0c, 0x0c, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x05,	0x0c, 0x0c, 0x01, 0x0b, 0x0b, 0x0b, 0x0b, 0x05,
+	0x0d, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05,	0x0d, 0x0d, 0x01, 0x01, 0x01, 0x0e, 0x0e, 0x0e,
+	0x0d, 0x0d, 0x01, 0x01, 0x0e, 0x0e, 0x0e, 0x0e,	0x0d, 0x0d, 0x01, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e,
+	0x0d, 0x0d, 0x01, 0x0e, 0x0e, 0x0e, 0x0e, 0x06,	0x07, 0x07, 0x07, 0x0e, 0x0e, 0x0e, 0x06, 0x06,
+	0x0c, 0x0c, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x08,	0x0c, 0x0c, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x08,
+	0x0d, 0x0d, 0x01, 0x01, 0x0b, 0x0e, 0x0e, 0x08,	0x0d, 0x0d, 0x01, 0x01, 0x0e, 0x0e, 0x0e, 0x0e,
+	0x0d, 0x0d, 0x0d, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e,	0x0d, 0x0d, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e,
+	0x0d, 0x0d, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0f,	0x0a, 0x0a, 0x0a, 0x0e, 0x0e, 0x0e, 0x0f, 0x0f,
+	0x0c, 0x0c, 0x0b, 0x0b, 0x0b, 0x0b, 0x08, 0x08,	0x0c, 0x0c, 0x0b, 0x0b, 0x0b, 0x0b, 0x08, 0x08,
+	0x0d, 0x0d, 0x01, 0x01, 0x0e, 0x0e, 0x0e, 0x08,	0x0d, 0x0d, 0x01, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e,
+	0x0d, 0x0d, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e,	0x0d, 0x0d, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e,
+	0x0a, 0x0a, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0f,	0x0a, 0x0a, 0x0a, 0x0e, 0x0e, 0x0e, 0x0f, 0x0f,
+	0x09, 0x09, 0x09, 0x0b, 0x0b, 0x08, 0x08, 0x08,	0x09, 0x09, 0x09, 0x0b, 0x0b, 0x08, 0x08, 0x08,
+	0x09, 0x09, 0x01, 0x01, 0x0e, 0x0e, 0x08, 0x08,	0x0d, 0x0d, 0x01, 0x0e, 0x0e, 0x0e, 0x0e, 0x08,
+	0x0d, 0x0d, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0f,	0x0a, 0x0a, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0f,
+	0x0a, 0x0a, 0x0a, 0x0e, 0x0e, 0x0e, 0x0f, 0x0f,	0x0a, 0x0a, 0x0a, 0x0a, 0x0f, 0x0f, 0x0f, 0x0f,
+	0x09, 0x09, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08,	0x09, 0x09, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08,
+	0x09, 0x09, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08,	0x09, 0x09, 0x09, 0x0e, 0x0e, 0x0e, 0x08, 0x08,
+	0x0a, 0x0a, 0x0a, 0x0e, 0x0e, 0x0e, 0x0f, 0x0f,	0x0a, 0x0a, 0x0a, 0x0e, 0x0e, 0x0e, 0x0f, 0x0f,
+	0x0a, 0x0a, 0x0a, 0x0a, 0x0f, 0x0f, 0x0f, 0x0f,	0x0a, 0x0a, 0x0a, 0x0a, 0x0f, 0x0f, 0x0f, 0x0f
+	};
+
+const long unsigned int color256array[256] = {
+	0x00000000,	0x00000033,	0x00000066,	0x00000099,	0x000000cc,	0x000000ff,
+	0x00003300,	0x00003333,	0x00003366,	0x00003399,	0x000033cc,	0x000033ff,
+	0x00006600,	0x00006633,	0x00006666,	0x00006699,	0x000066cc,	0x000066ff,
+	0x00009900,	0x00009933,	0x00009966,	0x00009999,	0x000099cc,	0x000099ff,
+	0x0000cc00,	0x0000cc33,	0x0000cc66,	0x0000cc99,	0x0000cccc,	0x0000ccff,
+	0x0000ff00,	0x0000ff33,	0x0000ff66,	0x0000ff99,	0x0000ffcc,	0x0000ffff,
+
+	0x00330000,	0x00330033,	0x00330066,	0x00330099,	0x003300cc,	0x003300ff,
+	0x00333300,	0x00333333,	0x00333366,	0x00333399,	0x003333cc,	0x003333ff,
+	0x00336600,	0x00336633,	0x00336666,	0x00336699,	0x003366cc,	0x003366ff,
+	0x00339900,	0x00339933,	0x00339966,	0x00339999,	0x003399cc,	0x003399ff,
+	0x0033cc00,	0x0033cc33,	0x0033cc66,	0x0033cc99,	0x0033cccc,	0x0033ccff,
+	0x0033ff00,	0x0033ff33,	0x0033ff66,	0x0033ff99,	0x0033ffcc,	0x0033ffff,
+
+	0x00660000,	0x00660033,	0x00660066,	0x00660099,	0x006600cc,	0x006600ff,
+	0x00663300,	0x00663333,	0x00663366,	0x00663399,	0x006633cc,	0x006633ff,
+	0x00666600,	0x00666633,	0x00666666,	0x00666699,	0x006666cc,	0x006666ff,
+	0x00669900,	0x00669933,	0x00669966,	0x00669999,	0x006699cc,	0x006699ff,
+	0x0066cc00,	0x0066cc33,	0x0066cc66,	0x0066cc99,	0x0066cccc,	0x0066ccff,
+	0x0066ff00,	0x0066ff33,	0x0066ff66,	0x0066ff99,	0x0066ffcc,	0x0066ffff,
+
+	0x00111111, 0x00222222, 0x00444444, 0x00555555, 0x00777777,
+	0x00000011, 0x00000022, 0x00000044, 0x00000055, 0x00000077,
+	0x00001100,	0x00002200,	0x00004400,	0x00005500,	0x00007700,
+	0x00110000,	0x00220000,	0x00440000,	0x00550000,	0x00770000,
+
+	0x00880000,	0x00aa0000,	0x00bb0000,	0x00dd0000,	0x00ee0000,
+	0x00008800,	0x0000aa00,	0x0000bb00,	0x0000dd00,	0x0000ee00,
+	0x00000088,	0x000000aa,	0x000000bb,	0x000000dd,	0x000000ee,
+	0x00888888, 0x00aaaaaa, 0x00bbbbbb, 0x00dddddd, 0x00eeeeee,
+
+	0x00990000,	0x00990033,	0x00990066,	0x00990099,	0x009900cc,	0x009900ff,
+	0x00993300,	0x00993333,	0x00993366,	0x00993399,	0x009933cc,	0x009933ff,
+	0x00996600,	0x00996633,	0x00996666,	0x00996699,	0x009966cc,	0x009966ff,
+	0x00999900,	0x00999933,	0x00999966,	0x00999999,	0x009999cc,	0x009999ff,
+	0x0099cc00,	0x0099cc33,	0x0099cc66,	0x0099cc99,	0x0099cccc,	0x0099ccff,
+	0x0099ff00,	0x0099ff33,	0x0099ff66,	0x0099ff99,	0x0099ffcc,	0x0099ffff,
+
+	0x00cc0000,	0x00cc0033,	0x00cc0066,	0x00cc0099,	0x00cc00cc,	0x00cc00ff,
+	0x00cc3300,	0x00cc3333,	0x00cc3366,	0x00cc3399,	0x00cc33cc,	0x00cc33ff,
+	0x00cc6600,	0x00cc6633,	0x00cc6666,	0x00cc6699,	0x00cc66cc,	0x00cc66ff,
+	0x00cc9900,	0x00cc9933,	0x00cc9966,	0x00cc9999,	0x00cc99cc,	0x00cc99ff,
+	0x00cccc00,	0x00cccc33,	0x00cccc66,	0x00cccc99,	0x00cccccc,	0x00ccccff,
+	0x00ccff00,	0x00ccff33,	0x00ccff66,	0x00ccff99,	0x00ccffcc,	0x00ccffff,
+
+	0x00ff0000,	0x00ff0033,	0x00ff0066,	0x00ff0099,	0x00ff00cc,	0x00ff00ff,
+	0x00ff3300,	0x00ff3333,	0x00ff3366,	0x00ff3399,	0x00ff33cc,	0x00ff33ff,
+	0x00ff6600,	0x00ff6633,	0x00ff6666,	0x00ff6699,	0x00ff66cc,	0x00ff66ff,
+	0x00ff9900,	0x00ff9933,	0x00ff9966,	0x00ff9999,	0x00ff99cc,	0x00ff99ff,
+	0x00ffcc00,	0x00ffcc33,	0x00ffcc66,	0x00ffcc99,	0x00ffcccc,	0x00ffccff,
+	0x00ffff00,	0x00ffff33,	0x00ffff66,	0x00ffff99,	0x00ffffcc,	0x00ffffff
+	};
+
+const unsigned char color256inverse[4096] = {
+	0x00, 0x71, 0x72, 0x01, 0x73, 0x74, 0x02, 0x75,	0x8a, 0x03, 0x8b, 0x8c, 0x04, 0x8d, 0x8e, 0x05,
+	0x76, 0x6c, 0x72, 0x01, 0x73, 0x74, 0x02, 0x75,	0x8a, 0x03, 0x8b, 0x8c, 0x04, 0x8d, 0x8e, 0x05,
+	0x77, 0x77, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08,	0x09, 0x09, 0x09, 0x0a, 0x0a, 0x0a, 0x0b, 0x0b,
+	0x06, 0x06, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08,	0x09, 0x09, 0x09, 0x0a, 0x0a, 0x0a, 0x0b, 0x0b,
+	0x78, 0x78, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08,	0x09, 0x09, 0x09, 0x0a, 0x0a, 0x0a, 0x0b, 0x0b,
+	0x79, 0x79, 0x0d, 0x0d, 0x0d, 0x0e, 0x0e, 0x0e,	0x0f, 0x0f, 0x0f, 0x10, 0x10, 0x10, 0x11, 0x11,
+	0x0c, 0x0c, 0x0d, 0x0d, 0x0d, 0x0e, 0x0e, 0x0e,	0x0f, 0x0f, 0x0f, 0x10, 0x10, 0x10, 0x11, 0x11,
+	0x7a, 0x7a, 0x0d, 0x0d, 0x0d, 0x0e, 0x0e, 0x0e,	0x0f, 0x0f, 0x0f, 0x10, 0x10, 0x10, 0x11, 0x11,
+	0x85, 0x85, 0x13, 0x13, 0x13, 0x14, 0x14, 0x14,	0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x17, 0x17,
+	0x12, 0x12, 0x13, 0x13, 0x13, 0x14, 0x14, 0x14,	0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x17, 0x17,
+	0x86, 0x86, 0x13, 0x13, 0x13, 0x14, 0x14, 0x14,	0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x17, 0x17,
+	0x87, 0x87, 0x19, 0x19, 0x19, 0x1a, 0x1a, 0x1a,	0x1b, 0x1b, 0x1b, 0x1c, 0x1c, 0x1c, 0x1d, 0x1d,
+	0x18, 0x18, 0x19, 0x19, 0x19, 0x1a, 0x1a, 0x1a,	0x1b, 0x1b, 0x1b, 0x1c, 0x1c, 0x1c, 0x1d, 0x1d,
+	0x88, 0x88, 0x19, 0x19, 0x19, 0x1a, 0x1a, 0x1a,	0x1b, 0x1b, 0x1b, 0x1c, 0x1c, 0x1c, 0x1d, 0x1d,
+	0x89, 0x89, 0x1f, 0x1f, 0x1f, 0x20, 0x20, 0x20,	0x21, 0x21, 0x21, 0x22, 0x22, 0x22, 0x23, 0x23,
+	0x1e, 0x1e, 0x1f, 0x1f, 0x1f, 0x20, 0x20, 0x20,	0x21, 0x21, 0x21, 0x22, 0x22, 0x22, 0x23, 0x23,
+	0x7b, 0x6c, 0x72, 0x01, 0x73, 0x74, 0x02, 0x75,	0x8a, 0x03, 0x8b, 0x8c, 0x04, 0x8d, 0x8e, 0x05,
+	0x6c, 0x6c, 0x6c, 0x01, 0x73, 0x74, 0x02, 0x75,	0x8a, 0x03, 0x8b, 0x8c, 0x04, 0x8d, 0x8e, 0x05,
+	0x77, 0x6c, 0x6d, 0x07, 0x07, 0x08, 0x08, 0x08,	0x09, 0x09, 0x09, 0x0a, 0x0a, 0x0a, 0x0b, 0x0b,
+	0x06, 0x06, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08,	0x09, 0x09, 0x09, 0x0a, 0x0a, 0x0a, 0x0b, 0x0b,
+	0x78, 0x78, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08,	0x09, 0x09, 0x09, 0x0a, 0x0a, 0x0a, 0x0b, 0x0b,
+	0x79, 0x79, 0x0d, 0x0d, 0x0d, 0x0e, 0x0e, 0x0e,	0x0f, 0x0f, 0x0f, 0x10, 0x10, 0x10, 0x11, 0x11,
+	0x0c, 0x0c, 0x0d, 0x0d, 0x0d, 0x0e, 0x0e, 0x0e,	0x0f, 0x0f, 0x0f, 0x10, 0x10, 0x10, 0x11, 0x11,
+	0x7a, 0x7a, 0x0d, 0x0d, 0x0d, 0x0e, 0x0e, 0x0e,	0x0f, 0x0f, 0x0f, 0x10, 0x10, 0x10, 0x11, 0x11,
+	0x85, 0x85, 0x13, 0x13, 0x13, 0x14, 0x14, 0x14,	0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x17, 0x17,
+	0x12, 0x12, 0x13, 0x13, 0x13, 0x14, 0x14, 0x14,	0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x17, 0x17,
+	0x86, 0x86, 0x13, 0x13, 0x13, 0x14, 0x14, 0x14,	0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x17, 0x17,
+	0x87, 0x87, 0x19, 0x19, 0x19, 0x1a, 0x1a, 0x1a,	0x1b, 0x1b, 0x1b, 0x1c, 0x1c, 0x1c, 0x1d, 0x1d,
+	0x18, 0x18, 0x19, 0x19, 0x19, 0x1a, 0x1a, 0x1a,	0x1b, 0x1b, 0x1b, 0x1c, 0x1c, 0x1c, 0x1d, 0x1d,
+	0x88, 0x88, 0x19, 0x19, 0x19, 0x1a, 0x1a, 0x1a,	0x1b, 0x1b, 0x1b, 0x1c, 0x1c, 0x1c, 0x1d, 0x1d,
+	0x89, 0x89, 0x1f, 0x1f, 0x1f, 0x20, 0x20, 0x20,	0x21, 0x21, 0x21, 0x22, 0x22, 0x22, 0x23, 0x23,
+	0x1e, 0x1e, 0x1f, 0x1f, 0x1f, 0x20, 0x20, 0x20,	0x21, 0x21, 0x21, 0x22, 0x22, 0x22, 0x23, 0x23,
+	0x7c, 0x7c, 0x25, 0x25, 0x25, 0x26, 0x26, 0x26,	0x27, 0x27, 0x27, 0x28, 0x28, 0x28, 0x29, 0x29,
+	0x7c, 0x6c, 0x6d, 0x25, 0x25, 0x26, 0x26, 0x26,	0x27, 0x27, 0x27, 0x28, 0x28, 0x28, 0x29, 0x29,
+	0x2a, 0x6d, 0x6d, 0x6d, 0x6d, 0x2c, 0x2c, 0x2c,	0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f,
+	0x2a, 0x2a, 0x6d, 0x2b, 0x2b, 0x2c, 0x2c, 0x2c,	0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f,
+	0x2a, 0x2a, 0x6d, 0x2b, 0x6e, 0x2c, 0x2c, 0x2c,	0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f,
+	0x30, 0x30, 0x31, 0x31, 0x31, 0x32, 0x32, 0x32,	0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x35, 0x35,
+	0x30, 0x30, 0x31, 0x31, 0x31, 0x32, 0x32, 0x32,	0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x35, 0x35,
+	0x30, 0x30, 0x31, 0x31, 0x31, 0x32, 0x32, 0x32,	0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x35, 0x35,
+	0x36, 0x36, 0x37, 0x37, 0x37, 0x38, 0x38, 0x38,	0x39, 0x39, 0x39, 0x3a, 0x3a, 0x3a, 0x3b, 0x3b,
+	0x36, 0x36, 0x37, 0x37, 0x37, 0x38, 0x38, 0x38,	0x39, 0x39, 0x39, 0x3a, 0x3a, 0x3a, 0x3b, 0x3b,
+	0x36, 0x36, 0x37, 0x37, 0x37, 0x38, 0x38, 0x38,	0x39, 0x39, 0x39, 0x3a, 0x3a, 0x3a, 0x3b, 0x3b,
+	0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3e, 0x3e, 0x3e,	0x3f, 0x3f, 0x3f, 0x40, 0x40, 0x40, 0x41, 0x41,
+	0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3e, 0x3e, 0x3e,	0x3f, 0x3f, 0x3f, 0x40, 0x40, 0x40, 0x41, 0x41,
+	0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3e, 0x3e, 0x3e,	0x3f, 0x3f, 0x3f, 0x40, 0x40, 0x40, 0x41, 0x41,
+	0x42, 0x42, 0x43, 0x43, 0x43, 0x44, 0x44, 0x44,	0x45, 0x45, 0x45, 0x46, 0x46, 0x46, 0x47, 0x47,
+	0x42, 0x42, 0x43, 0x43, 0x43, 0x44, 0x44, 0x44,	0x45, 0x45, 0x45, 0x46, 0x46, 0x46, 0x47, 0x47,
+	0x24, 0x24, 0x25, 0x25, 0x25, 0x26, 0x26, 0x26,	0x27, 0x27, 0x27, 0x28, 0x28, 0x28, 0x29, 0x29,
+	0x24, 0x24, 0x25, 0x25, 0x25, 0x26, 0x26, 0x26,	0x27, 0x27, 0x27, 0x28, 0x28, 0x28, 0x29, 0x29,
+	0x2a, 0x2a, 0x6d, 0x2b, 0x2b, 0x2c, 0x2c, 0x2c,	0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f,
+	0x2a, 0x2a, 0x2b, 0x2b, 0x2b, 0x2c, 0x2c, 0x2c,	0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f,
+	0x2a, 0x2a, 0x2b, 0x2b, 0x6e, 0x2c, 0x2c, 0x2c,	0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f,
+	0x30, 0x30, 0x31, 0x31, 0x31, 0x32, 0x32, 0x32,	0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x35, 0x35,
+	0x30, 0x30, 0x31, 0x31, 0x31, 0x32, 0x32, 0x32,	0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x35, 0x35,
+	0x30, 0x30, 0x31, 0x31, 0x31, 0x32, 0x32, 0x32,	0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x35, 0x35,
+	0x36, 0x36, 0x37, 0x37, 0x37, 0x38, 0x38, 0x38,	0x39, 0x39, 0x39, 0x3a, 0x3a, 0x3a, 0x3b, 0x3b,
+	0x36, 0x36, 0x37, 0x37, 0x37, 0x38, 0x38, 0x38,	0x39, 0x39, 0x39, 0x3a, 0x3a, 0x3a, 0x3b, 0x3b,
+	0x36, 0x36, 0x37, 0x37, 0x37, 0x38, 0x38, 0x38,	0x39, 0x39, 0x39, 0x3a, 0x3a, 0x3a, 0x3b, 0x3b,
+	0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3e, 0x3e, 0x3e,	0x3f, 0x3f, 0x3f, 0x40, 0x40, 0x40, 0x41, 0x41,
+	0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3e, 0x3e, 0x3e,	0x3f, 0x3f, 0x3f, 0x40, 0x40, 0x40, 0x41, 0x41,
+	0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3e, 0x3e, 0x3e,	0x3f, 0x3f, 0x3f, 0x40, 0x40, 0x40, 0x41, 0x41,
+	0x42, 0x42, 0x43, 0x43, 0x43, 0x44, 0x44, 0x44,	0x45, 0x45, 0x45, 0x46, 0x46, 0x46, 0x47, 0x47,
+	0x42, 0x42, 0x43, 0x43, 0x43, 0x44, 0x44, 0x44,	0x45, 0x45, 0x45, 0x46, 0x46, 0x46, 0x47, 0x47,
+	0x7d, 0x7d, 0x25, 0x25, 0x25, 0x26, 0x26, 0x26,	0x27, 0x27, 0x27, 0x28, 0x28, 0x28, 0x29, 0x29,
+	0x7d, 0x7d, 0x25, 0x25, 0x25, 0x26, 0x26, 0x26,	0x27, 0x27, 0x27, 0x28, 0x28, 0x28, 0x29, 0x29,
+	0x2a, 0x2a, 0x6d, 0x2b, 0x6e, 0x2c, 0x2c, 0x2c,	0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f,
+	0x2a, 0x2a, 0x2b, 0x2b, 0x6e, 0x2c, 0x2c, 0x2c,	0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f,
+	0x2a, 0x2a, 0x6e, 0x6e, 0x6e, 0x6e, 0x2c, 0x2c,	0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f,
+	0x30, 0x30, 0x31, 0x31, 0x6e, 0x6f, 0x32, 0x32,	0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x35, 0x35,
+	0x30, 0x30, 0x31, 0x31, 0x31, 0x32, 0x32, 0x32,	0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x35, 0x35,
+	0x30, 0x30, 0x31, 0x31, 0x31, 0x32, 0x32, 0x32,	0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x35, 0x35,
+	0x36, 0x36, 0x37, 0x37, 0x37, 0x38, 0x38, 0x38,	0x39, 0x39, 0x39, 0x3a, 0x3a, 0x3a, 0x3b, 0x3b,
+	0x36, 0x36, 0x37, 0x37, 0x37, 0x38, 0x38, 0x38,	0x39, 0x39, 0x39, 0x3a, 0x3a, 0x3a, 0x3b, 0x3b,
+	0x36, 0x36, 0x37, 0x37, 0x37, 0x38, 0x38, 0x38,	0x39, 0x39, 0x39, 0x3a, 0x3a, 0x3a, 0x3b, 0x3b,
+	0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3e, 0x3e, 0x3e,	0x3f, 0x3f, 0x3f, 0x40, 0x40, 0x40, 0x41, 0x41,
+	0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3e, 0x3e, 0x3e,	0x3f, 0x3f, 0x3f, 0x40, 0x40, 0x40, 0x41, 0x41,
+	0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3e, 0x3e, 0x3e,	0x3f, 0x3f, 0x3f, 0x40, 0x40, 0x40, 0x41, 0x41,
+	0x42, 0x42, 0x43, 0x43, 0x43, 0x44, 0x44, 0x44,	0x45, 0x45, 0x45, 0x46, 0x46, 0x46, 0x47, 0x47,
+	0x42, 0x42, 0x43, 0x43, 0x43, 0x44, 0x44, 0x44,	0x45, 0x45, 0x45, 0x46, 0x46, 0x46, 0x47, 0x47,
+	0x7e, 0x7e, 0x49, 0x49, 0x49, 0x4a, 0x4a, 0x4a,	0x4b, 0x4b, 0x4b, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d,
+	0x7e, 0x7e, 0x49, 0x49, 0x49, 0x4a, 0x4a, 0x4a,	0x4b, 0x4b, 0x4b, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d,
+	0x4e, 0x4e, 0x4f, 0x4f, 0x4f, 0x50, 0x50, 0x50,	0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x53, 0x53,
+	0x4e, 0x4e, 0x4f, 0x4f, 0x4f, 0x50, 0x50, 0x50,	0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x53, 0x53,
+	0x4e, 0x4e, 0x4f, 0x4f, 0x6e, 0x6f, 0x50, 0x50,	0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x53, 0x53,
+	0x54, 0x54, 0x55, 0x55, 0x6f, 0x6f, 0x6f, 0x6f,	0x57, 0x57, 0x57, 0x58, 0x58, 0x58, 0x59, 0x59,
+	0x54, 0x54, 0x55, 0x55, 0x55, 0x6f, 0x56, 0x56,	0x57, 0x57, 0x57, 0x58, 0x58, 0x58, 0x59, 0x59,
+	0x54, 0x54, 0x55, 0x55, 0x55, 0x6f, 0x56, 0x70,	0x57, 0x57, 0x57, 0x58, 0x58, 0x58, 0x59, 0x59,
+	0x5a, 0x5a, 0x5b, 0x5b, 0x5b, 0x5c, 0x5c, 0x5c,	0x5d, 0x5d, 0x5d, 0x5e, 0x5e, 0x5e, 0x5f, 0x5f,
+	0x5a, 0x5a, 0x5b, 0x5b, 0x5b, 0x5c, 0x5c, 0x5c,	0x5d, 0x5d, 0x5d, 0x5e, 0x5e, 0x5e, 0x5f, 0x5f,
+	0x5a, 0x5a, 0x5b, 0x5b, 0x5b, 0x5c, 0x5c, 0x5c,	0x5d, 0x5d, 0x5d, 0x5e, 0x5e, 0x5e, 0x5f, 0x5f,
+	0x60, 0x60, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62,	0x63, 0x63, 0x63, 0x64, 0x64, 0x64, 0x65, 0x65,
+	0x60, 0x60, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62,	0x63, 0x63, 0x63, 0x64, 0x64, 0x64, 0x65, 0x65,
+	0x60, 0x60, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62,	0x63, 0x63, 0x63, 0x64, 0x64, 0x64, 0x65, 0x65,
+	0x66, 0x66, 0x67, 0x67, 0x67, 0x68, 0x68, 0x68,	0x69, 0x69, 0x69, 0x6a, 0x6a, 0x6a, 0x6b, 0x6b,
+	0x66, 0x66, 0x67, 0x67, 0x67, 0x68, 0x68, 0x68,	0x69, 0x69, 0x69, 0x6a, 0x6a, 0x6a, 0x6b, 0x6b,
+	0x48, 0x48, 0x49, 0x49, 0x49, 0x4a, 0x4a, 0x4a,	0x4b, 0x4b, 0x4b, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d,
+	0x48, 0x48, 0x49, 0x49, 0x49, 0x4a, 0x4a, 0x4a,	0x4b, 0x4b, 0x4b, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d,
+	0x4e, 0x4e, 0x4f, 0x4f, 0x4f, 0x50, 0x50, 0x50,	0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x53, 0x53,
+	0x4e, 0x4e, 0x4f, 0x4f, 0x4f, 0x50, 0x50, 0x50,	0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x53, 0x53,
+	0x4e, 0x4e, 0x4f, 0x4f, 0x4f, 0x50, 0x50, 0x50,	0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x53, 0x53,
+	0x54, 0x54, 0x55, 0x55, 0x55, 0x6f, 0x56, 0x56,	0x57, 0x57, 0x57, 0x58, 0x58, 0x58, 0x59, 0x59,
+	0x54, 0x54, 0x55, 0x55, 0x55, 0x56, 0x56, 0x56,	0x57, 0x57, 0x57, 0x58, 0x58, 0x58, 0x59, 0x59,
+	0x54, 0x54, 0x55, 0x55, 0x55, 0x56, 0x56, 0x70,	0x57, 0x57, 0x57, 0x58, 0x58, 0x58, 0x59, 0x59,
+	0x5a, 0x5a, 0x5b, 0x5b, 0x5b, 0x5c, 0x5c, 0x5c,	0x5d, 0x5d, 0x5d, 0x5e, 0x5e, 0x5e, 0x5f, 0x5f,
+	0x5a, 0x5a, 0x5b, 0x5b, 0x5b, 0x5c, 0x5c, 0x5c,	0x5d, 0x5d, 0x5d, 0x5e, 0x5e, 0x5e, 0x5f, 0x5f,
+	0x5a, 0x5a, 0x5b, 0x5b, 0x5b, 0x5c, 0x5c, 0x5c,	0x5d, 0x5d, 0x5d, 0x5e, 0x5e, 0x5e, 0x5f, 0x5f,
+	0x60, 0x60, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62,	0x63, 0x63, 0x63, 0x64, 0x64, 0x64, 0x65, 0x65,
+	0x60, 0x60, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62,	0x63, 0x63, 0x63, 0x64, 0x64, 0x64, 0x65, 0x65,
+	0x60, 0x60, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62,	0x63, 0x63, 0x63, 0x64, 0x64, 0x64, 0x65, 0x65,
+	0x66, 0x66, 0x67, 0x67, 0x67, 0x68, 0x68, 0x68,	0x69, 0x69, 0x69, 0x6a, 0x6a, 0x6a, 0x6b, 0x6b,
+	0x66, 0x66, 0x67, 0x67, 0x67, 0x68, 0x68, 0x68,	0x69, 0x69, 0x69, 0x6a, 0x6a, 0x6a, 0x6b, 0x6b,
+	0x7f, 0x7f, 0x49, 0x49, 0x49, 0x4a, 0x4a, 0x4a,	0x4b, 0x4b, 0x4b, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d,
+	0x7f, 0x7f, 0x49, 0x49, 0x49, 0x4a, 0x4a, 0x4a,	0x4b, 0x4b, 0x4b, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d,
+	0x4e, 0x4e, 0x4f, 0x4f, 0x4f, 0x50, 0x50, 0x50,	0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x53, 0x53,
+	0x4e, 0x4e, 0x4f, 0x4f, 0x4f, 0x50, 0x50, 0x50,	0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x53, 0x53,
+	0x4e, 0x4e, 0x4f, 0x4f, 0x4f, 0x50, 0x50, 0x50,	0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x53, 0x53,
+	0x54, 0x54, 0x55, 0x55, 0x55, 0x6f, 0x56, 0x70,	0x57, 0x57, 0x57, 0x58, 0x58, 0x58, 0x59, 0x59,
+	0x54, 0x54, 0x55, 0x55, 0x55, 0x56, 0x56, 0x70,	0x57, 0x57, 0x57, 0x58, 0x58, 0x58, 0x59, 0x59,
+	0x54, 0x54, 0x55, 0x55, 0x55, 0x70, 0x70, 0x70,	0x70, 0x57, 0x57, 0x58, 0x58, 0x58, 0x59, 0x59,
+	0x5a, 0x5a, 0x5b, 0x5b, 0x5b, 0x5c, 0x5c, 0x70,	0x8f, 0x5d, 0x5d, 0x5e, 0x5e, 0x5e, 0x5f, 0x5f,
+	0x5a, 0x5a, 0x5b, 0x5b, 0x5b, 0x5c, 0x5c, 0x5c,	0x5d, 0x5d, 0x5d, 0x5e, 0x5e, 0x5e, 0x5f, 0x5f,
+	0x5a, 0x5a, 0x5b, 0x5b, 0x5b, 0x5c, 0x5c, 0x5c,	0x5d, 0x5d, 0x5d, 0x5e, 0x5e, 0x5e, 0x5f, 0x5f,
+	0x60, 0x60, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62,	0x63, 0x63, 0x63, 0x64, 0x64, 0x64, 0x65, 0x65,
+	0x60, 0x60, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62,	0x63, 0x63, 0x63, 0x64, 0x64, 0x64, 0x65, 0x65,
+	0x60, 0x60, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62,	0x63, 0x63, 0x63, 0x64, 0x64, 0x64, 0x65, 0x65,
+	0x66, 0x66, 0x67, 0x67, 0x67, 0x68, 0x68, 0x68,	0x69, 0x69, 0x69, 0x6a, 0x6a, 0x6a, 0x6b, 0x6b,
+	0x66, 0x66, 0x67, 0x67, 0x67, 0x68, 0x68, 0x68,	0x69, 0x69, 0x69, 0x6a, 0x6a, 0x6a, 0x6b, 0x6b,
+	0x80, 0x80, 0x80, 0x95, 0x95, 0x96, 0x96, 0x96,	0x97, 0x97, 0x97, 0x98, 0x98, 0x98, 0x99, 0x99,
+	0x80, 0x80, 0x80, 0x95, 0x95, 0x96, 0x96, 0x96,	0x97, 0x97, 0x97, 0x98, 0x98, 0x98, 0x99, 0x99,
+	0x80, 0x80, 0x9b, 0x9b, 0x9b, 0x9c, 0x9c, 0x9c,	0x9d, 0x9d, 0x9d, 0x9e, 0x9e, 0x9e, 0x9f, 0x9f,
+	0x9a, 0x9a, 0x9b, 0x9b, 0x9b, 0x9c, 0x9c, 0x9c,	0x9d, 0x9d, 0x9d, 0x9e, 0x9e, 0x9e, 0x9f, 0x9f,
+	0x9a, 0x9a, 0x9b, 0x9b, 0x9b, 0x9c, 0x9c, 0x9c,	0x9d, 0x9d, 0x9d, 0x9e, 0x9e, 0x9e, 0x9f, 0x9f,
+	0xa0, 0xa0, 0xa1, 0xa1, 0xa1, 0x6f, 0xa2, 0x70,	0x8f, 0xa3, 0xa3, 0xa4, 0xa4, 0xa4, 0xa5, 0xa5,
+	0xa0, 0xa0, 0xa1, 0xa1, 0xa1, 0xa2, 0xa2, 0x70,	0x8f, 0xa3, 0xa3, 0xa4, 0xa4, 0xa4, 0xa5, 0xa5,
+	0xa0, 0xa0, 0xa1, 0xa1, 0xa1, 0x70, 0x70, 0x70,	0x8f, 0x8f, 0x8f, 0xa4, 0xa4, 0xa4, 0xa5, 0xa5,
+	0xa6, 0xa6, 0xa7, 0xa7, 0xa7, 0x8f, 0x8f, 0x8f,	0x8f, 0x8f, 0x8f, 0x8f, 0xaa, 0xaa, 0xab, 0xab,
+	0xa6, 0xa6, 0xa7, 0xa7, 0xa7, 0xa8, 0xa8, 0x8f,	0x8f, 0xa9, 0xa9, 0xaa, 0xaa, 0xaa, 0xab, 0xab,
+	0xa6, 0xa6, 0xa7, 0xa7, 0xa7, 0xa8, 0xa8, 0x8f,	0x8f, 0xa9, 0x90, 0x90, 0xaa, 0xaa, 0xab, 0xab,
+	0xac, 0xac, 0xad, 0xad, 0xad, 0xae, 0xae, 0xae,	0x8f, 0xaf, 0x90, 0x91, 0xb0, 0xb0, 0xb1, 0xb1,
+	0xac, 0xac, 0xad, 0xad, 0xad, 0xae, 0xae, 0xae,	0xaf, 0xaf, 0xaf, 0xb0, 0xb0, 0xb0, 0xb1, 0xb1,
+	0xac, 0xac, 0xad, 0xad, 0xad, 0xae, 0xae, 0xae,	0xaf, 0xaf, 0xaf, 0xb0, 0xb0, 0xb0, 0xb1, 0xb1,
+	0xb2, 0xb2, 0xb3, 0xb3, 0xb3, 0xb4, 0xb4, 0xb4,	0xb5, 0xb5, 0xb5, 0xb6, 0xb6, 0xb6, 0xb7, 0xb7,
+	0xb2, 0xb2, 0xb3, 0xb3, 0xb3, 0xb4, 0xb4, 0xb4,	0xb5, 0xb5, 0xb5, 0xb6, 0xb6, 0xb6, 0xb7, 0xb7,
+	0x94, 0x94, 0x95, 0x95, 0x95, 0x96, 0x96, 0x96,	0x97, 0x97, 0x97, 0x98, 0x98, 0x98, 0x99, 0x99,
+	0x94, 0x94, 0x95, 0x95, 0x95, 0x96, 0x96, 0x96,	0x97, 0x97, 0x97, 0x98, 0x98, 0x98, 0x99, 0x99,
+	0x9a, 0x9a, 0x9b, 0x9b, 0x9b, 0x9c, 0x9c, 0x9c,	0x9d, 0x9d, 0x9d, 0x9e, 0x9e, 0x9e, 0x9f, 0x9f,
+	0x9a, 0x9a, 0x9b, 0x9b, 0x9b, 0x9c, 0x9c, 0x9c,	0x9d, 0x9d, 0x9d, 0x9e, 0x9e, 0x9e, 0x9f, 0x9f,
+	0x9a, 0x9a, 0x9b, 0x9b, 0x9b, 0x9c, 0x9c, 0x9c,	0x9d, 0x9d, 0x9d, 0x9e, 0x9e, 0x9e, 0x9f, 0x9f,
+	0xa0, 0xa0, 0xa1, 0xa1, 0xa1, 0xa2, 0xa2, 0xa2,	0xa3, 0xa3, 0xa3, 0xa4, 0xa4, 0xa4, 0xa5, 0xa5,
+	0xa0, 0xa0, 0xa1, 0xa1, 0xa1, 0xa2, 0xa2, 0xa2,	0xa3, 0xa3, 0xa3, 0xa4, 0xa4, 0xa4, 0xa5, 0xa5,
+	0xa0, 0xa0, 0xa1, 0xa1, 0xa1, 0xa2, 0xa2, 0x70,	0x8f, 0xa3, 0xa3, 0xa4, 0xa4, 0xa4, 0xa5, 0xa5,
+	0xa6, 0xa6, 0xa7, 0xa7, 0xa7, 0xa8, 0xa8, 0x8f,	0x8f, 0xa9, 0xa9, 0xaa, 0xaa, 0xaa, 0xab, 0xab,
+	0xa6, 0xa6, 0xa7, 0xa7, 0xa7, 0xa8, 0xa8, 0xa8,	0xa9, 0xa9, 0xa9, 0xaa, 0xaa, 0xaa, 0xab, 0xab,
+	0xa6, 0xa6, 0xa7, 0xa7, 0xa7, 0xa8, 0xa8, 0xa8,	0xa9, 0xa9, 0x90, 0x90, 0xaa, 0xaa, 0xab, 0xab,
+	0xac, 0xac, 0xad, 0xad, 0xad, 0xae, 0xae, 0xae,	0xaf, 0xaf, 0x90, 0x91, 0xb0, 0xb0, 0xb1, 0xb1,
+	0xac, 0xac, 0xad, 0xad, 0xad, 0xae, 0xae, 0xae,	0xaf, 0xaf, 0xaf, 0xb0, 0xb0, 0xb0, 0xb1, 0xb1,
+	0xac, 0xac, 0xad, 0xad, 0xad, 0xae, 0xae, 0xae,	0xaf, 0xaf, 0xaf, 0xb0, 0xb0, 0xb0, 0xb1, 0xb1,
+	0xb2, 0xb2, 0xb3, 0xb3, 0xb3, 0xb4, 0xb4, 0xb4,	0xb5, 0xb5, 0xb5, 0xb6, 0xb6, 0xb6, 0xb7, 0xb7,
+	0xb2, 0xb2, 0xb3, 0xb3, 0xb3, 0xb4, 0xb4, 0xb4,	0xb5, 0xb5, 0xb5, 0xb6, 0xb6, 0xb6, 0xb7, 0xb7,
+	0x81, 0x81, 0x81, 0x95, 0x95, 0x96, 0x96, 0x96,	0x97, 0x97, 0x97, 0x98, 0x98, 0x98, 0x99, 0x99,
+	0x81, 0x81, 0x81, 0x95, 0x95, 0x96, 0x96, 0x96,	0x97, 0x97, 0x97, 0x98, 0x98, 0x98, 0x99, 0x99,
+	0x81, 0x81, 0x9b, 0x9b, 0x9b, 0x9c, 0x9c, 0x9c,	0x9d, 0x9d, 0x9d, 0x9e, 0x9e, 0x9e, 0x9f, 0x9f,
+	0x9a, 0x9a, 0x9b, 0x9b, 0x9b, 0x9c, 0x9c, 0x9c,	0x9d, 0x9d, 0x9d, 0x9e, 0x9e, 0x9e, 0x9f, 0x9f,
+	0x9a, 0x9a, 0x9b, 0x9b, 0x9b, 0x9c, 0x9c, 0x9c,	0x9d, 0x9d, 0x9d, 0x9e, 0x9e, 0x9e, 0x9f, 0x9f,
+	0xa0, 0xa0, 0xa1, 0xa1, 0xa1, 0xa2, 0xa2, 0xa2,	0xa3, 0xa3, 0xa3, 0xa4, 0xa4, 0xa4, 0xa5, 0xa5,
+	0xa0, 0xa0, 0xa1, 0xa1, 0xa1, 0xa2, 0xa2, 0xa2,	0xa3, 0xa3, 0xa3, 0xa4, 0xa4, 0xa4, 0xa5, 0xa5,
+	0xa0, 0xa0, 0xa1, 0xa1, 0xa1, 0xa2, 0xa2, 0x70,	0x8f, 0xa3, 0x90, 0xa4, 0xa4, 0xa4, 0xa5, 0xa5,
+	0xa6, 0xa6, 0xa7, 0xa7, 0xa7, 0xa8, 0xa8, 0x8f,	0x8f, 0xa9, 0x90, 0x90, 0xaa, 0xaa, 0xab, 0xab,
+	0xa6, 0xa6, 0xa7, 0xa7, 0xa7, 0xa8, 0xa8, 0xa8,	0xa9, 0xa9, 0x90, 0x90, 0xaa, 0xaa, 0xab, 0xab,
+	0xa6, 0xa6, 0xa7, 0xa7, 0xa7, 0xa8, 0xa8, 0x90,	0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0xab, 0xab,
+	0xac, 0xac, 0xad, 0xad, 0xad, 0xae, 0xae, 0xae,	0x90, 0x90, 0x90, 0x91, 0x91, 0x91, 0xb1, 0xb1,
+	0xac, 0xac, 0xad, 0xad, 0xad, 0xae, 0xae, 0xae,	0xaf, 0xaf, 0x90, 0x91, 0xb0, 0xb0, 0xb1, 0xb1,
+	0xac, 0xac, 0xad, 0xad, 0xad, 0xae, 0xae, 0xae,	0xaf, 0xaf, 0x90, 0x91, 0xb0, 0x92, 0xb1, 0xb1,
+	0xb2, 0xb2, 0xb3, 0xb3, 0xb3, 0xb4, 0xb4, 0xb4,	0xb5, 0xb5, 0xb5, 0xb6, 0xb6, 0xb6, 0xb7, 0xb7,
+	0xb2, 0xb2, 0xb3, 0xb3, 0xb3, 0xb4, 0xb4, 0xb4,	0xb5, 0xb5, 0xb5, 0xb6, 0xb6, 0xb6, 0xb7, 0xb7,
+	0x82, 0x82, 0x82, 0xb9, 0xb9, 0xba, 0xba, 0xba,	0xbb, 0xbb, 0xbb, 0xbc, 0xbc, 0xbc, 0xbd, 0xbd,
+	0x82, 0x82, 0x82, 0xb9, 0xb9, 0xba, 0xba, 0xba,	0xbb, 0xbb, 0xbb, 0xbc, 0xbc, 0xbc, 0xbd, 0xbd,
+	0x82, 0x82, 0xbf, 0xbf, 0xbf, 0xc0, 0xc0, 0xc0,	0xc1, 0xc1, 0xc1, 0xc2, 0xc2, 0xc2, 0xc3, 0xc3,
+	0xbe, 0xbe, 0xbf, 0xbf, 0xbf, 0xc0, 0xc0, 0xc0,	0xc1, 0xc1, 0xc1, 0xc2, 0xc2, 0xc2, 0xc3, 0xc3,
+	0xbe, 0xbe, 0xbf, 0xbf, 0xbf, 0xc0, 0xc0, 0xc0,	0xc1, 0xc1, 0xc1, 0xc2, 0xc2, 0xc2, 0xc3, 0xc3,
+	0xc4, 0xc4, 0xc5, 0xc5, 0xc5, 0xc6, 0xc6, 0xc6,	0xc7, 0xc7, 0xc7, 0xc8, 0xc8, 0xc8, 0xc9, 0xc9,
+	0xc4, 0xc4, 0xc5, 0xc5, 0xc5, 0xc6, 0xc6, 0xc6,	0xc7, 0xc7, 0xc7, 0xc8, 0xc8, 0xc8, 0xc9, 0xc9,
+	0xc4, 0xc4, 0xc5, 0xc5, 0xc5, 0xc6, 0xc6, 0xc6,	0xc7, 0xc7, 0xc7, 0xc8, 0xc8, 0xc8, 0xc9, 0xc9,
+	0xca, 0xca, 0xcb, 0xcb, 0xcb, 0xcc, 0xcc, 0xcc,	0x8f, 0xcd, 0x90, 0x91, 0xce, 0xce, 0xcf, 0xcf,
+	0xca, 0xca, 0xcb, 0xcb, 0xcb, 0xcc, 0xcc, 0xcc,	0xcd, 0xcd, 0x90, 0x91, 0xce, 0xce, 0xcf, 0xcf,
+	0xca, 0xca, 0xcb, 0xcb, 0xcb, 0xcc, 0xcc, 0xcc,	0x90, 0x90, 0x90, 0x91, 0x91, 0x91, 0xcf, 0xcf,
+	0xd0, 0xd0, 0xd1, 0xd1, 0xd1, 0xd2, 0xd2, 0xd2,	0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0xd5,
+	0xd0, 0xd0, 0xd1, 0xd1, 0xd1, 0xd2, 0xd2, 0xd2,	0xd3, 0xd3, 0x91, 0x91, 0xd4, 0xd4, 0xd5, 0xd5,
+	0xd0, 0xd0, 0xd1, 0xd1, 0xd1, 0xd2, 0xd2, 0xd2,	0xd3, 0xd3, 0x91, 0x91, 0xd4, 0x92, 0x92, 0xd5,
+	0xd6, 0xd6, 0xd7, 0xd7, 0xd7, 0xd8, 0xd8, 0xd8,	0xd9, 0xd9, 0xd9, 0x91, 0xda, 0x92, 0x93, 0xdb,
+	0xd6, 0xd6, 0xd7, 0xd7, 0xd7, 0xd8, 0xd8, 0xd8,	0xd9, 0xd9, 0xd9, 0xda, 0xda, 0xda, 0xdb, 0xdb,
+	0xb8, 0xb8, 0xb9, 0xb9, 0xb9, 0xba, 0xba, 0xba,	0xbb, 0xbb, 0xbb, 0xbc, 0xbc, 0xbc, 0xbd, 0xbd,
+	0xb8, 0xb8, 0xb9, 0xb9, 0xb9, 0xba, 0xba, 0xba,	0xbb, 0xbb, 0xbb, 0xbc, 0xbc, 0xbc, 0xbd, 0xbd,
+	0xbe, 0xbe, 0xbf, 0xbf, 0xbf, 0xc0, 0xc0, 0xc0,	0xc1, 0xc1, 0xc1, 0xc2, 0xc2, 0xc2, 0xc3, 0xc3,
+	0xbe, 0xbe, 0xbf, 0xbf, 0xbf, 0xc0, 0xc0, 0xc0,	0xc1, 0xc1, 0xc1, 0xc2, 0xc2, 0xc2, 0xc3, 0xc3,
+	0xbe, 0xbe, 0xbf, 0xbf, 0xbf, 0xc0, 0xc0, 0xc0,	0xc1, 0xc1, 0xc1, 0xc2, 0xc2, 0xc2, 0xc3, 0xc3,
+	0xc4, 0xc4, 0xc5, 0xc5, 0xc5, 0xc6, 0xc6, 0xc6,	0xc7, 0xc7, 0xc7, 0xc8, 0xc8, 0xc8, 0xc9, 0xc9,
+	0xc4, 0xc4, 0xc5, 0xc5, 0xc5, 0xc6, 0xc6, 0xc6,	0xc7, 0xc7, 0xc7, 0xc8, 0xc8, 0xc8, 0xc9, 0xc9,
+	0xc4, 0xc4, 0xc5, 0xc5, 0xc5, 0xc6, 0xc6, 0xc6,	0xc7, 0xc7, 0xc7, 0xc8, 0xc8, 0xc8, 0xc9, 0xc9,
+	0xca, 0xca, 0xcb, 0xcb, 0xcb, 0xcc, 0xcc, 0xcc,	0xcd, 0xcd, 0xcd, 0xce, 0xce, 0xce, 0xcf, 0xcf,
+	0xca, 0xca, 0xcb, 0xcb, 0xcb, 0xcc, 0xcc, 0xcc,	0xcd, 0xcd, 0xcd, 0xce, 0xce, 0xce, 0xcf, 0xcf,
+	0xca, 0xca, 0xcb, 0xcb, 0xcb, 0xcc, 0xcc, 0xcc,	0xcd, 0xcd, 0x90, 0x91, 0xce, 0xce, 0xcf, 0xcf,
+	0xd0, 0xd0, 0xd1, 0xd1, 0xd1, 0xd2, 0xd2, 0xd2,	0xd3, 0xd3, 0x91, 0x91, 0xd4, 0xd4, 0xd5, 0xd5,
+	0xd0, 0xd0, 0xd1, 0xd1, 0xd1, 0xd2, 0xd2, 0xd2,	0xd3, 0xd3, 0xd3, 0xd4, 0xd4, 0xd4, 0xd5, 0xd5,
+	0xd0, 0xd0, 0xd1, 0xd1, 0xd1, 0xd2, 0xd2, 0xd2,	0xd3, 0xd3, 0xd3, 0xd4, 0xd4, 0x92, 0x92, 0xd5,
+	0xd6, 0xd6, 0xd7, 0xd7, 0xd7, 0xd8, 0xd8, 0xd8,	0xd9, 0xd9, 0xd9, 0xda, 0xda, 0x92, 0x93, 0xdb,
+	0xd6, 0xd6, 0xd7, 0xd7, 0xd7, 0xd8, 0xd8, 0xd8,	0xd9, 0xd9, 0xd9, 0xda, 0xda, 0xda, 0xdb, 0xdb,
+	0x83, 0x83, 0x83, 0xb9, 0xb9, 0xba, 0xba, 0xba,	0xbb, 0xbb, 0xbb, 0xbc, 0xbc, 0xbc, 0xbd, 0xbd,
+	0x83, 0x83, 0x83, 0xb9, 0xb9, 0xba, 0xba, 0xba,	0xbb, 0xbb, 0xbb, 0xbc, 0xbc, 0xbc, 0xbd, 0xbd,
+	0x83, 0x83, 0xbf, 0xbf, 0xbf, 0xc0, 0xc0, 0xc0,	0xc1, 0xc1, 0xc1, 0xc2, 0xc2, 0xc2, 0xc3, 0xc3,
+	0xbe, 0xbe, 0xbf, 0xbf, 0xbf, 0xc0, 0xc0, 0xc0,	0xc1, 0xc1, 0xc1, 0xc2, 0xc2, 0xc2, 0xc3, 0xc3,
+	0xbe, 0xbe, 0xbf, 0xbf, 0xbf, 0xc0, 0xc0, 0xc0,	0xc1, 0xc1, 0xc1, 0xc2, 0xc2, 0xc2, 0xc3, 0xc3,
+	0xc4, 0xc4, 0xc5, 0xc5, 0xc5, 0xc6, 0xc6, 0xc6,	0xc7, 0xc7, 0xc7, 0xc8, 0xc8, 0xc8, 0xc9, 0xc9,
+	0xc4, 0xc4, 0xc5, 0xc5, 0xc5, 0xc6, 0xc6, 0xc6,	0xc7, 0xc7, 0xc7, 0xc8, 0xc8, 0xc8, 0xc9, 0xc9,
+	0xc4, 0xc4, 0xc5, 0xc5, 0xc5, 0xc6, 0xc6, 0xc6,	0xc7, 0xc7, 0xc7, 0xc8, 0xc8, 0xc8, 0xc9, 0xc9,
+	0xca, 0xca, 0xcb, 0xcb, 0xcb, 0xcc, 0xcc, 0xcc,	0xcd, 0xcd, 0xcd, 0xce, 0xce, 0xce, 0xcf, 0xcf,
+	0xca, 0xca, 0xcb, 0xcb, 0xcb, 0xcc, 0xcc, 0xcc,	0xcd, 0xcd, 0xcd, 0xce, 0xce, 0xce, 0xcf, 0xcf,
+	0xca, 0xca, 0xcb, 0xcb, 0xcb, 0xcc, 0xcc, 0xcc,	0xcd, 0xcd, 0x90, 0x91, 0xce, 0x92, 0xcf, 0xcf,
+	0xd0, 0xd0, 0xd1, 0xd1, 0xd1, 0xd2, 0xd2, 0xd2,	0xd3, 0xd3, 0x91, 0x91, 0xd4, 0x92, 0x92, 0xd5,
+	0xd0, 0xd0, 0xd1, 0xd1, 0xd1, 0xd2, 0xd2, 0xd2,	0xd3, 0xd3, 0xd3, 0xd4, 0xd4, 0x92, 0x92, 0xd5,
+	0xd0, 0xd0, 0xd1, 0xd1, 0xd1, 0xd2, 0xd2, 0xd2,	0xd3, 0xd3, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92,
+	0xd6, 0xd6, 0xd7, 0xd7, 0xd7, 0xd8, 0xd8, 0xd8,	0xd9, 0xd9, 0xd9, 0x92, 0x92, 0x92, 0x93, 0x93,
+	0xd6, 0xd6, 0xd7, 0xd7, 0xd7, 0xd8, 0xd8, 0xd8,	0xd9, 0xd9, 0xd9, 0xda, 0xda, 0x92, 0x93, 0xdb,
+	0x84, 0x84, 0x84, 0xdd, 0xdd, 0xde, 0xde, 0xde,	0xdf, 0xdf, 0xdf, 0xe0, 0xe0, 0xe0, 0xe1, 0xe1,
+	0x84, 0x84, 0x84, 0xdd, 0xdd, 0xde, 0xde, 0xde,	0xdf, 0xdf, 0xdf, 0xe0, 0xe0, 0xe0, 0xe1, 0xe1,
+	0x84, 0x84, 0xe3, 0xe3, 0xe3, 0xe4, 0xe4, 0xe4,	0xe5, 0xe5, 0xe5, 0xe6, 0xe6, 0xe6, 0xe7, 0xe7,
+	0xe2, 0xe2, 0xe3, 0xe3, 0xe3, 0xe4, 0xe4, 0xe4,	0xe5, 0xe5, 0xe5, 0xe6, 0xe6, 0xe6, 0xe7, 0xe7,
+	0xe2, 0xe2, 0xe3, 0xe3, 0xe3, 0xe4, 0xe4, 0xe4,	0xe5, 0xe5, 0xe5, 0xe6, 0xe6, 0xe6, 0xe7, 0xe7,
+	0xe8, 0xe8, 0xe9, 0xe9, 0xe9, 0xea, 0xea, 0xea,	0xeb, 0xeb, 0xeb, 0xec, 0xec, 0xec, 0xed, 0xed,
+	0xe8, 0xe8, 0xe9, 0xe9, 0xe9, 0xea, 0xea, 0xea,	0xeb, 0xeb, 0xeb, 0xec, 0xec, 0xec, 0xed, 0xed,
+	0xe8, 0xe8, 0xe9, 0xe9, 0xe9, 0xea, 0xea, 0xea,	0xeb, 0xeb, 0xeb, 0xec, 0xec, 0xec, 0xed, 0xed,
+	0xee, 0xee, 0xef, 0xef, 0xef, 0xf0, 0xf0, 0xf0,	0xf1, 0xf1, 0xf1, 0xf2, 0xf2, 0xf2, 0xf3, 0xf3,
+	0xee, 0xee, 0xef, 0xef, 0xef, 0xf0, 0xf0, 0xf0,	0xf1, 0xf1, 0xf1, 0xf2, 0xf2, 0xf2, 0xf3, 0xf3,
+	0xee, 0xee, 0xef, 0xef, 0xef, 0xf0, 0xf0, 0xf0,	0xf1, 0xf1, 0xf1, 0xf2, 0xf2, 0xf2, 0xf3, 0xf3,
+	0xf4, 0xf4, 0xf5, 0xf5, 0xf5, 0xf6, 0xf6, 0xf6,	0xf7, 0xf7, 0xf7, 0x91, 0xf8, 0x92, 0x93, 0xf9,
+	0xf4, 0xf4, 0xf5, 0xf5, 0xf5, 0xf6, 0xf6, 0xf6,	0xf7, 0xf7, 0xf7, 0xf8, 0xf8, 0x92, 0x93, 0xf9,
+	0xf4, 0xf4, 0xf5, 0xf5, 0xf5, 0xf6, 0xf6, 0xf6,	0xf7, 0xf7, 0xf7, 0x92, 0x92, 0x92, 0x93, 0x93,
+	0xfa, 0xfa, 0xfb, 0xfb, 0xfb, 0xfc, 0xfc, 0xfc,	0xfd, 0xfd, 0xfd, 0x93, 0x93, 0x93, 0x93, 0x93,
+	0xfa, 0xfa, 0xfb, 0xfb, 0xfb, 0xfc, 0xfc, 0xfc,	0xfd, 0xfd, 0xfd, 0xfe, 0xfe, 0x93, 0x93, 0xff,
+	0xdc, 0xdc, 0xdd, 0xdd, 0xdd, 0xde, 0xde, 0xde,	0xdf, 0xdf, 0xdf, 0xe0, 0xe0, 0xe0, 0xe1, 0xe1,
+	0xdc, 0xdc, 0xdd, 0xdd, 0xdd, 0xde, 0xde, 0xde,	0xdf, 0xdf, 0xdf, 0xe0, 0xe0, 0xe0, 0xe1, 0xe1,
+	0xe2, 0xe2, 0xe3, 0xe3, 0xe3, 0xe4, 0xe4, 0xe4,	0xe5, 0xe5, 0xe5, 0xe6, 0xe6, 0xe6, 0xe7, 0xe7,
+	0xe2, 0xe2, 0xe3, 0xe3, 0xe3, 0xe4, 0xe4, 0xe4,	0xe5, 0xe5, 0xe5, 0xe6, 0xe6, 0xe6, 0xe7, 0xe7,
+	0xe2, 0xe2, 0xe3, 0xe3, 0xe3, 0xe4, 0xe4, 0xe4,	0xe5, 0xe5, 0xe5, 0xe6, 0xe6, 0xe6, 0xe7, 0xe7,
+	0xe8, 0xe8, 0xe9, 0xe9, 0xe9, 0xea, 0xea, 0xea,	0xeb, 0xeb, 0xeb, 0xec, 0xec, 0xec, 0xed, 0xed,
+	0xe8, 0xe8, 0xe9, 0xe9, 0xe9, 0xea, 0xea, 0xea,	0xeb, 0xeb, 0xeb, 0xec, 0xec, 0xec, 0xed, 0xed,
+	0xe8, 0xe8, 0xe9, 0xe9, 0xe9, 0xea, 0xea, 0xea,	0xeb, 0xeb, 0xeb, 0xec, 0xec, 0xec, 0xed, 0xed,
+	0xee, 0xee, 0xef, 0xef, 0xef, 0xf0, 0xf0, 0xf0,	0xf1, 0xf1, 0xf1, 0xf2, 0xf2, 0xf2, 0xf3, 0xf3,
+	0xee, 0xee, 0xef, 0xef, 0xef, 0xf0, 0xf0, 0xf0,	0xf1, 0xf1, 0xf1, 0xf2, 0xf2, 0xf2, 0xf3, 0xf3,
+	0xee, 0xee, 0xef, 0xef, 0xef, 0xf0, 0xf0, 0xf0,	0xf1, 0xf1, 0xf1, 0xf2, 0xf2, 0xf2, 0xf3, 0xf3,
+	0xf4, 0xf4, 0xf5, 0xf5, 0xf5, 0xf6, 0xf6, 0xf6,	0xf7, 0xf7, 0xf7, 0xf8, 0xf8, 0xf8, 0xf9, 0xf9,
+	0xf4, 0xf4, 0xf5, 0xf5, 0xf5, 0xf6, 0xf6, 0xf6,	0xf7, 0xf7, 0xf7, 0xf8, 0xf8, 0xf8, 0xf9, 0xf9,
+	0xf4, 0xf4, 0xf5, 0xf5, 0xf5, 0xf6, 0xf6, 0xf6,	0xf7, 0xf7, 0xf7, 0xf8, 0xf8, 0x92, 0x93, 0xf9,
+	0xfa, 0xfa, 0xfb, 0xfb, 0xfb, 0xfc, 0xfc, 0xfc,	0xfd, 0xfd, 0xfd, 0xfe, 0xfe, 0x93, 0x93, 0xff,
+	0xfa, 0xfa, 0xfb, 0xfb, 0xfb, 0xfc, 0xfc, 0xfc,	0xfd, 0xfd, 0xfd, 0xfe, 0xfe, 0xfe, 0xff, 0xff
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/inc/statcommon.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,195 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef STATCOMMON_H
+#define STATCOMMON_H
+
+// external definitions
+#include "stat.h"
+
+// current version - edit this for version updates to DLL
+#define STAT_VERSION_MAJOR "3"
+#define STAT_VERSION_MINOR "4"
+#define STAT_VERSION_PATCH "1001"
+
+
+// amount of time a thread sleeps between each processing cycle
+#define STAT_THREAD_SLEEP_TIME 5
+
+#define STAT_INI_NAME _T("stat.ini")
+
+
+#define STAT_WORKINGPATH_VALUE		_T("c:\\apps\\stat\\Work")
+
+#define STAT_LOGFILEPATH_VALUE		_T("c:\\apps\\stat\\LogFiles")
+
+#define STAT_SCRIPTFILEPATH_VALUE	_T("c:\\apps\\stat\\Scripts")
+
+#define STAT_INSTALLPATH_VALUE	_T("c:\\apps\\stat")
+
+
+// STAT Desktop and DLL Tester registry settings
+#define ST_TEST_KEY						_T("Settings")
+#define ST_ITERATIONS					_T("Iterations")
+
+#define ST_DELAY						_T("Delay")
+#define ST_DELAY_VALUE					_T("")
+
+#define ST_LOGFILE						_T("Logfile")
+#define ST_CMDFILE						_T("Commandfile")
+#define ST_RAWCMD						_T("RawCommand")
+
+#define ST_FUDGE						_T("FudgeFactor")
+#define ST_FUDGE_VALUE					_T("0")
+
+#define ST_SNAPSHOT						_T("Snapshot")
+
+#define ST_REFDIR						_T("RefDir")
+#define ST_REFDIR_VALUE					_T("")
+
+#define ST_ADDRESS						_T("Address")
+#define ST_RAWCMD						_T("RawCommand")
+#define ST_LINK							_T("LinkIndex")
+#define ST_CONNECTIONIDX				_T("ConnectionIndex")
+#define ST_CONNECTIONDLL				_T("ConnectionDLL")
+
+#define ST_CONNECTION					_T("Connection")
+#define ST_CONNECTION_VALUE				_T("SymbianSerial:COM2")
+
+#define ST_PLATFORM						_T("PlatformIndex")
+#define ST_VERIFYREMOVEIMAGES			_T("VerifyRemoveImages")
+
+#define ST_VERIFYIMAGE					_T("VerifyImage")
+#define ST_VERIFYIMAGE_VALUE			0
+
+#define ST_LOGTOFILE					_T("LogToFile")
+#define ST_LOGTOFILE_VALUE				0
+
+
+#define ST_SCRIPT						_T("Script")
+#define ST_SCRIPT_VALUE					_T("<b><s><e>")
+
+#define ST_CUST_LOGFILE					_T("CustomLogFile")
+#define ST_CUST_LOGFILE_VALUE			_T("")
+
+#define ST_APPEND						_T("Append")
+#define ST_APPEND_VALUE					0
+
+#define ST_CHKRAWCMD					_T("ChkRawCmd")
+#define ST_CHKCMDFILE					_T("ChkCmdFile")
+#define ST_CHKVERIF						_T("ChkVerif")
+#define ST_CHKSNAP						_T("ChkSnap")
+#define ST_CHKLOGTOFILE					_T("ChkLogtofile")
+
+#define ST_WORKINGPATH					_T("WorkingPath")
+#define ST_WORKINGPATH_VALUE			_T("c:\\apps\\stat\\Work")
+
+#define ST_LOGFILEPATH					_T("LogFilePath")
+#define ST_LOGFILEPATH_VALUE			_T("c:\\apps\\stat\\LogFiles")
+
+#define ST_SCRIPTFILEPATH				_T("ScriptFilePath")
+#define ST_SCRIPTFILEPATH_VALUE			_T("c:\\apps\\stat\\Scripts")
+
+#define ST_INSTALLPATH				_T("InstallPath")
+#define ST_INSTALLPATH_VALUE			_T("c:\\apps\\stat")
+
+// STAT Service registry settings
+#define ST_CONTROLLER_LIST				_T("Controllers")
+#define ST_CONNECTION_LIST				_T("Connections")
+#define ST_TRANSPORT_TYPE				_T("ServiceTransport")
+#define ST_TRANSPORT_PORT				_T("ServicePort")
+#define ST_SCRIPTLOCATION				_T("ScriptLocation")
+#define ST_LOGLOCATION					_T("LogLocation")
+
+// STAT Service command types
+typedef enum STATCommandType
+{
+	SymbianScript		= 1,
+	SymbianError		= 2,
+	SymbianDeviceInfo	= 3,
+	SymbianServiceLogs	= 4
+} STATCOMMANDTYPE;
+
+// default socket communication ports
+#define ST_DEFAULTDEVICEPORT			3000
+#define ST_DEFAULTSERVICEPORT			3001
+#define ST_MAX_CONNECTION_COUNT			25
+
+// script execution states
+typedef enum StatState
+{
+	STAT_RUN,
+	STAT_PAUSE,
+	STAT_STOP
+} STAT_STATE;
+
+#define STAT_APPNAME		"STAT DLL"
+#define STAT_SERVICENAME	"STAT Service"
+
+//not used
+// logging defaults
+//#define STAT_APPNAME	"STAT DLL"
+//#define STAT_LOGDIR		"C:\\"
+//#define STAT_LOGFILE	"stat_output.log"
+
+// debug file returned from remote device
+//#define STAT_DEBUGFILE	"C:\\stat_debug.log"
+
+#define MAX_LOG_MSG_LEN		1024
+#define MAX_ERROR_MSG_LEN	256
+
+#ifdef UNICODE
+#define MAX_UNICODE_LEN		2048
+#endif
+
+// communications
+typedef struct STATCommand
+{
+	unsigned long cIdentifier;	// used as 'char' but 'unsigned long' to cater for word boundaries
+//	char cIdentifier;
+	unsigned long ulLength;
+} STATCOMMAND;
+
+// special command identifiers
+#define STAT_FAILURE		'*'
+#define STAT_RESYNCID		'?'
+#define STAT_REFRESH		'Q'
+#define STAT_BEGIN			'B'
+#define STAT_END			'E'
+#define STAT_REBOOT			'|'
+
+
+// size of data transmissions
+// This is moved to a header file common to desktop 
+// and device side code.
+
+// timeouts on no data
+#define STAT_MAXTIME		240000	// max time to process a command
+#define STAT_RETRYDELAY		330		// delay between checking the port when no data
+
+// timeouts on transmission errors
+#define STAT_MAX_ERRORLEN	1024	// max length of error text
+#define STAT_MAXERRORS		7		// max errors allowed in a single command
+
+// old #defines used in connect transport
+#define STAT_ERRORDELAY		3000	// delay on an error
+#define STAT_MAXRETRIES		10		// max retries on error
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/inc/statcomms.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,62 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef STATCOMMS_H
+#define STATCOMMS_H
+
+#include "statcommon.h"
+#include "stattransport.h"
+
+class STATComms : public CSTATTransport
+{
+public:
+	STATComms();
+	~STATComms();
+
+	int SetTransport(const STATCONNECTTYPE eConnect);
+	int Initialise(void);
+	int Connect(const char *pAddress = NULL);
+	int Send(const char cIdentifier, const char *pData = NULL, const unsigned long ulLength = 0);
+	int Receive(char *cIdentifier, char **ppData = NULL, unsigned long *pLength = NULL);
+	int Disconnect(void);
+	int Release(void);
+	char * Error(void);
+	unsigned int GetMaxPacketSize(void) const;	// Get the maximum size
+												// of each data paacket we transfer
+												// in one go.
+												// Sub-classes will override this
+												// if tey support breaking up of
+												// packets.
+
+private:
+	CSTATTransport *pTransport;			// pointer to the selected transport
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// STATComms::GetMaxPacketSize
+// Our implementation checks if we have a transport component
+// and delegates to that object or returns the base class
+// implementation.
+inline unsigned int STATComms::GetMaxPacketSize(void) const
+{
+	return (pTransport->GetMaxPacketSize());
+}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/inc/statengine.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,126 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef STATENGINE_H
+#define STATENGINE_H
+
+#include <statcommon.h>
+#include <CSTATLogfile.h>
+#include <CSTATDataFormatConverter.h>
+#include <CSTATImageVerify.h>
+#include <statcomms.h>
+#include <statscriptdecoder.h>
+#include <ini.h>
+
+#include "ScriptProgressMonitor.h"
+#include <winsock2.h>
+
+#define DOTTED_LINE "--------------------------------------------------------------------------------------------------------------"
+
+class CSTATEngine
+{
+public:
+	CSTATEngine();
+	~CSTATEngine();
+	int Initialise(const STATCONNECTTYPE eConnect, const char *pAddress = NULL);	// start everything
+	void SetCommandDelay(int iMillisecondDelay);					// set delay between commands
+	int SetLogging(const CString& logfilename, const char* prefix, 
+			bool append, bool bMessages, bool bFile, MessageReporter *const aMessageReporter);	// set a log message
+	int GetCommandCount(CString file, int *pCount);					// get amount of commands in script
+	int OpenScriptFile(CString file, bool bIsFile);					// load the script
+	int RunScript(ScriptProgressMonitor *const monitor);			// run the script
+	int Release(void);												// release all resources
+	const char* GetErrorText(int iCode) { return pLog->Text(iCode); }	// convert an error code into a text message
+	const char* GetReceivedData(void);
+	int GetDeviceReturnCode() { return iDeviceCode; }				// get device return code
+	void SetMultithreaded(bool bState = true) { bMultithreaded = bState; }	// set multithreaded check
+
+	static LPTSTR ToUnicode(const char *string);					// convert ANSI to Unicode
+	static char * ToAnsi(LPCTSTR string);							// convert Unicode to ANSI
+	static void CreateAllDirectories(CString &fullpath);			// create sub folders
+	
+	CSTATDataFormatConverter *pConverter;							// bitmap conversion
+	CSTATImageVerify *pImageVerify;									// image verification
+	STAT_STATE eStopProcessing;										// flag to pause/stop processing
+	int iCurrentCommand;											// index of the current command being processed
+	char *pDeviceInfo;												// pointer to device information
+	char *iTEFSharedData;											// pointer to TEF shared data information
+	int iMaxTimeLimit;												// max time to wait for a command
+
+private:
+
+	
+
+	void SetScreenshotDirectory(const char *szScreenshotDir)	{ cScreenshotDirectory = szScreenshotDir; }
+	int SetScreenshotDefaultDirectory(void);
+	int SendCommand(CSTATScriptCommand *pCommand, CSTATScriptCommand **ppRecvCommand);
+	int SendSingleCommand(CSTATScriptCommand *pCommand, CSTATScriptCommand **ppRecvCommand);
+	int ReadTransferFile(const char *pFile, CSTATScriptCommand *pCommand);
+	int SaveTransferFile(const char *pFile, char *pContents, unsigned long ulLength);
+	void LogDetails(const char *prefix, CSTATScriptCommand *pCommand);
+	int ConvertAndSaveScreeenshot(CString &file, const char *pContents, const unsigned long ulLength);
+	int SaveTheFile(CString path, const char *pContents, const unsigned long ulLength);
+	void Message(const char *pMsg, ...);
+	bool StopProcessing();
+	bool RemoveLeftoverMBMFiles();
+	void AppendCommandToSTATLog(char *heading, char *log, unsigned long length);
+	void StoreData( char* aData, unsigned long aLength, char*& aOutputPtr );
+	CString GetConnection(STATCONNECTTYPE eConnectType);
+
+	CSTATScriptCommand oRecvCommand;		// last received command
+	STATComms *pComms;						// transport
+	CSTATScriptDecoder *pDecoder;			// script decoder
+	CSTATLogFile *pLog;						// log file
+	CString cScreenshotDirectory;			// screenshot location
+	int iDelay;								// command delay
+	const int minimumdelay;
+	const int maximumdelay;
+	char szAddress[256];					// the name of the port we are using
+	STATCONNECTTYPE eConnectType;			// current connection type
+	int iDeviceCode;						// device return code
+	bool bMultithreaded;					// flag if operating in multithreaded environment
+	CStatIniFile statIniFile;					// ini file reader
+	CString receivedData;
+
+	void WriteToSocket(const char *data, int *length);
+	void ReadFromSocket(char *data, int *length);
+	int SetSocket(const char *ip, const int port);
+	int ReleaseSocket();
+
+	bool settingSocket;
+	SOCKET dataSocket;
+	WSADATA wsaData;
+
+};
+
+inline const char* CSTATEngine::GetReceivedData(void)
+{
+	return ( receivedData.operator LPCTSTR( ) );
+}
+
+
+
+//----------------------------------------------------------------------------
+// our thread-safe mechanism - this must be defined, initialised and destroyed by
+// the code using CSTATEngine.  See STATMember.cpp for an example
+extern CRITICAL_SECTION CriticalSection;
+//----------------------------------------------------------------------------
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/inc/statexp.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,234 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef STATEXP30_H
+#define STATEXP30_H
+
+#ifndef STAT_EXPORT
+#define STAT_EXPORT // __declspec(dllexport) // exports now defined in .DEF file
+#endif
+
+#include <Stat.h>
+#include <StatCommon.h>
+#include <ScriptProgressMonitor.h>
+#include <MessageReporter.h>
+#include <CStatReturnCodes.h>
+
+// These functions are exported by name from the STAT DLL and should
+// be linked with dynamically by any application that needs them.
+
+const char	ProcVersion[] =	{ "StdVersion" };
+typedef	const char* (WINAPI *PROC_VERSION)( void );
+
+const char	ProcGetError[] =	{ "StdGetError" };
+typedef	const char* (WINAPI *PROC_GETERROR)( int handle );
+
+const char	ProcGetErrorText[] =	{ "StdGetErrorText" };
+typedef	const char* (WINAPI *PROC_GETERRORTEXT)( int handle, int errorCode );
+
+const char	ProcGetTEFSharedData[] =	{ "StdGetTEFSharedData" };
+typedef	const char* (WINAPI *PROC_GETTEFSHAREDDATA)( int handle );
+
+const char	ProcSetConnectionLogging[] =	{ "StdSetConnectionLogging" };
+typedef	int (WINAPI *PROC_SETCONNECTIONLOGGING)( const char *logPath );
+
+const char	ProcCloseConnectionLogging[] =	{ "StdCloseConnectionLogging" };
+typedef	void (WINAPI *PROC_CLOSECONNECTIONLOGGING)( void );
+
+const char	ProcConnect[] =	{ "StdConnect" };
+typedef	int (WINAPI *PROC_CONNECT)(	STATCONNECTTYPE iConnectType,
+									const char * pszPlatformType,
+									void *,
+									void *);
+
+const char	ProcDisconnect[] =	{ "StdDisconnect" };
+typedef	int (WINAPI *PROC_DISCONNECT)( int handle );
+
+const char	ProcSetCommandDelay[] =	{ "StdSetCommandDelay" };
+typedef	int (WINAPI *PROC_SETCOMMANDDELAY)(	int handle,
+											unsigned int iMillisecondDelay
+											);
+
+const char	ProcSetCommandLogging[] =	{ "StdSetCommandLogging" };
+typedef	int (WINAPI *PROC_SETCOMMANDLOGGING)(	int handle, 
+												const char *pszLogPath,
+												MessageReporter *const aMessageReporter,
+												STATLOGLEVEL iLevel,
+												bool bAppend,
+												void*,
+												void*
+												);
+
+const char	ProcSetImageVerification[] =	{ "StdSetImageVerification" };
+typedef	int (WINAPI *PROC_SETIMAGEVERIFICATION)(	int handle, 
+													const char *pszRefDir, 
+													bool bRemoveOldImages, 
+													int iFactor
+													);
+
+const char	ProcOpenScriptFile[] =	{ "StdOpenScriptFile" };
+typedef	int (WINAPI *PROC_OPENSCRIPTFILE)(	int handle, 
+											LPCTSTR pszText,
+											bool bIsFile
+											);
+
+const char	ProcRunScript[] =	{ "StdRunScript" };
+typedef	int (WINAPI *PROC_RUNSCRIPT)(	int handle, 
+										ScriptProgressMonitor *const monitor
+										);
+
+const char	ProcSendRawCommand[] =	{ "StdSendRawCommand" };
+typedef	int (WINAPI *PROC_SENDRAWCOMMAND)(	int handle, 
+											const char *pszText,
+											ScriptProgressMonitor *const monitor
+											);
+
+const char	ProcSendCommandFile[] =	{ "StdSendCommandFile" };
+typedef	int (WINAPI *PROC_SENDCOMMANDFILE)(	int handle, 
+											const char *pszFile,
+											ScriptProgressMonitor *const monitor
+											);
+
+const char	ProcGetCommandCount[] =	{ "StdGetCommandCount" };
+typedef	int (WINAPI *PROC_GETCOMMANDCOUNT)(	int handle, 
+											const char *pszFile,
+											int *commandCount
+											);
+
+const char	ProcGetCurrentCommandNumber[] =	{ "StdGetCurrentCommandNumber" };
+typedef	int (WINAPI *PROC_GETCURRENTCOMMANDNUMBER)(	int handle, 
+													int *commandNumber
+													);
+
+const char	ProcGetReceivedData[] =	{ "StdGetReceivedData" };
+typedef	const char* (WINAPI *PROC_GETRECEIVEDDATA)( int handle );
+const char	ProcStopProcessing[] =	{ "StdStopProcessing" };
+typedef	int (WINAPI *PROC_STOPPROCESSING)( int handle );
+
+const char	ProcGetSnapShot[] =	{ "StdGetSnapShot" };
+typedef	int (WINAPI *PROC_GETSNAPSHOT)(	int handle, 
+										TBitmapFileHeader **ppFile,
+										TBitmapInfoHeader **ppBitmap,
+										char **ppData,
+										unsigned long *pSize
+										);
+
+const char	DLLFolder[] =	{ "\\epoc32\\tools\\stat" };
+const char	DLLName[] =	{ "stat.dll" };
+const char	DLLUsbName[] =	{ "SymbianUsb.dll" };
+
+// Exported funcion entrypoints
+extern "C"
+{
+	// miscellaneous
+	STAT_EXPORT const char * __cdecl Version();
+	STAT_EXPORT const char * __stdcall StdVersion();
+
+	STAT_EXPORT const char * __cdecl GetError(const int handle = 0);
+	STAT_EXPORT const char * __stdcall StdGetError(const int handle = 0);
+
+	STAT_EXPORT const char * __cdecl GetErrorText(const int handle, int errorCode);
+	STAT_EXPORT const char * __stdcall StdGetErrorText(const int handle, int errorCode);
+
+	STAT_EXPORT const char * __cdecl GetTEFSharedData(const int handle = 0);
+	STAT_EXPORT const char * __stdcall StdGetTEFSharedData(const int handle = 0);
+
+	STAT_EXPORT int __cdecl SetConnectionLogging(const char *pszLogPath);
+	STAT_EXPORT void __cdecl CloseConnectionLogging();
+	STAT_EXPORT int __stdcall StdSetConnectionLogging(const char *pszLogPath);
+	STAT_EXPORT void __stdcall StdCloseConnectionLogging();
+	
+	// connection
+	STAT_EXPORT int __cdecl Connect(const STATCONNECTTYPE iConnectType, 
+							const char *pszPlatformType, 
+							void *Reserved1 = NULL, 
+							void *Reserved2 = NULL);
+	STAT_EXPORT int __stdcall StdConnect(const STATCONNECTTYPE iConnectType, 
+										 const char *pszPlatformType, 
+										 void *Reserved1 = NULL, 
+										 void *Reserved2 = NULL);
+
+	STAT_EXPORT int __cdecl ConnectMT(const STATCONNECTTYPE iConnectType, 
+							const char *pszPlatformType);
+	STAT_EXPORT int __stdcall StdConnectMT(const STATCONNECTTYPE iConnectType, 
+										 const char *pszPlatformType);
+
+	STAT_EXPORT int __cdecl Disconnect(const int handle);
+	STAT_EXPORT int __stdcall StdDisconnect(const int handle);
+
+	// remote command delay (100 - 30000ms)
+	STAT_EXPORT int __cdecl SetCommandDelay(const int handle, const unsigned int iMillisecondDelay);
+	STAT_EXPORT int __stdcall StdSetCommandDelay(const int handle, const unsigned int iMillisecondDelay);
+
+	// logging
+	STAT_EXPORT int __cdecl SetCommandLogging(const int handle, 
+									  const char *pszLogPath,
+									  MessageReporter *const aMessageReporter,
+									  const STATLOGLEVEL iLevel = EVerbose,
+									  const bool bAppend = true,
+									  void* Reserved1 = NULL,
+									  void* Reserved2 = NULL);
+	STAT_EXPORT int __stdcall StdSetCommandLogging(const int handle, 
+												   const char *pszLogPath,
+												   MessageReporter *const aMessageReporter,
+												   const STATLOGLEVEL iLevel = EVerbose,
+												   const bool bAppend = true,
+												   void* Reserved1 = NULL,
+												   void* Reserved2 = NULL);
+
+	// image verification
+	STAT_EXPORT int __cdecl SetImageVerification(const int handle, 
+										 const char *pszRefDir, 
+										 const bool bRemoveOldImages, 
+										 const int iFactor);
+	STAT_EXPORT int __stdcall StdSetImageVerification(const int handle, 
+													  const char *pszRefDir, 
+													  const bool bRemoveOldImages, 
+													  const int iFactor);
+
+	// target manipulation
+	STAT_EXPORT int __cdecl GetCommandCount(const int handle, const char *pszFile, int *commandCount);
+	STAT_EXPORT int __stdcall StdGetCommandCount(const int handle, const char *pszFile, int *commandCount);
+
+	STAT_EXPORT int __cdecl GetCurrentCommandNumber(const int handle, int *commandNumber);
+	STAT_EXPORT int __stdcall StdGetCurrentCommandNumber(const int handle, int *commandNumber);
+
+	STAT_EXPORT const char* __cdecl GetReceivedData(const int handle);
+	STAT_EXPORT const char* __stdcall StdGetReceivedData(const int handle);
+	STAT_EXPORT int __cdecl OpenScriptFile(const int handle, LPCTSTR pszText, bool bIsFile);
+	STAT_EXPORT int __stdcall StdOpenScriptFile(const int handle, LPCTSTR pszText, bool bIsFile);
+
+	STAT_EXPORT int __cdecl RunScript(const int handle, ScriptProgressMonitor *const monitor);
+	STAT_EXPORT int __stdcall StdRunScript(const int handle, ScriptProgressMonitor *const monitor);
+
+	STAT_EXPORT int __cdecl SendRawCommand(const int handle, const char *pszText, ScriptProgressMonitor *const monitor);
+	STAT_EXPORT int __stdcall StdSendRawCommand(const int handle, const char *pszText, ScriptProgressMonitor *const monitor);
+
+	STAT_EXPORT int __cdecl SendCommandFile(const int handle, const char *pszFile, ScriptProgressMonitor *const monitor);
+	STAT_EXPORT int __stdcall StdSendCommandFile(const int handle, const char *pszFile, ScriptProgressMonitor *const monitor);
+
+	STAT_EXPORT int __cdecl StopProcessing(int handle);
+	STAT_EXPORT int __stdcall StdStopProcessing(int handle);
+
+	STAT_EXPORT int __cdecl GetSnapshot(const int handle, TBitmapFileHeader **ppFile, TBitmapInfoHeader **ppBitmap, char **ppData, unsigned long *pSize);
+	STAT_EXPORT int __stdcall StdGetSnapshot(const int handle, TBitmapFileHeader **ppFile, TBitmapInfoHeader **ppBitmap, char **ppData, unsigned long *pSize);
+}
+
+#endif // STATEXP30_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/inc/statlist.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,54 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef STATLIST30_H
+#define STATLIST30_H
+
+#include "statmember.h"
+
+#define MAX_VERSION_LEN 32
+
+class STATDLLList
+{
+public:
+	STATDLLList();
+	~STATDLLList();
+	int SetLogging(const char *path);
+	void StopLogging();
+	DWORD CreateListMember(const STATCONNECTTYPE iConnectType, const char *pszPlatformType);
+	STATDLLMember* Member(const DWORD dwHandle);
+	bool RemoveListMember(const DWORD dwHandle);
+	bool ListExists() { return (ListStart != 0); }
+	char *Version() { return szVersion; }
+
+	char szErrorText[MAX_ERROR_MSG_LEN * 2];	// connection error message (if any)
+
+private:
+	void WalkList();
+
+	Reporter oRep;								// debug logging
+	STATDLLMember *ListStart;					// start of connection list
+	char szVersion[MAX_VERSION_LEN];
+};
+
+// stat connection list
+extern STATDLLList aList;
+
+#endif // STATLIST30_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/inc/statmember.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,82 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:     STAT member class header file
+*
+*/
+
+
+
+
+#ifndef STATMEMBER30_H
+#define STATMEMBER30_H
+
+#include <creporter.h>
+#include <statengine.h>
+#include "ini.h"
+
+#define MAX_ID_PREFIX				256
+
+class STATDLLMember
+{
+public:
+	STATDLLMember(const STATCONNECTTYPE iConnectType, 
+				  const char *pszPlatformType,
+				  Reporter *theRep = NULL);
+	virtual ~STATDLLMember();
+	bool Prepare(int iMillisecondDelay, LPTSTR pszLogPath, bool bAppend, MessageReporter *const aMessageReporter, LPTSTR pszRefDir, const bool bRemoveOldImages, const int iFactor, bool bState);
+	int SetCommandDelay(int iMillisecondDelay);		// set the command delay
+	int SetLogging(LPTSTR pszLogPath, bool bAppend, MessageReporter *const aMessageReporter);// set logging of the back end operations
+	int SetImageVerification(LPTSTR pszRefDir, const bool bRemoveOldImages, const int iFactor);
+	void SetResponseTimeout(const unsigned long lMilliseconds) { pEngine->iMaxTimeLimit = lMilliseconds; }
+	void SetMultithreaded(bool bState = true) { pEngine->SetMultithreaded(bState); }	// set multithreaded check
+
+	int OpenScriptFile(LPCTSTR pszText, bool bIsFile);
+	int RunScript(ScriptProgressMonitor *const monitor);
+	int SendCommandFile(LPCTSTR pszFile, ScriptProgressMonitor *const monitor);			// execute a command file
+	int SendRawCommand(LPCTSTR pszText, ScriptProgressMonitor *const monitor);			// execute a command script
+	int StopProcessing(void);
+	int GetCommandCount(LPCTSTR pszFile, int* commandCount);
+	int GetCurrentCommandNumber( int* commandNumber);
+	const char * GetReceivedData(void);
+	const char * GetErrorText( int errorCode );
+
+	int GetSnapshot(TBitmapFileHeader **ppFile, TBitmapInfoHeader **ppBitmap, char **ppData, unsigned long *pSize);
+	const char * GetDeviceInfo() { return pEngine->pDeviceInfo; }
+	const char * GetTEFSharedData() { return pEngine->iTEFSharedData; }
+	const char * GetErrorText() {	return szErrorText; }	// returns complete error message
+	int GetErrorCode() { return iErrorCode; }		// return just the code
+
+	static LPTSTR ToUnicode(const char *string);	// convert ANSI to Unicode
+	static const char * ToAnsi(LPCTSTR string);			// convert Unicode to ANSI
+	static void ParseConnection(char *pConnection, STATCONNECTTYPE *pType, char **ppAddress);
+
+	STATCONNECTTYPE iConnectionType;				// type of connection
+	char *pszAddress;								// our selected address
+
+	STATDLLMember* lPrevConnection;					// previous connection in list
+	STATDLLMember* lNextConnection;					// next connection in list
+
+private:
+	void Message(const char * message, ...);
+	void ErrorMessage(const char * message, ...);
+
+	CSTATEngine *pEngine;							// pointer to back end
+	int iErrorCode;									// error code
+	char szErrorText[MAX_ERROR_MSG_LEN * 2];		// error message
+	char szPrefix[MAX_ID_PREFIX];					// id prefix
+	Reporter *pRep;									// pointer to logging
+	CStatIniFile statIniFile;							// ini file reader
+};
+
+#endif // STATMEMBER30_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/inc/statscriptdecoder.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef STATSCRIPTDECODER_H
+#define STATSCRIPTDECODER_H
+
+#include "stat.h"
+#include "CSTATDataFormatConverter.h"
+#include "CSTATImageVerify.h"
+
+class CSTATScriptCommand
+{
+public:
+	CSTATScriptCommand();
+	~CSTATScriptCommand();
+	char *Command()			{ return pCommand; }
+	unsigned long Length()	{ return ulLength; }
+	bool SetData(const char *pData, const unsigned long theLength);
+	void Reset();
+
+	char cCommandID;
+	unsigned long ulLength;
+
+private:
+	char *pCommand;
+};
+
+class CSTATScriptDecoder
+{
+public:
+	CSTATScriptDecoder(CSTATLogFile *theLog);
+	~CSTATScriptDecoder();
+	int Initialise(const CString& file, bool bIsFile);
+	int GetNextCommand(CSTATScriptCommand **ppCommand);
+	void Release();
+
+private:
+	int ReadDataIntoMemory(const CString& commands);
+	int ReadFileIntoMemory(CFile& scriptdata);
+	int ValidateScript();
+	int ExtractComment();
+	bool IncrementCounter(void);
+
+	CSTATLogFile *pLog;
+	char *lpBuffer;										// buffer that holds read script file
+	long lFileLength;									// length of file read
+	int iCounter;										// step counter through file
+	CSTATScriptCommand LastCommand;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/inc/statserial.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,104 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// statserial.h
+// Serial transport class definition
+////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef STATSERIAL_H
+#define STATSERIAL_H
+
+#include "statcommon.h"
+#include "stattransport.h"
+
+// COM port settings
+// There is a problem with the use of ::ReadFile as this is a blocking
+// operation called in a critical section.  If the call blocks for too
+// long and the user closes the thread then the section is lost for ever.
+// Reduce the timeouts to prevent the threads locking when there is
+// a link error.  This is the wrong thing to do as we should really
+// update the reading to check the port first and query if data
+// is available.
+#define STAT_WRITETOTALTIMEOUTMULTIPLIER	0
+#define STAT_WRITETOTALTIMEOUTCONSTANT		1000
+#define STAT_READINTERVALTIMEOUT			0
+#define STAT_READTOTALTIMEOUTMULTIPLIER		0
+#if defined _DEBUG
+	// In a release build wait a few seconds.
+	// In a debug build wait for longer as we may be debugging and 
+	// pausing at break-points and generally slowing things up a bit.
+	#define STAT_READTOTALTIMEOUTCONSTANT		(10 * 1000)
+#else // defined _DEBUG
+	#define STAT_READTOTALTIMEOUTCONSTANT		1000
+#endif // defined _DEBUG
+
+#define STAT_BAUDRATE						CBR_115200
+#define STAT_BYTESIZE						8
+#define STAT_PARITY							NOPARITY
+#define STAT_STOPBITS						ONESTOPBIT
+
+
+class CSTATSerial : public CSTATTransport
+{
+public:
+	CSTATSerial(STATCONNECTTYPE eConnect);	// Request that when this object
+											// is created then it knows what
+											// implementation of serial it is.
+											// We could use sub-classes but there
+											// is so little difference we handle
+											// all serial transports as one case.
+											// The only difference is in the packet
+											// size which we store as an object
+											// data field.
+	~CSTATSerial();
+	int Initialise(void);
+	int Connect(const char *pAddress = NULL);
+	int Send(const char cIdentifier, const char *pData = NULL, const unsigned long ulLength = 0);
+	int Receive(char *cIdentifier, char **ppData = NULL, unsigned long *pLength = NULL);
+	int Disconnect(void);
+	int Release(void);
+	unsigned int GetMaxPacketSize(void) const;	// Override base class method
+												// to specify that we have
+												// a limit to the pakcet size
+												// and the specific limit
+												// depends upon the serial
+												// transport we represent.
+
+private:
+	bool OpenComPort(const char *pAddress);
+	int ReceiveBytes( char *buff, unsigned long size );
+
+	HANDLE hComPort;				// com port to work with
+	unsigned long int iMaxPacketSize;
+									// Holds the maximum size of the
+									// packets we send.
+	char *pBuffer;					// Holds received data
+	unsigned long int iBufferLength;
+									// Holds the length of the receive data 
+									// buffer
+};
+
+inline unsigned int CSTATSerial::GetMaxPacketSize(void) const
+{
+	return (iMaxPacketSize);
+}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/inc/statserialbluetooth.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef STATSERIALBLUETOOTH_H
+#define STATSERIALBLUETOOTH_H
+
+#include "statcommon.h"
+#include "stattransport.h"
+
+// COM port settings
+#define STATBT_WRITETOTALTIMEOUTMULTIPLIER		10
+#define STATBT_WRITETOTALTIMEOUTCONSTANT		10
+#define STATBT_READINTERVALTIMEOUT				100
+#define STATBT_READTOTALTIMEOUTMULTIPLIER		100
+#define STATBT_READTOTALTIMEOUTCONSTANT			120000
+
+#define STATBT_BAUDRATE						CBR_115200
+#define STATBT_BYTESIZE						8
+#define STATBT_PARITY						NOPARITY
+#define STATBT_STOPBITS						ONESTOPBIT
+
+
+class CSTATSerialBluetooth : public CSTATTransport
+{
+public:
+	CSTATSerialBluetooth();
+	~CSTATSerialBluetooth();
+	int Initialise(void);
+	int Connect(const char *pAddress = NULL);
+	int Send(const char cIdentifier, const char *pData = NULL, const unsigned long ulLength = 0);
+	int Receive(char *cIdentifier, char **ppData = NULL, unsigned long *pLength = NULL);
+	int Disconnect(void);
+	int Release(void);
+
+private:
+	bool OpenComPort(const char *pAddress);
+	int ReceiveBytes( char *buff, unsigned long size );
+	
+	HANDLE hComPort;				// com port to work with
+	char *pTemp;					// holds received data
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/inc/statsocket_block.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef STATSOCKET_H
+#define STATSOCKET_H
+
+#include <winsock2.h>
+#include "statcommon.h"
+#include "stattransport.h"
+#include "../../../../Common/inc/SerialPacketSize.h"
+
+#define SOCKETTIMEOUT 300 //300 seconds
+
+class CSTATSocket : public CSTATTransport
+{
+public:
+	CSTATSocket();
+	~CSTATSocket();
+	int Initialise(void);
+	int Connect(const char *pAddress = NULL);
+	int Send(const char cIdentifier, const char *pCommand = NULL, const unsigned long ulLength = 0);
+	int Receive(char *cIdentifier, char **ppData = NULL, unsigned long *pLength = NULL);
+	int Disconnect(void);
+	int Release(void);
+	unsigned int GetMaxPacketSize(void) const;
+
+private:
+
+	SOCKET sock;
+    SOCKADDR_IN sin;
+
+	SOCKET listener;
+    SOCKADDR_IN remote_sin;
+
+	char *pBuffer;					// Holds received data
+	unsigned long int iBufferLength;
+									// Holds the length of the receive data 
+									// buffer
+};
+
+inline unsigned int CSTATSocket::GetMaxPacketSize(void) const
+{
+	return (KMaxTCPIPPacketSize);
+}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/inc/stattransport.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,88 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef STATTRANSPORT_H
+#define STATTRANSPORT_H
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <memory.h>
+#include "CSTATReturnCodes.h"
+
+
+// abstract transport class
+class CSTATTransport
+{
+public:
+	CSTATTransport();
+	~CSTATTransport() {}
+
+	// these must be derived for selected transport
+	virtual int Initialise(void) = 0;
+	virtual int Connect(const char *pAddress = NULL) = 0;
+	virtual int Send(const char cIdentifier, const char *pData = NULL, const unsigned long ulLength = 0) = 0;
+	virtual int Receive(char *cIdentifier, char **ppData = NULL, unsigned long *pLength = NULL) = 0;
+	virtual int Disconnect(void) = 0;
+	virtual int Release(void) = 0;
+	virtual char * Error(void);
+	virtual unsigned int GetMaxPacketSize(void) const = 0;
+	
+protected:
+	void SetError(const char *pText, ...);
+
+private:
+	char szError[STAT_MAX_ERRORLEN + 1];
+};
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Constructor
+inline CSTATTransport::CSTATTransport(void)
+{
+	memset(&szError, 0, sizeof(szError));
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Return error text
+inline char * CSTATTransport::Error(void)
+{
+	return szError;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Set error text
+inline void CSTATTransport::SetError(const char *pText, ...)
+{
+	memset(&szError, 0, sizeof(szError));
+
+	va_list pCurrent = (va_list)0;
+    va_start (pCurrent, pText);
+	vsprintf (szError, pText, pCurrent);
+    va_end (pCurrent);
+
+	char szExtra[20] = {0};
+	sprintf(szExtra, " (%d)", GetLastError());
+	strcat (szError, szExtra);
+}
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/inc/stdafx.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#if !defined(AFX_STDAFX_H__CB0CFE43_F6B6_4fd6_BA4E_62F3A588FA05__INCLUDED_)
+#define AFX_STDAFX_H__CB0CFE43_F6B6_4fd6_BA4E_62F3A588FA05__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define VC_EXTRALEAN		// Exclude rarely-used stuff from Windows headers
+
+#include <afxwin.h>         // MFC core and standard components
+#include <afxext.h>         // MFC extensions
+#include <assert.h>
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__CB0CFE43_F6B6_4fd6_BA4E_62F3A588FA05__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/inc/windowmessages.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#if ! defined (WINDOW_MESSAGES_H_0731AB35_7D26_459d_9A0E_1AFB32883064)
+#define WINDOW_MESSAGES_H_0731AB35_7D26_459d_9A0E_1AFB32883064
+
+/////////////////////////////////////////////////////////////////////////////
+// WM_DONE_COMMAND
+// Passed from the script progress monitor to the main UI window (this is
+// the desktop dialog) to indicate that a single command of the current
+// scipt has been processed.
+/////////////////////////////////////////////////////////////////////////////
+#define WM_DONE_COMMAND	(WM_USER + 0x0001)
+
+/////////////////////////////////////////////////////////////////////////////
+// WM_DONE_SCRIPT
+// Passed from the script progress monitor to the main UI window (this is
+// the desktop dialog) to indicate that the current  script has 
+// been processed.
+/////////////////////////////////////////////////////////////////////////////
+#define WM_DONE_SCRIPT	(WM_USER + 0x0002)
+
+/////////////////////////////////////////////////////////////////////////////
+// WM_SHOW_LOG_MESSAGE
+// Passed from the log file to the application main window.
+// There is a data structure passed in this message (as the lParam) and 
+// the receiving window must delete it.
+/////////////////////////////////////////////////////////////////////////////
+#define WM_SHOW_LOG_MESSAGE	(WM_USER + 0x0003)
+
+#endif // ! defined (WINDOW_MESSAGES_H_0731AB35_7D26_459d_9A0E_1AFB32883064)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/src/crepmisc.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,623 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include "stdafx.h"
+#include <time.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+#include "cReporter.h"
+
+
+/*****************************************************************************
+ * Reporter preparation
+ * 
+ * Sets member strings to a known state
+ *****************************************************************************/
+
+void
+Reporter::prepare ( void )
+{
+  int i;
+  
+#ifdef RPT_DEBUG_PROG
+  // set filename contents to garbage value
+  for (i=0;i<CPO_MAX_FILENAME_LEN;i++)
+  {
+    filename [ i ] = CPO_GARBAGE_CHAR;
+  }
+  
+  // set program name contents to garbage value
+  for (i=0;i<RPT_MAX_PROGRAM_LEN;i++)
+  {
+    progname [ i ] = CPO_GARBAGE_CHAR;
+  }
+#endif  
+
+  for (i=0;i<RPT_MAX_LIST_ENTRIES;i++)
+  {
+    messageList [ i ] = (char *)0;
+  }
+  
+  fileRead = 0;
+  pCurrent = (va_list) 0;
+  prefix = 0;
+  state = 0;
+  hFile = (HANDLE) 0;
+  filename [ 0 ] = '\0';
+  progname [ 0 ] = '\0';
+}
+
+/*****************************************************************************
+ * Reporter setup
+ * 
+ * Checks the output streams.
+ * Sets the prefix mask.
+ * Stores a copy of the application name.
+ * Puts a message into the logging file that the Reporter is initialised.
+ *****************************************************************************/
+
+CPO_BOOL
+Reporter::setup ( const char * appName,
+                  const BITFIELD prefixMask,
+				  const unsigned long ulOpenAttributes )
+{
+  // check for valid output destinations
+  if ( !( state & RPT_FILE ) && 
+       !( state & RPT_STDOUT ) &&
+       !( state & RPT_STDERR ) )
+  {
+    return ( CPO_FALSE );
+  }  
+
+  // check for valid mask
+  if ( !( prefixMask & RPT_MSG_TYPE ) && 
+       !( prefixMask & RPT_APPNAME ) &&
+       !( prefixMask & RPT_DATE ) &&
+       !( prefixMask & RPT_TIME ) )
+  {
+    prefix = RPT_MSG_ONLY;
+  }  
+  else
+  {
+    prefix = prefixMask;
+  }
+  
+  // get the actual program name and make sure it is valid
+  extractName ( progname, appName, RPT_MAX_PROGRAM_LEN );
+  validateText ( progname, RPT_MAX_PROGRAM_LEN );
+  if ( !( *progname ) )
+  {
+    return ( CPO_FALSE );
+  }
+
+  if ( state & RPT_FILE )
+  {
+    // open output file
+    if ( !openFile ( ulOpenAttributes ) )
+    {
+      state -= RPT_FILE;
+      if ( !( state & RPT_OUTPUT_MASK ) )
+      {
+        return ( CPO_FALSE );
+      }
+    }
+  }
+  
+  // set flags to show everything ok
+  state |= CPO_CONNECTED;
+  state |= CPO_ACTIVATED;
+  
+  return ( CPO_TRUE );
+}
+
+/*****************************************************************************
+ * Resolve a code to a message and build it.
+ *****************************************************************************/
+
+void
+Reporter::actOnCode ( int code, char messType )
+{
+  // must be initialised and activated
+  if ( ( state & CPO_CONNECTED ) && 
+       ( state & CPO_ACTIVATED ) &&
+       code >= 0 && 
+       code < RPT_MAX_LIST_ENTRIES )
+  {
+    if ( messageList [ code ] )
+    {
+      buildMessage ( messageList [ code ], messType );
+    }
+    else
+    {
+      char tmpMsg [ 128 ];
+      (void) sprintf ( tmpMsg, "[ No message text for code %d ]", code );
+      buildMessage ( tmpMsg, messType );
+    }
+  }
+}
+
+/*****************************************************************************
+ * Generate a filename using the application name and current date.
+ *****************************************************************************/
+
+void
+Reporter::generateFilename ( char * validName, const char * appName )
+{
+  /* Construct a filename for the logging to be written to.
+   * Filename is of the format x[xxx]9988.rpt where :
+   * 
+   * xxxx = up to first 4 chars of calling program's name
+   * 99 = 2 digit day of month
+   * 88 = 2 digit month of year
+   */
+
+  const int PROG_LEN = 4;
+  time_t curtime;
+  struct tm *tminfo;
+  
+  // get filename from path
+  extractName ( buffer, appName, PROG_LEN );
+  
+  (void) time ( &curtime );
+  tminfo = localtime ( &curtime );
+
+  (void) sprintf ( validName, 
+                   "%s%02d%02d.RPT", 
+                   buffer, 
+                   tminfo->tm_mday, 
+                   tminfo->tm_mon + 1);
+
+#ifdef RPT_DEBUG_PROG
+  (void) fprintf ( stdout, "filename [%s] generated from [%s]\n", 
+                   validName, appName );
+  (void) fflush ( stdout );
+#endif  
+}
+
+/*****************************************************************************
+ * Extract 'length' characters of the actual filename from the path.
+ *****************************************************************************/
+
+void
+Reporter::extractName ( char * file, const char * path, const int length )
+{
+  char *ptr;
+
+  // find the last backslash
+  ptr = strrchr ( path, '\\' );
+
+  if ( !ptr )
+  {
+    strncpy ( file, path, length );
+  }
+  else
+  {
+    strncpy ( file, (++ptr), length );
+  }
+  
+  *( file + length ) = '\0';
+}
+
+/****************************************************************************
+ * Open the file or print a message if we can't
+ *****************************************************************************/
+
+int 
+Reporter::openFile ( unsigned long ulOpenAttributes )
+{
+#ifdef UNICODE
+	TCHAR uFilename[CPO_MAX_FILENAME_LEN + 1];
+
+    // Convert to UNICODE.
+    if (!MultiByteToWideChar(CP_ACP,					// conversion type
+							 0,							// flags
+							 filename,					// source
+							 -1,						// length
+							 uFilename,					// dest
+							 CPO_MAX_FILENAME_LEN))		// length
+    {
+		return ( CPO_FALSE );
+    }
+
+	hFile = CreateFile(uFilename,
+				   GENERIC_WRITE,
+				   FILE_SHARE_READ | FILE_SHARE_WRITE,
+				   NULL,
+				   ulOpenAttributes,
+				   FILE_ATTRIBUTE_NORMAL,
+				   NULL);
+#else
+	hFile = CreateFile(filename,
+				   GENERIC_WRITE,
+				   FILE_SHARE_READ | FILE_SHARE_WRITE,
+				   NULL,
+				   ulOpenAttributes,
+				   FILE_ATTRIBUTE_NORMAL,
+				   NULL);
+#endif
+
+	if (hFile == INVALID_HANDLE_VALUE)
+	{
+//		char szTemp[500] = {0};
+//		sprintf(szTemp, "WARNING : [%s] could not be opened. File output disabled", filename);
+//		MessageBox(NULL, szTemp, NULL, MB_OK);
+		return ( CPO_FALSE );
+	}
+
+	// move to the end if a file already exists
+	SetFilePointer(hFile, 0, 0, FILE_END);
+
+#ifdef RPT_DEBUG_PROG
+  (void) fprintf ( stdout, "file [%s] opened\n", filename );
+  (void) fflush ( stdout );
+#endif  
+
+  return ( CPO_TRUE );
+}
+
+/*****************************************************************************
+ * Construct the parts of the complete message.
+ *****************************************************************************/
+
+void
+Reporter::buildMessage ( const char * message, const char messType )
+{
+  char prefixInfo [ RPT_MAX_MSG_LEN + 1 ];
+  char finalStr [ RPT_OPEN_MSG_LEN + RPT_MAX_MSG_LEN + 1 ];
+  int maxlen;
+
+  // get prefix information
+  switch ( messType )
+  {
+   case RPT_TEXT:
+   case RPT_MSG:
+     *( prefixInfo ) = '\0';
+     break;
+   case RPT_HEADER:
+     addHeaderInfo ( prefixInfo );
+     break;
+   default:
+     addLogInfo ( prefixInfo, messType );
+     break;
+  }
+  
+  // parse arguments passed with message
+  (void) vsprintf ( buffer, message, pCurrent );
+
+  // get max length of output string
+  if ( messType == RPT_DEBUG || messType == RPT_MSG || 
+       messType == RPT_ERROR || messType == RPT_TEXT )
+  {
+    maxlen = RPT_OPEN_MSG_LEN - (int) strlen ( prefixInfo ) - 1;
+  }
+  else
+  {
+    maxlen = RPT_MAX_MSG_LEN - (int) strlen ( prefixInfo ) - 1;
+  }
+
+  // make sure we are dealing with a valid message of correct length
+  validateText ( buffer, maxlen );
+
+  // generate the output string
+  (void) sprintf ( finalStr,
+                   "%s%s",
+                   prefixInfo, 
+                   buffer );
+
+  if ( messType == RPT_TEXT )
+  {
+    (void) strcpy ( buffer, finalStr );
+  }
+  else
+  {
+    writeToStream ( finalStr );
+  }
+}
+
+/*****************************************************************************
+ * Validate the supplied string for zero length and unprintable chars up to 
+ * length bytes.
+ * 
+ * If unprintable chars are found embedded in the text, the text will be
+ * truncated at that point.  
+ *
+ * If the text is longer than the specified length, it will be truncated at
+ * that length.
+ *
+ * If the text is empty or the 1st char is unprintable, the function will
+ * insert replacement 'invalid' text.
+ *****************************************************************************/
+
+void
+Reporter::validateText ( char * text, const int length )
+{
+  int len = (int) strlen ( text );
+  if ( len > length )
+  {
+    len = length;
+  }
+
+  // check for empty message or unprintable 1st char
+  if ( len && isprint ( text [ 0 ] ) )
+  {
+    // check message for unprintable characters
+    for (int i=1;i<len;i++)
+    {
+		if (text [ i ] != '\t')
+		{
+		  if ( ! ( isprint ( text [ i ] ) ) )
+		  {
+			break;
+		  }
+		}
+    }
+
+    text [ i ] = '\0';
+  }
+  else
+  {
+    (void) strcpy ( text, "####" );
+  }
+}
+
+/*****************************************************************************
+ * Generate the prefix information to prepend to a 'write' message.
+ *
+ * NOTE: No checks are done to ensure prefix info is not too small for 
+ *       allocated string.  If more information is prepended in the future, 
+ *       this will have to be implemented.
+ *****************************************************************************/
+
+void
+Reporter::addHeaderInfo ( char * prefixInfo )
+{
+  time_t curTime;
+  
+  // create the time string
+  (void) time ( &curTime );
+  (void) strftime ( buffer, 
+                    sizeof ( buffer ), 
+                    "%a %b %d %Y  %H:%M:%S",
+                    localtime ( &curTime ) );
+
+  // append the program name
+  (void) sprintf ( prefixInfo,
+                   "%s [%s] ",
+                   buffer, 
+                   progname );
+}
+
+/*****************************************************************************
+ * Generate the prefix information to prepend to the message.
+ * If msg type is RPT_ERROR, info is generated regardless of prefix setting.
+ *
+ * NOTE: No checks are done to ensure prefix info is not too small for 
+ *       allocated string.  If more information is prepended in the future, 
+ *       this will have to be implemented.
+ *****************************************************************************/
+
+void
+Reporter::addLogInfo ( char * prefixInfo, const char msgType )
+{
+  int bytesUsed = 0;
+  time_t curTime;
+  *( prefixInfo ) = '\0';
+
+  if ( prefix == RPT_MSG_ONLY)
+  {
+    return;
+  }
+  
+#ifdef RPT_DEBUG_PROG
+  // fill prefix string to check for memory leaks
+  for (int i=1;i<RPT_MAX_MSG_LEN;i++)
+  {
+    *( prefixInfo + i ) = CPO_GARBAGE_CHAR;
+  }
+#endif  
+
+  if ( ( prefix & RPT_MSG_TYPE ) )
+  {
+    *( prefixInfo ) = msgType;
+    *( prefixInfo + 1 ) = ' ';
+    *( prefixInfo + 2 ) = '\0';
+
+    bytesUsed += 2;
+  }
+  
+  if ( ( prefix & RPT_APPNAME ) )
+  {
+    (void) sprintf ( prefixInfo + bytesUsed, "%s ", progname );
+    bytesUsed += (int) strlen ( progname ) + 1;
+  }
+  
+  if ( ( prefix & RPT_DATE ) )
+  {
+    const int sublen = 5;
+
+    // create the date string
+    (void) time ( &curTime );
+    (void) strftime ( buffer, 
+                      sizeof ( buffer ), 
+                      "%d/%m",
+                      localtime ( &curTime ) );
+
+    (void) sprintf ( prefixInfo + bytesUsed, "%s ", buffer );
+    bytesUsed += ( sublen + 1 );
+  }
+  
+  if ( ( prefix & RPT_TIME ) )
+  {
+    const int sublen = 8;
+
+    // create the time string
+    (void) time ( &curTime );
+    (void) strftime ( buffer, 
+                      sizeof ( buffer ), 
+                      "%H:%M:%S",
+                      localtime ( &curTime ) );
+
+    (void) sprintf ( prefixInfo + bytesUsed, "%s ", buffer );
+    bytesUsed += ( sublen + 1 );
+  }
+
+  // null terminate to be sure
+  *( prefixInfo + bytesUsed ) = '\0';
+}
+
+/*****************************************************************************
+ * Send text to appropriate stream(s).
+ *****************************************************************************/
+
+void
+Reporter::writeToStream ( const char * str )
+{
+#ifdef RPT_DEBUG_PROG
+  (void) fprintf ( stdout, "output [%s]\n", str );
+  (void) fflush ( stdout );
+#endif  
+
+  // write output string to file
+  if ( state & RPT_FILE )
+  {
+	  unsigned long lBytesWritten;
+
+	  // need to seek to end of file in case other handles have written in the meantime
+	  SetFilePointer(hFile, 0, NULL, FILE_END);
+
+	  WriteFile(hFile, str, strlen(str), &lBytesWritten, NULL);
+	  WriteFile(hFile, "\r\n", 2, &lBytesWritten, NULL);
+
+	  // in case other processes are using this file to log
+	  FlushFileBuffers(hFile);
+  }
+
+  // write output string to standard output
+  if ( state & RPT_STDOUT )
+  {
+    (void) fprintf ( stdout, "%s\n", str );
+    (void) fflush ( stdout );
+  }
+  
+  // write output string to standard error
+  if ( state & RPT_STDERR )
+  {
+    (void) fprintf ( stderr, "%s\n", str );
+    (void) fflush ( stderr );
+  }
+}
+
+/*****************************************************************************
+ * Close the output file stream.
+ *****************************************************************************/
+
+void 
+Reporter::closeFile ( void )
+{
+	CloseHandle(hFile);
+
+#ifdef RPT_DEBUG_PROG
+  (void) fprintf ( stdout, "file [%s] closed\n", filename );
+  (void) fflush ( stdout );
+#endif  
+}
+
+/***************************************************************************
+ * Open the message file, then read in contents, processing a line at a
+ * time, putting the current line into global buffer string.
+ ***************************************************************************/
+
+void
+Reporter::readMessageFile ( const char * file )
+{
+  FILE * finptr;
+  
+  // open initialisation file
+  if ( ( finptr = fopen ( file, "r" ) ) == NULL )
+  {
+    return;
+  }
+  
+  // read each line
+  while ( ( fgets ( buffer, RPT_MAX_LINE_LEN, finptr ) ) != NULL )
+  {
+    if ( *( buffer ) != '\n' && *( buffer ) != '#' )
+    {
+      addMessage ( );
+    }
+  }
+
+  (void) fclose ( finptr );
+}
+
+/***************************************************************************
+ * Split the line of text into code and message and allocate memory in
+ * list and store it.
+ ***************************************************************************/
+
+void
+Reporter::addMessage ( void )
+{
+  char *pCode;
+  char *pText;
+  int code;
+
+  // extract the code and text
+  pCode = strtok ( buffer, ":" );
+  pText = strtok ( NULL, "\n" );
+
+  // check for legitimate values
+  if ( !pCode || !pText )
+  {
+    return;
+  }
+
+  code = atoi ( pCode );
+  if ( code > RPT_MAX_LIST_ENTRIES || messageList [ code ] )
+  {
+    return;
+  }
+  
+  // jump any spaces in front of text
+  while ( *( pText ) == ' ' || *( pText ) == '\t' )
+  {
+    pText++;
+  }
+  
+  // copy string
+  // messageList [ code ] = new char ( strlen ( pText ) + 1 );
+  messageList [ code ] = 
+    (char *) malloc ( sizeof ( char ) * ( strlen ( pText ) + 1 ) );
+
+  (void) strcpy ( messageList [ code ], pText );
+
+#ifdef RPT_DEBUG_PROG
+//   (void) fprintf ( stdout, "code [%s] text [%s] entry [%s] len %d\n", 
+//                    pCode, pText, messageList [ code ], strlen ( pText ) );
+//   (void) fflush ( stdout );
+#endif
+
+  // let object know there is at least one message entry
+  fileRead = 1;
+}
+
+/****************************************************************************/
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/src/creporter.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,723 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include "stdafx.h"
+#include <string.h>
+#include <malloc.h>
+#include <winbase.h>
+#include "cReporter.h"
+
+CRITICAL_SECTION aCriticalSection;
+
+/*****************************************************************************
+ * Basic constructor
+ *****************************************************************************/
+
+Reporter::Reporter()
+: pCurrent((va_list)0), state(0), prefix(0), hFile((HANDLE)0), fileRead(0)
+{
+	memset(filename, 0, sizeof(filename));
+	memset(progname, 0, sizeof(progname));
+	memset(buffer, 0, sizeof(buffer));
+
+	int i;
+	for (i=0;i<RPT_MAX_LIST_ENTRIES;i++)
+		messageList[i] = NULL;
+}
+
+/***************************************************************************
+ * Destructor to free any memory we've allocated.
+ ***************************************************************************/
+
+Reporter::~Reporter ( void )
+{
+  kill();
+}
+
+/*****************************************************************************
+ * Initialiser for Reporter using automatic filename generator.
+ * 
+ * Generates a filename if requested. If file doesn't exist, it is created.
+ *****************************************************************************/
+
+CPO_BOOL
+Reporter::init ( const char * appName,
+                 const BITFIELD prefixMask,
+                 const BITFIELD destination )
+{
+  // must not be initialised
+  if ( state & CPO_CONNECTED )
+  {
+    return ( CPO_FALSE );
+  }
+
+  // initialise variables
+  prepare ( );
+  
+  // set up logging file
+  state = destination;
+  if ( state & RPT_FILE )
+  {
+    generateFilename ( filename, appName );
+  }
+  
+  // final preparations
+  if ( ! ( setup ( appName, prefixMask ) ) )
+  {
+    return ( CPO_FALSE );
+  }
+
+#ifdef RPT_DEBUG_PROG
+    (void) fprintf ( stdout, 
+                     "progname [%s] prefix %ld dest %ld file [%s] state %ld\n",
+                     progname, prefixMask, destination, filename, state );
+    (void) fflush ( stdout );
+#endif  
+
+  InitializeCriticalSection(&aCriticalSection);
+  return ( CPO_TRUE );
+}
+
+/*****************************************************************************
+ * Initialiser for Reporter using specific path for file output.
+ * 
+ * Opens an output file if requested at the supplied path.  
+ * If the requested file doesn't exist, it is created.
+ * If the path is invalid, initialisation will fail.
+ *****************************************************************************/
+
+CPO_BOOL
+Reporter::init ( const char * appName,
+                 const BITFIELD prefixMask,
+                 const BITFIELD destination,
+                 const char * path )
+{
+  char tmpFile [ CPO_MAX_FILENAME_LEN + 1 ];
+  char tmpPath [ CPO_MAX_FILENAME_LEN + 1 ];
+  
+  // must not be initialised
+  if ( state & CPO_CONNECTED )
+  {
+    return ( CPO_FALSE );
+  }
+
+// initialise variables
+  prepare ( );
+  
+  // because we supplied a path, make sure we are setup for file output
+  state = destination;
+  if ( !(state & RPT_FILE) )
+  {
+    state += RPT_FILE;
+  }
+
+  // generate the output filename
+  generateFilename ( tmpFile, appName );
+
+  // add a backslash if there isn't one
+  strcpy(tmpPath, path);
+  if ((*(tmpPath + strlen(tmpPath) - 1)) != '\\')
+	strcat(tmpPath, "\\");
+
+  (void) sprintf ( filename, "%s%s", tmpPath, tmpFile );
+  
+  // final preparations
+  if ( ! ( setup ( appName, prefixMask ) ) )
+  {
+    return ( CPO_FALSE );
+  }
+
+#ifdef RPT_DEBUG_PROG
+    (void) fprintf ( stdout, 
+                     "appname [%s] prefix %ld dest %ld file [%s] state %ld\n", 
+                     appName, prefixMask, destination, filename, state );
+    (void) fflush ( stdout );
+#endif  
+    
+  InitializeCriticalSection(&aCriticalSection);
+  return ( CPO_TRUE );
+}
+
+/*****************************************************************************
+ * Initialiser for Reporter using specific path and filename for output.
+ * 
+ * Opens an output file using supplied name at supplied path.  
+ * If the requested file doesn't exist, it is created.
+ * If the path is invalid, initialisation will fail.
+ *****************************************************************************/
+
+CPO_BOOL
+Reporter::init ( const char * appName,
+                 const BITFIELD prefixMask,
+                 const BITFIELD destination,
+                 const char * path,
+                 const char * file,
+				 const unsigned long ulOpenAttributes)
+{
+  char tmpFile [ CPO_MAX_FILENAME_LEN + 1 ];
+  char tmpPath [ CPO_MAX_FILENAME_LEN + 1 ];
+
+  // must not be initialised
+  if ( state & CPO_CONNECTED )
+  {
+    return ( CPO_FALSE );
+  }
+
+ // initialise variables
+  prepare ( );
+  
+  // because we supplied a filename, make sure we are setup for file output
+  state = destination;
+  if ( ! ( state & RPT_FILE ) )
+  {
+    state += RPT_FILE;
+  }
+
+  // get the actual filename if a full path has been supplied
+  extractName ( tmpFile, file, CPO_MAX_FILENAME_LEN );
+
+  // add a backslash if there isn't one
+  strcpy(tmpPath, path);
+  if ((*(tmpPath + strlen(tmpPath) - 1)) != '\\')
+	strcat(tmpPath, "\\");
+
+  (void) sprintf ( filename, "%s%s", tmpPath, tmpFile );
+  
+  // final preparations
+  if ( ! ( setup ( appName, prefixMask, ulOpenAttributes ) ) )
+  {
+    return ( CPO_FALSE );
+  }
+
+#ifdef RPT_DEBUG_PROG
+    (void) fprintf ( stdout, 
+                     "appname [%s] prefix %ld dest %ld file [%s] state %ld\n", 
+                     appName, prefixMask, destination, filename, state );
+    (void) fflush ( stdout );
+#endif  
+    
+  InitializeCriticalSection(&aCriticalSection);
+  return ( CPO_TRUE );
+}
+
+/*****************************************************************************
+ * Append a 'Warning' message to file
+ *****************************************************************************/
+
+void
+Reporter::warn ( char * message, ... )
+{
+  // must be initialised and activated
+  if ( ( state & CPO_CONNECTED ) && ( state & CPO_ACTIVATED ) )
+  {
+    EnterCriticalSection(&aCriticalSection);
+    va_start ( pCurrent, message );
+    buildMessage ( message, RPT_WARN );
+    va_end ( pCurrent );
+	LeaveCriticalSection(&aCriticalSection);
+  }
+}
+
+/*****************************************************************************
+ * Append an 'Error' message to file
+ *****************************************************************************/
+
+void
+Reporter::error ( char * message, ... )
+{
+  // must be initialised and activated
+  if ( ( state & CPO_CONNECTED ) && ( state & CPO_ACTIVATED ) )
+  {
+    EnterCriticalSection(&aCriticalSection);
+    va_start ( pCurrent, message );
+    buildMessage ( message, RPT_ERROR );
+    va_end ( pCurrent );
+    LeaveCriticalSection(&aCriticalSection);
+  }
+}
+
+/*****************************************************************************
+ * Append a 'Info' message to file
+ *****************************************************************************/
+
+void
+Reporter::info ( char * message, ... )
+{
+  // must be initialised and activated
+  if ( ( state & CPO_CONNECTED ) && ( state & CPO_ACTIVATED ) )
+  {
+    EnterCriticalSection(&aCriticalSection);
+    va_start ( pCurrent, message );
+    buildMessage ( message, RPT_INFO );
+    va_end ( pCurrent );
+    LeaveCriticalSection(&aCriticalSection);
+  }
+}
+
+/*****************************************************************************
+ * Append a 'Debug' message to file
+ *****************************************************************************/
+
+void
+Reporter::debug ( char * message, ... )
+{
+  // must be initialised and activated
+  if ( ( state & CPO_CONNECTED ) && 
+       ( state & CPO_ACTIVATED ) && 
+       ( state & RPT_DEBUG_ON ) )
+  {
+    EnterCriticalSection(&aCriticalSection);
+    va_start ( pCurrent, message );
+    buildMessage ( message, RPT_DEBUG );
+    va_end ( pCurrent );
+    LeaveCriticalSection(&aCriticalSection);
+  }
+}
+
+/*****************************************************************************
+ * Append a message to output stream with no accompanying information.
+ *****************************************************************************/
+
+void
+Reporter::msg ( char * message, ... )
+{
+  // must be initialised and activated
+  if ( ( state & CPO_CONNECTED ) && ( state & CPO_ACTIVATED ) )
+  {
+    EnterCriticalSection(&aCriticalSection);
+    va_start ( pCurrent, message );
+    buildMessage ( message, RPT_MSG );
+    va_end ( pCurrent );
+    LeaveCriticalSection(&aCriticalSection);
+  }
+}
+
+/*****************************************************************************
+ * Write a special message containing day, mth, year, and time with the text.
+ *****************************************************************************/
+
+void
+Reporter::header ( char * message, ... )
+{
+  if ( ( state & CPO_CONNECTED ) && ( state & CPO_ACTIVATED ) )
+  {
+    EnterCriticalSection(&aCriticalSection);
+    va_start ( pCurrent, message );
+    buildMessage ( message, RPT_HEADER );
+    va_end ( pCurrent );
+    LeaveCriticalSection(&aCriticalSection);
+  }
+}
+
+/*****************************************************************************
+ * Return the text associated with a particular code.
+ *****************************************************************************/
+
+char *
+Reporter::text ( char * message, ... )
+{
+  *( buffer ) = '\0';
+  
+  if ( ( state & CPO_CONNECTED ) && ( state & CPO_ACTIVATED ) )
+  {
+    EnterCriticalSection(&aCriticalSection);
+    va_start ( pCurrent, message );
+    buildMessage ( message, RPT_TEXT );
+    va_end ( pCurrent );
+    LeaveCriticalSection(&aCriticalSection);
+  }
+
+  return ( buffer );
+}
+
+/*****************************************************************************
+ * Append a 'Warning' message to file from message list.
+ *****************************************************************************/
+
+void
+Reporter::warn ( int code, ... )
+{
+  if ( ( state & CPO_CONNECTED ) && ( state & CPO_ACTIVATED ) )
+  {
+	  EnterCriticalSection(&aCriticalSection);
+
+	  va_start ( pCurrent, code );
+	  actOnCode ( code, RPT_WARN );
+	  va_end ( pCurrent );
+
+	  LeaveCriticalSection(&aCriticalSection);
+  }
+}
+
+/*****************************************************************************
+ * Append an 'Error' message to file from message list.
+ *****************************************************************************/
+
+void
+Reporter::error ( int code, ... )
+{
+  if ( ( state & CPO_CONNECTED ) && ( state & CPO_ACTIVATED ) )
+  {
+	  EnterCriticalSection(&aCriticalSection);
+
+	  va_start ( pCurrent, code );
+	  actOnCode ( code, RPT_ERROR );
+	  va_end ( pCurrent );
+
+	  LeaveCriticalSection(&aCriticalSection);
+  }
+}
+
+/*****************************************************************************
+ * Append a 'Info' message to file from message list.
+ *****************************************************************************/
+
+void
+Reporter::info ( int code, ... )
+{
+  if ( ( state & CPO_CONNECTED ) && ( state & CPO_ACTIVATED ) )
+  {
+	  EnterCriticalSection(&aCriticalSection);
+
+	  va_start ( pCurrent, code );
+	  actOnCode ( code, RPT_INFO );
+	  va_end ( pCurrent );
+
+	  LeaveCriticalSection(&aCriticalSection);
+  }
+}
+
+/*****************************************************************************
+ * Append a 'Debug' message to file from message list.
+ *****************************************************************************/
+
+void
+Reporter::debug ( int code, ... )
+{
+  if ( ( state & CPO_CONNECTED ) && ( state & CPO_ACTIVATED ) )
+  {
+	  EnterCriticalSection(&aCriticalSection);
+
+	  if ( state & RPT_DEBUG_ON )
+	  {
+		va_start ( pCurrent, code );
+		actOnCode ( code, RPT_DEBUG );
+		va_end ( pCurrent );
+	  }
+
+	  LeaveCriticalSection(&aCriticalSection);
+  }
+}
+
+/*****************************************************************************
+ * Append a message to output stream with no accompanying information.
+ *****************************************************************************/
+
+void
+Reporter::msg ( int code, ... )
+{
+  if ( ( state & CPO_CONNECTED ) && ( state & CPO_ACTIVATED ) )
+  {
+	  EnterCriticalSection(&aCriticalSection);
+
+	  va_start ( pCurrent, code );
+	  actOnCode ( code, RPT_MSG );
+	  va_end ( pCurrent );
+
+	  LeaveCriticalSection(&aCriticalSection);
+  }
+}
+
+/*****************************************************************************
+ * Write a special message containing day, mth, year, and time with the text.
+ *****************************************************************************/
+
+void
+Reporter::header ( int code, ... )
+{
+  if ( ( state & CPO_CONNECTED ) && ( state & CPO_ACTIVATED ) )
+  {
+	  EnterCriticalSection(&aCriticalSection);
+
+	  va_start ( pCurrent, code );
+	  actOnCode ( code, RPT_HEADER );
+	  va_end ( pCurrent );
+
+	  LeaveCriticalSection(&aCriticalSection);
+  }
+}
+
+/*****************************************************************************
+ * Return the text associated with a particular code.
+ *****************************************************************************/
+
+char *
+Reporter::text ( int code, ... )
+{
+  if ( ( state & CPO_CONNECTED ) && ( state & CPO_ACTIVATED ) )
+  {
+	  EnterCriticalSection(&aCriticalSection);
+
+	  *( buffer ) = '\0';
+  
+	  va_start ( pCurrent, code );
+	  actOnCode ( code, RPT_TEXT );
+	  va_end ( pCurrent );
+
+	  LeaveCriticalSection(&aCriticalSection);
+  }
+  return ( buffer );
+}
+
+/*****************************************************************************
+ * Append a dashed line to file
+ *****************************************************************************/
+
+void
+Reporter::dash ( void )
+{
+  // must be initialised and activated
+  if ( ( state & CPO_CONNECTED ) && ( state & CPO_ACTIVATED ) )
+  {
+    EnterCriticalSection(&aCriticalSection);
+    writeToStream ( "----------------------------------------"
+                    "---------------------------------------" );
+    LeaveCriticalSection(&aCriticalSection);
+  }
+}
+
+/*****************************************************************************
+ * Append a star line to file
+ *****************************************************************************/
+
+void
+Reporter::star ( void )
+{
+  // must be initialised and activated
+  if ( ( state & CPO_CONNECTED ) && ( state & CPO_ACTIVATED ) )
+  {
+    EnterCriticalSection(&aCriticalSection);
+    writeToStream ( "****************************************"
+                    "***************************************" );
+    LeaveCriticalSection(&aCriticalSection);
+  }
+}
+
+/*****************************************************************************
+ * Append a blank line to file
+ *****************************************************************************/
+
+void
+Reporter::blank ( void )
+{
+  // must be initialised and activated
+  if ( ( state & CPO_CONNECTED ) && ( state & CPO_ACTIVATED ) )
+  {
+    EnterCriticalSection(&aCriticalSection);
+    writeToStream ( " " );
+    LeaveCriticalSection(&aCriticalSection);
+  }
+}
+
+/*****************************************************************************
+ * Shutdown the Reporter
+ * Puts a message into the logging file that the Reporter has shutdown.
+ * Closes the logging file.
+ *****************************************************************************/
+
+void
+Reporter::kill ( void )
+{
+  // must be initialised
+  if ( state & CPO_CONNECTED )
+  {
+    EnterCriticalSection(&aCriticalSection);
+    if ( state & RPT_FILE )
+    {
+      closeFile ( );
+    }
+
+    // clear in case actions are tried on an uninitialised Reporter
+    state = CPO_CLEAR;
+
+    // free any memory allocated
+    if ( fileRead )
+    {
+      for (int i=0;i<RPT_MAX_LIST_ENTRIES;i++)
+      {
+        if ( messageList [ i ] )
+        {
+          //delete ( messageList [ i ] );
+          free ( messageList [ i ] );
+        }
+      }
+    }
+    LeaveCriticalSection(&aCriticalSection);
+  }
+
+  DeleteCriticalSection(&aCriticalSection);
+}
+
+/*****************************************************************************
+ * Return whether the Reporter is currently initialised or not.
+ *****************************************************************************/
+
+CPO_BOOL
+Reporter::connected ( void )
+{
+  return ( (BOOLEAN) state & CPO_CONNECTED );
+}
+
+/*****************************************************************************
+ * Return whether the Reporter is currently active or not.
+ *****************************************************************************/
+
+CPO_BOOL
+Reporter::active ( void )
+{
+  return ( (BOOLEAN) state & CPO_ACTIVATED );
+}
+
+/*****************************************************************************
+ * Suspend the Reporter
+ *****************************************************************************/
+
+void
+Reporter::sleep ( void )
+{
+  // must be initialised and activated
+  if ( ( state & CPO_CONNECTED ) && ( state & CPO_ACTIVATED ) )
+  {
+    EnterCriticalSection(&aCriticalSection);
+    state -= CPO_ACTIVATED;
+    
+    if ( state & RPT_FILE )
+    {
+      closeFile ( );
+    }
+    LeaveCriticalSection(&aCriticalSection);
+  }
+}
+
+/*****************************************************************************
+ * Re-activate the Reporter
+ *****************************************************************************/
+
+void
+Reporter::wake ( void )
+{
+  // must be initialised but not activated
+  if ( ( state & CPO_CONNECTED ) && ! ( state & CPO_ACTIVATED ) )
+  {
+    EnterCriticalSection(&aCriticalSection);
+    state += CPO_ACTIVATED;
+    
+    if ( state & RPT_FILE && !openFile ( ) )
+    {
+      // couldn't reopen the file so stop outputting to it
+      state -= RPT_FILE;
+
+      // no output left so shutdown Reporter
+      if ( !( state & RPT_OUTPUT_MASK ) )
+      {
+        kill ( );
+      }
+    }
+    LeaveCriticalSection(&aCriticalSection);
+  }
+}
+
+/*****************************************************************************
+ * Allow debug messages.
+ *****************************************************************************/
+
+void
+Reporter::debugON ( void )
+{
+  if ( state & CPO_CONNECTED )
+  {
+    EnterCriticalSection(&aCriticalSection);
+    if ( !( state & RPT_DEBUG_ON ) )
+    {
+      state += RPT_DEBUG_ON;
+      debug ( "DEBUG messages will be processed" );
+    }
+    LeaveCriticalSection(&aCriticalSection);
+  }
+}
+
+/*****************************************************************************
+ * Refuse debug messages.
+ *****************************************************************************/
+
+void
+Reporter::debugOFF ( void )
+{
+  if ( state & CPO_CONNECTED )
+  {
+    EnterCriticalSection(&aCriticalSection);
+    if ( state & RPT_DEBUG_ON )
+    {
+      debug ( "DEBUG messages will not be processed" );
+      state -= RPT_DEBUG_ON;
+    }
+    LeaveCriticalSection(&aCriticalSection);
+  }
+}
+
+/***************************************************************************
+ * Loads the contents of a message file into memory.
+ ***************************************************************************/
+
+void
+Reporter::load ( const char * file )
+{
+  if ( state & CPO_CONNECTED )
+  {
+    EnterCriticalSection(&aCriticalSection);
+    readMessageFile ( file );
+    if ( fileRead )
+    {
+      debug ( "Messages loaded from %s", file );
+    }
+    else
+    {
+      debug ( "No messages loaded from %s", file );
+    }
+    
+#ifdef RPT_DEBUG_PROG
+    if ( fileRead )
+    {
+      for (int i=0;i<RPT_MAX_LIST_ENTRIES;i++)
+      {
+        if ( messageList [ i ] )
+        {
+          (void) fprintf ( stdout, "%d : [%s] %d\n", 
+                           i, messageList [ i ], 
+                           strlen ( messageList [ i ] ) );
+        }
+      }
+    }
+#endif
+    LeaveCriticalSection(&aCriticalSection);
+  }
+}
+
+/***************************************************************************/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/src/cstatdataformatconverter.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,673 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include "stdafx.h"
+#include "afxpriv.h"
+#include "CSTATDataFormatConverter.h"
+
+//-------------------------------------------------------------------------------
+//standard functions for new variant class
+CSTATDataFormatConverter::CSTATDataFormatConverter(CSTATLogFile *pLog)
+: bWriteToFile(true)
+{
+	vt = VT_BLOB;
+	    
+	BLOB* pBody = new BLOB;
+	byref = pBody;
+	pBody->pBlobData = m_index = new BYTE [16];	//16 is the default buffer size
+	pBody->cbSize = m_bufsize = 16;
+
+	// set up logging
+	pLogFile = pLog;
+
+	// reset bitmap structures
+	memset(&iPbmHeader, 0xff, sizeof(iPbmHeader));
+	memset(&fileheader, 0xff, sizeof(fileheader));
+	memset(&bmpHeader, 0xff, sizeof(bmpHeader));
+	pPbmBits = NULL;
+	bmpBits = NULL;
+	lDataSize = 0;
+}
+
+//-------------------------------------------------------------------------------
+
+//Destructor
+CSTATDataFormatConverter::~CSTATDataFormatConverter()
+{
+	BLOB* pBody = (BLOB*)byref;
+	if (pBody)
+	{
+		if (pBody->pBlobData) 
+			delete [] pBody->pBlobData;
+	
+		delete pBody;
+	}
+
+	if (pPbmBits)
+	{
+		delete [] pPbmBits;
+		pPbmBits = NULL;
+	}
+
+	if (bmpBits)
+	{
+		delete [] bmpBits;
+		bmpBits = NULL;
+	}
+}
+
+//----------------------------------------------------------------------------
+
+bool CSTATDataFormatConverter::ConvertStringToUnicode(CString& data)
+{
+	// clear the existing buffer
+	((BLOB*)byref)->cbSize = 0;
+
+	// length IN BYTES of the UNICODE result (not the TCHAR input)
+	UINT len = (data.GetLength() + 1) * 2;
+
+	// check that the buffer can hold the contents -- otherwise enlarge
+	EnsureBufSize( len );
+
+	// convert the input string to unicode
+	USES_CONVERSION;
+	LPWSTR wstr = T2W(data.GetBuffer(0));
+
+	// copy data into the buffer and set the size
+	memcpy( m_index, wstr, len);
+	((BLOB*)byref)->cbSize = len;
+
+	// done
+	return true;
+}
+
+//----------------------------------------------------------------------------
+
+void CSTATDataFormatConverter::EnsureBufSize(int size)
+{
+	if (size > m_bufsize)
+	{
+		BLOB* pBody = (BLOB*)byref;
+		BYTE* newbuf = new BYTE [size];
+		delete[] pBody->pBlobData;
+		m_index = pBody->pBlobData = newbuf;
+		m_bufsize = size;
+	}
+}
+
+//----------------------------------------------------------------------------
+//Converts from .mbm to .bmp
+int
+CSTATDataFormatConverter::ConvertScreenShot(CString &mbmdirectory, CString &destdir)
+{
+	CFileFind imagefinder;
+	CString searchpattern = mbmdirectory;
+	if (searchpattern.Right(1) != _T('\\'))
+		searchpattern += _T("\\");
+	searchpattern += "*.mbm";
+
+	// there will only ever be one file to be converted at a time
+	if (imagefinder.FindFile(searchpattern, 0))
+	{
+		imagefinder.FindNextFile();
+
+		// get the source filename (in quotes)
+		CString imagefilename = _T("\"");
+		imagefilename += imagefinder.GetFilePath();
+		imagefilename += _T("\"");
+
+		// get the destination folder (in quotes)
+		CString newimagefilename = _T("\"");
+		newimagefilename += destdir;
+
+		// add a backslash if we need one
+		if (newimagefilename.Right(1) != _T("\\"))
+			newimagefilename += _T("\\");
+
+		// add the filename
+		newimagefilename += imagefinder.GetFileName();
+		newimagefilename.Replace(_T(".mbm"), _T(".bmp"));
+		newimagefilename += _T("\"");
+		imagefinder.Close();
+
+		// remove dest file if it already exists
+		if(imagefinder.FindFile(newimagefilename, 0))
+		{
+			imagefinder.Close();
+			DeleteFile(newimagefilename);
+		}
+
+		imagefilename.Remove('\"');
+		newimagefilename.Remove('\"');
+
+		if (bWriteToFile)
+		{
+			pLogFile->Set(CONVERTINGIMAGE, imagefilename.GetBuffer(0));
+			pLogFile->Set(TO, newimagefilename.GetBuffer(0));
+		}
+		else
+			pLogFile->Set(READINGIMAGE, imagefilename.GetBuffer(0));
+
+		// convert the bitmap
+		int errorcode = LoadBitmap(imagefilename);
+		if (errorcode != ITS_OK)
+			return pLogFile->Set(E_BITMAPLOADFAILED, pLogFile->Text(errorcode));
+
+		if ((errorcode = SaveBitmap(newimagefilename)) != ITS_OK)
+			return pLogFile->Set(E_BITMAPSAVEFAILED, pLogFile->Text(errorcode));
+
+		DeleteFile(imagefilename);	//delete original .mbm image
+
+		// success
+		mbmdirectory = newimagefilename;
+
+		// log a message that desktop STAT can use to display bitmap
+		pLogFile->Set(SCREENSHOT_CONVERSION_OK, mbmdirectory, false, true);
+
+		return ITS_OK;
+	}
+
+	return pLogFile->Set(E_NOIMAGESTOCONVERT, searchpattern);
+}
+
+//----------------------------------------------------------------------------
+int CSTATDataFormatConverter::LoadBitmap(CString &file)
+{
+	// reset structures
+	memset(&iPbmHeader, 0xff, sizeof(iPbmHeader));
+	if (pPbmBits)
+	{
+		delete [] pPbmBits;
+		pPbmBits = NULL;
+	}
+
+	// open file
+	HANDLE infile;
+	if (INVALID_HANDLE_VALUE != (infile = CreateFile(file, 
+										   GENERIC_READ,
+										   FILE_SHARE_READ, 
+										   NULL, 
+										   OPEN_EXISTING,
+										   FILE_ATTRIBUTE_NORMAL,
+										   0)))
+	{
+		long int iBuffer;
+		DWORD dwBytesRead = 0;
+
+		// read the header to ensure it is a valid file
+		if (!ReadFile(infile, (LPVOID *)&iBuffer, 4, &dwBytesRead, NULL) ||
+			dwBytesRead != 4 || iBuffer != KWriteOnceFileStoreUid)
+		{
+			CloseHandle(infile);
+			return E_BADFORMAT;
+		}
+
+		if (!ReadFile(infile, (LPVOID *)&iBuffer, 4, &dwBytesRead, NULL) ||
+			dwBytesRead != 4 || iBuffer != KMultiBitmapFileImageUid)
+		{
+			CloseHandle(infile);
+			return E_BADFORMAT;
+		}
+
+		if (!ReadFile(infile, (LPVOID *)&iBuffer, 4, &dwBytesRead, NULL) ||
+			dwBytesRead != 4 || iBuffer != 0)
+		{
+			CloseHandle(infile);
+			return E_BADFORMAT;
+		}
+
+		if (!ReadFile(infile, (LPVOID *)&iBuffer, 4, &dwBytesRead, NULL) ||
+			dwBytesRead != 4 || iBuffer != KMultiBitmapFileImageChecksum)
+		{
+			CloseHandle(infile);
+			return E_BADFORMAT;
+		}
+
+		if (!ReadFile(infile, (LPVOID *)&iBuffer, 4, &dwBytesRead, NULL) ||
+			dwBytesRead != 4)
+		{
+			CloseHandle(infile);
+			return E_BADFORMAT;
+		}
+
+		// go back to offset from the beginning
+		if (SetFilePointer(infile, iBuffer, NULL, FILE_BEGIN) == 0xFFFFFFFF)
+		{
+			CloseHandle(infile);
+			return E_BADFORMAT;
+		}
+
+		// read the number of sources (in our case it will always be one)
+		if (!ReadFile(infile, (LPVOID *)&iBuffer, 4, &dwBytesRead, NULL) ||
+			dwBytesRead != 4)
+		{
+			CloseHandle(infile);
+			return E_BADFORMAT;
+		}
+
+		// read offset from the beginning of this bitmap
+		if (!ReadFile(infile, (LPVOID *)&iBuffer, 4, &dwBytesRead, NULL) ||
+			dwBytesRead != 4)
+		{
+			CloseHandle(infile);
+			return E_BADFORMAT;
+		}
+
+		// go back to offset from the beginning
+		if (SetFilePointer(infile, iBuffer, NULL, FILE_BEGIN) == 0xFFFFFFFF)
+		{
+			CloseHandle(infile);
+			return E_BADFORMAT;
+		}
+
+		// read in the header
+		DWORD dwSize = sizeof(SEpocBitmapHeader);
+		if (!ReadFile(infile, (LPVOID *)&iPbmHeader, dwSize, &dwBytesRead, NULL) || dwBytesRead != dwSize)
+		{
+			CloseHandle(infile);
+			return E_BADFORMAT;
+		}
+
+		dwSize = iPbmHeader.iBitmapSize - iPbmHeader.iStructSize;
+
+		// now read in the bitmap matrix
+		pPbmBits = new char[dwSize];
+		if (pPbmBits)
+		{
+			memset(pPbmBits, 0xff, dwSize);
+			if (!ReadFile(infile, (LPVOID *)pPbmBits, dwSize, &dwBytesRead, NULL) || dwBytesRead != dwSize)
+			{
+				CloseHandle(infile);
+				return E_BADFORMAT;
+			}
+
+			if (iPbmHeader.iCompression != ENoBitmapCompression)
+			{
+				int byteWidth = ByteWidth(iPbmHeader.iWidthInPixels, iPbmHeader.iBitsPerPixel);
+				int expandedsize = byteWidth * iPbmHeader.iHeightInPixels;
+				char* newbits = new char[expandedsize];
+				if (newbits)
+				{
+					memset(newbits,0xff,expandedsize);
+					int ret = ITS_OK;
+
+					switch (iPbmHeader.iCompression)
+					{
+						case EByteRLECompression:
+							ret = ExpandByteRLEData(newbits,expandedsize,pPbmBits, dwSize);
+							break;
+						case ETwelveBitRLECompression:
+							ret = ExpandTwelveBitRLEData(newbits,expandedsize,pPbmBits, dwSize);
+							break;
+						case ESixteenBitRLECompression:
+							ret = ExpandSixteenBitRLEData(newbits,expandedsize,pPbmBits, dwSize);
+							break;
+						case ETwentyFourBitRLECompression:
+							ret = ExpandTwentyFourBitRLEData(newbits,expandedsize,pPbmBits, dwSize);
+							break;
+						default:
+							delete [] pPbmBits;
+							return E_BADCOMPRESSION;
+							break;
+					}
+
+					delete [] pPbmBits;
+					pPbmBits = newbits;
+					iPbmHeader.iCompression = ENoBitmapCompression;
+					iPbmHeader.iBitmapSize += expandedsize - dwSize;
+				}
+				else
+				{
+					CloseHandle(infile);
+					return E_OUTOFMEM;
+				}
+			}
+
+			CloseHandle(infile);
+		}
+		else
+		{
+			CloseHandle(infile);
+			return E_OUTOFMEM;
+		}
+	}
+	else
+		return E_FILE_OPEN_READ_FAILED;
+
+	return ITS_OK;
+}
+
+bool
+CSTATDataFormatConverter::ExpandByteRLEData(char* aDest,int aDestSize,char* aSrce,int aSrceSize)
+{
+	char* srcelimit=aSrce+aSrceSize;
+	char* destlimit=aDest+aDestSize;
+	while(aSrce<srcelimit && aDest<destlimit)
+		{
+		char count=*aSrce++;
+		if (count<0)
+			{
+			int runLength=-count;
+			memcpy(aDest,aSrce,runLength);
+			aSrce+=runLength;
+			aDest+=runLength;
+			}
+		else
+			{
+			char value=*aSrce++;
+			while(count>=0)
+				{
+				*aDest++=value;
+				count--;
+				}
+			}
+		}
+	if (aSrce!=srcelimit || aDest!=destlimit)
+		return false;
+
+	return true;
+}
+
+bool
+CSTATDataFormatConverter::ExpandTwelveBitRLEData(char* aDest,int aDestSizeInBytes,char* aSrce,int aSrceSizeInBytes)
+{
+	unsigned short* srcePtr = (unsigned short*)aSrce;
+	unsigned short* destPtr = (unsigned short*)aDest;
+	unsigned short* srcePtrLimit = srcePtr + (aSrceSizeInBytes / 2);
+	unsigned short* destPtrLimit = destPtr + (aDestSizeInBytes / 2);
+
+	while (srcePtr < srcePtrLimit && destPtr < destPtrLimit)
+		{
+		unsigned short value = *srcePtr++;
+		int runLength = (value >> 12) + 1;
+		value &= 0x0fff;
+
+		for (;runLength > 0;runLength--)
+			*destPtr++ = value;
+		}
+
+	if (srcePtr != srcePtrLimit || destPtr != destPtrLimit)
+		return false;
+
+	return true;
+}
+
+bool
+CSTATDataFormatConverter::ExpandSixteenBitRLEData(char* aDest,int aDestSizeInBytes,char* aSrce,int aSrceSizeInBytes)
+{
+	char* srcePtrLimit = aSrce + aSrceSizeInBytes;
+	unsigned short* destPtr = (unsigned short*)aDest;
+	unsigned short* destPtrLimit = destPtr + (aDestSizeInBytes / 2);
+
+	while (aSrce < srcePtrLimit && destPtr < destPtrLimit)
+		{
+		int runLength = *aSrce++;
+
+		if (runLength >= 0)
+			{
+			unsigned short value = *((unsigned short*)(aSrce));
+			aSrce += 2;
+			for (runLength++; runLength > 0; runLength--)
+				*destPtr++ = value;
+			}
+		else
+			{
+			runLength = -runLength;
+			int byteLength = runLength * 2;
+			memcpy(destPtr,aSrce,byteLength);
+			aSrce += byteLength;
+			destPtr += runLength;
+			}
+		}
+
+	if (aSrce != srcePtrLimit || destPtr != destPtrLimit)
+		return false;
+
+	return true;
+}
+
+bool
+CSTATDataFormatConverter::ExpandTwentyFourBitRLEData(char* aDest,int aDestSizeInBytes,char* aSrce,int aSrceSizeInBytes)
+{
+	char* srcePtrLimit = aSrce + aSrceSizeInBytes;
+	char* destPtrLimit = aDest + aDestSizeInBytes;
+
+	while (aSrce < srcePtrLimit && aDest < destPtrLimit)
+		{
+		int runLength = *aSrce++;
+
+		if (runLength >= 0)
+			{
+			char component1 = *aSrce++;
+			char component2 = *aSrce++;
+			char component3 = *aSrce++;
+			for (runLength++; runLength > 0; runLength--)
+				{
+				*aDest++ = component1;
+				*aDest++ = component2;
+				*aDest++ = component3;
+				}
+			}
+		else
+			{
+			runLength = -runLength;
+			int byteLength = runLength * 3;
+			memcpy(aDest,aSrce,byteLength);
+			aSrce += byteLength;
+			aDest += byteLength;
+			}
+		}
+
+	if (aSrce != srcePtrLimit || aDest != destPtrLimit)
+		return false;
+
+	return true;
+}
+
+int
+CSTATDataFormatConverter::SaveBitmap(CString &newfilename)
+{
+	// reset structures
+	memset(&fileheader, 0xff, sizeof(fileheader));
+	memset(&bmpHeader, 0xff, sizeof(bmpHeader));
+	if (bmpBits)
+	{
+		delete [] bmpBits;
+		bmpBits = NULL;
+	}
+	lDataSize = 0;
+
+	// copy header info into BMP structures
+	bmpHeader.biSize = sizeof(TBitmapInfoHeader);
+	bmpHeader.biWidth = iPbmHeader.iWidthInPixels;
+	bmpHeader.biHeight = iPbmHeader.iHeightInPixels;
+	bmpHeader.biPlanes = 1;
+	bmpHeader.biBitCount = 24;
+	bmpHeader.biCompression = 0;
+	bmpHeader.biSizeImage = 0;
+	bmpHeader.biXPelsPerMeter = 0;
+	bmpHeader.biYPelsPerMeter = 0;
+	bmpHeader.biClrUsed = 0;
+	bmpHeader.biClrImportant = 0;
+
+	long byteWidth = ((bmpHeader.biWidth * 3) + 3) & ~3;
+	lDataSize = bmpHeader.biHeight * byteWidth;
+
+	fileheader.bfType = 'B'+('M'<<8);
+	fileheader.bfSize = sizeof(TBitmapFileHeader)+sizeof(TBitmapInfoHeader) + lDataSize;
+	fileheader.bfReserved1 = 0;
+	fileheader.bfReserved2 = 0;
+	fileheader.bfOffBits = sizeof(TBitmapFileHeader)+sizeof(TBitmapInfoHeader);
+
+	// copy BMP data
+	bmpBits = new char[lDataSize];
+	if (!bmpBits)
+		return E_OUTOFMEM;
+
+	memset(bmpBits,0xff,lDataSize);
+
+	for(long y=0;y<bmpHeader.biHeight;y++)
+	{
+		char* dest=&bmpBits[(bmpHeader.biHeight-y-1)*byteWidth];
+		for(long x=0;x<bmpHeader.biWidth;x++)
+		{
+			TRgb pixel=GetPixel(x,y);
+			*dest++=pixel.iBlue;
+			*dest++=pixel.iGreen;
+			*dest++=pixel.iRed;
+		}
+	}
+
+	int ret = ITS_OK;
+	if (bWriteToFile)
+	{
+		// write the whole lot out to file
+		HANDLE infile;
+		if (INVALID_HANDLE_VALUE != (infile = CreateFile(newfilename, 
+											   GENERIC_WRITE,
+											   0, 
+											   NULL, 
+											   CREATE_ALWAYS,
+											   FILE_ATTRIBUTE_NORMAL,
+											   0)))
+		{
+			DWORD dwBytesWritten = 0;
+
+			// read the header to ensure it is a valid file
+			if (WriteFile(infile, (LPVOID *)&fileheader, sizeof(TBitmapFileHeader), &dwBytesWritten, NULL) &&
+				dwBytesWritten == sizeof(TBitmapFileHeader))
+			{
+				// read the header to ensure it is a valid file
+				if (WriteFile(infile, (LPVOID *)&bmpHeader, sizeof(TBitmapInfoHeader), &dwBytesWritten, NULL) &&
+					dwBytesWritten == sizeof(TBitmapInfoHeader))
+				{
+					if (WriteFile(infile, (LPVOID *)bmpBits, lDataSize, &dwBytesWritten, NULL) &&
+						dwBytesWritten == lDataSize)
+					{
+						ret = ITS_OK;
+					}
+					else
+						ret = E_BADWRITE;
+				}
+				else
+					ret = E_BADWRITE;
+			}
+			else
+				ret = E_BADWRITE;
+
+			CloseHandle(infile);
+		}
+		else
+			ret = E_FILE_OPEN_WRITE_FAILED;
+	}
+
+	return ret;
+}
+
+TRgb
+CSTATDataFormatConverter::GetPixel(int aXCoord,int aYCoord)
+{
+	unsigned char col;
+	aXCoord%=iPbmHeader.iWidthInPixels;
+	aYCoord%=iPbmHeader.iHeightInPixels;
+	int byteWidth = ByteWidth(iPbmHeader.iWidthInPixels,iPbmHeader.iBitsPerPixel);
+	int yOffset = aYCoord * byteWidth;
+
+	switch(iPbmHeader.iBitsPerPixel)
+	{
+		case 1:
+			col = pPbmBits[yOffset + (aXCoord / 8)];
+			col >>= (aXCoord&7);
+			return TRgb::Gray2(col & 1);
+		case 2:
+			col = pPbmBits[yOffset + (aXCoord / 4)];
+			col = (unsigned char)(col>>(2*(aXCoord%4)));
+			return TRgb::Gray4(col & 3);
+		case 4:
+			col = pPbmBits[yOffset + (aXCoord / 2)];
+			if (aXCoord & 1)
+				col >>= 4;
+			col &= 0xf;
+			if (iPbmHeader.iColor==EColorBitmap)
+				return TRgb::Color16(col);
+			else
+				return TRgb::Gray16(col);
+		case 8:
+			col=pPbmBits[yOffset + aXCoord];
+			if (iPbmHeader.iColor==EColorBitmap)
+				return TRgb::Color256(col);
+			else
+				return TRgb::Gray256(col);
+		case 12:
+		case 16:
+		{
+			unsigned short* shortPtr = (unsigned short*)&pPbmBits[yOffset + (aXCoord * 2)];
+			if (iPbmHeader.iBitsPerPixel == 12)
+				return TRgb::Color4K(*shortPtr);
+			else
+				return TRgb::Color64K(*shortPtr);
+		}
+		case 24:
+		{
+			char* pixelPtr = pPbmBits + yOffset + (aXCoord * 3);
+			TRgb pixelColor;
+			pixelColor.iBlue = *pixelPtr++;
+			pixelColor.iGreen = *pixelPtr++;
+			pixelColor.iRed = *pixelPtr;
+			return pixelColor;
+		}
+		default:
+			return TRgb(0);
+	}
+}
+
+int
+CSTATDataFormatConverter::ByteWidth(int aPixelWidth,int aBitsPerPixel)
+{
+	int wordWidth = 0;
+
+	switch (aBitsPerPixel)
+	{
+	case 1:
+		wordWidth = (aPixelWidth + 31) / 32;
+		break;
+	case 2:
+		wordWidth = (aPixelWidth + 15) / 16;
+		break;
+	case 4:
+		wordWidth = (aPixelWidth + 7) / 8;
+		break;
+	case 8:
+		wordWidth = (aPixelWidth + 3) / 4;
+		break;
+	case 12:
+	case 16:
+		wordWidth = (aPixelWidth + 1) / 2;
+		break;
+	case 24:
+		wordWidth = (((aPixelWidth * 3) + 11) / 12) * 3;
+		break;
+	default:
+		break;
+	};
+
+	return wordWidth * 4;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/src/cstatimageverify.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,678 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include "stdafx.h"
+#include <STATCommon.h>
+#include "CSTATImageVerify.h"
+
+//----------------------------------------------------------------------------
+//standard constructor
+CSTATImageVerify::CSTATImageVerify(CSTATLogFile *pLog)
+: iImageCount(0), margin(0), lastrefimageloaded(0), pLogFile(pLog),
+  m_pDib(NULL), m_pDib2(NULL), m_pDibBits(NULL), m_pDibBits2(NULL),
+  m_pBIH(NULL), m_pBIH2(NULL), m_pPalette(NULL), m_pPalette2(NULL),
+  m_dwDibSize(0), m_dwDibSize2(0), m_nPaletteEntries(0), m_nPaletteEntries2(0)
+{
+}
+
+//----------------------------------------------------------------------------
+//destructor
+CSTATImageVerify::~CSTATImageVerify()
+{
+	if (m_pDib)
+	{
+		delete [] m_pDib;
+		m_pDib = NULL;
+	}
+
+	if (m_pDib2)
+	{
+		delete [] m_pDib2;
+		m_pDib2 = NULL;
+	}
+}
+
+//----------------------------------------------------------------------------
+
+//image verification function (loading + blitting)
+int CSTATImageVerify::VerifyImage(CString& lastscreenshot)	
+{
+	TCHAR buffer[70];
+	_stprintf(buffer, _T("User set margin of error (percentage) : %ld"), margin);
+
+	pLogFile->Set(START_VERIFICATION, buffer);
+
+	// make sure we've got at least 1 image left
+	if(ImagesRemaining())
+	{
+		if(LoadRefImage())
+			pLogFile->Set(REFIMAGELOAD_OK, refimagearray[lastrefimageloaded++].completefilenamepath);
+		else
+			return pLogFile->Set(REFIMAGELOAD_FAILURE);
+
+		Sleep(500);
+
+		if(LoadNewImage(lastscreenshot))
+			pLogFile->Set(NEWIMAGELOAD_OK);
+		else
+			return pLogFile->Set(NEWIMAGELOAD_FAILURE);
+	}
+	else
+		return pLogFile->Set(REFIMAGELOAD_FAILURE_LIMIT);	//run out of reference images
+
+	//compare images and decide if difference is greater than margin value set earlier
+
+	// If we have not data we can't draw.
+	if (!m_pDib2)
+		return pLogFile->Set(VERIFICATION_FAILURE);
+
+	//set width and height of images
+	int nWidth = m_pBIH2 -> biWidth;
+	int nHeight = m_pBIH2 -> biHeight;
+
+	HDC hdc, hMaskDC, hImageDC;
+	HBITMAP hMaskBitmap, hImageBitmap;
+
+	hdc = GetDC(NULL);
+
+	//---------------------
+
+	hMaskDC = CreateCompatibleDC(hdc);
+	hImageDC = CreateCompatibleDC(hdc);
+	
+	hMaskBitmap = CreateCompatibleBitmap(hdc, nWidth, nHeight);
+	
+	SelectObject(hMaskDC, hMaskBitmap);
+	SetTextColor(hMaskDC, RGB(0, 0, 255)); 
+
+	//---------------------
+
+	hImageBitmap = CreateCompatibleBitmap(hdc, nWidth, nHeight);
+
+	// release the object now we're finished with it
+	ReleaseDC(NULL, hdc);
+
+	SelectObject(hImageDC, hImageBitmap);
+	SetTextColor(hImageDC, RGB(0, 0, 255)); 
+
+	//---------------------
+
+	//set MaskBitmap pixel data to that of the original DIB
+	SetDIBits(hMaskDC, hMaskBitmap, 0L, nHeight, m_pDibBits, (BITMAPINFO *)m_pBIH, (DWORD)DIB_RGB_COLORS);
+	
+	//create a new DIB using second image data
+	SetDIBits(hImageDC, hImageBitmap, 0L, nHeight, m_pDibBits2, (BITMAPINFO *)m_pBIH2, (DWORD)DIB_RGB_COLORS);
+
+	//XOR new image with original image (so new pic on top of pic 2)
+	BitBlt(hMaskDC, 0, 0, nWidth, nHeight, hImageDC, 0, 0, SRCINVERT);
+
+	//***************************************************
+
+	//now work on percentage difference in images
+
+	//need to use 'new' otherwise you get a stack overflow with anything big like this (1MB+)
+	COLORREF (*pixelcoord) [480];
+	pixelcoord = new COLORREF [640][480];
+	if (!pixelcoord)
+		return pLogFile->Set(VERIFICATION_FAILURE);
+
+	int x, y, myheight, mywidth;
+	float totalpixelarea;
+
+	x = 0;
+	y = 0;
+	int difference = 0;
+	float finalpercentage = 0;
+	totalpixelarea = 0;
+	myheight = 0;
+	mywidth = 0;
+
+	mywidth = m_pBIH -> biWidth;
+	myheight = m_pBIH -> biHeight;
+
+	// convert total to float for later % calculation
+	totalpixelarea = (float)(mywidth * myheight);
+
+	//initialisation
+	for(y = 0; y < 480; y++)
+	{
+		//go across picture left to right at each line
+		for(x = 0; x < 640; x++)
+		{
+			//get colorref value from coordinates
+			pixelcoord[x][y] = 0;
+		}
+	}
+
+	//check pixels - start at line 0
+	for(y = 0; y < myheight; y++)
+	{
+		//go across picture left to right at each line
+		for(x = 0; x < mywidth; x++)
+		{
+			//get colorref value from coordinates
+			pixelcoord[x][y] = GetPixel(hMaskDC, x, y);
+
+			//if not a  black pixel then increment counter
+			if(pixelcoord[x][y] != 0)
+			{
+				difference++;
+			}
+		}
+	}
+
+	// release resources
+	delete [] pixelcoord;
+	DeleteDC(hMaskDC);
+	DeleteDC(hImageDC);
+	DeleteObject(hMaskBitmap);
+	DeleteObject(hImageBitmap);
+
+	if (m_pDib)
+	{
+		delete [] m_pDib;
+		m_pDib = NULL;
+	}
+
+	if (m_pDib2)
+	{
+		delete [] m_pDib2;
+		m_pDib2 = NULL;
+	}
+
+	//now calculate percentage of pic that is not black
+	finalpercentage = ((difference / totalpixelarea) * 100);
+
+	// write conversion info to file
+
+
+	CString cBuffer;
+	cBuffer.Format(_T("Margin %ld : Difference %f"), margin, finalpercentage);
+	pLogFile->Set(cBuffer);
+
+	if(finalpercentage > margin)
+		return pLogFile->Set(VERIFICATION_FAILURE);
+
+	return pLogFile->Set(VERIFICATION_PASS);
+}
+
+
+//----------------------------------------------------------------------------
+//image loading for current new image
+bool CSTATImageVerify::LoadNewImage(CString& newimage)
+{
+	CFile cf;
+
+	// Attempt to open the Dib file for reading.
+	if(!cf.Open(newimage, CFile::modeRead))
+		return false;
+
+	// Get the size of the file and store
+	// in a local variable. Subtract the
+	// size of the BITMAPFILEHEADER structure
+	// since we won't keep that in memory.
+	DWORD dwDibSize;
+	dwDibSize = cf.GetLength() - sizeof( BITMAPFILEHEADER );
+
+	// Attempt to allocate the Dib memory.
+	unsigned char *pDib;
+	pDib = new unsigned char [dwDibSize];
+	if(!pDib)
+	{
+		cf.Close();
+		return false;
+	}
+
+	BITMAPFILEHEADER BFH;
+
+	// Read in the Dib header and data.
+	try
+	{
+		// Did we read in the entire BITMAPFILEHEADER?
+		if( cf.Read( &BFH, sizeof( BITMAPFILEHEADER ) )
+			!= sizeof( BITMAPFILEHEADER ) ||
+
+			// Is the type 'MB'?
+			BFH.bfType != 'MB' ||
+
+			// Did we read in the remaining data?
+			cf.Read( pDib, dwDibSize ) != dwDibSize )
+		{
+
+			// Delete the memory if we had any
+			// errors and return FALSE.
+			delete [] pDib;
+			cf.Close();
+			return false;
+			}
+		}
+
+	// If we catch an exception, delete the
+	// exception, the temporary Dib memory,
+	// and return FALSE.
+	catch( CFileException *e )
+	{
+		e->Delete();
+		delete [] pDib;
+		cf.Close();
+		return( FALSE );
+	}
+	
+	// If we got to this point, the Dib has been
+	// loaded. If a Dib was already loaded into
+	// this class, we must now delete it.
+	if (m_pDib2)
+	{
+		delete [] m_pDib2;
+		m_pDib2 = NULL;
+	}
+
+	// Store the local Dib data pointer and
+	// Dib size variables in the class member
+	// variables.
+	m_pDib2 = pDib;
+	m_dwDibSize2 = dwDibSize;
+
+	// Pointer our BITMAPINFOHEADER and RGBQUAD
+	// variables to the correct place in the Dib data.
+	m_pBIH2 = (BITMAPINFOHEADER *) m_pDib2;
+	m_pPalette2 =
+		(RGBQUAD *) &m_pDib2[sizeof(BITMAPINFOHEADER)];
+
+	// Calculate the number of palette entries.
+	m_nPaletteEntries = 1 << m_pBIH2->biBitCount;
+	if( m_pBIH2->biBitCount > 8 )
+		m_nPaletteEntries = 0;
+	else if( m_pBIH2->biClrUsed != 0 )
+		m_nPaletteEntries = m_pBIH2->biClrUsed;
+
+	// Point m_pDib2Bits to the actual Dib bits data.
+	m_pDibBits2 =
+		&m_pDib2[sizeof(BITMAPINFOHEADER)+
+			m_nPaletteEntries*sizeof(RGBQUAD)];
+
+	// If we have a valid palette, delete it.
+	if( m_Palette.GetSafeHandle() != NULL )
+		m_Palette.DeleteObject();
+
+	// If there are palette entries, we'll need
+	// to create a LOGPALETTE then create the
+	// CPalette palette.
+	if( m_nPaletteEntries != 0 )
+	{
+		// Allocate the LOGPALETTE structure.
+		LOGPALETTE *pLogPal = (LOGPALETTE *) new char [sizeof(LOGPALETTE) + m_nPaletteEntries*sizeof(PALETTEENTRY)];
+		if (pLogPal)
+		{
+			// Set the LOGPALETTE to version 0x300
+			// and store the number of palette
+			// entries.
+			pLogPal->palVersion = 0x300;
+			pLogPal->palNumEntries = (WORD)m_nPaletteEntries;
+
+			// Store the RGB values into each
+			// PALETTEENTRY element.
+			for( int i=0; i<m_nPaletteEntries; i++ )
+			{
+				pLogPal->palPalEntry[i].peRed =
+					m_pPalette2[i].rgbRed;
+				pLogPal->palPalEntry[i].peGreen =
+					m_pPalette2[i].rgbGreen;
+				pLogPal->palPalEntry[i].peBlue =
+					m_pPalette2[i].rgbBlue;
+			}
+
+			// Create the CPalette object and
+			// delete the LOGPALETTE memory.
+			m_Palette.CreatePalette( pLogPal );
+			delete [] pLogPal;
+		}
+		else
+			return false;
+	}
+
+	cf.Close();
+
+	return true;
+}
+
+//----------------------------------------------------------------------------
+//image loading for current reference image
+bool CSTATImageVerify::LoadRefImage()
+{
+	CFile cf;
+	if( !cf.Open(refimagearray[lastrefimageloaded].completefilenamepath, CFile::modeRead ) )
+		return false;
+
+	// Get the size of the file and store
+	// in a local variable. Subtract the
+	// size of the BITMAPFILEHEADER structure
+	// since we won't keep that in memory.
+	DWORD dwDibSize;
+	dwDibSize = cf.GetLength() - sizeof( BITMAPFILEHEADER );
+
+	// Attempt to allocate the Dib memory.
+	unsigned char *pDib;
+	pDib = new unsigned char [dwDibSize];
+	if(!pDib)
+	{
+		cf.Close();
+		return false;
+	}
+
+	BITMAPFILEHEADER BFH;
+
+	// Read in the Dib header and data.
+	try
+	{
+
+		// Did we read in the entire BITMAPFILEHEADER?
+		if( cf.Read( &BFH, sizeof( BITMAPFILEHEADER ) )
+			!= sizeof( BITMAPFILEHEADER ) ||
+
+			// Is the type 'MB'?
+			BFH.bfType != 'MB' ||
+
+			// Did we read in the remaining data?
+			cf.Read( pDib, dwDibSize ) != dwDibSize )
+		{
+
+			// Delete the memory if we had any
+			// errors and return FALSE.
+			delete [] pDib;
+			cf.Close();
+			return false;
+		}
+	}
+
+	// If we catch an exception, delete the
+	// exception, the temporary Dib memory,
+	// and return FALSE.
+	catch( CFileException *e )
+	{
+		e->Delete();
+		delete [] pDib;
+		cf.Close();
+		return false;
+	}
+	
+	// If we got to this point, the Dib has been
+	// loaded. If a Dib was already loaded into
+	// this class, we must now delete it.
+	if(m_pDib)
+	{
+		delete m_pDib;
+		m_pDib = NULL;
+	}
+
+	// Store the local Dib data pointer and
+	// Dib size variables in the class member
+	// variables.
+	m_pDib = pDib;
+	m_dwDibSize = dwDibSize;
+
+	// Pointer our BITMAPINFOHEADER and RGBQUAD
+	// variables to the correct place in the Dib data.
+	m_pBIH = (BITMAPINFOHEADER *) m_pDib;
+	m_pPalette =
+		(RGBQUAD *) &m_pDib[sizeof(BITMAPINFOHEADER)];
+
+	// Calculate the number of palette entries.
+	m_nPaletteEntries = 1 << m_pBIH->biBitCount;
+	if( m_pBIH->biBitCount > 8 )
+		m_nPaletteEntries = 0;
+	else if( m_pBIH->biClrUsed != 0 )
+		m_nPaletteEntries = m_pBIH->biClrUsed;
+
+	// Point m_pDibBits to the actual Dib bits data.
+	m_pDibBits =
+		&m_pDib[sizeof(BITMAPINFOHEADER)+
+			m_nPaletteEntries*sizeof(RGBQUAD)];
+
+	// If we have a valid palette, delete it.
+	if (m_Palette.GetSafeHandle())
+		m_Palette.DeleteObject();
+
+	// If there are palette entries, we'll need
+	// to create a LOGPALETTE then create the
+	// CPalette palette.
+	if( m_nPaletteEntries != 0 )
+	{
+		// Allocate the LOGPALETTE structure.
+		LOGPALETTE *pLogPal = (LOGPALETTE *) new char
+				[sizeof(LOGPALETTE)+
+				m_nPaletteEntries*sizeof(PALETTEENTRY)];
+
+		if(pLogPal)
+		{
+
+			// Set the LOGPALETTE to version 0x300
+			// and store the number of palette
+			// entries.
+			pLogPal->palVersion = 0x300;
+			pLogPal->palNumEntries = (WORD)m_nPaletteEntries;
+
+			// Store the RGB values into each
+			// PALETTEENTRY element.
+			for( int i=0; i<m_nPaletteEntries; i++ )
+			{
+				pLogPal->palPalEntry[i].peRed =
+					m_pPalette[i].rgbRed;
+				pLogPal->palPalEntry[i].peGreen =
+					m_pPalette[i].rgbGreen;
+				pLogPal->palPalEntry[i].peBlue =
+					m_pPalette[i].rgbBlue;
+			}
+
+			// Create the CPalette object and
+			// delete the LOGPALETTE memory.
+			m_Palette.CreatePalette( pLogPal );
+			delete [] pLogPal;
+		}
+		else
+			return false;
+	}
+
+	cf.Close();
+
+	return true;
+}
+
+//----------------------------------------------------------------------------
+int CSTATImageVerify::EnableVerification(int fudge)
+{
+	// temp variable
+	FILETIME creationtime;
+	creationtime.dwLowDateTime = 0;
+	creationtime.dwHighDateTime = 0;
+
+	// initialise settings
+	iImageCount = 0;
+	lastrefimageloaded = 0;
+	margin = fudge;
+
+	// check limits
+	if (margin < 0)
+		margin = 0;
+	if (margin > 100)
+		margin = 100;
+
+	// populate our array with images
+	CFileFind refimagefinder;
+	if (refimagefinder.FindFile(referenceimagedir + _T("\\*.bmp"), 0))
+	{
+		int i = 0;
+		int iMoreFiles = true;
+		for (i=0;i<VERIFY_MAX_IMAGES;i++)
+		{
+			if (iMoreFiles)
+			{
+				iMoreFiles = refimagefinder.FindNextFile();
+  				refimagearray[i].completefilenamepath = refimagefinder.GetFilePath();	//store filename into array string variable
+				refimagefinder.GetLastWriteTime(&creationtime);		//store corresponding modification time
+				refimagearray[i].lCreationTime = (((ULONGLONG) creationtime.dwHighDateTime) << 32) + creationtime.dwLowDateTime;
+				iImageCount++;
+			}
+			else
+			{
+				refimagearray[i].completefilenamepath = _T("");
+				refimagearray[i].lCreationTime = 0;
+			}
+		}
+
+		refimagefinder.Close();
+	}
+	
+	// now sort into date/time order
+	if (iImageCount)
+	{
+		CSTATReferenceImages temp;
+		bool bNotFinished = true;
+		int i = 0;
+		while (bNotFinished)
+		{
+			bNotFinished = false;
+			for (i=0;i<iImageCount;i++)
+			{
+				if ((i + 1) < iImageCount &&
+					refimagearray[i+1].lCreationTime < refimagearray[i].lCreationTime)
+				{
+					temp = refimagearray[i];
+					refimagearray[i]= refimagearray[i+1];
+					refimagearray[i+1]= temp;
+					bNotFinished = true;
+				}
+			}
+		}
+	}
+
+	return iImageCount;
+}
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
+// Get the local reference image directory from the registry
+int CSTATImageVerify::Initialise(const CString& path)
+{
+	int ret = ERROR_REGISTRY;
+	TCHAR szFullPath[256 + 1];
+
+
+	_tcsncpy(szFullPath, path.operator LPCTSTR(), path.GetLength() + 1);
+	
+	//append ref images directory to the stat installation directory as found in registry
+	_tcscat(szFullPath, _T("\\Reference Images"));
+	referenceimagedir = szFullPath;
+
+	// try to create in case it doesn't exist
+	CreateDirectory(referenceimagedir, NULL);
+
+	// there may be old files to delete...
+	_tcscat(szFullPath, _T("\\*.*"));
+	CFileFind finder;
+	if (finder.FindFile(szFullPath, 0))
+	{
+		int iWorking = 1;
+		int filecount = 0;
+		while (iWorking)
+		{
+			iWorking = finder.FindNextFile();
+
+			// skip . and .. files
+			if (finder.IsDots())
+				continue;
+
+			filecount++;
+		}
+
+		finder.Close();
+
+		if (filecount)
+			ret = REFDIR_FOUND;
+		else
+			ret = ITS_OK;
+	}
+	else
+		ret = LOG_DIR_CREATE_FAILURE;
+	
+	
+	
+	return ret;
+}
+
+//----------------------------------------------------------------------------
+//reference images copied over to local machine
+int CSTATImageVerify::CopyReferenceImages(LPTSTR refimagelocation)
+{
+	int ret = GENERAL_FAILURE;
+
+	// need to copy into null terminated string to have 2 nulls at end as required
+	TCHAR szFrom[MAX_PATH + 1] = {0};
+	_tcscpy(szFrom, refimagelocation);
+	_tcscat(szFrom, _T("\\*.bmp"));
+
+	// need to copy into null terminated string to have 2 nulls at end as required
+	TCHAR szTo[MAX_PATH + 1] = {0};
+	_tcscpy(szTo, referenceimagedir);
+
+	//new file structure for copying files
+	SHFILEOPSTRUCT fo = {0};
+	fo.wFunc = FO_COPY;
+	fo.pFrom = szFrom;
+	fo.pTo = szTo;
+	fo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT;
+
+	//copy new images across
+	if(::SHFileOperation(&fo) != 0) //if fail file operation
+		return ERR_FILE_COPY_FAILED;
+
+	// check that at least 1 bitmap image got copied across
+	_tcscat(szTo, _T("\\*.bmp"));
+	CFileFind finder;
+	ret = finder.FindFile(szTo, 0);
+	finder.Close();
+	if (!ret)
+		return NO_BITMAPS;
+
+	return ITS_OK;
+}
+
+//----------------------------------------------------------------------------
+//local reference images deleted from local machine
+int CSTATImageVerify::DeleteReferenceImages()
+{
+	// need to copy into null terminated string to have 2 nulls at end as required
+	TCHAR szImages[MAX_PATH + 1] = {0};
+	_tcscpy(szImages, referenceimagedir);
+	_tcscat(szImages, _T("\\*.*"));
+	
+	//new file structure for deleting files
+	SHFILEOPSTRUCT fo2 = {0};
+	fo2.wFunc = FO_DELETE;
+	fo2.pFrom = szImages;
+	fo2.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_FILESONLY | FOF_NOERRORUI;
+
+	//delete
+	if(::SHFileOperation(&fo2) != 0) //if fail file deletion
+		return DELETEIMAGES_FAILURE;
+
+	return ITS_OK;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/src/cstatlogfile.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,387 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include "stdafx.h"
+#include "CSTATLogFile.h"
+#include <statcommon.h>
+
+//----------------------------------------------------------------------------
+// our thread-safe mechanism - this must be defined, initialised and destroyed by
+// the code using CSTATEngine.  See STATExp.cpp for an example
+extern CRITICAL_SECTION CriticalSection;
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
+//standard constructor
+CSTATLogFile::CSTATLogFile()
+: bMessageBox(false), bMessage(false), bWriteToScreen(false), bWriteToFile(false), bScreenshot(false),
+	iMessageReporter(NULL)
+{
+	message = _T("");
+	text = _T("");
+	*(szLogPrefix) = (char)0;
+}
+
+//----------------------------------------------------------------------------
+//destructor
+CSTATLogFile::~CSTATLogFile()
+{
+	CloseLogFile();
+}
+
+
+//----------------------------------------------------------------------------
+// opens (creates) logfile
+int CSTATLogFile::CreateLogFile(const CString& newlogfilename,const CString& defaultPath, const char* prefix, bool append, bool bMessages, bool bFile)
+{
+	// set flags to write to dialog screen/file
+	bWriteToScreen = bMessages;
+	bWriteToFile = bFile;
+
+	// construct our log file
+	if (bWriteToFile)
+	{
+		EnterCriticalSection(&CriticalSection);
+
+		// in case it's already open
+		CloseLogFile();
+
+		int position;
+		UINT openFlags = CFile::modeCreate | CFile::modeWrite | CFile::shareDenyNone;
+
+		// if newlogfilename contains a path, use it otherwise get the default log directory
+		position = newlogfilename.ReverseFind('\\');
+		if (position != -1)
+		{
+			Logfilename = newlogfilename;
+			CreateDirectory(Logfilename.Left(position), NULL); // try to create directory just in case
+		}
+		else
+		{
+			Logfilename=defaultPath;
+			if (Logfilename[Logfilename.GetLength() - 1] != _T('\\'))
+				Logfilename += _T("\\");
+
+			Logfilename += newlogfilename;
+			CreateDirectory(Logfilename, NULL); // try to create directory just in case
+		}
+
+		// just path supplied, add a filename
+		if (Logfilename[Logfilename.GetLength() - 1] == _T('\\'))
+		{
+			char FormattedDate[12] = {0};
+			Logfilename += _T("STAT");
+			Logfilename += _strdate(FormattedDate);		// ...\\filename is now 'STATmm/dd/yy'
+			Logfilename.Remove('/');					// ...\\filename is now 'STATmmddyy'
+		}
+
+		// add extension if not supplied
+		if(Logfilename.ReverseFind('.') == -1)
+			Logfilename += _T(".log");
+
+		// if not append, create a new file every time, renaming with (1),(2)...(n) as needed
+		CFileFind finder;
+		if (!append)
+		{
+			CString tempLogfile, tempLogstart, tempLogend;
+			char szCopycount[15] = {0};
+			int iCopycount = 1;
+
+			// save various bits
+			tempLogfile = Logfilename;
+			position = tempLogfile.ReverseFind('.');
+			tempLogstart = tempLogfile.Left(position);
+			tempLogend = Logfilename.Right(Logfilename.GetLength() - position);
+
+			while (finder.FindFile(tempLogfile, 0))
+			{
+				if (position > 0)
+				{
+					tempLogfile = tempLogstart;
+					tempLogfile += "(";
+					tempLogfile += itoa(iCopycount++, szCopycount, 10);
+					tempLogfile += ")";
+					tempLogfile += tempLogend;
+				}
+				finder.Close();
+			}					
+
+			// assign new filename
+			Logfilename = tempLogfile;
+		}
+		else
+		{
+			// if it already exists, open simple in case other handles are open on it
+			if (finder.FindFile(Logfilename, 0))
+			{
+				openFlags = CFile::modeWrite | CFile::shareDenyNone;
+				finder.Close();
+			}
+		}
+
+		// open the file
+		int valid = logfile.Open(Logfilename, openFlags);
+		if (valid)
+		{
+			logfile.SeekToEnd();
+			if (prefix && *prefix)
+			{
+				strcpy(szLogPrefix, "  ");
+				strcat(szLogPrefix, prefix);
+			}
+		}
+
+		LeaveCriticalSection(&CriticalSection);
+
+		if (!valid)
+			return LOG_FILE_FAILURE;
+	}
+
+	return LOG_FILE_OK;
+}
+
+//----------------------------------------------------------------------------
+// Specifies the message handler.
+void CSTATLogFile::SetMessageReporter(MessageReporter *const messageReporter)
+{
+	iMessageReporter =	messageReporter;
+}
+
+//----------------------------------------------------------------------------
+// sets a log message
+void
+CSTATLogFile::WriteTimeToLog()
+{
+	if (logfile.m_hFile != CFile::hFileNull)
+	{
+		EnterCriticalSection(&CriticalSection);
+
+		// get the time
+		time_t aclock;
+		time(&aclock);
+		CString cBuf = asctime(localtime(&aclock));
+		int position = cBuf.Find(_T('\n')); // remove the carriage return from the end
+		if (position != -1)
+			cBuf.SetAt(position, 0);
+
+		Write("--------------------------------------------------\r\n");
+		Write(FormatText(cBuf));
+
+		logfile.Flush();
+
+		LeaveCriticalSection(&CriticalSection);
+	}
+}
+
+
+//----------------------------------------------------------------------------
+// writes CString directly to the log file
+void
+CSTATLogFile::Write(CString cBuf)
+{
+	Write(FormatText(cBuf));
+}
+
+
+//----------------------------------------------------------------------------
+//writes basic text directly to the log file
+void CSTATLogFile::Write(char *szText, ...)
+{
+	if (logfile.m_hFile != CFile::hFileNull)
+	{
+		EnterCriticalSection(&CriticalSection);
+
+		static char szMessage[MAX_LOG_MSG_LEN + 1];
+		static time_t curTime;
+
+		logfile.SeekToEnd();
+		logfile.Write(szLogPrefix, strlen(szLogPrefix));
+
+		// write the date/time
+		time ( &curTime );
+		strftime ( szMessage, 
+					sizeof ( szMessage ), 
+					"%d/%m %H:%M:%S ",
+					localtime ( &curTime ) );
+		logfile.Write(szMessage, strlen(szMessage));
+
+		// write the message
+		memset(&szMessage, 0, sizeof(szMessage));
+		va_list pCurrent = (va_list)0;
+		va_start (pCurrent, szText);
+		vsprintf (szMessage, szText, pCurrent);
+		va_end (pCurrent);
+		logfile.Write(szMessage, strlen(szMessage));
+
+		// add a CRLF if there isn't one already
+		if (strlen(szMessage) > 2)
+			if (strcmp(szMessage + strlen(szMessage) - 2, "\r\n") != 0)
+				logfile.Write("\r\n", 2);
+
+		logfile.Flush();
+
+		LeaveCriticalSection(&CriticalSection);
+	}
+}
+
+
+//----------------------------------------------------------------------------
+// sets a log message (same as Write() but subject to waiting for previous
+// message to be processed before returning (if multi-threaded write to screen
+// is enabled)
+int
+CSTATLogFile::Set(const char* newtext)
+{
+	Set(-1, newtext, false, false);
+	return ITS_OK;
+}
+
+//----------------------------------------------------------------------------
+// sets a log message (same as Write() but subject to waiting for previous
+// message to be processed before returning (if multi-threaded write to screen
+// is enabled)
+int
+CSTATLogFile::Set(int iMsgCode, const char* newtext, bool bMsgBox, bool bScrshot)
+{
+	// write to screen
+	if (bWriteToScreen && (NULL != iMessageReporter))
+	{
+		// set contents
+		if (iMsgCode != -1)
+		{
+			message = ReturnCodes.GetRetMsg(iMsgCode);
+		}
+		else
+		{
+			message.Empty( );
+		}
+
+		if ((newtext != NULL) && (*newtext != '\0'))
+		{
+			text = newtext;
+		}
+
+		iMessageReporter->OnMessage( message.operator LPCTSTR(), text.operator LPCTSTR(),
+										bMsgBox, bScrshot );
+	}
+
+	// write to file
+	if (bWriteToFile)
+	{
+		EnterCriticalSection(&CriticalSection);
+
+		if (iMsgCode != -1)
+			Write(FormatText(ReturnCodes.GetRetMsg(iMsgCode)));
+
+		if ((newtext != NULL) && (*newtext != '\0'))
+			Write(FormatText(newtext));
+
+		LeaveCriticalSection(&CriticalSection);
+	}
+
+	return iMsgCode;
+}
+
+//----------------------------------------------------------------------------
+//closes the active logfile
+void CSTATLogFile::CloseLogFile()
+{
+	EnterCriticalSection(&CriticalSection);
+
+	if (logfile.m_hFile != CFile::hFileNull)
+		logfile.Abort();
+
+	LeaveCriticalSection(&CriticalSection);
+}
+
+
+//----------------------------------------------------------------------------
+// PRIVATE METHODS
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
+//removes spacing between data when writing to file
+char* CSTATLogFile::FormatText(const char* message)
+{
+	int newlen = 0;
+	static char szBuffer[MAX_LOG_MSG_LEN + 3];
+	int maxlen = strlen(message);
+
+	if (maxlen > MAX_LOG_MSG_LEN)
+		maxlen = MAX_LOG_MSG_LEN;
+
+	(*szBuffer) = (char)0;
+	newlen = ToAnsi(message, szBuffer, maxlen);
+
+	// add CR-LF and null-terminate, even if an empty string
+	*(szBuffer + newlen) = (char)0;
+	strcat(szBuffer, "\r\n");
+
+	return szBuffer;
+}
+
+
+//----------------------------------------------------------------------------
+//function to convert unicode to ansi - for logging
+int CSTATLogFile::ToAnsi(LPCTSTR szUnicode, LPSTR szBuffer, int nBufLen)
+{
+#ifdef UNICODE
+	return (WideCharToMultiByte(CP_ACP,						// conversion type
+								0,							// flags
+								szUnicode,					// source
+								nBufLen,					// length
+								szBuffer,					// dest
+								nBufLen,					// length
+								NULL,
+								NULL));
+#else
+	strncpy(szBuffer, szUnicode, nBufLen);
+	*(szBuffer + nBufLen) = (char)0;
+	return strlen(szBuffer);
+#endif
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Converts a char * to it's Unicode equivalent
+//
+LPCTSTR
+CSTATLogFile::ToUnicode(const char *string)
+{
+#ifdef UNICODE
+	static TCHAR szBuffer[MAX_LOG_MSG_LEN + 1] = {0};
+	szBuffer[0] = (TCHAR)0;
+
+    // Convert to UNICODE.
+    if (!MultiByteToWideChar(CP_ACP,					// conversion type
+							 0,							// flags
+							 string,					// source
+							 -1,						// length
+							 szBuffer,					// dest
+							 MAX_LOG_MSG_LEN))			// length
+    {
+        return _T("Unable to convert ansi to unicode");
+    }
+
+    return szBuffer;
+#else
+	return string;
+#endif
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/src/cstatreturncodes.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,225 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include "stdafx.h"
+#include "CSTATReturnCodes.h"
+
+static char *messages[] = 
+{
+	"General Failure.",															// 0
+	"This version of STAT has expired, please contact Symbian Ltd.",
+	"Unable to initialise time delay for the chosen platform.",
+	"DLL initialisation failure.",
+	"Interpreting STAT commands...",
+	"Unable to convert commands to 8-bit.",
+	"Unable to initialise Command Decoder.",
+	"Unable to initialise Data Format Converter.",
+	"Unable to initialise Directory Manager.",
+	"Unable to initialise Return Codes.",
+	"Unable to initialise COM library.",										// 10
+	"Copying...",
+	"Old images currently exist on the local machine.\r\n\r\nSelect YES to replace the images, NO to use the existing images, or CANCEL to stop.",
+	"The script completed successfully",
+	"Time delay set ok.",
+	"ALMOST THERE...",
+	"Error accessing registry.",
+	"Error with logfile directory.",
+	"Logfile directory found.",
+	"Logfile name found, but it is not a directory!  Please remove/rename.",
+	"Error in logfile registry key value - directory cannot be created.",		// 20
+	"Cannot create directory.",
+	"Logfile directory is :",
+	"Error with log file registry entry value.",
+	"Error with log file creation.",
+	"Log file created ok.",
+	"Script opened ok.",
+	"Unable to open script.",
+	"Error with cleanup.",
+	"NO END COMMAND FOUND IN SCRIPT FILE",
+	"End of script file.",														// 30
+	"Missing <B> or <E> command in script file",
+	"Please Connect first!",
+	"Unable to allocate memory for connection.",
+	"Connected.",
+	"Invalid # command.",
+	"New image directory...",
+	"Standard image directory created.",
+	"Cannot find trailing comment syntax.",
+	"Comment...",
+	"Invalid '/' found.",														// 40
+	"Unable to initialise log file class.",
+	"Pause...",
+	"Device information received.",
+	"Trying for device info...",
+	"Cannot retrieve device info.",
+	"Machine information received.",
+	"Trying for machine info...",
+	"Cannot retrieve machine info.",
+	"Key data...",
+	"Key data sent.",															// 50
+	"Key data sending failure.",
+	"System key data...",
+	"System key data sent.",
+	"System key data sending failure.",
+	"Combination key data...",
+	"Combination key data sent.",
+	"Combination key data sending failure.",
+	"Invalid script combination key data.",
+	"Application startup...",
+	"Application data sent.",													// 60
+	"Application data sending failure.",
+	"File opening...",
+	"File data sent.",
+	"File data sending failure.",
+	"File transfer...",
+	"File transfer ok.",
+	"File transfer failure.",
+	"A Symbian Connect session could not be instantiated.",
+	"File retrieval (move)...",
+	"File retrieval ok.",														// 70
+	"File retrieval failure.",
+	"Touch screen...",
+	"Touch screen ok.",
+	"Touch screen failure.",
+	"Attempting to close application...",
+	"Closed application ok.",
+	"Could not close application.",
+	"Starting EShell...",
+	"Started EShell ok.",
+	"Starting EShell failure.",													// 80
+	"Stopping EShell...",
+	"Stopped EShell ok.",
+	"Stopping EShell failure.",
+	"Attempting to take screenshot...",
+	"Screenshot taken ok.",
+	"Screenshot failure.",
+	"Attempting to move screenshot to PC...",
+	"Screenshot moved.",
+	"Screenshot moving failure.",
+	"Screenshot conversion failure.",											// 90
+	"Screenshot converted ok.",
+	"Unable to initialise Image Verifier.",
+	"Unable to delete reference images.",
+	"Reference image loaded ok.",
+	"Reference image loading failure.",
+	"No more reference images left for verification.",
+	"New image loaded OK",
+	"New image loading failure.",
+	"Image verification passed.",
+	"Image verification failed.",												// 100
+	"Attempting image verification...",
+	"Unable to create new image directory.",
+	"No reference images!  Verification disabled.",
+	"Invalid touch screen command.",
+	"Key hold command...",
+	"Key hold ok.",
+	"Key hold failure.",
+	"Invalid keyhold command.",
+	"Keyhold command string is too long.",
+	"Invalid image directory.",													// 110
+	"File copy operation failed.",
+	"An invalid platform was specified.",
+	"An external COM file system interface could not be obtained.",
+	"An external COM request interface could not be obtained.",
+	"A Symbian Connect session could not be initialised.",
+	"A COM request object could not be instantiated.",
+	"Remote device could not be initialised.  Check STAT support DLLs exist.",
+	"No reference images could be located",
+	"Deleting file...",
+	"File delete operation ok.",												// 120
+	"File delete operation failed.",
+	"Creating folder...",
+	"Create folder operation ok.",
+	"Create folder operation failed.",
+	"Removing folder...",
+	"Remove folder operation ok.",
+	"Remove folder operation failed.",
+	"The requested operation is not supported",
+	"Script cancelled at user's request",
+	"Out of memory",															// 130
+	"Invalid command format",
+	"Messaging initialisation failure",
+	"The file format is invalid",
+	"Could not open Symbian OS file to read",
+	"Image folder (PC side) does not exist for conversion",
+	"No images to convert",
+	"The bitmap could not be loaded prior to conversion",
+	"The converted bitmap could not be saved",
+	"The file write operation failed",
+	"Could not open bitmap file to write",										// 140
+	"Unknown data compression type",
+	"A leftover .mbm file could not be removed prior to bitmap conversion",
+	"Converting bitmap image from:",
+	"To:",
+	"File retrieval (copy)...",
+	"Invalid command syntax",
+	"Reading bitmap image into memory...",
+	"Screenshot read into memory successfully.",
+	"Command could not be sent...Retrying...",
+	"Retries exhausted.  Command failed.",										// 150
+	"A connection could not be established",
+	"Write to port failed",
+	"Read from port failed",
+	"No data read from port",
+	"Maximum time limit exceeded on single command",
+	"Maximum error limit exceeded on single command",
+	"Command ID of this type was not expected",
+	"Bad file name or file does not exist",
+	"Incorrect number of bytes read or written",
+	"Insufficient memory or connection type not supported",						// 160
+	"Retrieving file to:",
+	"Invalid command type",
+	"Communication needs to resynchronise",
+	"No data to save to file",
+	"Windows Socket Server could not be started",
+	"Socket could not be created",
+	"Socket connection failed",
+	"Socket could not be bound to this port",
+	"Socket could not listen on this port",
+	"Host name could not be obtained",											// 170
+	"Socket send failed",
+	"Socket receive failed",
+	"Script task terminated at user's request",
+	"Socket could not be closed",
+	"Windows Server shutdown failed",
+	"Using existing images",
+	"No connection specified",
+	NULL
+};
+
+CSTATReturnCodes::CSTATReturnCodes()
+: iMaxCodes(0)
+{
+	// determine the maximum error code possible
+	while(messages[iMaxCodes])
+		iMaxCodes++;
+}
+
+const char*
+CSTATReturnCodes::GetRetMsg(const DWORD codenum)
+{
+	static CString retval;
+	if (codenum < iMaxCodes)
+		retval = messages[(int)codenum];
+	else
+		retval = _T("No error text associated with this code");
+
+	return retval.operator LPCTSTR( );
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/src/statbitmap.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,167 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#include "stdafx.h"
+#include "CSTATDataFormatConverter.h"
+#include "statbitmap.h"
+
+extern TRgb* color256Palette;
+extern char* color256InversePalette;
+
+TRgb* color256Palette = NULL;
+char* color256InversePalette = NULL;
+
+TRgb::TRgb()
+	: iRed(255),iGreen(255),iBlue(255),iSpare(0)
+	{}
+
+TRgb::TRgb(long unsigned int val)
+	: iRed((unsigned char)(val&0xff)),iGreen((unsigned char)((val>>8)&0xff)),iBlue((unsigned char)((val>>16)&0xff)),iSpare(0)
+	{}
+
+TRgb::TRgb(int r,int g,int b)
+	: iRed((unsigned char)r),iGreen((unsigned char)g),iBlue((unsigned char)b),iSpare(0)
+	{}
+
+TRgb &TRgb::operator=(const TRgb &col)
+	{
+	iRed=col.iRed;
+	iGreen=col.iGreen;
+	iBlue=col.iBlue;
+	return(*this);
+	}
+
+int TRgb::operator==(const TRgb &col)
+	{
+	return(iRed==col.iRed && iGreen==col.iGreen && iBlue==col.iBlue);
+	}
+
+int TRgb::Difference(const TRgb& col) const
+	{
+	return abs(iRed-col.iRed) + abs(iGreen-col.iGreen) + abs(iBlue-col.iBlue);
+	}
+
+int TRgb::Gray2() const
+	{
+	return Gray256() / 128;
+	}
+
+int TRgb::Gray4() const
+	{
+	return Gray256() / 64;
+	}
+
+int TRgb::Gray16() const
+	{
+	return Gray256() / 16;
+	}
+
+int TRgb::Gray256() const
+	{
+	return((2*iRed+5*iGreen+iBlue)/8);
+	}
+
+int TRgb::Color16() const
+	{
+	int index = (iRed >> 5) & 0x007;
+	index |= (iGreen  >> 2) & 0x038;
+	index |= (iBlue << 1) & 0x1c0;
+	return color16inverse[index];
+	}
+
+int TRgb::Color256() const
+	{
+	int index = (iRed >> 4) & 0x00f;
+	index |= iGreen & 0x0f0;
+	index |= (iBlue << 4) & 0xf00;
+
+	if (color256InversePalette)
+		return color256InversePalette[index];
+	else
+		return color256inverse[index];
+	}
+
+int TRgb::Color4K() const
+	{
+	return(((iRed&0xf0)<<4)|(iGreen&0xf0)|((iBlue&0xf0)>>4));
+	}
+
+int TRgb::Color64K() const
+	{
+	return(((iRed&0xf8)<<8)|((iGreen&0xfc)<<3)|((iBlue&0xf8)>>3));
+	}
+
+long int TRgb::Color16M() const
+	{
+	return((iRed<<16)|(iGreen<<8)|iBlue);
+	}
+
+TRgb TRgb::Gray2(int aGray2)
+	{
+	aGray2 *= 255;
+	return TRgb(aGray2,aGray2,aGray2);
+	}
+
+TRgb TRgb::Gray4(int aGray4)
+	{
+	aGray4 *= 85;
+	return TRgb(aGray4,aGray4,aGray4);
+	}
+
+TRgb TRgb::Gray16(int aGray16)
+	{
+	aGray16 *= 17;
+	return TRgb(aGray16,aGray16,aGray16);
+	}
+
+TRgb TRgb::Gray256(int aGray256)
+	{
+	return TRgb(aGray256,aGray256,aGray256);
+	}
+
+TRgb TRgb::Color16(int aColor16)
+	{
+	return TRgb(color16array[aColor16&0xf]);
+	}
+
+TRgb TRgb::Color256(int aColor256)
+	{
+	if (color256Palette)
+		return color256Palette[aColor256&0xff];
+	else
+		return TRgb(color256array[aColor256&0xff]);
+	}
+
+TRgb TRgb::Color4K(int aColor4K)
+	{
+	return TRgb(((aColor4K>>8)&0xf)*17,((aColor4K>>4)&0xf)*17,(aColor4K&0xf)*17);
+	}
+
+TRgb TRgb::Color64K(int aColor64K)
+	{
+	return TRgb(((aColor64K>>11)&0x1f)*255/31,((aColor64K>>5)&0x3f)*255/63,(aColor64K&0x1f)*255/31);
+	}
+
+TRgb TRgb::Color16M(long int aColor16M)
+	{
+	return TRgb(((aColor16M>>16)&0xff),(aColor16M>>8)&0xff,aColor16M&0xff);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/src/statcomms.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,154 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include "stdafx.h"
+#include "STATComms.h"
+#include "statserial.h"
+#include "statsocket_block.h"
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Constructor
+STATComms::STATComms()
+: pTransport(NULL)
+{
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Destructor
+STATComms::~STATComms()
+{
+	if (pTransport)
+	{
+		pTransport->Disconnect();
+		pTransport->Release();
+
+		delete pTransport; 
+		pTransport = NULL;
+	}
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// 
+int STATComms::SetTransport(const STATCONNECTTYPE eConnect)
+{
+	// additional transports may be added here as needed...
+	switch(eConnect)
+	{
+		case SymbianSocket:
+			pTransport = new CSTATSocket;
+			break;
+		case SymbianSerial:
+			pTransport = new CSTATSerial(eConnect);
+			break;
+		case SymbianInfrared:
+			pTransport = new CSTATSerial(eConnect);
+			break;
+		case SymbianBluetooth:
+			pTransport = new CSTATSerial(eConnect);
+			break;
+		case SymbianUsb:
+			pTransport = NULL;
+			break;
+	};
+
+	if (!pTransport)
+ 		return E_OUTOFMEMNOTSUPPORTED;
+
+	return ITS_OK;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Initialise
+int STATComms::Initialise(void)
+{
+	if (!pTransport)
+ 		return E_OUTOFMEMNOTSUPPORTED;
+
+	return pTransport->Initialise();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Connect
+int STATComms::Connect(const char *pAddress)
+{
+	if (!pTransport)
+ 		return E_OUTOFMEMNOTSUPPORTED;
+
+	return pTransport->Connect(pAddress);
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Send
+int STATComms::Send(const char cIdentifier, const char *pData, const unsigned long ulLength)
+{
+	if (!pTransport)
+ 		return E_OUTOFMEMNOTSUPPORTED;
+
+	return pTransport->Send(cIdentifier, pData, ulLength);
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Receive
+int STATComms::Receive(char *cIdentifier, char **ppData, unsigned long *pLength)
+{
+	if (!pTransport)
+ 		return E_OUTOFMEMNOTSUPPORTED;
+
+	return pTransport->Receive(cIdentifier, ppData, pLength);
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Disconnect
+int STATComms::Disconnect(void)
+{
+	if (!pTransport)
+ 		return E_OUTOFMEMNOTSUPPORTED;
+
+	return pTransport->Disconnect();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Release
+int STATComms::Release(void)
+{
+	if (!pTransport)
+ 		return E_OUTOFMEMNOTSUPPORTED;
+
+	return pTransport->Release();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Return error text
+char * STATComms::Error(void)
+{
+	if (!pTransport)
+ 		return NULL;
+
+	return pTransport->Error();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/src/statengine.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,1580 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include "stdafx.h"
+#include "STATEngine.h"
+#include "STATCommon.h"
+#include "INI.h"
+
+#include <string>
+
+//----------------------------------------------------------------------------
+// Constructor
+CSTATEngine::CSTATEngine()
+: pImageVerify(NULL), pConverter(NULL), pComms(NULL), pDecoder(NULL), pLog(NULL),
+  minimumdelay(100), maximumdelay(30000), eStopProcessing(STAT_RUN), iCurrentCommand(0), bMultithreaded(false),
+  eConnectType(SymbianInvalid), pDeviceInfo(NULL), iDeviceCode(0), iMaxTimeLimit(STAT_MAXTIME), dataSocket(NULL), settingSocket(true), iTEFSharedData(NULL)
+{	
+	memset(&szAddress, 0, sizeof(szAddress));
+	statIniFile.SetIniFileName(STAT_INI_NAME);
+}
+
+
+//----------------------------------------------------------------------------
+// Destructor
+CSTATEngine::~CSTATEngine()
+{
+	Release();
+}
+
+
+//----------------------------------------------------------------------------
+// Set things up
+int
+CSTATEngine::Initialise(const STATCONNECTTYPE eConnect, const char *pAddress)
+{
+	iDelay = minimumdelay;
+
+
+
+
+	// logging - should be the first to be created for all other classes that depend on it
+	pLog = new CSTATLogFile;
+ 	if (!pLog)
+ 		return E_OUTOFMEM;
+
+	int ret = SetScreenshotDefaultDirectory();
+	if (ret != ITS_OK)
+		return ret;
+
+	// image verification
+ 	pImageVerify = new CSTATImageVerify(pLog);
+ 	if (!pImageVerify)
+ 		return E_OUTOFMEM;
+
+	// bitmap conversion
+	pConverter = new CSTATDataFormatConverter(pLog);
+ 	if (!pConverter)
+ 		return E_OUTOFMEM;
+
+	// script decoder
+	pDecoder = new CSTATScriptDecoder(pLog);
+ 	if (!pDecoder)
+ 		return E_OUTOFMEM;
+
+	// communications
+	pComms = new STATComms();
+ 	if (!pComms)
+ 		return E_OUTOFMEM;
+	else
+	{
+		EnterCriticalSection(&CriticalSection);
+
+		ret = pComms->SetTransport(eConnect);
+		if (ret == ITS_OK)
+		{
+			ret = pComms->Initialise();
+
+			if (ret == ITS_OK)
+				ret = pComms->Connect(pAddress);
+
+			if (ret == ITS_OK)
+			{
+				strcpy(szAddress, pAddress);	// save port in case of restart after error
+				eConnectType = eConnect;
+			}
+		}
+
+		LeaveCriticalSection(&CriticalSection);
+	}
+	return ret;
+}
+
+
+
+//----------------------------------------------------------------------------
+// Release resources
+int
+CSTATEngine::Release(void)
+{
+	if (pImageVerify)
+	{
+		delete pImageVerify;
+		pImageVerify = NULL;
+	}
+
+	if (pConverter)
+	{
+		delete pConverter;
+		pConverter = NULL;
+	}
+
+	if (pDecoder)
+	{
+		delete pDecoder;
+		pDecoder = NULL;
+	}
+
+	if (pDeviceInfo)
+	{
+		delete [] pDeviceInfo;
+		pDeviceInfo = NULL;
+	}
+
+	if (iTEFSharedData)
+	{
+		delete [] iTEFSharedData;
+		iTEFSharedData = NULL;
+	}
+	
+	EnterCriticalSection(&CriticalSection);
+
+	if (pComms)
+	{
+		delete pComms;
+		pComms = NULL;
+	}
+
+	// release this one last in case other objects are using it...
+	if (pLog)
+	{
+		pLog->CloseLogFile();
+		delete pLog;
+		pLog = NULL;
+	}
+
+	LeaveCriticalSection(&CriticalSection);
+	return ITS_OK;
+}
+
+
+//----------------------------------------------------------------------------
+// Sets up log file
+int
+CSTATEngine::SetLogging(const CString& logfilename, const char* prefix, bool append, bool bMessages, bool bFile,
+	MessageReporter *const aMessageReporter)
+{
+	EnterCriticalSection(&CriticalSection);
+	//set default logging path
+	CString defaultDirectory=STAT_LOGFILEPATH_VALUE;
+	//read from inifile if entry exists
+	if(statIniFile.SectionExists(ST_TEST_KEY) )
+	{
+		CString setting;
+		setting.Empty();
+		setting=statIniFile.GetKeyValue(ST_LOGFILEPATH,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+			defaultDirectory = setting;
+	}
+	int ret = pLog->CreateLogFile(logfilename,defaultDirectory, prefix, append, bMessages, bFile);
+
+	pLog->SetMessageReporter(aMessageReporter);
+
+	// in case our transport was initialised before logging was
+	// display the initialisation message if there is one
+	if (ret == LOG_FILE_OK)
+		Message(pComms->Error());
+
+	LeaveCriticalSection(&CriticalSection);
+	return ret;
+}
+
+
+//----------------------------------------------------------------------------
+// Sets up log file
+void
+CSTATEngine::SetCommandDelay(int iMillisecondDelay)
+{
+	iDelay = iMillisecondDelay;
+
+	// set some limits
+	if (iDelay < 100)
+		iDelay = minimumdelay;
+
+	if (iDelay > 30000)
+		iDelay = maximumdelay;
+}
+
+
+//----------------------------------------------------------------------------
+// Open, read and count the amount of commands on this script
+int
+CSTATEngine::GetCommandCount(CString file, int *pCount)
+{
+	EnterCriticalSection(&CriticalSection);
+
+	int ret = pDecoder->Initialise(file, true);
+	if (ret != ITS_OK)
+		ret = pDecoder->Initialise(file, false);
+
+	if (ret == ITS_OK)
+	{
+		CSTATScriptCommand *pSendCommand;
+		int iCount = 0;
+		
+		// get a command from the script
+		while (pDecoder->GetNextCommand(&pSendCommand) && ret == ITS_OK)
+		{
+			iCount++;
+			if (pSendCommand->cCommandID == STAT_END)
+				break;
+		}
+
+		// set the count
+		if (ret == ITS_OK)
+			(*pCount) = iCount;
+	}
+
+	pDecoder->Release();
+
+	LeaveCriticalSection(&CriticalSection);
+	return ret;
+}
+
+
+//----------------------------------------------------------------------------
+// Open and read a script file's contents
+int
+CSTATEngine::OpenScriptFile(CString file, bool bIsFile)
+{
+	EnterCriticalSection(&CriticalSection);
+
+	int ret = pDecoder->Initialise(file, bIsFile);
+
+	LeaveCriticalSection(&CriticalSection);
+	return ret;
+}
+
+
+//----------------------------------------------------------------------------
+// Execute a script file
+int
+CSTATEngine::RunScript(ScriptProgressMonitor *const monitor)
+{
+	int ret = ITS_OK;
+	iCurrentCommand = 0;
+	eStopProcessing = STAT_RUN;
+	iDeviceCode = 0;
+
+	// anything smaller can cause problems and doesn't make sense anyway!
+	if (iMaxTimeLimit < 1000)
+		iMaxTimeLimit = 1000;
+
+	// pointers to our command structures
+	CSTATScriptCommand *pSendCommand;
+	CSTATScriptCommand *pRecvCommand;
+
+	char lastCommand = NULL;
+
+	receivedData.Empty( );
+	
+	
+
+	// get a command from the script
+	while (pDecoder->GetNextCommand(&pSendCommand) && ret == ITS_OK)
+	{
+		iCurrentCommand++;
+
+		if (StopProcessing())
+		{
+			pComms->Send(STAT_RESYNCID);
+			ret = E_USERCANCEL;
+			break;
+		}
+
+		if (lastCommand == STAT_REBOOT)
+		{
+			ret = ITS_OK;
+			break;
+		}
+
+		switch(pSendCommand->cCommandID)
+		{
+			case 'P':
+				Message(pSendCommand->Command());
+				Sleep(atol(pSendCommand->Command()));
+				break;
+			case '/':
+				Message(pSendCommand->Command());
+				break;
+			case '#':
+				{
+					Message(pSendCommand->Command());
+					cScreenshotDirectory = pSendCommand->Command();
+					if(cScreenshotDirectory.Right(1) != _T("\\"))
+						cScreenshotDirectory += _T("\\");
+					CreateAllDirectories(cScreenshotDirectory);
+				}
+				break;
+			
+			default:
+				{
+
+					// send the command and retrieve a response
+					int iResyncErrors = 0;
+					while ((ret = SendCommand(pSendCommand, &pRecvCommand)) == E_RESYNCCOMMAND)
+					{
+						Sleep(STAT_RETRYDELAY);
+						iResyncErrors++;
+						if (iResyncErrors > STAT_MAXERRORS)
+						{
+							Message("Too many resync errors - stopping");
+							ret = E_COMMANDFAILED;
+							break;
+						}
+						
+					}
+
+					if (ret == ITS_OK)
+					{
+						// perform special operations for these commands
+						switch(pSendCommand->cCommandID)
+						{
+							case 'D':
+								StoreData(pRecvCommand->Command(), pRecvCommand->Length(), pDeviceInfo);
+								AppendCommandToSTATLog("*** DEVICE INFORMATION ***", pRecvCommand->Command(), pRecvCommand->Length());
+								break;
+							case 'S':
+							{
+								// convert and save the data returned in the response
+								CString image = pSendCommand->Command();
+								ret = ConvertAndSaveScreeenshot(image, pRecvCommand->Command(), pRecvCommand->Length());
+
+								// imave verification
+								if (ret == ITS_OK)
+								{
+									if (pImageVerify->IsActive() && pConverter->bWriteToFile)
+									{
+										ret = pImageVerify->VerifyImage(image);
+										if (ret == VERIFICATION_PASS)
+											ret = ITS_OK;
+									}
+								}
+								break;
+							}
+						
+							case 'T':
+							{
+								
+								if(dataSocket==NULL)
+								{
+
+									// filename has been sent, now send the file itself
+									CSTATScriptCommand oSendCommand;
+									oSendCommand.cCommandID = pRecvCommand->cCommandID;
+									
+										// read and send the file contents
+									if ((ret = ReadTransferFile(pSendCommand->Command(), &oSendCommand)) == ITS_OK)
+									{
+										int iResyncErrors = 0;
+										while ((ret = SendCommand(&oSendCommand, &pRecvCommand)) == E_RESYNCCOMMAND)
+										{
+											Sleep(STAT_RETRYDELAY);
+											iResyncErrors++;
+											if (iResyncErrors > STAT_MAXERRORS)
+											{
+												Message("Too many resync errors - stopping");
+												ret = E_COMMANDFAILED;
+												break;
+											}
+										}
+									}
+									
+								}
+								else
+								{
+									//release the socket
+									ret = ReleaseSocket();
+									
+								}
+								
+
+								break;
+							}
+							case 'R':
+							case 'X':
+							{	
+								if(dataSocket==NULL)
+								{
+									// save the file contents
+									ret = SaveTransferFile(pSendCommand->Command(), pRecvCommand->Command(), pRecvCommand->Length());
+								}
+								else
+								{
+									//release the socket
+									ret = ReleaseSocket();
+								}
+								break;
+							}
+							case 'G':
+							{
+								// upload the device log file and write to STAT log file
+								AppendCommandToSTATLog("*** DEVICE LOG ***", pRecvCommand->Command(), pRecvCommand->Length());
+								break;
+							}
+							case STAT_REFRESH:
+							case STAT_END:
+							{
+								ret = END_SCRIPT;
+								break;
+							}
+							case 'N':
+							{
+								// Retrieve the TEF shared data
+								StoreData(pRecvCommand->Command(), pRecvCommand->Length(), iTEFSharedData);
+								AppendCommandToSTATLog("*** RETRIEVE TEF SHARED DATA ***", pRecvCommand->Command(), pRecvCommand->Length());
+							}
+							break;
+							default:
+							{
+								Sleep(iDelay);
+								break;
+							}
+						}
+					}
+
+					if (ret == ITS_OK)
+					{
+						// Data received from certain of the commands is stored
+						// for retreival later.
+						switch(pSendCommand->cCommandID)
+						{
+							case 'W':
+							case 'V':
+							//execute returns pid
+							case 'J':
+							//poll returns 0 1
+							case '3':
+								receivedData += oRecvCommand.Command();
+								break;
+							default:
+								break;
+						}
+					}
+				}
+				break;
+		}
+
+		lastCommand = pSendCommand->cCommandID;
+
+		if(monitor)
+		{
+			monitor->OnCompleteCommand( iCurrentCommand );
+		}
+	}
+
+	pDecoder->Release();
+
+	return ret;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Converts a char * to it's Unicode equivalent
+//
+LPTSTR
+CSTATEngine::ToUnicode(const char *string)
+{
+#ifdef UNICODE
+	static TCHAR szBuffer[MAX_UNICODE_LEN + 1] = {0};
+	szBuffer[0] = (TCHAR)0;
+
+    // Convert to UNICODE.
+    if (!MultiByteToWideChar(CP_ACP,					// conversion type
+							 0,							// flags
+							 string,					// source
+							 -1,						// length
+							 szBuffer,					// dest
+							 MAX_UNICODE_LEN))			// length
+    {
+        return _T("Could not convert");
+    }
+    return szBuffer;
+#else
+	return (LPTSTR)string;
+#endif
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Converts a Unicode to it's char * equivalent
+//
+char *
+CSTATEngine::ToAnsi(LPCTSTR string)
+{
+#ifdef UNICODE
+	static char szBuffer[MAX_UNICODE_LEN + 1] = {0};
+	szBuffer[0] = (char)0;
+
+    // Convert to ANSI.
+    if (!WideCharToMultiByte(CP_ACP,					// conversion type
+							 0,							// flags
+							 string,					// source
+							 -1,						// length
+							 szBuffer,					// dest
+							 MAX_UNICODE_LEN,			// length
+							 NULL,
+							 NULL ))
+    {
+        return "Could not convert";
+    }
+    return szBuffer;
+#else
+	return (char *)string;
+#endif
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// PRIVATE METHODS
+//////////////////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// sets screenshot image directory
+int CSTATEngine::SetScreenshotDefaultDirectory(void)
+{
+	//Set default logfile path
+	CString path = ST_LOGFILEPATH_VALUE;
+	//read from inifile if entry exists
+	if(statIniFile.SectionExists(ST_TEST_KEY) )
+	{
+		CString setting;
+		setting.Empty();
+		setting=statIniFile.GetKeyValue(ST_LOGFILEPATH,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+			path = setting;
+	}
+
+	
+	cScreenshotDirectory = path;
+
+	// add a backslash
+	if (cScreenshotDirectory.Right(1) != _T('\\'))
+		cScreenshotDirectory += _T('\\');
+
+	cScreenshotDirectory += _T("Images\\");
+
+	return ITS_OK;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////
+// Execute a complete command
+//
+// Sends a command, breaking it up into separate commands if required
+//
+// When sending, if larger than our buffer , break it up into correctly sized
+// pieces and send these.  The first will be an empty one containing the total
+// size, followed by buffer-sized pieces.  The last will be an empty command.
+//
+
+//////////////////////////////////////////////////////////////////////////////////////
+int CSTATEngine::SendCommand(CSTATScriptCommand *pSendCommand, CSTATScriptCommand **ppRecvCommand)
+{
+	int ret = GENERAL_FAILURE;
+	CSTATScriptCommand tempCommand;
+	tempCommand.cCommandID = pSendCommand->cCommandID;
+
+
+	// the first instance of a 'R' or 'T' command, it could set a data socket instead of a file
+	if(pSendCommand->cCommandID=='T' || pSendCommand->cCommandID=='R')
+	{
+		if(dataSocket==NULL && settingSocket && pSendCommand->Command()!=NULL)
+		{
+
+			char *comma = strchr(pSendCommand->Command(),',');
+			
+			if(!(comma > pSendCommand->Command() + pSendCommand->Length()))
+			{
+	
+				switch(pSendCommand->cCommandID)
+				{
+				case 'R':
+					{
+						char *colon = strchr(comma,':');
+						
+						if(colon==NULL)
+							break;
+	
+						comma += 1;
+						std::string ipAdd( comma, colon - comma );
+						colon += 1;
+						std::string ipPort( colon );
+	
+						ret = SetSocket(ipAdd.c_str() , atoi( ipPort.c_str() ));
+
+						if(ret!=ITS_OK)
+						{
+							return ret;
+						}
+	
+						break;
+					}
+	
+				case 'T':
+					{
+						char *colon = strchr( pSendCommand->Command() , ':' );
+	
+						if(colon==NULL)
+							break;
+	
+						std::string ipAdd( pSendCommand->Command() , colon - pSendCommand->Command() );
+						colon += 1;
+						
+						if(comma < colon)
+							break;
+	
+						std::string ipPort( colon , comma - colon );
+	
+						ret = SetSocket(ipAdd.c_str() , atoi(ipPort.c_str()));
+						
+						if(ret!=ITS_OK)
+						{
+							return ret;
+						}
+
+						break;
+					}
+				}
+			}
+		}
+
+		settingSocket=false;
+	}
+	
+	
+	
+	// send the first command
+	if ((ret = SendSingleCommand(pSendCommand, ppRecvCommand)) == ITS_OK)
+	{
+		// check our response - if Serial/Infra-red, need to break it down
+		if (pComms->GetMaxPacketSize() != 0)
+		{
+
+			
+			// break up the command into buffer-sized chunks
+			if (pSendCommand->Length() > pComms->GetMaxPacketSize() || (dataSocket!=NULL && pSendCommand->cCommandID=='T'))
+			{
+				int i = 0;
+				unsigned long offset = 0;
+				unsigned long ulTotalWritten = 0;
+				unsigned long AmountToWrite = pComms->GetMaxPacketSize();
+				unsigned long OriginalLength = pSendCommand->Length();
+				
+				if(dataSocket==NULL)
+				{
+					
+					int iWrites = pSendCommand->Length() / pComms->GetMaxPacketSize() + 1;
+
+					Message("Writing %d bytes of data in %d separate writes...", OriginalLength, iWrites);
+					for (i=0;i<iWrites;i++)
+					{
+						offset = i * pComms->GetMaxPacketSize();
+
+						if ((pSendCommand->Length() - offset) < pComms->GetMaxPacketSize())
+							AmountToWrite = (pSendCommand->Length() - offset);
+
+						if (AmountToWrite)
+						{
+							//Sleep(100);		// pause a bit for slower machines - probably doesn't need it but it can't hurt...
+
+							// now send the command
+							Message("Writing %d bytes from offset %d", AmountToWrite, offset);
+							tempCommand.SetData(pSendCommand->Command() + ulTotalWritten, AmountToWrite);
+							if ((ret = SendSingleCommand(&tempCommand, ppRecvCommand)) == ITS_OK)
+							{
+								//Message("%d bytes successfully written", AmountToWrite);
+							}
+							else
+								return ret;
+
+							ulTotalWritten += AmountToWrite;
+						}
+					}
+					
+				}
+				else
+				{
+
+					//uses socket transmission
+
+					char *pData = new char[AmountToWrite];
+					
+					tempCommand.ulLength = (unsigned long) -1;
+					
+					if((ret = SendSingleCommand(&tempCommand, ppRecvCommand)) != ITS_OK)
+					{	
+						delete [] pData;
+						return ret;
+					}
+
+					while(true){
+
+
+						int AmountToWrite = pComms->GetMaxPacketSize();
+						
+						ReadFromSocket(pData, &AmountToWrite );
+											
+						if(AmountToWrite>=0)
+						{
+							Message("Writing %d bytes", AmountToWrite);
+							tempCommand.SetData(pData , AmountToWrite);
+						
+							if ((ret = SendSingleCommand(&tempCommand, ppRecvCommand)) == ITS_OK)
+							{
+							//Message("%d bytes successfully written", AmountToWrite);
+							}
+							else
+							{
+								settingSocket=true;
+								delete [] pData;
+								return ret;
+							}
+
+							ulTotalWritten +=AmountToWrite;
+						}
+						else
+						{
+							eStopProcessing = STAT_PAUSE;
+							break;
+						}
+						
+						if(AmountToWrite==0)
+						{
+							break;
+						}
+						
+					}
+
+					delete [] pData;
+				
+				}
+			
+				// once completely sent, send an empty command to show that we've finished
+				
+				
+				if(dataSocket == NULL )
+				{
+					if (ulTotalWritten == OriginalLength)
+					{
+						// send the command that signals the end of our transmission
+						Message("Sending completion command %c", tempCommand.cCommandID);
+						tempCommand.SetData(NULL, 0);
+						if ((ret = SendSingleCommand(&tempCommand, ppRecvCommand)) == ITS_OK)
+						{
+							//Message("Completion command successfully written");
+						}
+					}
+					else
+					{
+						Message("Incorrect number of bytes written - expected %ld got %ld", ulTotalWritten, OriginalLength);
+						ret = E_BADNUMBERBYTES;
+					}
+				}
+			}
+		}
+	}
+
+	if (ret == ITS_OK)
+	{
+		// check our response - if Serial/Infra-red, need to break it down
+		// if < STAT_BUFFERSIZE, nothing more to do
+		// if not, we need to read in as many times as it takes to
+		// assemble our complete command response
+		if (pComms->GetMaxPacketSize() != 0)
+		{
+			if (ppRecvCommand && (*ppRecvCommand)->Length() > pComms->GetMaxPacketSize())
+			{
+				unsigned long TotalLength = (*ppRecvCommand)->Length();
+
+				Message("%s: About to read %d bytes of data", GetConnection(eConnectType), TotalLength);
+
+				// allocate memory to hold entire command
+				char *pTemp = new char [TotalLength];
+				if (pTemp)
+				{
+					unsigned long ulTotalRead = 0;
+
+					// empty packets
+					tempCommand.SetData(NULL, 0);
+
+					// now read data until we get an empty packet
+					while((*ppRecvCommand)->Length())
+					{
+						//Sleep(100);		// pause a bit for slower machines - probably doesn't need it but it can't hurt...
+
+						//Message("Sending continuation command %c", tempCommand.cCommandID);
+						if ((ret = SendSingleCommand(&tempCommand, ppRecvCommand)) == ITS_OK)
+						{
+							if ((*ppRecvCommand)->Length())
+							{
+								Message("%s to offset %d", pComms->Error(), ulTotalRead);
+								
+								//copy the data into the buffer
+								memcpy(pTemp + ulTotalRead, (*ppRecvCommand)->Command(), (*ppRecvCommand)->Length());
+								
+								if(dataSocket!=NULL)
+								{
+									int bytesSent = (int)(*ppRecvCommand)->Length();
+								
+									WriteToSocket((*ppRecvCommand)->Command() , &bytesSent);
+									
+									if(bytesSent <= 0)
+									{
+										eStopProcessing = STAT_PAUSE;
+									}
+								}
+								
+								
+
+								//increment the pointer to the end of the first chunk received
+								ulTotalRead += (*ppRecvCommand)->Length();
+							}
+						}
+						else
+						{
+							settingSocket=true;
+							delete [] pTemp;
+							return ret;
+						}
+					}
+
+					// make sure we got what we expected
+					if (ulTotalRead == TotalLength)
+					{
+						// set our final response to the complete data transmission
+						(*ppRecvCommand)->SetData(pTemp, ulTotalRead);
+						//Message("Received successfully %ld bytes", ulTotalRead);
+					}
+					else
+					{
+						Message("Incorrect number of bytes read - expected %ld got %ld", ulTotalRead, TotalLength);
+						ret = E_BADNUMBERBYTES;
+					}
+
+					// finished with it
+					delete [] pTemp;
+				}
+				else
+				{
+					Message("Could not allocate %d bytes of memory", TotalLength);
+					ret = E_OUTOFMEM;
+				}
+			}
+			else if(dataSocket!=NULL && pSendCommand->cCommandID=='R')
+			{
+				int bytesSent = (int)(*ppRecvCommand)->Length();
+				WriteToSocket((*ppRecvCommand)->Command(), &bytesSent);
+			}
+		}
+	}
+
+	
+
+	return ret;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+// Execute a single command
+//
+// Once the command is sent, wait for a response.  If received and of the correct
+// ID, save the contents (if any) and quit.  If no response, send RESYNC commands
+// every few seconds to get response from other end.  On receipt of a RESYNC
+// command, resend the previous command.  After no response for a minute or so, quit.
+//////////////////////////////////////////////////////////////////////////////////////
+int CSTATEngine::SendSingleCommand(CSTATScriptCommand *pSendCommand, CSTATScriptCommand **ppRecvCommand)
+{
+	int iTotalCommandTime = 0;
+	int ret = GENERAL_FAILURE;
+
+	LogDetails("Send", pSendCommand);
+
+	// send the command
+	EnterCriticalSection(&CriticalSection);
+	ret = pComms->Send(pSendCommand->cCommandID, pSendCommand->Command(), pSendCommand->Length());
+	LeaveCriticalSection(&CriticalSection);
+	if (ret != ITS_OK)
+	{
+		Message(pComms->Error());
+		return ret;
+	}
+
+	// The refresh command will not return anything due to the transport getting restarted.
+	// So, don't wait for a response.
+	if( (ret == ITS_OK) && (pSendCommand->cCommandID == STAT_REFRESH || pSendCommand->cCommandID == STAT_REBOOT)  )
+	{
+		return ret;
+	}
+
+	// wait for a response
+	unsigned long ulLength = 0;
+	char *pData = NULL;
+	while(iTotalCommandTime < iMaxTimeLimit)
+	{
+		if (StopProcessing())
+		{
+			pComms->Send(STAT_RESYNCID);
+			ret = E_USERCANCEL;
+			break;
+		}
+
+		EnterCriticalSection(&CriticalSection);
+		ret = pComms->Receive(&oRecvCommand.cCommandID, &pData, &ulLength);
+		LeaveCriticalSection(&CriticalSection);
+		
+		if (ret == ITS_OK)
+		{
+			if (oRecvCommand.SetData(pData, ulLength))
+			{
+				oRecvCommand.ulLength = ulLength;
+				*ppRecvCommand = &oRecvCommand;
+
+				// invalid response received
+				if (pSendCommand->cCommandID != oRecvCommand.cCommandID)
+				{
+					// need to resync back to start of this command
+					if (oRecvCommand.cCommandID == STAT_RESYNCID)
+					{
+						Message("RESYNC response received - retrying command...");
+						ret = E_RESYNCCOMMAND;
+					}
+					else
+					{
+						if (oRecvCommand.cCommandID == STAT_FAILURE)
+						{
+							if (oRecvCommand.Command() && oRecvCommand.Length())
+							{
+								Message("Command failed with error code %s",
+										oRecvCommand.Command());
+								iDeviceCode = atoi(oRecvCommand.Command());
+							}
+						}
+						else
+							Message("Invalid response received - expected %c received %c",
+									pSendCommand->cCommandID, oRecvCommand.cCommandID);
+						ret = GENERAL_FAILURE;
+					}
+				}
+				else
+					LogDetails("Receive", *ppRecvCommand);
+			}
+			else
+				ret = E_OUTOFMEM;
+
+			// at this point we have received something whether it's what we were expecting or not so exit loop
+			break;
+		}
+		else if (ret == NO_DATA_AT_PORT)
+		{
+//			Message("Waiting for response");
+			Sleep(STAT_RETRYDELAY);
+			iTotalCommandTime += STAT_RETRYDELAY;
+			ret = E_TOOMUCHTIME;
+		}
+		else
+		{
+			Message(pComms->Error());
+			break;
+		}
+	}
+
+	return ret;
+}
+
+
+//----------------------------------------------------------------------------
+// Write command details to log
+void CSTATEngine::LogDetails(const char *prefix, CSTATScriptCommand *pCommand)
+{
+	if (pCommand->Length() && (pCommand->Length() < MAX_LOG_MSG_LEN) && 
+		pCommand->cCommandID != 'D' && pCommand->cCommandID != 'T' && pCommand->cCommandID != 'R' && pCommand->cCommandID != 'X' && pCommand->cCommandID != 'G')
+	{
+		char szContents[MAX_LOG_MSG_LEN + 1];
+		unsigned long actuallen = MAX_LOG_MSG_LEN - 30 - strlen(prefix) - 6;  // max actual message length
+		if (pCommand->Length() < actuallen)
+			actuallen = pCommand->Length();
+
+		strncpy(szContents, pCommand->Command(), actuallen);
+		*(szContents + actuallen) = (char)0;
+		Message("%s: ID: %c Contents: [%s] Length: [%lu]", prefix, pCommand->cCommandID, szContents, pCommand->Length());
+	}
+	else
+		Message("%s: ID: %c Length: [%lu]", prefix, pCommand->cCommandID, pCommand->Length());
+}
+
+
+//----------------------------------------------------------------------------
+// Read in a file's contents
+//
+// pFile will contain "pc path,device path" of which we want the 'pc path' part
+int CSTATEngine::ReadTransferFile(const char *pFile, CSTATScriptCommand *pCommand)
+{
+	int ret = E_BADFILENAME;
+
+	// get the default file location
+	CString path = ST_WORKINGPATH_VALUE;
+	//read from inifile if entry exists
+	if(statIniFile.SectionExists(ST_TEST_KEY) )
+	{
+		CString setting;
+		setting.Empty();
+		setting=statIniFile.GetKeyValue(ST_WORKINGPATH,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+			path = setting;
+	}
+
+	// add a backslash
+	if (path.Right(1) != _T('\\'))
+		path += _T('\\');
+
+	// get the name of the file
+	CString filename = pFile;
+	int index = filename.ReverseFind(_T(','));
+	if (index == -1)
+		return E_BADFILENAME;
+
+	// add the name
+	path += filename.Left(index);
+
+	Message("Opening file [%s]", ToAnsi(path));
+
+	EnterCriticalSection(&CriticalSection);
+
+	CFile script_file;
+	if (script_file.Open(path, CFile::modeRead))
+	{
+		try
+		{
+			char *pData = new char [script_file.GetLength()];
+			if (pData)
+			{
+				script_file.Read(pData, script_file.GetLength());
+
+				if(pCommand->SetData(pData, script_file.GetLength()))
+					ret = ITS_OK;
+				else
+					ret = E_OUTOFMEM;
+
+				delete [] pData;
+			}
+			else
+				ret = E_OUTOFMEM;
+		}
+		catch(CFileException *e)
+		{
+			e->Delete();
+			ret = GENERAL_FAILURE;
+		}
+
+		script_file.Abort();
+	}
+
+	LeaveCriticalSection(&CriticalSection);
+	return ret;
+}
+
+
+
+
+
+
+
+//----------------------------------------------------------------------------
+// Save a data stream to file
+//
+// pFile will contain "device path,pc folder" of which we want the 'pc folder' part
+int CSTATEngine::SaveTransferFile(const char *pFile, char *pContents, unsigned long ulLength)
+{
+	int ret = E_BADFILENAME;
+
+	CString path = ST_WORKINGPATH_VALUE;
+	//read from inifile if entry exists
+	if(statIniFile.SectionExists(ST_TEST_KEY) )
+	{
+		CString setting;
+		setting.Empty();
+		setting=statIniFile.GetKeyValue(ST_WORKINGPATH,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+			path = setting;
+	}
+	// add a backslash
+	if (path.Right(1) != _T('\\'))
+		path += _T('\\');
+
+	// get any additional sub folders
+	CString folder = pFile;
+	int index = folder.Find(_T(','));
+	if (index == -1)
+		return E_BADFILENAME;
+	// if the comma is the last char there are no folders to add
+	if (folder.Right(1) != _T(','))
+	{
+		path += folder.Mid(index + 1);
+
+		// add a backslash
+		if (path.Right(1) != _T('\\'))
+			path += _T('\\');
+	}
+
+	if (bMultithreaded)
+	{
+		// add a sub-folder for the connection type
+		path += GetConnection(eConnectType);
+		path += _T(".");
+		path += szAddress;
+		path += _T('\\');
+	}
+
+	// now extract the filename from the first argument
+	CString filename = folder.Left(index);
+	index = filename.ReverseFind(_T('\\'));
+	if (index == -1)
+		path += filename;
+	else
+		path += filename.Mid(index + 1);
+
+	Message("Saving file [%s]", ToAnsi(path));
+
+	ret = SaveTheFile(path, pContents, ulLength);
+	if (ret != ITS_OK)
+		Message("Error saving [%s] (%d)", ToAnsi(path), GetLastError());
+	return ret;
+}
+
+
+//----------------------------------------------------------------------------
+// Convert and save a screenshot
+int CSTATEngine::ConvertAndSaveScreeenshot(CString &file, const char *pContents, const unsigned long ulLength)
+{
+	int ret = E_BADFILENAME;
+
+	// clean out any previous mbm files lying around
+	if (!RemoveLeftoverMBMFiles())
+		return E_SCREENSHOT_LEFTOVERFILES;
+
+	// get the destination screenshot name
+	CString destfile = file;
+	if (destfile.IsEmpty())
+	{
+		// construct a filename from date/time
+		char szName[20] = {0};
+		time_t curTime;
+		time (&curTime);
+		strftime (szName, 
+					sizeof (szName),
+					"%Y%m%d%H%M%S",
+					localtime (&curTime));
+
+		destfile = szName;
+	}
+
+	// get the full name of the source image
+	CString SrcPath = cScreenshotDirectory;
+
+	if (bMultithreaded)
+	{
+		// add a sub-folder for the connection type
+		SrcPath += GetConnection(eConnectType);
+		SrcPath += _T(".");
+		SrcPath += szAddress;
+		SrcPath += _T('\\');
+	}
+
+	// attach the filename
+	CString path = SrcPath;
+
+	path += destfile;
+	path += _T(".mbm");
+
+//	Message("Saving screenshot [%s]", ToAnsi(path));
+
+	// save bitmap data to file
+	if ((ret = SaveTheFile(path, pContents, ulLength)) == ITS_OK)
+		ret = pConverter->ConvertScreenShot(SrcPath, SrcPath);
+
+	// save the full path to the converted image
+	if (ret == ITS_OK)
+		file = SrcPath;
+	return ret;
+}
+
+
+//----------------------------------------------------------------------------
+// Save data to file
+int CSTATEngine::SaveTheFile(CString path, const char *pContents, const unsigned long ulLength)
+{
+	int ret = E_BADFILENAME;
+
+	EnterCriticalSection(&CriticalSection);
+
+	// ensure the path exists
+	CreateAllDirectories(path);
+
+	DeleteFile(path);
+
+	CFile script_file;
+	if (script_file.Open(path, CFile::modeCreate | CFile::modeWrite | CFile::shareDenyWrite))
+	{
+		try
+		{
+			// might be a zero-length file
+			if (pContents && ulLength)
+				script_file.Write(pContents, ulLength);
+
+			ret = ITS_OK;
+		}
+		catch(CFileException *e)
+		{
+			e->Delete();
+			ret = GENERAL_FAILURE;
+		}
+
+		script_file.Abort();
+	}
+
+	LeaveCriticalSection(&CriticalSection);
+	return ret;
+}
+
+
+//----------------------------------------------------------------------------
+// Write a message to the log
+void CSTATEngine::Message(const char *pMsg, ...)
+{
+	char szMessage[MAX_LOG_MSG_LEN + 1];
+
+	if (pMsg)
+	{
+		memset(&szMessage, 0, sizeof(szMessage));
+		va_list pCurrent = (va_list)0;
+		va_start (pCurrent, pMsg);
+		vsprintf (szMessage, pMsg, pCurrent);
+		va_end (pCurrent);
+	}
+	else
+		strcpy(szMessage, "No message associated with this error");
+
+	EnterCriticalSection(&CriticalSection);
+	pLog->Set(szMessage);
+	LeaveCriticalSection(&CriticalSection);
+}
+
+//----------------------------------------------------------------------------
+// Try to create all directories within a supplied path
+void CSTATEngine::CreateAllDirectories(CString &fullpath)
+{
+	CString path;
+	int index = fullpath.Find(_T('\\'));
+	while (index != -1)
+	{
+		path = fullpath.Left(index);
+		CreateDirectory(path, NULL);
+
+		index = fullpath.Find(_T('\\'), index + 1);
+	}
+}
+
+//----------------------------------------------------------------------------
+// check if we want to quit
+bool CSTATEngine::StopProcessing()
+{
+	// check if instructed to stop processing (will only happen on Desktop version)
+	if (eStopProcessing == STAT_PAUSE)
+	{
+		eStopProcessing = STAT_STOP;
+		return true;
+	}
+
+	return false;
+}
+
+//----------------------------------------------------------------------------
+//Remove any leftover .mbm files prior to retrieving a screenshot
+bool CSTATEngine::RemoveLeftoverMBMFiles()
+{
+	CFileFind imagefinder;
+	CString imagedir = cScreenshotDirectory;
+	bool valid = true;
+
+	// add the search pattern
+	if (imagedir.Right(1) != _T('\\'))
+		imagedir += _T("\\");
+
+	// now add a folder for the connection type
+	if (bMultithreaded)
+	{
+		imagedir += GetConnection(eConnectType);
+		imagedir += _T(".");
+		imagedir += szAddress;
+		imagedir += _T('\\');
+	}
+
+	imagedir += _T("*.mbm");
+
+//	Message("Searching for [%s]", ToAnsi(imagedir));
+
+	EnterCriticalSection(&CriticalSection);
+
+	// locate files
+	int iLeftFiles = imagefinder.FindFile(imagedir, 0);
+	while (iLeftFiles)
+	{
+		iLeftFiles = imagefinder.FindNextFile();
+//		Message("Deleting file [%s]", ToAnsi(imagefinder.GetFilePath()));
+
+		if (!DeleteFile(imagefinder.GetFilePath()))
+		{
+			valid = false;
+			break;
+		}
+	}
+
+	imagefinder.Close();
+	LeaveCriticalSection(&CriticalSection);
+	return valid;
+}
+
+
+//----------------------------------------------------------------------------
+// Append the device log to the end of the STAT log
+void CSTATEngine::AppendCommandToSTATLog(char *heading, char *log, unsigned long length)
+{
+	if (length && log)
+	{
+		EnterCriticalSection(&CriticalSection);
+		Message(DOTTED_LINE);
+		Message(heading);
+
+		char *start = log;
+		char *eol = log;
+		unsigned long count = 0;
+
+		*(log + length) = (char)0;
+
+		while (count < length - 1)
+		{
+			// find the end of the line
+			while ((count < length - 1) && (*eol != '\r') && (*eol != '\n'))
+			{
+				count++;
+				eol++;
+			}
+
+			// null it
+			if (count < length - 1)
+			{
+				*eol = (char)0;
+				count++;
+				eol++;
+			}
+
+			if (start && *start)
+				Message("%s", start);
+
+			// step over newline
+			while ((count < length - 1) && (*eol == '\r') || (*eol == '\n'))
+			{
+				count++;
+				eol++;
+			}
+
+			if (count < length - 1)
+				start = eol;
+		}
+
+		Message(DOTTED_LINE);
+		LeaveCriticalSection(&CriticalSection);
+	}
+	else
+		Message("No information returned from device");
+}
+
+//----------------------------------------------------------------------------
+// Store some data in a public defined char* pointer
+//  (currently iTEFSharedData and pDeviceInfo)
+void CSTATEngine::StoreData( char* aData, unsigned long aLength, char*& aOutputPtr )
+{
+
+	receivedData.Empty();
+	receivedData = aData;
+
+	if( aOutputPtr )
+	{
+		delete [] aOutputPtr;
+		aOutputPtr = NULL;
+	}
+
+	if( aData && aLength )
+	{
+		aOutputPtr = new char[aLength + 1];
+		if( aOutputPtr )
+		{
+			// skip over leading CR/LF's
+			char *p = aData;
+			while (p && (*p) && (*p == '\r') || (*p == '\n'))
+				p++;
+			strcpy(aOutputPtr, p);
+		}
+	}
+}
+
+//----------------------------------------------------------------------------
+// Translate a connection type to a string
+CString CSTATEngine::GetConnection(STATCONNECTTYPE eConnectType)
+{
+	CString connection;
+
+	switch(eConnectType)
+	{
+	case SymbianSocket:
+		connection = _T("SymbianSocket");
+		break;
+	case SymbianSerial:
+		connection = _T("SymbianSerial");
+		break;
+	case SymbianInfrared:
+		connection = _T("SymbianInfrared");
+		break;
+	case SymbianBluetooth:
+		connection = _T("SymbianBluetooth");
+		break;
+	case SymbianUsb:
+		connection = _T("SymbianUsb");
+		break;
+	default:
+		connection = _T("SymbianInvalid");
+		break;
+	};
+
+	return connection;
+}
+
+
+//----------------------------------------------------------------------------
+//  Sets a data socket to read/write file streams
+//
+int CSTATEngine::SetSocket(const char *ip, const int port)
+{
+
+	//initialise winsock
+	WSAStartup( MAKEWORD(2,2), &wsaData );
+	
+	dataSocket = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
+
+    if ( dataSocket == INVALID_SOCKET ) 
+	{
+        dataSocket=NULL;
+		return E_SOCKETCREATE; 
+    }
+
+	// Connect to a server.
+    sockaddr_in clientService;
+
+    clientService.sin_family = AF_INET;
+    clientService.sin_addr.s_addr = inet_addr( ip );
+    clientService.sin_port = htons( port );
+
+    if ( connect( dataSocket, (SOCKADDR*) &clientService, sizeof(clientService) ) == SOCKET_ERROR) 
+	{
+        ReleaseSocket();
+		return E_SOCKETCONNECT;
+    }
+	else
+	{
+		return ITS_OK;
+	}
+
+
+	
+}
+
+int CSTATEngine::ReleaseSocket()
+{
+	int ret = ITS_OK;
+
+	//release the socket
+	if( closesocket(dataSocket) == SOCKET_ERROR)
+	{
+		ret = E_SOCKETCLOSE;
+	}
+
+
+	//cleanup winsock
+	WSACleanup();
+
+	dataSocket=NULL;
+
+	return ret;
+	
+}
+
+
+//----------------------------------------------------------------------------
+// Read from the board and write to the data socket
+//
+
+void CSTATEngine::WriteToSocket(const char *data, int *length)
+{
+	// Send data.
+   	*length = send( dataSocket, data, *length , 0 );
+}
+
+
+
+//----------------------------------------------------------------------------
+// Read from the data socket and send to the board
+//
+void CSTATEngine::ReadFromSocket(char *data, int *length)
+{
+	int bufferSize = 0xFF;
+
+	if(*length >= bufferSize)
+	{
+	
+		int packetLength = *length;
+		
+		int totalRead = 0;
+		int iterRead = 0;
+
+		// Receive data to fill a packet
+		while(totalRead <= packetLength - bufferSize)
+		{
+			iterRead = recv( dataSocket, data + totalRead, bufferSize, 0 );
+			if(iterRead == 0)
+				break;
+			totalRead += iterRead;
+		}
+
+		*length = totalRead;
+	}
+	else
+	{
+		*length = recv( dataSocket, data, *length, 0 );
+	}
+}
+
+
+
+
+
+
+
+ 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/src/statexp.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,402 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include "stdafx.h"
+#include "statexp.h"
+#include "statlist.h"
+
+//////////////////////////////////////////////////////////////////////////
+// our thread-safe mechanism for list manipulation and back-end processing
+CRITICAL_SECTION CriticalSection;
+//////////////////////////////////////////////////////////////////////////
+
+// get the version
+STAT_EXPORT const char * __cdecl Version()
+{
+	return aList.Version();
+}
+
+// set logging for main STAT connection interface
+STAT_EXPORT int __cdecl SetConnectionLogging(const char *pszLogPath)
+{
+	EnterCriticalSection(&CriticalSection);
+
+	int valid = aList.SetLogging(pszLogPath);
+
+	LeaveCriticalSection(&CriticalSection);
+	return valid;
+}
+
+// set logging for main STAT connection interface
+STAT_EXPORT void __cdecl CloseConnectionLogging()
+{
+	EnterCriticalSection(&CriticalSection);
+
+	aList.StopLogging();
+
+	LeaveCriticalSection(&CriticalSection);
+}
+
+// connect to the remote target
+STAT_EXPORT int __cdecl Connect(const STATCONNECTTYPE iConnectType, const char *pszPlatformType, void *Reserved1, void *Reserved2)
+{
+	EnterCriticalSection(&CriticalSection);
+
+	int valid = false;
+
+	// unused parameters
+	(void)Reserved1;
+	(void)Reserved2;
+
+	if (iConnectType && pszPlatformType && (*pszPlatformType))
+		valid = aList.CreateListMember(iConnectType, pszPlatformType);
+	else
+		strcpy(aList.szErrorText, "Invalid or missing parameter(s)");
+
+	LeaveCriticalSection(&CriticalSection);
+	return valid;
+}
+
+STAT_EXPORT int __cdecl ConnectMT(const STATCONNECTTYPE iConnectType, const char *pszPlatformType)
+{
+	EnterCriticalSection(&CriticalSection);
+
+	int valid = Connect(iConnectType, pszPlatformType);
+	if (valid)
+	{
+		aList.Member(valid)->SetMultithreaded();
+	}
+
+	LeaveCriticalSection(&CriticalSection);
+	return valid;
+}
+
+// set the delay between executed commands
+STAT_EXPORT int __cdecl SetCommandDelay(const int handle, const unsigned int iMillisecondDelay)
+{
+	EnterCriticalSection(&CriticalSection);
+
+	int valid = false;
+
+	if (handle && aList.ListExists())
+		valid = aList.Member(handle)->SetCommandDelay(iMillisecondDelay);
+	else
+		strcpy(aList.szErrorText, "Invalid parameter(s) or connection does not exist");
+
+	LeaveCriticalSection(&CriticalSection);
+	return valid;
+}
+
+// set logging for individual STAT connection command processing
+STAT_EXPORT int __cdecl SetCommandLogging(const int handle,
+						   const char *pszLogPath,
+						   MessageReporter *const aMessageReporter,
+						   const STATLOGLEVEL iLevel,
+					       const bool bAppend,
+						   void* Reserved1,
+						   void* Reserved2)
+{
+	EnterCriticalSection(&CriticalSection);
+
+	int valid = false;
+
+	// unused parameters
+	(void)iLevel;
+	(void)Reserved1;
+	(void)Reserved2;
+
+	if (handle && aList.ListExists())
+		valid = aList.Member(handle)->SetLogging(STATDLLMember::ToUnicode(pszLogPath), bAppend, aMessageReporter);
+	else
+		strcpy(aList.szErrorText, "Invalid handle or connection does not exist");
+
+	LeaveCriticalSection(&CriticalSection);
+	return valid;
+}
+
+// set image verification settings
+STAT_EXPORT int __cdecl SetImageVerification(const int handle, const char * pszRefDir, const bool bRemoveOldImages, const int iFactor)
+{
+	EnterCriticalSection(&CriticalSection);
+
+	int valid = false;
+
+	if (handle && aList.ListExists())
+		valid = aList.Member(handle)->SetImageVerification(STATDLLMember::ToUnicode(pszRefDir), bRemoveOldImages, iFactor);
+	else
+		strcpy(aList.szErrorText, "Invalid parameter(s) or connection does not exist");
+
+	LeaveCriticalSection(&CriticalSection);
+	return valid;
+}
+
+// open a script file within the member
+STAT_EXPORT int __cdecl OpenScriptFile(const int handle, const char *pszText, bool bIsFile)
+{
+	if (handle && aList.ListExists())
+		return aList.Member(handle)->OpenScriptFile(STATDLLMember::ToUnicode(pszText), bIsFile);
+
+	strcpy(aList.szErrorText, "Invalid parameter(s) or connection does not exist");
+	return false;
+}
+
+// run a command in the script engine
+STAT_EXPORT int __cdecl RunScript(const int handle, ScriptProgressMonitor *const monitor)
+{
+	if (handle && aList.ListExists())
+		return aList.Member(handle)->RunScript(monitor);
+
+	strcpy(aList.szErrorText, "Invalid parameter(s) or connection does not exist");
+	return false;
+}
+
+// send a command to the remote target
+STAT_EXPORT int __cdecl SendRawCommand(const int handle, const char *pszText, ScriptProgressMonitor *const monitor)
+{
+	if (handle && aList.ListExists())
+		return aList.Member(handle)->SendRawCommand(STATDLLMember::ToUnicode(pszText), monitor);
+
+	strcpy(aList.szErrorText, "Invalid parameter(s) or connection does not exist");
+	return false;
+}
+
+// send a command to the remote target
+STAT_EXPORT int __cdecl SendCommandFile(const int handle, const char *pszText, ScriptProgressMonitor *const monitor)
+{
+	if (handle && aList.ListExists())
+		return aList.Member(handle)->SendCommandFile(STATDLLMember::ToUnicode(pszText), monitor);
+
+	strcpy(aList.szErrorText, "Invalid parameter(s) or connection does not exist");
+	return false;
+}
+
+// get the number of commands in the current script
+STAT_EXPORT int __cdecl GetCommandCount(const int handle, const char *pszFile, int *commandCount)
+{
+	if (handle && aList.ListExists())
+		return aList.Member(handle)->GetCommandCount(pszFile, commandCount);
+
+	strcpy(aList.szErrorText, "Invalid parameter(s) or connection does not exist");
+	return false;
+}
+
+// get the number of current command
+STAT_EXPORT int __cdecl GetCurrentCommandNumber(const int handle, int *commandNumber)
+{
+	if (handle && aList.ListExists())
+		return aList.Member(handle)->GetCurrentCommandNumber(commandNumber);
+
+	strcpy(aList.szErrorText, "Invalid parameter(s) or connection does not exist");
+	return false;
+}
+
+// get the text received by the last command
+STAT_EXPORT const char* __cdecl GetReceivedData(const int handle)
+{
+	if (handle && aList.ListExists())
+		return aList.Member(handle)->GetReceivedData();
+
+	strcpy(aList.szErrorText, "Invalid parameter(s) or connection does not exist");
+	return NULL;
+}
+
+// stop processing the current command on the remote target
+STAT_EXPORT int __cdecl StopProcessing(int handle)
+{
+	if (handle && aList.ListExists())
+		return aList.Member(handle)->StopProcessing();
+
+	strcpy(aList.szErrorText, "Invalid parameter(s) or connection does not exist");
+	return false;
+}
+
+// get a bitmap snapshot of the remote target
+STAT_EXPORT int __cdecl GetSnapshot(const int handle, TBitmapFileHeader **ppFile, TBitmapInfoHeader **ppBitmap, char **ppData, unsigned long *pSize)
+{
+	if (handle && aList.ListExists())
+		return aList.Member(handle)->GetSnapshot(ppFile, ppBitmap, ppData, pSize);
+
+	strcpy(aList.szErrorText, "Invalid parameter(s) or connection does not exist");
+	return false;
+}
+
+// disconnect from the remote target
+STAT_EXPORT int __cdecl Disconnect(const int handle)
+{
+	EnterCriticalSection(&CriticalSection);
+
+	int valid = false;
+
+	if (handle && aList.ListExists())
+		valid = aList.RemoveListMember(handle);
+	else
+		strcpy(aList.szErrorText, "Invalid handle or connection does not exist");
+
+	LeaveCriticalSection(&CriticalSection);
+	return valid;
+}
+
+// get the last error thrown
+STAT_EXPORT const char * __cdecl GetError(const int handle)
+{
+	if (handle && aList.ListExists())
+		return aList.Member(handle)->GetErrorText();
+
+	return aList.szErrorText;
+}
+
+// get the error text for a particular error code
+STAT_EXPORT const char * __cdecl GetErrorText(const int handle, int errorCode)
+{
+	if (handle && aList.ListExists())
+		return aList.Member(handle)->GetErrorText(errorCode);
+
+	return aList.szErrorText;
+}
+
+// get the TEF Shared Data
+STAT_EXPORT const char * __cdecl GetTEFSharedData(const int handle)
+{
+	if (handle && aList.ListExists())
+		return aList.Member(handle)->GetTEFSharedData();
+
+	return NULL;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////
+// STD CALL ENTRYPOINTS
+///////////////////////////////////////////////////////////////////////////////////////
+
+STAT_EXPORT const char * __stdcall StdVersion()
+{
+	return Version();
+}
+
+STAT_EXPORT const char * __stdcall StdGetError(const int handle)
+{
+	return GetError(handle);
+}
+
+STAT_EXPORT const char * __stdcall StdGetErrorText(const int handle, int errorCode)
+{
+	return GetErrorText(handle, errorCode);
+}
+
+STAT_EXPORT const char * __stdcall StdGetTEFSharedData(const int handle)
+{
+	return GetTEFSharedData(handle);
+}
+
+STAT_EXPORT int __stdcall StdSetConnectionLogging(const char *filename)
+{
+	return (SetConnectionLogging(filename));
+}
+
+STAT_EXPORT void __stdcall StdCloseConnectionLogging()
+{
+	CloseConnectionLogging();
+}
+
+STAT_EXPORT int __stdcall StdConnect(const STATCONNECTTYPE iConnectType, const char *pszPlatformType, void *Reserved1, void *Reserved2)
+{
+	return (Connect(iConnectType, pszPlatformType, Reserved1, Reserved2));
+}
+
+STAT_EXPORT int __stdcall StdConnectMT(const STATCONNECTTYPE iConnectType, const char *pszPlatformType)
+{
+	return (ConnectMT(iConnectType, pszPlatformType));
+}
+
+STAT_EXPORT int __stdcall StdDisconnect(const int handle)
+{
+	return Disconnect(handle);
+}
+
+STAT_EXPORT int __stdcall StdSetCommandDelay(const int handle, const unsigned int iMillisecondDelay)
+{
+	return SetCommandDelay(handle, iMillisecondDelay);
+}
+
+STAT_EXPORT int __stdcall StdSetCommandLogging(const int handle, 
+											const char *pszLogPath,
+											MessageReporter *const aMessageReporter,
+											const STATLOGLEVEL iLevel,
+											const bool bAppend,
+											void* Reserved1,
+											void* Reserved2)
+{ 
+	return SetCommandLogging(handle,
+							pszLogPath,
+							aMessageReporter,
+							iLevel,
+							bAppend,
+							Reserved1,
+							Reserved2);
+}
+
+STAT_EXPORT int __stdcall StdSetImageVerification(const int handle, const char *pszRefDir, const bool bRemoveOldImages, const int iFactor)
+{
+	return SetImageVerification(handle, pszRefDir, bRemoveOldImages, iFactor);
+}
+
+STAT_EXPORT int __stdcall StdOpenScriptFile(const int handle, LPCTSTR pszText, bool bIsFile)
+{
+	return OpenScriptFile(handle, pszText, bIsFile);
+}
+
+STAT_EXPORT int __stdcall StdRunScript(const int handle, ScriptProgressMonitor *const monitor)
+{
+	return RunScript(handle, monitor);
+}
+
+STAT_EXPORT int __stdcall StdSendRawCommand(const int handle, const char *pszText, ScriptProgressMonitor *const monitor)
+{
+	return SendRawCommand(handle, pszText, monitor);
+}
+
+STAT_EXPORT int __stdcall StdSendCommandFile(const int handle, const char *pszFile, ScriptProgressMonitor *const monitor)
+{
+	return SendCommandFile(handle, pszFile, monitor);
+}
+
+STAT_EXPORT int __stdcall StdGetCommandCount(const int handle, const char *pszFile, int *commandCount)
+{
+	return GetCommandCount(handle, pszFile, commandCount);
+}
+
+STAT_EXPORT int __stdcall StdGetCurrentCommandNumber(const int handle, int *commandNumber)
+{
+	return GetCurrentCommandNumber(handle, commandNumber);
+}
+
+STAT_EXPORT const char* __stdcall StdGetReceivedData(const int handle)
+{
+	return GetReceivedData(handle);
+}
+
+STAT_EXPORT int __stdcall StdStopProcessing(int handle)
+{
+	return StopProcessing(handle);
+}
+
+STAT_EXPORT int __stdcall StdGetSnapshot(int handle, TBitmapFileHeader **ppFile, TBitmapInfoHeader **ppBitmap, char **ppData, unsigned long *pSize)
+{
+	return GetSnapshot(handle, ppFile, ppBitmap, ppData, pSize);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/src/statlist.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,249 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include "stdafx.h"
+#include "statlist.h"
+
+////////////////////////////////////////////////////////////////////////////////////////
+// The one and only connection list
+STATDLLList aList;
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Constructor
+STATDLLList::STATDLLList()
+: ListStart(0)
+{
+	InitializeCriticalSection(&CriticalSection);
+
+	memset(szVersion, 0, sizeof(szVersion));
+	sprintf(szVersion, "%s.%s.%s", STAT_VERSION_MAJOR, STAT_VERSION_MINOR, STAT_VERSION_PATCH);
+
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Destructor
+//
+STATDLLList::~STATDLLList()
+{
+	// release list members (passing 0 will return the last member in the list)
+	STATDLLMember* pMember = Member(0);
+	while(pMember)
+	{
+		RemoveListMember((DWORD)pMember);
+		pMember = Member(0);
+	}
+
+	StopLogging();
+	DeleteCriticalSection(&CriticalSection);
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Turns on logging for STAT multiple connection management.
+//
+int
+STATDLLList::SetLogging(const char *path)
+{
+	bool valid = false;
+	if (!oRep.active())
+	{
+		// split path into folder/file
+		char folder[MAX_PATH + 1] = {0};
+		strcpy(folder, path);
+		char *ptr = strrchr(folder, '\\');
+		if (ptr)
+		{
+			char file[MAX_PATH + 1] = {0};
+			strcpy(file, ptr + 1);
+			(*ptr) = (char)0;
+
+			if (*file)
+			{
+				if (oRep.init(STAT_APPNAME, RPT_ALL, RPT_FILE, folder, file))
+				{
+					oRep.dash();
+					oRep.header("%s", STAT_APPNAME);
+					valid = true;
+				}
+				else
+					strcpy(szErrorText, "Connection logging failed (file system error).");
+			}
+			else
+				strcpy(szErrorText, "Connection logging failed (invalid filename).");
+		}
+		else
+			strcpy(szErrorText, "Connection logging failed (invalid path).");
+	}
+	else
+		strcpy(szErrorText, "Connection logging is already initialised.");
+
+	return valid;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Turns off logging
+//
+void
+STATDLLList::StopLogging()
+{
+	if (oRep.active())
+		oRep.kill();
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Open a connection with a new list member
+//
+DWORD
+STATDLLList::CreateListMember(const STATCONNECTTYPE iConnectType, const char *pszPlatformType)
+{
+	bool valid = false;
+
+	(*szErrorText) = (char)0;
+	oRep.info("Creating new list member (%d : %s)...", iConnectType, pszPlatformType);
+
+	STATDLLMember *ptr = new STATDLLMember(iConnectType, pszPlatformType, &oRep);
+	if (ptr)
+	{
+		if (ptr->GetErrorCode() == ITS_OK)
+		{
+			// add to list
+			if (ListStart)
+			{
+				ptr->lPrevConnection = Member(0);				// returns last member in list
+				ptr->lPrevConnection->lNextConnection = ptr;
+				ptr->lNextConnection = NULL;
+			}
+			else
+			{
+				ListStart = ptr;
+			}
+
+//			WalkList();
+
+			oRep.info("Member %ld (%d : %s) created", ptr, iConnectType, pszPlatformType);
+			valid = true;
+		}
+		else
+		{
+			// save the error thrown
+			strcpy(szErrorText, ptr->GetErrorText());
+			delete ptr;
+			ptr = NULL;
+		}
+	}
+
+	if (!ptr || !valid)
+		oRep.error("ERROR: Could not create new member");
+
+	return (DWORD)ptr;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Find and return a member connection
+// If 0 or bad pointer is passed, will return the last position in the list
+// If nothing in list, will return NULL
+//
+STATDLLMember*
+STATDLLList::Member(const DWORD dwHandle)
+{
+	STATDLLMember *current = 0, *next = 0;
+	next = ListStart;
+	while (next)
+	{
+		current = next;
+		if (current == (STATDLLMember *)dwHandle)
+			break;
+
+		next = current->lNextConnection;
+	}
+
+	return current;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Close a member connection
+//
+bool
+STATDLLList::RemoveListMember(const DWORD dwHandle)
+{
+	STATDLLMember *current = Member(dwHandle);
+	oRep.info("Removing list member %ld...", dwHandle);
+	bool valid = false;
+
+	// remove from list
+	if (current)
+	{
+		// something before
+		if (current->lPrevConnection)
+			current->lPrevConnection->lNextConnection = current->lNextConnection;
+		else
+			ListStart = current->lNextConnection;
+
+		// something after
+		if (current->lNextConnection)
+			current->lNextConnection->lPrevConnection = current->lPrevConnection;
+
+		delete current;
+		oRep.info("Member removed");
+
+//		WalkList();
+
+		valid = true;
+	}
+	else
+		oRep.error("ERROR: Could not remove");
+
+	return valid;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Private Methods
+//////////////////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// walks the list for debug purposes
+//
+void
+STATDLLList::WalkList()
+{
+	if (ListStart)
+		oRep.dash();
+
+	STATDLLMember *current = 0, *next = 0;
+	next = ListStart;
+	while (next)
+	{
+		current = next;
+
+		oRep.info("Member details: Previous:%ld this:%ld Next:%ld",
+			current->lPrevConnection, current, current->lNextConnection);
+
+		next = current->lNextConnection;
+	}
+
+	if (ListStart)
+		oRep.dash();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/src/statmember.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,635 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include "stdafx.h"
+#include "statmember.h"
+#include <stdio.h>
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Construct and initialise a STAT object and check it hasn't passed it's expiry date.
+//
+STATDLLMember::STATDLLMember(const STATCONNECTTYPE iConnectType, const char *pszPlatformType, Reporter *theRep)
+: pRep(theRep), 
+  iConnectionType(iConnectType), 
+  iErrorCode(GENERAL_FAILURE), 
+  lNextConnection((STATDLLMember*)0), 
+  lPrevConnection((STATDLLMember*)0),
+  pEngine(NULL)
+{
+	CString lPrefix="";
+
+	pszAddress = NULL;
+	iErrorCode = GENERAL_FAILURE;
+	strcpy(szErrorText, "An unknown error has occured");
+
+	// set logging identifier
+	lPrefix.Format(LPCTSTR("[%d:%s] "), iConnectType, pszPlatformType);
+ 	const char *lPrefixPtr=(const char *)lPrefix.GetBuffer(lPrefix.GetLength());
+	strncpy(szPrefix, lPrefixPtr, MAX_ID_PREFIX);
+
+	pEngine = new CSTATEngine;
+	if (pEngine)
+	{
+		if ((iErrorCode = pEngine->Initialise(iConnectType, pszPlatformType)) != ITS_OK)
+		{
+			ErrorMessage("Could not initialise new connection object");
+			delete pEngine;
+			pEngine = NULL;
+		}
+		else
+		{
+			pszAddress = new char[strlen(pszPlatformType) + 1];
+			if (pszAddress)
+				strcpy(pszAddress, pszPlatformType);
+		}
+	}
+	else
+		ErrorMessage("Could not create new connection object");
+
+	// did we make it?
+	if (iErrorCode == ITS_OK)
+		Message("Connection initialised successfully");
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Release any STAT resources.
+//
+STATDLLMember::~STATDLLMember()
+{
+	if (pEngine)
+	{
+		Message("Releasing member resources");
+		pEngine->Release();
+		delete pEngine;
+	}
+
+	if (pszAddress)
+		delete [] pszAddress;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Do all the preparations in one go
+//
+bool
+STATDLLMember::Prepare(int iMillisecondDelay, LPTSTR pszLogPath, bool bAppend, MessageReporter *const aMessageReporter, LPTSTR pszRefDir, const bool bRemoveOldImages, const int iFactor, bool bState)
+{
+	if (pEngine)
+	{
+		pEngine->SetMultithreaded(bState);
+	}
+
+	if (!SetCommandDelay(iMillisecondDelay))
+		return false;
+
+	if (pszLogPath && (*pszLogPath) && !SetLogging(pszLogPath, bAppend, aMessageReporter))
+		return false;
+
+	if (pszRefDir && (*pszRefDir) && !SetImageVerification(pszRefDir, bRemoveOldImages, iFactor))
+		return false;
+
+	return true;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Set the delay time between commands
+//
+int
+STATDLLMember::SetCommandDelay(int iMillisecondDelay)
+{
+	if (pEngine)
+	{
+		pEngine->SetCommandDelay(iMillisecondDelay);
+		Message("Command delay set");
+		iErrorCode = ITS_OK;
+		return true;
+	}
+
+	iErrorCode = GENERAL_FAILURE;
+	ErrorMessage("Command delay could not be set");
+	return false;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Set logging of STAT commands.
+//
+int
+STATDLLMember::SetLogging(LPTSTR pszLogPath, bool bAppend, MessageReporter *const aMessageReporter)
+{
+	iErrorCode = GENERAL_FAILURE;
+	CString logpath = pszLogPath;
+
+	if (pEngine)
+	{
+		if (LOG_FILE_OK == (iErrorCode = pEngine->SetLogging(logpath, szPrefix, bAppend, 
+				(aMessageReporter != NULL), true, aMessageReporter)))
+		{
+			Message("Logging set");
+			return LOG_FILE_OK;
+		}
+	}
+
+	ErrorMessage("Logging could not be set");
+	return GENERAL_FAILURE;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Send a string of STAT commands through to the STAT object.
+//
+int
+STATDLLMember::SendRawCommand(LPCTSTR pszText, ScriptProgressMonitor *const monitor)
+{
+	iErrorCode = GENERAL_FAILURE;
+	CString file = pszText;
+
+	if (pEngine)
+	{
+		{
+		CString msg;
+		msg.Format( "Sending raw command...%s", pszText );
+		Message(msg.operator LPCTSTR());
+		}
+		if ((iErrorCode = pEngine->OpenScriptFile(file, false)) == ITS_OK)
+			if ((iErrorCode = pEngine->RunScript(monitor)) == END_SCRIPT)
+				return ITS_OK;
+	}
+
+	ErrorMessage("Command text could not be processed successfully");
+	return iErrorCode;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Open a script file or text block in the engine.
+//
+int
+STATDLLMember::OpenScriptFile(LPCTSTR pszText, bool bIsFile)
+{
+	iErrorCode = GENERAL_FAILURE;
+	CString file = pszText;
+
+	if (pEngine)
+	{
+		{
+		CString msg;
+		msg.Format( "Opening script file...%s", pszText );
+		Message(msg.operator LPCTSTR());
+		}
+		if ((iErrorCode = pEngine->OpenScriptFile(pszText, bIsFile)) == ITS_OK)
+				return iErrorCode;
+	}
+
+	ErrorMessage("Open script file could not be processed successfully");
+	return iErrorCode;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Runs the script in the engine.
+//
+int
+STATDLLMember::RunScript(ScriptProgressMonitor *const monitor)
+{
+	iErrorCode = GENERAL_FAILURE;
+
+	if (pEngine)
+	{
+		{
+		CString msg;
+		msg.Format( "Running script..." );
+		Message(msg.operator LPCTSTR());
+		}
+
+		iErrorCode = pEngine->RunScript(monitor);
+	}
+
+	if( iErrorCode != END_SCRIPT )
+	{
+		ErrorMessage("Run script could not be processed successfully");
+	}
+
+	if(monitor)
+	{
+		monitor->OnCompleteScript( iErrorCode );
+	}
+
+	return iErrorCode;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Send a command file containing a string of STAT commands through to the STAT object.
+// Checks that it is actually an accessible file before accepting it.
+//
+int
+STATDLLMember::SendCommandFile(LPCTSTR pszFile, ScriptProgressMonitor *const monitor)
+{
+	iErrorCode = GENERAL_FAILURE;
+	CString file = pszFile;
+
+	if (pEngine)
+	{
+		Message("Sending command file...");
+		if ((iErrorCode = pEngine->OpenScriptFile(file, true)) == ITS_OK)
+			if ((iErrorCode = pEngine->RunScript(monitor)) == END_SCRIPT)
+				return true;
+	}
+
+	ErrorMessage("Script file could not be processed successfully");
+	return false;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Stops processing the current command.
+//
+int
+STATDLLMember::StopProcessing(void)
+{
+	iErrorCode = GENERAL_FAILURE;
+
+	if (pEngine)
+	{
+		Message("Stopping processing...");
+		pEngine->eStopProcessing = STAT_PAUSE;
+		return true;
+	}
+
+	ErrorMessage("Stopping the process could not be processed successfully");
+	return false;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Returns the number of commands in the current script.
+//
+int
+STATDLLMember::GetCommandCount(LPCTSTR pszFile, int* commandCount)
+{
+	iErrorCode = GENERAL_FAILURE;
+
+	if (pEngine)
+	{
+		Message("Sending command file...");
+		if ((iErrorCode = pEngine->GetCommandCount(pszFile, commandCount)) == ITS_OK)
+				return ITS_OK;
+	}
+
+	ErrorMessage("Getting the command count could not be processed successfully");
+	return GENERAL_FAILURE;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Returns the number of the current command.
+//
+int
+STATDLLMember::GetCurrentCommandNumber( int* commandNumber )
+{
+	iErrorCode = GENERAL_FAILURE;
+
+	if (pEngine)
+	{
+		Message("Getting current command number...");
+		*commandNumber =	pEngine->iCurrentCommand;
+		iErrorCode = ITS_OK;
+			return iErrorCode;
+	}
+
+	ErrorMessage("Getting the current command number could not be processed successfully");
+	return iErrorCode;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Returns the text recevied by the commands.
+//
+const char *
+STATDLLMember::GetReceivedData(void)
+{
+	if (pEngine)
+	{
+		Message("Getting data received by commands...");
+		return ( pEngine->GetReceivedData() );
+	}
+
+	return ( "Getting the error text could not be processed successfully" );
+}
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Returns the text associated with an error value.
+//
+const char *
+STATDLLMember::GetErrorText( int errorCode )
+{
+	if (pEngine)
+	{
+		Message("Getting current command number...");
+		return ( pEngine->GetErrorText(errorCode) );
+	}
+
+	return ( "Getting the error text could not be processed successfully" );
+}
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Sets image verification with supplied reference directory, and will remove existing
+// images if specified.  Also sets the 'fudge' factor for the verification itself.
+//
+int
+STATDLLMember::SetImageVerification(LPTSTR pszRefDir, const bool bRemoveOldImages, const int iFactor)
+{
+	iErrorCode = GENERAL_FAILURE;
+	Message("Setting image verification Dir [%s] Remove Old %d Factor %d...", ToAnsi(pszRefDir), bRemoveOldImages, iFactor);
+
+	if (pEngine && pEngine->pImageVerify)
+	{
+		//set default logging path
+		CString defaultDirectory=STAT_LOGFILEPATH_VALUE;
+		//read from inifile if entry exists
+		if(statIniFile.SectionExists(ST_TEST_KEY) )
+		{
+			CString setting;
+			setting.Empty();
+			setting=statIniFile.GetKeyValue(ST_LOGFILEPATH,ST_TEST_KEY);
+			if(!setting.IsEmpty())
+				defaultDirectory = setting;
+		}
+		iErrorCode = pEngine->pImageVerify->Initialise(defaultDirectory);
+		if(iErrorCode == ERROR_REGISTRY)
+		{
+			ErrorMessage("Config file failure");
+		}
+		else if(iErrorCode == REFDIR_FOUND)
+		{
+			if (bRemoveOldImages)
+			{
+				Message("Removing old images...");
+				iErrorCode = pEngine->pImageVerify->DeleteReferenceImages();
+			}
+			else
+				Message("Old reference images exist");
+		}
+
+		// if preparations went OK...
+		if(iErrorCode == ITS_OK)
+		{
+			Message("Copying new images from [%s]...", ToAnsi(pszRefDir));
+			iErrorCode = pEngine->pImageVerify->CopyReferenceImages(pszRefDir);
+			if(iErrorCode != ITS_OK)
+				ErrorMessage("Images could not be copied");
+		}
+
+		// success?
+		if(iErrorCode == ITS_OK || iErrorCode == REFDIR_FOUND)
+		{
+			if (pEngine->pImageVerify->EnableVerification(iFactor) > 0)
+			{
+				Message("Image verification set");
+				return true;
+			}
+			else
+			{
+				iErrorCode = GENERAL_FAILURE;
+				ErrorMessage("No images available for verification");
+			}
+		}
+
+		// disable on error
+		pEngine->pImageVerify->DisableVerification();
+	}
+
+	ErrorMessage("Image verification could not be set");
+	return false;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Gets a 'snapshot' of the screen of the remote target and returns the information
+// and data in the supplied parameters. Only stores the most recent snapshot.
+//
+STATDLLMember::GetSnapshot(TBitmapFileHeader **ppFile, TBitmapInfoHeader **ppBitmap, char **ppData, unsigned long *pSize)
+{
+	// basic screenshot command
+	CString file = "<B><S><E>";
+
+	iErrorCode = GENERAL_FAILURE;
+	*ppFile = NULL;
+	*ppBitmap = NULL;
+	*ppData = NULL;
+	*pSize = NULL;
+
+	if (pEngine)
+	{
+		Message("Sending snapshot command...");
+		if ((iErrorCode = pEngine->OpenScriptFile(file, false)) == ITS_OK)
+		{
+			pEngine->pConverter->bWriteToFile = false;
+			if ((iErrorCode = pEngine->RunScript(NULL)) == END_SCRIPT)
+			{
+				Message("Accessing bitmap data...");
+				pEngine->pConverter->GetScreenshotData(ppFile, ppBitmap, ppData, pSize);
+			}
+			pEngine->pConverter->bWriteToFile = true;
+		}
+	}
+
+	// success
+	if (ppFile && (*ppFile) && ppBitmap && (*ppBitmap) && ppData && (*ppData) && pSize && (*pSize))
+	{
+		Message("Bitmap data retrieved successfully");
+		return true;
+	}
+
+	ErrorMessage("Snapshot could not be taken");
+	return false;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Converts a char * to it's Unicode equivalent
+//
+LPTSTR
+STATDLLMember::ToUnicode(const char *string)
+{
+#ifdef UNICODE
+	static TCHAR szBuffer[MAX_UNICODE_LEN + 1] = {0};
+	szBuffer[0] = (TCHAR)0;
+
+    // Convert to UNICODE.
+    if (!MultiByteToWideChar(CP_ACP,					// conversion type
+							 0,							// flags
+							 string,					// source
+							 -1,						// length
+							 szBuffer,					// dest
+							 MAX_UNICODE_LEN))			// length
+    {
+        return _T("Could not convert");
+    }
+
+    return szBuffer;
+#else
+	return (LPTSTR)string;
+#endif
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Converts a Unicode to it's char * equivalent
+//
+const char *
+STATDLLMember::ToAnsi(LPCTSTR string)
+{
+#ifdef UNICODE
+	static char szBuffer[MAX_UNICODE_LEN + 1] = {0};
+	szBuffer[0] = (char)0;
+
+    // Convert to ANSI.
+    if (!WideCharToMultiByte(CP_ACP,					// conversion type
+							 0,							// flags
+							 string,					// source
+							 -1,						// length
+							 szBuffer,					// dest
+							 MAX_UNICODE_LEN,			// length
+							 NULL,
+							 NULL ))
+    {
+        return "Could not convert";
+    }
+
+    return szBuffer;
+#else
+	return (char *)string;
+#endif
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////
+// Split a connection registry entry into its respective parts
+void
+STATDLLMember::ParseConnection(char *pConnection, STATCONNECTTYPE *pType, char **ppAddress)
+{
+	(*pType) = SymbianInvalid;
+	(*ppAddress) = NULL;
+
+	static char szConnection[256];
+	memset(szConnection, 0, sizeof(szConnection));
+	strcpy(szConnection, pConnection);
+
+	char *p = strchr(szConnection, ':');
+	if (p)
+	{
+		(*p) = (char)0;
+		(*ppAddress) = p + 1;
+
+		if (stricmp(szConnection, "SymbianSocket") == 0)
+		{
+			(*pType) = SymbianSocket;
+		}
+		else if (stricmp(szConnection, "SymbianSerial") == 0)
+		{
+			(*pType) = SymbianSerial;
+		}
+		else if (stricmp(szConnection, "SymbianInfrared") == 0)
+		{
+			(*pType) = SymbianInfrared;
+		}
+		else if (stricmp(szConnection, "SymbianBluetooth") == 0)
+		{
+			(*pType) = SymbianBluetooth;
+		}
+
+		(*p) = ':';
+	}
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// PRIVATE METHODS
+//////////////////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Writes a message to file
+//
+void
+STATDLLMember::Message(const char * message, ...)
+{
+	if (pRep)
+	{
+		char szText[MAX_ERROR_MSG_LEN * 2] = {0};
+		va_list pMsg;
+
+		strcpy(szText, szPrefix);
+
+		va_start (pMsg, message);
+		vsprintf (szText + strlen(szText), message, pMsg);
+		va_end (pMsg);
+
+		pRep->info(szText);
+	}
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Writes an error message to file
+//
+void
+STATDLLMember::ErrorMessage(const char * message, ...)
+{
+	if (pRep)
+	{
+		va_list pMsg;
+		char szErrorMsg[MAX_ERROR_MSG_LEN + 1] = {0};
+
+		// get the API error
+		va_start (pMsg, message);
+		vsprintf (szErrorMsg, message, pMsg);
+		va_end (pMsg);
+
+		// save the complete error
+		if (pEngine)
+		{
+			if (pEngine->GetDeviceReturnCode() != 0)
+			{
+				sprintf(szErrorText, "%s (%d : %s - Device return code %d)", 
+										szErrorMsg, 
+										iErrorCode, 
+										ToAnsi(pEngine->GetErrorText(iErrorCode)),
+										pEngine->GetDeviceReturnCode());
+			}
+			else
+			{
+				sprintf(szErrorText, "%s (%d : %s)", 
+										szErrorMsg, 
+										iErrorCode, 
+										ToAnsi(pEngine->GetErrorText(iErrorCode)));
+			}
+		}
+		else
+			strcpy(szErrorText, "(STAT Engine not initialised)");
+
+		// construct a full log message
+		char szLogError[MAX_ERROR_MSG_LEN * 2] = {0};
+		sprintf(szLogError, "%sERROR: %s", szPrefix, szErrorText);
+		pRep->error(szLogError);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/src/statscriptdecoder.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,353 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include "stdafx.h"
+#include "statscriptdecoder.h"
+
+//----------------------------------------------------------------------------
+// Contructor
+CSTATScriptCommand::CSTATScriptCommand()
+: cCommandID(0), pCommand(NULL), ulLength(0)
+{
+}
+
+//----------------------------------------------------------------------------
+// Destructor
+CSTATScriptCommand::~CSTATScriptCommand()
+{
+	Reset();
+}
+
+
+//----------------------------------------------------------------------------
+// Set command data
+bool CSTATScriptCommand::SetData(const char *pData, const unsigned long theLength)
+{
+	Reset();
+
+	if (pData && theLength)
+	{
+		pCommand = new char[theLength + 1];
+		if (!pCommand)
+			return false;
+
+		memcpy(pCommand, pData, theLength);
+		*(pCommand + theLength) = (char)0;
+		ulLength = theLength;
+	}
+
+	return true;
+}
+
+
+//----------------------------------------------------------------------------
+// Destructor
+void CSTATScriptCommand::Reset()
+{
+	if (pCommand)
+	{
+		delete [] pCommand;
+		pCommand = NULL;
+	}
+
+	ulLength = 0;
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Script Decoder class
+////////////////////////////////////////////////////////////////////////////////////////
+
+//----------------------------------------------------------------------------
+// Constructor
+CSTATScriptDecoder::CSTATScriptDecoder(CSTATLogFile *theLog)
+: lFileLength(0), iCounter(0),
+  lpBuffer(NULL)
+{
+	pLog = theLog;
+}
+
+
+//----------------------------------------------------------------------------
+// Destructor
+CSTATScriptDecoder::~CSTATScriptDecoder()
+{
+	Release();
+}
+
+
+//----------------------------------------------------------------------------
+// Read the script into memory
+int
+CSTATScriptDecoder::Initialise(const CString& file, bool bIsFile)
+{
+	lpBuffer = NULL;
+	int ret = OPEN_SCRIPT_FILE_COMPLETE_FAILURE;
+
+	// read the commands into memory
+	if (bIsFile)
+	{
+		CFile script_file;
+		if (script_file.Open(file, CFile::modeRead))
+		{
+			ret = ReadFileIntoMemory(script_file);
+			script_file.Abort();
+		}
+	}
+	else
+		ret = ReadDataIntoMemory(file);
+
+	// make sure we have valid start/end points in the script
+	if (ret == ITS_OK)
+		ret = ValidateScript();
+
+	if (ret == ITS_OK)
+	{
+		pLog->WriteTimeToLog();
+
+		if(bIsFile)
+		{
+			CString cBuffer = _T("Script file is : ");
+			cBuffer += file;
+			pLog->Write(cBuffer);
+		}
+		else
+			pLog->Write(_T("Interpreting command script..."));
+
+		ret = ITS_OK;
+	}
+	else
+		Release();
+
+	return ret;
+}
+
+
+//----------------------------------------------------------------------------
+// Release resources
+void CSTATScriptDecoder::Release()
+{
+	LastCommand.Reset();
+
+	// release the script
+	if (lpBuffer && lFileLength)
+	{
+		delete [] lpBuffer;
+		lpBuffer = NULL;
+		lFileLength = iCounter = 0;
+	}
+}
+
+
+//----------------------------------------------------------------------------
+// get the contents of a single command
+int
+CSTATScriptDecoder::GetNextCommand(CSTATScriptCommand **ppCommand)
+{
+	// get to the start of the command
+	while (lpBuffer[iCounter] != '<')
+	{
+		// comment
+		if (lpBuffer[iCounter] == '/' && lpBuffer[iCounter + 1] == '*')
+		{
+			if (ExtractComment())
+			{
+				*ppCommand = &LastCommand;
+				return LastCommand.cCommandID;
+			}
+
+			return 0;
+		}
+
+		if (!IncrementCounter())
+			return 0;
+	}
+
+	// step over the '<'
+	if (!IncrementCounter())
+		return 0;
+
+	// save the command ID
+	LastCommand.cCommandID = (char)toupper(lpBuffer[iCounter]);
+	if (!IncrementCounter())
+		return 0;
+
+	// need to step over 'image' with '#image' command
+	if (LastCommand.cCommandID == '#')
+	{
+		while (lpBuffer[iCounter] != ' ')
+			if (!IncrementCounter())
+				return 0;
+
+		// step over the space
+		if (!IncrementCounter())
+			return 0;
+	}
+
+	int iBeginning = iCounter;
+
+	// extract the command
+	while (lpBuffer[iCounter] != '>')
+		if (!IncrementCounter())
+			return 0;
+
+	// save our command
+	LastCommand.SetData(lpBuffer + iBeginning, iCounter - iBeginning);
+
+	// step over the '>'
+	IncrementCounter();
+
+	// set pointer to the command
+	*ppCommand = &LastCommand;
+	return LastCommand.cCommandID;
+}
+
+
+//----------------------------------------------------------------------------
+// PRIVATE METHODS
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
+//reads string data into memory so that it can be decoded
+int CSTATScriptDecoder::ReadDataIntoMemory(const CString& commands)
+{
+	// Convert CString to char *
+	lFileLength = commands.GetLength();		//set length
+	lpBuffer = new char [lFileLength + 1];		//allocate temporary buffer
+	if (lpBuffer)
+	{
+		if (!pLog->ToAnsi(commands, 
+								  lpBuffer, 
+								  lFileLength))
+		{
+			return INTERPRET_COMMANDS_FAILURE;		//unable to convert to 8-bit
+		}
+
+		lpBuffer[lFileLength] = 0;
+		return ITS_OK;
+	}
+
+	return E_OUTOFMEM;
+}
+//----------------------------------------------------------------------------
+//reads file data into memory so that it can be decoded
+int CSTATScriptDecoder::ReadFileIntoMemory(CFile& scriptdata)
+{
+	try
+	{
+		lFileLength = scriptdata.GetLength();		//file length
+		lpBuffer = new char [lFileLength + 1];		//allocate temporary buffer
+		if (lpBuffer)
+		{
+			scriptdata.Read(lpBuffer, lFileLength);	//read in from the file and store in the buffer
+			lpBuffer[lFileLength] = 0;
+			return ITS_OK;
+		}
+	}
+	catch(CFileException *e)
+	{
+		e -> Delete();
+		return OPEN_SCRIPT_FILE_COMPLETE_FAILURE;
+	}
+
+	return E_OUTOFMEM;
+}
+
+
+//----------------------------------------------------------------------------
+// checks that start and end codes exist in the script
+// on success, iCounter will be left ready for the first STAT command
+int CSTATScriptDecoder::ValidateScript()
+{
+	CSTATScriptCommand *pCommand;
+	bool bFound = false;
+
+	// reset
+	iCounter = 0;
+
+	// look for end
+	while (GetNextCommand(&pCommand))
+	{
+		if (pCommand->cCommandID == 'E')
+		{
+			bFound = true;
+			break;
+		}
+	}
+
+	if (bFound)
+	{
+		// reset
+		iCounter = 0;
+		bFound = false;
+
+		// look for begin
+		while (GetNextCommand(&pCommand))
+		{
+			if (pCommand->cCommandID == 'B')
+			{
+				bFound = true;
+				iCounter -= 3;	// step back so this is the first command sent
+				break;
+			}
+		}
+	}
+
+	if (!bFound)
+		return BEGIN_COMMAND_FAILURE;
+
+	return ITS_OK;
+}
+
+
+//----------------------------------------------------------------------------
+// get a comment
+int
+CSTATScriptDecoder::ExtractComment()
+{
+	int iBeginning = iCounter;
+
+	LastCommand.cCommandID = lpBuffer[iCounter];
+	iCounter += 2;
+
+	while (((iCounter + 1) < lFileLength) &&
+		   !(lpBuffer[iCounter] == '*' && lpBuffer[iCounter + 1] == '/') )
+	{
+		if (!IncrementCounter())
+			return 0;
+	}
+
+	// get the last bit of the comment '*/'
+	if ((iCounter + 1) < lFileLength)
+		iCounter += 2;
+
+	// save our comment
+	LastCommand.SetData(lpBuffer + iBeginning, iCounter - iBeginning);
+	return LastCommand.cCommandID;
+}
+
+
+//----------------------------------------------------------------------------
+// increment counter but make sure we don't go over the end of the script
+bool CSTATScriptDecoder::IncrementCounter(void)
+{
+	return (++iCounter < lFileLength);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/src/statserial.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,391 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// STATSerial.cpp
+// Implementation of the serial comms transport
+////////////////////////////////////////////////////////////////////////////////////////
+#include "stdafx.h"
+#include "statserial.h"
+#include "assert.h"
+#include "../../../../Common/inc/SerialPacketSize.h"
+
+#define SP_COMMANDSIZE	4
+#define SP_LENGTHSIZE	4
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Constructor
+CSTATSerial::CSTATSerial(STATCONNECTTYPE eConnect)
+: hComPort((HANDLE)0), 	pBuffer(NULL), iBufferLength(0), iMaxPacketSize(0)
+{
+	switch(eConnect)
+	{
+		case SymbianSerial:
+		case SymbianInfrared:
+			iMaxPacketSize = KMaxPacketSize;
+			break;
+		case SymbianBluetooth:
+			iMaxPacketSize = KMaxBluetoothPacketSize;
+			break;
+		default:
+			assert(0);
+			break;
+	};
+
+	assert(0 != iMaxPacketSize);
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Destructor
+CSTATSerial::~CSTATSerial()
+{
+	Disconnect();
+	Release();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Initialisation stuff
+int CSTATSerial::Initialise(void)
+{
+	return ITS_OK;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Open a connection
+int CSTATSerial::Connect(const char *pAddress)
+{
+	// already connected
+	if (hComPort)
+		return ITS_OK;
+
+	if (OpenComPort(pAddress))
+	{
+		SetError("Connected to port %s Speed %d Bytes %d Parity %d Stop %d",
+			pAddress, STAT_BAUDRATE, STAT_BYTESIZE, STAT_PARITY, STAT_STOPBITS);
+		return ITS_OK;
+	}
+
+	return E_CONNECTIONFAILED;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Send a command and associated data
+////////////////////////////////////////////////////////////////////////////////////////
+int CSTATSerial::Send(const char cIdentifier, const char *pCommand, const unsigned long ulLength)
+{
+	DWORD dwBytes = 0;
+	int ret = E_WRITEFAILED;
+
+	// prepare command
+	STATCOMMAND STATSendCommand;
+	memset(&STATSendCommand, 0, sizeof(STATCOMMAND));
+	STATSendCommand.cIdentifier = cIdentifier;
+	STATSendCommand.ulLength = ulLength;
+
+	int result = 0;
+	if (result = WriteFile(hComPort, (LPVOID)&STATSendCommand, sizeof(STATCOMMAND), &dwBytes, NULL))
+	{
+		if (dwBytes == sizeof(STATCOMMAND))
+		{
+			// only send data if it will fit into our buffer
+			if (pCommand && STATSendCommand.ulLength && STATSendCommand.ulLength <= iMaxPacketSize)
+			{
+				if (WriteFile(hComPort, (LPVOID)pCommand, STATSendCommand.ulLength, &dwBytes, NULL))
+				{
+					if (dwBytes == STATSendCommand.ulLength)
+					{
+						SetError("Sent successfully %ld bytes", STATSendCommand.ulLength);
+						ret = ITS_OK;
+					}
+					else
+					{
+						SetError("Incorrect number of bytes written - expected %ld sent %ld", STATSendCommand.ulLength, dwBytes);
+						ret = E_BADNUMBERBYTES;
+					}
+				}
+				else
+					SetError("Write data to port failed");
+			}
+			else
+			{
+				SetError("Sent successfully");
+				ret = ITS_OK;
+			}
+		}
+		else
+		{
+			int err = ::GetLastError();
+			SetError("Incorrect number of bytes written - expected %ld sent %ld", sizeof(STATCOMMAND), dwBytes);
+			ret = E_BADNUMBERBYTES;
+		}
+	}
+	else
+		SetError("Write command to port failed");
+
+	return ret;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Receive a command and associated data
+//
+// Tries to read a STATCOMMAND structure from the port.  If successful, the length
+// of any data following will be specified in the structure.  If extra data, try to
+// read this.  If all successful, set the pointers to point to it
+//
+////////////////////////////////////////////////////////////////////////////////////////
+int CSTATSerial::ReceiveBytes( char *buff, unsigned long size )
+{
+	int ret;
+	int err;
+	unsigned long bytes_read = 0;
+	unsigned long bytes_read_this_iteration = 0;
+
+	// make sure size > 0 otherwise the following semantics fail
+	assert( size > 0 );
+
+	// loop until either all bytes have been received or an error occurs
+	for( bytes_read = 0; bytes_read < size; bytes_read += bytes_read_this_iteration ) { 
+		ret = ReadFile( hComPort, &(buff[bytes_read]), (size - bytes_read), &bytes_read_this_iteration, NULL );
+		if( bytes_read_this_iteration == 0 ) {
+			return NO_DATA_AT_PORT;
+		}
+		if( ret == 0 ) {
+			err = ::GetLastError();
+			SetError( "Error while receiving command - %ld", err );
+			return err;
+		}
+	}
+
+	// everything is OK
+	return 0;
+}
+
+int CSTATSerial::Receive( char *cIdentifier, char **ppData, unsigned long *pLength )
+{
+	int ret;
+	unsigned long command;
+	unsigned long data_length;
+
+	// initialise parameters
+	*cIdentifier = 0;
+	*ppData = NULL;
+	*pLength = 0;
+
+	// get command
+	ret = ReceiveBytes( (char*)&command, SP_COMMANDSIZE );
+	if( ret != 0 ) {
+		return ret;
+	}
+
+	static const int MAX_COMMAND = 127;
+	if( command > MAX_COMMAND ){
+		return INVALID_COMMAND_FORMAT;
+	}
+
+	// get length
+	ret = ReceiveBytes( (char*)&data_length, SP_LENGTHSIZE );
+	if( ret != 0 ) {
+		return ret;
+	}
+
+	// put these values into the return slots
+	*cIdentifier = (char)command;
+	*pLength = data_length;
+
+	// if the length is zero then there is no more to do
+	if( data_length == 0 ) {
+		return ITS_OK;
+	}
+
+	// if the length is greater than the buffer size then this is a header packet and we are not
+	// supposed to actually read any data from it.
+	// if( data_length > SP_BUFFERSIZE ) {
+	if( data_length > iMaxPacketSize ) {
+		SetError( "Received command ID: %c successfully length %d", (*cIdentifier), (*pLength) );
+		return ITS_OK;
+	}
+
+	// Otherwise we are about to read some data. We first have to setup the memory management
+	// which is done in a pretty ugly way IMAO.
+	if( data_length > iBufferLength )
+	{
+		if( pBuffer ) {
+			delete [] pBuffer;
+			pBuffer = NULL;
+			iBufferLength = 0;
+		}
+		pBuffer = new char [data_length];
+		if( pBuffer == NULL ) {
+			SetError( "Unable to allocate %ld bytes of memory to hold data", data_length );
+			return E_OUTOFMEM;
+		}
+		iBufferLength = data_length;
+	}
+
+	// now read the data
+	ret = ReceiveBytes( pBuffer, data_length );
+	if( ret != 0 ) {
+		return ret;
+	}
+	*ppData = pBuffer;
+
+	return ITS_OK;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Disconnect from the port
+int CSTATSerial::Disconnect(void)
+{
+	// release previous resources
+	if (pBuffer)
+	{
+		delete [] pBuffer;
+		pBuffer = NULL;
+		iBufferLength = 0;
+	}
+
+	// disconnect
+	if (hComPort)
+	{
+		CloseHandle(hComPort);
+		hComPort = (HANDLE)0;
+	}
+
+	SetError("Disconnected successfully");
+	return ITS_OK;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Release resources
+int CSTATSerial::Release(void)
+{
+	Disconnect();
+	return ITS_OK;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+//	PRIVATE FUNCTIONS
+////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////
+// 
+bool CSTATSerial::OpenComPort(const char *pAddress)
+{
+	TCHAR szAddress[256] = {0};
+
+#ifdef UNICODE
+	szAddress[0] = (TCHAR)0;
+
+    // Convert to UNICODE.
+    MultiByteToWideChar(CP_ACP,					// conversion type
+						 0,							// flags
+						 pAddress,					// source
+						 -1,						// length
+						 szAddress,					// dest
+						 256);						// length
+#else
+	strcpy(szAddress, pAddress);
+#endif
+
+	// Use device naming for COM port.
+	CString port;
+	CString address(pAddress);	// Local variable to cope with 
+								// wide UNICODE characters.
+	port.Format(_T("\\\\.\\%s"), address.operator LPCTSTR());
+
+	if (INVALID_HANDLE_VALUE == (hComPort = CreateFile(port,
+					 GENERIC_READ | GENERIC_WRITE,
+					 0,
+					 NULL,
+					 OPEN_EXISTING,
+					 FILE_FLAG_WRITE_THROUGH,
+					 NULL)))
+	{
+		SetError("Port [%s] could not be opened", pAddress);
+		int err = ::GetLastError();
+		hComPort = (HANDLE)0;
+		return false;
+	}
+
+	COMMTIMEOUTS CommTimeOuts;
+	CommTimeOuts.WriteTotalTimeoutMultiplier	= STAT_WRITETOTALTIMEOUTMULTIPLIER; 
+	CommTimeOuts.WriteTotalTimeoutConstant		= STAT_WRITETOTALTIMEOUTCONSTANT;
+	CommTimeOuts.ReadIntervalTimeout			= STAT_READINTERVALTIMEOUT;
+	CommTimeOuts.ReadTotalTimeoutMultiplier		= STAT_READTOTALTIMEOUTMULTIPLIER;
+	CommTimeOuts.ReadTotalTimeoutConstant		= STAT_READTOTALTIMEOUTCONSTANT;
+
+	if (!SetCommTimeouts(hComPort, &CommTimeOuts))
+	{
+		SetError("Comm port timeouts could not be set");
+		CloseHandle(hComPort);
+		hComPort = (HANDLE)0;
+		return false;
+	} 
+
+	// Configure the COM port 
+	DCB dcb;
+	GetCommState(hComPort, &dcb);
+	dcb.DCBlength			= sizeof(dcb); 
+	dcb.BaudRate			= STAT_BAUDRATE;
+	dcb.fBinary				= TRUE;
+	dcb.fParity				= STAT_PARITY;
+	dcb.fOutxCtsFlow		= TRUE;
+	dcb.fOutxDsrFlow		= FALSE;
+	dcb.fDtrControl			= DTR_CONTROL_ENABLE;	
+	dcb.fDsrSensitivity		= FALSE;
+	dcb.fTXContinueOnXoff	= TRUE;
+	dcb.fOutX				= FALSE;
+	dcb.fInX				= FALSE;
+	dcb.fErrorChar			= FALSE;
+	dcb.fNull				= FALSE;
+	dcb.fRtsControl			= RTS_CONTROL_HANDSHAKE;
+	dcb.fAbortOnError		= TRUE;
+	dcb.XonLim				= 4096;
+	dcb.XoffLim				= 1024;
+	dcb.ByteSize			= STAT_BYTESIZE;
+	dcb.Parity				= STAT_PARITY;
+	dcb.StopBits			= STAT_STOPBITS;
+	dcb.XonChar				= 17;
+	dcb.XoffChar			= 19;
+
+//	dcb.fRtsControl		= RTS_CONTROL_ENABLE;
+//	dcb.BaudRate		= STAT_BAUDRATE;
+//	dcb.fOutxCtsFlow	= FALSE;
+//	dcb.XonLim			= STAT_XONLIMIT;
+//	dcb.XoffLim			= STAT_XOFFLIMIT;
+	
+	if (!SetCommState(hComPort, &dcb))
+	{
+		SetError("Comm port state could not be set");
+		CloseHandle(hComPort);
+		hComPort = (HANDLE)0;
+		return false;
+	} 
+
+	return true;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/src/statserialbluetooth.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,364 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include "stdafx.h"
+#include "statserialbluetooth.h"
+#include "assert.h"
+
+#define SP_COMMANDSIZE	4
+#define SP_LENGTHSIZE	4
+#define SP_BUFFERSIZE	STAT_BUFFERSIZE
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Constructor
+CSTATSerialBluetooth::CSTATSerialBluetooth()
+: hComPort((HANDLE)0), 	pTemp(NULL)
+{
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Destructor
+CSTATSerialBluetooth::~CSTATSerialBluetooth()
+{
+	Disconnect();
+	Release();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Initialisation stuff
+int CSTATSerialBluetooth::Initialise(void)
+{
+	return ITS_OK;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Open a connection
+int CSTATSerialBluetooth::Connect(const char *pAddress)
+{
+	// already connected
+	if (hComPort)
+		return ITS_OK;
+
+	if (OpenComPort(pAddress))
+	{
+		SetError("Connected to port %s Speed %d Bytes %d Parity %d Stop %d",
+			pAddress, STATBT_BAUDRATE, STATBT_BYTESIZE, STATBT_PARITY, STATBT_STOPBITS);
+		return ITS_OK;
+	}
+
+	return E_CONNECTIONFAILED;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Send a command and associated data
+////////////////////////////////////////////////////////////////////////////////////////
+int CSTATSerialBluetooth::Send(const char cIdentifier, const char *pCommand, const unsigned long ulLength)
+{
+	DWORD dwBytes = 0;
+	int ret = E_WRITEFAILED;
+
+	// prepare command
+	STATCOMMAND STATSendCommand;
+	memset(&STATSendCommand, 0, sizeof(STATCOMMAND));
+	STATSendCommand.cIdentifier = cIdentifier;
+	STATSendCommand.ulLength = ulLength;
+
+	if (WriteFile(hComPort, (LPVOID)&STATSendCommand, sizeof(STATCOMMAND), &dwBytes, NULL))
+	{
+		if (dwBytes == sizeof(STATCOMMAND))
+		{
+			// only send data if it will fit into our buffer
+		//	if (pCommand && STATSendCommand.ulLength && STATSendCommand.ulLength <= STAT_BUFFERSIZE)
+		//	{
+				if (WriteFile(hComPort, (LPVOID)pCommand, STATSendCommand.ulLength, &dwBytes, NULL))
+				{
+					if (dwBytes == STATSendCommand.ulLength)
+					{
+						SetError("Sent successfully %ld bytes", STATSendCommand.ulLength);
+						ret = ITS_OK;
+					}
+					else
+					{
+						SetError("Incorrect number of bytes written - expected %ld sent %ld", STATSendCommand.ulLength, dwBytes);
+						ret = E_BADNUMBERBYTES;
+					}
+				}
+				else
+					SetError("Write data to port failed");
+		///	}
+		//	else
+		//	{
+		//		SetError("Sent successfully");
+		//		ret = ITS_OK;
+		//	}
+		}
+		else
+		{
+			SetError("Incorrect number of bytes written - expected %ld sent %ld", sizeof(STATCOMMAND), dwBytes);
+			ret = E_BADNUMBERBYTES;
+		}
+	}
+	else
+		SetError("Write command to port failed");
+
+	return ret;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Receive a command and associated data
+//
+// Tries to read a STATCOMMAND structure from the port.  If successful, the length
+// of any data following will be specified in the structure.  If extra data, try to
+// read this.  If all successful, set the pointers to point to it
+//
+////////////////////////////////////////////////////////////////////////////////////////
+int CSTATSerialBluetooth::ReceiveBytes( char *buff, unsigned long size )
+{
+	int ret;
+	int err;
+	unsigned long bytes_read = 0;
+	unsigned long bytes_read_this_iteration = 0;
+
+	// make sure size > 0 otherwise the following semantics fail
+	assert( size > 0 );
+
+	// loop until either all bytes have been received or an error occurs
+	for( bytes_read = 0; bytes_read < size; bytes_read += bytes_read_this_iteration ) 
+	{ 
+		ret = ReadFile( hComPort, &(buff[bytes_read]), (size - bytes_read), &bytes_read_this_iteration, NULL );		
+		
+		if( bytes_read_this_iteration == 0 ) 
+		{
+			return NO_DATA_AT_PORT;
+		}
+
+		if( ret == 0 ) 
+		{
+			err = GetLastError();
+			SetError( "Error while receiving command - %ld", err );
+			return err;
+		}
+	}
+
+	// everything is OK
+	return 0;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////
+int CSTATSerialBluetooth::Receive( char *cIdentifier, char **ppData, unsigned long *pLength )
+{
+	int ret;
+	unsigned long command;
+	unsigned long data_length;
+
+	// initialise parameters
+	*cIdentifier = 0;
+	*ppData = NULL;
+	*pLength = 0;
+
+	// get command
+	ret = ReceiveBytes( (char*)&command, SP_COMMANDSIZE );
+	if( ret != 0 ) {
+		return ret;
+	}
+		
+	// get length
+	ret = ReceiveBytes( (char*)&data_length, SP_LENGTHSIZE );
+	if( ret != 0 ) {
+		return ret;
+	}
+
+	// put these values into the return slots
+	*cIdentifier = (char)command;
+	*pLength = data_length;
+
+	// if the length is zero then there is no more to do
+	if( data_length == 0 ) {
+		return ITS_OK;
+	}
+
+	// if the length is greater than the buffer size then this is a header packet and we are not
+	// supposed to actually read any data from it.
+/*	if( data_length > SP_BUFFERSIZE ) {
+		SetError( "Received command ID: %c successfully length %d", (*cIdentifier), (*pLength) );
+		return ITS_OK;
+	}
+*/
+
+	SetError( "Received command ID: %c successfully length %d", (*cIdentifier), (*pLength) );
+	
+	// Otherwise we are about to read some data. We first have to setup the memory management
+	// which is done in a pretty ugly way IMAO.
+	if( pTemp ) 
+	{
+		delete [] pTemp;
+		pTemp = NULL;
+	}
+	
+	pTemp = new char [data_length];
+	
+	if( pTemp == NULL ) 
+	{
+		SetError( "Unable to allocate %ld bytes of memory to hold data", data_length );
+		return E_OUTOFMEM;
+	}
+
+	// now read the data
+	ret = ReceiveBytes( pTemp, data_length );
+	
+	if( ret != 0 ) 
+	{
+		return ret;
+	}
+
+	*ppData = pTemp;
+
+	return ITS_OK;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Disconnect from the port
+int CSTATSerialBluetooth::Disconnect(void)
+{
+	// release previous resources
+	if (pTemp)
+	{
+		delete [] pTemp;
+		pTemp = NULL;
+	}
+
+	// disconnect
+	if (hComPort)
+	{
+		CloseHandle(hComPort);
+		hComPort = (HANDLE)0;
+	}
+
+	SetError("Disconnected successfully");
+	return ITS_OK;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Release resources
+int CSTATSerialBluetooth::Release(void)
+{
+	Disconnect();
+	return ITS_OK;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+//	PRIVATE FUNCTIONS
+////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////
+// 
+bool CSTATSerialBluetooth::OpenComPort(const char *pAddress)
+{
+	TCHAR szAddress[256] = {0};
+
+#ifdef UNICODE
+	szAddress[0] = (TCHAR)0;
+
+    // Convert to UNICODE.
+    MultiByteToWideChar(CP_ACP,					// conversion type
+						 0,							// flags
+						 pAddress,					// source
+						 -1,						// length
+						 szAddress,					// dest
+						 256);						// length
+#else
+	strcpy(szAddress, pAddress);
+#endif
+
+	if (INVALID_HANDLE_VALUE == (hComPort = CreateFile(szAddress,
+					 GENERIC_READ | GENERIC_WRITE,
+					 0,
+					 NULL,
+					 OPEN_EXISTING,
+					 FILE_FLAG_WRITE_THROUGH,
+					 NULL)))
+	{
+		SetError("Port [%s] could not be opened", pAddress);
+		return false;
+	}
+
+	COMMTIMEOUTS CommTimeOuts;
+	CommTimeOuts.WriteTotalTimeoutMultiplier	= STATBT_WRITETOTALTIMEOUTMULTIPLIER; 
+	CommTimeOuts.WriteTotalTimeoutConstant		= STATBT_WRITETOTALTIMEOUTCONSTANT;
+	CommTimeOuts.ReadIntervalTimeout			= STATBT_READINTERVALTIMEOUT;          
+    CommTimeOuts.ReadTotalTimeoutMultiplier		= STATBT_READTOTALTIMEOUTMULTIPLIER;   
+    CommTimeOuts.ReadTotalTimeoutConstant		= STATBT_READTOTALTIMEOUTCONSTANT;
+	
+	if (!SetCommTimeouts(hComPort, &CommTimeOuts))
+	{
+		SetError("Comm port timeouts could not be set");
+		CloseHandle(hComPort);
+		return false;
+	} 
+
+	// Configure the COM port 
+	DCB dcb;
+	GetCommState(hComPort, &dcb);
+	dcb.DCBlength			= sizeof(dcb); 
+	dcb.BaudRate			= STATBT_BAUDRATE;
+	dcb.fBinary				= TRUE;
+	dcb.fParity				= STATBT_PARITY;
+	dcb.fOutxCtsFlow		= TRUE;
+	dcb.fOutxDsrFlow		= FALSE;
+	dcb.fDtrControl			= DTR_CONTROL_ENABLE;	
+	dcb.fDsrSensitivity		= FALSE;
+	dcb.fTXContinueOnXoff	= TRUE;
+	dcb.fOutX				= FALSE;
+	dcb.fInX				= FALSE;
+	dcb.fErrorChar			= FALSE;
+	dcb.fNull				= FALSE;
+	dcb.fRtsControl			= RTS_CONTROL_HANDSHAKE;
+	dcb.fAbortOnError		= TRUE;
+	dcb.XonLim				= 4096;
+	dcb.XoffLim				= 1024;
+	dcb.ByteSize			= STATBT_BYTESIZE;
+	dcb.Parity				= STATBT_PARITY;
+	dcb.StopBits			= STATBT_STOPBITS;
+	dcb.XonChar				= 17;
+	dcb.XoffChar			= 19;
+
+//	dcb.fRtsControl		= RTS_CONTROL_ENABLE;
+//	dcb.BaudRate		= STAT_BAUDRATE;
+//	dcb.fOutxCtsFlow	= FALSE;
+//	dcb.XonLim			= STAT_XONLIMIT;
+//	dcb.XoffLim			= STAT_XOFFLIMIT;
+	
+	if (!SetCommState(hComPort, &dcb))
+	{
+		SetError("Comm port state could not be set");
+		CloseHandle(hComPort);
+		return false;
+	} 
+
+	return true;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/src/statsocket_block.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,325 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include "stdafx.h"
+#include "statsocket_block.h"
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Constructor
+CSTATSocket::CSTATSocket() : pBuffer(NULL), iBufferLength(0)
+{
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Destructor
+CSTATSocket::~CSTATSocket()
+{
+	Disconnect();
+	Release();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Initialise
+int CSTATSocket::Initialise(void)
+{
+	WORD version;
+	WSADATA wsaData;
+
+	// start the windows socket server
+	version = MAKEWORD( 2, 2 );
+	if (WSAStartup( version, &wsaData ))
+		return E_SOCKETSTARTUP;
+
+	return ITS_OK;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Connect
+int CSTATSocket::Connect(const char *pAddress)
+{
+	int iPort = ST_DEFAULTDEVICEPORT;
+
+	// parameter will either be MACHINE_NAME:PORT_NUMBER if connecting
+	// or just PORT_NUMBER if listening
+	char *p = strrchr(pAddress, ':');
+	char *q = p;
+	if (p)
+	{
+		(*p) = (char)0;
+
+		p++;
+		if (p && *p)
+			iPort = atoi(p);
+
+		// local address
+		struct hostent *hp;
+		memset(&sin,0,sizeof(sin));
+		sin.sin_family = AF_INET;
+		sin.sin_port = htons((unsigned short)iPort);
+		hp = gethostbyname(pAddress);
+
+		// put this back to restore original string
+		*q = ':';
+
+		if (hp)
+		{
+
+			// create a client socket
+			sock = socket( AF_INET, SOCK_STREAM, 0 ) ;
+			if( sock == INVALID_SOCKET )
+				return E_SOCKETCREATE;
+
+			memcpy(&(sin.sin_addr),hp->h_addr,hp->h_length);
+
+			// connect to server
+			if (connect(sock, (struct sockaddr*)&sin, sizeof(sin)) != 0)
+				return E_SOCKETCONNECT;
+
+			// Set the socket I/O mode
+			// FIONBIO enables or disables the blocking mode for the 
+			// socket:
+			// 0   => blocking is enabled; 
+			// !=0 => non-blocking mode is enabled.
+			u_long mode = 1;
+			ioctlsocket(sock, FIONBIO, &mode);
+
+		}
+		else
+			return E_SOCKETHOSTNAME;
+	}
+	else
+	{
+		// create a listener socket
+		listener = socket(AF_INET, SOCK_STREAM, 0);
+		if( listener == INVALID_SOCKET )
+			return E_SOCKETCREATE;
+
+		iPort = atoi(pAddress);
+		if (!iPort)
+			iPort = ST_DEFAULTDEVICEPORT;
+
+		sin.sin_family = AF_INET;
+		sin.sin_port = htons((unsigned short)iPort);
+		sin.sin_addr.s_addr = INADDR_ANY;
+
+		if (bind(listener, (struct sockaddr*)&sin, sizeof(sin)) != 0)
+			return E_SOCKETBIND;
+
+		if (listen(listener, 1) != 0)
+			return E_SOCKETLISTEN;
+
+		int sin_size = sizeof(remote_sin);
+		memset((void *)&remote_sin, 0, sizeof(remote_sin));
+		sock = accept(listener, (struct sockaddr*)&remote_sin, &sin_size);
+
+		// shut down the listener now we have our connection
+		shutdown(listener, SD_SEND);
+		shutdown(listener, SD_RECEIVE);
+		closesocket(listener);
+
+		if (sock == INVALID_SOCKET)
+			return E_OUTOFMEM;
+	}
+
+	return ITS_OK;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Send
+int CSTATSocket::Send(const char cIdentifier, const char *pData, const unsigned long ulLength)
+{
+	int ret = ITS_OK;
+	unsigned long ID = htonl(cIdentifier);
+	unsigned long Length = htonl(ulLength);
+
+	// send the identifier
+	ret = send( sock, (char*)&ID, sizeof(unsigned long), 0 );
+	if (ret != sizeof(unsigned long))
+		return E_SOCKETSEND;
+
+	// send the length
+	ret = send( sock, (char*)&Length, sizeof(unsigned long), 0 );
+	if (ret != sizeof(unsigned long))
+		return E_SOCKETSEND;
+
+	if (pData && ulLength && (ulLength <= GetMaxPacketSize( )) )
+	{
+		char *pSendData = new char[ulLength + 1];
+		if (pSendData)
+		{
+			memset(pSendData, 0, ulLength + 1);
+			memcpy(pSendData, pData, ulLength);
+		}
+		else
+			return E_OUTOFMEM;
+
+		// send the length
+		ret = send( sock, pSendData, ulLength, 0 );
+
+		if (pSendData)
+			delete [] pSendData;
+
+		if (ret != (int)ulLength)
+			return E_SOCKETSEND;
+	}
+
+	return ITS_OK;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Receive
+int CSTATSocket::Receive(char *cIdentifier, char **ppData, unsigned long *pLength)
+{
+	int ret = ITS_OK;
+	unsigned long ID = 0;
+	unsigned long Length = 0;
+
+	TIMEVAL timeout;
+	timeout.tv_sec = SOCKETTIMEOUT;
+	timeout.tv_usec = 0;
+
+	FD_SET reader;
+	
+	FD_ZERO(&reader);
+	FD_SET(sock, &reader);
+
+	// receive the identifier
+
+	if(select(0, &reader, NULL, NULL, &timeout)==0)
+	{
+		return E_SOCKETRECV;
+	}
+
+	ret = recv( sock, (char*)&ID, sizeof(unsigned long), 0 );
+	if (ret != sizeof(unsigned long))
+		return E_SOCKETRECV;
+
+
+	if(select(0, &reader, NULL, NULL, &timeout)==0)
+	{
+		return E_SOCKETRECV;
+	}
+
+	// receive the length
+	ret = recv( sock, (char*)&Length, sizeof(unsigned long), 0 );
+	if (ret != sizeof(unsigned long))
+		return E_SOCKETRECV;
+
+	(*cIdentifier) = (char)ntohl(ID);
+	(*pLength) = ntohl(Length);
+
+	// if the length is zero then there is no more to do
+	if( *pLength == 0 ) {
+		return ITS_OK;
+	}
+
+	if( *pLength > GetMaxPacketSize( ) ) {
+		SetError( "Received command ID: %c successfully length %d", (*cIdentifier), *pLength );
+		return ITS_OK;
+	}
+
+	if (*pLength)
+	{
+		if( *pLength > iBufferLength )
+		{
+			if( pBuffer ) {
+				delete [] pBuffer;
+				pBuffer = NULL;
+				iBufferLength = 0;
+			}
+			pBuffer = new char [*pLength + 1];
+			if( pBuffer == NULL ) {
+				SetError( "Unable to allocate %ld bytes of memory to hold data", *pLength );
+				return E_OUTOFMEM;
+			}
+			memset(pBuffer, 0, (*pLength) + 1);
+			iBufferLength = *pLength;
+		}
+
+		char *p = pBuffer;
+
+		// receive the data
+		int iThisAmount = 0;
+		int iTotalReceived = 0;
+		while (iTotalReceived < (int)(*pLength))
+		{
+
+			if(select(0, &reader, NULL, NULL, &timeout)==0)
+			{
+				return E_SOCKETRECV;
+			}
+
+			iThisAmount = recv( sock, p, (*pLength) - iTotalReceived, 0 );
+			if (iThisAmount == SOCKET_ERROR)
+				return E_SOCKETRECV;
+
+			iTotalReceived += iThisAmount;
+			p += iThisAmount;
+			Sleep(100);
+		}
+
+		(*ppData) = pBuffer;
+	}
+
+	return ITS_OK;
+}
+	
+	
+////////////////////////////////////////////////////////////////////////////////////////
+// Disconnect
+int CSTATSocket::Disconnect(void)
+{
+	// release previous resources
+	if (pBuffer)
+	{
+		delete [] pBuffer;
+		pBuffer = NULL;
+		iBufferLength = 0;
+	}
+
+	shutdown(sock, SD_SEND);
+	shutdown(sock, SD_RECEIVE);
+
+	if (closesocket(sock) == SOCKET_ERROR)
+		return E_SOCKETCLOSE;
+
+	return ITS_OK;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+// 
+int CSTATSocket::Release(void)
+{
+	if (WSACleanup() == SOCKET_ERROR)
+		return E_SOCKETSHUTDOWN;
+
+	return ITS_OK;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+//	PRIVATE FUNCTIONS
+////////////////////////////////////////////////////////////////////////////////////////
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/src/stdafx.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#include "stdafx.h"
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/statlib.dep	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,158 @@
+# Microsoft Developer Studio Generated Dependency File, included by STATLib.mak
+
+.\src\cRepmisc.cpp : \
+	".\inc\cReporter.h"\
+	
+
+.\src\cReporter.cpp : \
+	".\inc\cReporter.h"\
+	
+
+.\src\cstatdataformatconverter.cpp : \
+	".\inc\cstatdataformatconverter.h"\
+	".\inc\cstatlogfile.h"\
+	".\inc\cstatreturncodes.h"\
+	".\inc\MessageReporter.h"\
+	".\inc\statcommon.h"\
+	
+
+.\src\cstatimageverify.cpp : \
+	".\inc\cstatimageverify.h"\
+	".\inc\cstatlogfile.h"\
+	".\inc\cstatreturncodes.h"\
+	".\inc\MessageReporter.h"\
+	".\inc\statcommon.h"\
+	
+
+.\src\cstatlogfile.cpp : \
+	".\inc\cstatlogfile.h"\
+	".\inc\cstatreturncodes.h"\
+	".\inc\MessageReporter.h"\
+	".\inc\statcommon.h"\
+	
+
+.\src\cstatreturncodes.cpp : \
+	".\inc\cstatreturncodes.h"\
+	
+
+..\common\src\INI.cpp : \
+	"..\common\inc\INI.h"\
+	
+
+.\src\statbitmap.cpp : \
+	".\inc\cstatdataformatconverter.h"\
+	".\inc\cstatlogfile.h"\
+	".\inc\cstatreturncodes.h"\
+	".\inc\MessageReporter.h"\
+	".\inc\statbitmap.h"\
+	".\inc\statcommon.h"\
+	
+
+.\src\STATComms.cpp : \
+	"..\..\..\Common\inc\SerialPacketSize.h"\
+	".\inc\cstatreturncodes.h"\
+	".\inc\statcommon.h"\
+	".\inc\statcomms.h"\
+	".\inc\statserial.h"\
+	".\inc\statsocket_block.h"\
+	".\inc\stattransport.h"\
+	
+
+.\src\STATEngine.cpp : \
+	"..\common\inc\INI.h"\
+	".\inc\cstatdataformatconverter.h"\
+	".\inc\cstatimageverify.h"\
+	".\inc\cstatlogfile.h"\
+	".\inc\cstatreturncodes.h"\
+	".\inc\MessageReporter.h"\
+	".\inc\ScriptProgressMonitor.h"\
+	".\inc\statcommon.h"\
+	".\inc\statcomms.h"\
+	".\inc\STATEngine.h"\
+	".\inc\statscriptdecoder.h"\
+	".\inc\stattransport.h"\
+	
+
+.\src\statexp.cpp : \
+	"..\common\inc\INI.h"\
+	".\inc\cReporter.h"\
+	".\inc\cstatdataformatconverter.h"\
+	".\inc\cstatimageverify.h"\
+	".\inc\cstatlogfile.h"\
+	".\inc\cstatreturncodes.h"\
+	".\inc\MessageReporter.h"\
+	".\inc\ScriptProgressMonitor.h"\
+	".\inc\statcommon.h"\
+	".\inc\statcomms.h"\
+	".\inc\STATEngine.h"\
+	".\inc\statexp.h"\
+	".\inc\statlist.h"\
+	".\inc\statmember.h"\
+	".\inc\statscriptdecoder.h"\
+	".\inc\stattransport.h"\
+	
+
+.\src\statlist.cpp : \
+	"..\common\inc\INI.h"\
+	".\inc\cReporter.h"\
+	".\inc\cstatdataformatconverter.h"\
+	".\inc\cstatimageverify.h"\
+	".\inc\cstatlogfile.h"\
+	".\inc\cstatreturncodes.h"\
+	".\inc\MessageReporter.h"\
+	".\inc\ScriptProgressMonitor.h"\
+	".\inc\statcommon.h"\
+	".\inc\statcomms.h"\
+	".\inc\STATEngine.h"\
+	".\inc\statlist.h"\
+	".\inc\statmember.h"\
+	".\inc\statscriptdecoder.h"\
+	".\inc\stattransport.h"\
+	
+
+.\src\statmember.cpp : \
+	"..\common\inc\INI.h"\
+	".\inc\cReporter.h"\
+	".\inc\cstatdataformatconverter.h"\
+	".\inc\cstatimageverify.h"\
+	".\inc\cstatlogfile.h"\
+	".\inc\cstatreturncodes.h"\
+	".\inc\MessageReporter.h"\
+	".\inc\ScriptProgressMonitor.h"\
+	".\inc\statcommon.h"\
+	".\inc\statcomms.h"\
+	".\inc\STATEngine.h"\
+	".\inc\statmember.h"\
+	".\inc\statscriptdecoder.h"\
+	".\inc\stattransport.h"\
+	
+
+.\src\statscriptdecoder.cpp : \
+	".\inc\cstatdataformatconverter.h"\
+	".\inc\cstatimageverify.h"\
+	".\inc\cstatlogfile.h"\
+	".\inc\cstatreturncodes.h"\
+	".\inc\MessageReporter.h"\
+	".\inc\statcommon.h"\
+	".\inc\statscriptdecoder.h"\
+	
+
+.\src\statserial.cpp : \
+	"..\..\..\Common\inc\SerialPacketSize.h"\
+	".\inc\cstatreturncodes.h"\
+	".\inc\statcommon.h"\
+	".\inc\statserial.h"\
+	".\inc\stattransport.h"\
+	
+
+.\src\statsocket_block.cpp : \
+	"..\..\..\Common\inc\SerialPacketSize.h"\
+	".\inc\cstatreturncodes.h"\
+	".\inc\statcommon.h"\
+	".\inc\statsocket_block.h"\
+	".\inc\stattransport.h"\
+	
+
+.\src\StdAfx.cpp : \
+	".\inc\StdAfx.h"\
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/statlib.dsp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,263 @@
+# Microsoft Developer Studio Project File - Name="STATLib" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=STATLib - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "STATLib.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "STATLib.mak" CFG="STATLib - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "STATLib - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "STATLib - Win32 Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName "STATLib"
+# PROP Scc_LocalPath "."
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "STATLib - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W2 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\common\inc" /I ".\inc" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "WINDOWS" /FR /Yu"stdafx.h" /FD /c
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo /out:"..\..\lib\STAT.lib"
+
+!ELSEIF  "$(CFG)" == "STATLib - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 1
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\common\inc" /I ".\inc" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "WINDOWS" /FR /FD /GZ /c
+# SUBTRACT CPP /YX /Yc /Yu
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo /out:"..\..\lib\STATd.lib"
+
+!ENDIF 
+
+# Begin Target
+
+# Name "STATLib - Win32 Release"
+# Name "STATLib - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\src\cRepmisc.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\cReporter.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\cstatdataformatconverter.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\cstatimageverify.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\cstatlogfile.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\cstatreturncodes.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\common\src\INI.cpp
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\statbitmap.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\STATComms.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\STATEngine.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\statexp.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\STATLib.dep
+# End Source File
+# Begin Source File
+
+SOURCE=.\STATLib.mak
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\statlist.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\statmember.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\statscriptdecoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\statserial.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\statsocket_block.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\StdAfx.cpp
+# ADD CPP /Yc"stdafx.h"
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\inc\cReporter.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\cstatdataformatconverter.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\cstatimageverify.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\cstatlogfile.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\cstatreturncodes.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\common\inc\INI.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\MessageReporter.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\messagetypes.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\ScriptProgressMonitor.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\inc\SerialPacketSize.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\stat.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\statbitmap.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\statcommon.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\statcomms.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\STATEngine.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\statexp.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\statlist.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\statmember.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\statscriptdecoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\statserial.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\statsocket_block.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\stattransport.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\StdAfx.h
+# End Source File
+# End Group
+# End Target
+# End Project
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/statlib.mak	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,428 @@
+# Microsoft Developer Studio Generated NMAKE File, Based on STATLib.dsp
+!IF "$(CFG)" == ""
+CFG=STATLib - Win32 Debug
+!MESSAGE No configuration specified. Defaulting to STATLib - Win32 Debug.
+!ENDIF 
+
+!IF "$(CFG)" != "STATLib - Win32 Release" && "$(CFG)" != "STATLib - Win32 Debug"
+!MESSAGE Invalid configuration "$(CFG)" specified.
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "STATLib.mak" CFG="STATLib - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "STATLib - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "STATLib - Win32 Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE 
+!ERROR An invalid configuration is specified.
+!ENDIF 
+
+!IF "$(OS)" == "Windows_NT"
+NULL=
+!ELSE 
+NULL=nul
+!ENDIF 
+
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "STATLib - Win32 Release"
+
+OUTDIR=.\Release
+INTDIR=.\Release
+# Begin Custom Macros
+OutDir=.\Release
+# End Custom Macros
+
+ALL : "..\..\lib\STAT.lib" "$(OUTDIR)\STATLib.bsc"
+
+
+CLEAN :
+	-@erase "$(INTDIR)\cRepmisc.obj"
+	-@erase "$(INTDIR)\cRepmisc.sbr"
+	-@erase "$(INTDIR)\cReporter.obj"
+	-@erase "$(INTDIR)\cReporter.sbr"
+	-@erase "$(INTDIR)\cstatdataformatconverter.obj"
+	-@erase "$(INTDIR)\cstatdataformatconverter.sbr"
+	-@erase "$(INTDIR)\cstatimageverify.obj"
+	-@erase "$(INTDIR)\cstatimageverify.sbr"
+	-@erase "$(INTDIR)\cstatlogfile.obj"
+	-@erase "$(INTDIR)\cstatlogfile.sbr"
+	-@erase "$(INTDIR)\cstatreturncodes.obj"
+	-@erase "$(INTDIR)\cstatreturncodes.sbr"
+	-@erase "$(INTDIR)\INI.obj"
+	-@erase "$(INTDIR)\INI.sbr"
+	-@erase "$(INTDIR)\statbitmap.obj"
+	-@erase "$(INTDIR)\statbitmap.sbr"
+	-@erase "$(INTDIR)\STATComms.obj"
+	-@erase "$(INTDIR)\STATComms.sbr"
+	-@erase "$(INTDIR)\STATEngine.obj"
+	-@erase "$(INTDIR)\STATEngine.sbr"
+	-@erase "$(INTDIR)\statexp.obj"
+	-@erase "$(INTDIR)\statexp.sbr"
+	-@erase "$(INTDIR)\STATLib.pch"
+	-@erase "$(INTDIR)\statlist.obj"
+	-@erase "$(INTDIR)\statlist.sbr"
+	-@erase "$(INTDIR)\statmember.obj"
+	-@erase "$(INTDIR)\statmember.sbr"
+	-@erase "$(INTDIR)\statscriptdecoder.obj"
+	-@erase "$(INTDIR)\statscriptdecoder.sbr"
+	-@erase "$(INTDIR)\statserial.obj"
+	-@erase "$(INTDIR)\statserial.sbr"
+	-@erase "$(INTDIR)\statsocket_block.obj"
+	-@erase "$(INTDIR)\statsocket_block.sbr"
+	-@erase "$(INTDIR)\StdAfx.obj"
+	-@erase "$(INTDIR)\StdAfx.sbr"
+	-@erase "$(INTDIR)\vc60.idb"
+	-@erase "$(OUTDIR)\STATLib.bsc"
+	-@erase "..\..\lib\STAT.lib"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MT /W3 /GX /O2 /I "..\common\inc" /I ".\inc" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "WINDOWS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\STATLib.pch" /Yu"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\STATLib.bsc" 
+BSC32_SBRS= \
+	"$(INTDIR)\cRepmisc.sbr" \
+	"$(INTDIR)\cReporter.sbr" \
+	"$(INTDIR)\cstatdataformatconverter.sbr" \
+	"$(INTDIR)\cstatimageverify.sbr" \
+	"$(INTDIR)\cstatlogfile.sbr" \
+	"$(INTDIR)\cstatreturncodes.sbr" \
+	"$(INTDIR)\INI.sbr" \
+	"$(INTDIR)\statbitmap.sbr" \
+	"$(INTDIR)\STATComms.sbr" \
+	"$(INTDIR)\STATEngine.sbr" \
+	"$(INTDIR)\statexp.sbr" \
+	"$(INTDIR)\statlist.sbr" \
+	"$(INTDIR)\statmember.sbr" \
+	"$(INTDIR)\statscriptdecoder.sbr" \
+	"$(INTDIR)\statserial.sbr" \
+	"$(INTDIR)\statsocket_block.sbr" \
+	"$(INTDIR)\StdAfx.sbr"
+
+"$(OUTDIR)\STATLib.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+    $(BSC32) @<<
+  $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LIB32=link.exe -lib
+LIB32_FLAGS=/nologo /out:"..\..\lib\STAT.lib" 
+LIB32_OBJS= \
+	"$(INTDIR)\cRepmisc.obj" \
+	"$(INTDIR)\cReporter.obj" \
+	"$(INTDIR)\cstatdataformatconverter.obj" \
+	"$(INTDIR)\cstatimageverify.obj" \
+	"$(INTDIR)\cstatlogfile.obj" \
+	"$(INTDIR)\cstatreturncodes.obj" \
+	"$(INTDIR)\INI.obj" \
+	"$(INTDIR)\statbitmap.obj" \
+	"$(INTDIR)\STATComms.obj" \
+	"$(INTDIR)\STATEngine.obj" \
+	"$(INTDIR)\statexp.obj" \
+	"$(INTDIR)\statlist.obj" \
+	"$(INTDIR)\statmember.obj" \
+	"$(INTDIR)\statscriptdecoder.obj" \
+	"$(INTDIR)\statserial.obj" \
+	"$(INTDIR)\statsocket_block.obj" \
+	"$(INTDIR)\StdAfx.obj"
+
+"..\..\lib\STAT.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
+    $(LIB32) @<<
+  $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
+<<
+
+!ELSEIF  "$(CFG)" == "STATLib - Win32 Debug"
+
+OUTDIR=.\Debug
+INTDIR=.\Debug
+# Begin Custom Macros
+OutDir=.\Debug
+# End Custom Macros
+
+ALL : "..\..\lib\STATd.lib" "$(OUTDIR)\STATLib.pch" "$(OUTDIR)\STATLib.bsc"
+
+
+CLEAN :
+	-@erase "$(INTDIR)\cRepmisc.obj"
+	-@erase "$(INTDIR)\cRepmisc.sbr"
+	-@erase "$(INTDIR)\cReporter.obj"
+	-@erase "$(INTDIR)\cReporter.sbr"
+	-@erase "$(INTDIR)\cstatdataformatconverter.obj"
+	-@erase "$(INTDIR)\cstatdataformatconverter.sbr"
+	-@erase "$(INTDIR)\cstatimageverify.obj"
+	-@erase "$(INTDIR)\cstatimageverify.sbr"
+	-@erase "$(INTDIR)\cstatlogfile.obj"
+	-@erase "$(INTDIR)\cstatlogfile.sbr"
+	-@erase "$(INTDIR)\cstatreturncodes.obj"
+	-@erase "$(INTDIR)\cstatreturncodes.sbr"
+	-@erase "$(INTDIR)\INI.obj"
+	-@erase "$(INTDIR)\INI.sbr"
+	-@erase "$(INTDIR)\statbitmap.obj"
+	-@erase "$(INTDIR)\statbitmap.sbr"
+	-@erase "$(INTDIR)\STATComms.obj"
+	-@erase "$(INTDIR)\STATComms.sbr"
+	-@erase "$(INTDIR)\STATEngine.obj"
+	-@erase "$(INTDIR)\STATEngine.sbr"
+	-@erase "$(INTDIR)\statexp.obj"
+	-@erase "$(INTDIR)\statexp.sbr"
+	-@erase "$(INTDIR)\STATLib.pch"
+	-@erase "$(INTDIR)\statlist.obj"
+	-@erase "$(INTDIR)\statlist.sbr"
+	-@erase "$(INTDIR)\statmember.obj"
+	-@erase "$(INTDIR)\statmember.sbr"
+	-@erase "$(INTDIR)\statscriptdecoder.obj"
+	-@erase "$(INTDIR)\statscriptdecoder.sbr"
+	-@erase "$(INTDIR)\statserial.obj"
+	-@erase "$(INTDIR)\statserial.sbr"
+	-@erase "$(INTDIR)\statsocket_block.obj"
+	-@erase "$(INTDIR)\statsocket_block.sbr"
+	-@erase "$(INTDIR)\StdAfx.obj"
+	-@erase "$(INTDIR)\StdAfx.sbr"
+	-@erase "$(INTDIR)\vc60.idb"
+	-@erase "$(INTDIR)\vc60.pdb"
+	-@erase "$(OUTDIR)\STATLib.bsc"
+	-@erase "..\..\lib\STATd.lib"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\common\inc" /I ".\inc" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "WINDOWS" /FR"$(INTDIR)\\" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c 
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\STATLib.bsc" 
+BSC32_SBRS= \
+	"$(INTDIR)\cRepmisc.sbr" \
+	"$(INTDIR)\cReporter.sbr" \
+	"$(INTDIR)\cstatdataformatconverter.sbr" \
+	"$(INTDIR)\cstatimageverify.sbr" \
+	"$(INTDIR)\cstatlogfile.sbr" \
+	"$(INTDIR)\cstatreturncodes.sbr" \
+	"$(INTDIR)\INI.sbr" \
+	"$(INTDIR)\statbitmap.sbr" \
+	"$(INTDIR)\STATComms.sbr" \
+	"$(INTDIR)\STATEngine.sbr" \
+	"$(INTDIR)\statexp.sbr" \
+	"$(INTDIR)\statlist.sbr" \
+	"$(INTDIR)\statmember.sbr" \
+	"$(INTDIR)\statscriptdecoder.sbr" \
+	"$(INTDIR)\statserial.sbr" \
+	"$(INTDIR)\statsocket_block.sbr" \
+	"$(INTDIR)\StdAfx.sbr"
+
+"$(OUTDIR)\STATLib.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+    $(BSC32) @<<
+  $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LIB32=link.exe -lib
+LIB32_FLAGS=/nologo /out:"..\..\lib\STATd.lib" 
+LIB32_OBJS= \
+	"$(INTDIR)\cRepmisc.obj" \
+	"$(INTDIR)\cReporter.obj" \
+	"$(INTDIR)\cstatdataformatconverter.obj" \
+	"$(INTDIR)\cstatimageverify.obj" \
+	"$(INTDIR)\cstatlogfile.obj" \
+	"$(INTDIR)\cstatreturncodes.obj" \
+	"$(INTDIR)\INI.obj" \
+	"$(INTDIR)\statbitmap.obj" \
+	"$(INTDIR)\STATComms.obj" \
+	"$(INTDIR)\STATEngine.obj" \
+	"$(INTDIR)\statexp.obj" \
+	"$(INTDIR)\statlist.obj" \
+	"$(INTDIR)\statmember.obj" \
+	"$(INTDIR)\statscriptdecoder.obj" \
+	"$(INTDIR)\statserial.obj" \
+	"$(INTDIR)\statsocket_block.obj" \
+	"$(INTDIR)\StdAfx.obj"
+
+"..\..\lib\STATd.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
+    $(LIB32) @<<
+  $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
+<<
+
+!ENDIF 
+
+.c{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cpp{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cxx{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.c{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cpp{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cxx{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+
+!IF "$(NO_EXTERNAL_DEPS)" != "1"
+!IF EXISTS("STATLib.dep")
+!INCLUDE "STATLib.dep"
+!ELSE 
+!MESSAGE Warning: cannot find "STATLib.dep"
+!ENDIF 
+!ENDIF 
+
+
+!IF "$(CFG)" == "STATLib - Win32 Release" || "$(CFG)" == "STATLib - Win32 Debug"
+SOURCE=.\src\cRepmisc.cpp
+
+"$(INTDIR)\cRepmisc.obj"	"$(INTDIR)\cRepmisc.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\STATLib.pch"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=.\src\cReporter.cpp
+
+"$(INTDIR)\cReporter.obj"	"$(INTDIR)\cReporter.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\STATLib.pch"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=.\src\cstatdataformatconverter.cpp
+
+"$(INTDIR)\cstatdataformatconverter.obj"	"$(INTDIR)\cstatdataformatconverter.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\STATLib.pch"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=.\src\cstatimageverify.cpp
+
+"$(INTDIR)\cstatimageverify.obj"	"$(INTDIR)\cstatimageverify.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\STATLib.pch"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=.\src\cstatlogfile.cpp
+
+"$(INTDIR)\cstatlogfile.obj"	"$(INTDIR)\cstatlogfile.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\STATLib.pch"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=.\src\cstatreturncodes.cpp
+
+"$(INTDIR)\cstatreturncodes.obj"	"$(INTDIR)\cstatreturncodes.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\STATLib.pch"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\src\INI.cpp
+
+!IF  "$(CFG)" == "STATLib - Win32 Release"
+
+CPP_SWITCHES=/nologo /MT /W3 /GX /O2 /I "..\common\inc" /I ".\inc" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "WINDOWS" /FR"$(INTDIR)\\" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+
+"$(INTDIR)\INI.obj"	"$(INTDIR)\INI.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) @<<
+  $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ELSEIF  "$(CFG)" == "STATLib - Win32 Debug"
+
+CPP_SWITCHES=/nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\common\inc" /I ".\inc" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "WINDOWS" /FR"$(INTDIR)\\" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c 
+
+"$(INTDIR)\INI.obj"	"$(INTDIR)\INI.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) @<<
+  $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ENDIF 
+
+SOURCE=.\src\statbitmap.cpp
+
+"$(INTDIR)\statbitmap.obj"	"$(INTDIR)\statbitmap.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\STATLib.pch"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=.\src\STATComms.cpp
+
+"$(INTDIR)\STATComms.obj"	"$(INTDIR)\STATComms.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\STATLib.pch"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=.\src\STATEngine.cpp
+
+"$(INTDIR)\STATEngine.obj"	"$(INTDIR)\STATEngine.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\STATLib.pch"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=.\src\statexp.cpp
+
+"$(INTDIR)\statexp.obj"	"$(INTDIR)\statexp.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\STATLib.pch"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=.\src\statlist.cpp
+
+"$(INTDIR)\statlist.obj"	"$(INTDIR)\statlist.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\STATLib.pch"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=.\src\statmember.cpp
+
+"$(INTDIR)\statmember.obj"	"$(INTDIR)\statmember.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\STATLib.pch"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=.\src\statscriptdecoder.cpp
+
+"$(INTDIR)\statscriptdecoder.obj"	"$(INTDIR)\statscriptdecoder.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\STATLib.pch"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=.\src\statserial.cpp
+
+"$(INTDIR)\statserial.obj"	"$(INTDIR)\statserial.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\STATLib.pch"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=.\src\statsocket_block.cpp
+
+"$(INTDIR)\statsocket_block.obj"	"$(INTDIR)\statsocket_block.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\STATLib.pch"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+SOURCE=.\src\StdAfx.cpp
+
+!IF  "$(CFG)" == "STATLib - Win32 Release"
+
+CPP_SWITCHES=/nologo /MT /W3 /GX /O2 /I "..\common\inc" /I ".\inc" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "WINDOWS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\STATLib.pch" /Yc"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+
+"$(INTDIR)\StdAfx.obj"	"$(INTDIR)\StdAfx.sbr"	"$(INTDIR)\STATLib.pch" : $(SOURCE) "$(INTDIR)"
+	$(CPP) @<<
+  $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ELSEIF  "$(CFG)" == "STATLib - Win32 Debug"
+
+CPP_SWITCHES=/nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\common\inc" /I ".\inc" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "WINDOWS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\STATLib.pch" /Yc"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c 
+
+"$(INTDIR)\StdAfx.obj"	"$(INTDIR)\StdAfx.sbr"	"$(INTDIR)\STATLib.pch" : $(SOURCE) "$(INTDIR)"
+	$(CPP) @<<
+  $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ENDIF 
+
+
+!ENDIF 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/lib/updatelib.bat	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,33 @@
+@rem
+@rem Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description: 
+@rem
+@@rem
+
+rem
+rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+
+rem which accompanies this distribution, and is available
+
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/perl/statapi.pm	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,1874 @@
+#
+# Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:  
+#
+
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+package Symbian::StatAPI;
+require 5.000;
+use Win32::API;
+use Win32::TieRegistry(Delimiter=>"/");
+use IO::File;
+use File::Basename;
+use LWP::Simple;
+use LWP::UserAgent;
+use HTTP::Request;
+use HTTP::Response;
+use Exporter;
+use vars qw (@ISA @EXPORT $VERSION);
+@ISA		= qw(Exporter);
+@EXPORT		= qw(
+				&set_dll_folder
+				&set_working_folder
+				&initialise
+				&get_version
+				&set_connection_logging
+				&close_connection_logging
+				&get_device_log_file
+				&set_screenshot_dir
+				&get_last_error
+				&connect_to_target
+				&connect_to_target_multithreaded
+				&disconnect_from_target
+				&set_command_delay
+				&set_image_verification
+				&set_command_logging
+				&get_screenshot
+				&get_device_info
+				&touch_screen
+				&start_application
+				&start_program
+				&open_application
+				&close_application
+				&basic_key_sequence
+				&control_keystroke
+				&combination_keystroke
+				&pause
+				&start_eshell
+				&stop_eshell
+				&copy_commonfile_to_target
+				&copy_testfile_to_target
+				&copy_buildfile_to_target
+				&move_from_target
+				&copy_from_target
+				&remove_unwanted_file
+				&send_command_file
+				&send_raw_command
+				&hold_key
+				&remove_file
+				&create_folder
+				&remove_folder);
+
+
+##########################################################################
+# AUTO-GENERATED BLOCK - DO NOT MODIFY
+##########################################################################
+$VERSION = 3.3;
+##########################################################################
+
+
+# global variables
+my $FUNCTION;			# dll function entrypoint
+my $dllname;			# dll to call
+my $def_connection_type;	# default (global) connection type
+my $def_codetype;		# default (global) code type
+my $lasterror;			# last error thrown
+my $imagedir;			# image retrieve location
+my $logfile;			# log file to write to
+my $senddir;			# temp send directory
+my $recvdir;			# temp receive directory
+my $workdir;			# stat working directory
+my $statdir;			# stat dll location
+my $loglevel;			# internal logging level
+
+#TMS required vars
+my $httpserver;  		# http server for downloading files
+my $runno;			# needed to obtain build location to download files
+my $commondir;			# common files temp dir
+my $builddir;			# build files location
+
+
+################################################################
+# exported functions
+# Come in 2 levels: Global - apply to all connections, 
+#                   Local - apply to individual connections
+################################################################
+
+################################################################
+# GLOBAL ENTRYPOINTS
+# Apply to all connections
+################################################################
+
+################################################################
+# 	set_dll_folder(<dll folder>);
+#
+# 	Required parameters:
+#	$statdir 	e.g. "C:\epoc32\tools\STAT";
+#
+################################################################
+sub set_dll_folder
+{
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $dir = $cmdref->[0];
+
+	$statdir = $dir;
+
+	return 1;
+}
+
+
+################################################################
+# 	set_working_folder(<working folder>);
+#
+# 	Required parameters:
+#	$statdir 	e.g. "C:\apps\STAT";
+#
+################################################################
+sub set_working_folder
+{
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $dir = $cmdref->[0];
+
+	$workdir = $dir;
+
+	return 1;
+}
+
+
+################################################################
+# Must be the first function called
+# 	initialise(@ARGV);
+# 	initialise(<dll name>, <connection type>, <code type>, <log level>, <log file>, <send dir>, <recv dir>, <common dir>, <httpserver>, <runno>, <builddir>);
+#
+# 	Required parameters:
+#	$dllname 	e.g. STAT.DLL;
+#
+#	Needed only if connection/code types won't change throughout the script
+#	$def_connection_type	e.g. 2 (Symbian Serial)
+#	$def_codetype		e.g. COM2
+#
+#	Needed only for logging
+#	$loglevel 	# internal logging level:
+			# 0 = terse
+			# 1 = noraml
+			# 2 = verbose
+			# 3 = Perl output redirected to log file
+#	$logfile 	e.g. C:\Apps\Stat\LogFiles\StatPerl.log;
+#
+#	Needed only for sending/receiving files (must end in 'slash')
+#	$senddir 	e.g. auto/12267/send/
+#	$recvdir 	e.g. auto/12267/recv/
+#
+#	Needed only for sending common files to target (TMS only - must end in 'slash')
+#	$commondir 	e.g. auto/12267/common/
+
+#	Needed only for sending build files to target (TMS only)
+#	$httpserver e.g. http://lon-adminpool01:8080/AutoTest
+#	$runno	e.g. 150
+#	$builddir 	e.g. auto/12267/build/	(must end in 'slash')
+#
+################################################################
+sub initialise
+{
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	$dllname = $cmdref->[0];
+	$def_connection_type = $cmdref->[1];
+	$def_codetype = $cmdref->[2];
+	$loglevel = $cmdref->[3];
+	$logfile = $cmdref->[4];
+	$senddir = $cmdref->[5];
+	$recvdir = $cmdref->[6];
+	$commondir = $cmdref->[7];
+	$httpserver = $cmdref->[8];
+	$runno = $cmdref->[9];
+	$builddir = $cmdref->[10];
+
+	# required parameter
+	if (!$dllname)
+	{
+		$lasterror = "DLL name not supplied!";
+		Line(get_last_error());
+		return 0;
+	}
+
+	# adjust log level if necessary
+	if ($loglevel < 0)
+	{
+		$loglevel = 0;
+	}
+	if ($loglevel > 3)
+	{
+		$loglevel = 3;
+	}
+	
+	# redirect output to log file if we've supplied one, else will go to screen
+	if ($logfile and ($loglevel eq 3))
+	{
+		print "Redirecting output to [$logfile]...\n";
+		open(STDOUT, ">> $logfile");
+		open(STDERR, ">> $logfile");
+	}
+		
+	# reverse '/' to '\\' in filenames
+	$senddir =~ s/\//\\/g;
+	$recvdir =~ s/\//\\/g;
+	$commondir =~ s/\//\\/g;
+	$builddir =~ s/\//\\/g;
+
+	if (!$workdir)
+	{
+		$workdir = "C:\\apps\\stat";
+	}
+	Line("Working directory: $workdir\n");
+
+	if (!$statdir)
+	{
+		$statdir = "C:\\epoc32\\tools\\STAT";
+	}
+	Line("Stat directory: $statdir\n");
+
+	Line("Initialising STAT API:\n  DLLName [$dllname]\n  Default Connection [$def_connection_type]\n  Default Code Type [$def_codetype]\n  Log Level [$loglevel]\n  LogFile [$logfile]\n  Send [$senddir]\n  Recv [$recvdir]\n  Common [$commondir]\n  HTTPServer [$httpserver]\n  Run No [$runno]\n  Build [$builddir]\n");
+	return 1;
+}
+
+
+################################################################
+# Get the version of the dll
+################################################################
+sub get_version
+{
+	$FUNCTION = new Win32::API("$statdir/$dllname", "StdVersion", [V], P);
+	if (defined($FUNCTION))
+	{
+		$ret = $FUNCTION->Call();
+		if ($ret)
+		{
+			return $ret;
+		}
+		else
+		{
+			$lasterror = "Version could not be established\n";
+		}
+	}
+	else
+	{
+		$lasterror = "Function StdVersion not found\n";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Set logging of stat connection attempts
+# param0: logfile
+################################################################
+sub set_connection_logging
+{
+	Line("Setting connection logging...");
+	if ($loglevel and $logfile)
+	{
+		$FUNCTION = new Win32::API("$statdir/$dllname", "StdSetConnectionLogging", [P], I);
+		if (defined($FUNCTION))
+		{
+			Line("Logging to $logfile");
+			$ret = $FUNCTION->Call($logfile);
+			if ($ret)
+			{
+				return 1;
+			}
+			else
+			{
+				GetDllError(0);
+			}
+		}
+		else
+		{
+			$lasterror = "Function StdSetConnectionLogging not found\n";
+		}
+	}
+	else
+	{
+		$lasterror = "Logging disabled or logfile not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Set logging of stat connection attempts
+# param0: logfile
+################################################################
+sub close_connection_logging
+{
+	Line("Closing connection logging...");
+	if ($loglevel and $logfile)
+	{
+		$FUNCTION = new Win32::API("$statdir/$dllname", "StdCloseConnectionLogging", [], V);
+		if (defined($FUNCTION))
+		{
+			Line("Stopping logging to $logfile");
+			$FUNCTION->Call();
+			return 1;
+		}
+		else
+		{
+			$lasterror = "Function StdCloseConnectionLogging not found\n";
+		}
+	}
+	else
+	{
+		$lasterror = "Logging disabled or logfile not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Retrieve the device log file to our log and truncate it at that point on the device
+################################################################
+sub get_device_log_file
+{
+	Line("Retrieving log file...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+
+	if ($loglevel and $logfile)
+	{
+		if ($hndl)
+		{
+			if (SendCommand($hndl, "<B><G><E>"))
+			{
+				return 1;
+			}
+		}
+		else
+		{
+			$lasterror = "Handle not supplied";
+		}
+	}
+	else
+	{
+		$lasterror = "Logging disabled or logfile not supplied";
+	}
+	
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Set the output directory for screenshots
+################################################################
+sub set_screenshot_dir
+{
+	Line("Setting screenshot dir...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $dir = $cmdref->[0];
+	if ($dir)
+	{
+		$imagedir = $dir;
+
+		# reverse '/' to '\\' for DOS
+		$imagedir =~ s/\//\\/g;
+		
+		Line("Directory ($imagedir)");
+		return 1;
+	}
+
+	$lasterror = "Directory not supplied";
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Get the last error that occurred
+################################################################
+sub get_last_error
+{
+	# add prefix if not one already	
+	if (!(substr($lasterror, 0, 8) =~ "ERROR : "))
+	{
+		$lasterror = "ERROR : $lasterror";
+	}
+	
+	return $lasterror;
+}
+
+
+################################################################
+# LOCAL ENTRYPOINTS
+# Apply to individual connection
+################################################################
+
+################################################################
+# Connect to the target device
+################################################################
+sub connect_to_target
+{
+	Line("Connecting to $statdir/$dllname...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $connection_type = $cmdref->[0];
+	my $codetype = $cmdref->[1];
+
+	# if we haven't supplied a connection type through here, maybe it was defined during initialise()
+	if (!$connection_type)
+	{
+		$connection_type = $def_connection_type;
+	}
+
+	# if we haven't supplied a code type through here, maybe it was defined during initialise()
+	if (!$codetype)
+	{
+		$codetype = $def_codetype;
+	}
+	
+	if ($connection_type)
+	{
+		if ($codetype)
+		{
+			$FUNCTION = new Win32::API("$statdir/$dllname", "StdConnect", [I, P, P, P], I);
+			if (defined($FUNCTION))
+			{
+				Line("Connecting ($connection_type, $codetype)...");
+				my $hndl = $FUNCTION->Call($connection_type, $codetype, 0, 0);
+				if ($hndl)
+				{
+					return $hndl;
+				}
+				else
+				{
+					GetDllError(0);
+				}
+			}
+			else
+			{
+				$lasterror = "Function StdConnect not found";
+			}
+		}
+		else
+		{
+			$lasterror = "Code type not supplied";
+		}
+	}
+	else
+	{
+		$lasterror = "Connection type not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Connect to the target device in a multithreaded environment
+################################################################
+sub connect_to_target_multithreaded
+{
+	Line("Connecting to $statdir/$dllname (" . get_version() . ")...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $connection_type = $cmdref->[0];
+	my $codetype = $cmdref->[1];
+
+	# if we haven't supplied a connection type through here, maybe it was defined during initialise()
+	if (!$connection_type)
+	{
+		$connection_type = $def_connection_type;
+	}
+
+	# if we haven't supplied a code type through here, maybe it was defined during initialise()
+	if (!$codetype)
+	{
+		$codetype = $def_codetype;
+	}
+	
+	if ($connection_type)
+	{
+		if ($codetype)
+		{
+			$FUNCTION = new Win32::API("$statdir/$dllname", "StdConnectMT", [I, P], I);
+			if (defined($FUNCTION))
+			{
+				Line("Connecting ($connection_type, $codetype)...");
+				my $hndl = $FUNCTION->Call($connection_type, $codetype);
+				if ($hndl)
+				{
+					return $hndl;
+				}
+				else
+				{
+					GetDllError(0);
+				}
+			}
+			else
+			{
+				$lasterror = "Function StdConnect not found";
+			}
+		}
+		else
+		{
+			$lasterror = "Code type not supplied";
+		}
+	}
+	else
+	{
+		$lasterror = "Connection type not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Disconnect from the target device
+################################################################
+sub disconnect_from_target
+{
+	Line("Disconnecting from $statdir/$dllname...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+
+	if ($hndl)
+	{
+		$FUNCTION = new Win32::API("$statdir/$dllname", "StdDisconnect", [I], I);
+		if (defined($FUNCTION))
+		{
+			Line("Disconnecting $statdir/$dllname ($hndl)...");
+			$ret = $FUNCTION->Call($hndl);
+			if ($ret)
+			{
+				return 1;
+			}
+			else
+			{
+				GetDllError($hndl);
+			}
+		}
+		else
+		{
+			$lasterror = "Function StdDisconnect not found";
+		}
+	}
+	else
+	{
+		$lasterror = "Handle not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Set logging of stat commands
+# param0: logfile
+# param1: log level
+# param2: append or overwrite
+# param3: reserved
+# param4: reserved
+################################################################
+sub set_command_logging
+{
+	Line("Setting command logging...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	if (($loglevel > 1) and $logfile)
+	{
+		if ($hndl)
+		{
+			if ($logfile)
+			{
+				$FUNCTION = new Win32::API("$statdir/$dllname", "StdSetCommandLogging", [I, P, P, I, I, P, P], I);
+				if (defined($FUNCTION))
+				{
+					Line("Logging to ($hndl, $logfile, $actual_level)");
+					$ret = $FUNCTION->Call($hndl, $logfile, 0, $loglevel, 0, 0, 0);
+					if ($ret)
+					{
+						return 1;
+					}
+					else
+					{
+						GetDllError($hndl);
+					}
+				}
+				else
+				{
+					$lasterror = "Function StdSetCommandLogging not found\n";
+				}
+			}
+			else
+			{
+				$lasterror = "Logfile not supplied";
+			}
+		}
+		else
+		{
+			$lasterror = "Handle not supplied";
+		}
+	}
+	else
+	{
+		$lasterror = "Logging level incorrect or logfile not supplied";
+	}
+	
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Set command delay
+# param0: delay (in milliseconds).  Range 100 (default) -> 30,000
+# The delay is inserted between complete commands, not between
+# individual keystrokes.
+################################################################
+sub set_command_delay
+{
+	Line("Setting command delay...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	my $delay = $cmdref->[1];
+	if ($hndl)
+	{
+		if ($delay)
+		{
+			$FUNCTION = new Win32::API("$statdir/$dllname", "StdSetCommandDelay", [I, I], I);
+			if (defined($FUNCTION))
+			{
+				Line("Delay ($hndl, $delay)");
+				$ret = $FUNCTION->Call($hndl, $delay);
+				if ($ret)
+				{
+					return 1;
+				}
+				else
+				{
+					GetDllError($hndl);
+				}
+			}
+			else
+			{
+				$lasterror = "Function StdSetCommandDelay not found\n";
+			}
+		}
+		else
+		{
+			$lasterror = "Delay not supplied";
+		}
+	}
+	else
+	{
+		$lasterror = "Handle not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Set image verification
+# param0: Ref Dir (string) - the directory where the reference 
+# images are located
+# param1: Remove old images (bool)
+# param2: Fudge factor - what percentage (0 -> 100%) of mismatched 
+# pixels are still considered to be a match
+################################################################
+sub set_image_verification
+{
+	Line("Setting image verification...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	my $refdir = $cmdref->[1];
+	my $removeImages = $cmdref->[2];
+	my $fudgeFactor = $cmdref->[3];
+	if ($hndl)
+	{
+		if ($refdir)
+		{
+			$FUNCTION = new Win32::API("$statdir/$dllname", "StdSetImageVerification", [I, P, I, I], I);
+			if (defined($FUNCTION))
+			{
+				Line("Reference Directory ($hndl, $refdir, $removeImages, $fudgeFactor)");
+				$ret = $FUNCTION->Call($hndl, $refdir, $removeImages, $fudgeFactor);
+				if ($ret)
+				{
+					return 1;
+				}
+				else
+				{
+					GetDllError($hndl);
+				}
+			}
+			else
+			{
+				$lasterror = "Function StdSetImageVerification not found\n";
+			}
+		}
+		else
+		{
+			$lasterror = "Reference Image Directory not supplied";
+		}
+	}
+	else
+	{
+		$lasterror = "Handle not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Get a target screenshot
+################################################################
+sub get_screenshot
+{
+	Line("Getting screenshot...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	my $name = $cmdref->[1];
+	my $command;
+	if ($hndl)
+	{
+		if ($name)
+		{
+			if ($imagedir)
+			{
+				$command = "<B><#image $imagedir/><S$name><E>";
+			}
+			else
+			{
+				$command = "<B><S$name><E>";
+			}
+		}	
+		else
+		{
+			if ($imagedir)
+			{
+				$command = "<B><#image $imagedir/><S><E>";
+			}
+			else
+			{
+				$command = "<B><S><E>";
+			}
+		}
+
+		if (SendCommand($hndl, $command))
+		{
+			return 1;
+		}
+	}
+	else
+	{
+		$lasterror = "Handle not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Get Device Information
+################################################################
+sub get_device_info
+{
+	Line("Getting device info...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+
+	if (SendCommand($hndl, "<B><D><E>"))
+	{
+		return 1;
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# 'Touch' the screen at specified co-ordinates
+################################################################
+sub touch_screen
+{
+	Line("Touching screen...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	my $xx = $cmdref->[1];
+	my $yy = $cmdref->[2];
+	if ($hndl)
+	{
+		if ($xx and $yy)
+		{
+			if (SendCommand($hndl, "<B><I$xx,$yy><E>"))
+			{
+				return 1;
+			}
+		}
+		else
+		{
+			$lasterror = "X-Y co-ordinates not specified";
+		}
+	}
+	else
+	{
+		$lasterror = "Handle not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Start an application and create a new file
+################################################################
+sub start_application
+{
+	Line("Starting application...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	my $name = $cmdref->[1];
+	my $doc = $cmdref->[2];
+	if ($hndl)
+	{
+		if ($name)
+		{
+			my $command;
+			if ($doc)
+			{
+				$command = "<B><A$name,$doc><E>";
+			}
+			else
+			{
+				$command = "<B><A$name><E>";
+			}
+	
+			if (SendCommand($hndl, $command))
+			{
+				return 1;
+			}
+		}
+		else
+		{
+			$lasterror = "Application name not supplied";
+		}
+	}
+	else
+	{
+		$lasterror = "Handle not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Start a program with parameters
+################################################################
+sub start_program
+{
+	Line("Starting program...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	my $name = $cmdref->[1];
+	my $param = $cmdref->[2];
+	if ($hndl)
+	{
+		if ($name)
+		{
+			my $command;
+			if ($param)
+			{
+				$command = "<B><J$name,$param><E>";
+			}
+			else
+			{
+				$command = "<B><J$name><E>";
+			}
+	
+			if (SendCommand($hndl, $command))
+			{
+				return 1;
+			}
+		}
+		else
+		{
+			$lasterror = "Program name not supplied";
+		}
+	}
+	else
+	{
+		$lasterror = "Handle not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Start an application and open an existing new file
+################################################################
+sub open_application
+{
+	Line("Opening application...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	my $name = $cmdref->[1];
+	my $doc = $cmdref->[2];
+	if ($hndl)
+	{
+		if ($name and $doc)
+		{
+			if (SendCommand($hndl, "<B><F$name,$doc><E>"))
+			{
+				return 1;
+			}
+		}
+		else
+		{
+			$lasterror = "Application name and file not supplied";
+		}
+	}
+	else
+	{
+		$lasterror = "Handle not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Close the current application
+################################################################
+sub close_application
+{
+	Line("Closing application...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	if ($hndl)
+	{
+		if (SendCommand($hndl, "<B><C><E>"))
+		{
+			return 1;
+		}
+	}
+	else
+	{
+		$lasterror = "Handle not supplied";
+	}
+	
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Send a sequence of basic keystrokes
+################################################################
+sub basic_key_sequence
+{
+	Line("Sending basic key sequence...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	my $sequence = $cmdref->[1];
+	if ($hndl)
+	{
+		if ($sequence)
+		{
+			if (SendCommand($hndl, "<B><K$sequence><E>"))
+			{
+				return 1;
+			}
+		}
+		else
+		{
+			$lasterror = "Key sequence not supplied";
+		}
+	}
+	else
+	{
+		$lasterror = "Handle not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Send a control keystroke
+################################################################
+sub control_keystroke
+{
+	Line("Sending control keystroke...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	my $keystroke = $cmdref->[1];
+	if ($hndl)
+	{
+		if ($keystroke)
+		{
+			if (SendCommand($hndl, "<B><L$keystroke><E>"))
+			{
+				return 1;
+			}
+		}
+		else
+		{
+			$lasterror = "Control keystroke not supplied";
+		}
+	}
+	else
+	{
+		$lasterror = "Handle not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Send a combination keystroke
+################################################################
+sub combination_keystroke
+{
+	Line("Sending combination keystroke...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	my $combination = $cmdref->[1];
+	if ($hndl)
+	{
+		if ($combination)
+		{
+			if (SendCommand($hndl, "<B><M$combination><E>"))
+			{
+				return 1;
+			}
+		}
+		else
+		{
+			$lasterror = "Combination keystroke not supplied";
+		}
+	}
+	else
+	{
+		$lasterror = "Handle not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Pause for milliseconds
+################################################################
+sub pause
+{
+	Line("Pausing...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	my $pause = $cmdref->[1];
+	if ($hndl)
+	{
+		if ($pause)
+		{
+			if (SendCommand($hndl, "<B><P$pause><E>"))
+			{
+				return 1;
+			}
+		}
+		else
+		{
+			$lasterror = "Value not supplied";
+		}
+	}
+	else
+	{
+		$lasterror = "Handle not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Start ESHELL command interpreter
+################################################################
+sub start_eshell
+{
+	Line("Starting ESHELL...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	if ($hndl)
+	{
+		if (SendCommand($hndl, "<B><!><E>"))
+		{
+			return 1;
+		}
+	}
+	else
+	{
+		$lasterror = "Handle not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Stop ESHELL command interpreter
+################################################################
+sub stop_eshell
+{
+	Line("Stopping ESHELL...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	if ($hndl)
+	{
+		if (SendCommand($hndl, "<B><!!><E>"))
+		{
+			return 1;
+		}
+	}
+	else
+	{
+		$lasterror = "Handle not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Transfer (copy) common test file to target.  Copies a 'common'
+# test file to the target board.
+################################################################
+sub copy_commonfile_to_target
+{
+	Line("Copying commonfile file to target...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	my $source = $cmdref->[1];
+	my $dest = $cmdref->[2];
+	if ($hndl)
+	{
+		if ($source and $dest)
+		{
+			if (SendCommand($hndl, "<B><T$commondir$source,$dest><E>"))
+			{
+				return 1;
+			}
+		}
+		else
+		{
+			$lasterror = "Source and/or target names not supplied";
+		}
+	}
+	else
+	{
+		$lasterror = "Handle not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Transfer (copy) test file to target.  Copies a specific test 
+# file to the target board.
+################################################################
+sub copy_testfile_to_target
+{
+	Line("Copying testfile file to target...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	my $source = $cmdref->[1];
+	my $dest = $cmdref->[2];
+	if ($hndl)
+	{
+		if ($source and $dest)
+		{
+			if (SendCommand($hndl, "<B><T$senddir$source,$dest><E>"))
+			{
+				return 1;
+			}
+		}
+		else
+		{
+			$lasterror = "Source and/or target names not supplied";
+		}
+	}
+	else
+	{
+		$lasterror = "Handle not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Transfer (copy) build file to target.  Copies a file located
+# within a build image to the target board
+################################################################
+sub copy_buildfile_to_target
+{
+	Line("Copying buildfile file to target...");
+	
+	if (!$httpserver or !$runno or !builddir)
+	{
+		Line("ERROR: TMS Server, run number, or build directory not defined - Build files cannot be transfered");
+		return 0;
+	}
+
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	my $source = $cmdref->[1];
+	my $dest = $cmdref->[2];
+	my $codetype = $cmdref->[2];
+	if ($hndl)
+	{
+		if ($source and $dest)
+		{
+			# find the location of the build
+			$location = GetBuildLocation($codetype);
+			if ($location)
+			{		
+				# get the desired file from the TMS
+				if (DownloadAndSaveFile("$location/$source", "$workdir$builddir$source"))
+				{			
+					# send the file	to the target device
+					if (SendCommand($hndl, "<B><T$builddir$source,$dest><E>"))
+					{
+						return 1;
+					}
+				}				
+				else
+				{
+					$lasterror = "Could not download file $location/$file";
+				}
+			}
+			else
+			{
+				$lasterror = "Build location could not be obtained";
+			}
+		}
+		else
+		{
+			$lasterror = "Source and/or target names not supplied";
+		}
+	}
+	else
+	{
+		$lasterror = "Handle not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Retrieve (move) file from target
+################################################################
+sub move_from_target
+{
+	Line("Moving file from target...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	my $source = $cmdref->[1];
+	if ($hndl)
+	{
+		if ($source)
+		{
+			if (SendCommand($hndl, "<B><X$source,$recvdir><E>"))
+			{
+				return 1;
+			}
+		}
+		else
+		{
+			$lasterror = "Source name not supplied";
+		}
+	}
+	else
+	{
+		$lasterror = "Handle not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Retrieve (copy) file from target
+################################################################
+sub copy_from_target
+{
+	Line("Copying file from target...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	my $source = $cmdref->[1];
+	if ($hndl)
+	{
+		if ($source)
+		{
+			if (SendCommand($hndl, "<B><R$source,$recvdir><E>"))
+			{
+				return 1;
+			}
+		}
+		else
+		{
+			$lasterror = "Source name not supplied";
+		}
+	}
+	else
+	{
+		$lasterror = "Handle not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Delete unneeded file from target
+################################################################
+sub remove_file
+{
+	Line("Removing file...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	my $file = $cmdref->[1];
+	
+	if ($hndl)
+	{
+		if ($file)
+		{
+			if (SendCommand($hndl, "<B><U$file><E>"))
+			{
+				return 1;
+			}
+		}
+		else
+		{
+			$lasterror = "File not supplied";
+		}
+	}
+	else
+	{
+		$lasterror = "Handle not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Creating a folder on the target
+################################################################
+sub create_folder
+{
+	Line("Creating folder...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	my $folder = $cmdref->[1];
+	
+	if ($hndl)
+	{
+		if ($folder)
+		{
+			if (SendCommand($hndl, "<B><N$folder><E>"))
+			{
+				return 1;
+			}
+		}
+		else
+		{
+			$lasterror = "Folder not supplied";
+		}
+	}
+	else
+	{
+		$lasterror = "Handle not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Delete unneeded folder from target
+################################################################
+sub remove_folder
+{
+	Line("Removing folder...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	my $folder = $cmdref->[1];
+	
+	if ($hndl)
+	{
+		if ($folder)
+		{
+			if (SendCommand($hndl, "<B><Z$folder><E>"))
+			{
+				return 1;
+			}
+		}
+		else
+		{
+			$lasterror = "Folder not supplied";
+		}
+	}
+	else
+	{
+		$lasterror = "Handle not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Hold a key down for a specified time
+################################################################
+sub hold_key
+{
+	Line("Holding key down for specified time...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	my $key = $cmdref->[1];
+	my $delaytime = $cmdref->[2];
+	
+	if ($hndl)
+	{
+		if ($key)
+		{
+			if ($delaytime)
+			{
+				if (SendCommand($hndl, "<B><H$key,$delaytime><E>"))
+				{
+					return 1;
+				}
+			}
+			else
+			{
+				$lasterror = "Delay time not supplied";
+			}
+		}
+		else
+		{
+			$lasterror = "Key not supplied";
+		}
+	}
+	else
+	{
+		$lasterror = "Handle not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Execute a command file
+################################################################
+sub send_command_file
+{
+	Line("Sending command file...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	my $file = $cmdref->[1];
+	if ($hndl)
+	{
+		if ($file)
+		{
+			$FUNCTION = new Win32::API("$statdir/$dllname", "StdSendCommandFile", [I, P, P], I);
+			if (defined($FUNCTION))
+			{
+				Line("Command File ($hndl, $file )");
+				$ret = $FUNCTION->Call($hndl, $file, 0);
+				if ($ret)
+				{
+					return 1;
+				}
+				else
+				{
+					GetDllError($hndl);
+				}
+			}
+			else
+			{
+				$lasterror = "Function StdSendCommandFile not found\n";
+			}
+		}
+		else
+		{
+			$lasterror = "Command file not supplied";
+		}
+	}
+	else
+	{
+		$lasterror = "Handle not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# Execute a raw command
+################################################################
+sub send_raw_command
+{
+	Line("Executing raw command...");
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	my $command = $cmdref->[1];
+	if ($hndl)
+	{
+		if ($command)
+		{
+			$FUNCTION = new Win32::API("$statdir/$dllname", "StdSendRawCommand", [I, P, P], I);
+			if (defined($FUNCTION))
+			{
+				Line("Command File ($hndl, $command)");
+				$ret = $FUNCTION->Call($hndl, $command, 0);
+				if ($ret)
+				{
+					return 1;
+				}
+				else
+				{
+					GetDllError($hndl);
+				}
+			}
+			else
+			{
+				$lasterror = "Function StdSendRawCommand not found\n";
+			}
+		}
+		else
+		{
+			$lasterror = "Command file not supplied";
+		}
+	}
+	else
+	{
+		$lasterror = "Handle not supplied";
+	}
+
+	Line(get_last_error());
+	return 0;
+}
+
+
+################################################################
+# PRIVATE FUNCTIONS
+################################################################
+
+#############################################################################
+# Get the STAT working path from the registry
+#############################################################################
+sub GetSTATWorkingDirectory
+{
+	my $swkey = $Registry->{"LMachine/software/"};
+	my $endkey = $swkey->{"symbian/stat/"};
+	
+	$workdir = $endkey->{"/WorkingPath"};
+	if (!$workdir)
+	{
+		$lasterror = "Cannot obtain STAT work dir from registry";
+		return 0;
+	}
+
+	$statdir = $endkey->{"/InstallRoot"};
+	if (!$statdir)
+	{
+		$lasterror = "Cannot obtain STAT Install dir from registry";
+		return 0;
+	}
+
+	# substitute DOS '\' with '/' if needed
+	$workdir = "$workdir/";
+	$workdir =~ s/\\/\//g;
+	$statdir =~ s/\\/\//g;
+
+	return 1;
+}
+
+
+################################################################
+# Get the error that occurred within the DLL call
+################################################################
+sub GetDllError
+{
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+
+	$FUNCTION = new Win32::API("$statdir/$dllname", "StdGetError", [I], P);
+	if (defined($FUNCTION))
+	{
+		if ($hndl)
+		{
+			Line("Handle : ($hndl)");
+		}
+
+		$lasterror = $FUNCTION->Call($hndl);
+	}
+	else
+	{
+		$lasterror = "Function StdGetError not found";
+	}
+	
+	return $lasterror;
+}
+
+
+#############################################################################
+# Display a line of text
+#############################################################################
+sub Line
+{
+	my ($msg) = @_;
+
+	if ($msg)
+	{
+		($hour, $min, $sec) = (localtime)[2,1,0];
+		printf("%02d:%02d:%02d $msg\n", $hour, $min, $sec);
+		STDOUT->autoflush;
+		STDERR->autoflush;
+	}
+}
+
+
+###############################################################################################
+# Construct a build location depending on the code and build type
+###############################################################################################
+sub GetBuildLocation
+{
+	my $command;
+	
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $codetype = $cmdref->[0];
+
+	if (!$httpserver)
+	{
+		$lasterror = "TMS Server not defined";
+		Line(get_last_error());
+		return 0;
+	}
+
+	# ceate a user agent object
+	my $ua = new LWP::UserAgent;
+	$ua->agent("AgentName/0.1 " . $ua->agent);
+	
+	$req = new HTTP::Request GET => "$httpserver/GetBuildLocation?RunNo=$runno";
+	$req->header('User-Agent' => $ua->agent);
+	$req->header('Authorization' => "Basic $encoded");
+	$req->header('Content-type' => 'binary');
+	$res = $ua->request($req);
+	if (!$res->is_success)
+	{
+		$lasterror = "Cannot open $httpserver/GetBuildLocation";
+		Line(get_last_error());
+		return 0;
+	}
+
+	# decide build type depending on $codetype
+	my $buildtype = "UREL";
+	if ($codetype eq "WINS")
+	{
+		$buildtype = "UDEB";
+	}
+
+	$command = "$httpserver/" . $res->content() . "/epoc32/release/$codetype/$buildtype";
+
+	# remove any carriage returns in the string
+	$command =~ s/\n//g;
+	
+	Line("Build location is [$command]");
+
+	return $command;
+}
+
+
+###############################################################################################
+# Download a single file to a local location
+###############################################################################################
+sub DownloadAndSaveFile
+{
+	my ($source, $destination) = @_;
+
+	# substitute DOS '\' with '/' if needed
+	$source =~ s/\\/\//g;
+	$destination =~ s/\\/\//g;
+
+	Line("$source => $destination");
+
+	# ceate a user agent object
+	my $ua = new LWP::UserAgent;
+	$ua->agent("AgentName/0.1 " . $ua->agent);
+	
+	$req = new HTTP::Request GET => "$source";
+	$req->header('User-Agent' => $ua->agent);
+	$req->header('Authorization' => "Basic $encoded");
+	$req->header('Content-type' => 'binary');
+	$res = $ua->request($req);
+	if (!$res->is_success)
+	{
+		$lasterror = "Cannot open $source";
+		Line(get_last_error());
+		return 0;
+	}
+
+	Line("Saving retrieved file to $destination...");
+
+	# save the retrieved contents to disk
+	my $fh = IO::File->new ("$destination", O_CREAT | O_WRONLY | O_TRUNC);
+	binmode($fh);
+	if ($fh)
+	{
+		print $fh $res->content();
+		$fh->autoflush(1);
+		close($fh);
+	}
+	else
+	{
+		$lasterror = "Cannot create $destination";
+		Line(get_last_error());
+		return 0;
+	}
+
+	return 1;
+}
+
+
+################################################################
+# Send a command to the target
+################################################################
+sub SendCommand
+{
+	my @cmdline = @_;
+	my $cmdref = \@cmdline;
+	my $hndl = $cmdref->[0];
+	my $command = $cmdref->[1];
+
+	# substitute Perl '/' with DOS '\' if needed
+	$command =~ s/\//\\/g;
+
+	$FUNCTION = new Win32::API("$statdir/$dllname", "StdSendRawCommand", [I, P, P], I);
+	if (defined($FUNCTION))
+	{
+		Line("Command ($hndl, $command)");
+		$ret = $FUNCTION->Call($hndl, $command, 0);
+		if ($ret)
+		{
+			return 1;
+		}
+		else
+		{
+			GetDllError($hndl);
+		}
+	}
+	else
+	{
+		$lasterror = "Function StdSendRawCommand not found";
+	}
+
+	return 0;
+}
+
+
+# last line in file
+1;
+__END__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/stat.dsw	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,65 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "STATDesktop"=.\desktop\STATDesktop.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "STATDll"=.\dll\STATdll.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "STATLib"=.\lib\STATLib.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "stat2perl"=.\stat2perl\stat2perl.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/stat2perl/group/bld.inf	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,41 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:  
+//
+
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+
+* which accompanies this distribution, and is available
+
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+PRJ_PLATFORMS
+
+TOOLS
+
+PRJ_MMPFILES
+// Extension Makefile
+makefile stat2perl.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/stat2perl/group/stat2perl.mk	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,83 @@
+#
+# Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:  
+#
+
+# which accompanies this distribution, and is available
+
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+# Typically C:\apps\MSVC6\VC98\Bin
+COMPILER=nmake
+
+# Called with
+#
+# $(PLATFORM) = TOOLS
+# $(CFG)      = DEB, REL
+
+BLD	:  
+	@echo BLD called with $(PLATFORM)$(CFG)
+	
+# release version
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "REL"
+	-mkdir "$(EPOCROOT)epoc32\tools\STAT"
+
+# Go up one level to access the makefile
+	cd ".."
+
+# Execute the command line compiler (stat2perl)
+	"$(COMPILER)" /A /NOLOGO /f "stat2perl.mak" CFG="stat2perl - Win32 Release"
+	
+	echo ** STAT 2 PERL CONVERTER (RELEASE) compiled successfully
+
+!endif
+
+# debug version
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "DEB"
+
+# Go up one level to access the makefile
+	cd ".."
+
+# Execute the command line compiler (stat2perl)
+	"$(COMPILER)" /A /NOLOGO /f "stat2perl.mak" CFG="stat2perl - Win32 Debug"
+	
+	echo ** STAT 2 PERL CONVERTER (DEBUG) compiled successfully
+
+!endif
+
+CLEAN :
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "REL"
+	-rmdir "..\Release" /q /s
+!endif
+
+CLEAN :
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "DEB"
+	-rmdir "..\Debug" /q /s
+!endif
+
+RELEASABLES :
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "REL"
+	@echo $(EPOCROOT)epoc32\tools\STAT\STAT2PERL.exe
+!endif
+
+SAVESPACE : BLD
+
+MAKMAKE LIB CLEANLIB RESOURCE FREEZE FINAL : 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/stat2perl/inc/commandline.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:     include file for Commandline access							*
+*/
+
+
+
+
+
+// Provides access to the command line
+//
+
+#ifndef COMMANDLINE_H
+#define COMMANDLINE_H
+
+class CommandLine
+{
+public:
+	CommandLine();
+	virtual ~CommandLine(){}
+
+	char * GetProgramArgument(const unsigned int iIndex);
+	unsigned int GetNumberOfArgs() {return iCount;}
+	bool FindArgument(const char *pArg);
+	char * GetArgumentBySwitch(const char *pSwitch, const bool bIncludeSwitch = false);
+	char * GetArgumentString();
+
+private:
+	unsigned int iCount;
+	char *pArguments[256];
+	char *pCmdLine;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/stat2perl/inc/stdafx.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:     include file for standard system include files				*
+*/
+
+
+
+
+// stdafx.h : include file for standard system include files,
+//  or project specific include files that are used frequently, but
+//      are changed infrequently
+//
+
+#if !defined(AFX_STDAFX_H__55543DF3_BBFB_11D5_BC3C_00B0D065107F__INCLUDED_)
+#define AFX_STDAFX_H__55543DF3_BBFB_11D5_BC3C_00B0D065107F__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include <windows.h>
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__55543DF3_BBFB_11D5_BC3C_00B0D065107F__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/stat2perl/src/commandline.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,161 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#include "stdafx.h"
+#include "CommandLine.h"
+
+CommandLine::CommandLine()
+: iCount(0), pCmdLine(NULL)
+{
+	char *pTmpCmdLine = GetCommandLine();
+
+	// see if we have one
+	if (pTmpCmdLine && *pTmpCmdLine)
+	{
+		char *pStart, *ptr;
+		unsigned int len = strlen(pTmpCmdLine);
+
+		// save a copy
+		pCmdLine = new char[len + 1];
+		strcpy(pCmdLine, pTmpCmdLine);
+
+		// get a working copy
+		pTmpCmdLine = new char[len + 1];
+		strcpy(pTmpCmdLine, pCmdLine);
+		ptr = pTmpCmdLine;
+
+		// reset the array
+		for (int i=0;i<256;i++)
+			pArguments[i] = NULL;
+
+		// limit of 256 arguments
+		for (i=0;i<256;i++)
+		{
+			pStart = ptr;
+
+			// step to start of argument
+			while (*pStart && *pStart == ' ')
+				pStart++;
+
+			// step to end of argument
+			ptr = pStart;
+			while (*ptr && *ptr != ' ')
+			{
+				// if path is enclosed in quotes, we skip any spaces that might exist within them
+				// NOTE: if a quote exists inside the path, we will lose the first part of the argument!
+				if (*ptr == '"')
+				{
+					ptr++;
+					pStart = ptr;					// don't want first quote in the returned argument
+					while (*ptr && *ptr != '"')
+						ptr++;
+
+					if (*ptr == '"')
+					{
+						*ptr = (char)0;				// don't want last quote in the returned argument
+					}
+				}
+				ptr++;
+			}
+
+			// not at the end so separate arguments
+			if (*ptr)
+			{
+				(*ptr) = (char)0;
+				ptr++;
+			}
+
+			if (*pStart)
+			{
+				// store argument
+				pArguments[i] = new char[strlen(pStart) + 1];
+				strcpy(pArguments[i], pStart);
+				iCount++;
+			}
+			else
+				break;
+		}
+
+		delete [] pTmpCmdLine;
+	}
+}
+
+
+// return whole command line less the first arg (app name)
+char * CommandLine::GetArgumentString()
+{
+	if (pCmdLine && *pCmdLine)
+		return pCmdLine;
+
+	return NULL;
+}
+
+
+// return an argument match
+bool CommandLine::FindArgument(const char *pArg)
+{
+	bool valid = false;
+
+	for (unsigned int i=0;i<iCount;i++)
+	{
+		if (strcmp(pArg, pArguments[i]) == 0)
+		{
+			valid = true;
+			break;
+		}
+	}
+
+	return valid;
+}
+
+
+// return the argument according to the supplied index
+char * CommandLine::GetProgramArgument(const unsigned int iIndex)
+{
+	if (iIndex < iCount)
+	{
+		return pArguments[iIndex];
+	}
+
+	return NULL;
+}
+
+
+// find the argument that begins with the supplied 'switch' and return the value less the 'switch'
+char * CommandLine::GetArgumentBySwitch(const char *pSwitch, const bool bIncludeSwitch)
+{
+	unsigned int len = strlen(pSwitch);
+
+	for (unsigned int i=0;i<iCount;i++)
+	{
+		if (strncmp(pArguments[i], pSwitch, len) == 0)
+		{
+			if (bIncludeSwitch)
+				return pArguments[i];
+			else
+				return pArguments[i] + len;
+		}
+	}
+
+	return NULL;
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/stat2perl/src/stat2perl.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,495 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#include "stdafx.h"
+#include <commandline.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdio.h>
+
+#define IN_LINE_MAX 4096
+
+///////////////////////////////////////////////
+// AUTO-GENERATED TEXT - DO NOT MODIFY!!!
+///////////////////////////////////////////////
+#define S2P_VERSION "4.0"
+///////////////////////////////////////////////
+
+DWORD nFileLength = 0;
+char *lpBuffer = NULL;
+char szConnection[3] = {0};
+char szPlatform[20] = {0};
+char szInputName[MAX_PATH + 1] = {0};
+char szOutputName[MAX_PATH + 1] = {0};
+
+void cleanup(char *message, UINT errorcode = 0);
+bool ReadFileIntoArray(const char *file);
+bool ProcessFileContents(const char *file);
+void ConvertBackslash(char *szCommand);
+void WriteHeader(HANDLE outfile);
+void WriteTrailer(HANDLE outfile);
+void SkipOverComment(DWORD *counter);
+
+int main(int argc, char* argv[])
+{
+	printf("\n------------------------------\n"
+			"STAT2PERL Script Converter %s\n"
+			"------------------------------\n"
+			"Copyright Symbian Ltd 2002.\n"
+			"---------------------------", S2P_VERSION);
+
+	CommandLine oCmd;
+	if (oCmd.GetNumberOfArgs() == 5)
+	{
+		strcpy(szConnection, oCmd.GetProgramArgument(1));
+		strcpy(szPlatform, oCmd.GetProgramArgument(2));
+		strcpy(szInputName, oCmd.GetProgramArgument(3));
+		strcpy(szOutputName, oCmd.GetProgramArgument(4));
+
+		if (ReadFileIntoArray(szInputName))
+		{
+			if (ProcessFileContents(szOutputName))
+			{
+				printf("\n\nFile converted successfully.\n");
+				return 1;
+			}
+		}
+		else
+			printf("\nERROR: Could not read [%s] into memory.\n", szInputName);
+	}
+	else
+		printf("\n\nERROR: Incorrect Number of arguments.\nUsage: stat2perl <connection> <platform> <input file> <output file>\n   Eg: stat2perl 3 COM1 file.txt file.pl\n");
+
+	return -1;
+}
+
+
+bool ReadFileIntoArray(const char *file)
+{
+	HANDLE infile;
+	DWORD bytes = 0;
+	struct stat buf;
+
+	if (stat(file, &buf) == 0)
+	{
+		nFileLength = buf.st_size;
+
+		if ((infile = CreateFile(file,
+							   GENERIC_READ,
+							   0, 
+							   NULL, 
+							   OPEN_EXISTING,
+							   FILE_ATTRIBUTE_NORMAL,
+							   0))
+				!= INVALID_HANDLE_VALUE)
+		{
+			lpBuffer = new char [nFileLength + 1];
+			if (lpBuffer)
+			{
+				if (ReadFile(infile, lpBuffer, nFileLength, &bytes, NULL) && bytes == nFileLength)
+				{
+					CloseHandle(infile);
+					return true;
+				}
+				else
+					printf("\nERROR: Failed to read entire file into memory.");
+
+			}
+			else
+				printf("\nERROR: Could not allocate memory to read file.");
+
+			CloseHandle(infile);
+		}
+		else
+			printf("\nERROR: Could not open [%s] to read.", file);
+	}
+	else
+		printf("\nERROR: [%s] does not exist.", file);
+
+	return false;
+}
+
+bool ProcessFileContents(const char *file)
+{
+	HANDLE outfile;
+	DWORD bytes = 0;
+
+	// open our output file
+	if ((outfile = CreateFile(file,
+						   GENERIC_WRITE,
+						   0, 
+						   NULL, 
+						   CREATE_ALWAYS,
+						   FILE_ATTRIBUTE_NORMAL,
+						   0))
+			!= INVALID_HANDLE_VALUE)
+	{
+		bool bCommand = false;
+		DWORD counter = 0;
+		DWORD actualstart = 0;
+		DWORD actualend = 0;
+
+		WriteHeader(outfile);
+
+		// find the beginning and end
+		while(counter < nFileLength)
+		{
+			// check command format is correct
+			if(lpBuffer[counter] == '<')
+			{
+				counter++;
+				if(lpBuffer[counter] == 'B')
+					actualstart = counter + 2;
+
+				if(lpBuffer[counter] == 'E')
+				{
+					actualend = counter - 2;
+					break;
+				}
+			}
+			else if (lpBuffer[counter] == '/') // start of comment or command
+			{	
+				SkipOverComment(&counter);
+			}
+
+			counter++;
+		}
+
+		// only concerned with usable part of script
+		counter = actualstart;
+		nFileLength = actualend;
+
+		// now parse it...
+		while(counter < nFileLength)	//while not reached end of the file
+		{
+			// check command format is correct
+			if(lpBuffer[counter] == '<')
+			{
+				bCommand = true;
+			}
+			else if (lpBuffer[counter] == '/') // start of comment or command
+			{	
+				SkipOverComment(&counter);
+			}
+			else if (bCommand) // start of comment or command
+			{	
+				char szCommand[2048] = {0};
+				char szLine[IN_LINE_MAX + 1] = {0};
+				char *ptr = NULL;
+				int cmdLength = 0;
+
+				// extract the command
+				while (lpBuffer[counter + cmdLength] != '>')
+					cmdLength++;
+				strncpy(szLine, lpBuffer + counter, cmdLength);
+				*(szLine + counter + cmdLength) = (char)0;
+
+				switch(lpBuffer[counter]) 
+				{
+					case '#' :	// set image directory - format: '#image <location>
+						if ((ptr = strchr(szLine, ' ')) && strncmp(szLine, "#image", 6) == 0)
+						{
+							(*ptr++) = (char)0;
+							sprintf(szCommand, "set_screenshot_dir(\"%s\") or goto scripterror;", ptr);
+						}
+						break;
+					case 'D' :		// retrieves information about connected device
+					case 'd' :
+						strcpy(szCommand, "get_device_info($hndl) or goto scripterror;");
+						break;
+					case 'K' :		//standard QWERTY Keypress command
+					case 'k' :
+						sprintf(szCommand, "basic_key_sequence($hndl, \"%s\") or goto scripterror;", szLine + 1);
+						break;
+					case 'L' :	//used to send non-standard key data over (ie - Menu button, Home button, PageDown button)
+					case 'l' :
+						sprintf(szCommand, "control_keystroke($hndl, \"%s\") or goto scripterror;", szLine + 1);
+						break;
+					case 'M' :	//used when combination keys are to be sent over
+					case 'm' :
+						sprintf(szCommand, "combination_keystroke($hndl, \"%s\") or goto scripterror;", szLine + 1);
+						break;
+					case 'H' :	// hold key down for a while
+					case 'h' :
+						if (ptr = strchr(szLine, ','))
+						{
+							(*ptr++) = (char)0;
+							sprintf(szCommand, "hold_key($hndl, \"%s\", \"%s\") or goto scripterror;", szLine + 1, ptr);
+						}
+						break;
+					case 'A' :	//Fire up application (second character is a number which opens up the app (e.g - <A1>))
+					case 'a' :
+						if (ptr = strchr(szLine, ','))
+						{
+							(*ptr++) = (char)0;
+							sprintf(szCommand, "start_application($hndl, \"%s\", \"%s\") or goto scripterror;", szLine + 1, ptr);
+						}
+						else
+							sprintf(szCommand, "start_application($hndl, \"%s\") or goto scripterror;", szLine + 1);
+						break;
+					case 'F' :	//Open file
+					case 'f' :
+						if (ptr = strchr(szLine, ','))
+						{
+							(*ptr++) = (char)0;
+							sprintf(szCommand, "open_application($hndl, \"%s\", \"%s\") or goto scripterror;", szLine + 1, ptr);
+						}
+						break;
+					case 'T' :	//used to transfer files from the PC to the EPOC device
+					case 't' :
+						if (ptr = strchr(szLine, ','))
+						{
+							(*ptr++) = (char)0;
+							sprintf(szCommand, "copy_testfile_to_target($hndl, \"%s\", \"%s\") or goto scripterror;", szLine + 1, ptr);
+						}
+						break;
+					case 'R' :	//used to retrieve files from the EPOC device
+					case 'r' :
+						if (ptr = strchr(szLine, ','))
+						{
+							(*ptr++) = (char)0;
+							sprintf(szCommand, "copy_from_target($hndl, \"%s\", \"%s\") or goto scripterror;", szLine + 1, ptr);
+						}
+						break;
+					case 'X' :
+					case 'x' :
+						if (ptr = strchr(szLine, ','))
+						{
+							(*ptr++) = (char)0;
+							sprintf(szCommand, "move_from_target($hndl, \"%s\", \"%s\") or goto scripterror;", szLine + 1, ptr);
+						}
+						break;
+					case 'S' :	// Used for screen capture 
+					case 's' :
+						if (cmdLength > 1)
+							sprintf(szCommand, "get_screenshot($hndl, \"%s\") or goto scripterror;", szLine + 1);
+						else
+							strcpy(szCommand, "get_screenshot($hndl) or goto scripterror;");
+						break;
+					case 'I' :	//Icon coordinates
+					case 'i' :
+						if (ptr = strchr(szLine, ','))
+						{
+							(*ptr++) = (char)0;
+							sprintf(szCommand, "touch_screen($hndl, %s, %s) or goto scripterror;", szLine + 1, ptr);
+						}
+						break;
+					case 'C' :	//Close currently active application
+					case 'c' :
+						strcpy(szCommand, "close_application($hndl) or goto scripterror;");
+						break;
+					case '!' :	// Start ESHELL.EXE
+						if (*(szLine + 1) != '!')
+							strcpy(szCommand, "start_eshell($hndl) or goto scripterror;");
+						else
+							strcpy(szCommand, "stop_eshell($hndl) or goto scripterror;");
+						break;
+					case 'P' : //pause 
+					case 'p' :
+						sprintf(szCommand, "pause($hndl, %s) or goto scripterror;", szLine + 1);
+						break;
+					case 'U' :	// remove file
+					case 'u' :
+						sprintf(szCommand, "remove_file($hndl, \"%s\") or goto scripterror;", szLine + 1);
+						break;
+					case 'Y' :	// create folder
+					case 'y' :
+						sprintf(szCommand, "create_folder($hndl, \"%s\") or goto scripterror;", szLine + 1);
+						break;
+					case 'Z' :	// remove folder
+					case 'z' :
+						sprintf(szCommand, "remove_folder($hndl, \"%s\") or goto scripterror;", szLine + 1);
+						break;
+				} // switch
+
+				// if command supported, write it to file
+				if (*szCommand)
+				{
+					ConvertBackslash(szCommand);
+					WriteFile(outfile, szCommand, strlen(szCommand), &bytes, NULL);
+					WriteFile(outfile, "\r\n", 2, &bytes, NULL);
+					(*szCommand) = (char)0;
+				}
+
+				counter += cmdLength;
+				bCommand = false;
+			}
+
+			counter++;
+		}
+
+		WriteTrailer(outfile);
+		CloseHandle(outfile);
+	}
+	else
+	{
+		printf("\nERROR: Could not open [%s] to write.", file);
+		return false;
+	}
+
+	return true;
+}
+
+void SkipOverComment(DWORD *counter)
+{
+	int iInComment = 0;
+
+	// beginning of comment
+	if (lpBuffer[(*counter) + 1] == '*')
+	{
+		iInComment++;
+		(*counter)+=2;
+		while(iInComment && (*counter) < nFileLength)	//while not reached end of the file
+		{
+			if (lpBuffer[(*counter)] == '/')
+			{
+				// beginning of comment - support nested comments
+				if (lpBuffer[(*counter) + 1] == '*')
+				{
+					iInComment++;
+					(*counter)++;
+				}
+
+				// end of comment
+				if (lpBuffer[(*counter) - 1] == '*')
+				{
+					iInComment--;
+				}
+			}
+
+			(*counter)++;
+		}
+	}
+}
+
+void ConvertBackslash(char *szCommand)
+{
+	char szCopy[IN_LINE_MAX + 1] = {0};
+	int iSrc = 0, iDest = 0;
+
+	while(*(szCommand + iSrc))
+	{
+		// need to substitute the special chars
+		if (*(szCommand + iSrc) == '\r')
+		{
+			*(szCopy + iDest) = '\\';
+			iDest++;
+			*(szCopy + iDest) = 'r';
+			iDest++;
+		}
+		else if (*(szCommand + iSrc) == '\n')
+		{
+			*(szCopy + iDest) = '\\';
+			iDest++;
+			*(szCopy + iDest) = 'n';
+			iDest++;
+		}
+		else if (*(szCommand + iSrc) == '\t')
+		{
+			*(szCopy + iDest) = '\\';
+			iDest++;
+			*(szCopy + iDest) = 't';
+			iDest++;
+		}
+		else if (*(szCommand + iSrc) == '@')
+		{
+			*(szCopy + iDest) = '\\';
+			iDest++;
+			*(szCopy + iDest) = '@';
+			iDest++;
+		}
+		else
+		{
+			// append a backslash
+			if (*(szCommand + iSrc) == '\\')
+			{
+				*(szCopy + iDest) = '\\';
+				iDest++;
+			}
+
+			// now copy the char
+			*(szCopy + iDest) = *(szCommand + iSrc);
+			iDest++;
+		}
+
+		// don't go too far
+		if (iDest >= IN_LINE_MAX)
+		{
+			*(szCopy + iDest) = (char)0;
+			break;
+		}
+		iSrc++;
+	}
+
+	strcpy(szCommand, szCopy);
+}
+
+void WriteHeader(HANDLE outfile)
+{
+	DWORD bytes = 0;
+	char szLine[2048] = {0};
+
+	WriteFile(outfile, "#########################################################################\r\n", 75, &bytes, NULL);
+	WriteFile(outfile, "# STAT2PERL CONVERTED SCRIPT\r\n", 30, &bytes, NULL);
+	WriteFile(outfile, "#\r\n", 3, &bytes, NULL);
+	WriteFile(outfile, "# For STAT Perl Interface ", 26, &bytes, NULL);
+	WriteFile(outfile, S2P_VERSION, strlen(S2P_VERSION), &bytes, NULL);
+	WriteFile(outfile, " or higher\r\n#\r\n", 15, &bytes, NULL);
+	WriteFile(outfile, "# Auto-Generated from script:\r\n", 31, &bytes, NULL);
+	sprintf(szLine, "# %s\r\n#\r\n", szInputName);
+	WriteFile(outfile, szLine, strlen(szLine), &bytes, NULL);
+	WriteFile(outfile, "#########################################################################\r\n", 75, &bytes, NULL);
+	WriteFile(outfile, "\r\n", 2, &bytes, NULL);
+	WriteFile(outfile, "use Symbian::StatAPI30;  # must include this library\r\n\r\n", 56, &bytes, NULL);
+	WriteFile(outfile, "my $result = 1;          # test result\r\n", 40, &bytes, NULL);
+	WriteFile(outfile, "my $hndl;                # handle to connection\r\n\r\n", 51, &bytes, NULL);
+	WriteFile(outfile, "# set everything up\r\n", 21, &bytes, NULL);
+	sprintf(szLine, "my @arglist = (\"STAT.DLL\", %c, \"%s\");\r\n", szConnection[0], _strupr(szPlatform));
+	WriteFile(outfile, szLine, strlen(szLine), &bytes, NULL);
+	WriteFile(outfile, "initialise(@arglist) or goto scripterror;\r\n\r\n", 45, &bytes, NULL);
+	WriteFile(outfile, "# connect to the board\r\n", 24, &bytes, NULL);
+	WriteFile(outfile, "$hndl = connect_to_target();\r\n", 30, &bytes, NULL);
+	WriteFile(outfile, "$hndl or goto scripterror;\r\n\r\n", 30, &bytes, NULL);
+	WriteFile(outfile, "# send commands\r\n", 17, &bytes, NULL);
+}
+
+
+void WriteTrailer(HANDLE outfile)
+{
+	DWORD bytes = 0;
+
+	WriteFile(outfile, "\r\n\r\n#########################################################################\r\n", 79, &bytes, NULL);
+	WriteFile(outfile, "# test succeeded\r\n", 18, &bytes, NULL);
+	WriteFile(outfile, "goto endscript;\r\n\r\n\r\n", 21, &bytes, NULL);
+	WriteFile(outfile, "#########################################################################\r\n", 75, &bytes, NULL);
+	WriteFile(outfile, "# fail the test\r\n", 17, &bytes, NULL);
+	WriteFile(outfile, "scripterror:\r\n", 14, &bytes, NULL);
+	WriteFile(outfile, "print \"\\nScript aborted due to error:\\n\" . get_last_error($hndl) . \"\\n\";\r\n", 74, &bytes, NULL);
+	WriteFile(outfile, "$result = 0;\r\n\r\n\r\n", 18, &bytes, NULL);
+	WriteFile(outfile, "#########################################################################\r\n", 75, &bytes, NULL);
+	WriteFile(outfile, "# finish\r\n", 10, &bytes, NULL);
+	WriteFile(outfile, "endscript:\r\n", 12, &bytes, NULL);
+	WriteFile(outfile, "$hndl and disconnect_from_target($hndl) and print \"Disconnected OK\\n\";\r\n\r\n\r\n", 76, &bytes, NULL);
+	WriteFile(outfile, "#########################################################################\r\n", 75, &bytes, NULL);
+	WriteFile(outfile, "# return value (zero=fail, non-zero=success)\r\n", 46, &bytes, NULL);
+	WriteFile(outfile, "exit($result);\r\n", 16, &bytes, NULL);
+	WriteFile(outfile, "\r\n", 2, &bytes, NULL);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/stat2perl/src/stdafx.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include "stdafx.h"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/stat2perl/stat2perl.dep	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,13 @@
+# Microsoft Developer Studio Generated Dependency File, included by stat2perl.mak
+
+.\src\CommandLine.cpp : \
+	".\inc\CommandLine.h"\
+	
+
+.\src\stat2perl.cpp : \
+	".\inc\CommandLine.h"\
+	
+
+.\src\StdAfx.cpp : \
+	".\inc\StdAfx.h"\
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/stat2perl/stat2perl.dsp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,130 @@
+# Microsoft Developer Studio Project File - Name="stat2perl" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=stat2perl - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "stat2perl.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "stat2perl.mak" CFG="stat2perl - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "stat2perl - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "stat2perl - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName "stat2perl"
+# PROP Scc_LocalPath "..\.."
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "stat2perl - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu".\inc\stdafx.h" /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I ".\src" /I ".\inc" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FR /Yu"stdafx.h" /FD /c
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"..\..\bin\STAT2Perl.exe"
+# Begin Special Build Tool
+ProjDir=.
+SOURCE="$(InputPath)"
+PostBuild_Desc=Performing Custom Build Step on stat2perl
+PostBuild_Cmds=$(ProjDir)\UpdateStat2Perl.bat
+# End Special Build Tool
+
+!ELSEIF  "$(CFG)" == "stat2perl - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu".\inc\stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I ".\src" /I ".\inc" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /FD /GZ /c
+# SUBTRACT CPP /YX /Yc /Yu
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"..\..\bin\STAT2Perld.exe" /pdbtype:sept
+
+!ENDIF 
+
+# Begin Target
+
+# Name "stat2perl - Win32 Release"
+# Name "stat2perl - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\src\CommandLine.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\stat2perl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\stat2perl.dep
+# End Source File
+# Begin Source File
+
+SOURCE=.\stat2perl.mak
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\StdAfx.cpp
+# ADD CPP /Yc"stdafx.h"
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\inc\CommandLine.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\StdAfx.h
+# End Source File
+# End Group
+# End Target
+# End Project
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/stat2perl/stat2perl.mak	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,231 @@
+# Microsoft Developer Studio Generated NMAKE File, Based on stat2perl.dsp
+!IF "$(CFG)" == ""
+CFG=stat2perl - Win32 Debug
+!MESSAGE No configuration specified. Defaulting to stat2perl - Win32 Debug.
+!ENDIF 
+
+!IF "$(CFG)" != "stat2perl - Win32 Release" && "$(CFG)" != "stat2perl - Win32 Debug"
+!MESSAGE Invalid configuration "$(CFG)" specified.
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "stat2perl.mak" CFG="stat2perl - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "stat2perl - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "stat2perl - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE 
+!ERROR An invalid configuration is specified.
+!ENDIF 
+
+!IF "$(OS)" == "Windows_NT"
+NULL=
+!ELSE 
+NULL=nul
+!ENDIF 
+
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "stat2perl - Win32 Release"
+
+OUTDIR=.\Release
+INTDIR=.\Release
+# Begin Custom Macros
+OutDir=.\Release
+# End Custom Macros
+
+ALL : "..\..\bin\STAT2Perl.exe" "$(OUTDIR)\stat2perl.bsc"
+
+
+CLEAN :
+	-@erase "$(INTDIR)\CommandLine.obj"
+	-@erase "$(INTDIR)\CommandLine.sbr"
+	-@erase "$(INTDIR)\stat2perl.obj"
+	-@erase "$(INTDIR)\stat2perl.pch"
+	-@erase "$(INTDIR)\stat2perl.sbr"
+	-@erase "$(INTDIR)\StdAfx.obj"
+	-@erase "$(INTDIR)\StdAfx.sbr"
+	-@erase "$(INTDIR)\vc60.idb"
+	-@erase "$(OUTDIR)\stat2perl.bsc"
+	-@erase "..\..\bin\STAT2Perl.exe"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /ML /W3 /GX /O2 /I ".\src" /I ".\inc" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\stat2perl.pch" /Yu"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\stat2perl.bsc" 
+BSC32_SBRS= \
+	"$(INTDIR)\CommandLine.sbr" \
+	"$(INTDIR)\stat2perl.sbr" \
+	"$(INTDIR)\StdAfx.sbr"
+
+"$(OUTDIR)\stat2perl.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+    $(BSC32) @<<
+  $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /pdb:"$(OUTDIR)\STAT2Perl.pdb" /machine:I386 /out:"..\..\bin\STAT2Perl.exe" 
+LINK32_OBJS= \
+	"$(INTDIR)\CommandLine.obj" \
+	"$(INTDIR)\stat2perl.obj" \
+	"$(INTDIR)\StdAfx.obj"
+
+"..\..\bin\STAT2Perl.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+    $(LINK32) @<<
+  $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+ProjDir=.
+SOURCE="$(InputPath)"
+PostBuild_Desc=Performing Custom Build Step on stat2perl
+DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep
+
+ALL : $(DS_POSTBUILD_DEP)
+
+# Begin Custom Macros
+OutDir=.\Release
+# End Custom Macros
+
+$(DS_POSTBUILD_DEP) : "..\..\bin\STAT2Perl.exe" "$(OUTDIR)\stat2perl.bsc"
+   .\UpdateStat2Perl.bat
+	echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)"
+
+!ELSEIF  "$(CFG)" == "stat2perl - Win32 Debug"
+
+OUTDIR=.\Debug
+INTDIR=.\Debug
+# Begin Custom Macros
+OutDir=.\Debug
+# End Custom Macros
+
+ALL : "..\..\bin\STAT2Perld.exe" "$(OUTDIR)\stat2perl.bsc"
+
+
+CLEAN :
+	-@erase "$(INTDIR)\CommandLine.obj"
+	-@erase "$(INTDIR)\CommandLine.sbr"
+	-@erase "$(INTDIR)\stat2perl.obj"
+	-@erase "$(INTDIR)\stat2perl.pch"
+	-@erase "$(INTDIR)\stat2perl.sbr"
+	-@erase "$(INTDIR)\StdAfx.obj"
+	-@erase "$(INTDIR)\StdAfx.sbr"
+	-@erase "$(INTDIR)\vc60.idb"
+	-@erase "$(INTDIR)\vc60.pdb"
+	-@erase "$(OUTDIR)\stat2perl.bsc"
+	-@erase "$(OUTDIR)\STAT2Perld.pdb"
+	-@erase "..\..\bin\STAT2Perld.exe"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /I ".\src" /I ".\inc" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\stat2perl.pch" /Yu"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c 
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\stat2perl.bsc" 
+BSC32_SBRS= \
+	"$(INTDIR)\CommandLine.sbr" \
+	"$(INTDIR)\stat2perl.sbr" \
+	"$(INTDIR)\StdAfx.sbr"
+
+"$(OUTDIR)\stat2perl.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+    $(BSC32) @<<
+  $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /pdb:"$(OUTDIR)\STAT2Perld.pdb" /debug /machine:I386 /out:"..\..\bin\STAT2Perld.exe" /pdbtype:sept 
+LINK32_OBJS= \
+	"$(INTDIR)\CommandLine.obj" \
+	"$(INTDIR)\stat2perl.obj" \
+	"$(INTDIR)\StdAfx.obj"
+
+"..\..\bin\STAT2Perld.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+    $(LINK32) @<<
+  $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ENDIF 
+
+.c{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cpp{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cxx{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.c{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cpp{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cxx{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+
+!IF "$(NO_EXTERNAL_DEPS)" != "1"
+!IF EXISTS("stat2perl.dep")
+!INCLUDE "stat2perl.dep"
+!ELSE 
+!MESSAGE Warning: cannot find "stat2perl.dep"
+!ENDIF 
+!ENDIF 
+
+
+!IF "$(CFG)" == "stat2perl - Win32 Release" || "$(CFG)" == "stat2perl - Win32 Debug"
+SOURCE=.\src\CommandLine.cpp
+
+"$(INTDIR)\CommandLine.obj"	"$(INTDIR)\CommandLine.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\stat2perl.pch"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=.\src\stat2perl.cpp
+
+"$(INTDIR)\stat2perl.obj"	"$(INTDIR)\stat2perl.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\stat2perl.pch"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=.\src\StdAfx.cpp
+
+!IF  "$(CFG)" == "stat2perl - Win32 Release"
+
+CPP_SWITCHES=/nologo /ML /W3 /GX /O2 /I ".\src" /I ".\inc" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\stat2perl.pch" /Yc"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+
+"$(INTDIR)\StdAfx.obj"	"$(INTDIR)\StdAfx.sbr"	"$(INTDIR)\stat2perl.pch" : $(SOURCE) "$(INTDIR)"
+	$(CPP) @<<
+  $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ELSEIF  "$(CFG)" == "stat2perl - Win32 Debug"
+
+CPP_SWITCHES=/nologo /MLd /W3 /Gm /GX /Zi /Od /I ".\src" /I ".\inc" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\stat2perl.pch" /Yc"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c 
+
+"$(INTDIR)\StdAfx.obj"	"$(INTDIR)\StdAfx.sbr"	"$(INTDIR)\stat2perl.pch" : $(SOURCE) "$(INTDIR)"
+	$(CPP) @<<
+  $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ENDIF 
+
+
+!ENDIF 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/stat2perl/updatestat2perl.bat	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,34 @@
+@rem
+@rem Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description: 
+@rem
+@@rem
+
+rem
+rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+
+rem which accompanies this distribution, and is available
+
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+copy ..\..\bin\stat2perl.exe \epoc32\tools\stat\stat2perl.exe
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/trgtest/group/bld.inf	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,48 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:  
+//
+
+/*
+* Copyright (c) 1999-2000 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+
+* which accompanies this distribution, and is available
+
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+PRJ_PLATFORMS
+
+TOOLS
+
+
+PRJ_MMPFILES
+
+#if defined(TOOLS)
+
+trgtest.mmp
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/trgtest/group/trgtest.mmp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   
+*
+*/
+
+
+
+
+target			trgtest.exe
+targettype		exe
+
+systeminclude	\epoc32\include
+
+sourcepath		..\src
+source			trgtest.cpp
+
+VENDORID 0x70000001
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/source/trgtest/src/trgtest.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,1417 @@
+/*
+* Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+* e32utils\trgtest\trgtesth.cpp
+*
+*/
+
+
+#include <e32err.h>
+#include <windows.h>
+#include <shlwapi.h>
+#include <stdio.h>
+#include <time.h>
+
+#pragma comment(lib, "shlwapi.lib")
+
+const TUint8 SOH=0x01;
+const TUint8 STX=0x02;
+const TUint8 EOT=0x04;
+const TUint8 ACK=0x06;
+const TUint8 NAK=0x15;
+const TUint8 CAN=0x18;
+const TUint8 SUB=0x1A;
+const TUint8 BIGC=0x43;
+const TUint8 BIGG=0x47;
+
+// Try 115200bps first since it is the most commonly supported baud rate.  Newer platforms like the
+// NaviEngine support 230400bps and above.
+const TUint KDefaultBaudRate = 115200;
+const TUint KBaudRateSearchList[] = {KDefaultBaudRate, 230400, 460800};
+
+#define READ_BUF_SIZE	32768
+#define WRITE_BUF_SIZE	32768
+#define MAX_LINE		32768
+#define PACKET_SIZE		1024
+
+#define MIN(a,b)		((a)<(b)?(a):(b))
+#define OFFSET(p,off)	((void*)((char*)p+off))
+
+#define RESET_COMM()	PurgeComm(Comm, PURGE_RXCLEAR|PURGE_TXCLEAR)
+
+const TInt	KExitCodeOK							= 0;		// no failure
+const TInt	KExitCodeUsage						= 1;		// command like usage
+const TInt	KExitCodeLog						= 2;		// can't open log file
+const TInt	KExitCodeImage						= 3;		// can't open image file
+const TInt	KExitCodeSerial						= 4;		// can't open serial port
+const TInt	KExitCodeDownload					= 5;		// download started, but failed
+const TInt	KExitCodeFaulted					= 6;		// entered debug monitor abnormally
+const TInt	KExitCodeHung						= 7;		// target hung
+const TInt	KExitCodeDOA						= 8;		// board was in debug monitor at start
+const TInt	KExitCodeUnsupportedBaudRate		= 9;		// the baud rate set by the -b parameter is not supported by the PC's COM port
+const TInt	KExitCodeAssert						= 99;		// trgtest assertion failed
+
+FILE* LogFile = NULL;
+HANDLE Comm = INVALID_HANDLE_VALUE;
+
+char ImgFileName[MAX_PATH] = "";
+TInt ImgFileSize = 0;
+char LineBuf[MAX_LINE+1];
+void* ImgFileChunkBase = NULL;
+TBool use_stdout = false;
+
+enum EDebugMonitorOptions
+{
+	kDebugDumpCodeSegs = 1
+};
+
+TUint DebugMonitorOptions = kDebugDumpCodeSegs;
+
+#define TT_ASSERT(x)	__ASSERT_ALWAYS(x, __Panic(__LINE__))
+
+const char* GetWinErrMsg(DWORD errorCode)
+	{
+	static char lastErrorBuffer[512]; // not thread safe or reentrant (but shouldn't need to be)
+	strcpy(lastErrorBuffer, "Unknown error");
+	
+	if(errorCode != ERROR_SUCCESS)
+		{
+		if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, errorCode, 0, lastErrorBuffer, 512, NULL) != 0)
+			{
+			size_t size = strlen(lastErrorBuffer);
+			
+			// Strip any trailing carriage return.
+			if(StrCmpNI(lastErrorBuffer + size - 2, "\r\n", 2) == 0)
+				{
+				lastErrorBuffer[size - 2] = '\0';
+				size -= 2;
+				}
+
+			// Strip any trailing period.
+			if(lastErrorBuffer[size - 1] == '.')
+				{
+				lastErrorBuffer[size - 1] = '\0';
+				}
+			}
+		}
+	
+	return lastErrorBuffer;
+	}
+
+const char* GetSymOrWinErrMsg(TInt errorCode)
+	{
+	static char lastErrorBuffer[512]; // not thread safe or reentrant (but shouldn't need to be)
+	strcpy(lastErrorBuffer, "Unknown error");
+	
+	switch(errorCode)
+		{
+		case KErrNone:
+			{
+			// Unknown error
+			}
+		break;
+		case KErrEof:
+			{
+			strcpy(lastErrorBuffer, "Unexpected end of file");
+			}
+		break;
+		case KErrTimedOut:
+			{
+			strcpy(lastErrorBuffer, "Timed-out");
+			}
+		break;
+		default:
+			{
+			if(errorCode > 0)
+				{
+				strcpy(lastErrorBuffer, GetWinErrMsg(errorCode));
+				}
+			}
+		break;
+		}
+	
+	return lastErrorBuffer;
+	}
+
+void __Panic(TInt aLine)
+	{
+	fprintf(stderr, "Assertion failed at line %d\n", aLine);
+	exit(KExitCodeAssert);
+	}
+
+void WriteLog(const void* aBuf, TInt aLength)
+	{
+	if (LogFile)
+		fwrite(aBuf, 1, aLength, LogFile);
+	}
+
+void WriteLogS(const char* aString)
+	{
+	WriteLog( aString, strlen(aString) );
+	}
+
+void TraceLog(const char* aFmt, ...)
+	{
+	char buf[512];
+	va_list list;
+	va_start(list, aFmt);
+	if (!LogFile)
+		return;
+	sprintf(buf, "TRGTEST: ");
+	vsprintf(buf, aFmt, list);
+	strcat(buf, "\r\n");
+	WriteLogS(buf);
+	}
+
+/*
+YModem packet structure:
+Byte 0 = STX
+Byte 1 = sequence number (first user data packet is 1)
+Byte 2 = complement of sequence number
+Bytes 3-1026 = data (1K per packet)
+Bytes 1027, 1028 = 16-bit CRC (big-endian)
+
+A herald packet is sent first, with sequence number 0
+The data field consists of the null-terminated file name
+followed by the null-terminated file size in ASCII decimal
+digits.
+*/
+struct SPacket
+	{
+	TUint8 iPTI;
+	TUint8 iSeq;
+	TUint8 iSeqBar;
+	TUint8 iData[PACKET_SIZE];
+	TUint8 iCRC1;
+	TUint8 iCRC0;
+	};
+
+static const TUint16 crcTab[256] =
+    {
+	0x0000,0x1021,0x2042,0x3063,0x4084,0x50a5,0x60c6,0x70e7,0x8108,0x9129,0xa14a,
+	0xb16b,0xc18c,0xd1ad,0xe1ce,0xf1ef,0x1231,0x0210,0x3273,0x2252,0x52b5,0x4294,
+	0x72f7,0x62d6,0x9339,0x8318,0xb37b,0xa35a,0xd3bd,0xc39c,0xf3ff,0xe3de,0x2462,
+	0x3443,0x0420,0x1401,0x64e6,0x74c7,0x44a4,0x5485,0xa56a,0xb54b,0x8528,0x9509,
+	0xe5ee,0xf5cf,0xc5ac,0xd58d,0x3653,0x2672,0x1611,0x0630,0x76d7,0x66f6,0x5695,
+	0x46b4,0xb75b,0xa77a,0x9719,0x8738,0xf7df,0xe7fe,0xd79d,0xc7bc,0x48c4,0x58e5,
+	0x6886,0x78a7,0x0840,0x1861,0x2802,0x3823,0xc9cc,0xd9ed,0xe98e,0xf9af,0x8948,
+	0x9969,0xa90a,0xb92b,0x5af5,0x4ad4,0x7ab7,0x6a96,0x1a71,0x0a50,0x3a33,0x2a12,
+	0xdbfd,0xcbdc,0xfbbf,0xeb9e,0x9b79,0x8b58,0xbb3b,0xab1a,0x6ca6,0x7c87,0x4ce4,
+	0x5cc5,0x2c22,0x3c03,0x0c60,0x1c41,0xedae,0xfd8f,0xcdec,0xddcd,0xad2a,0xbd0b,
+	0x8d68,0x9d49,0x7e97,0x6eb6,0x5ed5,0x4ef4,0x3e13,0x2e32,0x1e51,0x0e70,0xff9f,
+	0xefbe,0xdfdd,0xcffc,0xbf1b,0xaf3a,0x9f59,0x8f78,0x9188,0x81a9,0xb1ca,0xa1eb,
+	0xd10c,0xc12d,0xf14e,0xe16f,0x1080,0x00a1,0x30c2,0x20e3,0x5004,0x4025,0x7046,
+	0x6067,0x83b9,0x9398,0xa3fb,0xb3da,0xc33d,0xd31c,0xe37f,0xf35e,0x02b1,0x1290,
+	0x22f3,0x32d2,0x4235,0x5214,0x6277,0x7256,0xb5ea,0xa5cb,0x95a8,0x8589,0xf56e,
+	0xe54f,0xd52c,0xc50d,0x34e2,0x24c3,0x14a0,0x0481,0x7466,0x6447,0x5424,0x4405,
+	0xa7db,0xb7fa,0x8799,0x97b8,0xe75f,0xf77e,0xc71d,0xd73c,0x26d3,0x36f2,0x0691,
+	0x16b0,0x6657,0x7676,0x4615,0x5634,0xd94c,0xc96d,0xf90e,0xe92f,0x99c8,0x89e9,
+	0xb98a,0xa9ab,0x5844,0x4865,0x7806,0x6827,0x18c0,0x08e1,0x3882,0x28a3,0xcb7d,
+	0xdb5c,0xeb3f,0xfb1e,0x8bf9,0x9bd8,0xabbb,0xbb9a,0x4a75,0x5a54,0x6a37,0x7a16,
+	0x0af1,0x1ad0,0x2ab3,0x3a92,0xfd2e,0xed0f,0xdd6c,0xcd4d,0xbdaa,0xad8b,0x9de8,
+	0x8dc9,0x7c26,0x6c07,0x5c64,0x4c45,0x3ca2,0x2c83,0x1ce0,0x0cc1,0xef1f,0xff3e,
+	0xcf5d,0xdf7c,0xaf9b,0xbfba,0x8fd9,0x9ff8,0x6e17,0x7e36,0x4e55,0x5e74,0x2e93,
+	0x3eb2,0x0ed1,0x1ef0
+    };
+
+void UpdateCrc(const void* aPtr, TInt aLength, TUint16& aCrc)
+//
+// Perform a CCITT CRC checksum.
+//
+	{
+
+	register const TUint8* pB = (const TUint8*)aPtr;
+	register TUint16 crc=aCrc;
+    while (aLength--)
+		crc=TUint16((crc<<8)^crcTab[(crc>>8)^*pB++]);
+	aCrc=crc;
+	}
+
+void ClearCommError()
+	{
+	DWORD err;
+	COMSTAT s;
+	TT_ASSERT(ClearCommError(Comm,&err,&s));
+	}
+	
+void OpenCommPort(TInt aPort)
+	{
+	char buf[20];
+
+	sprintf(buf, "\\\\.\\COM%d", aPort); // COM ports with indexes higher than 9 can only be referenced by prefixing the device name with "\\.\\"
+	Comm = CreateFile(buf, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
+	if (Comm == INVALID_HANDLE_VALUE)
+		{
+		if(GetLastError() == ERROR_ACCESS_DENIED)
+			{
+			fprintf(stderr, "Can't open COM%d: Error %d (Access denied) - a terminal application has probably been left running with the port still open\n", aPort, ERROR_ACCESS_DENIED);
+			}
+		else
+			{
+			fprintf(stderr, "Can't open COM%d: Error %d (%s)\n", aPort, GetLastError(), GetWinErrMsg(GetLastError()));
+			}
+		exit(KExitCodeSerial);
+		}
+
+	// Raise our thread priority to avoid being starved if builds are continuing in parallel while we are communicating with the target
+	// at high speeds.  TrgTest does not use serial flow control so if the buffers fill up, data will be lost.  We do not try to use the
+	// real-time process priority class because it requires administrator privileges.
+	SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
+	}
+	
+TInt SetupCommPort(TInt aPort, TUint aBaudRate, TBool aIgnoreInvalidBaudRateError = false)
+	{
+	TInt r = KErrNone;
+	const char* errFuncName = NULL;
+
+	DCB dcb;
+
+	dcb.DCBlength = sizeof(dcb);
+	if(!GetCommState(Comm, &dcb))
+		{
+		r = GetLastError();
+		errFuncName = "GetCommState";
+		}
+	else if(!SetCommMask(Comm, EV_ERR|EV_RXCHAR))
+		{
+		r = GetLastError();
+		errFuncName = "SetCommMask";
+		}
+	else if(!SetupComm(Comm, READ_BUF_SIZE, WRITE_BUF_SIZE))
+		{
+		r = GetLastError();
+		errFuncName = "SetupComm";
+		}
+	if(r != KErrNone)
+		{
+		TT_ASSERT(errFuncName);
+		
+		fprintf(stderr, "Error in SetupComm: Error %d (%s) calling %s\n", r, GetWinErrMsg(r), errFuncName);
+		TraceLog("Error in SetupComm: Error %d (%s) calling %s", r, GetWinErrMsg(r), errFuncName);
+		fprintf(stderr, "Trying to proceed anyway, be suspicious of any problems!\n");
+		TraceLog("Trying to proceed anyway, be suspicious of any problems!");
+		}
+	ClearCommError();
+	r = KErrNone;
+
+	dcb.fAbortOnError = TRUE;
+	dcb.BaudRate=aBaudRate;
+	dcb.Parity=NOPARITY;
+	dcb.fParity = FALSE;
+	dcb.fErrorChar = FALSE;
+	dcb.ByteSize = 8;
+	dcb.StopBits=ONESTOPBIT;
+	dcb.fInX  = FALSE;
+	dcb.fOutX = FALSE;
+	dcb.XonChar = 0;
+	dcb.XoffChar = 0;
+	dcb.ErrorChar = 0;
+	dcb.fOutxDsrFlow = FALSE;
+	dcb.fOutxCtsFlow = FALSE;
+	dcb.fDsrSensitivity =  FALSE;
+	dcb.fRtsControl = RTS_CONTROL_DISABLE;
+	dcb.fDtrControl = DTR_CONTROL_DISABLE;
+	if(!SetCommState(Comm, &dcb))
+		{
+		if(GetLastError() == ERROR_INVALID_PARAMETER)
+			{
+			r = KExitCodeUnsupportedBaudRate;
+
+			if(aIgnoreInvalidBaudRateError)
+				{
+				return r;
+				}
+			else
+				{
+				fprintf(stderr, "Error in SetCommState : Error %d (%s) - a baud rate of %dbps is not supported by COM%d - try a different port\n", GetLastError(), GetWinErrMsg(GetLastError()), aBaudRate, aPort);
+				TraceLog("Error in SetCommState : Error %d (%s) - a baud rate of %dbps is not supported by COM%d - try a different port", GetLastError(), GetWinErrMsg(GetLastError()), aBaudRate, aPort);
+				}
+			}
+		else
+			{
+			fprintf(stderr, "Error in SetCommState : Error %d calling (%s) SetCommState\n", GetLastError(), GetWinErrMsg(GetLastError()), aBaudRate);
+			TraceLog("Error in SetCommState : Error %d (%s) SetCommState", GetLastError(), GetWinErrMsg(GetLastError()), aBaudRate);
+			r = KExitCodeSerial;
+			}
+
+		exit(r);
+		}
+	EscapeCommFunction(Comm, SETDTR);
+	EscapeCommFunction(Comm, SETRTS);
+	
+	return KErrNone;
+	}
+
+void SetupTimeout(TInt aInt, TInt aTot)
+	{
+	COMMTIMEOUTS ct;
+	GetCommTimeouts(Comm, &ct);
+	ct.ReadIntervalTimeout = aInt;		// ms
+	ct.ReadTotalTimeoutMultiplier = 0;
+	ct.ReadTotalTimeoutConstant = aTot;	// ms
+	ct.WriteTotalTimeoutConstant = 0;
+	ct.WriteTotalTimeoutMultiplier = 0;
+	SetCommTimeouts(Comm, &ct);
+	}
+
+TInt CommRead1(TInt aTimeout)
+	{
+	unsigned char c;
+	DWORD n=0;
+	BOOL ok;
+
+	SetupTimeout(0, aTimeout);
+	ok = ReadFile(Comm, &c, 1, &n, NULL);
+	if (!ok)
+		ClearCommError();
+	if (ok && n)
+		return c;
+	return KErrTimedOut;
+	}
+
+TInt CommRead(void* aBuf, TInt aMax, TInt aTimeout)
+	{
+	DWORD n=0;
+	BOOL ok;
+
+	SetupTimeout(100, aTimeout);
+	ok = ReadFile(Comm, aBuf, aMax, &n, NULL);
+	if (!ok)
+		ClearCommError();
+	if (n==0)
+		return KErrTimedOut;
+	return n;
+	}
+
+void CommWrite(const void* aBuf, TInt aLen)
+	{
+	DWORD n = 0;
+	BOOL ok = WriteFile(Comm, aBuf, aLen, &n, NULL);
+	if (!ok)
+		ClearCommError();
+	}
+
+void CommWriteC(TUint aChar)
+	{
+	unsigned char c = (unsigned char)aChar;
+	CommWrite(&c, 1);
+	}
+
+void CommWriteS(const char* aString)
+	{
+	CommWrite( aString, strlen(aString) );
+	}
+
+TInt PreparePacket(SPacket& pkt, TInt aSeq, TInt& aOutBytesUploaded)
+	{
+	TInt r = KErrNone;
+	TUint16 crc = 0;
+
+	pkt.iPTI = STX;
+	pkt.iSeq = (TUint8)(aSeq>=0 ? aSeq : 0);
+	pkt.iSeqBar = (TUint8)~pkt.iSeq;
+	if (aSeq>0)
+		{
+		TInt l;
+		aOutBytesUploaded = (aSeq-1)*PACKET_SIZE;	// file position of packet
+		if ( aOutBytesUploaded >= ImgFileSize )
+			return KErrEof;
+		l = MIN(PACKET_SIZE, ImgFileSize-aOutBytesUploaded);
+		memcpy(pkt.iData, OFFSET(ImgFileChunkBase,aOutBytesUploaded), l);
+		if (l<PACKET_SIZE)
+			memset(pkt.iData+l, 0, PACKET_SIZE-l);
+		aOutBytesUploaded = max( aOutBytesUploaded, 0L );
+		}
+	else
+		{
+		aOutBytesUploaded = 0;
+		memset(pkt.iData, 0, PACKET_SIZE);
+		if (aSeq==0)
+			{
+			const char* p = ImgFileName;
+			const char* q = p + strlen(p);
+			while (--q>=p && *q!='\\') {}
+			sprintf( (char*)pkt.iData, "%s%c%d", q+1, 0, ImgFileSize);
+			}
+		}
+	UpdateCrc(pkt.iData, PACKET_SIZE, crc);
+	pkt.iCRC1 = (TUint8)(crc>>8);
+	pkt.iCRC0 = (TUint8)crc;
+	return r;
+	}
+
+TInt SendPacket(TInt& aSeq, TBool aStream, clock_t startTime)
+	{
+	TBool ackPacket = aSeq == -1;
+	TInt c;
+	SPacket pkt;
+	TInt retries = 10;
+	TInt tmout = (aSeq>=0) ? 2000 : 500;
+	TInt bytesUploaded;
+	
+	// Prepare the next packet.
+	TInt r = PreparePacket(pkt, aSeq, bytesUploaded);
+		
+	if (r==KErrNone)
+		{
+		// Keep trying to send the packet until it is acknowledged.
+		for(;;)
+			{
+			RESET_COMM();
+			CommWrite(&pkt, sizeof(pkt));
+			if (aStream)
+				break;
+			c = CommRead1(tmout);
+			if (c==KErrTimedOut && aSeq<0)
+				{
+				return KErrNone;
+				}
+			if (c>=0)
+				{
+				if (c==ACK)
+					break;
+				}
+			if (--retries==0)
+				{
+				r = KErrTimedOut;
+				break;
+				}
+			}
+	
+		// Check to see if the send operation was successful.	
+		if (r == KErrNone || (r == KErrEof))
+			{
+			// Verify the stream type for the first packet.
+			if(aSeq==0)
+				{
+				c = CommRead1(100);
+				if (c==KErrTimedOut)
+					{
+					r = KErrNone;
+					}
+				else if (aStream && c!=BIGG)
+					r = KErrTimedOut;
+				else if (!aStream && c!=BIGC)
+					r = KErrTimedOut;
+				}
+			
+			if(r == KErrNone)
+				{
+				++aSeq;
+				}
+			}
+		}
+		
+	// Print the progress info.
+	if (((r == KErrNone) && ((aSeq & 7) == 0)) || (r != KErrNone) || ackPacket)
+		{
+		// Calculate total packet count.
+		TInt totalPacketCount = (ImgFileSize / PACKET_SIZE) + 2; // one extra packet for handshake and one extra packet for acknowledgement
+		TInt roundedImageFileSize = ImgFileSize;
+		TInt remainderSize = ImgFileSize % PACKET_SIZE;
+		if(remainderSize != 0)
+			{
+			totalPacketCount ++;
+			roundedImageFileSize += (PACKET_SIZE - remainderSize);
+			}
+		
+		// Calculate the percentage complete.
+		TInt percentComplete = (bytesUploaded * 100) / roundedImageFileSize;
+		
+		// Calculate the ETA.
+		clock_t elapsedTime = clock() - startTime;
+		clock_t etaM = -1L;
+		clock_t etaS = -1L;
+		if(aSeq > 0)
+			{
+			double bytesPerSec = double(bytesUploaded) / (double(elapsedTime) / double(CLOCKS_PER_SEC));
+			clock_t etaTotalS = clock_t((double(roundedImageFileSize) - double(bytesUploaded)) / bytesPerSec);
+			etaM = max(etaTotalS / 60, 0L);
+			etaS = max(etaTotalS % 60, 0L);
+			}
+
+		// Ensure upload always halts at 100%.
+		if(ackPacket)
+			{
+			aSeq = totalPacketCount;
+			bytesUploaded = roundedImageFileSize;
+			percentComplete = 100;
+			etaM = 0L;
+			etaS = 0L;
+			}
+
+		// Format uploaded bytes and ROM size.
+		char sizeBuffer[256];
+		StrFormatByteSize(bytesUploaded, sizeBuffer, sizeof(sizeBuffer));
+		char imageSizeBuffer[256];
+		StrFormatByteSize(roundedImageFileSize, imageSizeBuffer, sizeof(imageSizeBuffer));
+
+		// Update the currently uploaded bytes, percentage complete and ETA in-place.
+		// We add additional spacing to overwrite the previous line if the new line
+		// contracts because the byte sizes have switched to larger units.
+		if(ackPacket)
+			{
+			elapsedTime /= CLOCKS_PER_SEC;
+			clock_t elapsedM = max(elapsedTime / 60, 0L);
+			clock_t elapsedS = max(elapsedTime % 60, 0L);
+			printf("\r%05d Packets Sent: %s / %s (%02d %%), Time Taken: %02d:%02d      ", aSeq, sizeBuffer, imageSizeBuffer, percentComplete, elapsedM, elapsedS);
+			}
+		else if((r == KErrNone) || (r == KErrEof))
+			{
+			if(etaM >= 0L)
+				{
+				printf("\r%05d Packets Sent: %s / %s (%02d %%), ETA: %02d:%02d      ", aSeq, sizeBuffer, imageSizeBuffer, percentComplete, etaM, etaS);
+				}
+			else
+				{
+				printf("\r%05d Packets Sent: %s / %s (%02d %%), ETA: ??:??      ", aSeq, sizeBuffer, imageSizeBuffer, percentComplete);
+				}
+			}
+		else
+			{
+			fprintf(stderr, "\rFailed to send packet %d: %s / %s (%02d %%), Error: %d (%s)      ", ackPacket ? (totalPacketCount - 1) : aSeq, sizeBuffer, imageSizeBuffer, percentComplete, r, GetSymOrWinErrMsg(r));
+			}
+		}
+		
+	return r;
+	}
+
+TInt GetMonitorInfo();
+
+TInt Handshake(TBool& aOutStream, TBool aIgnoreHandshakeFailure = false)
+	{
+	TInt r = 0;
+	TInt r2 = 0;
+	TUint8 b2[256];
+
+	Sleep(2000); // wait 2 seconds
+	RESET_COMM();
+	Sleep(2000); // wait 2 seconds
+flush:
+	r = CommRead(b2, sizeof(b2), 60000);	// 60 second timeout
+	if(r==sizeof(b2))
+		{
+		printf("Flushing data from port\n");
+		TraceLog("Flushing data from port");
+		goto flush;
+		}
+
+	if (r<0)
+		{
+		TraceLog("ERROR Handshake 1: r=%d (%s)", r, GetSymOrWinErrMsg(r));
+		// Send CR to see if it elicits monitor prompt
+		CommWriteC(0x0d);
+		r2 = CommRead(LineBuf, 12, 1000);		// 1 second timeout
+		if (r2==12 && memcmp(LineBuf, "\xd\xaPassword: ", 12)==0)
+			{
+			printf("ERROR: target is in debug monitor\n");
+			TraceLog("ERROR: target is in debug monitor");
+			if (LogFile)
+				{
+				printf("Gathering information...\n");
+				TraceLog("Gathering information...");
+				r2 = GetMonitorInfo();
+				printf("Rebooting...\n");
+				TraceLog("Rebooting...");
+				CommWriteS("X\xd");
+				}
+			else
+				{
+				printf("No logfile - preserving state (not rebooting)\n");
+				TraceLog("No logfile - preserving state (not rebooting)");
+				}
+			return KExitCodeDOA;
+			}
+		return r;
+		}
+	if (b2[r-1]!=BIGG && b2[r-1]!=BIGC)
+		{
+		if(!aIgnoreHandshakeFailure)
+			{
+			TraceLog("ERROR Handshake 2: r=%d (%s)", KErrTimedOut, GetSymOrWinErrMsg(KErrTimedOut));
+			}
+		return KErrTimedOut;
+		}
+		
+	aOutStream = (b2[r-1]==BIGG);
+	
+	return KErrNone;
+	}
+	
+TInt SendImageFile(TUint aPort, TUint aBaudRate, TBool aStream)
+	{
+	printf("Sending ROM image %s on COM%d at %dbps\n",ImgFileName,aPort,aBaudRate);
+	TraceLog("Sending ROM image %s on COM%d at %dbps",ImgFileName,aPort,aBaudRate);
+
+	TInt r = KErrNone;
+
+	// Keep sending packets until we reach the end of the file or an error occurs.
+	TInt seq = 0;
+	clock_t startTime = clock();
+	while(r==KErrNone)
+		{
+		r = SendPacket(seq, aStream, startTime);
+		}
+	
+	// If we reached the end of the file, acknowledge that the transfer is complete.
+	if(r==KErrEof)
+		{
+		RESET_COMM();
+		CommWriteC(EOT);
+		TInt b1 = CommRead1(500);
+		if (b1==KErrTimedOut)
+			{
+			r = KErrNone;
+			}
+		else if (b1!=ACK)
+			{
+			r = KErrNone;
+			}
+		
+		if(r == KErrNone)
+			{
+			printf("\n");
+			}
+		else
+			{
+			// Wait for acknowledgement from the target.
+			TBool noAck = false;
+			b1 = CommRead1(1000);
+			if (b1==KErrTimedOut)
+				{
+				r = KErrNone;
+				noAck = true;
+				}
+			else if (aStream && b1!=BIGG)
+				{
+				r = KErrNone;
+				noAck = true;
+				}
+			else if (!aStream && b1!=BIGC)
+				{
+				r = KErrNone;
+				noAck = true;
+				}
+			
+			// If there was no acknowledgement from the target, ignore the problem at this point and print the newline.
+			if(noAck)
+				{
+				printf("\n");
+				}
+
+			// Else, send our acknowledgement packet to complete the transfer.
+			else
+				{
+				seq = -1;
+				TInt bytesUploaded = 0;
+				r = SendPacket(seq, aStream, bytesUploaded);
+				printf("\n");
+				if(r)
+					{
+					TraceLog("ERROR: SendImageFile r=%d (%s)", r, GetSymOrWinErrMsg(r));
+					}
+				}
+			}
+		}
+		
+	// Else, print any error.
+	else
+		{
+		printf("\n<SendPacket %d -> %d (%s)\n", seq, r, GetSymOrWinErrMsg(r));
+		TraceLog("ERROR: <SendPacket seq=%d r=%d (%s)", seq, r, GetSymOrWinErrMsg(r));
+		}
+
+	return r;
+	}
+
+void GetResponse()
+	{
+	TInt r;
+	do	{
+		r = CommRead(LineBuf, MAX_LINE, 1000);
+		if (r>=0)
+			if(use_stdout)
+				{
+				LineBuf[r]=0;
+				printf(LineBuf);
+				}
+			else
+				{
+				WriteLog(LineBuf, r);
+				}
+		} while (r>=0);
+	}
+
+void IssueCommandAndGetResponse(const char* aCmd)
+	{
+	CommWriteS(aCmd);
+	GetResponse();
+	}
+
+int token_length(const char* s)
+	{
+	const char* p = s;
+	for (; *p && !isspace(*p); ++p) {}
+	return p - s;
+	}
+
+const char* skip_space(const char* s)
+	{
+	for (; *s && isspace(*s); ++s) {}
+	return s;
+	}
+
+TInt GetMonitorInfo()
+/*
+ return 0 on success, -1 on failure
+ */
+	{
+	BOOL ok = FALSE;
+	int l;
+	int type;
+	RESET_COMM();
+	IssueCommandAndGetResponse("replacement\xd");
+	IssueCommandAndGetResponse("f\xd");
+	const char* p = LineBuf;
+	const char* q = LineBuf + strlen(LineBuf);
+	while (p<q)
+		{
+		p = skip_space(p);
+		if (p+16>q || memcmp(p, "Fault Category: ", 16))
+			{
+			p += token_length(p);
+			continue;
+			}
+		p = skip_space(p+16);
+		l = token_length(p);
+		if (l!=4 || memcmp(p, "KERN", 4))
+			{
+			p += l;
+			continue;
+			}
+		p = skip_space(p+4);
+		if (p+14>q || memcmp(p, "Fault Reason: ", 14))
+			{
+			p += token_length(p);
+			continue;
+			}
+		p = skip_space(p+14);
+		if (p+8<=q && memcmp(p, "00000050", 8)==0)
+			{
+			ok = true;
+			break;
+			}
+		p+=8;
+		continue;
+		}
+	if (ok)
+		{
+		// Add a line after the "." debug monitor prompt so the next log line won't appear next to it.
+		TraceLog("");
+		
+		return 0;
+		}
+
+	IssueCommandAndGetResponse("i\xd");
+	for (type=0; type<14; ++type)
+		{
+		char b[8];
+		sprintf(b, "c%x\xd", type);
+		IssueCommandAndGetResponse(b);
+		}
+
+	IssueCommandAndGetResponse("S\xd");
+	
+	// Optionally, dump the code segs to make it clear where non-XIP code is loaded
+	// and make debugging easier.
+	if(DebugMonitorOptions & kDebugDumpCodeSegs)
+		{
+		IssueCommandAndGetResponse("p all\xd");
+		}
+		
+	// Add a line after the "." debug monitor prompt so the next log line won't appear next to it.
+	TraceLog("");
+
+	return -1;
+	}
+	
+TInt ReceiveTestLog(TInt aOverallTimeOutS)
+	{
+	TInt r=0;
+	TInt r2;
+	clock_t iterationStartTime = clock();
+	
+	for(;;)
+		{
+		TBool checkDebugMonitor = false;
+		
+		r = CommRead(LineBuf, MAX_LINE, aOverallTimeOutS * 1000);
+		
+		// If a time-out occured, print an error message.
+		if (r==KErrTimedOut)
+			{
+			clock_t elapsedTimeC = clock() - iterationStartTime;
+			double elapsedTimeS = double(elapsedTimeC) / double(CLOCKS_PER_SEC);
+
+			if(elapsedTimeS < 10.0)
+				{
+				if(!use_stdout)
+					{
+					fprintf(stderr, "Nothing received for past %.02f seconds\n", elapsedTimeS);
+					}
+				TraceLog("Nothing received for past %.02f seconds", elapsedTimeS);
+				}
+			else
+				{
+				elapsedTimeC /= CLOCKS_PER_SEC;
+				clock_t elapsedM = max(elapsedTimeC / 60, 0L);
+				clock_t elapsedS = max(elapsedTimeC % 60, 0L);
+
+				if(!use_stdout)
+					{
+					fprintf(stderr, "Nothing received for past %02d:%02d minutes\n", elapsedM, elapsedS);
+					}
+				TraceLog("Nothing received for past %02d:%02d minutes", elapsedM, elapsedS);
+				}
+
+			checkDebugMonitor = true;
+			}
+			
+		// If the string "Password: " was read, this probably indicates the kernel
+		// has jumped into the debug monitor.
+		if (r>=10 && memcmp(LineBuf+r-10, "Password: ", 10)==0)
+			{
+			checkDebugMonitor = true;
+			}
+			
+		// If real data was received, print it to the selected output.
+		if (r>0)
+			{
+			if (use_stdout)
+				{
+				LineBuf[r]=0;		// terminate string
+				printf(LineBuf);
+				}
+			else
+				{
+				WriteLog(LineBuf, r);
+				}
+
+			iterationStartTime = clock();
+			}
+		
+		// If an error occured, check to see if the debug monitor is running.  If it is,
+		// we can extract information about the fault and use it to reboot the board.
+		if (checkDebugMonitor || (r==KErrTimedOut))
+			{
+			// Send CR to see if it elicits monitor prompt.
+			CommWriteC(0x0d);
+			r2 = CommRead(LineBuf, 12, 1000);
+			if (r2>0)
+				{
+				if(use_stdout)
+					{
+					LineBuf[r2]=0;
+					printf(LineBuf);
+					}
+				else
+					{
+					WriteLog(LineBuf, r2);
+					}
+				}
+			if (r2==12 && memcmp(LineBuf, "\xd\xaPassword: ", 12)==0)
+				{
+				break;
+				}
+			}
+			
+		// If an error occured and the debug monitor is not running, stop trying to receive the session log.
+		if (r<0)
+			{
+			break;
+			}
+		}
+
+	// Check to see if the debug monitor was successfully prompted.
+	TT_ASSERT((r>0) || (r==KErrTimedOut));
+	if (r>0)
+		{
+		// The debug monitor is accessible so extract debugging information.
+		r = GetMonitorInfo();
+		
+		// Issue the command to try to reboot the board.
+		CommWriteS("X\xd");
+		if (r)
+			{
+			r = KExitCodeFaulted;
+			}
+		else
+			{
+			r = KErrNone;
+			}
+		}
+	else if(r<0)
+		{
+		// The board debug monitor is not accessible or the board has locked up.
+		printf("Target hung\n");
+		TraceLog("Target hung");
+		r = KExitCodeHung;
+		}
+		
+	return r;	
+	}
+
+TInt DetermineBaudRate(TInt aPort, TUint& outBaudRate, TBool& aOutStream)
+	{
+	TInt r = KErrNone;
+	
+	for( TUint i = 0; i < sizeof(KBaudRateSearchList) / sizeof(TUint); i ++ )
+		{
+		// Set the COM port to use the next baud rate to try.
+		if(i != 0)	// hide the first test so that the UI for boards supporting 115200bps-only remains the same as it
+			{		// was before.
+			printf("Testing COM%d at %dbps...", aPort, KBaudRateSearchList[i]);
+			}
+		TraceLog("Testing COM%d at %dbps", aPort, KBaudRateSearchList[i]);
+		r = SetupCommPort(aPort, KBaudRateSearchList[i], true);
+
+		if(r == KErrNone)
+			{
+			// Try to Y-modem handshake with the board.  If we succeed then we have found the correct speed.
+			r = Handshake(aOutStream, true);
+			if(r == KErrNone)
+				{
+				if(i != 0)
+					{
+					// If we finished the first test (115200bps) successfully, we do not reveal the fact that we are
+					// prepared to test multiple baud rates so that the UI for boards supporting 115200bps only remains
+					// the same as it was before.
+					printf(" Succeeded\n", aPort, KBaudRateSearchList[i]);
+					}
+				TraceLog("Testing of COM%d at %dbps Succeeded", aPort, KBaudRateSearchList[i]);
+				outBaudRate = KBaudRateSearchList[i];
+				
+				break;
+				}
+			else if(r == KExitCodeDOA)
+				{
+				// The board is stuck in the crash debugger and is unusable.
+				break;
+				}
+			else
+				{
+				if(i == 0)
+					{
+					// If we finished the first test (115200bps) unsuccessfully, at this point we reveal that we are
+					// testing multiple baud rates and report the results of the failure.
+					printf("Testing COM%d at %dbps...", aPort, KBaudRateSearchList[i]);
+					}
+				printf(" Failed (%d) %s\n", r, GetSymOrWinErrMsg(r));
+				TraceLog("Testing of COM%d at %dbps Failed (%d) %s", aPort, KBaudRateSearchList[i], r, GetSymOrWinErrMsg(r));
+				}
+			}
+		else if(r == KExitCodeUnsupportedBaudRate)
+			{
+			if(i == 0)
+				{
+				// If we finished the first test (115200bps) and the baud rate setting is unsupported, at this point
+				// we reveal that we are testing multiple baud rates and report the results of the failure.
+				printf("Testing COM%d at %dbps...", aPort, KBaudRateSearchList[i]);
+				}
+			printf(" COM%d port doesn't support this baud rate setting\n", aPort);
+			TraceLog("COM%d port doesn't support %dbps setting", aPort, KBaudRateSearchList[i]);
+			}
+		}
+		
+	return r;
+	}
+
+void UploadROM(TInt aPort, TUint& aInOutBaudRate)
+	{
+	// Open the ROM image file and copy it into memory.
+	FILE* img = fopen(ImgFileName, "rb");
+	if (!img)
+		{
+		fprintf(stderr, "Can't open %s for read (%d) %s\n", ImgFileName, errno, strerror(errno));
+		exit(KExitCodeImage);
+		}
+	fseek(img,0,SEEK_END);
+	ImgFileSize=ftell(img);
+	fseek(img,0,SEEK_SET);
+	TraceLog("ROM Image File Size   = %d bytes\n", ImgFileSize);
+	ImgFileChunkBase = malloc(ImgFileSize);
+	TT_ASSERT(ImgFileChunkBase != NULL);
+	int n = fread(ImgFileChunkBase, 1, ImgFileSize, img);
+	TT_ASSERT(n == ImgFileSize);
+	fclose(img);
+
+	// Check to see if we should flash the ROM image or the boot loader based
+	// on the filename of the tool.
+	if (strcmpi("flashimg", __argv[0])==0)
+		{
+		printf("Uploading image %s to flash ", ImgFileName);
+		if (strstr(ImgFileName, ".zip") || strstr(ImgFileName, ".zip"))
+			strcpy(ImgFileName, "flashimg.zip");
+		else
+			strcpy(ImgFileName, "flashimg.bin");
+		printf("[%s]\n", ImgFileName);
+		}
+	else if (strcmpi("flashldr", __argv[0])==0)
+		{
+		printf("Uploading image %s to flash as bootloader ", ImgFileName);
+		if (strstr(ImgFileName, ".zip") || strstr(ImgFileName, ".zip"))
+			strcpy(ImgFileName, "flashldr.zip");
+		else
+			strcpy(ImgFileName, "flashldr.bin");
+		printf("[%s]\n", ImgFileName);
+		}
+
+	// Open the COM port.
+	OpenCommPort(aPort);
+	
+	// Check to see if we should try to automatically determine the baud rate.
+	TInt r;
+	TBool stream = true;
+	if(aInOutBaudRate == 0)
+		{
+		r = DetermineBaudRate(aPort, aInOutBaudRate, stream);
+		if(r != KErrNone)
+			{
+			if(r != KExitCodeDOA) // DetermineBaudRate prints its own error message for KExitCodeDOA
+				{
+				fprintf(stderr, "Unable to determine baud rate or the target is hung/unplugged\n");
+				TraceLog("Unable to determine baud rate or the target is hung/unplugged");
+				}
+			exit(r);
+			}
+		}
+	else
+		{
+		r = SetupCommPort(aPort, aInOutBaudRate);
+		if(r == KErrNone)
+			{
+			r = Handshake(stream);
+			}
+		if(r != KErrNone)
+			{
+			fprintf(stderr, "Unable to connect to target on COM%d at %dbps (%d) %s\n", aPort, aInOutBaudRate, r, GetSymOrWinErrMsg(r));
+			TraceLog("Unable to connect to target on COM%d at %dbps (%d) %s", aPort, aInOutBaudRate, r, GetSymOrWinErrMsg(r));
+			exit(r);
+			}
+		}
+
+	// Send the image.
+	r = SendImageFile(aPort, aInOutBaudRate, stream);
+	
+	free(ImgFileChunkBase);
+	}
+	
+TInt LogTargetOutput(const char* aLogFileName, TBool aUseStdOut, TInt aPort, TUint& aInOutBaudRate, TUint& aInOutLogBaudRate, TInt aOverallTimeOutS)
+	{
+	TInt r;
+	
+	// Switch to the session log baud rate (default 115200bps) - higher speeds are usually only used for serial
+	// upload and not for the log download.  It is possible to utilise higher log baud rates by manually modifying
+	// the debugport code in the board support package.
+	if(aInOutBaudRate != aInOutLogBaudRate)
+		{
+		r = SetupCommPort(aPort, aInOutLogBaudRate);
+
+		if(r != KErrNone)
+			{
+			fprintf(stderr, "Unable to switch to session log baud rate (%dbps) or the target is hung/unplugged\n", aInOutLogBaudRate);
+			TraceLog("Unable to switch to session log baud rate (%dbps) or the target is hung/unplugged", aInOutLogBaudRate);
+			exit(r);
+			}
+		
+		aInOutBaudRate = aInOutLogBaudRate;
+		}
+
+	// Check to see if we are logging to STDOUT or to a file.
+	if(!aUseStdOut)
+		{
+		printf("Logging target output from COM%d at %dbps to %s...\n", aPort, aInOutLogBaudRate, aLogFileName);
+		TraceLog("BEGIN TARGET LOG", aLogFileName);
+		}
+	
+	// Receive the session log.
+	clock_t startTime = clock();
+	r = ReceiveTestLog(aOverallTimeOutS);
+	
+	// Print the duration of the session.
+	clock_t elapsedTimeC = clock() - startTime;
+	double elapsedTimeS = double(elapsedTimeC) / double(CLOCKS_PER_SEC);
+	if(elapsedTimeS < 10.0)
+		{
+		if(!use_stdout)
+			{
+			printf("Target output log ended after %.02f seconds\n", elapsedTimeS);
+			}
+		TraceLog("END TARGET LOG after %.02f seconds", elapsedTimeS);
+		}
+	else
+		{
+		elapsedTimeC /= CLOCKS_PER_SEC;
+		clock_t elapsedM = max(elapsedTimeC / 60, 0L);
+		clock_t elapsedS = max(elapsedTimeC % 60, 0L);
+
+		if(!use_stdout)
+			{
+			printf("Target output log ended after %02d:%02d minutes\n", elapsedM, elapsedS);
+			}
+		TraceLog("END TARGET LOG after %02d:%02d minutes", elapsedM, elapsedS);
+		}
+	
+	return r;
+	}
+	
+void CloseSession()
+	{
+	// Perform cleanup...
+	
+	WriteLogS("\n\n");
+	TraceLog("DONE");
+
+	EscapeCommFunction(Comm, CLRRTS);
+	EscapeCommFunction(Comm, CLRDTR);
+
+	if(Comm != INVALID_HANDLE_VALUE)
+		{
+		CloseHandle(Comm);
+		Comm = INVALID_HANDLE_VALUE;
+		}
+
+	if (LogFile)
+		{
+		fclose(LogFile);
+		LogFile = NULL;
+		}
+	}
+
+void PrintHelp()
+	{
+	fprintf(stderr, "\n");
+	fprintf(stderr, "TrgTest Serial Y-Modem Upload Test Utility\n");
+	fprintf(stderr, "==========================================\n\n");
+	fprintf(stderr, "trgtest port# [-b<baudrate> default: 0 (auto)] [-lb<baudrate> default: 115200]");
+	fprintf(stderr, "        imagefilename [logfilename] [timeout]\n\n");
+	fprintf(stderr, "  port#              = COM port e.g., \"1\"\n");
+	fprintf(stderr, "  -b (optional)      = ROM image serial upload baud rate e.g., \"-b115200\"\n");
+	fprintf(stderr, "  -lb (opt.)         = session log download baud rate e.g., \"-lb115200\"\n");
+	fprintf(stderr, "  imagefilename      = path to ROM image e.g., \"rom.img\" or \"nul\" for no image\n");
+	fprintf(stderr, "  logfilename (opt.) = path to session log e.g., \"test.log\" or \"-\" for STDOUT\n");
+	fprintf(stderr, "  timeout (opt.)     = timeout after inactivity in seconds e.g., \"1800\"\n\n");
+	fprintf(stderr, "Example Usage:\n\n");
+	fprintf(stderr, "  trgtest 1 rom.img log.txt\n");
+	}
+
+
+int main(int argc, char** argv)
+	{
+	TInt r = KErrNone;
+	TInt port = 0;
+	TUint baudRate = 0;
+	TUint logBaudRate = 0;
+	TInt overallTimeOutS = 1800;  // default time to wait for output (in seconds)
+	const char* logfilename = NULL;
+	int paramIndex = 1;
+	
+	// Disable stream buffering.
+	setvbuf(stdout,NULL,_IONBF,0);
+	
+	// Print help if the parameter count is incorrect.
+	if (argc<3 || argc>7)
+		{
+		PrintHelp();
+		exit(KExitCodeUsage);
+		}
+		
+	// Get the COM port.
+	if(isdigit(argv[paramIndex][0]))
+		{
+		port = atoi(argv[paramIndex]);
+		if(port == 0)
+			{
+			fprintf(stderr, "\"0\" is not valid - specify a serial COM port index number >= 1");
+			exit(KExitCodeUsage);
+			}
+		paramIndex ++;
+		}
+	else
+		{
+		fprintf(stderr, "\"%s\" is not valid - specify a serial COM port index number >= 1", argv[paramIndex]);
+		exit(KExitCodeUsage);
+		}
+	
+	// Parse the optional parameters - order is not important.	
+	while(paramIndex < argc)
+		{
+		// Get the serial upload baud rate.
+		if(StrCmpNI(argv[paramIndex], "-b", 2) == 0)
+			{
+			baudRate = atoi(argv[paramIndex] + 2);
+			paramIndex ++;
+			}
+			
+		// Get the session log baud rate.
+		else if(StrCmpNI(argv[paramIndex], "-lb", 3) == 0)
+			{
+			logBaudRate = atoi(argv[paramIndex] + 3);
+			paramIndex ++;
+			}
+		
+		// Stop if we parse an unknown option - it is probably the ROM image file path.	
+		else
+			{
+			break;
+			}
+		}
+		
+	// If no session log baud rate was specified, set the default rate of 115200bps.
+	if(logBaudRate == 0)
+		{
+		logBaudRate = KDefaultBaudRate;
+		}
+		
+	// Get the ROM image file path.
+	if(paramIndex >= argc)
+		{
+		fprintf(stderr, "No ROM image file specified\n");
+		exit(KExitCodeUsage);
+		}
+	strcpy(ImgFileName, argv[paramIndex]);
+	paramIndex ++;
+
+	// Get the session log options.
+	if (paramIndex < argc)
+		{
+		// Check to see if TrgTest should log the target output and to what.
+		logfilename = argv[paramIndex];
+		if (!strcmp(logfilename, "-"))
+			{
+			printf("After the upload has completed, TrgTest will read from the serial port and write to STDOUT.\n");
+			use_stdout = true;
+			}
+		else
+			{
+			LogFile = fopen(logfilename, "wb");
+			
+			if (!LogFile)
+				{
+				fprintf(stderr, "Can't open %s for write (%d) %s\n", logfilename, errno, strerror(errno));
+				exit(KExitCodeLog);
+				}
+			
+			// Disable stream buffering.
+			setvbuf(LogFile,NULL,_IONBF,0);
+			}
+		paramIndex ++;
+
+		// Check to see if a non-default inactivity timeout has been specified.
+		if (paramIndex < argc)
+			{
+			overallTimeOutS = atoi(argv[paramIndex]);
+			}
+		}
+
+	TBool sendImage = strcmpi(ImgFileName, "nul") != 0;
+
+	// Log the trgtest parameters.
+	TraceLog("Port                  = COM%d", port);
+	if(sendImage)
+		{
+		if(baudRate == 0)
+			{
+			TraceLog("Baud Rate             = Auto");
+			}
+		else
+			{
+			TraceLog("Baud Rate             = %dbps", baudRate);
+			}
+		TraceLog("ROM Image             = %s", ImgFileName);
+		}
+	else
+		{
+		TraceLog("ROM Image             = None");
+		}
+	TraceLog("Log Baud Rate         = %dbps", logBaudRate);
+	if(use_stdout)
+		{
+		TraceLog("Log                   = STDOUT");
+		}
+	else if(logfilename)
+		{
+		TraceLog("Log                   = %s", logfilename);
+		}
+	else
+		{
+		TraceLog("Log                   = None", logfilename);
+		}
+	TraceLog("Inactivity Timeout    = %d secs.", overallTimeOutS);
+	if(DebugMonitorOptions & kDebugDumpCodeSegs)
+		{
+		TraceLog("Debug Monitor Options = Dump Code Segs");
+		}
+	else
+		{
+		TraceLog("Debug Monitor Options = None");
+		}
+
+	// Initiate serial upload if a ROM image was specified.
+	if(sendImage)
+		{
+		UploadROM(port, baudRate);
+		}
+
+	if(r==KErrNone)
+		{
+		// Check to see if the ROM upload (if any) succeeded.
+		if(sendImage)
+			{
+			printf("Sent image file OK\n");
+			TraceLog("Sent image file OK");
+			}
+		
+		// Check to see if we should log the target output.
+		if (LogFile || use_stdout)
+			{
+			// If no serial upload was performed the COM port is not yet open.
+			if(!sendImage)
+				{
+				// Open the COM port.
+				OpenCommPort(port);
+				}
+
+			// Log the target output if a log file was specified.
+			r = LogTargetOutput(logfilename, use_stdout, port, baudRate, logBaudRate, overallTimeOutS);
+			}
+		}
+	else
+		{
+		printf("SendImageFile upload failed -> (%d) %s\n", r, GetSymOrWinErrMsg(r));
+		TraceLog("SendImageFile upload failed -> (%d) %s", r, GetSymOrWinErrMsg(r));
+		r = KExitCodeDownload;
+		}
+
+	// Close the session
+	CloseSession();
+
+	// Print any exit error. 
+	if (r!=KErrNone)
+		{
+		fprintf(stderr, "Exiting with error %d\n", r);
+		}
+
+	return r;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatcomms/include.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,24 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#include "stdafx.h"
+
+#include "D://development//test_harness//automation//stat//3.0//desktop//cstatlogfile.cpp"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatcomms/resource.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by testcom.rc
+//
+#define IDD_TESTCOM_DIALOG              102
+#define IDR_MAINFRAME                   128
+#define IDC_OUT                         1000
+#define IDC_IN                          1001
+#define IDC_TRANSFER                    1002
+#define IDC_LIST1                       1003
+#define IDC_LIST2                       1004
+#define IDC_BUTTON1                     1005
+#define IDC_TRANSPORT                   1006
+#define IDC_PORT                        1007
+
+// Next default values for new objects
+// 
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE        130
+#define _APS_NEXT_COMMAND_VALUE         32771
+#define _APS_NEXT_CONTROL_VALUE         1008
+#define _APS_NEXT_SYMED_VALUE           101
+#endif
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatcomms/stdafx.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// stdafx.cpp : source file that includes just the standard includes
+//	testcom.pch will be the pre-compiled header
+//	stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatcomms/stdafx.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// stdafx.h : include file for standard system include files,
+//  or project specific include files that are used frequently, but
+//      are changed infrequently
+//
+
+#if !defined(AFX_STDAFX_H__F5EDDB5A_81F0_11D6_BC69_00B0D065107F__INCLUDED_)
+#define AFX_STDAFX_H__F5EDDB5A_81F0_11D6_BC69_00B0D065107F__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define VC_EXTRALEAN		// Exclude rarely-used stuff from Windows headers
+
+#include <afxwin.h>         // MFC core and standard components
+#include <afxext.h>         // MFC extensions
+#include <afxdtctl.h>		// MFC support for Internet Explorer 4 Common Controls
+#ifndef _AFX_NO_AFXCMN_SUPPORT
+#include <afxcmn.h>			// MFC support for Windows Common Controls
+#endif // _AFX_NO_AFXCMN_SUPPORT
+
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__F5EDDB5A_81F0_11D6_BC69_00B0D065107F__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatcomms/testcom.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// testcom.cpp : Defines the class behaviors for the application.
+//
+
+#include "stdafx.h"
+#include "testcom.h"
+#include "testcomDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CTestcomApp
+
+BEGIN_MESSAGE_MAP(CTestcomApp, CWinApp)
+	//{{AFX_MSG_MAP(CTestcomApp)
+	//}}AFX_MSG
+	ON_COMMAND(ID_HELP, CWinApp::OnHelp)
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CTestcomApp construction
+
+CTestcomApp::CTestcomApp()
+{
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// The one and only CTestcomApp object
+
+CTestcomApp theApp;
+
+/////////////////////////////////////////////////////////////////////////////
+// CTestcomApp initialization
+
+BOOL CTestcomApp::InitInstance()
+{
+	// Standard initialization
+
+	CTestcomDlg dlg;
+	m_pMainWnd = &dlg;
+	int nResponse = dlg.DoModal();
+	if (nResponse == IDOK)
+	{
+	}
+	else if (nResponse == IDCANCEL)
+	{
+	}
+
+	// Since the dialog has been closed, return FALSE so that we exit the
+	//  application, rather than start the application's message pump.
+	return FALSE;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatcomms/testcom.dsp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,192 @@
+# Microsoft Developer Studio Project File - Name="testcom" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Application" 0x0101
+
+CFG=testcom - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "testcom.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "testcom.mak" CFG="testcom - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "testcom - Win32 Release" (based on "Win32 (x86) Application")
+!MESSAGE "testcom - Win32 Debug" (based on "Win32 (x86) Application")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName "testcom"
+# PROP Scc_LocalPath ".."
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "testcom - Win32 Release"
+
+# PROP BASE Use_MFC 6
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 6
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I ".\inc" /I ".\src" /I "..\..\..\source\dll\transport\inc" /I "..\..\..\source\dll\inc" /I "..\..\..\source\regaccess\inc" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG" /d "_AFXDLL"
+# ADD RSC /l 0x809 /d "NDEBUG" /d "_AFXDLL"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
+# ADD LINK32 Ws2_32.lib /nologo /subsystem:windows /machine:I386
+
+!ELSEIF  "$(CFG)" == "testcom - Win32 Debug"
+
+# PROP BASE Use_MFC 6
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 6
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I ".\inc" /I ".\src" /I "..\..\..\source\dll\transport\inc" /I "..\..\..\source\dll\inc" /I "..\..\..\source\regaccess\inc" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /Yu"stdafx.h" /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG" /d "_AFXDLL"
+# ADD RSC /l 0x809 /d "_DEBUG" /d "_AFXDLL"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 Ws2_32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
+
+!ENDIF 
+
+# Begin Target
+
+# Name "testcom - Win32 Release"
+# Name "testcom - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\..\..\source\dll\transport\src\STATComms.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\source\dll\transport\src\statserial.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\source\dll\transport\src\statserialbluetooth.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\source\dll\transport\src\statsocket_block.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.cpp
+# ADD CPP /Yc"stdafx.h"
+# End Source File
+# Begin Source File
+
+SOURCE=.\testcom.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\testcom.rc
+# End Source File
+# Begin Source File
+
+SOURCE=.\testcomDlg.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\..\..\source\dll\inc\cstatreturncodes.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\resource.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\source\dll\inc\stat.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\source\dll\inc\statcommon.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\source\dll\transport\inc\statcomms.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\source\dll\transport\inc\statserial.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\source\dll\transport\inc\statserialbluetooth.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\source\dll\transport\inc\statsocket_block.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\source\dll\transport\inc\stattransport.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\testcom.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\testcomDlg.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# Begin Source File
+
+SOURCE=.\res\testcom.ico
+# End Source File
+# Begin Source File
+
+SOURCE=.\res\testcom.rc2
+# End Source File
+# End Group
+# End Target
+# End Project
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatcomms/testcom.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,67 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// testcom.h : main header file for the TESTCOM application
+//
+
+#if !defined(AFX_TESTCOM_H__F5EDDB56_81F0_11D6_BC69_00B0D065107F__INCLUDED_)
+#define AFX_TESTCOM_H__F5EDDB56_81F0_11D6_BC69_00B0D065107F__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#ifndef __AFXWIN_H__
+	#error include 'stdafx.h' before including this file for PCH
+#endif
+
+#include "resource.h"		// main symbols
+
+/////////////////////////////////////////////////////////////////////////////
+// CTestcomApp:
+// See testcom.cpp for the implementation of this class
+//
+
+class CTestcomApp : public CWinApp
+{
+public:
+	CTestcomApp();
+
+// Overrides
+	// ClassWizard generated virtual function overrides
+	//{{AFX_VIRTUAL(CTestcomApp)
+	public:
+	virtual BOOL InitInstance();
+	//}}AFX_VIRTUAL
+
+// Implementation
+
+	//{{AFX_MSG(CTestcomApp)
+	//}}AFX_MSG
+	DECLARE_MESSAGE_MAP()
+};
+
+
+/////////////////////////////////////////////////////////////////////////////
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_TESTCOM_H__F5EDDB56_81F0_11D6_BC69_00B0D065107F__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatcomms/testcom.rc	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,217 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_TESTCOM_DIALOG DIALOGEX 0, 0, 265, 151
+STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | 
+    WS_SYSMENU
+EXSTYLE WS_EX_APPWINDOW
+CAPTION "STAT Device Communications Test"
+FONT 8, "MS Sans Serif"
+BEGIN
+    DEFPUSHBUTTON   "Listen / Stop",IDC_TRANSFER,150,129,50,14
+    PUSHBUTTON      "Close",IDOK,208,129,50,14
+    LISTBOX         IDC_LIST1,7,36,251,87,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | 
+                    WS_TABSTOP
+    COMBOBOX        IDC_TRANSPORT,7,131,78,90,CBS_DROPDOWNLIST | WS_VSCROLL | 
+                    WS_TABSTOP
+    EDITTEXT        IDC_PORT,94,129,47,14,ES_AUTOHSCROLL
+    LTEXT           "This dialog is used to test a STAT connection to the device.  Whatever is sent down will be bounced straight back, with the exception of <S> and <R> which read and send the files C:\\basicscreen.mbm and C:\\basicapp.exe respectively.",
+                    IDC_STATIC,7,7,251,27
+END
+
+
+#ifndef _MAC
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,0,0,1
+ PRODUCTVERSION 1,0,0,1
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904B0"
+        BEGIN
+            VALUE "CompanyName", "\0"
+            VALUE "FileDescription", "testcom MFC Application\0"
+            VALUE "FileVersion", "1, 0, 0, 1\0"
+            VALUE "InternalName", "testcom\0"
+            VALUE "LegalCopyright", "Copyright (C) 2002\0"
+            VALUE "LegalTrademarks", "\0"
+            VALUE "OriginalFilename", "testcom.EXE\0"
+            VALUE "ProductName", "testcom Application\0"
+            VALUE "ProductVersion", "1, 0, 0, 1\0"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x409, 1200
+    END
+END
+
+#endif    // !_MAC
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE 
+BEGIN
+    IDD_TESTCOM_DIALOG, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 258
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 143
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog Info
+//
+
+IDD_TESTCOM_DIALOG DLGINIT
+BEGIN
+    IDC_TRANSPORT, 0x403, 16, 0
+0x7953, 0x626d, 0x6169, 0x436e, 0x6e6f, 0x656e, 0x7463, 0x0020, 
+    IDC_TRANSPORT, 0x403, 14, 0
+0x7953, 0x626d, 0x6169, 0x536e, 0x636f, 0x656b, 0x0074, 
+    IDC_TRANSPORT, 0x403, 14, 0
+0x7953, 0x626d, 0x6169, 0x536e, 0x7265, 0x6169, 0x006c, 
+    IDC_TRANSPORT, 0x403, 16, 0
+0x7953, 0x626d, 0x6169, 0x496e, 0x666e, 0x6172, 0x6572, 0x0064, 
+    IDC_TRANSPORT, 0x403, 17, 0
+0x7953, 0x626d, 0x6169, 0x426e, 0x756c, 0x7465, 0x6f6f, 0x6874, "\000" 
+    IDC_TRANSPORT, 0x403, 11, 0
+0x7953, 0x626d, 0x6169, 0x556e, 0x4253, "\000" 
+    0
+END
+
+#endif    // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.K.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "#include ""afxres.h""\r\n"
+    "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
+    "#define _AFX_NO_OLE_RESOURCES\r\n"
+    "#define _AFX_NO_TRACKER_RESOURCES\r\n"
+    "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
+    "\r\n"
+    "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
+    "#ifdef _WIN32\r\n"
+    "LANGUAGE 9, 1\r\n"
+    "#pragma code_page(1252)\r\n"
+    "#endif //_WIN32\r\n"
+    "#include ""res\\testcom.rc2""  // non-Microsoft Visual C++ edited resources\r\n"
+    "#include ""afxres.rc""         // Standard components\r\n"
+    "#endif\r\n"
+    "\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDR_MAINFRAME           ICON    DISCARDABLE     "res\\testcom.ico"
+#endif    // English (U.K.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+#define _AFX_NO_SPLITTER_RESOURCES
+#define _AFX_NO_OLE_RESOURCES
+#define _AFX_NO_TRACKER_RESOURCES
+#define _AFX_NO_PROPERTY_RESOURCES
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE 9, 1
+#pragma code_page(1252)
+#endif //_WIN32
+#include "res/testcom.rc2"  // non-Microsoft Visual C++ edited resources
+#include "afxres.rc"         // Standard components
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+#endif    // not APSTUDIO_INVOKED
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatcomms/testcomdlg.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,361 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// testcomDlg.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "testcom.h"
+#include "testcomDlg.h"
+#include <statcommon.h>
+#include <statcomms.h>
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+DWORD WINAPI ThreadProcOut(LPVOID lpParameter);
+void ProcessInput(STATComms *pComms, CTestcomDlg *pDlg);
+
+bool bFinished = true;
+bool bReset = true;
+char szBitmapFile[] = "C:\\basicscreen.mbm";
+char szReceiveFile[] = "C:\\basicapp.exe";
+
+/////////////////////////////////////////////////////////////////////////////
+// CTestcomDlg dialog
+
+CTestcomDlg::CTestcomDlg(CWnd* pParent /*=NULL*/)
+	: CDialog(CTestcomDlg::IDD, pParent)
+{
+	//{{AFX_DATA_INIT(CTestcomDlg)
+		// NOTE: the ClassWizard will add member initialization here
+	//}}AFX_DATA_INIT
+	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
+}
+
+CTestcomDlg::~CTestcomDlg()
+{
+  	if (hThread2Out)
+  		CloseHandle(hThread2Out);
+}
+
+void CTestcomDlg::DoDataExchange(CDataExchange* pDX)
+{
+	CDialog::DoDataExchange(pDX);
+	//{{AFX_DATA_MAP(CTestcomDlg)
+	DDX_Control(pDX, IDC_PORT, m_Port);
+	DDX_Control(pDX, IDC_TRANSPORT, m_Transport);
+	DDX_Control(pDX, IDC_LIST1, m_List1);
+	//}}AFX_DATA_MAP
+}
+
+BEGIN_MESSAGE_MAP(CTestcomDlg, CDialog)
+	//{{AFX_MSG_MAP(CTestcomDlg)
+	ON_WM_PAINT()
+	ON_WM_QUERYDRAGICON()
+	ON_BN_CLICKED(IDC_TRANSFER, OnTransfer)
+	//}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CTestcomDlg message handlers
+
+BOOL CTestcomDlg::OnInitDialog()
+{
+	CDialog::OnInitDialog();
+
+	SetIcon(m_hIcon, TRUE);			// Set big icon
+	SetIcon(m_hIcon, FALSE);		// Set small icon
+	
+	// defaults
+	m_Transport.SetCurSel(1);
+	m_Port.SetWindowText("3000");
+	m_Port.SetLimitText(25);
+
+	return TRUE;  // return TRUE  unless you set the focus to a control
+}
+
+// If you add a minimize button to your dialog, you will need the code below
+//  to draw the icon.  For MFC applications using the document/view model,
+//  this is automatically done for you by the framework.
+
+void CTestcomDlg::OnPaint() 
+{
+	if (IsIconic())
+	{
+		CPaintDC dc(this); // device context for painting
+
+		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
+
+		// Center icon in client rectangle
+		int cxIcon = GetSystemMetrics(SM_CXICON);
+		int cyIcon = GetSystemMetrics(SM_CYICON);
+		CRect rect;
+		GetClientRect(&rect);
+		int x = (rect.Width() - cxIcon + 1) / 2;
+		int y = (rect.Height() - cyIcon + 1) / 2;
+
+		// Draw the icon
+		dc.DrawIcon(x, y, m_hIcon);
+	}
+	else
+	{
+		CDialog::OnPaint();
+	}
+}
+
+HCURSOR CTestcomDlg::OnQueryDragIcon()
+{
+	return (HCURSOR) m_hIcon;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////
+// Start it all
+///////////////////////////////////////////////////////////////////////////////////
+void CTestcomDlg::OnTransfer() 
+{
+	if (bFinished)
+	{
+		bReset = true;
+		DWORD dwThreadID2Out;
+		if (!(hThread2Out = CreateThread( NULL,				// security attributes
+												0,				// stack size
+												ThreadProcOut,		// proc to call
+												this,			// proc parameter
+												0,				// creation flags
+												&dwThreadID2Out)))	// thread identifier
+		{
+			AfxMessageBox("Could not create listening thread");
+		}
+	}
+	else
+	{
+		bFinished = true;	// signal thread to stop
+		AddString("Stopping...");
+		Sleep(250);			// ...and wait for it
+	}
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////
+// Thread entry point
+///////////////////////////////////////////////////////////////////////////////////
+DWORD WINAPI ThreadProcOut(LPVOID lpParameter)
+{
+	CTestcomDlg *pDlg = (CTestcomDlg *)lpParameter;
+
+	STATComms *pComms;
+	pComms = new STATComms();
+	if (pComms)
+	{
+		pComms->SetTransport((STATCONNECTTYPE)(pDlg->m_Transport.GetCurSel() + 1));
+		if (pComms->Initialise() == ITS_OK)
+		{
+			char szPort[25];
+			pDlg->m_Port.GetWindowText(szPort, 25);
+
+			while (bReset)
+			{
+				pDlg->AddString("Listening...");
+				if (pComms->Connect(szPort) == ITS_OK)
+				{
+					bFinished = false;
+					bReset = false;
+					pDlg->AddString("Connected.");
+					pDlg->AddString(szPort);
+
+					ProcessInput(pComms, pDlg);
+
+					pComms->Disconnect();
+				}
+				else
+				{
+					pDlg->AddString("Could not connect.");
+					pDlg->AddString(szPort);
+				}
+
+				pDlg->AddString("Stopped.");
+			}
+
+			pComms->Release();
+		}
+		else
+		{
+			pDlg->AddString("Could not initialise.");
+		}
+	}
+	else
+		pDlg->AddString("Out of memory.");
+
+	return 1;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////
+// Listen on the port
+///////////////////////////////////////////////////////////////////////////////////
+void
+ProcessInput(STATComms *pComms, CTestcomDlg *pDlg)
+{
+	int ret = GENERAL_FAILURE;
+	char szBuf[512] = {0};
+	char cIdentifier;
+	char *pExtra = NULL;
+	unsigned long ulReadLength = 0;
+
+	while (!bFinished)
+	{
+		if ((ret = pComms->Receive(&cIdentifier, &pExtra, &ulReadLength)) == ITS_OK)
+		{
+			// display what we received
+			if (ulReadLength && ulReadLength < MAX_LOG_MSG_LEN)
+			{
+				char szContents[MAX_LOG_MSG_LEN + 1];
+				strncpy(szContents, pExtra, ulReadLength);
+				*(szContents + ulReadLength) = (char)0;
+				sprintf(szBuf, "%c   [%s]   (%ld)", cIdentifier, szContents, ulReadLength);
+			}
+			else
+				sprintf(szBuf, "%c   (%ld)", cIdentifier, ulReadLength);
+			pDlg->AddString(szBuf);
+
+			// special behaviour
+			switch(cIdentifier)
+			{
+				case 'T':
+				{
+					pDlg->ReleaseData(&pExtra);
+					ulReadLength = 0;
+					break;
+				}
+				case 'S':
+				{
+					// read bitmap data
+					pDlg->ReleaseData(&pExtra);
+					ret = pDlg->ReadTransferFile(szBitmapFile, &pExtra, &ulReadLength);
+					if (ret != ITS_OK)
+					{
+						pDlg->AddString("Read of bitmap failed!!!");
+						pDlg->AddString(szBitmapFile);
+					}
+					break;
+				}
+				case 'R':
+				case 'X':
+				{
+					// read binary
+					pDlg->ReleaseData(&pExtra);
+					ret = pDlg->ReadTransferFile(szReceiveFile, &pExtra, &ulReadLength);
+					if (ret != ITS_OK)
+					{
+						pDlg->AddString("Read of application file failed!!!");
+						pDlg->AddString(szReceiveFile);
+					}
+					break;
+				}
+			}
+
+			// now send data back as a response to show we got it ok
+			if (pComms->Send(cIdentifier, pExtra, ulReadLength) != ITS_OK)
+				pDlg->AddString("Send failed!!!");
+
+			// need to delete received data once finished with it
+			pDlg->ReleaseData(&pExtra);
+		}
+		else
+		{
+			// restart the connection
+			if (ret != NO_DATA_AT_PORT)
+			{
+				bReset = true;
+				break;
+			}
+		}
+
+		Sleep (250);
+	}
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////
+// Release memory resources
+///////////////////////////////////////////////////////////////////////////////////
+void
+CTestcomDlg::ReleaseData(char **ppData)
+{
+	if (*ppData)
+	{
+		delete [] (*ppData);
+		(*ppData) = NULL;
+	}
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////
+// Add a string to the list box
+///////////////////////////////////////////////////////////////////////////////////
+void
+CTestcomDlg::AddString(char *szText)
+{
+	m_List1.AddString(szText);
+	int nCount = m_List1.GetCount();
+	if (nCount > 0)
+		m_List1.SetTopIndex(nCount - 1);
+	UpdateWindow();
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////
+// Read in a file
+///////////////////////////////////////////////////////////////////////////////////
+int CTestcomDlg::ReadTransferFile(const char *pFile, char **ppContents, unsigned long *pLength)
+{
+	int ret = E_BADFILENAME;
+	CString path = pFile;
+	CFile script_file;
+	if (script_file.Open(path, CFile::modeRead))
+	{
+		try
+		{
+			(*pLength) = script_file.GetLength();
+			(*ppContents) = new char [*pLength];
+			if (*ppContents)
+			{
+				script_file.Read(*ppContents, *pLength);
+				ret = ITS_OK;
+			}
+			else
+				ret = E_OUTOFMEM;
+		}
+		catch(CFileException *e)
+		{
+			e->Delete();
+			ret = GENERAL_FAILURE;
+		}
+
+		script_file.Abort();
+	}
+
+	return ret;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatcomms/testcomdlg.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// testcomDlg.h : header file
+//
+
+#if !defined(AFX_TESTCOMDLG_H__F5EDDB58_81F0_11D6_BC69_00B0D065107F__INCLUDED_)
+#define AFX_TESTCOMDLG_H__F5EDDB58_81F0_11D6_BC69_00B0D065107F__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+/////////////////////////////////////////////////////////////////////////////
+// CTestcomDlg dialog
+
+class CTestcomDlg : public CDialog
+{
+// Construction
+public:
+	CTestcomDlg(CWnd* pParent = NULL);	// standard constructor
+	~CTestcomDlg();
+	void AddString(char *szText);
+	int ReadTransferFile(const char *pFile, char **ppContents, unsigned long *pLength);
+	void ReleaseData(char **ppData);
+
+	HANDLE hThread2Out;
+
+// Dialog Data
+	//{{AFX_DATA(CTestcomDlg)
+	enum { IDD = IDD_TESTCOM_DIALOG };
+	CEdit	m_Port;
+	CComboBox	m_Transport;
+	CListBox	m_List1;
+	//}}AFX_DATA
+
+	// ClassWizard generated virtual function overrides
+	//{{AFX_VIRTUAL(CTestcomDlg)
+	protected:
+	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
+	//}}AFX_VIRTUAL
+
+// Implementation
+protected:
+	HICON m_hIcon;
+
+	// Generated message map functions
+	//{{AFX_MSG(CTestcomDlg)
+	virtual BOOL OnInitDialog();
+	afx_msg void OnPaint();
+	afx_msg HCURSOR OnQueryDragIcon();
+	afx_msg void OnTransfer();
+	//}}AFX_MSG
+	DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_TESTCOMDLG_H__F5EDDB58_81F0_11D6_BC69_00B0D065107F__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsasync/myclient.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// myclient.cpp : Defines the class behaviors for the application.
+//
+
+#include "stdafx.h"
+#include "myclient.h"
+#include "myclientDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CMyclientApp
+
+BEGIN_MESSAGE_MAP(CMyclientApp, CWinApp)
+	//{{AFX_MSG_MAP(CMyclientApp)
+	//}}AFX_MSG
+	ON_COMMAND(ID_HELP, CWinApp::OnHelp)
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CMyclientApp construction
+
+CMyclientApp::CMyclientApp()
+{
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// The one and only CMyclientApp object
+
+CMyclientApp theApp;
+
+/////////////////////////////////////////////////////////////////////////////
+// CMyclientApp initialization
+
+BOOL CMyclientApp::InitInstance()
+{
+	if (!AfxSocketInit())
+	{
+		AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
+		return FALSE;
+	}
+
+	// Standard initialization
+
+	CMyclientDlg dlg;
+	m_pMainWnd = &dlg;
+	int nResponse = dlg.DoModal();
+	if (nResponse == IDOK)
+	{
+	}
+	else if (nResponse == IDCANCEL)
+	{
+	}
+
+	// Since the dialog has been closed, return FALSE so that we exit the
+	//  application, rather than start the application's message pump.
+	return FALSE;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsasync/myclient.dsp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,170 @@
+# Microsoft Developer Studio Project File - Name="myclient" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Application" 0x0101
+
+CFG=myclient - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "myclient.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "myclient.mak" CFG="myclient - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "myclient - Win32 Release" (based on "Win32 (x86) Application")
+!MESSAGE "myclient - Win32 Debug" (based on "Win32 (x86) Application")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName "myclient"
+# PROP Scc_LocalPath "..\.."
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "myclient - Win32 Release"
+
+# PROP BASE Use_MFC 6
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 6
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I ".\inc" /I ".\src" /I "..\..\..\source\dll\transport\inc" /I "..\..\..\source\dll\inc" /I "..\..\..\source\regaccess\inc" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG" /d "_AFXDLL"
+# ADD RSC /l 0x809 /d "NDEBUG" /d "_AFXDLL"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
+# ADD LINK32 /nologo /subsystem:windows /machine:I386
+
+!ELSEIF  "$(CFG)" == "myclient - Win32 Debug"
+
+# PROP BASE Use_MFC 6
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 6
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I ".\inc" /I ".\src" /I "..\..\..\source\dll\transport\inc" /I "..\..\..\source\dll\inc" /I "..\..\..\source\regaccess\inc" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /Yu"stdafx.h" /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG" /d "_AFXDLL"
+# ADD RSC /l 0x809 /d "_DEBUG" /d "_AFXDLL"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
+
+!ENDIF 
+
+# Begin Target
+
+# Name "myclient - Win32 Release"
+# Name "myclient - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\..\..\source\dll\transport\src\CClientSocket.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\myclient.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\myclient.rc
+# End Source File
+# Begin Source File
+
+SOURCE=.\myclientDlg.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\source\dll\transport\src\statsocket.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.cpp
+# ADD CPP /Yc"stdafx.h"
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\..\..\source\dll\transport\inc\CClientSocket.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\source\dll\inc\cstatreturncodes.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\myclient.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\myclientDlg.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Resource.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\source\dll\inc\statcommon.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\source\dll\transport\inc\statsocket.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\source\dll\transport\inc\stattransport.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# Begin Source File
+
+SOURCE=.\res\myclient.ico
+# End Source File
+# Begin Source File
+
+SOURCE=.\res\myclient.rc2
+# End Source File
+# End Group
+# End Target
+# End Project
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsasync/myclient.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,67 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// myclient.h : main header file for the MYCLIENT application
+//
+
+#if !defined(AFX_MYCLIENT_H__DCBFD0A3_CBD8_11D6_AF94_000000000000__INCLUDED_)
+#define AFX_MYCLIENT_H__DCBFD0A3_CBD8_11D6_AF94_000000000000__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#ifndef __AFXWIN_H__
+	#error include 'stdafx.h' before including this file for PCH
+#endif
+
+#include "resource.h"		// main symbols
+
+/////////////////////////////////////////////////////////////////////////////
+// CMyclientApp:
+// See myclient.cpp for the implementation of this class
+//
+
+class CMyclientApp : public CWinApp
+{
+public:
+	CMyclientApp();
+
+// Overrides
+	// ClassWizard generated virtual function overrides
+	//{{AFX_VIRTUAL(CMyclientApp)
+	public:
+	virtual BOOL InitInstance();
+	//}}AFX_VIRTUAL
+
+// Implementation
+
+	//{{AFX_MSG(CMyclientApp)
+	//}}AFX_MSG
+	DECLARE_MESSAGE_MAP()
+};
+
+
+/////////////////////////////////////////////////////////////////////////////
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_MYCLIENT_H__DCBFD0A3_CBD8_11D6_AF94_000000000000__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsasync/myclient.rc	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,229 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_ABOUTBOX DIALOG DISCARDABLE  0, 0, 235, 55
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "About myclient"
+FONT 8, "MS Sans Serif"
+BEGIN
+    ICON            IDR_MAINFRAME,IDC_STATIC,11,17,20,20
+    LTEXT           "myclient Version 1.0",IDC_STATIC,40,10,119,8,
+                    SS_NOPREFIX
+    LTEXT           "Copyright (C) 2002",IDC_STATIC,40,25,119,8
+    DEFPUSHBUTTON   "OK",IDOK,178,7,50,14,WS_GROUP
+END
+
+IDD_MYCLIENT_DIALOG DIALOGEX 0, 0, 237, 169
+STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_APPWINDOW
+CAPTION "STAT Socket Transport Tester"
+FONT 8, "MS Sans Serif"
+BEGIN
+    EDITTEXT        IDC_SENDMSG,7,7,164,14,ES_AUTOHSCROLL
+    DEFPUSHBUTTON   "Send",IDC_SEND,180,7,50,14
+    EDITTEXT        IDC_MACHINE,44,127,112,14,ES_AUTOHSCROLL
+    EDITTEXT        IDC_PORT,190,127,40,14,ES_AUTOHSCROLL
+    PUSHBUTTON      "Connect",IDC_CONNECT,121,148,50,14
+    PUSHBUTTON      "OK",IDOK,180,148,50,14
+    LISTBOX         IDC_RECVLIST,7,29,223,90,LBS_NOINTEGRALHEIGHT | 
+                    WS_VSCROLL
+    LTEXT           "Machine:",IDC_STATIC,7,127,31,8
+    LTEXT           "Port:",IDC_STATIC,167,127,16,8
+    CONTROL         "Listen",IDC_CHKLISTEN,"Button",BS_AUTOCHECKBOX | 
+                    WS_TABSTOP,7,152,35,10
+END
+
+
+#ifndef _MAC
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,0,0,1
+ PRODUCTVERSION 1,0,0,1
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904B0"
+        BEGIN
+            VALUE "CompanyName", "\0"
+            VALUE "FileDescription", "myclient MFC Application\0"
+            VALUE "FileVersion", "1, 0, 0, 1\0"
+            VALUE "InternalName", "myclient\0"
+            VALUE "LegalCopyright", "Copyright (C) 2002\0"
+            VALUE "LegalTrademarks", "\0"
+            VALUE "OriginalFilename", "myclient.EXE\0"
+            VALUE "ProductName", "myclient Application\0"
+            VALUE "ProductVersion", "1, 0, 0, 1\0"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x409, 1200
+    END
+END
+
+#endif    // !_MAC
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE 
+BEGIN
+    IDD_ABOUTBOX, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 228
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 48
+    END
+
+    IDD_MYCLIENT_DIALOG, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 230
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 162
+        HORZGUIDE, 127
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE 
+BEGIN
+    IDS_ABOUTBOX            "&About myclient..."
+    IDP_SOCKETS_INIT_FAILED "Windows sockets initialization failed."
+END
+
+#endif    // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.K.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "#include ""afxres.h""\r\n"
+    "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
+    "#define _AFX_NO_OLE_RESOURCES\r\n"
+    "#define _AFX_NO_TRACKER_RESOURCES\r\n"
+    "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
+    "\r\n"
+    "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
+    "#ifdef _WIN32\r\n"
+    "LANGUAGE 9, 1\r\n"
+    "#pragma code_page(1252)\r\n"
+    "#endif //_WIN32\r\n"
+    "#include ""res\\myclient.rc2""  // non-Microsoft Visual C++ edited resources\r\n"
+    "#include ""afxres.rc""         // Standard components\r\n"
+    "#endif\r\n"
+    "\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDR_MAINFRAME           ICON    DISCARDABLE     "res\\myclient.ico"
+#endif    // English (U.K.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+#define _AFX_NO_SPLITTER_RESOURCES
+#define _AFX_NO_OLE_RESOURCES
+#define _AFX_NO_TRACKER_RESOURCES
+#define _AFX_NO_PROPERTY_RESOURCES
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE 9, 1
+#pragma code_page(1252)
+#endif //_WIN32
+#include "res/myclient.rc2"  // non-Microsoft Visual C++ edited resources
+#include "afxres.rc"         // Standard components
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+#endif    // not APSTUDIO_INVOKED
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsasync/myclientdlg.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,323 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// myclientDlg.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "myclient.h"
+#include "myclientDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CAboutDlg dialog used for App About
+
+class CAboutDlg : public CDialog
+{
+public:
+	CAboutDlg();
+
+// Dialog Data
+	//{{AFX_DATA(CAboutDlg)
+	enum { IDD = IDD_ABOUTBOX };
+	//}}AFX_DATA
+
+	// ClassWizard generated virtual function overrides
+	//{{AFX_VIRTUAL(CAboutDlg)
+	protected:
+	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+	//}}AFX_VIRTUAL
+
+// Implementation
+protected:
+	//{{AFX_MSG(CAboutDlg)
+	//}}AFX_MSG
+	DECLARE_MESSAGE_MAP()
+};
+
+CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
+{
+	//{{AFX_DATA_INIT(CAboutDlg)
+	//}}AFX_DATA_INIT
+}
+
+void CAboutDlg::DoDataExchange(CDataExchange* pDX)
+{
+	CDialog::DoDataExchange(pDX);
+	//{{AFX_DATA_MAP(CAboutDlg)
+	//}}AFX_DATA_MAP
+}
+
+BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
+	//{{AFX_MSG_MAP(CAboutDlg)
+		// No message handlers
+	//}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CMyclientDlg dialog
+
+CMyclientDlg::CMyclientDlg(CWnd* pParent /*=NULL*/)
+	: CDialog(CMyclientDlg::IDD, pParent)
+{
+	//{{AFX_DATA_INIT(CMyclientDlg)
+		// NOTE: the ClassWizard will add member initialization here
+	//}}AFX_DATA_INIT
+	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
+}
+
+void CMyclientDlg::DoDataExchange(CDataExchange* pDX)
+{
+	CDialog::DoDataExchange(pDX);
+	//{{AFX_DATA_MAP(CMyclientDlg)
+	DDX_Control(pDX, IDC_CHKLISTEN, m_ChkListen);
+	DDX_Control(pDX, IDC_PORT, m_Port);
+	DDX_Control(pDX, IDC_MACHINE, m_Machine);
+	DDX_Control(pDX, IDC_CONNECT, m_Connect);
+	DDX_Control(pDX, IDC_SEND, m_Send);
+	DDX_Control(pDX, IDC_SENDMSG, m_SendMsg);
+	DDX_Control(pDX, IDC_RECVLIST, m_RecvList);
+	//}}AFX_DATA_MAP
+}
+
+BEGIN_MESSAGE_MAP(CMyclientDlg, CDialog)
+	//{{AFX_MSG_MAP(CMyclientDlg)
+	ON_WM_SYSCOMMAND()
+	ON_WM_PAINT()
+	ON_WM_QUERYDRAGICON()
+	ON_BN_CLICKED(IDC_SEND, OnSend)
+	ON_BN_CLICKED(IDC_CONNECT, OnConnect)
+	//}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CMyclientDlg message handlers
+
+BOOL CMyclientDlg::OnInitDialog()
+{
+	CDialog::OnInitDialog();
+
+	if (!AfxSocketInit())
+	{
+		AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
+		exit(0);
+	}
+
+	// Add "About..." menu item to system menu.
+
+	// IDM_ABOUTBOX must be in the system command range.
+	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
+	ASSERT(IDM_ABOUTBOX < 0xF000);
+
+	CMenu* pSysMenu = GetSystemMenu(FALSE);
+	if (pSysMenu != NULL)
+	{
+		CString strAboutMenu;
+		strAboutMenu.LoadString(IDS_ABOUTBOX);
+		if (!strAboutMenu.IsEmpty())
+		{
+			pSysMenu->AppendMenu(MF_SEPARATOR);
+			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
+		}
+	}
+
+	SetIcon(m_hIcon, TRUE);			// Set big icon
+	SetIcon(m_hIcon, FALSE);		// Set small icon
+	
+	m_SendMsg.EnableWindow(FALSE);
+	m_Send.EnableWindow(FALSE);
+
+	m_Machine.SetWindowText("LON-PHILH01");
+	m_Port.SetWindowText("701");
+
+	hThreadHandle = 0;
+
+	return TRUE;  // return TRUE  unless you set the focus to a control
+}
+
+void CMyclientDlg::OnSysCommand(UINT nID, LPARAM lParam)
+{
+	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
+	{
+		CAboutDlg dlgAbout;
+		dlgAbout.DoModal();
+	}
+	else
+	{
+		CDialog::OnSysCommand(nID, lParam);
+	}
+}
+
+// If you add a minimize button to your dialog, you will need the code below
+//  to draw the icon.  For MFC applications using the document/view model,
+//  this is automatically done for you by the framework.
+
+void CMyclientDlg::OnPaint() 
+{
+	if (IsIconic())
+	{
+		CPaintDC dc(this); // device context for painting
+
+		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
+
+		// Center icon in client rectangle
+		int cxIcon = GetSystemMetrics(SM_CXICON);
+		int cyIcon = GetSystemMetrics(SM_CYICON);
+		CRect rect;
+		GetClientRect(&rect);
+		int x = (rect.Width() - cxIcon + 1) / 2;
+		int y = (rect.Height() - cyIcon + 1) / 2;
+
+		// Draw the icon
+		dc.DrawIcon(x, y, m_hIcon);
+	}
+	else
+	{
+		CDialog::OnPaint();
+	}
+}
+
+HCURSOR CMyclientDlg::OnQueryDragIcon()
+{
+	return (HCURSOR) m_hIcon;
+}
+
+void CMyclientDlg::OnSend() 
+{
+	if (pSocket)
+	{
+		char szData[256];
+		m_SendMsg.GetWindowText(szData, 256);
+		if (*szData)
+		{
+			if (pSocket->Send('X', szData, strlen(szData)) != ITS_OK)
+				m_RecvList.AddString("Could not send.");
+		}
+	}
+}
+
+void CMyclientDlg::OnConnect() 
+{
+	bool IsConnected = false;
+
+	pSocket = new CSTATSocket;
+	if (pSocket)
+	{
+		CWaitCursor oWait;
+
+		if (!m_ChkListen.GetCheck())
+		{
+			// get machine name and port number
+			char szMachine[256];
+			m_Machine.GetWindowText(szMachine, 251);
+			strcat(szMachine, ":");
+			m_Port.GetWindowText(szMachine + strlen(szMachine), 4);
+
+			if (pSocket->Connect(szMachine) == ITS_OK)
+			{
+				IsConnected = true;
+				m_RecvList.AddString("Connected.");
+			}
+			else
+				m_RecvList.AddString("Could not connect.");
+		}
+		else
+		{
+			int ret = 0;
+			char szPort[4];
+			m_Port.GetWindowText(szPort, 4);
+			if ((ret = pSocket->Listen(szPort)) == ITS_OK)
+			{
+				m_RecvList.AddString("Listening for connection...");
+				IsConnected = true;
+			}
+			else
+				m_RecvList.AddString("Could not connect.");
+		}
+
+		if (IsConnected)
+		{
+			m_SendMsg.EnableWindow(TRUE);
+			m_Send.EnableWindow(TRUE);
+			m_Connect.EnableWindow(FALSE);
+			m_ChkListen.EnableWindow(FALSE);
+			m_Machine.EnableWindow(FALSE);
+			m_Port.EnableWindow(FALSE);
+			GetMessages();
+		}
+	}
+	else
+		m_RecvList.AddString("Memory error.");
+}
+
+// thread entry point
+DWORD WINAPI ThreadProc(LPVOID lpParameter)
+{
+	// lpParameter can be a pointer to a class to allow method calls
+	CMyclientDlg *pDlg = (CMyclientDlg *)lpParameter;
+
+	char ID = 0;
+	unsigned long Length = 0;
+	char *pData = NULL;
+	char szBuffer[1024];
+
+	while(1)
+	{
+		if (pDlg->pSocket->Receive(&ID, &pData, &Length) == ITS_OK)
+		{
+			memset(szBuffer, 0, 1024);
+			sprintf(szBuffer, "%c %ld %s", ID, Length, pData);
+
+			pDlg->m_RecvList.AddString(szBuffer);
+			pDlg->UpdateWindow();
+		}
+
+		Sleep(100);
+	}
+
+	return 1;
+}
+
+void CMyclientDlg::GetMessages() 
+{
+	DWORD dwThreadID;
+	if (!(hThreadHandle = CreateThread( NULL,				// security attributes
+											0,				// stack size
+											ThreadProc,		// proc to call
+											this,		// proc parameter
+											0,				// creation flags
+											&dwThreadID)))	// thread identifier
+	{
+		AfxMessageBox("Could not create thread");
+	}
+}
+
+void CMyclientDlg::OnOK() 
+{
+	if (hThreadHandle)
+		TerminateThread(hThreadHandle, -1);	
+
+	CDialog::OnOK();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsasync/myclientdlg.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,87 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// myclientDlg.h : header file
+//
+
+#if !defined(AFX_MYCLIENTDLG_H__DCBFD0A5_CBD8_11D6_AF94_000000000000__INCLUDED_)
+#define AFX_MYCLIENTDLG_H__DCBFD0A5_CBD8_11D6_AF94_000000000000__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include <statsocket.h>
+
+/////////////////////////////////////////////////////////////////////////////
+// CMyclientDlg dialog
+
+class CMyclientDlg : public CDialog
+{
+// Construction
+public:
+	CMyclientDlg(CWnd* pParent = NULL);	// standard constructor
+
+	CSTATSocket* pSocket;
+
+// Dialog Data
+	//{{AFX_DATA(CMyclientDlg)
+	enum { IDD = IDD_MYCLIENT_DIALOG };
+	CButton	m_ChkListen;
+	CEdit	m_Port;
+	CEdit	m_Machine;
+	CButton	m_Connect;
+	CButton	m_Send;
+	CEdit	m_SendMsg;
+	CListBox	m_RecvList;
+	//}}AFX_DATA
+
+	// ClassWizard generated virtual function overrides
+	//{{AFX_VIRTUAL(CMyclientDlg)
+	protected:
+	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
+	//}}AFX_VIRTUAL
+
+// Implementation
+protected:
+	HICON m_hIcon;
+
+	// Generated message map functions
+	//{{AFX_MSG(CMyclientDlg)
+	virtual BOOL OnInitDialog();
+	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
+	afx_msg void OnPaint();
+	afx_msg HCURSOR OnQueryDragIcon();
+	afx_msg void OnSend();
+	afx_msg void OnConnect();
+	virtual void OnOK();
+	//}}AFX_MSG
+	DECLARE_MESSAGE_MAP()
+
+private:
+	void GetMessages();
+
+	HANDLE hThreadHandle;
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_MYCLIENTDLG_H__DCBFD0A5_CBD8_11D6_AF94_000000000000__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsasync/resource.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by myclient.rc
+//
+#define IDM_ABOUTBOX                    0x0010
+#define IDD_ABOUTBOX                    100
+#define IDS_ABOUTBOX                    101
+#define IDD_MYCLIENT_DIALOG             102
+#define IDP_SOCKETS_INIT_FAILED         103
+#define IDR_MAINFRAME                   128
+#define IDC_SENDMSG                     1000
+#define IDC_SEND                        1001
+#define IDC_RECVLIST                    1002
+#define IDC_CONNECT                     1003
+#define IDC_LISTEN                      1004
+#define IDC_MACHINE                     1005
+#define IDC_PORT                        1006
+#define IDC_CHKLISTEN                   1007
+
+// Next default values for new objects
+// 
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE        129
+#define _APS_NEXT_COMMAND_VALUE         32771
+#define _APS_NEXT_CONTROL_VALUE         1008
+#define _APS_NEXT_SYMED_VALUE           101
+#endif
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsasync/stdafx.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// stdafx.cpp : source file that includes just the standard includes
+//	myclient.pch will be the pre-compiled header
+//	stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsasync/stdafx.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// stdafx.h : include file for standard system include files,
+//  or project specific include files that are used frequently, but
+//      are changed infrequently
+//
+
+#if !defined(AFX_STDAFX_H__DCBFD0A7_CBD8_11D6_AF94_000000000000__INCLUDED_)
+#define AFX_STDAFX_H__DCBFD0A7_CBD8_11D6_AF94_000000000000__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define VC_EXTRALEAN		// Exclude rarely-used stuff from Windows headers
+
+#include <afxwin.h>         // MFC core and standard components
+#include <afxext.h>         // MFC extensions
+#include <afxdtctl.h>		// MFC support for Internet Explorer 4 Common Controls
+#ifndef _AFX_NO_AFXCMN_SUPPORT
+#include <afxcmn.h>			// MFC support for Windows Common Controls
+#endif // _AFX_NO_AFXCMN_SUPPORT
+
+#include <afxsock.h>		// MFC socket extensions
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__DCBFD0A7_CBD8_11D6_AF94_000000000000__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsblock/myclient.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,67 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// myclient.cpp : Defines the class behaviors for the application.
+//
+
+#include "stdafx.h"
+#include "myclient.h"
+#include "myclientDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CMyclientApp
+
+BEGIN_MESSAGE_MAP(CMyclientApp, CWinApp)
+	//{{AFX_MSG_MAP(CMyclientApp)
+	//}}AFX_MSG
+	ON_COMMAND(ID_HELP, CWinApp::OnHelp)
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CMyclientApp construction
+
+CMyclientApp::CMyclientApp()
+{
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// The one and only CMyclientApp object
+
+CMyclientApp theApp;
+
+/////////////////////////////////////////////////////////////////////////////
+// CMyclientApp initialization
+
+BOOL CMyclientApp::InitInstance()
+{
+	CMyclientDlg dlg;
+	m_pMainWnd = &dlg;
+	dlg.DoModal();
+
+	// Since the dialog has been closed, return FALSE so that we exit the
+	//  application, rather than start the application's message pump.
+	return FALSE;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsblock/myclient.dsp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,158 @@
+# Microsoft Developer Studio Project File - Name="myclient" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Application" 0x0101
+
+CFG=myclient - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "myclient.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "myclient.mak" CFG="myclient - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "myclient - Win32 Release" (based on "Win32 (x86) Application")
+!MESSAGE "myclient - Win32 Debug" (based on "Win32 (x86) Application")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName "myclient"
+# PROP Scc_LocalPath "..\.."
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "myclient - Win32 Release"
+
+# PROP BASE Use_MFC 6
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 6
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I ".\inc" /I ".\src" /I "..\..\..\source\dll\transport\inc" /I "..\..\..\source\dll\inc" /I "..\..\..\source\regaccess\inc" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG" /d "_AFXDLL"
+# ADD RSC /l 0x809 /d "NDEBUG" /d "_AFXDLL"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
+# ADD LINK32 /nologo /subsystem:windows /machine:I386
+
+!ELSEIF  "$(CFG)" == "myclient - Win32 Debug"
+
+# PROP BASE Use_MFC 6
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 6
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I ".\inc" /I ".\src" /I "..\..\..\source\dll\transport\inc" /I "..\..\..\source\dll\inc" /I "..\..\..\source\regaccess\inc" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /Yu"stdafx.h" /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG" /d "_AFXDLL"
+# ADD RSC /l 0x809 /d "_DEBUG" /d "_AFXDLL"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
+
+!ENDIF 
+
+# Begin Target
+
+# Name "myclient - Win32 Release"
+# Name "myclient - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\myclient.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\myclient.rc
+# End Source File
+# Begin Source File
+
+SOURCE=.\myclientDlg.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\source\dll\transport\src\statsocket_block.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.cpp
+# ADD CPP /Yc"stdafx.h"
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\myclient.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\myclientDlg.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Resource.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\source\dll\inc\statcommon.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\source\dll\transport\inc\statsocket_block.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\source\dll\transport\inc\stattransport.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# Begin Source File
+
+SOURCE=.\res\myclient.ico
+# End Source File
+# Begin Source File
+
+SOURCE=.\res\myclient.rc2
+# End Source File
+# End Group
+# End Target
+# End Project
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsblock/myclient.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,67 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// myclient.h : main header file for the MYCLIENT application
+//
+
+#if !defined(AFX_MYCLIENT_H__DCBFD0A3_CBD8_11D6_AF94_000000000000__INCLUDED_)
+#define AFX_MYCLIENT_H__DCBFD0A3_CBD8_11D6_AF94_000000000000__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#ifndef __AFXWIN_H__
+	#error include 'stdafx.h' before including this file for PCH
+#endif
+
+#include "resource.h"		// main symbols
+
+/////////////////////////////////////////////////////////////////////////////
+// CMyclientApp:
+// See myclient.cpp for the implementation of this class
+//
+
+class CMyclientApp : public CWinApp
+{
+public:
+	CMyclientApp();
+
+// Overrides
+	// ClassWizard generated virtual function overrides
+	//{{AFX_VIRTUAL(CMyclientApp)
+	public:
+	virtual BOOL InitInstance();
+	//}}AFX_VIRTUAL
+
+// Implementation
+
+	//{{AFX_MSG(CMyclientApp)
+	//}}AFX_MSG
+	DECLARE_MESSAGE_MAP()
+};
+
+
+/////////////////////////////////////////////////////////////////////////////
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_MYCLIENT_H__DCBFD0A3_CBD8_11D6_AF94_000000000000__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsblock/myclient.rc	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,236 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_ABOUTBOX DIALOG DISCARDABLE  0, 0, 235, 55
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "About myclient"
+FONT 8, "MS Sans Serif"
+BEGIN
+    ICON            IDR_MAINFRAME,IDC_STATIC,11,17,20,20
+    LTEXT           "myclient Version 1.0",IDC_STATIC,40,10,119,8,
+                    SS_NOPREFIX
+    LTEXT           "Copyright (C) 2002",IDC_STATIC,40,25,119,8
+    DEFPUSHBUTTON   "OK",IDOK,178,7,50,14,WS_GROUP
+END
+
+IDD_MYCLIENT_DIALOG DIALOGEX 0, 0, 237, 199
+STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_APPWINDOW
+CAPTION "STAT Service Communications Test"
+FONT 8, "MS Sans Serif"
+BEGIN
+    EDITTEXT        IDC_SENDMSG,40,158,133,14,ES_AUTOHSCROLL
+    DEFPUSHBUTTON   "Send",IDC_SEND,180,158,50,14
+    EDITTEXT        IDC_MACHINE,40,137,66,14,ES_AUTOHSCROLL
+    EDITTEXT        IDC_PORT,141,137,32,14,ES_AUTOHSCROLL
+    PUSHBUTTON      "Connect",IDC_CONNECT,67,178,50,14
+    PUSHBUTTON      "OK",IDOK,123,178,50,14
+    LISTBOX         IDC_RECVLIST,7,36,223,90,LBS_NOINTEGRALHEIGHT | 
+                    WS_VSCROLL
+    LTEXT           "Machine:",IDC_STATIC,7,137,31,8
+    LTEXT           "Port:",IDC_STATIC,117,137,16,8
+    CONTROL         "Listen",IDC_CHKLISTEN,"Button",BS_AUTOCHECKBOX | 
+                    WS_TABSTOP,7,182,35,10
+    PUSHBUTTON      "Receive",IDC_RECEIVE,180,178,50,14
+    LTEXT           "This application is used to send STAT scripts to a listening STAT service.  This application can also be used to test a socket connection by one listening and one connecting on the same port.",
+                    IDC_STATIC,7,7,223,26
+    LTEXT           "Data:",IDC_STATIC,7,158,26,8
+    PUSHBUTTON      "Device Info",IDC_INFO,180,137,50,14
+END
+
+
+#ifndef _MAC
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,0,0,1
+ PRODUCTVERSION 1,0,0,1
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904B0"
+        BEGIN
+            VALUE "CompanyName", "\0"
+            VALUE "FileDescription", "myclient MFC Application\0"
+            VALUE "FileVersion", "1, 0, 0, 1\0"
+            VALUE "InternalName", "myclient\0"
+            VALUE "LegalCopyright", "Copyright (C) 2002\0"
+            VALUE "LegalTrademarks", "\0"
+            VALUE "OriginalFilename", "myclient.EXE\0"
+            VALUE "ProductName", "myclient Application\0"
+            VALUE "ProductVersion", "1, 0, 0, 1\0"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x409, 1200
+    END
+END
+
+#endif    // !_MAC
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE 
+BEGIN
+    IDD_ABOUTBOX, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 228
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 48
+    END
+
+    IDD_MYCLIENT_DIALOG, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 230
+        VERTGUIDE, 40
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 192
+        HORZGUIDE, 137
+        HORZGUIDE, 158
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE 
+BEGIN
+    IDS_ABOUTBOX            "&About myclient..."
+    IDP_SOCKETS_INIT_FAILED "Windows sockets initialization failed."
+END
+
+#endif    // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.K.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "#include ""afxres.h""\r\n"
+    "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
+    "#define _AFX_NO_OLE_RESOURCES\r\n"
+    "#define _AFX_NO_TRACKER_RESOURCES\r\n"
+    "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
+    "\r\n"
+    "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
+    "#ifdef _WIN32\r\n"
+    "LANGUAGE 9, 1\r\n"
+    "#pragma code_page(1252)\r\n"
+    "#endif //_WIN32\r\n"
+    "#include ""res\\myclient.rc2""  // non-Microsoft Visual C++ edited resources\r\n"
+    "#include ""afxres.rc""         // Standard components\r\n"
+    "#endif\r\n"
+    "\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDR_MAINFRAME           ICON    DISCARDABLE     "res\\myclient.ico"
+#endif    // English (U.K.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+#define _AFX_NO_SPLITTER_RESOURCES
+#define _AFX_NO_OLE_RESOURCES
+#define _AFX_NO_TRACKER_RESOURCES
+#define _AFX_NO_PROPERTY_RESOURCES
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE 9, 1
+#pragma code_page(1252)
+#endif //_WIN32
+#include "res/myclient.rc2"  // non-Microsoft Visual C++ edited resources
+#include "afxres.rc"         // Standard components
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+#endif    // not APSTUDIO_INVOKED
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsblock/myclientdlg.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,588 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// myclientDlg.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "myclient.h"
+#include "myclientDlg.h"
+#include <statsocket.h>
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CAboutDlg dialog used for App About
+
+class CAboutDlg : public CDialog
+{
+public:
+	CAboutDlg();
+
+// Dialog Data
+	//{{AFX_DATA(CAboutDlg)
+	enum { IDD = IDD_ABOUTBOX };
+	//}}AFX_DATA
+
+	// ClassWizard generated virtual function overrides
+	//{{AFX_VIRTUAL(CAboutDlg)
+	protected:
+	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+	//}}AFX_VIRTUAL
+
+// Implementation
+protected:
+	//{{AFX_MSG(CAboutDlg)
+	//}}AFX_MSG
+	DECLARE_MESSAGE_MAP()
+};
+
+CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
+{
+	//{{AFX_DATA_INIT(CAboutDlg)
+	//}}AFX_DATA_INIT
+}
+
+void CAboutDlg::DoDataExchange(CDataExchange* pDX)
+{
+	CDialog::DoDataExchange(pDX);
+	//{{AFX_DATA_MAP(CAboutDlg)
+	//}}AFX_DATA_MAP
+}
+
+BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
+	//{{AFX_MSG_MAP(CAboutDlg)
+		// No message handlers
+	//}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CMyclientDlg dialog
+
+CMyclientDlg::CMyclientDlg(CWnd* pParent /*=NULL*/)
+	: CDialog(CMyclientDlg::IDD, pParent)
+{
+	//{{AFX_DATA_INIT(CMyclientDlg)
+		// NOTE: the ClassWizard will add member initialization here
+	//}}AFX_DATA_INIT
+	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
+}
+
+void CMyclientDlg::DoDataExchange(CDataExchange* pDX)
+{
+	CDialog::DoDataExchange(pDX);
+	//{{AFX_DATA_MAP(CMyclientDlg)
+	DDX_Control(pDX, IDC_INFO, m_Info);
+	DDX_Control(pDX, IDC_RECEIVE, m_Receive);
+	DDX_Control(pDX, IDC_CHKLISTEN, m_ChkListen);
+	DDX_Control(pDX, IDC_PORT, m_Port);
+	DDX_Control(pDX, IDC_MACHINE, m_Machine);
+	DDX_Control(pDX, IDC_CONNECT, m_Connect);
+	DDX_Control(pDX, IDC_SEND, m_Send);
+	DDX_Control(pDX, IDC_SENDMSG, m_SendMsg);
+	DDX_Control(pDX, IDC_RECVLIST, m_RecvList);
+	//}}AFX_DATA_MAP
+}
+
+BEGIN_MESSAGE_MAP(CMyclientDlg, CDialog)
+	//{{AFX_MSG_MAP(CMyclientDlg)
+	ON_WM_SYSCOMMAND()
+	ON_WM_PAINT()
+	ON_WM_QUERYDRAGICON()
+	ON_BN_CLICKED(IDC_SEND, OnSend)
+	ON_BN_CLICKED(IDC_CONNECT, OnConnect)
+	ON_BN_CLICKED(IDC_RECEIVE, OnReceive)
+	ON_BN_CLICKED(IDC_CHKLISTEN, OnChklisten)
+	ON_BN_CLICKED(IDC_INFO, OnInfo)
+	//}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CMyclientDlg message handlers
+
+BOOL CMyclientDlg::OnInitDialog()
+{
+	CDialog::OnInitDialog();
+
+	// IDM_ABOUTBOX must be in the system command range.
+	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
+	ASSERT(IDM_ABOUTBOX < 0xF000);
+
+	CMenu* pSysMenu = GetSystemMenu(FALSE);
+	if (pSysMenu != NULL)
+	{
+		CString strAboutMenu;
+		strAboutMenu.LoadString(IDS_ABOUTBOX);
+		if (!strAboutMenu.IsEmpty())
+		{
+			pSysMenu->AppendMenu(MF_SEPARATOR);
+			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
+		}
+	}
+
+	SetIcon(m_hIcon, TRUE);			// Set big icon
+	SetIcon(m_hIcon, FALSE);		// Set small icon
+	
+	hThreadHandle = 0;
+	pSocket = NULL;
+
+	m_Machine.SetWindowText("LON-PHILH03");
+	m_Port.SetWindowText("3001");
+	m_SendMsg.SetWindowText("<B><S><E>");
+
+	Prepare();
+	ResetDeviceInfo();
+
+	return TRUE;  // return TRUE  unless you set the focus to a control
+}
+
+void CMyclientDlg::OnSysCommand(UINT nID, LPARAM lParam)
+{
+	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
+	{
+		CAboutDlg dlgAbout;
+		dlgAbout.DoModal();
+	}
+	else
+	{
+		CDialog::OnSysCommand(nID, lParam);
+	}
+}
+
+// If you add a minimize button to your dialog, you will need the code below
+//  to draw the icon.  For MFC applications using the document/view model,
+//  this is automatically done for you by the framework.
+
+void CMyclientDlg::OnPaint() 
+{
+	if (IsIconic())
+	{
+		CPaintDC dc(this); // device context for painting
+
+		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
+
+		// Center icon in client rectangle
+		int cxIcon = GetSystemMetrics(SM_CXICON);
+		int cyIcon = GetSystemMetrics(SM_CYICON);
+		CRect rect;
+		GetClientRect(&rect);
+		int x = (rect.Width() - cxIcon + 1) / 2;
+		int y = (rect.Height() - cyIcon + 1) / 2;
+
+		// Draw the icon
+		dc.DrawIcon(x, y, m_hIcon);
+	}
+	else
+	{
+		CDialog::OnPaint();
+	}
+}
+
+HCURSOR CMyclientDlg::OnQueryDragIcon()
+{
+	return (HCURSOR) m_hIcon;
+}
+
+void CMyclientDlg::OnSend() 
+{
+	if (pSocket)
+	{
+		char szData[256];
+		m_SendMsg.GetWindowText(szData, 256);
+		if (*szData)
+		{
+			CWaitCursor oWait;
+
+			if (pSocket->Send(SymbianScript, szData, strlen(szData)) != ITS_OK)
+			{
+				AddString("Could not send.  Try to re-connect.");
+				Prepare();
+			}
+		}
+	}
+	else
+		AddString("Bad socket");
+}
+
+void CMyclientDlg::OnReceive() 
+{
+	if (pSocket)
+	{
+		CWaitCursor oWait;
+
+		char ID = 0;
+		unsigned long Length = 0;
+		char *pData = NULL;
+
+		if (pSocket->Receive(&ID, &pData, &Length) != ITS_OK)
+		{
+			AddString("Could not receive.  Try to re-connect.");
+			Prepare();
+		}
+		else
+		{
+			char szBuffer[120] = {0};
+
+			switch(ID)
+			{
+			case SymbianScript:
+				if ((Length < 80) && pData)
+					sprintf(szBuffer, "%ld [%s]", Length, pData);
+				else
+				{
+					sprintf(szBuffer, "Received %ld bytes of data", Length);
+					OpenDataInNotepad(pData, Length);
+				}
+				break;
+			case SymbianError:
+				if ((Length < 100) && pData)
+					sprintf(szBuffer, "ERROR: %ld [%s]", Length, pData);
+				else
+				{
+					sprintf(szBuffer, "ERROR: Received %ld bytes of data", Length);
+					OpenDataInNotepad(pData, Length);
+				}
+				break;
+			case SymbianDeviceInfo:
+				StoreDeviceInformation(pData, Length);
+				DisplayDeviceInformation(pData);
+				break;
+			};
+
+			AddString(szBuffer);
+		}
+
+		if (pData)
+		{
+			delete [] pData;
+			pData = NULL;
+		}
+	}
+	else
+		AddString("Bad socket");
+}
+
+void CMyclientDlg::OnConnect() 
+{
+	bool IsConnected = false;
+
+	pSocket = new CSTATSocket;
+	if (pSocket)
+	{
+		CWaitCursor oWait;
+
+		if (pSocket->Initialise() != ITS_OK)
+			return;
+
+		char szMachine[256] = {0};
+		if (!m_ChkListen.GetCheck())
+		{
+			// get machine name and port number
+			m_Machine.GetWindowText(szMachine, 247);
+			strcat(szMachine, ":");
+			m_Port.GetWindowText(szMachine + strlen(szMachine), 8);
+		}
+		else
+		{
+			m_Port.GetWindowText(szMachine, 8);
+		}
+
+		if (pSocket->Connect(szMachine) == ITS_OK)
+		{
+			AddString("Connected.");
+			m_SendMsg.EnableWindow(TRUE);
+			m_Send.EnableWindow(TRUE);
+			m_Receive.EnableWindow(TRUE);
+			m_Connect.EnableWindow(FALSE);
+			m_ChkListen.EnableWindow(FALSE);
+			m_Machine.EnableWindow(FALSE);
+			m_Port.EnableWindow(FALSE);
+			m_Info.EnableWindow(TRUE);
+		}
+		else
+			AddString("Could not connect.");
+	}
+	else
+		AddString("Memory error.");
+}
+
+
+void CMyclientDlg::OnChklisten() 
+{
+	if (m_ChkListen.GetCheck())
+	{
+		m_Machine.EnableWindow(FALSE);
+	}
+	else
+	{
+		m_Machine.EnableWindow(TRUE);
+	}
+}
+
+void CMyclientDlg::OnOK() 
+{
+	Prepare();
+
+	// delete once we've finished with it
+	DeleteFile(STAT_TEMP_FILE);
+
+	CDialog::OnOK();
+}
+
+
+void CMyclientDlg::OnInfo() 
+{
+	if (pSocket)
+	{
+		if (pSocket->Send(SymbianDeviceInfo) != ITS_OK)
+		{
+			AddString("Could not send.  Try to re-connect.");
+			Prepare();
+		}
+		else
+		{
+			OnReceive();
+		}
+	}
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////
+// PRIVATE FUNCTIONS
+///////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////
+// Add a string to the list box
+///////////////////////////////////////////////////////////////////////////////////
+void CMyclientDlg::AddString(char *szText)
+{
+	m_RecvList.AddString(szText);
+	int nCount = m_RecvList.GetCount();
+	if (nCount > 0)
+		m_RecvList.SetTopIndex(nCount - 1);
+	UpdateWindow();
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////
+// Open a text file in Notepad
+void CMyclientDlg::OpenDataInNotepad(char *pContents, unsigned long ulLength)
+{
+	// save data
+	int ret = E_BADFILENAME;
+
+	CFile script_file;
+	if (script_file.Open(STAT_TEMP_FILE, CFile::modeCreate | CFile::modeWrite | CFile::shareDenyWrite))
+	{
+		try
+		{
+			// might be a zero-length file
+			if (pContents && ulLength)
+				script_file.Write(pContents, ulLength);
+
+			ret = ITS_OK;
+		}
+		catch(CFileException *e)
+		{
+			e->Delete();
+			ret = GENERAL_FAILURE;
+		}
+
+		script_file.Flush();
+		script_file.Close();
+	}
+
+
+	if (ret == ITS_OK)
+	{
+		// open file
+		TCHAR szCurrentDir[MAX_PATH + 1];
+		if (GetWindowsDirectory(szCurrentDir, sizeof(szCurrentDir)))
+		{
+			CString cBuf;
+			cBuf = _T("\"");
+			cBuf += szCurrentDir;
+			cBuf += _T("\\Notepad.exe\" ");
+			cBuf += STAT_TEMP_FILE;
+
+			if (!CallProcess(NULL, cBuf.GetBuffer(0), NULL))
+				MessageBox(_T("Could not invoke Notepad.exe to view script file"), NULL, MB_OK);
+		}
+		else
+			MessageBox(_T("Could not locate Windows directory"), NULL, MB_OK);
+	}
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////
+// Invoke a process
+bool CMyclientDlg::CallProcess(LPCTSTR szApplication, LPTSTR szCommandLine, LPCTSTR szDirectory)
+{
+	bool valid = false;
+	STARTUPINFO startInfo = {0};
+	startInfo.cb = sizeof(STARTUPINFO);
+
+	PROCESS_INFORMATION procInfo = {0};
+
+	// event attributes for the child process
+	SECURITY_ATTRIBUTES eventAttr;
+	eventAttr.nLength = sizeof(eventAttr);
+	eventAttr.lpSecurityDescriptor = NULL;
+	eventAttr.bInheritHandle = TRUE;
+
+	if (CreateProcess(szApplication, szCommandLine, NULL, NULL, FALSE, NULL, NULL,
+					  szDirectory, &startInfo, &procInfo))
+	{
+		valid = true;
+		CloseHandle(procInfo.hThread);
+		CloseHandle(procInfo.hProcess);
+	}
+
+	return valid;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////
+// Reset dialog buttons
+void CMyclientDlg::Prepare()
+{
+	m_Info.EnableWindow(FALSE);
+	m_SendMsg.EnableWindow(FALSE);
+	m_Send.EnableWindow(FALSE);
+	m_Receive.EnableWindow(FALSE);
+	m_Connect.EnableWindow(TRUE);
+	m_ChkListen.EnableWindow(TRUE);
+
+	if (pSocket)
+	{
+		pSocket->Disconnect();
+		pSocket->Release();
+		delete pSocket;
+		pSocket = NULL;
+	}
+}
+
+
+//----------------------------------------------------------------------------
+// Break up newline delimited list of device info and store
+void CMyclientDlg::StoreDeviceInformation(char *info, unsigned long length)
+{
+	ResetDeviceInfo();
+	if (length && info)
+	{
+		char szInfo[2048] = {0};
+		char *pEnd = szInfo;
+		strncpy(szInfo, info, length);
+
+		char *p[18] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+		int i = 0;
+
+		// skip over leading CR/LF's
+		while ((*pEnd) && (*pEnd) == '\r' || (*pEnd) == '\n')
+		{
+			(*pEnd) = (char)0;
+			pEnd++;
+		}
+
+		// split
+		while(*pEnd)
+		{
+			p[i] = pEnd;
+
+			// step over setting
+			while ((*pEnd) && (*pEnd) != '\r' && (*pEnd) != '\n')
+				pEnd++;
+
+			// null terminate
+			while ((*pEnd) && (*pEnd) == '\r' || (*pEnd) == '\n')
+			{
+				(*pEnd) = (char)0;
+				pEnd++;
+			}
+
+			i++;
+			if (i > 18)
+				break;
+		}
+		*pEnd = (char)0;
+
+		// assign
+		strcpy(szMachine, p[0]);
+		strcpy(szCPU, p[1]);
+		strcpy(szInterface, p[2]);
+		strcpy(szFamily, p[3]);
+		strcpy(szManufacturer, p[4]);
+		lModel = atol(p[5]);
+		lFamilyRevision = atol(p[6]);
+		lHardwareRevision = atol(p[7]);
+		lSoftwareRevision = atol(p[8]);
+		lSoftwareBuild = atol(p[9]);
+		lMemoryPageSize = atol(p[10]);
+		lMemoryRAM = atol(p[11]);
+		lMemoryRAMFree = atol(p[12]);
+		lMemoryROM = atol(p[13]);
+		iDelay = atoi(p[14]);
+		iImageVerification = atoi(p[15]);
+		if (iImageVerification)
+		{
+			strcpy(szRefDir, p[16]);
+			iFudge = atoi(p[17]);
+		}
+	}
+}
+
+
+//----------------------------------------------------------------------------
+// Clear any device info settings
+void CMyclientDlg::ResetDeviceInfo()
+{
+	// device info
+	memset(&szMachine, 0, sizeof(szMachine));
+	memset(&szCPU, 0, sizeof(szCPU));
+	memset(&szInterface, 0, sizeof(szInterface));
+	memset(&szFamily, 0, sizeof(szFamily));
+	memset(&szManufacturer, 0, sizeof(szManufacturer));
+	lModel = 0;
+	lFamilyRevision = 0;
+	lHardwareRevision = 0;
+	lSoftwareRevision = 0;
+	lSoftwareBuild = 0;
+	lMemoryPageSize = 0;
+	lMemoryRAM = 0;
+	lMemoryRAMFree = 0;
+	lMemoryROM = 0;
+	iDelay = 0;
+	iImageVerification = 0;
+	memset(&szRefDir, 0, sizeof(szRefDir));
+	iFudge = 0;
+}
+
+
+//----------------------------------------------------------------------------
+// Clear any device info settings
+void CMyclientDlg::DisplayDeviceInformation(char *data)
+{
+	MessageBox(data, "Info", MB_OK);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsblock/myclientdlg.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,120 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// myclientDlg.h : header file
+//
+
+#if !defined(AFX_MYCLIENTDLG_H__DCBFD0A5_CBD8_11D6_AF94_000000000000__INCLUDED_)
+#define AFX_MYCLIENTDLG_H__DCBFD0A5_CBD8_11D6_AF94_000000000000__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+class CSTATSocket;
+
+#define STAT_TEMP_FILE	"C:\\stat_temp_file.tmp"
+
+/////////////////////////////////////////////////////////////////////////////
+// CMyclientDlg dialog
+
+class CMyclientDlg : public CDialog
+{
+// Construction
+public:
+	CMyclientDlg(CWnd* pParent = NULL);	// standard constructor
+
+	CSTATSocket* pSocket;
+
+// Dialog Data
+	//{{AFX_DATA(CMyclientDlg)
+	enum { IDD = IDD_MYCLIENT_DIALOG };
+	CButton	m_Info;
+	CButton	m_Receive;
+	CButton	m_ChkListen;
+	CEdit	m_Port;
+	CEdit	m_Machine;
+	CButton	m_Connect;
+	CButton	m_Send;
+	CEdit	m_SendMsg;
+	CListBox	m_RecvList;
+	//}}AFX_DATA
+
+	// ClassWizard generated virtual function overrides
+	//{{AFX_VIRTUAL(CMyclientDlg)
+	protected:
+	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
+	//}}AFX_VIRTUAL
+
+// Implementation
+protected:
+	HICON m_hIcon;
+
+	// Generated message map functions
+	//{{AFX_MSG(CMyclientDlg)
+	virtual BOOL OnInitDialog();
+	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
+	afx_msg void OnPaint();
+	afx_msg HCURSOR OnQueryDragIcon();
+	afx_msg void OnSend();
+	afx_msg void OnConnect();
+	afx_msg void OnReceive();
+	afx_msg void OnChklisten();
+	virtual void OnOK();
+	afx_msg void OnInfo();
+	//}}AFX_MSG
+	DECLARE_MESSAGE_MAP()
+
+private:
+	void Prepare();
+	void OpenDataInNotepad(char *pContents, unsigned long ulLength);
+	bool CallProcess(LPCTSTR szApplication, LPTSTR szCommandLine, LPCTSTR szDirectory);
+	void AddString(char *szText);
+	void StoreDeviceInformation(char *info, unsigned long length);
+	void ResetDeviceInfo();
+	void DisplayDeviceInformation(char *data);
+
+	HANDLE hThreadHandle;
+
+	// device information - retains information of connected device after <D> command is run
+	char szMachine[256];
+	char szCPU[256];
+	char szInterface[256];
+	char szFamily[256];
+	char szManufacturer[256];
+	long lModel;
+	long lFamilyRevision;
+	long lHardwareRevision;
+	long lSoftwareRevision;
+	long lSoftwareBuild;
+	long lMemoryPageSize;
+	long lMemoryRAM;
+	long lMemoryRAMFree;
+	long lMemoryROM;
+	int iDelay;
+	int iImageVerification;
+	char szRefDir[256];
+	int iFudge;
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_MYCLIENTDLG_H__DCBFD0A5_CBD8_11D6_AF94_000000000000__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsblock/resource.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by myclient.rc
+//
+#define IDM_ABOUTBOX                    0x0010
+#define IDD_ABOUTBOX                    100
+#define IDS_ABOUTBOX                    101
+#define IDD_MYCLIENT_DIALOG             102
+#define IDP_SOCKETS_INIT_FAILED         103
+#define IDR_MAINFRAME                   128
+#define IDC_SENDMSG                     1000
+#define IDC_SEND                        1001
+#define IDC_RECVLIST                    1002
+#define IDC_CONNECT                     1003
+#define IDC_LISTEN                      1004
+#define IDC_MACHINE                     1005
+#define IDC_PORT                        1006
+#define IDC_CHKLISTEN                   1007
+#define IDC_RECEIVE                     1008
+#define IDC_INFO                        1009
+
+// Next default values for new objects
+// 
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE        129
+#define _APS_NEXT_COMMAND_VALUE         32771
+#define _APS_NEXT_CONTROL_VALUE         1010
+#define _APS_NEXT_SYMED_VALUE           101
+#endif
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsblock/stdafx.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// stdafx.cpp : source file that includes just the standard includes
+//	myclient.pch will be the pre-compiled header
+//	stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dllcommstesters/teststatsocketsblock/stdafx.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// stdafx.h : include file for standard system include files,
+//  or project specific include files that are used frequently, but
+//      are changed infrequently
+//
+
+#if !defined(AFX_STDAFX_H__DCBFD0A7_CBD8_11D6_AF94_000000000000__INCLUDED_)
+#define AFX_STDAFX_H__DCBFD0A7_CBD8_11D6_AF94_000000000000__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define VC_EXTRALEAN		// Exclude rarely-used stuff from Windows headers
+
+#include <afxwin.h>         // MFC core and standard components
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__DCBFD0A7_CBD8_11D6_AF94_000000000000__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltester/dlltest.dep	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,33 @@
+# Microsoft Developer Studio Generated Dependency File, included by dlltest.mak
+
+.\src\dlltest.cpp : \
+	"..\..\source\lib\inc\INI.h"\
+	"..\..\source\lib\inc\statcommon.h"\
+	".\inc\dlltest.h"\
+	".\inc\dlltestDlg.h"\
+	".\inc\Resource.h"\
+	
+
+.\dlltest.rc : \
+	".\inc\Resource.h"\
+	".\res\dlltest.ico"\
+	".\res\dlltest.rc2"\
+	
+
+.\src\dlltestDlg.cpp : \
+	"..\..\source\lib\inc\INI.h"\
+	"..\..\source\lib\inc\statcommon.h"\
+	"..\..\source\lib\inc\statexp.h"\
+	".\inc\dlltest.h"\
+	".\inc\dlltestDlg.h"\
+	".\inc\Resource.h"\
+	".\inc\Utils.h"\
+	
+
+.\src\StdAfx.cpp : \
+	".\inc\StdAfx.h"\
+	
+
+.\src\utils.cpp : \
+	".\inc\Utils.h"\
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltester/dlltest.dsp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,176 @@
+# Microsoft Developer Studio Project File - Name="dlltest" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Application" 0x0101
+
+CFG=dlltest - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "dlltest.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "dlltest.mak" CFG="dlltest - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "dlltest - Win32 Release" (based on "Win32 (x86) Application")
+!MESSAGE "dlltest - Win32 Debug" (based on "Win32 (x86) Application")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName "dlltest"
+# PROP Scc_LocalPath "."
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "dlltest - Win32 Release"
+
+# PROP BASE Use_MFC 5
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 5
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I ".\inc" /I "..\..\source\lib\inc" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FR /Yu"stdafx.h" /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
+# ADD LINK32 ..\..\lib\STATDll.lib ..\..\lib\STAT.lib /nologo /subsystem:windows /pdb:none /machine:I386 /out:"Release\STATDllTest.exe"
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Cmds=copy release\STATDllTest.exe \epoc32\tools\stat\STATDllTest.exe
+# End Special Build Tool
+
+!ELSEIF  "$(CFG)" == "dlltest - Win32 Debug"
+
+# PROP BASE Use_MFC 5
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 5
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /Yu"stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /GX /Zi /Od /I ".\inc" /I "..\..\source\lib\inc" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FR /Yu"stdafx.h" /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 ..\..\lib\STATDlld.lib ..\..\lib\STATd.lib /nologo /subsystem:windows /incremental:no /debug /machine:I386 /out:"Debug\STATDllTestd.exe" /pdbtype:sept
+
+!ENDIF 
+
+# Begin Target
+
+# Name "dlltest - Win32 Release"
+# Name "dlltest - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\src\dlltest.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\dlltest.dep
+# End Source File
+# Begin Source File
+
+SOURCE=.\dlltest.mak
+# End Source File
+# Begin Source File
+
+SOURCE=.\dlltest.rc
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\dlltestDlg.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\StdAfx.cpp
+# ADD CPP /Yc"stdafx.h"
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\utils.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\inc\dlltest.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\dlltestDlg.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\source\lib\inc\INI.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\Resource.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\source\lib\inc\statcommon.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\source\lib\inc\statexp.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\StdAfx.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\Utils.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# Begin Source File
+
+SOURCE=.\res\dlltest.ico
+# End Source File
+# Begin Source File
+
+SOURCE=.\res\dlltest.rc2
+# End Source File
+# End Group
+# End Target
+# End Project
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltester/dlltest.mak	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,258 @@
+# Microsoft Developer Studio Generated NMAKE File, Based on dlltest.dsp
+!IF "$(CFG)" == ""
+CFG=dlltest - Win32 Debug
+!MESSAGE No configuration specified. Defaulting to dlltest - Win32 Debug.
+!ENDIF 
+
+!IF "$(CFG)" != "dlltest - Win32 Release" && "$(CFG)" != "dlltest - Win32 Debug"
+!MESSAGE Invalid configuration "$(CFG)" specified.
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "dlltest.mak" CFG="dlltest - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "dlltest - Win32 Release" (based on "Win32 (x86) Application")
+!MESSAGE "dlltest - Win32 Debug" (based on "Win32 (x86) Application")
+!MESSAGE 
+!ERROR An invalid configuration is specified.
+!ENDIF 
+
+!IF "$(OS)" == "Windows_NT"
+NULL=
+!ELSE 
+NULL=nul
+!ENDIF 
+
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "dlltest - Win32 Release"
+
+OUTDIR=.\Release
+INTDIR=.\Release
+# Begin Custom Macros
+OutDir=.\Release
+# End Custom Macros
+
+ALL : "$(OUTDIR)\STATDllTest.exe" "$(OUTDIR)\dlltest.bsc"
+
+
+CLEAN :
+	-@erase "$(INTDIR)\dlltest.obj"
+	-@erase "$(INTDIR)\dlltest.pch"
+	-@erase "$(INTDIR)\dlltest.res"
+	-@erase "$(INTDIR)\dlltest.sbr"
+	-@erase "$(INTDIR)\dlltestDlg.obj"
+	-@erase "$(INTDIR)\dlltestDlg.sbr"
+	-@erase "$(INTDIR)\StdAfx.obj"
+	-@erase "$(INTDIR)\StdAfx.sbr"
+	-@erase "$(INTDIR)\utils.obj"
+	-@erase "$(INTDIR)\utils.sbr"
+	-@erase "$(INTDIR)\vc60.idb"
+	-@erase "$(OUTDIR)\dlltest.bsc"
+	-@erase "$(OUTDIR)\STATDllTest.exe"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MT /W3 /GX /O2 /I ".\inc" /I "..\..\source\lib\inc" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\dlltest.pch" /Yu"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
+RSC_PROJ=/l 0x809 /fo"$(INTDIR)\dlltest.res" /d "NDEBUG" 
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\dlltest.bsc" 
+BSC32_SBRS= \
+	"$(INTDIR)\dlltest.sbr" \
+	"$(INTDIR)\dlltestDlg.sbr" \
+	"$(INTDIR)\StdAfx.sbr" \
+	"$(INTDIR)\utils.sbr"
+
+"$(OUTDIR)\dlltest.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+    $(BSC32) @<<
+  $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=..\..\lib\STATDll.lib ..\..\lib\STAT.lib /nologo /subsystem:windows /pdb:none /machine:I386 /out:"$(OUTDIR)\STATDllTest.exe" 
+LINK32_OBJS= \
+	"$(INTDIR)\dlltest.obj" \
+	"$(INTDIR)\dlltestDlg.obj" \
+	"$(INTDIR)\StdAfx.obj" \
+	"$(INTDIR)\utils.obj" \
+	"$(INTDIR)\dlltest.res"
+
+"$(OUTDIR)\STATDllTest.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+    $(LINK32) @<<
+  $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+SOURCE="$(InputPath)"
+DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep
+
+ALL : $(DS_POSTBUILD_DEP)
+
+# Begin Custom Macros
+OutDir=.\Release
+# End Custom Macros
+
+$(DS_POSTBUILD_DEP) : "$(OUTDIR)\STATDllTest.exe" "$(OUTDIR)\dlltest.bsc"
+   copy release\STATDllTest.exe \epoc32\tools\stat\STATDllTest.exe
+	echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)"
+
+!ELSEIF  "$(CFG)" == "dlltest - Win32 Debug"
+
+OUTDIR=.\Debug
+INTDIR=.\Debug
+# Begin Custom Macros
+OutDir=.\Debug
+# End Custom Macros
+
+ALL : "$(OUTDIR)\STATDllTestd.exe" "$(OUTDIR)\dlltest.bsc"
+
+
+CLEAN :
+	-@erase "$(INTDIR)\dlltest.obj"
+	-@erase "$(INTDIR)\dlltest.pch"
+	-@erase "$(INTDIR)\dlltest.res"
+	-@erase "$(INTDIR)\dlltest.sbr"
+	-@erase "$(INTDIR)\dlltestDlg.obj"
+	-@erase "$(INTDIR)\dlltestDlg.sbr"
+	-@erase "$(INTDIR)\StdAfx.obj"
+	-@erase "$(INTDIR)\StdAfx.sbr"
+	-@erase "$(INTDIR)\utils.obj"
+	-@erase "$(INTDIR)\utils.sbr"
+	-@erase "$(INTDIR)\vc60.idb"
+	-@erase "$(INTDIR)\vc60.pdb"
+	-@erase "$(OUTDIR)\dlltest.bsc"
+	-@erase "$(OUTDIR)\STATDllTestd.exe"
+	-@erase "$(OUTDIR)\STATDllTestd.pdb"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MTd /W3 /GX /Zi /Od /I ".\inc" /I "..\..\source\lib\inc" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\dlltest.pch" /Yu"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c 
+MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
+RSC_PROJ=/l 0x809 /fo"$(INTDIR)\dlltest.res" /d "_DEBUG" 
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\dlltest.bsc" 
+BSC32_SBRS= \
+	"$(INTDIR)\dlltest.sbr" \
+	"$(INTDIR)\dlltestDlg.sbr" \
+	"$(INTDIR)\StdAfx.sbr" \
+	"$(INTDIR)\utils.sbr"
+
+"$(OUTDIR)\dlltest.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+    $(BSC32) @<<
+  $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=..\..\lib\STATDlld.lib ..\..\lib\STATd.lib /nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)\STATDllTestd.pdb" /debug /machine:I386 /out:"$(OUTDIR)\STATDllTestd.exe" /pdbtype:sept 
+LINK32_OBJS= \
+	"$(INTDIR)\dlltest.obj" \
+	"$(INTDIR)\dlltestDlg.obj" \
+	"$(INTDIR)\StdAfx.obj" \
+	"$(INTDIR)\utils.obj" \
+	"$(INTDIR)\dlltest.res"
+
+"$(OUTDIR)\STATDllTestd.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+    $(LINK32) @<<
+  $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ENDIF 
+
+.c{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cpp{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cxx{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.c{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cpp{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cxx{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+
+!IF "$(NO_EXTERNAL_DEPS)" != "1"
+!IF EXISTS("dlltest.dep")
+!INCLUDE "dlltest.dep"
+!ELSE 
+!MESSAGE Warning: cannot find "dlltest.dep"
+!ENDIF 
+!ENDIF 
+
+
+!IF "$(CFG)" == "dlltest - Win32 Release" || "$(CFG)" == "dlltest - Win32 Debug"
+SOURCE=.\src\dlltest.cpp
+
+"$(INTDIR)\dlltest.obj"	"$(INTDIR)\dlltest.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\dlltest.pch"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=.\dlltest.rc
+
+"$(INTDIR)\dlltest.res" : $(SOURCE) "$(INTDIR)"
+	$(RSC) $(RSC_PROJ) $(SOURCE)
+
+
+SOURCE=.\src\dlltestDlg.cpp
+
+"$(INTDIR)\dlltestDlg.obj"	"$(INTDIR)\dlltestDlg.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\dlltest.pch"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=.\src\StdAfx.cpp
+
+!IF  "$(CFG)" == "dlltest - Win32 Release"
+
+CPP_SWITCHES=/nologo /MT /W3 /GX /O2 /I ".\inc" /I "..\..\source\lib\inc" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\dlltest.pch" /Yc"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+
+"$(INTDIR)\StdAfx.obj"	"$(INTDIR)\StdAfx.sbr"	"$(INTDIR)\dlltest.pch" : $(SOURCE) "$(INTDIR)"
+	$(CPP) @<<
+  $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ELSEIF  "$(CFG)" == "dlltest - Win32 Debug"
+
+CPP_SWITCHES=/nologo /MTd /W3 /GX /Zi /Od /I ".\inc" /I "..\..\source\lib\inc" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\dlltest.pch" /Yc"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c 
+
+"$(INTDIR)\StdAfx.obj"	"$(INTDIR)\StdAfx.sbr"	"$(INTDIR)\dlltest.pch" : $(SOURCE) "$(INTDIR)"
+	$(CPP) @<<
+  $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ENDIF 
+
+SOURCE=.\src\utils.cpp
+
+"$(INTDIR)\utils.obj"	"$(INTDIR)\utils.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\dlltest.pch"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+
+!ENDIF 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltester/dlltest.rc	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,320 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "./inc/resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_ABOUTBOX DIALOG DISCARDABLE  0, 0, 184, 79
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "About STAT DLL Entrypoint Tester"
+FONT 8, "MS Sans Serif"
+BEGIN
+    ICON            IDR_MAINFRAME,IDC_STATIC,11,17,20,20
+    LTEXT           "STAT DLL Entrypoint Tester",IDC_STATIC,46,7,97,10,
+                    SS_NOPREFIX
+    LTEXT           "Copyright Symbian (C) 2002",IDC_STATIC,50,38,91,8
+    DEFPUSHBUTTON   "OK",IDOK,69,58,50,14,WS_GROUP
+    LTEXT           "Version 4.0",IDC_STATIC,73,23,40,8
+END
+
+IDD_DLLTEST_DIALOG DIALOGEX 0, 0, 342, 253
+STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | 
+    WS_SYSMENU
+EXSTYLE WS_EX_APPWINDOW
+CAPTION "STAT DLL Entrypoint Tester"
+FONT 8, "MS Sans Serif", 0, 0, 0x1
+BEGIN
+    COMBOBOX        IDC_LINK,64,20,55,76,CBS_DROPDOWNLIST | CBS_SORT | 
+                    CBS_UPPERCASE | WS_TABSTOP
+    EDITTEXT        IDC_DELAY,156,20,24,14,ES_AUTOHSCROLL | ES_NUMBER
+    EDITTEXT        IDC_ITERATIONS,233,20,24,14,ES_AUTOHSCROLL | ES_NUMBER
+    COMBOBOX        IDC_CONNECTION,76,41,50,76,CBS_DROPDOWNLIST | WS_VSCROLL | 
+                    WS_TABSTOP
+    COMBOBOX        IDC_PLATFORM,172,41,51,76,CBS_DROPDOWNLIST | CBS_SORT | 
+                    CBS_UPPERCASE | WS_TABSTOP
+    EDITTEXT        IDC_ADDRESS,265,41,59,14,ES_AUTOHSCROLL
+    PUSHBUTTON      "&Reset Defaults",IDC_RESETSETTINGS,265,20,59,14
+    EDITTEXT        IDC_LOGFILE,76,62,181,14,ES_AUTOHSCROLL
+    EDITTEXT        IDC_RAWCMD,98,103,226,14,ES_AUTOHSCROLL
+    EDITTEXT        IDC_CMDFILE,98,123,159,14,ES_AUTOHSCROLL
+    EDITTEXT        IDC_SNAPSHOT,98,143,159,14,ES_AUTOHSCROLL
+    EDITTEXT        IDC_REFDIR,98,162,159,14,ES_AUTOHSCROLL
+    EDITTEXT        IDC_FUDGE,98,182,28,14,ES_AUTOHSCROLL | ES_NUMBER
+    PUSHBUTTON      "Reset &Defaults",IDC_RESETTESTS,265,182,59,14
+    DEFPUSHBUTTON   "&Run",IDC_RUN,7,232,50,14
+    PUSHBUTTON      "&OK",IDOK,225,232,50,14
+    PUSHBUTTON      "&Cancel",IDCANCEL,284,232,50,14
+    LTEXT           "Delay:",IDC_STATIC,126,20,26,8
+    LTEXT           "Fudge Factor (%):",IDC_STATIC,28,182,61,8
+    LTEXT           "Iterations:",IDC_STATIC,189,20,33,8
+    LTEXT           "DLL Linkage:",IDC_STATIC,16,20,44,8
+    LTEXT           "Platform:",IDC_STATIC,134,41,31,8
+    GROUPBOX        " Tests ",IDC_STATIC,7,89,327,114
+    GROUPBOX        " Settings ",IDC_STATIC,7,6,327,77
+    CONTROL         "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER,7,
+                    210,327,14
+    LTEXT           "Connection Type:",IDC_STATIC,16,41,58,8
+    LTEXT           "Address:",IDC_STATIC,231,41,33,8
+    PUSHBUTTON      "Browse...",IDC_BROWSELOG,265,62,59,14
+    PUSHBUTTON      "Browse...",IDC_BROWSECMDFILE,265,123,59,14
+    PUSHBUTTON      "Browse...",IDC_BROWSESNAPSHOT,265,143,59,14
+    PUSHBUTTON      "Browse...",IDC_BROWSEREFIMAGES,265,162,59,14
+    CONTROL         "Raw Command:",IDC_CHECKRAWCMD,"Button",BS_AUTOCHECKBOX | 
+                    WS_TABSTOP,16,103,66,10
+    CONTROL         "Command File:",IDC_CHECKCMDFILE,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,16,123,62,10
+    CONTROL         "Snapshot Filename:",IDC_CHECKSNAPSHOT,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,16,143,76,10
+    CONTROL         "Image Verification:",IDC_CHECKVERIFICATION,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,16,162,76,10
+    CONTROL         "Log To File:",IDC_CHKLOGTOFILE,"Button",BS_AUTOCHECKBOX | 
+                    WS_TABSTOP,16,62,54,10
+    CONTROL         "Remove old images",IDC_OVERWRITE,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,182,182,75,10
+END
+
+
+#ifndef _MAC
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,0,0,1
+ PRODUCTVERSION 1,0,0,1
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904b0"
+        BEGIN
+            VALUE "Comments", "STAT DLL Test Application\0"
+            VALUE "CompanyName", "Symbian Ltd\0"
+            VALUE "FileDescription", "STAT DLL Test Application\0"
+            VALUE "FileVersion", "4.0\0"
+            VALUE "InternalName", "STAT DLL Test\0"
+            VALUE "LegalCopyright", "Copyright (C) 2005-2009 Nokia Corporation\0"
+            VALUE "LegalTrademarks", "Copyright Nokia Corporation\0"
+            VALUE "OriginalFilename", "STATDLLTest.exe\0"
+            VALUE "PrivateBuild", "\0"
+            VALUE "ProductName", "STAT DLL Test Application\0"
+            VALUE "ProductVersion", "4.0\0"
+            VALUE "SpecialBuild", "\0"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x409, 1200
+    END
+END
+
+#endif    // !_MAC
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE 
+BEGIN
+    IDD_ABOUTBOX, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 177
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 72
+    END
+
+    IDD_DLLTEST_DIALOG, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 334
+        VERTGUIDE, 16
+        VERTGUIDE, 76
+        VERTGUIDE, 98
+        VERTGUIDE, 126
+        VERTGUIDE, 189
+        VERTGUIDE, 197
+        VERTGUIDE, 209
+        VERTGUIDE, 250
+        VERTGUIDE, 257
+        VERTGUIDE, 265
+        VERTGUIDE, 324
+        TOPMARGIN, 6
+        BOTTOMMARGIN, 246
+        HORZGUIDE, 20
+        HORZGUIDE, 41
+        HORZGUIDE, 62
+        HORZGUIDE, 83
+        HORZGUIDE, 103
+        HORZGUIDE, 123
+        HORZGUIDE, 143
+        HORZGUIDE, 162
+        HORZGUIDE, 182
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog Info
+//
+
+IDD_DLLTEST_DIALOG DLGINIT
+BEGIN
+    IDC_LINK, 0x403, 9, 0
+0x5552, 0x2d4e, 0x4954, 0x454d, "\000" 
+    IDC_LINK, 0x403, 8, 0
+0x5944, 0x414e, 0x494d, 0x0043, 
+    IDC_CONNECTION, 0x403, 7, 0
+0x6f53, 0x6b63, 0x7465, "\000" 
+    IDC_CONNECTION, 0x403, 7, 0
+0x6553, 0x6972, 0x6c61, "\000" 
+    IDC_CONNECTION, 0x403, 10, 0
+0x6e49, 0x7266, 0x2d61, 0x6572, 0x0064, 
+    IDC_CONNECTION, 0x403, 10, 0
+0x6c42, 0x6575, 0x6f74, 0x746f, 0x0068, 
+    IDC_CONNECTION, 0x403, 4, 0
+0x5355, 0x0042, 
+    IDC_PLATFORM, 0x403, 4, 0
+0x5241, 0x004d, 
+    IDC_PLATFORM, 0x403, 5, 0
+0x4957, 0x534e, "\000" 
+    IDC_PLATFORM, 0x403, 7, 0
+0x4957, 0x534e, 0x5743, "\000" 
+    IDC_PLATFORM, 0x403, 6, 0
+0x4854, 0x4d55, 0x0042, 
+    0
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE 
+BEGIN
+    IDS_ABOUTBOX            "&About dlltest..."
+END
+
+#endif    // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.K.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    ".\\inc\\resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "#include ""afxres.h""\r\n"
+    "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
+    "#define _AFX_NO_OLE_RESOURCES\r\n"
+    "#define _AFX_NO_TRACKER_RESOURCES\r\n"
+    "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
+    "\r\n"
+    "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
+    "#ifdef _WIN32\r\n"
+    "LANGUAGE 9, 1\r\n"
+    "#pragma code_page(1252)\r\n"
+    "#endif //_WIN32\r\n"
+    "#include ""res\\dlltest.rc2""  // non-Microsoft Visual C++ edited resources\r\n"
+    "#include ""afxres.rc""         // Standard components\r\n"
+    "#endif\r\n"
+    "\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDR_MAINFRAME           ICON    DISCARDABLE     "res\\dlltest.ico"
+#endif    // English (U.K.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+#define _AFX_NO_SPLITTER_RESOURCES
+#define _AFX_NO_OLE_RESOURCES
+#define _AFX_NO_TRACKER_RESOURCES
+#define _AFX_NO_PROPERTY_RESOURCES
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE 9, 1
+#pragma code_page(1252)
+#endif //_WIN32
+#include "res/dlltest.rc2"  // non-Microsoft Visual C++ edited resources
+#include "afxres.rc"         // Standard components
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+#endif    // not APSTUDIO_INVOKED
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltester/group/bld.inf	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,41 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:  
+//
+
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+
+* which accompanies this distribution, and is available
+
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+PRJ_PLATFORMS
+
+TOOLS
+
+PRJ_MMPFILES
+// Extension Makefile
+makefile statdlltester.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltester/group/statdlltester.mk	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,82 @@
+#
+# Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:  
+#
+
+# which accompanies this distribution, and is available
+
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+# Typically C:\apps\MSVC6\VC98\Bin
+COMPILER=nmake
+
+# Called with
+#
+# $(PLATFORM) = TOOLS
+# $(CFG)      = DEB, REL
+
+BLD	:  
+	@echo BLD called with $(PLATFORM)$(CFG)
+	
+# release version
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "REL"
+
+# Go up one level to access the makefile
+	cd ".."
+
+# Execute the command line compiler (dlltester)
+	"$(COMPILER)" /A /NOLOGO /f "dlltest.mak" CFG="dlltest - Win32 Release"
+	
+	echo ** DLL TESTER (RELEASE) compiled successfully
+
+!endif
+
+# debug version
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "DEB"
+
+# Go up one level to access the makefile
+	cd ".."
+
+# Execute the command line compiler (dlltester)
+	"$(COMPILER)" /A /NOLOGO /f "dlltest.mak" CFG="dlltest - Win32 Debug"
+	
+	echo ** DLL TESTER (DEBUG) compiled successfully
+
+!endif
+
+CLEAN :
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "REL"
+	-rmdir "..\Release" /q /s
+!endif
+
+CLEAN :
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "DEB"
+	-rmdir "..\Debug" /q /s
+!endif
+
+RELEASABLES :
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "REL"
+	@echo $(EPOCROOT)epoc32\tools\STAT\STATDlltest.exe
+!endif
+
+SAVESPACE : BLD
+
+MAKMAKE LIB CLEANLIB RESOURCE FREEZE FINAL : 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltester/inc/dlltest.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,67 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// dlltest.h : main header file for the DLLTEST application
+//
+
+#if !defined(AFX_DLLTEST_H__04DFB724_4E37_11D6_BC5F_00B0D065107F__INCLUDED_)
+#define AFX_DLLTEST_H__04DFB724_4E37_11D6_BC5F_00B0D065107F__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#ifndef __AFXWIN_H__
+	#error include 'stdafx.h' before including this file for PCH
+#endif
+
+#include "resource.h"		// main symbols
+
+/////////////////////////////////////////////////////////////////////////////
+// CDlltestApp:
+// See dlltest.cpp for the implementation of this class
+//
+
+class CDlltestApp : public CWinApp
+{
+public:
+	CDlltestApp();
+
+// Overrides
+	// ClassWizard generated virtual function overrides
+	//{{AFX_VIRTUAL(CDlltestApp)
+	public:
+	virtual BOOL InitInstance();
+	//}}AFX_VIRTUAL
+
+// Implementation
+
+	//{{AFX_MSG(CDlltestApp)
+	//}}AFX_MSG
+	DECLARE_MESSAGE_MAP()
+};
+
+
+/////////////////////////////////////////////////////////////////////////////
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_DLLTEST_H__04DFB724_4E37_11D6_BC5F_00B0D065107F__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltester/inc/dlltestdlg.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,133 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// dlltestDlg.h : header file
+//
+
+#if !defined(AFX_DLLTESTDLG_H__04DFB726_4E37_11D6_BC5F_00B0D065107F__INCLUDED_)
+#define AFX_DLLTESTDLG_H__04DFB726_4E37_11D6_BC5F_00B0D065107F__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include <statcommon.h>
+#include <ini.h>
+
+/////////////////////////////////////////////////////////////////////////////
+// CDlltestDlg dialog
+
+class CDlltestDlg : public CDialog
+{
+// Construction
+public:
+	CDlltestDlg(CWnd* pParent = NULL);	// standard constructor
+	void Run();
+
+// Dialog Data
+	//{{AFX_DATA(CDlltestDlg)
+	enum { IDD = IDD_DLLTEST_DIALOG };
+	CButton	m_RemoveImages;
+	CButton	m_Run;
+	CButton	m_ChkLogtofile;
+	CButton	m_BrowseSnapshot;
+	CButton	m_BrowseRefImages;
+	CButton	m_BrowseLog;
+	CButton	m_BrowseCmdFile;
+	CButton	m_CheckCmdFile;
+	CButton	m_CheckVerification;
+	CButton	m_CheckSnapshot;
+	CButton	m_CheckRawCmd;
+	CEdit	m_Address;
+	CComboBox	m_Connection;
+	CProgressCtrl	m_Progress;
+	CEdit	m_Snapshot;
+	CEdit	m_Delay;
+	CEdit	m_Fudge;
+	CEdit	m_RefDir;
+	CEdit	m_RawCmd;
+	CEdit	m_LogFile;
+	CEdit	m_CmdFile;
+	CEdit	m_Iterations;
+	CComboBox	m_Platform;
+	CComboBox	m_Link;
+	//}}AFX_DATA
+
+	// ClassWizard generated virtual function overrides
+	//{{AFX_VIRTUAL(CDlltestDlg)
+	protected:
+	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
+	//}}AFX_VIRTUAL
+
+// Implementation
+protected:
+	HICON m_hIcon;
+
+	// Generated message map functions
+	//{{AFX_MSG(CDlltestDlg)
+	virtual BOOL OnInitDialog();
+	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
+	afx_msg void OnPaint();
+	afx_msg HCURSOR OnQueryDragIcon();
+	afx_msg void OnRun();
+	afx_msg void OnChangeConnection();
+	virtual void OnOK();
+	afx_msg void OnResetsettings();
+	afx_msg void OnResettests();
+	afx_msg void OnBrowselog();
+	afx_msg void OnCheckcmdfile();
+	afx_msg void OnCheckrawcmd();
+	afx_msg void OnChecksnapshot();
+	afx_msg void OnCheckverification();
+	afx_msg void OnBrowsecmdfile();
+	afx_msg void OnBrowsesnapshot();
+	afx_msg void OnBrowserefimages();
+	afx_msg void OnChklogtofile();
+	//}}AFX_MSG
+	DECLARE_MESSAGE_MAP()
+
+private:
+	void LoadEntrypoint(HINSTANCE inst, FARPROC *fn, const char *name);
+	bool LoadFunctionEntrypoints(HINSTANCE inst);
+	void Evaluate(int ret, int handle);
+	bool WriteBitmap(char *file, TBitmapFileHeader *fileheader, TBitmapInfoHeader * bmpHeader, char *bmpBits, unsigned long lSize);
+	int GetIncrement();
+	void ReadSettings();
+	void SaveSettings();
+	void AddConnectPlatforms();
+	void AddPortPlatforms();
+	void ChangeConnection(int iSelection);
+	void EnableFields(bool bEnable);
+	void GetLogFolder(CString& logFileFolder) const;
+	void GetLogFilePath(const char* logFileName, CString& logFilePath) const;
+
+	bool bRunning;				// flag set if currently processing a script
+	HANDLE hThreadHandle;		// handle to our worker thread
+	char szBuffer[2048];		// global buffer for strings
+	int iValue;					// global buffer for ints
+	int h;						// handle to stat
+	bool bErrors;
+	CStatIniFile statIniFile;
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_DLLTESTDLG_H__04DFB726_4E37_11D6_BC5F_00B0D065107F__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltester/inc/resource.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by M:\D\P4work\DP\development\project\2008\preq2582\sf\ana\testexec\testtoolsconn\stat\Desktop\testsource\dlltester\dlltest.rc
+//
+
+// Next default values for new objects
+// 
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE        130
+#define _APS_NEXT_COMMAND_VALUE         32771
+#define _APS_NEXT_CONTROL_VALUE         1027
+#define _APS_NEXT_SYMED_VALUE           101
+#endif
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltester/inc/stdafx.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// stdafx.h : include file for standard system include files,
+//  or project specific include files that are used frequently, but
+//      are changed infrequently
+//
+
+#if !defined(AFX_STDAFX_H__04DFB728_4E37_11D6_BC5F_00B0D065107F__INCLUDED_)
+#define AFX_STDAFX_H__04DFB728_4E37_11D6_BC5F_00B0D065107F__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define VC_EXTRALEAN		// Exclude rarely-used stuff from Windows headers
+
+#include <afxwin.h>         // MFC core and standard components
+#include <afxext.h>         // MFC extensions
+#include <afxdtctl.h>		// MFC support for Internet Explorer 4 Common Controls
+#ifndef _AFX_NO_AFXCMN_SUPPORT
+#include <afxcmn.h>			// MFC support for Windows Common Controls
+#endif // _AFX_NO_AFXCMN_SUPPORT
+
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__04DFB728_4E37_11D6_BC5F_00B0D065107F__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltester/inc/utils.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// Utils.h : main header file for the basic utilities class
+//
+
+#ifndef UTILS_H
+#define UTILS_H
+
+#include <windows.h>
+#include <stdio.h>
+#include <winsvc.h>
+
+// service requests
+#define REQ_START 1
+#define REQ_STOP  2
+
+// file requests
+#define DELETEALL 1
+#define DELETEFILESONLY 2
+#define REMOVEALLATTRIBUTES 4
+
+
+class CUtils
+{
+	SC_HANDLE hSCM;
+	HANDLE m_hMutex;
+	WIN32_FIND_DATA ffd;
+	unsigned int iFileCommand;
+	unsigned int iFileCount;
+	TCHAR szError[2048];
+	unsigned long retCode;
+
+	bool Validate(SC_HANDLE hSCM, const char *szServiceName, DWORD dwState, bool bDisplayOnly = false);
+	void Recurse(const char * rootDir);
+	void DealWithDependentServices(const char *szServiceName, const unsigned int iRequest);
+	void _GetWindowsError();
+
+public:
+	CUtils();
+	~CUtils();
+
+	bool AlreadyRunning(LPCTSTR szAppName);
+	bool CallProcessAndWait(LPCTSTR szApplication, LPTSTR szCommandLine, LPCTSTR szDirectory, bool bRunMinimised = false);
+	bool CallProcess(LPCTSTR szApplication, LPTSTR szCommandLine, LPCTSTR szDirectory);
+	bool ServiceRequest(const char *szServiceName, const unsigned int iRequest);
+	bool ListServices(DWORD dwState);
+	unsigned int RecurseDir(const char *szDirectory, const unsigned int iCommand);
+	void AddSlash(char *szPath);
+	int TrimBufferToFirstEOL(HANDLE mmphndl, char *szBuffer, bool bIncludeCR = true);
+	void TrimBufferToLastEOL(HANDLE mmphndl, char *szBuffer);
+	void TrimTabsCRAndWhitespace(char *szBuffer);
+	char *GetWindowsError();
+	char *GetWindowsErrorNow();
+	unsigned long GetReturnCode() {return retCode;}
+	unsigned long GetReturnCodeNow() {return GetLastError();}
+};
+
+#endif
Binary file testconns/statdesktop/desktop/testsource/dlltester/res/dlltest.ico has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltester/res/dlltest.rc2	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,13 @@
+//
+// DLLTEST.RC2 - resources Microsoft Visual C++ does not edit directly
+//
+
+#ifdef APSTUDIO_INVOKED
+	#error this file is not editable by Microsoft Visual C++
+#endif //APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Add manually edited resources here...
+
+/////////////////////////////////////////////////////////////////////////////
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltester/src/dlltest.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// dlltest.cpp : Defines the class behaviors for the application.
+//
+
+#include "stdafx.h"
+#include "dlltest.h"
+#include "dlltestDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CDlltestApp
+
+BEGIN_MESSAGE_MAP(CDlltestApp, CWinApp)
+	//{{AFX_MSG_MAP(CDlltestApp)
+	//}}AFX_MSG
+	ON_COMMAND(ID_HELP, CWinApp::OnHelp)
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CDlltestApp construction
+
+CDlltestApp::CDlltestApp()
+{
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// The one and only CDlltestApp object
+
+CDlltestApp theApp;
+
+/////////////////////////////////////////////////////////////////////////////
+// CDlltestApp initialization
+
+BOOL CDlltestApp::InitInstance()
+{
+	// Standard initialization
+
+	CDlltestDlg dlg;
+	m_pMainWnd = &dlg;
+	int nResponse = dlg.DoModal();
+	if (nResponse == IDOK)
+	{
+	}
+	else if (nResponse == IDCANCEL)
+	{
+	}
+
+	// Since the dialog has been closed, return FALSE so that we exit the
+	//  application, rather than start the application's message pump.
+	return FALSE;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltester/src/dlltestdlg.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,1419 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// dlltestDlg.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "dlltest.h"
+#include "dlltestDlg.h"
+
+#include <utils.h>
+#include <statexp.h>
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+// function pointer prototypes
+typedef	char * (*LPFN_Version)();
+typedef	char * (*LPFN_GetError)(const int handle);
+typedef	int (*LPFN_SetConnectionLogging)(const char * filename);
+typedef	void (*LPFN_CloseConnectionLogging)();
+typedef	int (*LPFN_Connect)(const STATCONNECTTYPE iConnectType, const char * pszPlatformType);
+typedef	int (*LPFN_Disconnect)(const int handle);
+typedef	int (*LPFN_SetCommandDelay)(const int handle, const unsigned int iMillisecondDelay);
+typedef	int (*LPFN_SetCommandLogging)(const int handle, const char * pszLogPath, HWND messageWindow, const STATLOGLEVEL iLevel, const bool bAppend);
+typedef	int (*LPFN_SetImageVerification)(const int handle, const char * pszRefDir, const bool bRemoveOldImages, const int iFactor);
+typedef	int (*LPFN_SendRawCommand)(const int handle, const char * pszText);
+typedef	int (*LPFN_SendCommandFile)(const int handle, const char * pszFile);
+typedef	int (*LPFN_GetSnapshot)(const int handle, TBitmapFileHeader **ppFile, TBitmapInfoHeader **ppBitmap, char **ppData, unsigned long *pSize);
+
+// initialise pointers
+LPFN_Version pfn_Version = NULL;
+LPFN_GetError pfn_GetError = NULL;
+LPFN_SetConnectionLogging pfn_SetConnectionLogging = NULL;
+LPFN_CloseConnectionLogging pfn_CloseConnectionLogging = NULL;
+LPFN_Connect pfn_Connect = NULL;
+LPFN_Disconnect pfn_Disconnect = NULL;
+LPFN_SetCommandDelay pfn_SetCommandDelay = NULL;
+LPFN_SetCommandLogging pfn_SetCommandLogging = NULL;
+LPFN_SetImageVerification pfn_SetImageVerification = NULL;
+LPFN_SendRawCommand pfn_SendRawCommand = NULL;
+LPFN_SendCommandFile pfn_SendCommandFile = NULL;
+LPFN_GetSnapshot pfn_GetSnapshot = NULL;
+
+//////////////////////////////////////////////////////////////////////////
+// This is the main thread function which listens on a socket and
+// processes any incoming scripts
+DWORD WINAPI
+ThreadProc(LPVOID lpParameter)
+{
+	CDlltestDlg *pWorker = (CDlltestDlg *)lpParameter;
+
+	pWorker->Run();
+
+	return 1;
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CAboutDlg dialog used for App About
+
+class CAboutDlg : public CDialog
+{
+public:
+	CAboutDlg();
+
+// Dialog Data
+	//{{AFX_DATA(CAboutDlg)
+	enum { IDD = IDD_ABOUTBOX };
+	//}}AFX_DATA
+
+	// ClassWizard generated virtual function overrides
+	//{{AFX_VIRTUAL(CAboutDlg)
+	protected:
+	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+	//}}AFX_VIRTUAL
+
+// Implementation
+protected:
+	//{{AFX_MSG(CAboutDlg)
+	//}}AFX_MSG
+	DECLARE_MESSAGE_MAP()
+};
+
+CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
+{
+	//{{AFX_DATA_INIT(CAboutDlg)
+	//}}AFX_DATA_INIT
+}
+
+void CAboutDlg::DoDataExchange(CDataExchange* pDX)
+{
+	CDialog::DoDataExchange(pDX);
+	//{{AFX_DATA_MAP(CAboutDlg)
+	//}}AFX_DATA_MAP
+}
+
+BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
+	//{{AFX_MSG_MAP(CAboutDlg)
+		// No message handlers
+	//}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CDlltestDlg dialog
+
+CDlltestDlg::CDlltestDlg(CWnd* pParent /*=NULL*/)
+	: CDialog(CDlltestDlg::IDD, pParent)
+{
+	//{{AFX_DATA_INIT(CDlltestDlg)
+		// NOTE: the ClassWizard will add member initialization here
+	//}}AFX_DATA_INIT
+	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
+}
+
+void CDlltestDlg::DoDataExchange(CDataExchange* pDX)
+{
+	CDialog::DoDataExchange(pDX);
+	//{{AFX_DATA_MAP(CDlltestDlg)
+	DDX_Control(pDX, IDC_OVERWRITE, m_RemoveImages);
+	DDX_Control(pDX, IDC_RUN, m_Run);
+	DDX_Control(pDX, IDC_CHKLOGTOFILE, m_ChkLogtofile);
+	DDX_Control(pDX, IDC_BROWSESNAPSHOT, m_BrowseSnapshot);
+	DDX_Control(pDX, IDC_BROWSEREFIMAGES, m_BrowseRefImages);
+	DDX_Control(pDX, IDC_BROWSELOG, m_BrowseLog);
+	DDX_Control(pDX, IDC_BROWSECMDFILE, m_BrowseCmdFile);
+	DDX_Control(pDX, IDC_CHECKCMDFILE, m_CheckCmdFile);
+	DDX_Control(pDX, IDC_CHECKVERIFICATION, m_CheckVerification);
+	DDX_Control(pDX, IDC_CHECKSNAPSHOT, m_CheckSnapshot);
+	DDX_Control(pDX, IDC_CHECKRAWCMD, m_CheckRawCmd);
+	DDX_Control(pDX, IDC_ADDRESS, m_Address);
+	DDX_Control(pDX, IDC_CONNECTION, m_Connection);
+	DDX_Control(pDX, IDC_PROGRESS, m_Progress);
+	DDX_Control(pDX, IDC_SNAPSHOT, m_Snapshot);
+	DDX_Control(pDX, IDC_DELAY, m_Delay);
+	DDX_Control(pDX, IDC_FUDGE, m_Fudge);
+	DDX_Control(pDX, IDC_REFDIR, m_RefDir);
+	DDX_Control(pDX, IDC_RAWCMD, m_RawCmd);
+	DDX_Control(pDX, IDC_LOGFILE, m_LogFile);
+	DDX_Control(pDX, IDC_CMDFILE, m_CmdFile);
+	DDX_Control(pDX, IDC_ITERATIONS, m_Iterations);
+	DDX_Control(pDX, IDC_PLATFORM, m_Platform);
+	DDX_Control(pDX, IDC_LINK, m_Link);
+	//}}AFX_DATA_MAP
+}
+
+BEGIN_MESSAGE_MAP(CDlltestDlg, CDialog)
+	//{{AFX_MSG_MAP(CDlltestDlg)
+	ON_WM_SYSCOMMAND()
+	ON_WM_PAINT()
+	ON_WM_QUERYDRAGICON()
+	ON_BN_CLICKED(IDC_RUN, OnRun)
+	ON_CBN_SELCHANGE(IDC_CONNECTION, OnChangeConnection)
+	ON_BN_CLICKED(IDC_RESETSETTINGS, OnResetsettings)
+	ON_BN_CLICKED(IDC_RESETTESTS, OnResettests)
+	ON_BN_CLICKED(IDC_BROWSELOG, OnBrowselog)
+	ON_BN_CLICKED(IDC_CHECKCMDFILE, OnCheckcmdfile)
+	ON_BN_CLICKED(IDC_CHECKRAWCMD, OnCheckrawcmd)
+	ON_BN_CLICKED(IDC_CHECKSNAPSHOT, OnChecksnapshot)
+	ON_BN_CLICKED(IDC_CHECKVERIFICATION, OnCheckverification)
+	ON_BN_CLICKED(IDC_BROWSECMDFILE, OnBrowsecmdfile)
+	ON_BN_CLICKED(IDC_BROWSESNAPSHOT, OnBrowsesnapshot)
+	ON_BN_CLICKED(IDC_BROWSEREFIMAGES, OnBrowserefimages)
+	ON_BN_CLICKED(IDC_CHKLOGTOFILE, OnChklogtofile)
+	//}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CDlltestDlg message handlers
+
+BOOL CDlltestDlg::OnInitDialog()
+{
+	CDialog::OnInitDialog();
+
+	// Add "About..." menu item to system menu.
+
+	// IDM_ABOUTBOX must be in the system command range.
+	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
+	ASSERT(IDM_ABOUTBOX < 0xF000);
+
+	CMenu* pSysMenu = GetSystemMenu(FALSE);
+	if (pSysMenu != NULL)
+	{
+		CString strAboutMenu;
+		strAboutMenu.LoadString(IDS_ABOUTBOX);
+		if (!strAboutMenu.IsEmpty())
+		{
+			pSysMenu->AppendMenu(MF_SEPARATOR);
+			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
+		}
+	}
+
+	SetIcon(m_hIcon, TRUE);			// Set big icon
+	SetIcon(m_hIcon, FALSE);		// Set small icon
+
+	m_Snapshot.SetLimitText(sizeof(szBuffer));
+	m_RefDir.SetLimitText(sizeof(szBuffer));
+	m_RawCmd.SetLimitText(sizeof(szBuffer));
+	m_LogFile.SetLimitText(sizeof(szBuffer));
+	m_CmdFile.SetLimitText(sizeof(szBuffer));
+
+	// initialise our settings
+	OnResetsettings();
+	OnResettests();
+	ReadSettings();
+
+	return TRUE;  // return TRUE  unless you set the focus to a control
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+void CDlltestDlg::OnSysCommand(UINT nID, LPARAM lParam)
+{
+	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
+	{
+		CAboutDlg dlgAbout;
+		dlgAbout.DoModal();
+	}
+	else
+	{
+		CDialog::OnSysCommand(nID, lParam);
+	}
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+// If you add a minimize button to your dialog, you will need the code below
+//  to draw the icon.  For MFC applications using the document/view model,
+//  this is automatically done for you by the framework.
+
+void CDlltestDlg::OnPaint() 
+{
+	if (IsIconic())
+	{
+		CPaintDC dc(this); // device context for painting
+
+		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
+
+		// Center icon in client rectangle
+		int cxIcon = GetSystemMetrics(SM_CXICON);
+		int cyIcon = GetSystemMetrics(SM_CYICON);
+		CRect rect;
+		GetClientRect(&rect);
+		int x = (rect.Width() - cxIcon + 1) / 2;
+		int y = (rect.Height() - cyIcon + 1) / 2;
+
+		// Draw the icon
+		dc.DrawIcon(x, y, m_hIcon);
+	}
+	else
+	{
+		CDialog::OnPaint();
+	}
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+HCURSOR CDlltestDlg::OnQueryDragIcon()
+{
+	return (HCURSOR) m_hIcon;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+void CDlltestDlg::OnRun() 
+{
+	if (bRunning)
+	{
+		if (IDYES == AfxMessageBox(_T("The work task has not completed its current job and stopping it now may cause it to be left in an unstable state.  Do you wish to abort the current task?"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2))
+		{
+			TerminateThread(hThreadHandle, (unsigned long)-1);
+			EnableFields(TRUE);
+		}
+	}
+	else
+	{
+		//call Run to run through the script (with no appending to log file in this case) - spawn a thread...
+		DWORD dwThreadID;
+		if (hThreadHandle = CreateThread( NULL,					// security attributes
+												0,				// stack size
+												ThreadProc,		// proc to call
+												this,			// proc parameter
+												0,				// creation flags
+												&dwThreadID))	// thread identifier
+		{
+			EnableFields(FALSE);
+
+			MSG msg;
+			while(WaitForSingleObject(hThreadHandle, STAT_THREAD_SLEEP_TIME) == WAIT_TIMEOUT)
+			{
+				PeekMessage(&msg, m_hWnd, 0, 0, PM_REMOVE);
+				DispatchMessage(&msg);
+			}
+
+			EnableFields(TRUE);
+		}
+	}
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+void CDlltestDlg::Run()
+{
+	struct TBitmapFileHeader *pFile = NULL;
+	struct TBitmapInfoHeader *pInfo = NULL;
+	char *pData = NULL;
+	char szPrevious[10] = {0};
+	char szRemaining[10] = {0};
+	unsigned long lSize = 0;
+
+	bErrors = false;
+
+	m_Progress.SetRange(0, 100);
+	m_Progress.SetPos(0);
+	m_Progress.SetStep(GetIncrement());
+
+	CString logFile;		// We use this file name throughout the
+							// function and we should save it.
+	CString logFilePath;	// Also, we have a bit of a mixture
+							// of calls to make to set up logging
+							// and some require a file name (and assume a
+							// folder) and some require a full path.
+							// Generate a full path (based on the file name
+							// above) and use whichever variable suits
+							// each function call.
+
+	if (m_ChkLogtofile.GetCheck())
+	{
+		m_LogFile.GetWindowText(logFile);
+		GetLogFilePath(logFile,logFilePath);
+	}
+
+	// connect to runtime dll
+	if (m_Link.GetCurSel() == 1)
+	{
+		// display version
+		MessageBox(Version(), "STAT DLL Version", MB_OK);
+
+		CWaitCursor oWait;
+
+		// log connections
+		if (m_ChkLogtofile.GetCheck())
+		{
+			if (0 != logFilePath.GetLength())
+			{
+				SetConnectionLogging(logFilePath);
+			}
+		}
+
+		// get the connect string
+		switch(m_Connection.GetCurSel())
+		{
+		case 1:	// serial
+		case 2:	// infra-red
+		case 3:	// bluetooth
+		case 4:	// USB
+			m_Platform.GetLBText(m_Platform.GetCurSel(), szBuffer);
+			break;
+		case 0:	// socket
+			m_Address.GetWindowText(szBuffer, sizeof(szBuffer));
+			break;
+		}
+
+		// connect
+		Evaluate(h = Connect((STATCONNECTTYPE)(m_Connection.GetCurSel() + 1), szBuffer, NULL, NULL), h);
+
+		if (h)
+		{
+			m_Progress.StepIt();
+			UpdateWindow();
+
+			// log commands
+			if (m_ChkLogtofile.GetCheck())
+			{
+				if (0 != logFile.GetLength())
+					Evaluate(SetCommandLogging(h, logFile, NULL, EVerbose, true, NULL, NULL), h);
+			}
+
+			if (!bErrors)
+			{
+				// set command delay
+				m_Delay.GetWindowText(szBuffer, sizeof(szBuffer));
+				iValue = atoi(szBuffer);
+				Evaluate(SetCommandDelay(h, iValue), h);
+			}
+
+			if (!bErrors)
+			{
+				// set image verification
+				if (m_CheckVerification.GetCheck())
+				{
+					m_Fudge.GetWindowText(szBuffer, sizeof(szBuffer));
+					iValue = atoi(szBuffer);
+					m_RefDir.GetWindowText(szBuffer, sizeof(szBuffer));
+					if (*szBuffer)
+						Evaluate(SetImageVerification(h, szBuffer, m_RemoveImages.GetCheck()?true:false, iValue), h);
+				}
+			}
+
+			m_Iterations.GetWindowText(szPrevious, sizeof(szPrevious));
+			int iMax = atoi(szPrevious);
+			for (int i=0;i<iMax;i++)
+			{
+				if (!bErrors)
+				{
+					// execute raw command
+					if (m_CheckRawCmd.GetCheck())
+					{
+						m_RawCmd.GetWindowText(szBuffer, sizeof(szBuffer));
+						if (*szBuffer)
+						{
+							Evaluate(SendRawCommand(h, szBuffer), h);
+							m_Progress.StepIt();
+							UpdateWindow();
+						}
+					}
+				}
+
+				if (!bErrors)
+				{
+					// execute command file
+					if (m_CheckCmdFile.GetCheck())
+					{
+						m_CmdFile.GetWindowText(szBuffer, sizeof(szBuffer));
+						if (*szBuffer)
+						{
+							Evaluate(SendCommandFile(h, szBuffer), h);
+							m_Progress.StepIt();
+							UpdateWindow();
+						}
+					}
+				}
+
+				if (!bErrors)
+				{
+					// get a snapshot
+					if (m_CheckSnapshot.GetCheck())
+					{
+						m_Snapshot.GetWindowText(szBuffer, sizeof(szBuffer));
+						if (*szBuffer)
+						{
+							DeleteFile(szBuffer);
+							Evaluate(GetSnapshot(h, &pFile, &pInfo, &pData, &lSize), h);
+
+							if (!bErrors)
+								if (!WriteBitmap(szBuffer, pFile, pInfo, pData, lSize))
+									bErrors = true;
+
+							m_Progress.StepIt();
+							UpdateWindow();
+						}
+					}
+				}
+
+				// decrement the iteration count
+				itoa(iMax - i - 1, szRemaining, 10);
+				m_Iterations.SetWindowText(szRemaining);
+				UpdateWindow();
+			}
+
+			// disconnect
+			Evaluate(Disconnect(h), h);
+			m_Progress.SetPos(100);
+			m_Iterations.SetWindowText(szPrevious);
+		}
+
+		if (m_ChkLogtofile.GetCheck())
+			CloseConnectionLogging();
+	}
+	else
+	{
+		// connect to loaded dll
+#if defined _DEBUG
+		HINSTANCE inst = LoadLibrary("statd.dll");
+#else // defined _DEBUG
+		HINSTANCE inst = LoadLibrary("stat.dll");
+#endif // defined _DEBUG
+		if (inst && LoadFunctionEntrypoints(inst))
+		{
+			// display version
+			MessageBox((*pfn_Version)(), "STAT DLL Version", MB_OK);
+
+			CWaitCursor oWait;
+
+			// log connections
+			if (m_ChkLogtofile.GetCheck())
+			{
+				if (0 != logFilePath.GetLength())
+				{
+					(*pfn_SetConnectionLogging)(logFilePath);
+				}
+			}
+
+			// get the connect string
+			switch(m_Connection.GetCurSel())
+			{
+			case 1:	// serial
+			case 2:	// infra-red
+			case 3:	// bluetooth
+			case 4:	// USB
+				m_Platform.GetLBText(m_Platform.GetCurSel(), szBuffer);
+				break;
+			
+			case 0:	// socket
+				m_Address.GetWindowText(szBuffer, sizeof(szBuffer));
+				break;
+			}
+
+			// connect
+			Evaluate(h = (*pfn_Connect)((STATCONNECTTYPE)(m_Connection.GetCurSel() + 1), szBuffer), h);
+
+			if (h)
+			{
+				m_Progress.StepIt();
+				UpdateWindow();
+
+				// log commands
+				if (m_ChkLogtofile.GetCheck())
+				{
+					if (0 != logFile.GetLength())
+						Evaluate((*pfn_SetCommandLogging)(h, logFile, NULL, EVerbose, true), h);
+				}
+
+				// set command delay
+				if (!bErrors)
+				{
+					m_Delay.GetWindowText(szBuffer, sizeof(szBuffer));
+					iValue = atoi(szBuffer);
+					Evaluate((*pfn_SetCommandDelay)(h, iValue), h);
+				}
+
+				// set image verification
+				if (!bErrors)
+				{
+					if (m_CheckVerification.GetCheck())
+					{
+						m_Fudge.GetWindowText(szBuffer, sizeof(szBuffer));
+						iValue = atoi(szBuffer);
+						m_RefDir.GetWindowText(szBuffer, sizeof(szBuffer));
+						if (*szBuffer)
+							Evaluate((*pfn_SetImageVerification)(h, szBuffer, m_RemoveImages.GetCheck()?true:false, iValue), h);
+					}
+				}
+
+				m_Iterations.GetWindowText(szPrevious, sizeof(szPrevious));
+				int iMax = atoi(szPrevious);
+				for (int i=0;i<iMax;i++)
+				{
+					if (!bErrors)
+					{
+						// execute raw command
+						if (m_CheckRawCmd.GetCheck())
+						{
+							m_RawCmd.GetWindowText(szBuffer, sizeof(szBuffer));
+							if (*szBuffer)
+							{
+								Evaluate((*pfn_SendRawCommand)(h, szBuffer), h);
+								m_Progress.StepIt();
+								UpdateWindow();
+							}
+						}
+					}
+
+					if (!bErrors)
+					{
+						// execute command file
+						if (m_CheckCmdFile.GetCheck())
+						{
+							m_CmdFile.GetWindowText(szBuffer, sizeof(szBuffer));
+							if (*szBuffer)
+							{
+								Evaluate((*pfn_SendCommandFile)(h, szBuffer), h);
+								m_Progress.StepIt();
+								UpdateWindow();
+							}
+						}
+					}
+
+					if (!bErrors)
+					{
+						// get a snapshot
+						if (m_CheckSnapshot.GetCheck())
+						{
+							m_Snapshot.GetWindowText(szBuffer, sizeof(szBuffer));
+							if (*szBuffer)
+							{
+								DeleteFile(szBuffer);
+								Evaluate((*pfn_GetSnapshot)(h, &pFile, &pInfo, &pData, &lSize), h);
+
+								if (!bErrors)
+									if (!WriteBitmap(szBuffer, pFile, pInfo, pData, lSize))
+										bErrors = true;
+
+								m_Progress.StepIt();
+								UpdateWindow();
+							}
+						}
+					}
+
+					// decrement the iteration count
+					itoa(iMax - i - 1, szRemaining, 10);
+					m_Iterations.SetWindowText(szRemaining);
+					UpdateWindow();
+				}
+
+				// disconnect
+				Evaluate((*pfn_Disconnect)(h), h); // start of list
+				m_Progress.SetPos(100);
+				m_Iterations.SetWindowText(szPrevious);
+			}
+
+			// close logging
+			if (m_ChkLogtofile.GetCheck())
+				if (pfn_CloseConnectionLogging)	// doesn't exist in 3.2
+					(*pfn_CloseConnectionLogging)();
+		}
+		else
+			MessageBox("STAT.DLL could not be loaded successfully", NULL, MB_OK|MB_ICONERROR);
+
+		// finished
+		if (inst)
+			FreeLibrary(inst);
+	}
+
+	if (m_ChkLogtofile.GetCheck() && (0 != logFile.GetLength()))
+	{
+		if ((bErrors && (IDYES == AfxMessageBox("Do you wish to view the log file?", MB_YESNO | MB_ICONINFORMATION | MB_DEFBUTTON1))) ||
+			(!bErrors && (IDYES == AfxMessageBox("All tests completed successfully.  Do you wish to view the log file?", MB_YESNO | MB_ICONINFORMATION | MB_DEFBUTTON2))))
+		{
+			CString logFileDirectory;
+			GetLogFolder(logFileDirectory);
+			::ShellExecute(GetSafeHwnd(), NULL, logFile, NULL, 
+				logFileDirectory, SW_SHOW);
+		}
+	}
+	else
+	{
+		if (!bErrors)
+			AfxMessageBox("All tests completed successfully.", MB_OK | MB_ICONINFORMATION);
+	}
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+int CDlltestDlg::GetIncrement()
+{
+	int increment = 0;
+
+	if (m_CheckRawCmd.GetCheck())
+		increment++;
+
+	if (m_CheckCmdFile.GetCheck())
+		increment++;
+
+	if (m_CheckSnapshot.GetCheck())
+		increment++;
+
+	m_Iterations.GetWindowText(szBuffer, sizeof(szBuffer));
+	int iMax = atoi(szBuffer);
+	if (iMax)
+		increment *= iMax;
+
+	// for Connect()/Disconnect()
+	increment++;
+
+	return (int) 100 / increment;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+void CDlltestDlg::LoadEntrypoint(HINSTANCE inst, FARPROC *fn, const char *name)
+{
+	if (!*fn)
+		*fn = GetProcAddress(inst, name);
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+bool CDlltestDlg::LoadFunctionEntrypoints(HINSTANCE inst)
+{
+	// get
+	LoadEntrypoint(inst, (FARPROC *)&pfn_Version, "Version");
+	LoadEntrypoint(inst, (FARPROC *)&pfn_GetError, "GetError");
+	LoadEntrypoint(inst, (FARPROC *)&pfn_SetConnectionLogging, "SetConnectionLogging");
+	LoadEntrypoint(inst, (FARPROC *)&pfn_CloseConnectionLogging, "CloseConnectionLogging");
+	LoadEntrypoint(inst, (FARPROC *)&pfn_Connect, "Connect");
+	LoadEntrypoint(inst, (FARPROC *)&pfn_Disconnect, "Disconnect");
+	LoadEntrypoint(inst, (FARPROC *)&pfn_SetCommandDelay, "SetCommandDelay");
+	LoadEntrypoint(inst, (FARPROC *)&pfn_SetCommandLogging, "SetCommandLogging");
+	LoadEntrypoint(inst, (FARPROC *)&pfn_SetImageVerification, "SetImageVerification");
+	LoadEntrypoint(inst, (FARPROC *)&pfn_SendRawCommand, "SendRawCommand");
+	LoadEntrypoint(inst, (FARPROC *)&pfn_SendCommandFile, "SendCommandFile");
+	LoadEntrypoint(inst, (FARPROC *)&pfn_GetSnapshot, "GetSnapshot");
+
+
+	// check
+	if (pfn_Version && pfn_GetError && pfn_SetConnectionLogging && pfn_Connect && pfn_Disconnect &&
+		pfn_SetCommandDelay && pfn_SetCommandLogging && pfn_GetSnapshot && pfn_CloseConnectionLogging &&
+		pfn_SetImageVerification && pfn_SendRawCommand && pfn_SendCommandFile )
+	{
+		return true;
+	}
+
+	MessageBox("Not all required STAT entrypoints could be located.  This application is compatible with STAT DLL 3.3 (September 2002) and later.", NULL, MB_OK|MB_ICONERROR);
+	return false;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+void CDlltestDlg::Evaluate(int ret, int handle)
+{
+	if (!ret)
+	{
+		if (m_Link.GetCurSel() == 1)
+			strcpy(szBuffer, GetError(handle));
+		else
+			strcpy(szBuffer, pfn_GetError(handle));
+
+		bErrors = true;
+		MessageBox(szBuffer, NULL, MB_OK|MB_ICONERROR);
+	}
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+bool CDlltestDlg::WriteBitmap(char *file, TBitmapFileHeader *fileheader, TBitmapInfoHeader * bmpHeader, char *bmpBits, unsigned long lSize)
+{
+	bool success = false;
+
+	// write the whole lot out to file
+	HANDLE infile;
+	if (INVALID_HANDLE_VALUE != (infile = CreateFile(file,
+										   GENERIC_WRITE,
+										   0, 
+										   NULL, 
+										   CREATE_ALWAYS,
+										   FILE_ATTRIBUTE_NORMAL,
+										   0)))
+	{
+		DWORD dwBytesWritten = 0;
+
+		// write the file info
+		if (WriteFile(infile, (LPVOID *)fileheader, sizeof(TBitmapFileHeader), &dwBytesWritten, NULL) &&
+			dwBytesWritten == sizeof(TBitmapFileHeader))
+		{
+			// write the bitmap info
+			if (WriteFile(infile, (LPVOID *)bmpHeader, sizeof(TBitmapInfoHeader), &dwBytesWritten, NULL) &&
+				dwBytesWritten == sizeof(TBitmapInfoHeader))
+			{
+				// write the bitmap data
+				if (WriteFile(infile, (LPVOID *)bmpBits, lSize, &dwBytesWritten, NULL) &&
+					dwBytesWritten == lSize)
+				{
+					success = true;
+				}
+			}
+		}
+
+		CloseHandle(infile);
+	}
+
+	return success;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+void CDlltestDlg::OnChangeConnection() 
+{
+	ChangeConnection(0);
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+void CDlltestDlg::ChangeConnection(int iSelection) 
+{
+	switch(m_Connection.GetCurSel())
+	{
+	case 0:	// socket
+		m_Address.EnableWindow();
+		m_Platform.EnableWindow(FALSE);
+		break;
+	
+	case 1:	// serial
+	case 2:	// infra-red
+	case 3:	// bluetooth
+	case 4:	// USB
+		m_Platform.ResetContent();
+		m_Platform.AddString("COM1");
+		m_Platform.AddString("COM2");
+		m_Platform.AddString("COM3");
+		m_Platform.AddString("COM4");
+		m_Platform.AddString("COM5");
+		m_Platform.AddString("COM6");
+		m_Platform.AddString("COM7");
+		m_Platform.SetCurSel(iSelection);
+		m_Platform.EnableWindow(TRUE);
+		m_Address.EnableWindow(FALSE);
+		break;
+	}
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+void CDlltestDlg::SaveSettings()
+{
+	(*szBuffer) = (char)0;
+	m_Iterations.GetWindowText(szBuffer, sizeof(szBuffer));
+	statIniFile.WriteKey(szBuffer,ST_ITERATIONS,ST_TEST_KEY);
+
+	(*szBuffer) = (char)0;
+	m_Delay.GetWindowText(szBuffer, sizeof(szBuffer));
+	statIniFile.WriteKey(szBuffer,ST_DELAY,ST_TEST_KEY);
+
+	(*szBuffer) = (char)0;
+	m_LogFile.GetWindowText(szBuffer, sizeof(szBuffer));
+	statIniFile.WriteKey(szBuffer,ST_LOGFILE,ST_TEST_KEY);
+
+	(*szBuffer) = (char)0;
+	m_CmdFile.GetWindowText(szBuffer, sizeof(szBuffer));
+	statIniFile.WriteKey(szBuffer,ST_CMDFILE,ST_TEST_KEY);
+
+	(*szBuffer) = (char)0;
+	m_RawCmd.GetWindowText(szBuffer, sizeof(szBuffer));
+	statIniFile.WriteKey(szBuffer,ST_RAWCMD,ST_TEST_KEY);
+
+	(*szBuffer) = (char)0;
+	m_Fudge.GetWindowText(szBuffer, sizeof(szBuffer));
+	statIniFile.WriteKey(szBuffer,ST_FUDGE,ST_TEST_KEY);
+
+	(*szBuffer) = (char)0;
+	m_Snapshot.GetWindowText(szBuffer, sizeof(szBuffer));
+	statIniFile.WriteKey(szBuffer,ST_SNAPSHOT,ST_TEST_KEY);
+
+
+	(*szBuffer) = (char)0;
+	m_RefDir.GetWindowText(szBuffer, sizeof(szBuffer));
+	statIniFile.WriteKey(szBuffer,ST_REFDIR,ST_TEST_KEY);
+
+	(*szBuffer) = (char)0;
+	m_Address.GetWindowText(szBuffer, sizeof(szBuffer));
+	statIniFile.WriteKey(szBuffer,ST_ADDRESS,ST_TEST_KEY);
+
+	_ltot( m_Link.GetCurSel(), szBuffer, 10);
+	statIniFile.WriteKey(szBuffer,ST_LINK,ST_TEST_KEY);
+
+	_ltot( m_Connection.GetCurSel(), szBuffer, 10);
+	statIniFile.WriteKey(szBuffer,ST_CONNECTIONDLL,ST_TEST_KEY);
+
+	_ltot( m_Platform.GetCurSel(), szBuffer, 10);
+	statIniFile.WriteKey(szBuffer,ST_PLATFORM,ST_TEST_KEY);
+
+	_ltot( m_CheckRawCmd.GetCheck(), szBuffer, 10);
+	statIniFile.WriteKey(szBuffer,ST_CHKRAWCMD,ST_TEST_KEY);
+
+	_ltot( m_CheckCmdFile.GetCheck(), szBuffer, 10);
+	statIniFile.WriteKey(szBuffer,ST_CHKCMDFILE,ST_TEST_KEY);
+
+	_ltot( m_CheckVerification.GetCheck(), szBuffer, 10);
+	statIniFile.WriteKey(szBuffer,ST_CHKVERIF,ST_TEST_KEY);
+
+	_ltot( m_RemoveImages.GetCheck(), szBuffer, 10);
+	statIniFile.WriteKey(szBuffer,ST_VERIFYREMOVEIMAGES,ST_TEST_KEY);
+
+	_ltot( m_CheckSnapshot.GetCheck(), szBuffer, 10);
+	statIniFile.WriteKey(szBuffer,ST_CHKSNAP,ST_TEST_KEY);
+
+	_ltot( m_ChkLogtofile.GetCheck(), szBuffer, 10);
+	statIniFile.WriteKey(szBuffer,ST_CHKLOGTOFILE,ST_TEST_KEY);
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+void CDlltestDlg::ReadSettings()
+{
+	long lCount = 0;
+	statIniFile.SetIniFileName(STAT_INI_NAME);
+	*(szBuffer) = (char)0;
+	if(statIniFile.SectionExists(ST_TEST_KEY) )
+	{
+		CString setting;
+		setting.Empty();
+		setting=statIniFile.GetKeyValue(ST_ITERATIONS,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			if (_ttoi(setting)<1)
+				setting=_T("1");
+
+			m_Iterations.SetWindowText(setting);
+		}
+
+
+		setting=statIniFile.GetKeyValue(ST_DELAY,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			int iPos = _ttoi(setting);
+			if (iPos < 100)
+				setting= _T("100");
+
+			if (iPos > 30000)
+				setting= _T("30000");
+
+			m_Delay.SetWindowText(setting);
+		}
+
+	// logging settings
+		setting.Empty();
+		setting=statIniFile.GetKeyValue(ST_LOGFILE,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			m_LogFile.SetWindowText(setting);
+		}
+
+		setting.Empty();
+		lCount=0;
+		setting=statIniFile.GetKeyValue(ST_CHKLOGTOFILE,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			lCount = _ttoi(setting);
+			m_ChkLogtofile.SetCheck(lCount);
+		}
+
+
+
+	// command file settings
+		setting.Empty();
+		setting=statIniFile.GetKeyValue(ST_CMDFILE,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			m_CmdFile.SetWindowText(setting);
+		}
+
+		setting.Empty();
+		lCount=0;
+		setting=statIniFile.GetKeyValue(ST_CHKCMDFILE,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			lCount = _ttoi(setting);
+			m_CheckCmdFile.SetCheck(lCount);
+		}
+
+	// raw command settings
+		setting.Empty();
+		setting=statIniFile.GetKeyValue(ST_RAWCMD,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			m_RawCmd.SetWindowText(setting);
+		}
+		setting.Empty();
+		lCount=0;
+		setting=statIniFile.GetKeyValue(ST_CHKRAWCMD,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			lCount=_ttol(setting);
+			m_CheckRawCmd.SetCheck(lCount);
+		}
+
+
+	// snapshot settings
+		setting.Empty();
+		setting=statIniFile.GetKeyValue(ST_SNAPSHOT,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			m_Snapshot.SetWindowText(setting);
+		}
+		setting.Empty();
+		lCount=0;
+		setting=statIniFile.GetKeyValue(ST_CHKSNAP,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			lCount=_ttol(setting);
+			m_CheckSnapshot.SetCheck(lCount);
+		}
+
+
+	// image verification settings
+		setting.Empty();
+		setting=statIniFile.GetKeyValue(ST_FUDGE,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+			m_Fudge.SetWindowText(setting);
+
+		setting.Empty();
+		setting=statIniFile.GetKeyValue(ST_REFDIR,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+			m_RefDir.SetWindowText(setting);
+		setting.Empty();
+		lCount=0;
+		setting=statIniFile.GetKeyValue(ST_CHKVERIF,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			lCount=_ttol(setting);
+			m_CheckVerification.SetCheck(lCount);
+		}
+
+		setting.Empty();
+		setting=statIniFile.GetKeyValue(ST_VERIFYREMOVEIMAGES,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			m_RemoveImages.SetWindowText(setting);
+		}
+		setting.Empty();
+		lCount=0;
+		setting=statIniFile.GetKeyValue(ST_VERIFYREMOVEIMAGES,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			lCount=_ttol(setting);
+			m_RemoveImages.SetCheck(lCount);
+		}
+
+
+	// connection settings
+		setting.Empty();
+		lCount=0;
+		setting=statIniFile.GetKeyValue(ST_LINK,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			lCount=_ttol(setting);
+			m_Link.SetCurSel(lCount);
+		}
+		setting.Empty();
+		lCount=0;
+		setting=statIniFile.GetKeyValue(ST_CONNECTIONDLL,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			lCount=_ttol(setting);
+			m_Connection.SetCurSel(lCount);
+		}
+		setting.Empty();
+		lCount=0;
+		setting=statIniFile.GetKeyValue(ST_PLATFORM,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			lCount=_ttol(setting);
+			ChangeConnection(lCount);
+		}
+		else
+			ChangeConnection(0);
+		
+		setting.Empty();
+		setting=statIniFile.GetKeyValue(ST_ADDRESS,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			m_Address.SetWindowText(setting);
+		}
+	}
+	// enable/disable accordingly
+	OnCheckcmdfile();
+	OnCheckrawcmd();
+	OnChecksnapshot();
+	OnCheckverification();
+
+	bRunning = false;
+
+	UpdateWindow();
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+void CDlltestDlg::OnOK() 
+{
+	CWaitCursor oWait;
+	SaveSettings();
+	CDialog::OnOK();
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+void CDlltestDlg::OnResetsettings() 
+{
+
+	GetDlgItem(IDC_LOGFILE)->SetWindowText("statdllv4cdecltest.log");
+	m_ChkLogtofile.SetCheck(TRUE);
+	OnChklogtofile();
+
+	GetDlgItem(IDC_ADDRESS)->SetWindowText("");
+	GetDlgItem(IDC_DELAY)->SetWindowText("100");
+	GetDlgItem(IDC_ITERATIONS)->SetWindowText("1");
+	m_Link.SetCurSel(0);
+	m_Connection.SetCurSel(0);
+	ChangeConnection(0);
+
+	UpdateWindow();
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+void CDlltestDlg::OnResettests() 
+{
+	// set some default values
+
+	GetDlgItem(IDC_CMDFILE)->SetWindowText("statdllv4test.txt");
+
+	// tests
+	GetDlgItem(IDC_ITERATIONS)->SetWindowText("1");
+	GetDlgItem(IDC_RAWCMD)->SetWindowText("<B><S><E>");
+	GetDlgItem(IDC_REFDIR)->SetWindowText("refimages");
+	GetDlgItem(IDC_FUDGE)->SetWindowText("20");
+	GetDlgItem(IDC_SNAPSHOT)->SetWindowText("mysnapshot.bmp");
+
+	m_CheckCmdFile.SetCheck(TRUE);
+	m_CheckVerification.SetCheck(TRUE);
+	m_RemoveImages.SetCheck(TRUE);
+	m_CheckSnapshot.SetCheck(TRUE);
+	m_CheckRawCmd.SetCheck(TRUE);
+	OnCheckcmdfile();
+	OnCheckrawcmd();
+	OnChecksnapshot();
+	OnCheckverification();
+
+	UpdateWindow();
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+void CDlltestDlg::OnBrowselog() 
+{
+	// use the folder of the current script as a starting point
+	m_LogFile.GetWindowText(szBuffer, sizeof(szBuffer));
+	CString buf = szBuffer;
+	if (!buf.IsEmpty())
+	{
+		int index = buf.ReverseFind('\\');
+		if (index != -1)
+		{
+			CString folder = buf.Left(index);
+			SetCurrentDirectory(folder.GetBuffer(0));
+		}
+	}
+
+	CFileDialog dlgStatFileOpen(TRUE, 
+								NULL, 
+								NULL, 
+								OFN_PATHMUSTEXIST, 
+								_T("Log Files (*.log)|*.log|All Files (*.*)|*.*||"));
+
+	// new script file to use
+	if (dlgStatFileOpen.DoModal() == IDOK)	//when ok is pressed
+		m_LogFile.SetWindowText(dlgStatFileOpen.GetPathName());
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+void CDlltestDlg::OnChklogtofile() 
+{
+	if (m_ChkLogtofile.GetCheck())
+	{
+		m_LogFile.EnableWindow(TRUE);
+		m_BrowseLog.EnableWindow(TRUE);
+	}
+	else
+	{
+		m_LogFile.EnableWindow(FALSE);
+		m_BrowseLog.EnableWindow(FALSE);
+	}
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+void CDlltestDlg::OnCheckcmdfile() 
+{
+	if (m_CheckCmdFile.GetCheck())
+	{
+		m_CmdFile.EnableWindow(TRUE);
+		m_BrowseCmdFile.EnableWindow(TRUE);
+	}
+	else
+	{
+		m_CmdFile.EnableWindow(FALSE);
+		m_BrowseCmdFile.EnableWindow(FALSE);
+	}
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+void CDlltestDlg::OnCheckrawcmd() 
+{
+	if (m_CheckRawCmd.GetCheck())
+	{
+		m_RawCmd.EnableWindow(TRUE);
+	}
+	else
+	{
+		m_RawCmd.EnableWindow(FALSE);
+	}
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+void CDlltestDlg::OnChecksnapshot() 
+{
+	if (m_CheckSnapshot.GetCheck())
+	{
+		m_Snapshot.EnableWindow(TRUE);
+		m_BrowseSnapshot.EnableWindow(TRUE);
+	}
+	else
+	{
+		m_Snapshot.EnableWindow(FALSE);
+		m_BrowseSnapshot.EnableWindow(FALSE);
+	}
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+void CDlltestDlg::OnCheckverification() 
+{
+	if (m_CheckVerification.GetCheck())
+	{
+		m_RefDir.EnableWindow(TRUE);
+		m_Fudge.EnableWindow(TRUE);
+		m_BrowseRefImages.EnableWindow(TRUE);
+		m_RemoveImages.EnableWindow(TRUE);
+	}
+	else
+	{
+		m_RefDir.EnableWindow(FALSE);
+		m_Fudge.EnableWindow(FALSE);
+		m_BrowseRefImages.EnableWindow(FALSE);
+		m_RemoveImages.EnableWindow(FALSE);
+	}
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+void CDlltestDlg::OnBrowsecmdfile() 
+{
+	// use the folder of the current script as a starting point
+	m_CmdFile.GetWindowText(szBuffer, sizeof(szBuffer));
+	CString buf = szBuffer;
+	if (!buf.IsEmpty())
+	{
+		int index = buf.ReverseFind('\\');
+		if (index != -1)
+		{
+			CString folder = buf.Left(index);
+			SetCurrentDirectory(folder.GetBuffer(0));
+		}
+	}
+
+	CFileDialog dlgStatFileOpen(TRUE, 
+								NULL, 
+								NULL, 
+								OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST, 
+								_T("Script Files (*.txt)|*.txt|All Files (*.*)|*.*||"));
+
+	// new script file to use
+	if (dlgStatFileOpen.DoModal() == IDOK)	//when ok is pressed
+		m_CmdFile.SetWindowText(dlgStatFileOpen.GetPathName());
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+void CDlltestDlg::OnBrowsesnapshot() 
+{
+	// use the folder of the current script as a starting point
+	m_Snapshot.GetWindowText(szBuffer, sizeof(szBuffer));
+	CString buf = szBuffer;
+	if (!buf.IsEmpty())
+	{
+		int index = buf.ReverseFind('\\');
+		if (index != -1)
+		{
+			CString folder = buf.Left(index);
+			SetCurrentDirectory(folder.GetBuffer(0));
+		}
+	}
+
+	CFileDialog dlgStatFileOpen(TRUE, 
+								NULL, 
+								NULL, 
+								OFN_PATHMUSTEXIST,
+								_T("Bitmap Files (*.bmp)|*.txt|All Files (*.*)|*.*||"));
+
+	// new script file to use
+	if (dlgStatFileOpen.DoModal() == IDOK)	//when ok is pressed
+		m_Snapshot.SetWindowText(dlgStatFileOpen.GetPathName());
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+void CDlltestDlg::OnBrowserefimages() 
+{
+	TCHAR chName[MAX_PATH];
+
+	BROWSEINFO bi = {0};
+	bi.hwndOwner = m_hWnd;
+	bi.lpszTitle = _T("Please select folder where the reference bitmap files are stored...");
+
+	LPITEMIDLIST lpIDList = ::SHBrowseForFolder(&bi); //now display dialog box 
+
+	::SHGetPathFromIDList(lpIDList, chName); //Converts an item identifier list to a file system path
+
+	m_RefDir.SetWindowText(chName);	//pastes location into edit box
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////
+// Set up image verification
+void CDlltestDlg::EnableFields(bool bEnable)
+{
+	GetDlgItem(IDC_LINK)->EnableWindow(bEnable);
+	GetDlgItem(IDC_DELAY)->EnableWindow(bEnable);
+//	GetDlgItem(IDC_ITERATIONS)->EnableWindow(bEnable);
+	GetDlgItem(IDC_RESETSETTINGS)->EnableWindow(bEnable);
+	GetDlgItem(IDC_CONNECTION)->EnableWindow(bEnable);
+	GetDlgItem(IDC_PLATFORM)->EnableWindow(bEnable);
+	GetDlgItem(IDC_ADDRESS)->EnableWindow(bEnable);
+	GetDlgItem(IDC_CHKLOGTOFILE)->EnableWindow(bEnable);
+	GetDlgItem(IDC_LOGFILE)->EnableWindow(bEnable);
+	GetDlgItem(IDC_BROWSELOG)->EnableWindow(bEnable);
+
+	GetDlgItem(IDC_CHECKRAWCMD)->EnableWindow(bEnable);
+	GetDlgItem(IDC_RAWCMD)->EnableWindow(bEnable);
+	GetDlgItem(IDC_CHECKCMDFILE)->EnableWindow(bEnable);
+	GetDlgItem(IDC_CMDFILE)->EnableWindow(bEnable);
+	GetDlgItem(IDC_BROWSECMDFILE)->EnableWindow(bEnable);
+	GetDlgItem(IDC_CHECKSNAPSHOT)->EnableWindow(bEnable);
+	GetDlgItem(IDC_SNAPSHOT)->EnableWindow(bEnable);
+	GetDlgItem(IDC_BROWSESNAPSHOT)->EnableWindow(bEnable);
+	GetDlgItem(IDC_CHECKVERIFICATION)->EnableWindow(bEnable);
+	GetDlgItem(IDC_OVERWRITE)->EnableWindow(bEnable);
+	GetDlgItem(IDC_REFDIR)->EnableWindow(bEnable);
+	GetDlgItem(IDC_BROWSEREFIMAGES)->EnableWindow(bEnable);
+	GetDlgItem(IDC_FUDGE)->EnableWindow(bEnable);
+	GetDlgItem(IDC_RESETTESTS)->EnableWindow(bEnable);
+
+	if (bEnable)
+	{
+		OnChklogtofile();
+		OnCheckcmdfile();
+		OnCheckrawcmd();
+		OnChecksnapshot();
+		OnCheckverification();
+
+		m_Run.SetWindowText(_T("Run"));
+		bRunning = false;
+	}
+	else
+	{
+		m_Run.SetWindowText(_T("Stop"));
+		bRunning = true;
+	}
+
+	UpdateWindow();
+}
+
+void CDlltestDlg::GetLogFolder(CString& logFileFolder) const
+{
+	// Get the log file folder location.
+	// If this is specified in the 'ini' file then we
+	// use the specified location.
+	// if it is not specified in the 'ini' file then we
+	// use a default value.
+
+	logFileFolder.Empty();
+
+	if(statIniFile.SectionExists(ST_TEST_KEY))
+	{
+		CString setting;
+		setting.Empty();
+		setting=statIniFile.GetKeyValue(ST_LOGFILEPATH,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+			logFileFolder = setting;
+	}
+
+	if(logFileFolder.IsEmpty())
+	{
+		logFileFolder = STAT_LOGFILEPATH_VALUE;
+	}
+}
+
+void CDlltestDlg::GetLogFilePath(const char* logFileName, CString& logFilePath) const
+{
+	// There are a mixture of method calls in this window
+	// that specify logging.
+	// Also, in this window we allow the user to specify a file
+	// name or a full path in the interface.
+	// Because of this we have a mix of specifying log file details
+	// with or without a full path.
+	// This function will create a full path for the log file from the
+	// name passed.  If the name passed already has a folder
+	// specified (at least on '\' characters) then we copy
+	// that to the out parameter.
+	// If the name passed does not have a folder specification
+	// within it then we prepend the log file folder.
+
+	static const char folder = '\\';
+
+	if(NULL != ::strchr(logFileName, folder))
+	{
+		logFilePath = logFileName;
+	}
+	else
+	{
+		GetLogFolder(logFilePath);
+		logFilePath += "\\";
+		logFilePath += logFileName;
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltester/src/stdafx.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// stdafx.cpp : source file that includes just the standard includes
+//	dlltest.pch will be the pre-compiled header
+//	stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltester/src/utils.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,519 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// CUtils.cpp : Handy bits and pieces for apps
+//
+
+#include "stdafx.h"
+#include <windows.h>
+#include <tchar.h>
+#include "Utils.h"
+
+CUtils::CUtils()
+: m_hMutex((HANDLE)0)
+{
+    // open the Service Control Manager
+    hSCM = OpenSCManager(NULL,						// local machine
+                         NULL,						// ServicesActive database
+                         SC_MANAGER_ALL_ACCESS);	// full access
+}
+
+CUtils::~CUtils()
+{
+    if (hSCM)
+	    CloseServiceHandle(hSCM);
+
+	if (m_hMutex)
+		CloseHandle(m_hMutex);
+}
+
+
+// attempts to create a mutex for this process.
+// if it fails, another process of the same name is already running
+bool CUtils::AlreadyRunning(LPCTSTR szAppName)
+{
+	m_hMutex = CreateMutex(NULL, FALSE, szAppName);
+	if ((!m_hMutex) || (WaitForSingleObject( m_hMutex, 0 ) == WAIT_TIMEOUT))
+    {
+		return true;   
+    }
+
+	return false;
+}
+
+
+// invokes an application then waits for it to exit
+bool CUtils::CallProcessAndWait(LPCTSTR szApplication, LPTSTR szCommandLine, LPCTSTR szDirectory, bool bRunMinimised)
+{
+	bool valid = false;
+	STARTUPINFO startInfo = {0};
+	startInfo.cb = sizeof(STARTUPINFO);
+	retCode = -1;
+
+	// run window minimised and not active
+	if (bRunMinimised)
+	{
+		startInfo.dwFlags = STARTF_USESHOWWINDOW;
+		startInfo.wShowWindow = SW_SHOWMINIMIZED | SW_SHOWMINNOACTIVE;
+	}
+
+	PROCESS_INFORMATION procInfo = {0};
+
+	// event attributes for the child process
+	SECURITY_ATTRIBUTES eventAttr;
+	eventAttr.nLength = sizeof(eventAttr);
+	eventAttr.lpSecurityDescriptor = NULL;
+	eventAttr.bInheritHandle = TRUE;
+
+	// NOTE: if passing a command line, include the application name in szCommandLine and pass NULL for szApplication
+	if (CreateProcess(szApplication, szCommandLine, NULL, NULL, FALSE, NULL, NULL,
+					  szDirectory, &startInfo, &procInfo))
+	{
+		if (WAIT_OBJECT_0 == WaitForSingleObject(procInfo.hProcess, INFINITE))
+		{
+			GetExitCodeProcess(procInfo.hProcess, &retCode);
+			CloseHandle(procInfo.hThread);
+			CloseHandle(procInfo.hProcess);
+			valid = true;
+		}
+	}
+	else
+		_GetWindowsError();
+
+	return valid;
+}
+
+
+bool CUtils::CallProcess(LPCTSTR szApplication, LPTSTR szCommandLine, LPCTSTR szDirectory)
+{
+	bool valid = false;
+	STARTUPINFO startInfo = {0};
+	startInfo.cb = sizeof(STARTUPINFO);
+
+	PROCESS_INFORMATION procInfo = {0};
+
+	// event attributes for the child process
+	SECURITY_ATTRIBUTES eventAttr;
+	eventAttr.nLength = sizeof(eventAttr);
+	eventAttr.lpSecurityDescriptor = NULL;
+	eventAttr.bInheritHandle = TRUE;
+
+	if (CreateProcess(szApplication, szCommandLine, NULL, NULL, FALSE, NULL, NULL,
+					  szDirectory, &startInfo, &procInfo))
+	{
+		CloseHandle(procInfo.hThread);
+		CloseHandle(procInfo.hProcess);
+		valid = true;
+	}
+	else
+		_GetWindowsError();
+
+	return valid;
+}
+
+// requests an NT service to perform a particular request
+bool CUtils::ServiceRequest(const char *szServiceName, const unsigned int iRequest)
+{
+	bool valid = false;
+
+    if (hSCM)
+	{
+		switch(iRequest)
+		{
+		case REQ_START:
+			if (Validate(hSCM, szServiceName, SERVICE_INACTIVE))
+			{
+				SC_HANDLE hService = OpenService(hSCM, szServiceName, SERVICE_ALL_ACCESS);
+				if (hService) 
+				{
+					DealWithDependentServices(szServiceName, iRequest);
+
+					if (StartService(hService, 0, NULL))
+						valid = true;
+
+					CloseServiceHandle(hService);
+				}
+				else
+					_GetWindowsError();
+			}
+			else
+			{
+				valid = true;	// already started
+			}
+			break;
+		case REQ_STOP:
+			if (Validate(hSCM, szServiceName, SERVICE_ACTIVE))
+			{
+				SC_HANDLE hService = OpenService(hSCM, szServiceName, SERVICE_STOP);
+				if (hService) 
+				{
+					DealWithDependentServices(szServiceName, iRequest);
+
+					SERVICE_STATUS status;
+					if (ControlService(hService, SERVICE_CONTROL_STOP, &status))
+						valid = true;
+
+					CloseServiceHandle(hService);
+				}
+				else
+					_GetWindowsError();
+			}
+			else
+			{
+				valid = true;	// already stopped
+			}
+			break;
+		default:
+			break;
+		};
+
+    }
+	return valid;
+}
+
+
+
+// recurses through a directory structure, performing an action on the files/directories within
+unsigned int CUtils::RecurseDir(const char *szDirectory, const unsigned int iCommand)
+{
+	iFileCommand = iCommand;
+	iFileCount = 0;
+
+	Recurse(szDirectory);
+
+	return iFileCount;
+}
+
+
+// adds a backslash to a path if it doesn't already have one
+void CUtils::AddSlash(char *szPath)
+{
+	if (*(szPath + strlen(szPath) - 1) != '\\')
+		strcat(szPath, "\\");
+}
+
+
+bool CUtils::ListServices(DWORD dwState)
+{
+	return Validate(hSCM, NULL, dwState, true);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Private Methods
+//
+////////////////////////////////////////////////////////////////////////////////////////////////
+
+bool CUtils::Validate(SC_HANDLE hSCM, const char *szServiceName, DWORD dwState, bool bDisplayOnly)
+{
+	bool valid = false;
+	DWORD dwBytes = 0;
+	DWORD dwNumServices = 0;
+	DWORD dwResumeHandle = 0;
+	static ENUM_SERVICE_STATUS status[200];
+
+	// get list of services in particular state
+	if (EnumServicesStatus(hSCM,							// handle
+						 SERVICE_WIN32,						// service
+						 dwState,							// state
+						 (ENUM_SERVICE_STATUS *)status,		// returned info
+						 200 * sizeof(ENUM_SERVICE_STATUS),	// length of buffer
+						 &dwBytes,							// returned length
+						 &dwNumServices,					// number services returned
+						 &dwResumeHandle))					// point to continue
+	{
+		if (bDisplayOnly)
+		{
+			printf("\n\nServices\n========\n\n");
+		}
+
+		for (DWORD i=0;i<dwNumServices;i++)
+		{
+			if (bDisplayOnly)
+			{
+				if (status[i].ServiceStatus.dwCurrentState == SERVICE_RUNNING)
+					printf("STARTED  %s  (%s)\n", status[i].lpDisplayName, status[i].lpServiceName);
+				else if (status[i].ServiceStatus.dwCurrentState == SERVICE_STOPPED)
+					printf("STOPPED  %s  (%s)\n", status[i].lpDisplayName, status[i].lpServiceName);
+				else if (status[i].ServiceStatus.dwCurrentState == SERVICE_PAUSED)
+					printf("PAUSED   %s  (%s)\n", status[i].lpDisplayName, status[i].lpServiceName);
+				else
+					printf("PENDING  %s  (%s)\n", status[i].lpDisplayName, status[i].lpServiceName);
+			}
+			else
+			{
+				if (stricmp(status[i].lpServiceName, szServiceName) == 0)
+				{
+					valid = true;
+					break;
+				}
+			}
+		}
+	}
+
+	// check the driver list, just in case it's in there...
+	if (!valid)
+	{
+		if (EnumServicesStatus(hSCM,							// handle
+							 SERVICE_DRIVER,					// driver
+							 dwState,							// state
+							 (ENUM_SERVICE_STATUS *)status,		// returned info
+							 200 * sizeof(ENUM_SERVICE_STATUS),	// length of buffer
+							 &dwBytes,							// returned length
+							 &dwNumServices,					// number services returned
+							 &dwResumeHandle))					// point to continue
+		{
+			if (bDisplayOnly)
+			{
+				printf("\n\nDrivers\n=======\n\n");
+			}
+
+			for (DWORD i=0;i<dwNumServices;i++)
+			{
+				if (bDisplayOnly)
+				{
+					if (status[i].ServiceStatus.dwCurrentState == SERVICE_RUNNING)
+						printf("STARTED  %s  (%s)\n", status[i].lpDisplayName, status[i].lpServiceName);
+					else if (status[i].ServiceStatus.dwCurrentState == SERVICE_STOPPED)
+						printf("STOPPED  %s  (%s)\n", status[i].lpDisplayName, status[i].lpServiceName);
+					else if (status[i].ServiceStatus.dwCurrentState == SERVICE_PAUSED)
+						printf("PAUSED   %s  (%s)\n", status[i].lpDisplayName, status[i].lpServiceName);
+					else
+						printf("PENDING  %s  (%s)\n", status[i].lpDisplayName, status[i].lpServiceName);
+				}
+				else
+				{
+					if (stricmp(status[i].lpServiceName, szServiceName) == 0)
+					{
+						valid = true;
+						break;
+					}
+				}
+			}
+		}
+	}
+
+	return valid;
+}
+
+
+void
+CUtils::Recurse(const char * rootDir)
+{
+    char fullname[MAX_PATH + 1];
+	HANDLE hFind;
+	
+	sprintf( fullname, "%s\\*", rootDir );
+	hFind = FindFirstFile(fullname, &ffd);
+
+	if(hFind != INVALID_HANDLE_VALUE)
+	{
+		do
+		{
+	        sprintf( fullname, "%s\\%s", rootDir, ffd.cFileName );
+
+			// directory so recurse into it
+			if(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+			{
+				// ignore current and previous dirs
+				if ((stricmp (ffd.cFileName, ".") != 0) && (strcmp (ffd.cFileName, "..") != 0))
+				{
+					Recurse(fullname);
+
+					// remove it
+					if (iFileCommand == DELETEALL)
+						if (RemoveDirectory(fullname))
+							iFileCount++;
+				}
+			}
+			else
+			{ 
+				// remove now empty directory
+				if (iFileCommand == DELETEALL || iFileCommand == DELETEFILESONLY)
+					if (DeleteFile( fullname ))
+						iFileCount++;
+
+				// clear the attributes
+				if (iFileCommand == REMOVEALLATTRIBUTES)
+					if (SetFileAttributes(fullname, FILE_ATTRIBUTE_NORMAL))
+						iFileCount++;
+			}
+		}
+		while(FindNextFile(hFind, &ffd));
+
+		FindClose( hFind );
+	}
+
+	// remove this root now we are finished with it
+	if (iFileCommand == DELETEALL)
+		if (RemoveDirectory(rootDir))
+			iFileCount++;
+}
+
+
+void
+CUtils::DealWithDependentServices(const char *szServiceName, const unsigned int iRequest)
+{
+	DWORD dwBytes = 0;
+	DWORD dwNumServices = 0;
+	DWORD dwResumeHandle = 0;
+	ENUM_SERVICE_STATUS status[100];
+
+	// service may have dependent services so stop them first
+	SC_HANDLE hService = OpenService(hSCM, szServiceName, SERVICE_ENUMERATE_DEPENDENTS);
+	if (hService) 
+	{
+		if (EnumDependentServices(hService, 
+								SERVICE_ACTIVE,
+								(ENUM_SERVICE_STATUS *)status,		// returned info
+								100 * sizeof(ENUM_SERVICE_STATUS),	// length of buffer
+								&dwBytes,							// returned length
+								&dwNumServices))					// number services returned
+		{
+			for (DWORD i=0;i<dwNumServices;i++)
+			{
+				// recurse until we stop the last dependant
+				ServiceRequest(status[i].lpServiceName, iRequest);
+			}
+		}
+
+		CloseServiceHandle(hService);
+
+		// if there were dependents, allow some time register service stops
+		if (dwNumServices)
+			Sleep(2000);
+	}
+	else
+		_GetWindowsError();
+}
+
+void
+CUtils::_GetWindowsError()
+{
+	LPVOID lpSysError;
+	DWORD dwRet = GetLastError();
+
+	FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
+				   NULL,
+				   dwRet,
+				   MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+				   ( LPTSTR ) &lpSysError,
+				   0,
+				   NULL );
+
+	if (lpSysError)
+		_tcscpy(szError, ( LPTSTR )lpSysError);
+
+	LocalFree( lpSysError );
+}
+
+LPTSTR
+CUtils::GetWindowsError()
+{
+	return szError;
+}
+
+LPTSTR
+CUtils::GetWindowsErrorNow()
+{
+	_GetWindowsError();
+	return szError;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////
+// Trim the text of unwanted characters
+//
+void
+CUtils::TrimTabsCRAndWhitespace(char *szBuffer)
+{
+	// strip any unwanted chars off the end of each value
+	char *ptr = szBuffer + strlen(szBuffer) - 1;
+	if (ptr && (*ptr))
+	{
+		while ((*ptr) == '\r' || (*ptr) == '\n' || (*ptr) == '\t' || (*ptr) == ' ')
+			ptr--;
+
+		*(ptr + 1) = (char)0;
+	}
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////
+// Trim the buffered text to the first EOL and adjust the file pointer to suit
+// If EOL's included, include all up to the next occurance of text or EOF
+//
+int
+CUtils::TrimBufferToFirstEOL(HANDLE mmphndl, char *szBuffer, bool bIncludeCR)
+{
+	int count = 0;
+	int length = strlen(szBuffer);
+	int actualend = 0;
+
+	// move to first CR
+	while (*(szBuffer + count) && (*(szBuffer + count) != '\r') && (*(szBuffer + count) != '\n'))
+		count++;
+
+
+	// move to after CRs
+	actualend = count;
+	while ((*(szBuffer + actualend) == '\r') || (*(szBuffer + actualend) == '\n'))
+		actualend++;
+
+	if (count)
+	{
+		// include the CRs
+		if (bIncludeCR)
+			count = actualend;
+
+		// terminate the string at our desired point
+		*(szBuffer + count) = (char)0;
+
+		// set file pointer accordingly
+		if (mmphndl)
+			SetFilePointer(mmphndl, 0 - (length - actualend), NULL, FILE_CURRENT);
+	}
+
+	return count;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////
+// Trim the buffered text to the last EOL and adjust the file pointer to suit
+//
+void
+CUtils::TrimBufferToLastEOL(HANDLE mmphndl, char *szBuffer)
+{
+	// move back to last CR
+	char *end = szBuffer + strlen(szBuffer) - 1;
+	while ((end != szBuffer) && (*end != '\r') && (*end != '\n'))
+		end--;
+
+	// NULL-terminate line and adjust file pointer
+	if (end != (szBuffer + strlen(szBuffer) - 1))
+	{
+		int diff = (szBuffer + strlen(szBuffer) - 1) - end;
+		(*end) = (char)0;
+
+		// back up the file pointer to the end of the last line
+		if (mmphndl)
+			SetFilePointer(mmphndl, 0 - diff, NULL, FILE_CURRENT);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltestermt/dlltest_multithreaded.dep	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,26 @@
+# Microsoft Developer Studio Generated Dependency File, included by dlltest_multithreaded.mak
+
+.\src\dlltest_multithreaded.cpp : \
+	"..\..\source\lib\inc\INI.h"\
+	".\inc\dlltest_worker.h"\
+	".\inc\STATTask.h"\
+	".\inc\StdAfx.h"\
+	
+
+.\src\dlltest_worker.cpp : \
+	"..\..\source\lib\inc\INI.h"\
+	"..\..\source\lib\inc\statcommon.h"\
+	"..\..\source\lib\inc\statexp.h"\
+	".\inc\dlltest_worker.h"\
+	".\inc\STATTask.h"\
+	".\inc\StdAfx.h"\
+	
+
+.\src\STATTask.cpp : \
+	".\inc\STATTask.h"\
+	".\inc\StdAfx.h"\
+	
+
+.\src\StdAfx.cpp : \
+	".\inc\StdAfx.h"\
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltestermt/dlltest_multithreaded.dsp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,143 @@
+# Microsoft Developer Studio Project File - Name="dlltest_multithreaded" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=dlltest_multithreaded - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "dlltest_multithreaded.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "dlltest_multithreaded.mak" CFG="dlltest_multithreaded - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "dlltest_multithreaded - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "dlltest_multithreaded - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName "dlltest_multithreaded"
+# PROP Scc_LocalPath "."
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "dlltest_multithreaded - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I ".\inc" /I "..\..\source\lib\inc" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Fr /Yu"stdafx.h" /FD /c
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib advapi32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib advapi32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib advapi32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\lib\STATDll.lib ..\..\lib\STAT.lib /nologo /subsystem:console /pdb:none /machine:I386 /out:"Release\STATDllTestMT.exe" /OPT:NOREF
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Cmds=copy release\STATDllTestMT.exe \epoc32\tools\stat\STATDllTestMT.exe
+# End Special Build Tool
+
+!ELSEIF  "$(CFG)" == "dlltest_multithreaded - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /GX /Zi /Od /I ".\inc" /I "..\..\source\lib\inc" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /Yu"stdafx.h" /FD /GZ /c
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib advapi32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib advapi32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib advapi32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib advapi32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\lib\STATDlld.lib ..\..\lib\STATd.lib /nologo /subsystem:console /pdb:none /debug /machine:I386 /out:"Debug\STATDllTestMTd.exe"
+
+!ENDIF 
+
+# Begin Target
+
+# Name "dlltest_multithreaded - Win32 Release"
+# Name "dlltest_multithreaded - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\src\dlltest_multithreaded.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\dlltest_multithreaded.dep
+# End Source File
+# Begin Source File
+
+SOURCE=.\dlltest_multithreaded.mak
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\dlltest_worker.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\STATTask.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\StdAfx.cpp
+# ADD CPP /Yc"stdafx.h"
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\inc\dlltest_worker.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\source\lib\inc\statcommon.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\source\lib\inc\statexp.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\STATTask.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inc\StdAfx.h
+# End Source File
+# End Group
+# End Target
+# End Project
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltestermt/dlltest_multithreaded.mak	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,242 @@
+# Microsoft Developer Studio Generated NMAKE File, Based on dlltest_multithreaded.dsp
+!IF "$(CFG)" == ""
+CFG=dlltest_multithreaded - Win32 Debug
+!MESSAGE No configuration specified. Defaulting to dlltest_multithreaded - Win32 Debug.
+!ENDIF 
+
+!IF "$(CFG)" != "dlltest_multithreaded - Win32 Release" && "$(CFG)" != "dlltest_multithreaded - Win32 Debug"
+!MESSAGE Invalid configuration "$(CFG)" specified.
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "dlltest_multithreaded.mak" CFG="dlltest_multithreaded - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "dlltest_multithreaded - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "dlltest_multithreaded - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE 
+!ERROR An invalid configuration is specified.
+!ENDIF 
+
+!IF "$(OS)" == "Windows_NT"
+NULL=
+!ELSE 
+NULL=nul
+!ENDIF 
+
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "dlltest_multithreaded - Win32 Release"
+
+OUTDIR=.\Release
+INTDIR=.\Release
+# Begin Custom Macros
+OutDir=.\Release
+# End Custom Macros
+
+ALL : "$(OUTDIR)\STATDllTestMT.exe" "$(OUTDIR)\dlltest_multithreaded.bsc"
+
+
+CLEAN :
+	-@erase "$(INTDIR)\dlltest_multithreaded.obj"
+	-@erase "$(INTDIR)\dlltest_multithreaded.pch"
+	-@erase "$(INTDIR)\dlltest_multithreaded.sbr"
+	-@erase "$(INTDIR)\dlltest_worker.obj"
+	-@erase "$(INTDIR)\dlltest_worker.sbr"
+	-@erase "$(INTDIR)\STATTask.obj"
+	-@erase "$(INTDIR)\STATTask.sbr"
+	-@erase "$(INTDIR)\StdAfx.obj"
+	-@erase "$(INTDIR)\StdAfx.sbr"
+	-@erase "$(INTDIR)\vc60.idb"
+	-@erase "$(OUTDIR)\dlltest_multithreaded.bsc"
+	-@erase "$(OUTDIR)\STATDllTestMT.exe"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MT /W3 /GX /O2 /I ".\inc" /I "..\..\source\lib\inc" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Fr"$(INTDIR)\\" /Fp"$(INTDIR)\dlltest_multithreaded.pch" /Yu"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\dlltest_multithreaded.bsc" 
+BSC32_SBRS= \
+	"$(INTDIR)\dlltest_multithreaded.sbr" \
+	"$(INTDIR)\dlltest_worker.sbr" \
+	"$(INTDIR)\STATTask.sbr" \
+	"$(INTDIR)\StdAfx.sbr"
+
+"$(OUTDIR)\dlltest_multithreaded.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+    $(BSC32) @<<
+  $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib advapi32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib advapi32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\lib\STATDll.lib ..\..\lib\STAT.lib /nologo /subsystem:console /pdb:none /machine:I386 /out:"$(OUTDIR)\STATDllTestMT.exe" /OPT:NOREF 
+LINK32_OBJS= \
+	"$(INTDIR)\dlltest_multithreaded.obj" \
+	"$(INTDIR)\dlltest_worker.obj" \
+	"$(INTDIR)\STATTask.obj" \
+	"$(INTDIR)\StdAfx.obj"
+
+"$(OUTDIR)\STATDllTestMT.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+    $(LINK32) @<<
+  $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+SOURCE="$(InputPath)"
+DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep
+
+ALL : $(DS_POSTBUILD_DEP)
+
+# Begin Custom Macros
+OutDir=.\Release
+# End Custom Macros
+
+$(DS_POSTBUILD_DEP) : "$(OUTDIR)\STATDllTestMT.exe" "$(OUTDIR)\dlltest_multithreaded.bsc"
+   copy release\STATDllTestMT.exe \epoc32\tools\stat\STATDllTestMT.exe
+	echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)"
+
+!ELSEIF  "$(CFG)" == "dlltest_multithreaded - Win32 Debug"
+
+OUTDIR=.\Debug
+INTDIR=.\Debug
+# Begin Custom Macros
+OutDir=.\Debug
+# End Custom Macros
+
+ALL : "$(OUTDIR)\STATDllTestMTd.exe" "$(OUTDIR)\dlltest_multithreaded.bsc"
+
+
+CLEAN :
+	-@erase "$(INTDIR)\dlltest_multithreaded.obj"
+	-@erase "$(INTDIR)\dlltest_multithreaded.pch"
+	-@erase "$(INTDIR)\dlltest_multithreaded.sbr"
+	-@erase "$(INTDIR)\dlltest_worker.obj"
+	-@erase "$(INTDIR)\dlltest_worker.sbr"
+	-@erase "$(INTDIR)\STATTask.obj"
+	-@erase "$(INTDIR)\STATTask.sbr"
+	-@erase "$(INTDIR)\StdAfx.obj"
+	-@erase "$(INTDIR)\StdAfx.sbr"
+	-@erase "$(INTDIR)\vc60.idb"
+	-@erase "$(INTDIR)\vc60.pdb"
+	-@erase "$(OUTDIR)\dlltest_multithreaded.bsc"
+	-@erase "$(OUTDIR)\STATDllTestMTd.exe"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MTd /W3 /GX /Zi /Od /I ".\inc" /I "..\..\source\lib\inc" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\dlltest_multithreaded.pch" /Yu"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c 
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\dlltest_multithreaded.bsc" 
+BSC32_SBRS= \
+	"$(INTDIR)\dlltest_multithreaded.sbr" \
+	"$(INTDIR)\dlltest_worker.sbr" \
+	"$(INTDIR)\STATTask.sbr" \
+	"$(INTDIR)\StdAfx.sbr"
+
+"$(OUTDIR)\dlltest_multithreaded.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+    $(BSC32) @<<
+  $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib advapi32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib advapi32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\lib\STATDlld.lib ..\..\lib\STATd.lib /nologo /subsystem:console /pdb:none /debug /machine:I386 /out:"$(OUTDIR)\STATDllTestMTd.exe" 
+LINK32_OBJS= \
+	"$(INTDIR)\dlltest_multithreaded.obj" \
+	"$(INTDIR)\dlltest_worker.obj" \
+	"$(INTDIR)\STATTask.obj" \
+	"$(INTDIR)\StdAfx.obj"
+
+"$(OUTDIR)\STATDllTestMTd.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+    $(LINK32) @<<
+  $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ENDIF 
+
+.c{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cpp{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cxx{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.c{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cpp{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cxx{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+
+!IF "$(NO_EXTERNAL_DEPS)" != "1"
+!IF EXISTS("dlltest_multithreaded.dep")
+!INCLUDE "dlltest_multithreaded.dep"
+!ELSE 
+!MESSAGE Warning: cannot find "dlltest_multithreaded.dep"
+!ENDIF 
+!ENDIF 
+
+
+!IF "$(CFG)" == "dlltest_multithreaded - Win32 Release" || "$(CFG)" == "dlltest_multithreaded - Win32 Debug"
+SOURCE=.\src\dlltest_multithreaded.cpp
+
+"$(INTDIR)\dlltest_multithreaded.obj"	"$(INTDIR)\dlltest_multithreaded.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\dlltest_multithreaded.pch"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=.\src\dlltest_worker.cpp
+
+"$(INTDIR)\dlltest_worker.obj"	"$(INTDIR)\dlltest_worker.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\dlltest_multithreaded.pch"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=.\src\STATTask.cpp
+
+"$(INTDIR)\STATTask.obj"	"$(INTDIR)\STATTask.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\dlltest_multithreaded.pch"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=.\src\StdAfx.cpp
+
+!IF  "$(CFG)" == "dlltest_multithreaded - Win32 Release"
+
+CPP_SWITCHES=/nologo /MT /W3 /GX /O2 /I ".\inc" /I "..\..\source\lib\inc" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Fr"$(INTDIR)\\" /Fp"$(INTDIR)\dlltest_multithreaded.pch" /Yc"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+
+"$(INTDIR)\StdAfx.obj"	"$(INTDIR)\StdAfx.sbr"	"$(INTDIR)\dlltest_multithreaded.pch" : $(SOURCE) "$(INTDIR)"
+	$(CPP) @<<
+  $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ELSEIF  "$(CFG)" == "dlltest_multithreaded - Win32 Debug"
+
+CPP_SWITCHES=/nologo /MTd /W3 /GX /Zi /Od /I ".\inc" /I "..\..\source\lib\inc" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\dlltest_multithreaded.pch" /Yc"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c 
+
+"$(INTDIR)\StdAfx.obj"	"$(INTDIR)\StdAfx.sbr"	"$(INTDIR)\dlltest_multithreaded.pch" : $(SOURCE) "$(INTDIR)"
+	$(CPP) @<<
+  $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ENDIF 
+
+
+!ENDIF 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltestermt/group/bld.inf	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,41 @@
+//
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:  
+//
+
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+
+* which accompanies this distribution, and is available
+
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+PRJ_PLATFORMS
+
+TOOLS
+
+PRJ_MMPFILES
+// Extension Makefile
+makefile statdlltestermt.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltestermt/group/statdlltestermt.mk	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,82 @@
+#
+# Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:  
+#
+
+# which accompanies this distribution, and is available
+
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+# Typically C:\apps\MSVC6\VC98\Bin
+COMPILER=nmake
+
+# Called with
+#
+# $(PLATFORM) = TOOLS
+# $(CFG)      = DEB, REL
+
+BLD	:  
+	@echo BLD called with $(PLATFORM)$(CFG)
+	
+# release version
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "REL"
+
+# Go up one level to access the makefile
+	cd ".."
+
+# Execute the command line compiler (dlltester_multithreaded)
+	"$(COMPILER)" /A /NOLOGO /f "dlltest_multithreaded.mak" CFG="dlltest_multithreaded - Win32 Release"
+	
+	echo ** DLL MULTI-THREADED TESTER (RELEASE) compiled successfully
+
+!endif
+
+# debug version
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "DEB"
+
+# Go up one level to access the makefile
+	cd ".."
+
+# Execute the command line compiler (dlltester_multithreaded)
+	"$(COMPILER)" /A /NOLOGO /f "dlltest_multithreaded.mak" CFG="dlltest_multithreaded - Win32 Debug"
+	
+	echo ** DLL MULTI-THREADED TESTER (DEBUG) compiled successfully
+
+!endif
+
+CLEAN :
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "REL"
+	-rmdir "..\Release" /q /s
+!endif
+
+CLEAN :
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "DEB"
+	-rmdir "..\Debug" /q /s
+!endif
+
+RELEASABLES :
+!if "$(PLATFORM)"=="TOOLS" && "$(CFG)" == "REL"
+	@echo $(EPOCROOT)epoc32\tools\STAT\STATDllTestMT.exe
+!endif
+
+SAVESPACE : BLD
+
+MAKMAKE LIB CLEANLIB RESOURCE FREEZE FINAL : 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltestermt/inc/dlltest_worker.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:     include file for worker class								*
+*/
+
+
+
+
+#include <stat.h>
+#include <stattask.h>
+#include <ini.h>
+#include "STATTask.h"
+
+#define MAX_CONNECTIONS 25
+#define X_MAXENTRYLEN MAX_PATH + 1
+/////////////////////////////////////////////////////////////////////////
+// Task initialisation info
+typedef struct STATTaskInfo
+{
+	int iterations;
+	int delay;
+	long verify;
+	long removeImages;
+	int fudge;
+	TCHAR *pLogfile;
+	TCHAR *pCommand;
+	TCHAR *pSnapshot;
+	TCHAR *pRefdir;
+	STATCONNECTTYPE connectType;
+	char szAddress[256];
+} STATTASKINFO;
+
+
+/////////////////////////////////////////////////////////////////////////
+// Main worker class
+class dlltest_worker
+{
+public:
+	dlltest_worker();
+	~dlltest_worker();
+	bool Prepare();
+	int WorkPending();
+	bool Run();
+	void Finish();
+
+private:
+	void GetTaskInfo(int index);
+	void ParseConnection(char *pConnection, STATCONNECTTYPE *pType, char **ppAddress);
+
+	STATTask *pDeviceTask[MAX_CONNECTIONS];				// device connections
+	STATTASKINFO TaskInfo[MAX_CONNECTIONS];				// info associated with device connections
+	char szConections[MAX_CONNECTIONS][X_MAXENTRYLEN];	// device connection configuration
+	int iterations;										// number of times to run test
+	int delay;											// command delay
+	long lConectionCount;								// number of device connections on this PC
+	long verify;										// verify images?
+	long removeImages;									// remove existing images before verification?
+	int fudge;											// percentage image difference
+	TCHAR szLogfile[256];								// log file
+	TCHAR szCommand[2048];								// command to execute
+	TCHAR szSnapshot[256];								// file name of saved snapshot
+	TCHAR szRefdir[256];								// location of reference images
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltestermt/inc/stattask.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef STATTASK_H
+#define STATTASK_H
+
+// pointer to our thread procedure
+typedef DWORD (WINAPI *ThreadProc) (LPVOID);
+
+class STATTask
+{
+public:
+	STATTask(const ThreadProc pFunc, void *pMember, char *pConection = NULL);
+	~STATTask();
+	bool Start();
+	bool StillActive(DWORD timeout = 5);
+	bool Kill();
+	void * Member() { return theMember; }
+	char * Connection() { return szConection; }
+
+private:
+	HANDLE hThreadHandle;				// handle to this thread
+	ThreadProc pfThreadProc;
+	void *theMember;					// pointer to associated object
+	char *szConection;					// connection string
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltestermt/inc/stdafx.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#if !defined(AFX_STDAFX_H__50FF2A1F_EA69_11D6_BC86_00B0D065107F__INCLUDED_)
+#define AFX_STDAFX_H__50FF2A1F_EA69_11D6_BC86_00B0D065107F__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include <afx.h>
+#include <oaidl.h>
+#include <afxwin.h>
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__50FF2A1F_EA69_11D6_BC86_00B0D065107F__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltestermt/src/dlltest_multithreaded.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include "stdafx.h"
+#include "dlltest_worker.h"
+
+int main(int argc, char* argv[])
+{
+	dlltest_worker oWorker;
+	if (oWorker.Prepare())
+	{
+		int count = 0;
+		while (count = oWorker.WorkPending())
+		{
+			printf("Waiting for %d threads...\r\n", count);
+			Sleep(3000);
+		}
+
+		oWorker.Finish();
+	}
+
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltestermt/src/dlltest_worker.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,372 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include "stdafx.h"
+#include <statcommon.h>
+#include "dlltest_worker.h"
+#include <stattask.h>
+#include <statexp.h>
+
+//////////////////////////////////////////////////////////////////////////
+// Write the contents of a screenshot out to file
+bool WriteBitmap(char *file, TBitmapFileHeader *fileheader, TBitmapInfoHeader * bmpHeader, char *bmpBits, unsigned long lSize)
+{
+	bool success = false;
+
+	// write the whole lot out to file
+	HANDLE infile;
+	if (INVALID_HANDLE_VALUE != (infile = CreateFile(file,
+										   GENERIC_WRITE,
+										   0, 
+										   NULL, 
+										   CREATE_ALWAYS,
+										   FILE_ATTRIBUTE_NORMAL,
+										   0)))
+	{
+		DWORD dwBytesWritten = 0;
+
+		// write the file info
+		if (WriteFile(infile, (LPVOID *)fileheader, sizeof(TBitmapFileHeader), &dwBytesWritten, NULL) &&
+			dwBytesWritten == sizeof(TBitmapFileHeader))
+		{
+			// write the bitmap info
+			if (WriteFile(infile, (LPVOID *)bmpHeader, sizeof(TBitmapInfoHeader), &dwBytesWritten, NULL) &&
+				dwBytesWritten == sizeof(TBitmapInfoHeader))
+			{
+				// write the bitmap data
+				if (WriteFile(infile, (LPVOID *)bmpBits, lSize, &dwBytesWritten, NULL) &&
+					dwBytesWritten == lSize)
+				{
+					success = true;
+				}
+			}
+		}
+
+		CloseHandle(infile);
+	}
+
+	return success;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+// This thread function handles the processing of a script by a single
+// connection
+DWORD WINAPI
+STATDeviceThreadProcedure(LPVOID lpParameter)
+{
+	DWORD valid = true;
+
+	STATTASKINFO *pWorker = (STATTASKINFO *)lpParameter;
+	if (pWorker)
+	{
+		int h = ConnectMT(pWorker->connectType, pWorker->szAddress);
+		if (h)
+		{
+			printf("Version %s\r\n", Version());
+			valid = SetCommandLogging(h, pWorker->pLogfile, NULL);
+			valid = SetCommandDelay(h, pWorker->delay);
+
+			if (valid)
+				if (pWorker->verify)
+					valid = SetImageVerification(h, pWorker->pRefdir, pWorker->removeImages?true:false, pWorker->fudge);
+
+			if (valid)
+			{
+				for (int i=0;i<pWorker->iterations;i++)
+				{
+					//valid = SendRawCommand(h, pWorker->pCommand);
+					valid = SendCommandFile(h, pWorker->pCommand);
+					if (!valid)
+					{
+						printf("[%d] bad command(%s)\r\n", h, GetError(h));
+						break;
+					}
+
+					/*struct TBitmapFileHeader *pFile = NULL;
+					struct TBitmapInfoHeader *pInfo = NULL;
+					char *pData = NULL;
+					unsigned long lSize = 0;
+
+					valid = GetSnapshot(h, &pFile, &pInfo, &pData, &lSize);
+					if (valid)
+						valid = WriteBitmap(pWorker->pSnapshot, pFile, pInfo, pData, lSize);
+					if (!valid)
+					{
+						printf("[%d] bad command(%s)\r\n", h, GetError(h));
+						break;
+					}*/
+				}
+			}
+
+			Disconnect(h);
+		}
+		else
+			printf("Bad connection (%s)\r\n", GetError());
+	}
+	else
+		printf("Bad parameter\r\n");
+
+	return (DWORD)valid;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Constructor
+dlltest_worker::dlltest_worker()
+: iterations(1), delay(100), lConectionCount(0), verify(0), removeImages(0), fudge(0)
+{
+	memset(szLogfile, 0, sizeof(szLogfile));
+	memset(szCommand, 0, sizeof(szCommand));
+	memset(szSnapshot, 0, sizeof(szSnapshot));
+	memset(szRefdir, 0, sizeof(szRefdir));
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Destructor
+dlltest_worker::~dlltest_worker()
+{
+	Finish();
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Get the settings and start the worker threads
+bool dlltest_worker::Prepare()
+{
+	CStatIniFile statIniFile;
+	statIniFile.SetIniFileName(STAT_INI_NAME);
+	if(statIniFile.SectionExists(ST_TEST_KEY) )
+	{
+		CString setting;
+		TCHAR szBuffer[2048];
+		long lCount = 0;
+		*(szBuffer) = (TCHAR)0;
+
+		setting.Empty();
+		setting=statIniFile.GetKeyValue(ST_ITERATIONS,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			if (_ttoi(setting)<1)
+				setting=_T("1");
+
+			iterations=_ttoi(setting);
+		}
+
+		setting=statIniFile.GetKeyValue(ST_DELAY,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			int iPos = _ttoi(setting);
+			if (iPos < 100)
+				setting= _T("100");
+
+			if (iPos > 30000)
+				setting= _T("30000");
+
+			delay=_ttoi(setting);
+		}
+
+	// logging settings
+		strcpy(szLogfile,(LPCSTR)statIniFile.GetKeyValue(ST_LOGFILE,ST_TEST_KEY));
+
+	// raw command
+		strcpy(szCommand,(LPCSTR)statIniFile.GetKeyValue(ST_CMDFILE,ST_TEST_KEY));
+
+	// snapshot settings
+		strcpy(szSnapshot,(LPCSTR)statIniFile.GetKeyValue(ST_SNAPSHOT,ST_TEST_KEY));
+
+	// image verification settings
+		verify=0;
+		setting=statIniFile.GetKeyValue(ST_CHKVERIF,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			verify=_ttol(setting);
+
+		}
+		removeImages=0;
+		setting=statIniFile.GetKeyValue(ST_VERIFYREMOVEIMAGES,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			removeImages=_ttol(setting);
+
+		}
+		strcpy(szRefdir,(LPCSTR)	statIniFile.GetKeyValue(ST_REFDIR,ST_TEST_KEY));
+		setting.Empty();
+		setting=statIniFile.GetKeyValue(ST_FUDGE,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+			fudge = _ttoi(setting);
+
+	// connection settings
+
+		lConectionCount = 0;
+		setting.Empty();
+		setting=statIniFile.GetKeyValue(ST_CONNECTIONIDX,ST_TEST_KEY);
+		if(!setting.IsEmpty())
+		{
+			lConectionCount = _ttol(setting);
+
+		}
+		if(statIniFile.SectionExists(ST_CONNECTION_LIST) )
+		{
+			for( int i=0;i<lConectionCount;++i)
+			{
+				TCHAR buf[6];
+				_ltot(i+1, buf, 10);
+				setting.Empty();
+				setting=statIniFile.GetKeyValue(buf,ST_CONNECTION_LIST);
+				if(!setting.IsEmpty())
+					strcpy(szConections[i],(LPCSTR)(setting));
+			}
+		}
+	}
+	// turn on high-level logging
+	SetConnectionLogging(szLogfile);
+
+	// start the threads
+	int i;
+	for (i=0;i<lConectionCount;i++)
+	{
+		GetTaskInfo(i);
+		pDeviceTask[i] = new STATTask(STATDeviceThreadProcedure, &TaskInfo[i]);
+		if (pDeviceTask[i])
+		{
+			if (!pDeviceTask[i]->Start())
+			{
+				delete pDeviceTask[i];
+				pDeviceTask[i] = NULL;
+			}
+		}
+	}
+
+	// wait a bit to allow the threads to start
+	Sleep(500);
+
+	return true;
+}
+
+
+/////////////////////////////////////////////////////////////////////////
+// Check to see if all our jobs have finished
+int dlltest_worker::WorkPending()
+{
+	int i;
+	int count = 0;
+	for (i=0;i<lConectionCount;i++)
+	{
+		if (pDeviceTask[i] && pDeviceTask[i]->StillActive())
+		{
+			count++;
+		}
+	}
+
+	return count;
+}
+
+/////////////////////////////////////////////////////////////////////////
+// Release any resources
+void dlltest_worker::Finish()
+{
+	// kill the threads
+	int i;
+	for (i=0;i<lConectionCount;i++)
+	{
+		if (pDeviceTask[i])
+		{
+			pDeviceTask[i]->Kill();
+			delete pDeviceTask[i];
+			pDeviceTask[i] = NULL;
+		}
+	}
+
+	// turn off high-level logging
+	CloseConnectionLogging();
+}
+
+
+/////////////////////////////////////////////////////////////////////////
+// PRIVATE METHODS
+/////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////
+// Set task information for a single thread
+void dlltest_worker::GetTaskInfo(int index)
+{
+	STATCONNECTTYPE type;
+	char *addr;
+	ParseConnection(szConections[index], &type, &addr);
+
+	TaskInfo[index].connectType = type;
+	TaskInfo[index].delay = delay;
+	TaskInfo[index].fudge = fudge;
+	TaskInfo[index].iterations = iterations;
+	TaskInfo[index].removeImages = removeImages;
+	TaskInfo[index].pCommand = szCommand;
+	TaskInfo[index].pLogfile = szLogfile;
+	TaskInfo[index].pRefdir = szRefdir;
+	TaskInfo[index].pSnapshot = szSnapshot;
+	TaskInfo[index].verify = verify;
+	strcpy(TaskInfo[index].szAddress, addr);
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////
+// Split a connection registry entry into its respective parts
+void dlltest_worker::ParseConnection(char *pConnection, STATCONNECTTYPE *pType, char **ppAddress)
+{
+	(*pType) = SymbianInvalid;
+	(*ppAddress) = NULL;
+
+	static char szConnection[256];
+	memset(szConnection, 0, sizeof(szConnection));
+	strcpy(szConnection, pConnection);
+
+	char *p = strchr(szConnection, ':');
+	if (p)
+	{
+		(*p) = (char)0;
+		(*ppAddress) = p + 1;
+
+		if (stricmp(szConnection, "SymbianSocket") == 0)
+		{
+			(*pType) = SymbianSocket;
+		}
+		else if (stricmp(szConnection, "SymbianSerial") == 0)
+		{
+			(*pType) = SymbianSerial;
+		}
+		else if (stricmp(szConnection, "SymbianInfrared") == 0)
+		{
+			(*pType) = SymbianInfrared;
+		}
+		else if (stricmp(szConnection, "SymbianBluetooth") == 0)
+		{
+			(*pType) = SymbianBluetooth;
+		}
+		else if (stricmp(szConnection, "SymbianUSB") == 0)
+		{
+			(*pType) = SymbianUSB;
+		}
+
+		(*p) = ':';
+	}
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltestermt/src/stattask.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,121 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include "stdafx.h"
+#include "STATTask.h"
+
+//////////////////////////////////////////////////////////////////////////
+// Constructor
+// Takes 3 parameters: 
+// 1) Pointer to function to start the thread in
+// 2) Pointer to class object to use within the thread
+// 3) Optional string identifier
+//////////////////////////////////////////////////////////////////////////
+STATTask::STATTask(const ThreadProc pFunc, void *pMember, char *pConnection)
+{
+	pfThreadProc = pFunc;
+	theMember = pMember;
+	szConection = NULL;
+
+	if (pConnection)
+	{
+		szConection = new char[strlen(pConnection) + 1];
+		if (szConection)
+			strcpy(szConection, pConnection);
+	}
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+// Destructor
+STATTask::~STATTask()
+{
+	Kill();
+
+	if (szConection)
+		delete [] szConection;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+// Create the thread
+bool STATTask::Start()
+{
+	bool valid = true;
+
+	// event attributes for the child process
+	SECURITY_ATTRIBUTES eventAttr;
+	eventAttr.nLength = sizeof(eventAttr);
+	eventAttr.lpSecurityDescriptor = NULL;
+	eventAttr.bInheritHandle = TRUE;
+
+	// spawn a thread to do the processing
+	DWORD dwThreadID;
+	if (!(hThreadHandle = CreateThread( NULL,			// security attributes
+										0,				// stack size
+										pfThreadProc,	// proc to call
+										theMember,		// proc parameter
+										0,				// creation flags
+										&dwThreadID)))	// thread identifier
+	{
+		valid = false;
+	}
+
+	return valid;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+// Check to see if thread has finished processing
+bool STATTask::StillActive(DWORD timeout)
+{
+	bool valid = false;
+
+	if (hThreadHandle)
+	{
+		if (WAIT_TIMEOUT == WaitForSingleObject(hThreadHandle, timeout))
+		{
+			valid = true;
+		}
+	}
+
+	return valid;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+// Kill the thread
+bool STATTask::Kill()
+{
+	bool valid = true;
+
+	if (hThreadHandle)
+	{
+		if (!TerminateThread(hThreadHandle, 0))
+		{
+			valid = false;
+		}
+
+		hThreadHandle = 0;
+	}
+
+	return valid;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/dlltestermt/src/stdafx.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:     implementation file for including standard include files	*
+*/
+
+
+
+
+#include "stdafx.h"
+
+// : reference any additional headers you need in STDAFX.H
+// and not in this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/desktop/testsource/testsource.dsw	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,85 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "STATDll"=..\source\dll\STATdll.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+    begin source code control
+    Perforce Project
+    ..\source\dll
+    end source code control
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "STATLib"=..\source\lib\STATLib.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+    begin source code control
+    Perforce Project
+    ..\source\lib
+    end source code control
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "dlltest"=.\dlltester\dlltest.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+    begin source code control
+    Perforce Project
+    .\dlltester
+    end source code control
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "dlltest_multithreaded"=.\dlltestermt\dlltest_multithreaded.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+    begin source code control
+    Perforce Project
+    .\dlltestermt
+    end source code control
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+    begin source code control
+    Perforce Project
+    .
+    end source code control
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/group/release.txt	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,5 @@
+NOTESRC_RELEASER
+Nokia Ltd. 
+
+NOTESRC_RELEASE_REASON
+STAT release.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/scripts/perl/stat.pl	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,172 @@
+#
+# Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:  
+#
+
+# which accompanies this distribution, and is available
+
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+use Win32::API;
+use StatAPI;
+
+########################################
+# Set up initial data
+# You will want to change:
+#  - def_connection
+#  - def_codetype
+#  - loglevel
+########################################
+
+my $result = 1;
+my $dll = "stat.dll";
+# For the connection, refer to the enumeration in stat.h.
+my $def_connection = 2;
+my $def_codetype = "COM1";
+my $logfile = "C:\\apps\\stat\\LogFiles\\stat_perl.log";
+# For log level, specify 2 for command line testing, specify 3 for automatic testing.
+my $loglevel = 2;
+my $senddir = "/";  # (must end in 'slash')
+my $recvdir = "Recvd/";
+my $commondir = "Common/";
+my $hndl = 0;		# a handle to a remote device connection
+
+########################################
+# Set options from parameters
+########################################
+
+if (@ARGV > 4)
+	{
+		print "Usage : perl stat.pl [connection type <";
+		print $def_connection;
+		print ">] [connection data<";
+		print $def_codetype;
+		print ">] [log level<";
+		print $loglevel;
+		print ">]\n";
+		exit 0;
+	}
+
+if (@ARGV > 0)
+	{
+		$def_connection = @ARGV[0];
+	}
+
+if (@ARGV > 1)
+	{
+		$def_codetype = @ARGV[1];
+	}
+
+if (@ARGV > 2)
+	{
+		$loglevel = @ARGV[2];
+	}
+
+########################################
+# Create the argument list
+########################################
+
+my @arglist = ($dll, $def_connection, $def_codetype, $loglevel, $logfile , $senddir, $recvdir, $commondir);
+
+########################################
+# Create the connection
+########################################
+
+print "==========================\n";
+print "STAT API Connectivity Test\n";
+print "==========================\n\n";
+
+# set folders
+Symbian::StatAPI::set_dll_folder("\\epoc32\\tools\\stat");
+
+# initialise
+Symbian::StatAPI::initialise(@arglist) or goto scripterror;	# initialise the DLL
+
+# connect to a device
+$hndl = Symbian::StatAPI::connect_to_target();
+$hndl or goto scripterror;
+
+Symbian::StatAPI::set_connection_logging();
+
+Symbian::StatAPI::set_command_logging($hndl);
+
+########################################
+# The script
+########################################
+
+Symbian::StatAPI::get_screenshot($hndl);
+
+Symbian::StatAPI::basic_key_sequence($hndl,'b');
+
+Symbian::StatAPI::get_device_info($hndl);
+
+Symbian::StatAPI::start_application($hndl,'Z:\Sys\Bin\Contacts.app','Test');
+Symbian::StatAPI::control_keystroke($hndl,'Menu');
+Symbian::StatAPI::control_keystroke($hndl,'RightArrow');
+Symbian::StatAPI::basic_key_sequence($hndl,'1');
+Symbian::StatAPI::basic_key_sequence($hndl,'Os');
+Symbian::StatAPI::control_keystroke($hndl,'DownArrow');
+Symbian::StatAPI::basic_key_sequence($hndl,'Symbian');
+Symbian::StatAPI::combination_keystroke($hndl,'Ctrl+S');
+Symbian::StatAPI::get_screenshot($hndl);
+Symbian::StatAPI::combination_keystroke($hndl,'Ctrl+E');
+
+Symbian::StatAPI::start_application($hndl,'Z:\Sys\Bin\Agenda.app','Test');
+Symbian::StatAPI::combination_keystroke($hndl,'Shift+Ctrl+E');
+Symbian::StatAPI::control_keystroke($hndl,'Enter');
+Symbian::StatAPI::basic_key_sequence($hndl,'My Birthday');
+Symbian::StatAPI::control_keystroke($hndl,'DownArrow');
+Symbian::StatAPI::control_keystroke($hndl,'DownArrow');
+Symbian::StatAPI::control_keystroke($hndl,'DownArrow');
+Symbian::StatAPI::control_keystroke($hndl,'LeftArrow');
+Symbian::StatAPI::control_keystroke($hndl,'Enter');
+Symbian::StatAPI::get_screenshot($hndl);
+Symbian::StatAPI::combination_keystroke($hndl,'Ctrl+E');
+
+Symbian::StatAPI::start_application($hndl,'Z:\Sys\Bin\TimeW.app');
+Symbian::StatAPI::combination_keystroke($hndl,'Ctrl+Shift+K');
+Symbian::StatAPI::get_screenshot($hndl);
+Symbian::StatAPI::combination_keystroke($hndl,'Ctrl+E');
+
+Symbian::StatAPI::get_screenshot($hndl);
+
+Symbian::StatAPI::copy_testfile_to_target($hndl,'StdAfx.sbr','C:\System\StdAfx.sb_');
+Symbian::StatAPI::copy_from_target($hndl,'C:\System\StdAfx.sb_');
+Symbian::StatAPI::remove_file($hndl,'C:\System\StdAfx.sb_');
+
+goto endscript;
+
+########################################
+# Error handling routine
+########################################
+scripterror:
+print "\nScript aborted due to error:\n" . Symbian::StatAPI::get_last_error($hndl) . "\n";
+$result = 0;
+
+########################################
+# Finish
+########################################
+endscript:
+$hndl and Symbian::StatAPI::disconnect_from_target($hndl) and print "Disconnected OK\n";
+Symbian::StatAPI::close_connection_logging();		# close log file
+
+exit ($result);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/scripts/standard/file_transfer.txt	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,10 @@
+<B>
+<YC:\Logs\>
+<TEmpty.txt,C:\Logs\Empty.txt>
+<RC:\Logs\Empty.txt,Recvd>
+<YC:\STAT\Data\>
+<TStdAfx.sbr,C:\STAT\Data\StdAfx.sbr>
+<RC:\STAT\Data\StdAfx.sbr,Recvd>
+<UC:\STAT\Data\StdAfx.sbr>
+<ZC:\STAT\Data\>
+<E>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/scripts/standard/hamlet.txt	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,56 @@
+/*********************************************************
+* AUTO-GENERATED COMMENT BLOCK - DO NOT MODIFY
+**********************************************************
+*
+* HAMLET.TXT
+*
+* Author : Sanjeet Matharu
+* Version : 1.0
+* Description: 
+*
+* Sample STAT script to demonstrate multiline text input
+*
+* (C) Copyright Symbian 2001/2002
+*********************************************************/
+
+<B>
+<Az:\system\apps\jotter\jotter.app,Hamlet>
+<KHamlet - ACT III, scene 1. By William Shakespeare
+
+To be, or not to be: that is the question;
+Whether 'tis nobler in the mind to suffer
+The slings and arrows of outrageous fortune,
+Or to take arms against a sea of troubles,
+And by opposing end them? To die: to sleep;
+No more; and, by a sleep to say we end
+The heartache and the thousand natural shocks
+That flesh is heir to, 'tis a consummation
+Devoutly to be wish'd. To die, to sleep;
+To sleep; perchance to dream: ay there's the rub;
+For in that sleep of death what dreams may come
+When we have shuffled off this mortal coil,
+Must give us pause. There's the respect
+That makes calamity of so long life;
+For who bear the whips and scorns of time,
+The oppressor's wrong, the proud man's contumely,
+The pangs of dispriz'd love, the law's delay,
+The insolence of office, and the spurns
+That patient merit of the unworthy takes,
+When he himself might his quietus make
+
+With a bare bodkin? Who would fardels bear,
+To grunt and sweat under a weary life,
+But that the dread of something after death,
+The undiscover'd country from whose bourn
+No traveller returns, puzzles the will,
+And makes us rather bear those ills we have,
+Than fly to others that we know not of?
+Thus conscience doth make cowards of us all;
+And thus the native hue of resolution
+Is sicklied o'er with the pale cast of thought,
+And enterprises of great pith and moment
+With this regard their currents turn awry,
+
+And lose the name of action.>
+<S>
+<E>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/scripts/standard/prepare.txt	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,45 @@
+/*********************************************************
+* AUTO-GENERATED COMMENT BLOCK - DO NOT MODIFY
+**********************************************************
+*
+* PREPARE.TXT
+*
+* Author : Phil Hodgson
+* Version : 1.0
+* Description: 
+*
+* Sets a few things on the target prior to testing
+*
+* (C) Copyright Symbian 2001/2002
+*********************************************************/
+
+<B>					/* begin script */
+
+/* Disable screen power off */
+<MCtrl+S><P200>				/* system */
+<LDownArrow><P200>			/* navigate */
+<LDownArrow><P200>			/* navigate */
+<LRightArrow><P200>			/* navigate */
+<LEnter><P200>				/* set */
+<LDownArrow><P200>			/* navigate */
+<LDownArrow><P200>			/* navigate */
+<LDownArrow><P200>			/* navigate */
+<LRightArrow><P200>			/* navigate */
+<LEnter><P200>				/* set */
+<LEscape><P200>				/* exit */
+
+/* Show system and hidden files */
+<MCtrl+K><P200>				/* system */
+<LRightArrow><P200>			/* navigate */
+<LDownArrow><P200>			/* navigate */
+<LRightArrow><P200>			/* navigate */
+<LEnter><P200>				/* set */
+
+/* change to ROM drive */
+<MCtrl+Tab><P200>			/* system */
+<LUpArrow><P200>			/* navigate */
+<LUpArrow><P200>			/* navigate */
+<LLeftArrow><P200>			/* navigate */
+<LEnter><P200>				/* set */
+
+<E>					/* end script */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/scripts/standard/sample.txt	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,70 @@
+/*********************************************************
+* AUTO-GENERATED COMMENT BLOCK - DO NOT MODIFY
+**********************************************************
+*
+* SAMPLE.TXT
+*
+* Author : Phil Hodgson
+* Version : 1.0
+* Description: 
+*
+* Basic Functionality Test for all STAT commands
+*
+* (C) Copyright Symbian 2001/2002
+*********************************************************/
+
+<B>					/* begin script */
+<D>					/* device information */
+<#image C:>				/* set image dir */
+<S>					/* take screenshot */
+<SMyScreenshot>				/* take screenshot and give it a name */
+<Az:\system\apps\word\word.app>		/* start word with default doc */
+<P2000>					/* pause */
+<C>					/* close app */
+<Az:\system\apps\word\word.app,sample>	/* start Word */
+<P2000>					/* pause */
+<KTo be, or not to be>			/* type some text */
+<P1000>					/* pause */
+<LEnter>				/* newline */
+<P1000>					/* pause */
+<LEnter>				/* newline */
+<P1000>					/* pause */
+<HA,2000>				/* hold down the 'A' key for 2 seconds */
+<P1000>					/* pause */
+<LEnter>				/* newline */
+<P1000>					/* pause */
+<MCtrl+S>				/* save file */
+<P1000>					/* pause */
+<S>					/* take screenshot */
+<C>					/* close app */
+<P2000>					/* pause */
+<Fz:\system\apps\word\word.app,sample>	/* restart app */
+<P2000>					/* pause */
+<K - That is the question>		/* type some more text */
+<P1000>					/* pause */
+<MCtrl+S>				/* save file */
+<P1000>					/* pause */
+<S>					/* take screenshot */
+<C>					/* close app */
+<P1000>					/* pause */
+<Tmyfile.abc,c:\myfile.xyz>		/* transfer to target */
+<P1000>					/* pause */
+<Rc:\myfile.xyz,>			/* retrieve (move) from target */
+<P1000>					/* pause */
+<Xz:\system\apps\word\word.app,>	/* retrieve (copy) from target */
+<P1000>					/* pause */
+<I260,25>				/* touch screen */
+<P3000>					/* pause */
+<LEscape>				/* escape */
+<P2000>					/* pause */
+<UC:\sample>				/* delete a file */
+<P2000>					/* pause */
+<Nc:\newfolder\>			/* create folder */
+<P2000>					/* pause */
+<Zc:\newfolder\>			/* delete folder */
+<P1000>					/* pause */
+<!>					/* start eshell */
+<Kdir>					/* directory listing */
+<LEnter>				/* newline */
+<!!>					/* close eshell */
+<E>					/* end script */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/scripts/standard/simpleword.txt	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,49 @@
+/*********************************************************
+* AUTO-GENERATED COMMENT BLOCK - DO NOT MODIFY
+**********************************************************
+*
+* SIMPLEWORD.TXT
+*
+* Author : Tim Eades
+* Version : 1.0
+* Description: 
+*
+* Basic Functionality Test for Word application
+*
+* (C) Copyright Symbian 2001/2002
+*********************************************************/
+
+<B>
+/* Basic Functionality Test for Word */
+
+<Az:\system\apps\word\word.app,sample>		/* open Word */
+<MCtrl+T>					/* hide side menu */
+
+/* Passage from Hamlet to be typed to screen */
+
+<KTo be, or not to be>  			/* type some text */
+<P1000>
+<MCtrl+S>					/* save */
+<P500>
+<C>						/* close */
+<P500>
+<Fz:\system\apps\word\word.app,sample>		/* re-open */
+<P500>
+<C>						/* close */
+<E>						/* end */
+
+
+	/* None of the following is read! */
+	/* Saving document to Documents Folder */
+<LMenu><P5000>
+<LDownArrow><P5000>
+<LDownArrow><P5000>
+<LDownArrow><P5000>
+<LDownArrow><P5000>
+<LRightArrow><P5000>
+<LEnter><P5000>
+<KTim><P5000>
+<LDownArrow><P5000>
+<Kd><P5000>
+<LEnter><P2000>
+<E>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/scripts/standard/statdlltest.txt	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,16 @@
+/*********************************************************
+* AUTO-GENERATED COMMENT BLOCK - DO NOT MODIFY
+**********************************************************
+*
+* STATDLLV3TEST.TXT
+*
+* Author : Phil Hodgson
+* Version : 1.0
+* Description: 
+*
+* Takes a screenshot - for use with statdlltest.exe
+*
+* (C) Copyright Symbian 2001/2002
+*********************************************************/
+
+<B><S><E>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/scripts/standard/various.txt	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,48 @@
+/*********************************************************
+* AUTO-GENERATED COMMENT BLOCK - DO NOT MODIFY
+**********************************************************
+*
+* VARIOUS.TXT
+*
+* Author : Sanjeet Matharu
+* Version : 1.0
+* Description: 
+*
+* Basic testing of starting applications
+*
+* (C) Copyright Symbian 2001/2002
+*********************************************************/
+<B>
+<D>
+<Az:\System\Apps\Agenda\Agenda.app,Harris>
+<LMenu>
+<S>
+<LEscape>
+<MShift+Ctrl+Y>
+<S>
+<I288,41>
+<S>
+<LEscape>
+<MShift+Ctrl+W>
+<MCtrl+G>
+<K14042001>
+<LEnter>
+<S>
+<KMy Birthday>
+<S>
+<I297,87>
+<S>
+<LEnter>
+<S>
+<Az:\system\apps\word\word.app,Rubbish>
+<KThis is a test>
+<S>
+<Az:\system\apps\sheet\sheet.app,sheet test>
+<S>
+<Az:\system\apps\jotter\jotter.app,jotter test>
+<KThis is a test. What happens if I enter quite a long string as a set of key-press events? I wonder if 'punctuation' and other ! symbols are allowed? Boing.>
+<S>
+<Az:\system\apps\web\web.app><Kn><S>
+<I283,14>
+<S>
+<E>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/scripts/standard/various_eka1.txt	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,32 @@
+<B>
+<Kb>
+<D>
+<AZ:\Sys\Bin\Contacts.app,Test>
+<LMenu>
+<LRightArrow>
+<K1>
+<KOs>
+<LDownArrow>
+<KSymbian>
+<MCtrl+S>
+<S>
+<MCtrl+E>
+<AZ:\Sys\Bin\Agenda.app,Test>
+<MShift+Ctrl+E>
+<LEnter>
+<KMy Birthday>
+<LDownArrow>
+<LDownArrow>
+<LDownArrow>
+<LLeftArrow>
+<LEnter>
+<S>
+<MCtrl+E>
+<AZ:\Sys\Bin\TimeW.app>
+<MCtrl+Shift+K>
+<S>
+<MCtrl+E>
+<TRecvd\StdAfx.sbr,C:\System\StdAfx.sb_>
+<RC:\System\StdAfx.sb_,Recvd>
+<UC:\System\StdAfx.sb_>
+<E>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testconns/statdesktop/scripts/standard/various_eka2.txt	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,21 @@
+<B>
+<Kb>
+<D>
+<AZ:\Sys\Bin\Contacts.exe,Test>
+<LMenu>
+<LRightArrow>
+<K1>
+<KOs>
+<LDownArrow>
+<KSymbian>
+<MCtrl+S>
+<S>
+<MCtrl+E>
+<AZ:\Sys\Bin\TimeW.exe>
+<MCtrl+Shift+K>
+<S>
+<MCtrl+E>
+<TRecvd\StdAfx.sbr,C:\System\StdAfx.sb_>
+<RC:\System\StdAfx.sb_,Recvd>
+<UC:\System\StdAfx.sb_>
+<E>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/Group/bld.inf	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+/**
+
+bld.inf for BURTestServer
+
+*/
+
+PRJ_TESTEXPORTS
+burtestserver.iby   		/epoc32/rom/include/burtestserver.iby
+
+
+PRJ_TESTMMPFILES
+    burtestserver.mmp
+
+PRJ_PLATFORMS
+    DEFAULT
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/Group/burtestserver.iby	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,22 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+#ifndef __BUR_TEST_SERVER_IBY__
+#define __BUR_TEST_SERVER_IBY__
+
+file=ABI_DIR\DEBUG_DIR\BURTestServer.exe	Sys\bin\BURTestServer.exe
+
+#endif // __BUR_TEST_SERVER_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/Group/burtestserver.mmp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,58 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Using relative paths for sourcepath and user includes
+// 
+//
+
+
+// Target specification:
+    TARGET	BURTestServer.exe
+    TARGETTYPE  EXE
+    UID		0x1000007A 0x102050E4
+
+CAPABILITY ProtServ AllFiles WriteDeviceData ReadDeviceData
+
+// Source:
+SOURCEPATH		..\TestServer\src
+SOURCE			t_burtestserver.cpp
+SOURCE			t_storagemanager.cpp
+SOURCE 			t_asyncbackuptransferhandler.cpp
+
+SOURCEPATH		..\TestSteps\src
+SOURCE			t_burteststepbase.cpp
+SOURCE			t_teststepbackup.cpp
+SOURCE			t_teststeprestore.cpp
+SOURCE			t_teststepbackupasync.cpp
+SOURCE			t_teststeprestoreasync.cpp
+
+USERINCLUDE		..\TestServer\inc
+USERINCLUDE		..\TestSteps\inc
+//SYSTEMINCLUDE 	\epoc32\include
+//SYSTEMINCLUDE	\epoc32\include\test
+//SYSTEMINCLUDE	\epoc32\include\libc
+//SYSTEMINCLUDE	\epoc32\include\connect
+MW_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+LIBRARY			estlib.lib 
+LIBRARY			euser.lib
+LIBRARY			efsrv.lib
+LIBRARY			estor.lib
+LIBRARY			testexecuteutils.lib
+LIBRARY			testexecutelogclient.lib
+LIBRARY			sbeclient.lib
+LIBRARY			abclient.lib
+
+
+//EPOCHEAPSIZE 1024    1024000
+//EPOCSTACKSIZE 65536
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/Group/testtools_burtestserver.history.xml	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<relnotes name="BURTESTSERVER">
+  <purpose>
+  </purpose>
+</relnotes>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/Group/testtools_burtestserver.mrp	Mon Oct 04 02:58:21 2010 +0300
@@ -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: 
+#
+
+component	testtools_burtestserver
+
+source	\sf\os\buildtools\toolsandutils\burtestserver
+exports \sf\os\buildtools\toolsandutils\burtestserver\Group
+binary \sf\os\buildtools\toolsandutils\burtestserver\Group all
+notes_source	\component_defs\release.src
+
+
+ipr T 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/SampleTestScripts/test.ini	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,5 @@
+[default]
+BackupDir=c:\BackupArchive\
+IsPartial=0
+BaseOnly=0
+DriveList=c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/SampleTestScripts/test_backup.script	Mon Oct 04 02:58:21 2010 +0300
@@ -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: 
+//
+//////////////////////////////////////////////////////////////////////////////////////
+//
+// test.script
+//
+////////////////////////////////////////////////////////////////////////////////////
+LOAD_SUITE BURTestServer
+
+PRINT ----------------------------------------------
+PRINT  Test Backup
+PRINT ----------------------------------------------
+RUN_TEST_STEP 100 BURTestServer TestBackup c:\TestScripts\BUR\test.ini default
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/SampleTestScripts/test_backupasync.script	Mon Oct 04 02:58:21 2010 +0300
@@ -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: 
+//
+//////////////////////////////////////////////////////////////////////////////////////
+//
+// test.script
+//
+////////////////////////////////////////////////////////////////////////////////////
+LOAD_SUITE BURTestServer
+
+PRINT ----------------------------------------------
+PRINT  Test Backup
+PRINT ----------------------------------------------
+RUN_TEST_STEP 100 BURTestServer TestBackupAsync c:\TestScripts\BUR\test.ini default
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/SampleTestScripts/test_restore.script	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,28 @@
+//
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description: 
+//
+//////////////////////////////////////////////////////////////////////////////////////
+//
+// test.script
+//
+////////////////////////////////////////////////////////////////////////////////////
+LOAD_SUITE BURTestServer
+
+PRINT ----------------------------------------------
+PRINT  Test Backup/Restore
+PRINT ----------------------------------------------
+RUN_TEST_STEP 100 BURTestServer TestRestore c:\TestScripts\BUR\test.ini default
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/SampleTestScripts/test_restoreaysnc.script	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,28 @@
+//
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description: 
+//
+//////////////////////////////////////////////////////////////////////////////////////
+//
+// test.script
+//
+////////////////////////////////////////////////////////////////////////////////////
+LOAD_SUITE BURTestServer
+
+PRINT ----------------------------------------------
+PRINT  Test Backup/Restore
+PRINT ----------------------------------------------
+RUN_TEST_STEP 100 BURTestServer TestRestoreAsync c:\TestScripts\BUR\test.ini default
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/TestServer/inc/t_asyncbackuptransferhandler.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,87 @@
+/**
+* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file
+ @released
+*/
+
+#ifndef __ASYNC_BACKUP_TRANSFER_HANDLER_H__
+#define __ASYNC_BACKUP_TRANSFER_HANDLER_H__
+
+#include "t_teststepbackup.h"
+
+using namespace conn;
+
+namespace bur_ts
+	{
+	// Forward declaration
+	class CBURTestStepBase;
+	
+	class CAsyncBackupTransferHandler : public CActive
+		/**
+		Implements a mechanism for asynchronous data transfers bewteen CTestStepBackup 
+		and CSBEClient.
+		
+		@released
+		@internalComponent
+		*/
+		{
+	public:
+		static CAsyncBackupTransferHandler* NewL(CBURTestStepBase* aTestStep);
+		~CAsyncBackupTransferHandler();
+		
+		// CActive
+		void StartL();
+		TInt RunError(TInt aError);
+		
+		TBool Success();
+		
+	private:
+		CAsyncBackupTransferHandler(CBURTestStepBase* aTestStep);
+		virtual void ConstructL();
+	
+		// CActive
+		void RunL();
+		void DoCancel();
+		
+		void ContinueL();
+		void MakeRequestDataCallL();
+		void CurrentIDL();
+		
+	private:
+		/** */
+		CActiveSchedulerWait* iActiveScheduler;
+		
+		/** Current index into iTransferTypes */
+		TInt iCurrentIndex;
+		
+		/** Successful if all transfers are completed without errors */
+		TBool iSuccess;
+		
+		/** Parent test step for access to its logging */
+		CBURTestStepBase* iTestStep;
+		
+		/** */
+		HBufC* iID;
+		};
+	}
+
+#endif // __ASYNC_BACKUP_TRANSFER_HANDLER_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/TestServer/inc/t_burcommon.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,122 @@
+/**
+* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file
+ @released
+*/
+
+#ifndef __T_BURCOMMON_H__
+#define __T_BURCOMMON_H__
+
+#include <connect/sbtypes.h>
+#include <s32file.h>
+
+using namespace conn;
+
+namespace bur_ts
+	{
+	
+	// Directory names defining the Backup Archive naming scheme:
+	_LIT(KRegFilesDir, "RegistrationData\\");
+	_LIT(KPassiveDataDir, "Passive\\");
+	_LIT(KActiveDataDir, "Active\\");
+	_LIT(KBaseDataDir, "Base\\");
+	_LIT(KIncrementalDataDir, "Incremental\\");
+	_LIT(KSnapshotDataDir, "Snapshot\\");
+	_LIT(KDataOwnerDir, "DataOwners\\");
+	
+	_LIT(KData, "data");
+	_LIT(KSnapshot, "snapshot");
+	_LIT(KIncrement, "increment");
+	
+	_LIT(KMidlet, "midlet");
+	
+	_LIT(KSlash, "\\");
+	_LIT(KBackupExtn, ".bkp");
+	
+	_LIT(KSidDir, "IdData\\");
+	
+	// forward declaration
+	class CBURTDataOwner;
+	
+	// Some usefull shorthands:
+	typedef RPointerArray<CDataOwnerInfo> RDataOwnerArray;
+	typedef RPointerArray<CSBSecureId> RSBSecureIdArray;
+
+	typedef RPointerArray<CSBGenericTransferType> RTransferTypeArray;
+	
+	typedef RArray<CSBGenericDataType> RGenericDataTypeArray;
+	
+	// Indentation levels for logging:
+	const TUint LOG_LEVEL1 = 1;
+	const TUint LOG_LEVEL2 = 2;
+	const TUint LOG_LEVEL3 = 3;
+	const TUint LOG_LEVEL4 = 4;
+	const TUint LOG_LEVEL5 = 5;
+	const TUint LOG_LEVEL6 = 6;
+	const TUint LOG_LEVEL7 = 7;
+	const TUint LOG_LEVEL8 = 8;
+	
+	// Indentation marker for logging:
+	_LIT(KIndentationMarker, "--");
+	
+	enum TBackupMode
+		/**
+		@released
+		@internalComponent
+		*/
+		{
+		EBackupMode = 0,
+		ERestoreMode = 1
+		};
+		
+	enum TCurrentState
+		/**
+		@released
+		@internalComponent
+		*/
+		{
+		ERegistration =0,
+		ESnapshots = 1,
+		EBase = 2,
+		EIncrements
+		};
+		
+	// ERROR MESSAGES:
+	_LIT(KBURTestPanicText,"BURTestServer: ");
+	
+	// ERROR CODES:
+	/** 
+	Panic A null pointer has been encountered 
+	@internalComponent
+	*/
+	const TInt KErrBURTestNullPointer 			= 1;
+	
+	/** 
+	Panic An invalid file name
+	@internalComponent
+	*/
+	const TInt KErrBURTestInvalidFileName 		= 2;
+	
+	}
+
+#endif // __T_BURCOMMON_H__
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/TestServer/inc/t_burtestserver.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,78 @@
+/**
+* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file
+ @released
+*/
+
+#ifndef __T_BUR_TEST_SERVER_H__
+#define __T_BUR_TEST_SERVER_H__
+
+#include <test/testexecuteserverbase.h>
+
+namespace bur_ts
+	{
+	
+	class CBURTestServer : public CTestServer
+		/**
+		CBURTestServer implements the Backup and Restore Test Server. The Test Server is based
+		on the TestExecute Framework (TEF).
+		
+		When running the Test Server, the TestExecute scipts must specify:
+			
+			LOAD_SUITE BURTestServer
+		
+		This server handles two types of test steps only:\n
+			- TestBackup\n
+			- TestRestore
+		
+		Each test step must carry an ini file listing parameters:\n
+			1. BackupDir=full path of the directory\n
+				The directory to be used for
+					- storing the backup data during a backup operation, or for
+					- retrieving the backup data from during a restore.
+			
+			2. IsPartial=<[0|1]>\n
+				Whether to carry out a partial backup and restore or a full one.
+			
+			3. IsIncremental=<[0|1]>\n
+				Whether to carry out a base back up and restore or an incremental one.
+			
+			4. DriveList=a list of drive letters without spaces\n
+				The drives to be backed up.
+		
+		This ini file must be specifed in the test script for each indiviudal test step, e.g.,
+			
+			RUN_TEST_STEP 100 BURTestServer TestBackup c:\\TestScripts\\mySettings.ini
+		
+		@released
+		@internalComponent
+		*/
+		{
+	
+	public:
+		static CBURTestServer* NewL();
+		~CBURTestServer();
+		
+		virtual CTestStep* CreateTestStep(const TDesC& aStepName);
+		};
+	}
+
+#endif // __T_BUR_TEST_SERVER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/TestServer/inc/t_storagemanager.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,114 @@
+/**
+* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file
+ @released
+*/
+
+#ifndef __STORAGE_MANAGER_H__
+#define __STORAGE_MANAGER_H__
+
+#include <e32cmn.h>
+#include <s32file.h>
+#include "t_burteststepbase.h"
+
+using namespace conn;
+
+namespace bur_ts
+	{
+	// Forward declaration
+	class CBURTestStepBase;
+	
+	class CStorageManager : public CBase
+		/**
+		Handles storage management for both backup and restore.
+		
+		@released
+		@internalComponent
+		*/
+		{
+	public:
+		static CStorageManager* NewL(const TFileName& aBackupDirName, TDriveList aDriveList, CBURTestStepBase* aTestStep);
+		~CStorageManager();
+		
+		// Stores data in the archive during a backup operation
+		void ArchiveDataL(CSBGenericTransferType* aTransferType, const TDesC8& aData, TBool aFinished);
+		
+		// Retrieves data from the archive during a restore operation
+		void RetrieveDataL(CSBGenericTransferType* aTransferType, TDes8& aData, TBool& aFinished, TInt aIndex = 0);
+		
+		// generates transfer type array by parsing archive directory
+		//void GenerateSIDTransferTypeArrayL(RTransferTypeArray& aArray, TTransferDataType aDataType);
+		
+		// returns total number of files stored in the directory for Incrementals
+		TInt TotalIncFiles(CSBSIDTransferType* aTransferType);
+		
+		void SaveDataOwnerL(CDataOwnerInfo& aDataOwner);
+		
+		void ReadDataOwnersFromDiskL(RDataOwnerArray& aArray);
+		
+		void GetFileNameL(CSBGenericTransferType* aTransferType, TFileName& aFileName, TBool aBackup, TInt aIndex = 1);
+		
+		TBool IsFileExists(TFileName& aFileName);
+		
+		void Reset();
+		
+	private:
+		CStorageManager(const TFileName& aBackupDirName, TDriveList aDriveList, CBURTestStepBase* aTestStep);
+		void ConstructL();
+		
+		// Following methods implement the backup archive naming scheme:
+		void GetSIDFileNameL(CSBSIDTransferType* aTransferType, TFileName& aFileName);
+		void GetSIDPrivateDirName(TChar aDrive, TSecureId aSeID, TFileName& aFileName) const;
+		
+		void GetPIDFileNameL(CSBPackageTransferType* aTransferType, TFileName& aFileName);
+		void GetJavaFileNameL(CSBJavaTransferType* aTransferType, TFileName& aFileName);
+		
+		void GetJavaPrivateDirName(TChar aDrive, const TDesC& aSuiteHash, TFileName& aFileName);
+		
+		void GenerateIncNumber(TInt aIndex, TDes& aDes);
+		
+		void WriteToDiskL(TFileName& aFileName, const TDesC8& aData);
+		
+		void ReadFromDiskL(TFileName& aFileName, TDes8& aData, TBool& aFinished);
+		
+	private:
+		/** The name of the backup directory */
+		TFileName iBackupDirName;
+		
+		/** List of drives being backed up */
+		TDriveList iDriveList;
+		
+		/** Parent test step for callbacks to various logging methods */
+		CBURTestStepBase* iTestStep;
+		
+		/** Last file it which was written to */
+		TFileName iLastFile;
+		
+		/** firstSupply */
+		TBool iFirstSupply;
+		
+		/** bytes read */
+		TInt iBytesRead;
+		};
+	}
+
+#endif // __STORAGE_MANAGER_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/TestServer/src/t_asyncbackuptransferhandler.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,317 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @released
+*/
+
+
+#include "t_asyncbackuptransferhandler.h"
+
+using namespace conn;
+
+const TInt KZero = 0;
+
+namespace bur_ts
+	{
+	CAsyncBackupTransferHandler* CAsyncBackupTransferHandler::NewL(CBURTestStepBase* aTestStep)
+		/**
+		Symbian OS Constructor
+		
+		@internalComponent
+		@released
+		
+		@param aTestStep - A pointer to a CBURTestStepBackup or CBURTestStepRestore that owns this object
+		
+		@return Pointer to a newly created CAsyncBackupTransferHandler object.
+		*/
+		{
+		CAsyncBackupTransferHandler* self = new (ELeave) CAsyncBackupTransferHandler(aTestStep);
+		CleanupStack::PushL(self);
+		self->ConstructL();
+		CleanupStack::Pop();
+		return self;
+		}
+	
+	CAsyncBackupTransferHandler::CAsyncBackupTransferHandler(CBURTestStepBase* aTestStep)
+		/**
+		C++ Constructor
+		
+		@internalComponent
+		@released
+		
+		@param aTestStep - A pointer to a CBURTestStepBackup or CBURTestStepRestore that owns this object
+		*/
+	: 	CActive(EPriorityStandard),
+		iActiveScheduler(NULL),
+	  	iCurrentIndex(KZero),
+	  	iSuccess(ETrue),
+	  	iTestStep(aTestStep),
+	  	iID(NULL)
+		{}
+	
+	void CAsyncBackupTransferHandler::ConstructL()
+		/**
+		Symbian OS 2nd phase Constructor
+		
+		@internalComponent
+		@released
+		*/
+		{
+		iID = HBufC::NewL(KZero);
+		iActiveScheduler = new (ELeave) CActiveSchedulerWait;
+		CActiveScheduler::Add(this);
+		}
+	
+	CAsyncBackupTransferHandler::~CAsyncBackupTransferHandler()
+		/**
+		C++ Destructor
+		
+		@internalComponent
+		@released
+		*/
+		{
+		// Cancel the active object
+		if (IsActive())
+			{
+			Cancel();
+			}
+		delete iID; 
+		iID = 0;
+		delete iActiveScheduler;
+		iActiveScheduler = 0;
+		}
+	
+	void CAsyncBackupTransferHandler::StartL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		iCurrentIndex = KZero;
+		iSuccess = ETrue;
+		ContinueL();
+		iActiveScheduler->Start();
+		}
+	
+	void CAsyncBackupTransferHandler::ContinueL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		// If all transfer types have been dealt with, there are no more requests 
+		// to be made and hence we can stop the active scheduler:
+		if (iCurrentIndex == iTestStep->TransferTypes().Count())
+			{
+			iActiveScheduler->AsyncStop();
+			}
+		else if (!IsActive())
+			{
+			CurrentIDL();
+			TUint expectedSize = 0;
+			
+			_LIT(KCurrentSid, "Current ID: ");
+			iTestStep->LogWithText(LOG_LEVEL3, KCurrentSid, *iID);
+			
+			TRAPD(err, expectedSize = iTestStep->BackupClient()->ExpectedDataSizeL(*iTestStep->TransferTypes()[iCurrentIndex]));
+			if(err != KErrNone)
+				{
+				_LIT(KLog1e, "Request expected data size error: ");
+				iTestStep->LogWithNum(LOG_LEVEL5, KLog1e, err);
+				}
+							
+			_LIT(KExpSize, "Expected Data Size: ");
+			iTestStep->LogWithNum(LOG_LEVEL4, KExpSize, expectedSize);		
+
+			MakeRequestDataCallL();
+			}
+		else
+			{
+			// Being called during an active state
+			User::Leave(KErrInUse);
+			}
+		}
+		
+	void CAsyncBackupTransferHandler::MakeRequestDataCallL()
+		{
+		TRAPD(err1,iTestStep->BackupClient()->RequestDataL(*iTestStep->TransferTypes()[iCurrentIndex], iStatus));
+		if (err1 != KErrNone)
+			{
+			_LIT(KLog1, "Failed to request data for ID: ");
+			iTestStep->LogWithText(LOG_LEVEL5, KLog1, *iID);
+			_LIT(KLog2, "Error code: ");
+			iTestStep->LogWithNum(LOG_LEVEL5, KLog2, err1);
+			}						
+		iStatus = KRequestPending;
+		SetActive();	
+		}
+	
+	void CAsyncBackupTransferHandler::RunL()
+		/**
+		Upon completion of the request, gets backup data from the backup server, and 
+		saves it to the backup archive.
+		
+		@internalComponent
+		@released
+		*/
+		{
+		if (iStatus == KErrNone)
+			{
+			TBool isFinished;
+			
+			// Initialise following to NULL, or else SBEClient panics in debug builds:		
+			CSBGenericTransferType* receivedType = NULL;
+			TPtrC8 pData = iTestStep->BackupClient()->TransferDataInfoL(receivedType, isFinished);
+			CleanupStack::PushL(receivedType);
+			
+			// no need to push it onto CleanupStack as there is no ownership transfer
+			CSBGenericTransferType* currentTransfer = iTestStep->TransferTypes()[iCurrentIndex];
+			
+			if (KErrNone != (currentTransfer->Externalise()).CompareF(receivedType->Externalise()))
+				{
+				_LIT(KLogWrong, "The type of data requested doesn't much the received, please contact Connectivity team !");
+				iTestStep->LogWithText(LOG_LEVEL3, KLogWrong, *iID);
+				}
+			else if (pData.Size() > 0)
+				{
+				TRAPD(err, iTestStep->StorageManager()->ArchiveDataL(currentTransfer, pData, isFinished));
+				if (err != KErrNone)
+					{
+					iTestStep->StorageManager()->Reset();
+					_LIT(KLog1, "Error Saving data to archive for ID: ");
+					iTestStep->LogWithText(LOG_LEVEL3, KLog1, *iID);
+					_LIT(KLog2, "Error code: ");
+					iTestStep->LogWithNum(LOG_LEVEL3, KLog2, err);
+					}
+				else
+					{
+					_LIT(KLog3, "Number of bytes saved: ");
+					iTestStep->LogWithNum(LOG_LEVEL3, KLog3, pData.Size());
+					}
+				}
+				
+			CleanupStack::PopAndDestroy(receivedType);
+			if (isFinished)  // if not then there are more data to come, so run again on the same type
+				{
+				++iCurrentIndex;
+				// Restart the active object to request more data:
+				ContinueL();
+				}
+			else // continue to request data
+				{
+				MakeRequestDataCallL();
+				}
+			
+			}
+		else
+			{
+			User::Leave(iStatus.Int());
+			}
+		}
+	
+	
+	void CAsyncBackupTransferHandler::DoCancel()
+		/**
+		@internalComponent
+		@released
+		*/
+		{}
+	
+	TInt CAsyncBackupTransferHandler::RunError(TInt aError)
+		/**
+		This overridden method prints an error message to the TestExecute log
+		and then returns with the error passed to it by the Active Scheduler.
+		
+		@internalComponent
+		@released
+		
+		@param aError - Error code passed down by the Active Scheduler.
+		@return The error code returned by the Active Scheduler.
+		*/
+		{
+		++iCurrentIndex;
+		_LIT(KErrorText, "Error while async call : ");
+		iTestStep->LogWithNum(LOG_LEVEL4, KErrorText, aError);
+		iSuccess = EFalse;
+		TRAPD(err, ContinueL());
+		if (err != KErrNone)
+			{
+			_LIT(KErrorText1, "Error trying to issue another requst : ");
+			iTestStep->LogWithNum(LOG_LEVEL4, KErrorText1, err);
+			}
+		return KErrNone;
+		}
+	
+	void CAsyncBackupTransferHandler::CurrentIDL()
+		/**
+		@internalComponent
+		@released
+		
+		@return SecureId of the data owner currently being processed.
+		*/
+		{
+		delete iID;
+		iID = NULL;
+		CSBGenericTransferType* transfer = iTestStep->TransferTypes()[iCurrentIndex];
+		TSBDerivedType type = transfer->DerivedTypeL();
+		TInt numberOfDigits = EHex;
+		
+		if (type == ESIDTransferDerivedType)
+			{
+			CSBSIDTransferType* sidType = CSBSIDTransferType::NewL(transfer);
+			CleanupStack::PushL(sidType); 
+			iID = HBufC::NewL(numberOfDigits);
+			TPtr pID = iID->Des();
+			
+			pID.AppendNumUC(sidType->SecureIdL(), EHex);
+			CleanupStack::PopAndDestroy(sidType);
+			}
+		else if (type == EPackageTransferDerivedType)
+			{
+			CSBPackageTransferType* pidType = CSBPackageTransferType::NewL(transfer);
+			CleanupStack::PushL(pidType);
+			iID = HBufC::NewL(numberOfDigits);
+			TPtr pID = iID->Des();
+			pID.AppendNum(TSecureId(pidType->PackageIdL()), EHex);
+			CleanupStack::PopAndDestroy(pidType);
+			}
+		else if (type == EJavaTransferDerivedType)
+			{
+			CSBJavaTransferType* javaType = CSBJavaTransferType::NewL(transfer);
+			CleanupStack::PushL(javaType);
+			iID = HBufC::NewL(javaType->SuiteHashL().Length());
+			TPtr pID = iID->Des();
+			pID.Append(javaType->SuiteHashL());
+			CleanupStack::PopAndDestroy(javaType);
+			}
+		}
+		
+	
+	
+	TBool CAsyncBackupTransferHandler::Success()
+		/**
+		@internalComponent
+		@released
+		
+		@return Whether or not all data transfers completed successfully and resets the success.
+		*/
+		{
+		TBool res = iSuccess;
+		iSuccess = ETrue;
+		return res;
+		}
+	}	// end namespace
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/TestServer/src/t_burtestserver.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,174 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @released
+*/
+
+#include "t_burtestserver.h"
+#include "t_teststepbackup.h"
+#include "t_teststeprestore.h"
+#include "t_teststepbackupasync.h"
+#include "t_teststeprestoreasync.h"
+
+_LIT( KServerName, "BURTestServer");
+
+using namespace conn;
+
+namespace bur_ts
+	{
+
+	CBURTestServer* CBURTestServer::NewL()
+		/**
+		Symbian OS Constructor
+		Called inside the MainL() function to create and start the
+		CTestServer derived server.
+		
+		@internalComponent
+		@released
+		
+		@return - A pointer to an instance of the test server
+		*/
+		{
+		CBURTestServer* testServer = new (ELeave) CBURTestServer();
+		CleanupStack::PushL(testServer);
+		
+		// Either use a StartL or ConstructL, the latter will permit
+		// Server Logging.
+		//server->StartL(KServerName); 
+		testServer->ConstructL(KServerName);
+		CleanupStack::Pop(testServer);
+		return testServer;
+		}
+
+	CBURTestServer::~CBURTestServer()
+		/**
+		C++ Destructor
+		
+		@internalComponent
+		@released
+		*/
+		{}
+	
+	CTestStep* CBURTestServer::CreateTestStep(const TDesC& aStepName)
+		/**
+		Implementation of CTestServer pure virtual
+		Creates and returns a bur_ts::CBURTestStepBase object
+		
+		@internalComponent
+		@released
+		
+		@return - A CTestStep derived instance
+		*/
+		{
+		CBURTestStepBase* testStep = NULL;
+		
+		// Create a test step based on the string name passed:
+		TInt error = KErrNone;
+		if (aStepName == KBURTestBackup)
+			{
+			TRAP(error, testStep = CBURTestStepBackup::NewL(*this));
+			}
+		else if (aStepName == KBURTestRestore)
+			{
+			TRAP(error, testStep = CBURTestStepRestore::NewL(*this));
+			}
+		else if (aStepName == KBURTestBackupAsync)
+			{
+			TRAP(error, testStep = CBURTestStepBackupAsync::NewL(*this))
+			}
+		else
+			{
+			TRAP(error, testStep = CBURTestStepRestoreAsync::NewL(*this));
+			}
+			
+		if (error != KErrNone)
+			{
+			User::Leave(error);
+			}
+
+		return testStep;
+		}
+	
+	}	// end namespace
+
+//
+
+// EKA2 much simpler
+// Just an E32Main and a MainL()
+LOCAL_C void MainL()
+	/**
+	Much simpler, uses the new Rendezvous() call to sync with the client
+	*/
+	{
+	// Leave the hooks in for platform security
+	#if (defined __DATA_CAGING__)
+		RProcess().DataCaging(RProcess::EDataCagingOn);
+		RProcess().SecureApi(RProcess::ESecureApiOn);
+	#endif
+	
+	// Rename the thread:
+	User::RenameThread(KServerName);
+	
+	CActiveScheduler* scheduler = NULL;
+	scheduler = new(ELeave) CActiveScheduler;
+	CleanupStack::PushL(scheduler);
+	CActiveScheduler::Install(scheduler);
+	
+
+	bur_ts::CBURTestServer* testServer = NULL;
+	
+	// Create the CTestServer derived server
+	TRAPD(err, testServer = bur_ts::CBURTestServer::NewL());
+	if(!err)
+		{
+		CleanupStack::PushL(testServer);
+		
+		// Sync with the client and enter the active scheduler
+		RProcess::Rendezvous(KErrNone);
+		scheduler->Start();
+		CleanupStack::Pop(testServer);
+		}
+	
+	CleanupStack::Pop(scheduler);
+	delete testServer;
+	delete scheduler;
+	}
+
+
+
+// Only a DLL on emulator for typhoon and earlier
+
+GLDEF_C TInt E32Main()
+	/**
+	@return - Standard Epoc error code on exit
+	*/
+	{
+	__UHEAP_MARK;
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+	if(cleanup == NULL)
+		{
+		return KErrNoMemory;
+		}
+	TRAPD(err,MainL());
+	delete cleanup;
+	__UHEAP_MARKEND;
+	return err;
+	}
+
+// Create a thread in the calling process
+// Emulator typhoon and earlier
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/TestServer/src/t_storagemanager.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,702 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @released
+*/
+
+
+#include "t_storagemanager.h"
+#include "e32cons.h"
+#include "e32panic.h"
+
+namespace bur_ts
+	{
+	CStorageManager* CStorageManager::NewL(const TFileName& aBackupDirName, TDriveList aDriveList, CBURTestStepBase* aTestStep)
+		/**
+		Symbian OS Constructor
+		
+		@internalComponent
+		@released
+		
+		@param aBackupDirName - Directory to which all backup files are to be stored in 
+			(or read from during a restore operation).
+		@param aDriveList - Drives that are being backed up. One subdirectory under per 
+			drive will be generated under iBackupDirName.
+		@param aTestStep - A pointer to a CBURTestStepBackup or CBURTestStepRestore that 
+			owns this object.
+		
+		@return Pointer to a newly created CStorageManager object.
+		*/
+		{
+		CStorageManager* self = new (ELeave) CStorageManager(aBackupDirName, aDriveList, aTestStep);
+		CleanupStack::PushL(self);
+		self->ConstructL();
+		CleanupStack::Pop();
+		return self;
+		}
+	
+	CStorageManager::CStorageManager(const TFileName& aBackupDirName, TDriveList aDriveList, CBURTestStepBase* aTestStep)
+		/**
+		C++ Constructor
+		
+		@internalComponent
+		@released
+		
+		@param aBackupDirName - Directory to which all backup files are to be stored in 
+				(or read from during a restore operation).
+		@param aDriveList - Drives that are being backed up. One subdirectory under per 
+			drive will be generated under iBackupDirName.
+		@param aTestStep - A pointer to a CBURTestStepBackup or CBURTestStepRestore that 
+			owns this object.
+		*/
+		:iBackupDirName(aBackupDirName), iDriveList(aDriveList), iTestStep(aTestStep), iLastFile(KNullDesC), iFirstSupply(ETrue), iBytesRead(0) 		
+		{}
+	
+	void CStorageManager::ConstructL()
+		/**
+		Symbian OS 2nd phase Constructor
+		
+		@internalComponent
+		@released
+		*/
+		{
+		}
+	
+	CStorageManager::~CStorageManager()
+		/**
+		C++ Destructor
+	 	
+		@internalComponent
+		@released
+		*/
+		{}
+	
+	void CStorageManager::ArchiveDataL(CSBGenericTransferType* aTransferType, const TDesC8& aData, TBool aFinished)
+		/**
+		Stores data to the archive for the given transfer type
+		
+		@internalComponent
+		@released
+		
+		@param aTransferType - A CSBGenericTransferType* containing information about transfer type
+		@param aData - Data to be stored
+		
+		*/
+		{
+		__ASSERT_DEBUG(aTransferType != NULL, User::Panic(KBURTestPanicText, ENullTargetPointer));
+		
+		TFileName filename;
+		
+		if (iFirstSupply && aFinished) //no partial data
+			{
+			GetFileNameL(aTransferType, filename, ETrue);		
+			}
+		else if (iFirstSupply && !aFinished) // we start to write
+			{
+			GetFileNameL(aTransferType, filename, ETrue);
+			iFirstSupply = EFalse;
+			}
+		else if (!iFirstSupply && !aFinished) // we continue
+			{
+			filename = iLastFile;
+			}
+		else if (!iFirstSupply && aFinished) // we finish
+			{
+			filename = iLastFile;
+			iFirstSupply = ETrue;
+			}
+	
+		// Handle the error case where no name valid was generated!
+		__ASSERT_DEBUG(filename != _L(""), User::Panic(KBURTestPanicText, KErrBURTestInvalidFileName));
+		
+		WriteToDiskL(filename, aData);
+		
+		}
+	
+	void CStorageManager::RetrieveDataL(CSBGenericTransferType* aTransferType, TDes8& aData, TBool& aFinished, TInt aIndex)
+		/**
+		Retrieves data from the backup archive for the given transfer type.
+		
+		@internalComponent
+		@released
+		
+		@param aTransferType - A CSBGenericTransferType* containing information about transfer type
+		@param aErrorCode - Error code to be set on completion
+		@param aIndex - Index of the increment
+		
+		@return Pointer to the retrieved data on the heap
+		
+		*/
+		{
+		__ASSERT_DEBUG(aTransferType != NULL, User::Panic(KBURTestPanicText, ENullTargetPointer));
+		
+		TFileName filename;
+		GetFileNameL(aTransferType, filename, EFalse, aIndex);
+		
+		ReadFromDiskL(filename, aData, aFinished);		
+		}
+		
+	void CStorageManager::Reset()
+	/**
+	Resets last name and first supply variables
+	*/
+		{
+		iLastFile = KNullDesC;
+		iFirstSupply = ETrue;
+		iBytesRead = 0;
+		}
+		
+	void CStorageManager::GetFileNameL(CSBGenericTransferType* aTransferType, TFileName& aFileName, TBool aBackup, TInt aIndex)
+		/**
+		Creates the name of the file depending on its type
+	
+		@intenalComponent
+		@released
+	
+		@param aTransferType - A CSBGenericTransferType contains information about transfer type
+		@param aFileName - reference to a TFileName
+		@param aBackup - is it Backup or Restore
+		@param aIndex - index of increment (currently not supported)
+		
+		*/
+		{
+		__ASSERT_DEBUG(aTransferType != NULL, User::Panic(KBURTestPanicText, ENullTargetPointer));
+		TSBDerivedType derivedType = aTransferType->DerivedTypeL();
+		
+		if (derivedType == ESIDTransferDerivedType)
+			{
+			CSBSIDTransferType* type = CSBSIDTransferType::NewL(aTransferType);
+			CleanupStack::PushL(type);
+				
+			GetSIDFileNameL(type, aFileName);
+		
+			TTransferDataType  dataType = type->DataTypeL();
+		
+			if (dataType == EActiveIncrementalData || dataType == EPassiveIncrementalData )
+				{
+				aFileName.Append(KIncrement);
+				if (aBackup)
+					{
+					GenerateIncNumber(TotalIncFiles(type)+1, aFileName);
+					//GenerateIncNumber(TotalIncFiles(type)+1, aFileName);
+					}
+				else
+					{
+					GenerateIncNumber(aIndex, aFileName);
+					}
+				aFileName.Append(KBackupExtn);	
+				}
+			
+			CleanupStack::PopAndDestroy(type);
+			}
+				
+		else if (derivedType == EPackageTransferDerivedType)
+			{
+			CSBPackageTransferType* pkgType = CSBPackageTransferType::NewL(aTransferType);
+			CleanupStack::PushL(pkgType);
+				
+			GetPIDFileNameL(pkgType, aFileName);
+			
+			CleanupStack::PopAndDestroy(pkgType);
+ 			}
+ 		else if (derivedType == EJavaTransferDerivedType)
+ 			{
+ 			CSBJavaTransferType* javaType = CSBJavaTransferType::NewL(aTransferType);
+ 			CleanupStack::PushL(javaType);
+ 			
+ 			GetJavaFileNameL(javaType, aFileName);
+ 			
+ 			CleanupStack::PopAndDestroy(javaType);
+ 			}
+		}
+		
+	void CStorageManager::GetPIDFileNameL(CSBPackageTransferType* aTransferType, TFileName& aFileName)
+		/**
+		Generates file name for the PID
+		
+		@param aTransferType - A CSBPackageTransferType contains info about Package Type
+		@param aFileName - Reference to a filename
+		
+		*/
+		{
+		__ASSERT_DEBUG(aTransferType != NULL, User::Panic(KBURTestPanicText, ENullTargetPointer));
+		TUid id;
+		TChar drive;
+		TDriveNumber driveNumber;
+		TPackageDataType pkgType;
+		
+		id = aTransferType->PackageIdL();
+		pkgType = aTransferType->DataTypeL();
+		driveNumber = aTransferType->DriveNumberL();
+		
+		//Get the drive letter
+		iTestStep->Fs().DriveToChar(driveNumber, drive);
+		
+		switch(pkgType)
+			{
+			case ESystemData:
+				GetSIDPrivateDirName(drive, id, aFileName);
+				aFileName.Append(KData);
+				aFileName.Append(KBackupExtn);
+				break;
+			case ESystemSnapshotData:
+				GetSIDPrivateDirName(drive, id, aFileName);
+				aFileName.Append(KSnapshot);
+				aFileName.Append(KBackupExtn);
+				break;
+			}
+		}
+		
+	void CStorageManager::GetJavaFileNameL(CSBJavaTransferType* aTransferType, TFileName& aFileName)
+		/**
+		Concatenates the name of the backup file from the information found in aTransferType.
+		
+		
+		@param 	aTransferType - A CSBJavaTransferType* containing information about the 
+					type of file name that needs be returned.
+			
+		@param TFilename of the backup file generated in line with the 
+				implemented naming scheme
+		*/
+		{
+		const TDesC& suiteHash = aTransferType->SuiteHashL();
+		TDriveNumber driveNumber = aTransferType->DriveNumberL();
+		TJavaTransferType javaType = aTransferType->DataTypeL();
+		
+		TChar drive;
+		
+		iTestStep->Fs().DriveToChar(driveNumber, drive);
+		
+		// we can't create a TSecureID from suiteHash therefore need to duplicate GetSIDPrivateDir Method
+		GetJavaPrivateDirName(drive, suiteHash, aFileName);
+		
+		switch(javaType)
+			{
+			case EJavaMIDlet:
+				aFileName.Append(KMidlet);
+				aFileName.Append(KBackupExtn);
+				break;
+			case EJavaMIDletData:
+				aFileName.Append(KData);
+				aFileName.Append(KBackupExtn);
+				break;
+			}
+		}
+	
+	void CStorageManager::GetSIDFileNameL(CSBSIDTransferType* aTransferType, TFileName& aFileName)
+		/**
+		Concatenates the name of the backup file from the information found in aTransferType.
+		
+		@internalComponent
+		@released
+		
+		@param 	aTransferType - A CSBSIDTransferType* containing information about the 
+				type of file name that needs be returned.
+		
+		@param TFilename of the backup file generated in line with the 
+				implemented naming scheme
+				
+		*/
+		{
+		__ASSERT_DEBUG(aTransferType != NULL, User::Panic(KBURTestPanicText, ENullTargetPointer));
+		TSecureId sid;
+		TChar drive;
+		TDriveNumber driveNumber;
+		TTransferDataType dataType;
+		
+		sid = aTransferType->SecureIdL();
+		dataType = aTransferType->DataTypeL();
+		driveNumber = aTransferType->DriveNumberL();
+		
+		// Get the drive letter
+		iTestStep->Fs().DriveToChar(driveNumber, drive);
+		
+		switch(dataType)
+			{
+			case ERegistrationData:
+				{
+				GetSIDPrivateDirName(drive, sid, aFileName);
+				aFileName.Append(KRegFilesDir);
+				aFileName.AppendNumUC(sid, EHex);
+				aFileName.Append(KBackupExtn);
+				break;
+				}
+				// No need to create this directory, as it's done in SetupDirs():
+			case EPassiveSnapshotData:
+				{
+				GetSIDPrivateDirName(drive, sid, aFileName);
+				aFileName.Append(KPassiveDataDir);
+				aFileName.Append(KSnapshotDataDir);
+				aFileName.Append(KSnapshot);
+				aFileName.Append(KBackupExtn);
+				break;
+				}
+			case EPassiveBaseData:
+				{
+				GetSIDPrivateDirName(drive, sid, aFileName);
+				aFileName.Append(KPassiveDataDir);
+				aFileName.Append(KBaseDataDir);
+				aFileName.Append(KData);
+				aFileName.Append(KBackupExtn);
+				break;
+				} 
+			case EPassiveIncrementalData :
+				{
+				GetSIDPrivateDirName(drive, sid, aFileName);
+				aFileName.Append(KPassiveDataDir);
+				aFileName.Append(KIncrementalDataDir);
+				break;
+				}
+			case EActiveSnapshotData:
+				{
+				GetSIDPrivateDirName(drive, sid, aFileName);
+				aFileName.Append(KActiveDataDir);
+				aFileName.Append(KSnapshotDataDir);
+				aFileName.Append(KSnapshot);
+				aFileName.Append(KBackupExtn);
+				break;
+				}
+			case EActiveBaseData:
+				{
+				GetSIDPrivateDirName(drive, sid, aFileName);
+				aFileName.Append(KActiveDataDir);
+				aFileName.Append(KBaseDataDir);
+				aFileName.Append(KData);
+				aFileName.Append(KBackupExtn);
+				break;
+				}
+			case EActiveIncrementalData:
+				{
+				GetSIDPrivateDirName(drive, sid, aFileName);
+				aFileName.Append(KActiveDataDir);
+				aFileName.Append(KIncrementalDataDir);
+				break;
+				}
+			default:
+				{
+				User::Leave(KErrArgument);
+				break;
+				}
+			}
+		
+		}
+	
+	
+	void CStorageManager::GetSIDPrivateDirName(TChar aDrive, TSecureId aSID, TFileName& aFileName) const
+		/**
+		Gets the name of the directory where the private data is to stored:\n
+		\<backup directory>\\KPrivateDirName\\<aSID>\\
+		
+		@internalComponent
+		@released
+		
+		@param aDrive - The drive letter of the drive where data resides.
+		@param aSID - SID the data belonds to.
+		
+		@param aFileName - Directory name of the given SID's private directory, generated in 
+				line with the implemented naming scheme.
+		*/
+		{
+		aFileName = iBackupDirName;
+		aFileName.AppendNumUC(aSID, EHex);
+		aFileName.Append(KSlash);
+		aFileName.Append(aDrive);
+		aFileName.Append(KSlash);
+		}
+		
+	void CStorageManager::GetJavaPrivateDirName(TChar aDrive, const TDesC& aSuiteHash, TFileName& aFileName)
+		/**
+		Gets the name of the directory where the private data is to stored:\n
+		\<backup directory>\\KPrivateDirName\\<aSID>\\
+		
+		@internalComponent
+		@released
+		
+		@param aDrive - The drive letter of the drive where data resides.
+		@param aSuiteHash - Suite Hash the data belonds to.
+		
+		@param aFileName name of the given suite hash private directory, generated in line with the implemented naming scheme.
+		*/
+		{
+		aFileName = iBackupDirName;
+		aFileName.Append(aSuiteHash);
+		aFileName.Append(KSlash);
+		aFileName.Append(aDrive);
+		aFileName.Append(KSlash);
+		}
+		
+	TInt CStorageManager::TotalIncFiles(CSBSIDTransferType* aTransferType)
+		/**
+		Returns number of Files in the directory for SID TransferType
+		
+		@param aTransferType - CSBSIDTransferType* pointer
+		*/
+		{
+		__ASSERT_DEBUG(aTransferType != NULL, User::Panic(KBURTestPanicText, ENullTargetPointer));
+		CDir* dir = NULL;
+		TFileName filename;
+		GetSIDFileNameL(aTransferType, filename);
+		TInt err = iTestStep->Fs().GetDir(filename, KEntryAttMaskSupported, ESortByName, dir);
+		if (err != KErrNone)
+			{
+			return 0;
+			}
+		return dir->Count();
+		}
+			
+	void CStorageManager::GenerateIncNumber(TInt aIndex, TDes& aDes)
+		/**
+		Generates number from int to string in range 0 - 999
+		
+		@param aIndex - Number
+		@param aDes - A Descriptor
+		*/
+	
+		{
+		if (aIndex <= 9)
+			{
+			aDes.AppendNum(0);
+			aDes.AppendNum(0);
+			aDes.AppendNum(aIndex);
+			}
+		else if (aIndex <= 99)
+			{
+			aDes.AppendNum(0);
+			aDes.AppendNum(aIndex);
+			}
+		else if (aIndex <= 999)
+			{
+			aDes.AppendNum(aIndex);
+			}
+		else
+			{
+			_LIT(KPanic1, "Number greater then 999 ");
+			User::Panic(KPanic1, KErrNotSupported);
+			}
+		}
+
+		
+	void CStorageManager::SaveDataOwnerL(CDataOwnerInfo& aDataOwner)
+		/**
+		Saves data for DataOwner
+		
+		@param aDataOwner - DataOwner to be saved
+		
+		*/
+
+		{		
+		CDir* dir = NULL;
+		TFileName filename;
+		filename.Append(iBackupDirName);
+		filename.Append(KDataOwnerDir);
+		iTestStep->Fs().MkDirAll(filename);
+		_LIT(KPid, "pid");
+		_LIT(KSid, "sid");
+		_LIT(KJid, "jid");
+		
+		
+		TSBDerivedType type;
+		type = aDataOwner.Identifier().DerivedTypeL();
+		
+		if (type == ESIDDerivedType)
+			{
+			CSBSecureId* sid = CSBSecureId::NewL(&(aDataOwner.Identifier()));
+			CleanupStack::PushL(sid);
+			filename.Append(KSid);
+			filename.AppendNumUC(sid->SecureIdL(), EHex);
+			CleanupStack::PopAndDestroy(sid);
+			}
+		else if (type == EPackageDerivedType)
+			{
+			CSBPackageId* pid = CSBPackageId::NewL(&(aDataOwner.Identifier()));
+			CleanupStack::PushL(pid);
+			filename.Append(KPid);
+			filename.AppendNumUC(pid->PackageIdL().iUid, EHex);
+			CleanupStack::PopAndDestroy(pid);
+			}
+		else if (type == EJavaDerivedType)
+			{
+			CSBJavaId* jid = CSBJavaId::NewL(&(aDataOwner.Identifier()));
+			CleanupStack::PushL(jid);
+			filename.Append(KJid);
+			filename.Append(jid->SuiteHashL());
+			CleanupStack::PopAndDestroy(jid);
+			}
+		
+		filename.Append(KBackupExtn);
+		//HBufC8* data = HBufC8::NewLC(aDataOwner.Size());
+		
+		HBufC8* data = aDataOwner.ExternaliseLC();
+		WriteToDiskL(filename, *data);
+		CleanupStack::PopAndDestroy(data);
+		delete dir;
+		dir = NULL;
+		}
+		
+	void CStorageManager::WriteToDiskL(TFileName& aFile, const TDesC8& aData)
+		/**
+		Writes data to disk
+		
+		@param aFile - file to write to
+		@param aData - data to write
+		
+		*/
+		{
+		RFile file;
+		// Place on the cleanup stack:
+		CleanupClosePushL(file);
+		TInt error = iTestStep->Fs().MkDirAll(aFile);
+		
+		if (error == KErrAlreadyExists || error == KErrNone) // directory exists
+			{
+			if (iLastFile == aFile) // more data needs appended to already open file
+				{
+				error = file.Open(iTestStep->Fs(), aFile, EFileWrite);	
+				}
+			else 
+				{
+				error = file.Replace(iTestStep->Fs(), aFile, EFileWrite);
+				}
+			}
+		if (error != KErrNone)
+			{
+			CleanupStack::PopAndDestroy(&file); // file
+			User::Leave(error)	;
+			}
+		
+		TInt size = NULL;
+		file.Size(size);
+		error = file.Write(size, aData);
+		file.Flush();
+		
+		iLastFile = aFile;	
+			
+		CleanupStack::PopAndDestroy(&file); // file
+		User::LeaveIfError(error);
+		}
+		
+	void CStorageManager::ReadFromDiskL(TFileName& aFile, TDes8& aData, TBool& aFinished)
+		/**
+		Read data from a disk
+		
+		@param aFile - file to read
+		@param aData - reference to a buffer to put the data from a file
+		
+		*/
+		{
+		RFile file;
+		CleanupClosePushL(file);
+				
+		TInt err = file.Open(iTestStep->Fs(), aFile, EFileRead);
+		if (err != KErrNone)
+			{
+			CleanupStack::PopAndDestroy(&file);
+			User::Leave(err);
+			}
+		
+		TInt size;
+		file.Size(size);
+		
+		TInt availableSpace = aData.MaxLength() - aData.Length();
+		
+		if (availableSpace - (size - iBytesRead) >= 0)
+			{
+			aFinished = ETrue;
+			}
+		else
+			{
+			aFinished = EFalse;	
+			}
+		
+		err = file.Read(iBytesRead, aData);
+		file.Flush();
+		CleanupStack::PopAndDestroy(&file);
+		
+		User::LeaveIfError(err);
+		
+		if (aFinished)
+			{
+			iBytesRead = 0;
+			}
+		else
+			{
+			iBytesRead += availableSpace;
+			}
+		}
+		
+	void CStorageManager::ReadDataOwnersFromDiskL(RDataOwnerArray& aArray)
+		/**
+		Reads Data Owners from a storage
+		
+		@param aArray - RDataOwnerArray will contain dataowners found in storage
+		
+		*/
+
+		{
+		aArray.ResetAndDestroy();
+		CDir* dir = NULL;
+		TFileName filename = iBackupDirName;
+		filename.Append(KDataOwnerDir);
+		User::LeaveIfError(iTestStep->Fs().GetDir(filename, KEntryAttMaskSupported, ESortByName, dir));
+		TInt totalFiles = dir->Count();
+		
+		for (TInt index = 0; index < totalFiles; index++)
+			{
+			TFileName file = filename;
+			TEntry entry = (*dir)[index];
+			file.Append(entry.iName);
+			HBufC8* data = HBufC8::NewLC(entry.iSize);
+			TPtr8 pData = data->Des();
+			TBool ignore;
+			TRAPD(err, ReadFromDiskL(file, pData, ignore));
+			if (err != KErrNone)
+				{
+				_LIT(KLog1, "Error opening file: ");
+				iTestStep->LogWithText(LOG_LEVEL2, KLog1, file);
+				CleanupStack::PopAndDestroy(data);
+				continue;
+				}
+			CDataOwnerInfo* dataOwner = CDataOwnerInfo::NewL(pData);
+			CleanupStack::PushL(dataOwner);
+			aArray.AppendL(dataOwner);
+			CleanupStack::Pop(dataOwner);
+			CleanupStack::PopAndDestroy(data);
+			}
+		}
+	
+	TBool CStorageManager::IsFileExists(TFileName& aFileName)
+		/**
+		Is File Exists in the File System
+		
+		@param aFileName File Name of the file to check
+		
+		@return ETrue if exists
+		*/
+		{
+		TEntry entry;
+		TInt err = iTestStep->Fs().Entry(aFileName, entry);
+		if (err == KErrNone)
+			{
+			return ETrue;
+			}
+		else
+			{
+			return EFalse;
+			}
+		}
+	
+	}	// end namespace
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/TestSteps/inc/t_burteststepbase.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,261 @@
+/**
+* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file
+ @released
+*/
+
+#ifndef __T_BUR_TEST_STEP_BASE_H__
+#define __T_BUR_TEST_STEP_BASE_H__
+
+#include <test/testexecutestepbase.h>
+#include <connect/sbeclient.h>
+#include "t_burcommon.h"
+#include "t_burtestserver.h"
+#include "t_storagemanager.h"
+
+using namespace conn;
+
+namespace bur_ts
+	{
+	
+	const TInt KRetries = 3;
+	const TInt KDelay = 10000000; //10 sec
+	
+	// Forward declaration
+	class CStorageManager;
+	
+	class CBURTestStepBase : public CTestStep
+		/**
+		Base class for all test cases to be used by BURTestServer.
+		It provides common functionality to backup and restore, such as supplying data
+		from the archive, setting backup/restore mode, getting list of data owners, etc.
+		
+		This class may not be directly instantiated. All derived classes must supply 
+		implementations of all pure virtual functions inherited from CTestStep 
+		(from TestExecute Framework), namely:
+		
+		virtual TVerdict doTestStepPreambleL();\n
+		virtual TVerdict doTestStepPostambleL();\n
+		virtual TVerdict doTestStepL();
+		
+		The logging methods provide an interface to the text execute logging utility.
+		
+		@released
+		@internalComponent
+		*/
+		{
+	protected:
+		// No need for 2-phase construction here and this is an abstract class.
+		CBURTestStepBase(CBURTestServer& aTestServer);
+		~CBURTestStepBase();
+		
+	public:
+		// Utility function to convert user input into a TDriveList object
+		static TDriveList StringToDriveListL(TPtrC apText);
+		
+		// For logging to the TestExecute logger:
+		void Log(TUint aIndentationLevel, const TDesC& aLog);
+		void LogWithText(TUint aIndentationLevel, const TDesC& aLog, const TDesC& aText);
+		void LogWithText8(TUint aIndentationLevel, const TDesC& aLog, const TDesC8& aText);
+		void LogWithNum(TUint aIndentationLevel, const TDesC& aLog, TInt aNum);
+		void LogWithSID(TUint aIndentationLevel, const TDesC& aLog, TSecureId aSecureId);
+		void LogWithChar(TUint aIndentationLevel, const TDesC& aLog, TChar aChar);
+		
+		// Inline methods:
+		
+		inline RFs& Fs();
+		inline CSBEClient* BackupClient() const;
+		inline CStorageManager* StorageManager() const;
+		inline const RTransferTypeArray& TransferTypes() const;
+		
+	public:
+		RSIDArray iSidArray;
+		
+	private:
+		HBufC* GetIndentation(TInt aLevel);
+		
+	protected:
+		// Methods required by both CTestStepBackup as well CTestStepRestore:
+		void ProcessUserOptionsL();
+		
+		void PrepareForPartialBURL();
+		
+		void PopulateListOfDataOwnersL();
+		
+		void SetBURModeL(TBURPartType aBURPartType, TBackupIncType aBackupIncType);
+		
+		void CreateStorageManagerL();
+		
+		void GenerateSIDTransferTypesL(RTransferTypeArray& aTransferTypes, TTransferDataType aDataType);
+		
+		void GeneratePIDTransferTypesL(RTransferTypeArray& aTransferTypes, TPackageDataType aPkgDataType = ESystemData);
+		
+		void GenerateJavaTransferTypesL(RTransferTypeArray& aTransferTypes, TJavaTransferType aJavaTransferType);
+		
+		void SupplyDataL(RTransferTypeArray& aTransferTypes);
+		
+		void SaveDataOwners();
+		
+		void CheckSIDStatusL(RTransferTypeArray& aTransferTypes, RTransferTypeArray& aReadyArray);
+		
+		TSecureId ExtractIDL(CDataOwnerInfo& aDataOwner);
+		
+		void DoSupplyL(TTransferDataType aDataType);
+		
+		HBufC* ExtractJavaIDL(CDataOwnerInfo& aDataOwner);
+		
+		void CheckValidRegistrationL();
+		
+		void SetSIDListForPartialL();
+		
+		void GeneratePublicTransferTypesL(RPointerArray<CSBGenericDataType>& aTransferTypes);
+		
+		//async methods
+		void PopulateListOfDataOwnersAsyncL();
+		
+		void SetBURModeAsyncL(TBURPartType aBURPartType, TBackupIncType aBackupIncType);
+		
+		
+	protected:
+		/** Test server the test step belongs to: */
+		CBURTestServer& iParentTestServer;
+		
+		/** Data owners */
+		RDataOwnerArray iDataOwners;
+		
+		/** Backup server client */
+		CSBEClient* iBackupClient;
+		
+		/** User defined parameters read in by TestExecute config parser */
+		TFileName iBackupDirName;
+		TBackupIncType iBackupIncType;
+		TBool iIsPartial;
+		TDriveList iDriveList;
+		
+		/** Number of failures */
+		TInt iFailures;
+		
+		/** Storage handler for archiving backup data */
+		CStorageManager* iStorageManager;
+		
+		/** Active scheduler for this test step's thread */
+		CActiveScheduler* iActiveScheduler;
+		
+		/** File server session for use by all derived classes */
+		RFs iFs;
+		
+		/** Array of suite Hashes */
+		RArray<TPtrC> iJidArray;
+		
+		/** Restore or Backup ? */
+		TBackupMode iMode;
+		
+		/** waited for active to become ready? */
+		TBool iWaitedForActive;
+		
+		/** Array of transfer types */
+		RTransferTypeArray iTransferTypes;
+		};
+		
+	// INLINE METHODS:
+	inline RFs& CBURTestStepBase::Fs()
+		/**
+		Provides access to the central file server session.
+		
+		@released
+		@internalComponent
+		
+		@return An RFs file server session.
+		*/
+		{
+		return iFs; 
+		}
+	
+	inline CSBEClient* CBURTestStepBase::BackupClient() const
+		/**
+		Provides access to the backup client.
+		
+		@released
+		@internalComponent
+		
+		@return A pointer to the backup client.
+		*/
+		{
+		return iBackupClient;
+		}
+	
+	inline CStorageManager* CBURTestStepBase::StorageManager() const
+		/**
+		Provides access to the stroage manager.
+		
+		@released
+		@internalComponent
+		
+		@return A pointer to the storage manager.
+		*/
+		{
+		return iStorageManager;
+		}
+		
+	inline const RTransferTypeArray& CBURTestStepBase::TransferTypes() const
+		/**
+		Provides access to the Transfer Types.
+		
+		@released
+		@internalComponent
+		
+		@return A reference to the transfer types.
+		*/
+		{
+		return iTransferTypes;
+		}
+
+	/**
+	A Simple Active Object class for simulating Asyncrnous calls.
+	*/	
+	class CBURActiveObject : public CActive
+		{
+	public:
+		static CBURActiveObject* NewL();
+		~CBURActiveObject();
+		
+		void StartL();
+		TInt Error();
+		
+	protected:
+		void DoCancel();
+		void RunL();
+		TInt RunError(TInt aError);
+		
+	private:
+		CBURActiveObject();
+		void ConstructL();
+		
+	private:
+		CActiveSchedulerWait* iActiveScheduler;
+		TInt iError;
+		};
+	
+	} // end of namespace
+
+#endif // __T_BUR_TEST_STEP_BASE_H__
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/TestSteps/inc/t_teststepbackup.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,101 @@
+/**
+* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file
+ @released
+*/
+
+#ifndef __T_BUR_TEST_STEP_BACKUP_H__
+#define __T_BUR_TEST_STEP_BACKUP_H__
+
+#include "t_burteststepbase.h"
+#include "t_asyncbackuptransferhandler.h"
+
+_LIT(KBURTestBackup, "TestBackup");
+
+namespace bur_ts
+	{
+	// Forward declaration
+	class CAsyncBackupTransferHandler;
+	
+	class CBURTestStepBackup : public CBURTestStepBase
+		/**
+		Implements the backup operation. 
+		
+		@released
+		@internalComponent
+		*/
+		{
+	public:
+		static CBURTestStepBackup* NewL(CBURTestServer& aTestServer);
+		~CBURTestStepBackup();
+		
+		// Inherited from CTestStep
+		virtual TVerdict doTestStepPreambleL();
+		virtual TVerdict doTestStepPostambleL();
+		virtual TVerdict doTestStepL();
+		
+	private:
+		CBURTestStepBackup(CBURTestServer& aTestServer);
+		void ConstructL();
+		
+		// Core backup function
+		void DoBackupL();
+		void DoActiveBackupL(TTransferDataType aTransferDataType);
+		
+		// Following 2 methods implement sequences of backup operations during 
+		// base and incremental backups respectively
+		void BaseBackupL();
+		void IncrementalBackupL();
+		
+		// Registration data backup handler
+		void BackupRegistrationDataL();
+		
+		// Passive backup handlers
+		void BackupPassiveSnapshotDataL();
+		void SupplyPassiveSnapshotDataL();
+		void BackupPassiveBaseDataL();
+		void BackupPassiveIncDataL();
+		
+		// Active backup handlers
+		void BackupActiveSnapshotDataL();
+		void SupplyActiveSnapshotDataL();
+		void BackupActiveBaseDataL();
+		void BackupActiveIncDataL();
+		
+		// Packages backup
+		void SupplySystemSnapshotDataL();
+		void BackupSystemSnapshotDataL();
+		void BackupSystemBaseDataL();
+		
+		// java
+		void BackupJavaMidletsL();
+		void BackupJavaMidletsDataL();
+		
+		// public
+		void BackupPublicDataL();
+		void DoPublicBackupL(RPointerArray<CSBGenericDataType>& aTransferTypes);
+	
+	private:
+		/** Handler for async data requests */
+		CAsyncBackupTransferHandler* iDataTransferHandler;
+		};
+	}
+#endif // __T_BUR_TEST_STEP_BACKUP_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/TestSteps/inc/t_teststepbackupasync.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,103 @@
+/**
+* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+* T_TestStepBackup.h
+* 
+*
+*/
+
+
+
+/**
+ @file
+ @released
+*/
+
+#ifndef T_TESTSTEPBACKUPASYNC_H
+#define T_TESTSTEPBACKUPASYNC_H
+
+#include "t_burteststepbase.h"
+#include "t_asyncbackuptransferhandler.h"
+
+_LIT(KBURTestBackupAsync, "TestBackupAsync");
+
+namespace bur_ts
+	{
+	// Forward declaration
+	class CAsyncBackupTransferHandler;
+	
+	class CBURTestStepBackupAsync : public CBURTestStepBase
+		/**
+		Implements the backup operation. 
+		
+		@released
+		@internalComponent
+		*/
+		{
+	public:
+		static CBURTestStepBackupAsync* NewL(CBURTestServer& aTestServer);
+		~CBURTestStepBackupAsync();
+		
+		// Inherited from CTestStep
+		virtual TVerdict doTestStepPreambleL();
+		virtual TVerdict doTestStepPostambleL();
+		virtual TVerdict doTestStepL();
+		
+	private:
+		CBURTestStepBackupAsync(CBURTestServer& aTestServer);
+		void ConstructL();
+		
+		// Core backup function
+		void DoBackupL();
+		void DoActiveBackupL(TTransferDataType aTransferDataType);
+		
+		// Following 2 methods implement sequences of backup operations during 
+		// base and incremental backups respectively
+		void BaseBackupL();
+		void IncrementalBackupL();
+		
+		// Registration data backup handler
+		void BackupRegistrationDataL();
+		
+		// Passive backup handlers
+		void BackupPassiveSnapshotDataL();
+		void SupplyPassiveSnapshotDataL();
+		void BackupPassiveBaseDataL();
+		void BackupPassiveIncDataL();
+		
+		// Active backup handlers
+		void BackupActiveSnapshotDataL();
+		void SupplyActiveSnapshotDataL();
+		void BackupActiveBaseDataL();
+		void BackupActiveIncDataL();
+		
+		// Packages backup
+		void SupplySystemSnapshotDataL();
+		void BackupSystemSnapshotDataL();
+		void BackupSystemBaseDataL();
+		
+		// java
+		void BackupJavaMidletsL();
+		void BackupJavaMidletsDataL();
+		
+		// public
+		void BackupPublicDataL();
+		void DoPublicBackupL(RPointerArray<CSBGenericDataType>& aTransferTypes);
+	
+	private:
+		/** Handler for async data requests */
+		CAsyncBackupTransferHandler* iDataTransferHandler;
+		};
+	}
+#endif // T_TESTSTEPBACKUPASYNC_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/TestSteps/inc/t_teststeprestore.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,83 @@
+/**
+* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+/**
+ @file
+ @released
+*/
+
+#ifndef __T_BUR_TEST_STEP_RESTORE_H__
+#define __T_BUR_TEST_STEP_RESTORE_H__
+
+#include "t_burteststepbase.h"
+
+_LIT(KBURTestRestore, "TestRestore");
+
+namespace bur_ts
+	{
+
+	class CBURTestStepRestore : public CBURTestStepBase
+		/**
+		Implements the restore operation.
+		
+		@released
+		@internalComponent
+		*/
+		{
+	public:
+		static CBURTestStepRestore* NewL(CBURTestServer& aTestServer);
+		~CBURTestStepRestore();
+		
+		// Inherited from CTestStep
+		virtual TVerdict doTestStepPreambleL();
+		virtual TVerdict doTestStepPostambleL();
+		virtual TVerdict doTestStepL();
+		
+	private:
+		CBURTestStepRestore(CBURTestServer& aTestServer);
+		void ConstructL();
+		
+		void BaseRestoreL();
+		void IncrementalRestoreL();
+		
+		// Registration data restore handler
+		void SupplyRegistrationDataL();
+		
+		// Passive restore handlers
+		void SupplyPassiveSnapshotDataL();
+		void RestorePassiveBaseDataL();
+		void RestorePassiveIncDataL();
+		
+		// Active restore handlers
+		void SupplyActiveSnapshotDataL();
+		void RestoreActiveBaseDataL();
+		void RestoreActiveIncDataL();
+		
+		// Restore packages
+		void SupplySystemSnapshotDataL();
+		void RestoreSystemBaseDataL();
+		
+		// java
+		void RestoreJavaMidletL();
+		void RestoreJavaMidletDataL();
+		};
+	}
+
+#endif // __T_BUR_TEST_STEP_RESTORE_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/TestSteps/inc/t_teststeprestoreasync.h	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,85 @@
+/**
+* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+* T_TestStepRestore.h
+* 
+*
+*/
+
+
+
+/**
+ @file
+ @released
+*/
+
+#ifndef T_TESTSTEPRESTOREASYNC_H
+#define T_TESTSTEPRESTOREASYNC_H
+
+#include "t_burteststepbase.h"
+
+_LIT(KBURTestRestoreAsync, "TestRestoreAsync");
+
+namespace bur_ts
+	{
+
+	class CBURTestStepRestoreAsync : public CBURTestStepBase
+		/**
+		Implements the restore operation.
+		
+		@released
+		@internalComponent
+		*/
+		{
+	public:
+		static CBURTestStepRestoreAsync* NewL(CBURTestServer& aTestServer);
+		~CBURTestStepRestoreAsync();
+		
+		// Inherited from CTestStep
+		virtual TVerdict doTestStepPreambleL();
+		virtual TVerdict doTestStepPostambleL();
+		virtual TVerdict doTestStepL();
+		
+	private:
+		CBURTestStepRestoreAsync(CBURTestServer& aTestServer);
+		void ConstructL();
+		
+		void BaseRestoreL();
+		void IncrementalRestoreL();
+		
+		// Registration data restore handler
+		void SupplyRegistrationDataL();
+		
+		// Passive restore handlers
+		void SupplyPassiveSnapshotDataL();
+		void RestorePassiveBaseDataL();
+		void RestorePassiveIncDataL();
+		
+		// Active restore handlers
+		void SupplyActiveSnapshotDataL();
+		void RestoreActiveBaseDataL();
+		void RestoreActiveIncDataL();
+		
+		// Restore packages
+		void SupplySystemSnapshotDataL();
+		void RestoreSystemBaseDataL();
+		
+		// java
+		void RestoreJavaMidletL();
+		void RestoreJavaMidletDataL();
+		};
+	}
+
+#endif // T_TESTSTEPRESTOREASYNC_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/TestSteps/src/t_burteststepbase.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,1407 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @released
+*/
+
+#include "t_burteststepbase.h"
+
+namespace bur_ts
+	{
+	_LIT(KTabText, "\t|");
+	_LIT(KFormatText2, "%S%S");
+	_LIT(KFormatText3, "%S%S%S");
+	_LIT(KFormatText4, "%S%S%d");
+	_LIT(KFormatText5, "%S%S%X");
+	_LIT(KFormatText6, "%S%S%s");
+	
+	const TUint8 KMaxHexLength = 8;
+	
+	CBURTestStepBase::CBURTestStepBase(CBURTestServer& aParent) 
+		/**
+		C++ Constructor
+		
+		@internalComponent
+		@released
+		
+		@param aParent - The parent CBURTestServer of this child test step.
+		*/
+		:iParentTestServer(aParent),
+		iBackupClient(NULL),
+		iBackupIncType(EBackupBase),
+	 	iIsPartial(EFalse),
+		iFailures(KErrNone),
+		iStorageManager(NULL),
+		iMode(EBackupMode),
+		iWaitedForActive(EFalse)
+		{}
+	
+	CBURTestStepBase::~CBURTestStepBase()
+		/**
+		C++ Destructor
+		@internalComponent
+		@released
+		*/
+		{
+		iDataOwners.ResetAndDestroy();
+		iDataOwners.Close();
+			
+		iSidArray.Close();
+		iJidArray.Close();
+		
+		iFs.Close();
+		
+		iTransferTypes.ResetAndDestroy();
+		iTransferTypes.Close();
+		
+		delete iStorageManager;
+		delete iActiveScheduler;
+		
+		delete iBackupClient;
+		}
+	
+	// LOGGING METHODS
+	void CBURTestStepBase::Log(TUint aIndentationLevel, const TDesC& aLog)
+		/**
+		Logs the data inside the string as text string at aIndentationLevel.
+		
+		@internalComponent
+		@released
+		
+		@param aIndentationLevel - The indentation level in the TestExecute test report.
+		@param aLog - The message to be logged.
+		*/
+		{
+		HBufC* indentation = NULL;
+		indentation = GetIndentation(aIndentationLevel);
+		TPtr ptr = indentation->Des();
+		INFO_PRINTF3(KFormatText2, &ptr, &aLog);
+		delete indentation;
+		}
+	
+	void CBURTestStepBase::LogWithText(TUint aIndentationLevel, const TDesC& aLog, const TDesC& aText)
+		/**
+		Writes the message with a text string.
+		
+		@internalComponent
+		@released
+		
+		@param aIndentationLevel - The indentation level in the TestExecute test report.
+		@param aLog - The message to be logged.
+		@param aText - Textual data to be logged with the main message.
+		*/
+		{
+		HBufC* indentation = NULL;
+		indentation = GetIndentation(aIndentationLevel);
+		TPtr ptr = indentation->Des();
+		INFO_PRINTF4(KFormatText3, &ptr, &aLog, &aText);
+		delete indentation;
+		}
+	
+	void CBURTestStepBase::LogWithText8(TUint aIndentationLevel, const TDesC& aLog, const TDesC8& aText)
+		/**
+		8-bit variant of the above
+		
+		@internalComponent
+		@released
+		
+		@param aIndentationLevel - The indentation level in the TestExecute test report.
+		@param aLog - The message to be logged.
+		@param aText - 8-bit textual data to be logged with the main message.
+		*/
+		{
+		HBufC* indentation = NULL;
+		indentation = GetIndentation(aIndentationLevel);
+		TPtr ptr = indentation->Des();
+		INFO_PRINTF4(KFormatText3, &ptr, &aLog, &aText);
+		delete indentation;
+		}
+	
+	void CBURTestStepBase::LogWithNum(TUint aIndentationLevel, const TDesC& aLog, TInt aNum)
+		/**
+		Writes to the report a number along with a message.
+		
+		@internalComponent
+		@released
+		
+		@param aIndentationLevel - The indentation level in the TestExecute test report.
+		@param aLog - The message to be logged.
+		@param aNum - Number to be printed with the log.
+		*/
+		{
+		HBufC* indentation = NULL;
+		indentation = GetIndentation(aIndentationLevel);
+		TPtr ptr = indentation->Des();
+		INFO_PRINTF4(KFormatText4, &ptr, &aLog, aNum);
+		delete indentation;
+		}
+	
+	void CBURTestStepBase::LogWithSID(TUint aIndentationLevel, const TDesC& aLog, TSecureId aSecureId)
+		/**
+		Writes out a TSecureId as a hexadecimal number along with a message.
+		
+		@internalComponent
+		@released
+		
+		@param aIndentationLevel - The indentation level in the TestExecute test report.
+		@param aLog - The message to be logged.
+		@param aSecureId - A TSecureId to be printed as a hexadecimal number.
+		*/
+		{
+		HBufC* indentation = NULL;
+		indentation = GetIndentation(aIndentationLevel);
+		TPtr ptr = indentation->Des();
+		INFO_PRINTF4(KFormatText5, &ptr, &aLog, aSecureId.iId);
+		delete indentation;
+		}
+	
+	void CBURTestStepBase::LogWithChar(TUint aIndentationLevel, const TDesC& aLog, TChar aChar)
+		/**
+		@internalComponent
+		@released
+		
+		@param aIndentationLevel - The indentation level in the TestExecute test report.
+		@param aLog - The message to be logged.
+		@param aChar - A single char, appended at the end of the message.
+		*/
+		{
+		HBufC* indentation = NULL;
+		indentation = GetIndentation(aIndentationLevel);
+		TPtr ptr = indentation->Des();
+		INFO_PRINTF4(KFormatText6, &ptr, &aLog, &aChar);
+		delete indentation;
+		}
+	
+	HBufC* CBURTestStepBase::GetIndentation(TInt aLevel)
+		/**
+		Generates a string of indentation markers (based on KIndentationMarker) the 
+		level of depth specified by aLevel
+		
+		@internalComponent
+		@released
+		
+		@param aLevel - Level of depth required for indentation.
+		*/
+		{
+		HBufC* hbuf = NULL;
+		
+		// Indentation level times the length of the indentation marker, 
+		// plus room for a tab and a '|'
+		TInt indentationLength = aLevel * KIndentationMarker().Length() + 10;
+		hbuf = HBufC::NewL(indentationLength);
+		
+		hbuf->Des().Append(KTabText);
+		for(TInt i = 0; i < aLevel; ++i)
+			{
+			hbuf->Des().Append(KIndentationMarker);
+			}
+		
+		return hbuf;
+		}
+	
+	void CBURTestStepBase::CreateStorageManagerL()
+		/**
+		Must only be called after the user input has been processed.
+		@internalComponent
+		@released
+		*/
+		{
+		iStorageManager = CStorageManager::NewL(iBackupDirName, iDriveList, this);
+		}
+	
+	void CBURTestStepBase::ProcessUserOptionsL()
+		/**
+		This function uses TestExecute config file parsers to read in the user preferences
+		from ini files
+		
+		@internalComponent
+		@released
+		 */
+		{
+		TPtrC backupDir;
+		TInt isPartial = 0;
+		TInt isBase = 0;
+		TPtrC driveListText;
+		
+		// directory for archiving backup data
+		_LIT(KBackupDirText1, "BackupDir");
+		GetStringFromConfig(ConfigSection(), KBackupDirText1, backupDir);
+		
+		_LIT(KBackupDirText2, "Backup directory: ");
+		LogWithText(LOG_LEVEL3, KBackupDirText2, backupDir);
+		iBackupDirName.Copy(backupDir);
+		
+		// affected drives
+		_LIT(KDriveListText1, "DriveList");
+		GetStringFromConfig(ConfigSection(), KDriveListText1, driveListText);
+		_LIT(KDriveListText2, "Drives: ");
+		
+		LogWithText(LOG_LEVEL3, KDriveListText2, driveListText);
+		// extract all drives from the user input
+		iDriveList = CBURTestStepBase::StringToDriveListL(driveListText);
+		
+		// create the storage handler based on the drives and backup directory
+		CreateStorageManagerL();
+		
+		// full/partial backup
+		_LIT(KPartialText1, "IsPartial");
+		GetIntFromConfig(ConfigSection(), KPartialText1, isPartial);
+		if (isPartial == 0)
+			{
+			iIsPartial = EFalse;
+			
+			_LIT(KPartialText2, "Full/Partial Type: Full");
+			Log(LOG_LEVEL3, KPartialText2);
+			} //if
+		else if (isPartial == 1)
+			{
+			iIsPartial = ETrue;
+			TSecureId sid;
+			
+			TChar ch;
+			TPtrC list;
+			
+			
+			// PARSING ID LIST //
+			
+			_LIT(KSIDList, "IDs");
+			GetStringFromConfig(ConfigSection(), KSIDList, list);
+			TLex sidLex(list);
+		
+			while (!sidLex.Eos())
+				{
+        		sidLex.Mark();
+	        	ch=sidLex.Peek();
+
+    	    	while(!sidLex.Eos() && ( ch=sidLex.Peek() ) != TChar(','))
+        			sidLex.Inc();
+ 
+        		if(!sidLex.TokenLength())
+        			continue;
+        		
+        		TPtrC pToken = sidLex.MarkedToken();
+        		TLex token(pToken);
+        		
+        		if (pToken.Length() <= KMaxHexLength && token.Val(sid.iId, EHex) == KErrNone)
+        			{
+        			iSidArray.Append(sid);
+					_LIT(KFound, "ID Found in ini file: ");
+					LogWithSID(LOG_LEVEL4, KFound, sid);		
+        			} //if
+        		else // must be a Java suite hash
+        			{
+        			iJidArray.Append(pToken);
+        			_LIT(KJFound, "Java ID Found in ini file: ");
+        			LogWithText(LOG_LEVEL4, KJFound, pToken);
+        			}
+				
+        		if(ch==TChar(','))
+        			sidLex.Inc();
+        		
+        		sidLex.SkipSpace();
+        
+				} //while
+				
+			
+			_LIT(KPartialText3, "Full/Partial Type: Partial");
+			Log(LOG_LEVEL3, KPartialText3);
+			} //if
+		else
+			{
+			_LIT(KPartialText4, "Full/Partial Type: UNKNOWN");
+			_LIT(KPartialText5, "** PLEASE USE 0 OR 1 ONLY **");
+			_LIT(KPartialText6, "** Using FULL as default  **");
+			Log(LOG_LEVEL4, KPartialText4);
+			Log(LOG_LEVEL4, KPartialText5);
+			Log(LOG_LEVEL4, KPartialText6);
+			}
+		
+		// base/incremental
+		_LIT(KIncrText1, "BaseOnly");
+		GetIntFromConfig(ConfigSection(), KIncrText1, isBase);
+		if (isBase == 1)
+			{
+			iBackupIncType = EBackupBase;
+			
+			_LIT(KIncrText2, "Base/Incremental Type: Base Only");
+			Log(LOG_LEVEL3, KIncrText2);
+			}
+		else if (isBase == 0)
+			{
+			iBackupIncType = EBackupIncrement;
+			
+			_LIT(KIncrText3, "Base/Incremental Type: Incremental by Default");
+			Log(LOG_LEVEL3, KIncrText3);
+			}
+		else
+			{
+			_LIT(KIncrText4, "Base/Incremental Type: UNKNOWN");
+			_LIT(KIncrText5, "** PLEASE USE 0 OR 1 ONLY **");
+			_LIT(KIncrText6, "** Using BASE as default  **");
+			Log(LOG_LEVEL4, KIncrText4);
+			Log(LOG_LEVEL4, KIncrText5);
+			Log(LOG_LEVEL4, KIncrText6);
+			}
+		}
+		
+	
+	void CBURTestStepBase::PopulateListOfDataOwnersL()
+		/**
+		Uses CSBEClient::ListOfDataOwnersL() to extract a list of data owners that have 
+		registred for backup and restore. Populates iDataOwners.
+		
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KTempText1, "Getting list of data owners from device");
+		Log(LOG_LEVEL2,KTempText1);
+		
+		TRAPD(err, iBackupClient->ListOfDataOwnersL(iDataOwners));
+		if (err != KErrNone)
+			{
+			_LIT(KTempText1, "Error getting list of data owners: ");
+			LogWithNum(LOG_LEVEL2,KTempText1, err);
+			iFailures++;
+			}
+
+		// Log
+		if (iDataOwners.Count() == 0)
+			{
+			_LIT(KTempText3, "No data owners found.");
+			Log(LOG_LEVEL3, KTempText3);
+			}
+		else
+			{
+			_LIT(KTempText4, "Number of data owners found on device: ");
+			LogWithNum(LOG_LEVEL3, KTempText4, iDataOwners.Count());
+			}
+		}
+		
+	void CBURTestStepBase::PopulateListOfDataOwnersAsyncL()
+		/**
+		Uses CSBEClient::ListOfDataOwnersL() to extract a list of data owners that have 
+		registred for backup and restore. Populates iDataOwners.
+		
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KTempText1, "Getting list of data owners from device");
+		Log(LOG_LEVEL2,KTempText1);
+		CBURActiveObject* active = CBURActiveObject::NewL();
+		CleanupStack::PushL(active);
+		TRAPD(err, iBackupClient->ListOfDataOwnersL(iDataOwners, active->iStatus));
+		if (err == KErrNone)
+			{
+			active->StartL();
+			}
+			
+		if (err != KErrNone || active->Error() != KErrNone)
+			{
+			_LIT(KTempText1, "Error getting list of data owners: ");
+			LogWithNum(LOG_LEVEL2,KTempText1, err);
+			iFailures++;
+			}
+		CleanupStack::PopAndDestroy(active);
+		
+		// Log
+		if (iDataOwners.Count() == 0)
+			{
+			_LIT(KTempText3, "No data owners found.");
+			Log(LOG_LEVEL3, KTempText3);
+			}
+		else
+			{
+			_LIT(KTempText4, "Number of data owners found on device: ");
+			LogWithNum(LOG_LEVEL3, KTempText4, iDataOwners.Count());
+			}
+		}
+	
+	void CBURTestStepBase::SetBURModeL(TBURPartType aBURPartType, TBackupIncType aBackupIncType)
+		/**
+		Uses CSBEClient::SetBURModeL() to set backup and restore settings
+		
+		@internalComponent
+		@released
+		
+		@param aBURPartType - Full/Partial backup/restore.
+		@param aBackupIncType - Base/Incremental backup/restore.
+		*/
+		{
+		iBackupClient->SetBURModeL(iDriveList, aBURPartType, aBackupIncType);
+		}
+	
+	void CBURTestStepBase::SetBURModeAsyncL(TBURPartType aBURPartType, TBackupIncType aBackupIncType)
+		/**
+		Uses CSBEClient::SetBURModeL() Asyncrhonous version to set backup and restore settings
+		
+		@internalComponent
+		@released
+		
+		@param aBURPartType - Full/Partial backup/restore.
+		@param aBackupIncType - Base/Incremental backup/restore.
+		*/
+		{
+		CBURActiveObject* active = CBURActiveObject::NewL();
+		CleanupStack::PushL(active);
+		iBackupClient->SetBURModeL(iDriveList, aBURPartType, aBackupIncType, active->iStatus);
+		active->StartL();
+		User::LeaveIfError(active->Error());
+		CleanupStack::PopAndDestroy(active);
+		}
+	
+	void CBURTestStepBase::PrepareForPartialBURL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		TSecureId sid = NULL;
+		
+		// go through list of pids and sids
+		for (TInt index = 0; index < iDataOwners.Count(); index++)
+			{
+			TBool notFound = ETrue;
+			sid = ExtractIDL(*iDataOwners[index]);
+			
+			if (sid != NULL)
+				{
+				TInt position = iSidArray.Find(sid);
+				if (position != KErrNotFound)
+					{
+					_LIT(KTempText2, "ID found in list of data owners: ");
+					LogWithSID(LOG_LEVEL3, KTempText2, sid);
+					notFound = EFalse;
+					}
+				else if (position == KErrNotFound)
+					{
+					notFound = ETrue;
+					} // if else
+				} // if
+			else // possibly jid
+				{
+				HBufC* pSuiteHash = ExtractJavaIDL(*iDataOwners[index]);
+				TPtrC suiteHash = pSuiteHash->Des();
+				if (iJidArray.Find(suiteHash) != KErrNotFound)
+					{
+					_LIT(KTempText3, "Java ID found in list of data owners: ");
+					LogWithText(LOG_LEVEL3, KTempText3, suiteHash);
+					notFound = EFalse;
+					}
+				else // not found 
+					{
+					notFound = ETrue;
+					}
+				delete pSuiteHash;
+				pSuiteHash = NULL;
+				}
+			if (notFound)
+				{
+				delete iDataOwners[index];
+				iDataOwners[index] = NULL;
+				iDataOwners.Remove(index);
+				index--;
+				}
+			}
+		}
+		
+	void CBURTestStepBase::SetSIDListForPartialL()
+	/**
+	Set the list of active data owners for partial bur
+	
+	@param aDataOwners List of data owners for partial bur
+	*/
+		{
+		iSidArray.Reset();
+		for (TInt i=0; i< iDataOwners.Count(); i++)
+			{
+			if (iDataOwners[i]->CommonSettings() & EActiveBUR)
+				{
+				TSBDerivedType type = iDataOwners[i]->Identifier().DerivedTypeL();
+				if (type == ESIDDerivedType)
+					{
+					// means it is definately a sid
+					CSBSecureId* secureId = CSBSecureId::NewL(&(iDataOwners[i]->Identifier()));
+					CleanupStack::PushL(secureId);
+						
+					iSidArray.AppendL(secureId->SecureIdL());
+					CleanupStack::PopAndDestroy(secureId);
+					}
+				else if (type == EPackageDerivedType)
+					{
+					CSBPackageId* packageId = CSBPackageId::NewL(&(iDataOwners[i]->Identifier()));
+					CleanupStack::PushL(packageId);
+					
+					iSidArray.AppendL(packageId->SecureIdL());
+					CleanupStack::PopAndDestroy(packageId);
+					}
+				} //if
+			}// for
+		
+		// set active owners array	
+		TRAPD(err,iBackupClient->SetSIDListForPartialBURL(iSidArray));
+		if (err != KErrNone)
+			{
+			iFailures++;
+			_LIT(KSidP, "Error Setting list for partial : ");
+			LogWithNum(LOG_LEVEL3, KSidP, err);
+			}
+		}
+		
+	void CBURTestStepBase::GenerateSIDTransferTypesL(RTransferTypeArray& aTransferTypes, TTransferDataType aDataType)
+		/**
+		For each data owner in iDataOwners, this method creates CSBGenericTransferTypes
+		based on the TTransferDataType passed. One transfer type is created per drive that
+		the data owner in question has data on. Only creates transfer types supported by data owner
+		
+		@internalComponent
+		@released
+		
+		@param aTransferTypes - Array of transfer types.
+		@param aDataType - Trasnfer data type, passive base, active base, etc.
+		*/
+		{
+		TTransferDataType tempDataType = aDataType;
+		aTransferTypes.ResetAndDestroy();
+		TSecureId sid = NULL;
+		
+		TInt length = iDriveList.Length();
+		for (TInt driveCount = 0; driveCount < length; driveCount++)
+			{
+			if (iDriveList[driveCount])
+				{
+				for (TInt i = 0; i < iDataOwners.Count(); i++)
+					{
+					if (iDataOwners[i]->Identifier().DerivedTypeL() == ESIDDerivedType)
+						{
+						CSBSecureId* secureId = CSBSecureId::NewL(&(iDataOwners[i]->Identifier()));
+						CleanupStack::PushL(secureId);
+						
+						sid = secureId->SecureIdL();
+						
+						CleanupStack::PopAndDestroy(secureId);
+						}
+					else if (iDataOwners[i]->Identifier().DerivedTypeL() == EPackageDerivedType)
+						{						
+						CSBPackageId* pkgId = CSBPackageId::NewL(&(iDataOwners[i]->Identifier()));
+						CleanupStack::PushL(pkgId);
+					
+						sid = pkgId->SecureIdL();
+						
+						CleanupStack::PopAndDestroy(pkgId);	
+						} // else if
+					
+					if (sid != NULL)
+						{
+						// decides if data owner supports that data type
+						
+						TBool checkIfHaveBase = EFalse;
+						TBool baseOnly = EFalse;
+						TBool supports = EFalse;
+						switch (aDataType)
+							{
+							case ERegistrationData:
+								supports = EFalse;
+								break;
+							case EPassiveBaseData:
+								if (iDataOwners[i]->CommonSettings() & EPassiveBUR)
+									{
+									supports = ETrue;
+									}
+								break;
+							case EPassiveSnapshotData:
+								if (iDataOwners[i]->PassiveSettings() & EPassiveSupportsInc)
+									{
+									supports = ETrue;
+									}
+								break;
+							case EPassiveIncrementalData:
+								if (iDataOwners[i]->CommonSettings() & EPassiveBUR)
+									{
+									if (!(iDataOwners[i]->PassiveSettings() & EPassiveSupportsInc) && !iMode)
+										{
+										_LIT(KPsIncDt, "Base only for SID: ");
+										LogWithSID(LOG_LEVEL3, KPsIncDt, sid);
+										baseOnly = ETrue;
+										supports = ETrue;
+										aDataType = EPassiveBaseData;
+										}
+									else if (iDataOwners[i]->PassiveSettings() & EPassiveSupportsInc)
+										{
+										checkIfHaveBase = ETrue;
+										}
+									} // if
+								break;
+							case EActiveSnapshotData:
+								if (iDataOwners[i]->ActiveSettings() & EActiveSupportsInc)
+									{
+									supports = ETrue;
+									}
+								break;
+							case EActiveIncrementalData:
+								if (iDataOwners[i]->CommonSettings() & EActiveBUR)
+									{
+									if (!(iDataOwners[i]->ActiveSettings() & EActiveSupportsInc) && !iMode)
+										{
+										_LIT(KAcIncDt, "Base only for SID: ");
+										LogWithSID(LOG_LEVEL3, KAcIncDt, sid);
+										baseOnly = ETrue;
+										supports = ETrue;
+										aDataType = EActiveBaseData;
+										}
+									else if (iDataOwners[i]->ActiveSettings() & EActiveSupportsInc)
+										{
+										checkIfHaveBase = ETrue;
+										}	
+									} // if
+								break;
+							case EActiveBaseData:
+								if (iDataOwners[i]->CommonSettings() & EActiveBUR)
+									{
+									supports = ETrue;
+									}
+								break;
+							} //switch
+						
+						
+						if (checkIfHaveBase)
+							{
+							TTransferDataType dType;
+							if (aDataType == EActiveIncrementalData)
+								{
+								dType = EActiveBaseData;
+								}
+							else
+								{
+								dType = EPassiveBaseData;
+								} // if else
+								
+							CSBSIDTransferType* tType = CSBSIDTransferType::NewL(sid, TDriveNumber(driveCount), dType);
+							CleanupStack::PushL(tType);
+							TFileName fileName;
+							iStorageManager->GetFileNameL(tType, fileName, EFalse);
+							if(iStorageManager->IsFileExists(fileName))
+								{
+								supports = ETrue;
+								}
+							else 
+								{
+								_LIT(KTempText2, "No increments found use Base instead for SID: ");
+								LogWithSID(LOG_LEVEL3, KTempText2, sid);
+								supports = ETrue;
+								aDataType = dType;
+								baseOnly = ETrue;
+								}
+							CleanupStack::PopAndDestroy(tType);
+							} // if check if have base
+											
+						
+						if (supports)
+							{
+							CSBSIDTransferType* sidType = CSBSIDTransferType::NewL(sid, TDriveNumber(driveCount), aDataType);
+							CleanupStack::PushL(sidType);
+							aTransferTypes.AppendL(sidType);
+							CleanupStack::Pop(sidType);
+							} // if else
+						
+						// change to the proper dataType if base only true	
+						if (baseOnly)
+							{
+							aDataType = tempDataType;
+							}
+						sid = NULL;	
+						}// if
+					} // for		
+				} // if
+			} //for
+		}
+		
+	void CBURTestStepBase::GeneratePIDTransferTypesL(RTransferTypeArray& aTransferTypes, TPackageDataType aPkgDataType)
+		/**
+		For each data owner in iDataOwners, this method creates CSBGenericTransferTypes
+		based on the TTransferDataType passed. One transfer type is created per drive that
+		the data owner in question has data on.
+		
+		@internalComponent
+		@released
+		
+		@param aTransferTypes - Array of transfer types.
+		@param aDataType - Trasnfer data type, passive base, active base, etc.
+		*/
+		{
+		aTransferTypes.ResetAndDestroy();
+		TUid id;
+		//need array to avoid duplications
+		RArray<TUid> uidArray;
+		CleanupClosePushL(uidArray);
+		
+		TInt length = iDriveList.Length();
+		for (TInt driveCount = 0; driveCount < length; driveCount++)
+			{
+			if (iDriveList[driveCount])
+				{
+				TInt count = iDataOwners.Count();
+				for (TInt i = 0; i < count; i++)
+					{
+					switch (iDataOwners[i]->Identifier().DerivedTypeL())
+						{
+						case EPackageDerivedType:
+							if (iDataOwners[i]->CommonSettings() & EHasSystemFiles)
+								{
+								CSBPackageId* pkgId = CSBPackageId::NewL(&(iDataOwners[i]->Identifier()));
+								CleanupStack::PushL(pkgId);
+							
+								id = pkgId->PackageIdL();
+								if (uidArray.Find(id) == KErrNotFound)
+									{
+									CSBPackageTransferType* idType = CSBPackageTransferType::NewL(id, TDriveNumber(driveCount), aPkgDataType);
+									CleanupStack::PushL(idType);
+									aTransferTypes.AppendL(idType);
+									CleanupStack::Pop(idType);
+									//add to uid array
+									uidArray.AppendL(id);
+									}
+								CleanupStack::PopAndDestroy(pkgId);	
+								} //if
+							break;
+						} // switch
+					} //for		
+				} //if	
+			} //for
+		CleanupStack::PopAndDestroy(&uidArray);
+		}
+		
+	void CBURTestStepBase::GenerateJavaTransferTypesL(RTransferTypeArray& aTransferTypes, TJavaTransferType aJavaTransferType)
+		/**
+		For each data owner in iDataOwners, this method creates CSBGenericTransferTypes
+		based on the TTransferDataType passed. One transfer type is created per drive that
+		the data owner in question has data on.
+		
+		@internalComponent
+		@released
+		
+		@param aTransferTypes - Array of transfer types.
+		@param aJavaTransferType - Trasnfer data type
+		*/
+		{
+		aTransferTypes.ResetAndDestroy();
+		
+		TInt length = iDriveList.Length();
+		for (TInt driveCount = 0; driveCount < length; driveCount++)
+			{
+			if (iDriveList[driveCount])
+				{
+				TInt count = iDataOwners.Count();
+				for (TInt i=0; i < count; i++)
+					{
+					switch (iDataOwners[i]->Identifier().DerivedTypeL())
+						{
+						case EJavaDerivedType:
+							{
+							if ((aJavaTransferType == EJavaMIDlet && (iDataOwners[i]->CommonSettings() & EHasSystemFiles)) || aJavaTransferType == EJavaMIDletData)
+								{
+								CSBJavaId* javaId = CSBJavaId::NewL(&(iDataOwners[i]->Identifier()));
+								CleanupStack::PushL(javaId);
+								const TDesC& suiteHash = javaId->SuiteHashL();
+								CSBJavaTransferType* javaType = CSBJavaTransferType::NewL(suiteHash, TDriveNumber(driveCount), aJavaTransferType);
+								CleanupStack::PushL(javaType);
+								aTransferTypes.AppendL(javaType);
+								CleanupStack::Pop(javaType);
+								CleanupStack::PopAndDestroy(javaId);
+								}//if
+							} 
+							break;
+						} // switch
+					} //for
+				} // if
+			} // for
+		}
+		
+	
+	void CBURTestStepBase::GeneratePublicTransferTypesL(RPointerArray<CSBGenericDataType>& aTransferTypes)
+		/**
+		For each data owner in iDataOwners, this method creates CSBGenericTransferTypes
+		based on the TTransferDataType passed. One transfer type is created per drive that
+		the data owner in question has data on.
+		
+		@internalComponent
+		@released
+		
+		@param aTransferTypes - Array of transfer types.
+		@param aDataType - Trasnfer data type, passive base, active base, etc.
+		*/
+		{
+		aTransferTypes.ResetAndDestroy();
+
+		TInt count = iDataOwners.Count();
+		for (TInt i = 0; i < count; i++)
+			{
+			switch (iDataOwners[i]->Identifier().DerivedTypeL())
+				{
+				case EPackageDerivedType:
+				case ESIDDerivedType:
+					if (iDataOwners[i]->PassiveSettings() & EHasPublicFiles)
+						{
+						const TDesC8& desc = iDataOwners[i]->Identifier().Externalise();
+						CSBGenericDataType* idType = CSBGenericDataType::NewL(desc);
+						CleanupStack::PushL(idType);
+						aTransferTypes.AppendL(idType);
+						CleanupStack::Pop(idType);
+						} //if
+					break;
+				} // switch
+			}
+		}
+	
+	
+	void CBURTestStepBase::SupplyDataL(RTransferTypeArray& aTransferTypes)
+		/**
+		Retrieves data from the storage handler and supplies to the backup client for 
+		the given transfer type
+		
+		@internalComponent
+		@released
+		
+		@param aTransferTypes - Array of transfer types.
+		*/
+		{
+		TInt transferTypesCount = aTransferTypes.Count();
+		for(TInt currentIndex = 0; currentIndex < transferTypesCount; ++currentIndex)
+			{
+			TInt error;		
+			TInt increments = 0;
+			TInt incrIndex = 1;
+			
+			TSBDerivedType dataType = aTransferTypes[currentIndex]->DerivedTypeL();
+			
+			// check for incremental data
+			switch(dataType)
+				{
+				case ESIDTransferDerivedType:
+					{
+					CSBSIDTransferType* type = CSBSIDTransferType::NewL(aTransferTypes[currentIndex]);
+					CleanupStack::PushL(type);
+					
+					_LIT(KSid, "Supplying data for ID: ");
+					LogWithSID(LOG_LEVEL3, KSid, type->SecureIdL());
+					
+					if (type->DataTypeL() == EActiveIncrementalData || type->DataTypeL() == EPassiveIncrementalData)
+						{
+						increments = iStorageManager->TotalIncFiles(type);
+						if (!increments)
+							{
+							_LIT(KErrorText2, "No increments found");
+							Log(LOG_LEVEL4, KErrorText2);
+							// cleanup
+							CleanupStack::PopAndDestroy(type);
+							continue;
+							}
+						else 
+							{
+							_LIT(KIncFound, "Number of increments found: ");
+							LogWithNum(LOG_LEVEL4, KIncFound, increments);
+							} // else if
+						} // if
+					CleanupStack::PopAndDestroy(type);
+					}
+					break;
+				case EPackageTransferDerivedType:
+					{
+					// package stuff
+					CSBPackageTransferType* pType = CSBPackageTransferType::NewL(aTransferTypes[currentIndex]);
+					CleanupStack::PushL(pType);
+					_LIT(KPid, "Supplying data for Package ID: ");
+					LogWithSID(LOG_LEVEL3, KPid, pType->PackageIdL());
+					CleanupStack::PopAndDestroy(pType);
+					}
+					break;
+				case EJavaTransferDerivedType:
+					{
+					// java stuff
+					CSBJavaTransferType* jType = CSBJavaTransferType::NewL(aTransferTypes[currentIndex]);
+					CleanupStack::PushL(jType);
+					_LIT(KJid, "Supplying data for Java SuiteHash: ");
+					LogWithText(LOG_LEVEL3, KJid, jType->SuiteHashL());
+					CleanupStack::PopAndDestroy(jType);
+					}
+					break;
+				
+				} // switch
+			TBool runAgain = ETrue;		
+			do 
+				{
+				TBool finished;				
+				TPtr8* bufferPtr = NULL;
+				TRAP(error, bufferPtr = &iBackupClient->TransferDataAddressL());
+				if (error != KErrNone)
+					{
+					_LIT(KErrTDA, "Error getting TransferDataAddress: ");
+					LogWithNum(LOG_LEVEL4, KErrTDA, error);
+					break;
+					}
+				TRAP(error, iStorageManager->RetrieveDataL(aTransferTypes[currentIndex], *bufferPtr, finished, incrIndex));
+				if (error != KErrNone)
+					{
+					iStorageManager->Reset();
+					if (error == KErrPathNotFound || error == KErrNotFound)
+						{
+						_LIT(KErrorText2, "Data doesn't exists");
+						Log(LOG_LEVEL4, KErrorText2);
+						}
+					else
+						{
+						_LIT(KErrorText1, "Error reading from archive: ");
+						LogWithNum(LOG_LEVEL4, KErrorText1, error);
+						iFailures++;
+						}
+					break;
+					} 
+				else
+					{
+					_LIT(KLogBytes, "Number of bytes to send: ");
+					LogWithNum(LOG_LEVEL4, KLogBytes, bufferPtr->Length());	
+			
+					TRAP(error, iBackupClient->SupplyDataL(*aTransferTypes[currentIndex], finished));
+					if (error != KErrNone)
+						{
+						_LIT(KErrorText2, "Error supplying data to backup server: ");
+						LogWithNum(LOG_LEVEL4, KErrorText2, error);
+						iFailures++;
+						break;
+						}
+					else
+						{
+						_LIT(KSuccess, "Operation finished successfully");
+						Log(LOG_LEVEL4, KSuccess);
+						}
+					
+					} // else
+					
+				if ((finished && !increments) || (incrIndex == increments && finished)) // if finished 
+					{
+					runAgain = EFalse;
+					}
+				else if (finished && incrIndex < increments) // is incremental data move to next increment
+					{
+					incrIndex++;
+					runAgain = ETrue;
+					}
+				else 
+					{
+					runAgain = ETrue;
+					}
+				} // do
+				while (runAgain);
+			} // for
+			
+			if (!iFailures)
+				{
+				_LIT(KComp, "No errors found");
+				Log(LOG_LEVEL3, KComp);
+				}
+		// Do not delete bufferPtr, as it gets deleted by the iBackupClient
+		}
+	
+	TDriveList CBURTestStepBase::StringToDriveListL(TPtrC apText)
+		/**
+		@internalComponent
+		@released
+		
+		@param apText - String that needs to be converted into a TDriveList.
+		@return TDriveList with all the bytes set to 1 where a corresponding drive letter 
+				was found in apText
+		*/
+		{
+		TInt error;
+		RFs fsSession;
+		CleanupClosePushL(fsSession);
+		error = fsSession.Connect();
+		if (error != KErrNone)
+			{
+			User::Leave(error);
+			}
+		
+		TUint8 str[KMaxDrives];
+		for (TInt i = 0; i < KMaxDrives; ++i)
+			{ 
+			str[i] = 0; // Initialise to zero
+			}
+		
+		TInt length = apText.Length();
+		for (TInt i = 0; i < length; ++i)
+			{
+			TInt pos;
+			fsSession.CharToDrive(apText.Ptr()[i], pos);
+			str[pos] = 1;
+			}
+		
+		TDriveList driveList;
+		//driveList.FillZ(); // initialise to zeros
+		TPtr8 ptr(&str[0], KMaxDrives, KMaxDrives);
+		driveList.Copy(ptr);
+		
+		CleanupStack::PopAndDestroy();
+		return driveList;
+		}
+		
+	
+	void CBURTestStepBase::SaveDataOwners()
+		/**
+		Saves data owners to storage Manager
+		*/
+		{
+		TInt count = iDataOwners.Count();
+		for (TInt i =0; i < count; i++)
+			{
+			TRAPD(err, iStorageManager->SaveDataOwnerL(*iDataOwners[i]));
+			if (err != KErrNone)
+				{
+				_LIT(KDataOwnerErr, "Error saving Data Owner: ");
+				LogWithNum(LOG_LEVEL2, KDataOwnerErr, err);
+				}
+			}
+		}
+	
+	void CBURTestStepBase::CheckSIDStatusL(RTransferTypeArray& aTransferTypes, RTransferTypeArray& aReadyArray)
+		/**
+		Checks the readyness status for Active Data Owner. The ones are ready put into ready array and removed from the original
+		
+		@param aTransferTypes - TransferTypes to check for status
+		@param aReadyArray - array of transfer types where dataowners are ready
+		*/
+		{
+		aReadyArray.ResetAndDestroy();
+		if (aTransferTypes.Count())
+			{
+			// used for getting statuses
+			RSIDStatusArray statusArray;
+			CleanupClosePushL(statusArray);
+			// create array of sid for status request
+			for (TInt i =0; i< aTransferTypes.Count(); i++)
+				{
+				TSecureId id = NULL;
+				TSBDerivedType type = aTransferTypes[i]->DerivedTypeL();
+				if (type == ESIDTransferDerivedType)
+					{
+					CSBSIDTransferType* sidType = CSBSIDTransferType::NewL(aTransferTypes[i]);
+					CleanupStack::PushL(sidType);
+					id = sidType->SecureIdL();
+					CleanupStack::PopAndDestroy(sidType);
+					statusArray.Append(TDataOwnerAndStatus(id, EUnset, KErrNone));	
+					}
+				} //for
+						
+			// get status for data owners	
+			iBackupClient->SIDStatusL(statusArray);
+			
+			// check which sids ready
+			TInt total = statusArray.Count();
+			for (TInt j=0; j < total; j++)
+				{
+				TDataOwnerAndStatus test = statusArray[j];
+				if (statusArray[j].iStatus == EDataOwnerReady)
+					{
+					aReadyArray.Append(aTransferTypes[j]);
+					statusArray.Remove(j);
+					aTransferTypes.Remove(j);
+					j--;
+					total--;
+					}
+				else if (statusArray[j].iStatus == EDataOwnerReadyNoImpl || statusArray[j].iStatus == EDataOwnerFailed || statusArray[j].iStatus == EDataOwnerNotFound)
+					{
+					LogWithSID(LOG_LEVEL3, _L("Data Owner Failed, NotFound or Has No implementation : "),statusArray[j].iSID.iId);
+					statusArray.Remove(j);
+					delete aTransferTypes[j];
+					aTransferTypes[j] = NULL;
+					aTransferTypes.Remove(j);
+					j--;
+					total--;
+					}
+				} //for	
+			statusArray.Reset();
+			CleanupStack::PopAndDestroy(&statusArray);
+			} // if
+		}
+		
+	TSecureId CBURTestStepBase::ExtractIDL(CDataOwnerInfo& aDataOwner)
+		/**
+		Gets Secure ID or UID from Data Owner
+		
+		@param aDataOwner Data Owner to get ID from
+		
+		@return TSecureId Secure ID of the data owner
+		*/
+		{
+		TSecureId id = NULL;
+		if (aDataOwner.Identifier().DerivedTypeL() == ESIDDerivedType)
+			{
+			CSBSecureId* secureId = CSBSecureId::NewL(&(aDataOwner.Identifier()));
+			CleanupStack::PushL(secureId);
+					
+			id = secureId->SecureIdL();
+												
+			CleanupStack::PopAndDestroy(secureId);
+			} // if				
+		else if (aDataOwner.Identifier().DerivedTypeL() == EPackageDerivedType)
+			{
+			CSBPackageId* pkgId = CSBPackageId::NewL(&(aDataOwner.Identifier()));
+			CleanupStack::PushL(pkgId);
+			
+			// package id		
+			id = pkgId->PackageIdL();
+				
+			CleanupStack::PopAndDestroy(pkgId);
+			} // else if
+		return id;
+		}
+		
+	HBufC* CBURTestStepBase::ExtractJavaIDL(CDataOwnerInfo& aDataOwner)
+		/**
+		Gets Suite Hash ID from the Data Owner
+		
+		@param aDataOwner - Data Owner to get suite hash from
+		
+		@return HBufC* pointe to a suite hash
+		*/
+		{
+		HBufC* jid = NULL;
+		if (aDataOwner.Identifier().DerivedTypeL() == EJavaDerivedType)
+			{
+			CSBJavaId* javaId = CSBJavaId::NewL(&(aDataOwner.Identifier()));
+			CleanupStack::PushL(javaId);
+			
+			const TDesC& suiteHash = javaId->SuiteHashL();
+			jid = HBufC::NewLC(suiteHash.Size());
+			*jid = suiteHash;
+			CleanupStack::Pop(jid);
+			CleanupStack::PopAndDestroy(javaId);
+			}
+		return jid;
+		}
+		
+	void CBURTestStepBase::CheckValidRegistrationL()
+		/**
+		Checks the list of data owners returned from the device for the validity of the registration file.
+		If registration is invalid the data owner is removed from the list and not backed up or restored.
+		*/
+		{
+		for (TInt i = 0; i < iDataOwners.Count(); i++)
+			{
+			switch (iDataOwners[i]->Identifier().DerivedTypeL())
+				{
+				case ESIDDerivedType:
+					{
+					_LIT(KFoundSid, "Sid in the list: ");
+					LogWithSID(LOG_LEVEL3, KFoundSid, ExtractIDL(*iDataOwners[i]));
+					}
+					break;
+		
+				case EPackageDerivedType:
+					{
+					_LIT(KFoundPid, "Package in the list: ");
+					LogWithSID(LOG_LEVEL3, KFoundPid, ExtractIDL(*iDataOwners[i]));
+					}
+					break;
+				
+				case EJavaDerivedType:
+					{	
+					HBufC* suiteHash = ExtractJavaIDL(*iDataOwners[i]);
+					_LIT(KJava, "Java ID found: ");
+					LogWithText(LOG_LEVEL3, KJava, *suiteHash);
+					delete suiteHash;
+					suiteHash = NULL;
+					}
+					break;
+				default:
+					_LIT(KLogErr, "Not supported type");
+					Log(LOG_LEVEL3, KLogErr);
+					break;
+				}
+			
+			TCommonBURSettings settings = iDataOwners[i]->CommonSettings();
+			// check if registration file was parsed correctly
+			if (!(settings & EPassiveBUR))
+				{
+				if (!(settings & EActiveBUR))
+					{
+					if (!(settings & EHasSystemFiles))
+						{
+						delete iDataOwners[i];
+						iDataOwners[i] = NULL;
+						iDataOwners.Remove(i);
+						i--;
+						if (iIsPartial)
+							{
+							iFailures++;
+							}
+						_LIT(KBadReg, "*** Error: Bad Registration file for ID above ^^^");
+						Log(LOG_LEVEL3, KBadReg);
+						}
+					
+					}//if
+				}//if
+			}// for
+		}
+		
+	void CBURTestStepBase::DoSupplyL(TTransferDataType aDataType)
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		GenerateSIDTransferTypesL(iTransferTypes, aDataType);
+		if (iTransferTypes.Count())
+			{
+			// TODO: need to check weather we can supply snapshot without waiting
+			if (aDataType == EActiveSnapshotData || aDataType == EActiveBaseData || aDataType == EActiveIncrementalData)
+				{
+			 	// used for sids which are ready
+				RTransferTypeArray readyArray;
+				CleanupClosePushL(readyArray);
+					
+				for (TInt i=0; i < KRetries;)
+					{
+					CheckSIDStatusL(iTransferTypes, readyArray);
+											
+					if (readyArray.Count()) // dataowners ready
+						{
+						// ========= Supply Data ================
+						SupplyDataL(readyArray);		
+						} 
+					else if (iTransferTypes.Count()) // data owners not ready
+						{
+						User::After(KDelay);
+						i++;
+						}
+					else // finished with all sids
+						{
+						break;
+						}
+					} // for
+				if (iTransferTypes.Count())
+					{
+					iFailures++;
+					_LIT(KLogNoTrans, "***Error: Some Data Owners were Not Ready or Failed to Connect");
+					Log(LOG_LEVEL3, KLogNoTrans);
+					}
+				readyArray.ResetAndDestroy();
+				CleanupStack::PopAndDestroy(&readyArray);
+				} //if
+			else 
+				{
+				SupplyDataL(iTransferTypes);
+				}	
+			} //if
+		}
+		
+	// CBURActiveObject //
+	
+	/**
+	Standard Symbian OS Constructor
+	@return pointer to newly allocated CBURActiveObject object
+	*/
+	CBURActiveObject* CBURActiveObject::NewL()
+		{
+		CBURActiveObject* self = new(ELeave) CBURActiveObject();
+		CleanupStack::PushL(self);
+		self->ConstructL();
+		CleanupStack::Pop(self);
+		return self;
+		}
+		
+	/**
+	C++ Standard destructor
+	*/
+	CBURActiveObject::~CBURActiveObject()
+		{
+		Cancel();
+		delete iActiveScheduler;
+		}
+	
+	/**
+	C++ Standard Constructor
+	*/
+	CBURActiveObject::CBURActiveObject()
+		: CActive(EPriorityNormal), iError(KErrNone)
+		{
+		}
+	
+	/**
+	Symbian OS 2nd phase constructor
+	*/
+	void CBURActiveObject::ConstructL()
+		{
+		iActiveScheduler = new (ELeave) CActiveSchedulerWait();
+		CActiveScheduler::Add(this);		
+		}
+	
+	/**
+	CActive::DoCancel() implementation
+	Stops ActiveSchedulerWait if it is Started
+	*/
+	void CBURActiveObject::DoCancel()
+		{
+		if (iActiveScheduler->IsStarted())
+			{
+			iActiveScheduler->AsyncStop();
+			}
+		}
+	
+	/**
+	Waits for the Status to complete, remembers the iStatus code and calls AsyncStop
+	*/
+	void CBURActiveObject::RunL()
+		{
+		iError = iStatus.Int();
+		iActiveScheduler->AsyncStop();
+		}
+	/**
+	CActive::RunError() implementation
+	@param aError error code
+	@return KErrNone
+	*/
+	TInt CBURActiveObject::RunError(TInt aError)
+		{
+		iError = aError;
+		Cancel();
+		return KErrNone;
+		}
+	
+	/**
+	Starts and active object and Scheduler, the call will be complete when RunL is called
+	*/
+	void CBURActiveObject::StartL()
+		{
+		if (IsActive())
+			{
+			User::Leave(KErrInUse);
+			}
+		iStatus = KRequestPending;
+		SetActive();
+		iActiveScheduler->Start();
+		}
+	/**
+	Returns an error/completing code of the iStatus
+	*/
+	TInt CBURActiveObject::Error()
+		{
+		return iError;
+		}
+		
+	}	// end namespace
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/TestSteps/src/t_teststepbackup.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,606 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @released
+*/
+
+#include "t_teststepbackup.h"
+
+namespace bur_ts
+	{	
+		
+	CBURTestStepBackup* CBURTestStepBackup::NewL(CBURTestServer& aTestServer)
+		/**
+		Symbian OS Constructor
+		
+		@internalComponent
+		@released
+		
+		@param aParent - The parent CBURTestServer of this child test step.
+		@return Pointer to a newly created CBURTestStepBackup object.
+		*/
+		{
+		CBURTestStepBackup* self = new (ELeave) CBURTestStepBackup(aTestServer);
+		CleanupStack::PushL(self);
+		self->ConstructL();
+		CleanupStack::Pop();
+		return self;
+		}
+
+	CBURTestStepBackup::CBURTestStepBackup(CBURTestServer& aTestServer)
+		/**
+		C++ Constructor
+		
+		@internalComponent
+		@released
+		
+		@param aParent - The parent CBURTestServer of this child test step.
+		*/
+		: CBURTestStepBase(aTestServer), iDataTransferHandler(NULL)
+		{}
+	
+	void CBURTestStepBackup::ConstructL()
+		/**
+		Symbian OS 2nd-phase Constructor
+		
+		@internalComponent
+		@released
+		*/
+		{
+		TInt error;
+		
+		// Initialise the drive list to empty
+		iDriveList.FillZ();
+		
+		User::LeaveIfError(iFs.Connect());
+		
+		// Install an active scheduler for this test step
+		iActiveScheduler = new(ELeave) CActiveScheduler;
+		CActiveScheduler::Install(iActiveScheduler);
+		
+		TRAP(error, iBackupClient = CSBEClient::NewL());
+		if (error != KErrNone)
+			{
+			_LIT(KClientConnection, "SBEClientConnection");
+			User::Panic(KClientConnection,error);
+			}
+			
+		_LIT(KBURTBackup, "BURTestServerBackup");
+		User::RenameThread(KBURTBackup);
+		//User::SetCritical(User::ESystemCritical);
+		
+		SetTestStepName(KBURTestBackup);
+		}
+	
+	CBURTestStepBackup::~CBURTestStepBackup()
+		/**
+		C++ Destructor
+		
+		@internalComponent
+		@released
+		*/
+		{
+		delete iDataTransferHandler;
+		}
+
+	TVerdict CBURTestStepBackup::doTestStepPreambleL()
+		/**
+		Override of base class virtual function
+		
+		@internalComponent
+		@released
+		
+		@return TVerdict code
+		*/
+		{
+		SetTestStepResult(EPass);
+		return TestStepResult();
+		}
+
+	TVerdict CBURTestStepBackup::doTestStepL()
+		/**
+		Override of base class pure virtual
+		
+		@internalComponent
+		@released
+		
+		@return TVerdict code
+		*/
+		{
+		_LIT(KLog1, "Processing user options...");
+		Log(LOG_LEVEL2, KLog1);
+		ProcessUserOptionsL();
+		
+		// Get a list of data owners:
+		PopulateListOfDataOwnersL();
+		
+		
+		TBURPartType type = EBURBackupFull;
+		
+		if (iIsPartial)
+			{
+			_LIT(KLog2, "Preparing for PARTIAL backup...");
+			Log(LOG_LEVEL2, KLog2);
+			type = EBURBackupPartial;
+			PrepareForPartialBURL();
+			SetSIDListForPartialL();
+			}
+		else
+			{
+			_LIT(KLog3, "Preparing for FULL backup...");
+			Log(LOG_LEVEL2, KLog3);
+			}
+		
+		CheckValidRegistrationL();
+		
+		_LIT(KLog4, "Saving Data Owners...");
+		Log(LOG_LEVEL2, KLog4);
+		SaveDataOwners();
+		
+		Log(LOG_LEVEL2, _L("Setting backup mode..."));
+		TRAPD(err,SetBURModeL(type, iBackupIncType));
+		if (err != KErrNone)
+			{
+			_LIT(KBURError, "Error setting Backup mode ");
+			Log(LOG_LEVEL3, KBURError);
+			}
+		
+		iDataTransferHandler = CAsyncBackupTransferHandler::NewL(this);
+		Log(LOG_LEVEL2, _L("Starting backup..."));
+		
+		//BackupRegistrationDataL();
+		
+		BackupPublicDataL();
+		
+		BackupJavaMidletsL();
+		BackupJavaMidletsDataL();
+		
+		// Backup data according to user preferences
+		if (iBackupIncType == EBackupIncrement)
+			{
+			IncrementalBackupL();
+			}
+		else
+			{
+			BaseBackupL();
+			}
+			
+		Log(LOG_LEVEL2, _L("Setting backup mode to Normal ..."));
+		TRAPD(err2,SetBURModeL(EBURNormal, ENoBackup));
+		if (err2 != KErrNone)
+			{
+			_LIT(KBURError, "Error setting Backup mode ");
+			Log(LOG_LEVEL3, KBURError);
+			}
+		
+		
+		return TestStepResult();
+		}
+	
+	void CBURTestStepBackup::BaseBackupL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		// system data
+		BackupSystemBaseDataL();
+		BackupSystemSnapshotDataL();
+		
+		//active
+		BackupActiveBaseDataL();
+		BackupActiveSnapshotDataL();
+		
+		//passive
+		BackupPassiveBaseDataL();
+		BackupPassiveSnapshotDataL();
+		}
+	
+	void CBURTestStepBackup::IncrementalBackupL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KInc, "Backup mode: INCREMENTAL");
+		Log(LOG_LEVEL2, KInc);
+		//active
+		SupplySystemSnapshotDataL();
+		SupplyActiveSnapshotDataL();
+		SupplyPassiveSnapshotDataL();
+		TRAPD(err,iBackupClient->AllSnapshotsSuppliedL());
+		if (err != KErrNone)
+			{
+			_LIT(KSnapErr, "Error Supplying Snapshot Data ");
+			LogWithNum(LOG_LEVEL3, KSnapErr, err);
+			}
+		else
+			{
+			_LIT(KSnap, "All Snapshots Supplied");
+			Log(LOG_LEVEL3, KSnap);
+			}
+			
+		// system data
+		BackupSystemBaseDataL();
+		BackupSystemSnapshotDataL();
+		
+		// active
+		BackupActiveIncDataL();
+		BackupActiveSnapshotDataL();
+		
+		//passive
+		BackupPassiveIncDataL();
+		BackupPassiveSnapshotDataL();
+		}
+		
+	void CBURTestStepBackup::BackupSystemBaseDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KLog, "Backup System Data ...");
+		Log(LOG_LEVEL2, KLog);
+		GeneratePIDTransferTypesL(iTransferTypes, ESystemData);
+		DoBackupL();
+		}
+		
+	void CBURTestStepBackup::SupplySystemSnapshotDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		GeneratePIDTransferTypesL(iTransferTypes, ESystemSnapshotData);
+		// go through each of them and check if we have snapshot to supply
+		if (iTransferTypes.Count())
+			{
+			_LIT(KLog, "Supply System Snapshot Data ...");
+			Log(LOG_LEVEL2, KLog);
+			SupplyDataL(iTransferTypes);
+			}
+		}
+		
+	void CBURTestStepBackup::BackupSystemSnapshotDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KLog, "Backup System Snapshot Data ...");
+		Log(LOG_LEVEL2, KLog);
+		GeneratePIDTransferTypesL(iTransferTypes, ESystemSnapshotData);
+		DoBackupL();
+		}
+	
+	
+	void CBURTestStepBackup::BackupRegistrationDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KReg, "Backup registration data...");
+		Log(LOG_LEVEL2, KReg);
+		GenerateSIDTransferTypesL(iTransferTypes, ERegistrationData);
+		DoBackupL();
+		}
+	
+	void CBURTestStepBackup::BackupPassiveSnapshotDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KPassSnap, "Backup passive snapshot data...");
+		Log(LOG_LEVEL2, KPassSnap);
+		GenerateSIDTransferTypesL(iTransferTypes, EPassiveSnapshotData);
+		DoBackupL();
+		}
+	
+	void CBURTestStepBackup::SupplyPassiveSnapshotDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KSupp, "Supplying passive snapshot data...");
+		Log(LOG_LEVEL2, KSupp);
+		DoSupplyL(EPassiveSnapshotData);
+		}
+
+	void CBURTestStepBackup::BackupPassiveBaseDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KPassBase, "Backup passive base data...");
+		Log(LOG_LEVEL2, KPassBase);
+		GenerateSIDTransferTypesL(iTransferTypes, EPassiveBaseData);
+		DoBackupL();
+		}
+	
+	void CBURTestStepBackup::BackupPassiveIncDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KPassInc, "Backup passive incremental data...");
+		Log(LOG_LEVEL2, KPassInc);
+		GenerateSIDTransferTypesL(iTransferTypes, EPassiveIncrementalData);
+		DoBackupL();
+		}
+	
+	void CBURTestStepBackup::BackupActiveSnapshotDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KActSnap, "Backup active snapshot data...");
+		Log(LOG_LEVEL2, KActSnap);
+		DoActiveBackupL(EActiveSnapshotData);
+		}
+	
+	void CBURTestStepBackup::SupplyActiveSnapshotDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KSuppActSnap,"Supplying active snapshot data...");
+		Log(LOG_LEVEL2, KSuppActSnap);
+		DoSupplyL(EActiveSnapshotData);
+		}
+	
+	void CBURTestStepBackup::BackupActiveBaseDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KActBase, "Backup active base data...");
+		Log(LOG_LEVEL2, KActBase);
+		DoActiveBackupL(EActiveBaseData);
+		}
+
+	void CBURTestStepBackup::BackupActiveIncDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KActInc, "Backup active incremental data...");
+		Log(LOG_LEVEL2, KActInc);
+		DoActiveBackupL(EActiveIncrementalData);
+		}
+		
+	void CBURTestStepBackup::BackupPublicDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KPublic, "Backup Public Data...");
+		Log(LOG_LEVEL2, KPublic);
+		RPointerArray<CSBGenericDataType> array;
+		TRAP_IGNORE(GeneratePublicTransferTypesL(array));
+		TRAP_IGNORE(DoPublicBackupL(array));
+		array.ResetAndDestroy();
+		array.Close();
+		}
+		
+	void CBURTestStepBackup::DoPublicBackupL(RPointerArray<CSBGenericDataType>& aTransferTypes)
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KNote, "Public data is Not saved it just for Testing purposes to show the list of files got from the device!");
+		Log(LOG_LEVEL2, KNote);
+		RFileArray array;
+		CleanupClosePushL(array);
+		TInt length = iDriveList.Length();
+		TInt count = aTransferTypes.Count();
+		for (TInt driveCount = 0; driveCount < length && count; driveCount++)
+			{
+			if (iDriveList[driveCount])
+				{
+				for (TInt i =0; i < count; i++)
+					{
+					iBackupClient->PublicFileListL(TDriveNumber(driveCount), *aTransferTypes[i], array);
+					/**CDataOwnerInfo* doi = CDataOwnerInfo::NewL(aTransferTypes[i], ENoOptions, ENoOptions, ENoOptions, iDriveList);
+					CleanupStack::PushL(doi);
+					switch (aTransferTypes[i]->DerivedTypeL())
+						{
+						case ESIDDerivedType:
+							{
+							_LIT(KFoundSid, "SecureId: ");
+							LogWithSID(LOG_LEVEL3, KFoundSid, ExtractIDL(*doi));
+							}
+							break;
+				
+						case EPackageDerivedType:
+							{
+							_LIT(KFoundPid, "Package: ");
+							LogWithSID(LOG_LEVEL3, KFoundPid, ExtractIDL(*doi));
+							}
+							break;
+						
+						case EJavaDerivedType:
+							{	
+							HBufC* suiteHash = ExtractJavaIDL(*doi);
+							_LIT(KJava, "Java ID found: ");
+							LogWithText(LOG_LEVEL3, KJava, *suiteHash);
+							delete suiteHash;
+							suiteHash = NULL;
+							}
+							break;
+						default:
+							_LIT(KLogErr, "Not supported type");
+							Log(LOG_LEVEL3, KLogErr);
+							break;
+						}
+						
+					CleanupStack::Pop(doi);
+					*/
+					
+					TInt fileCount = array.Count();
+					_LIT(KFoundCount, "Found number of files: ");
+					LogWithNum(LOG_LEVEL3, KFoundCount, fileCount);
+					
+					for (TInt j = 0; j < fileCount; j++)
+						{
+						_LIT(KFile, "File: ");
+						LogWithText(LOG_LEVEL4, KFile, array[i].iName); 
+						}
+					
+					array.Reset();
+					}
+				}
+			}		
+		CleanupStack::PopAndDestroy(&array);
+		}
+	
+	void CBURTestStepBackup::DoBackupL()
+		/**
+		Core backup method to carry out the transfer as well as the storage of 
+		data to the archive.
+		
+		@internalComponent
+		@released
+		
+		@param aDataType - Type of data to be backed up.
+		*/
+		{
+		if (iTransferTypes.Count())
+			{
+			// STEP 2 - Start the data request handler to backup data:
+			_LIT(KLog2, "Requesting backup data for IDs per drive...");
+			Log(LOG_LEVEL3, KLog2);
+			iDataTransferHandler->StartL();
+			// Log success:
+			if (iDataTransferHandler->Success())
+				{
+				_LIT(KLog3, "Operation finished with no errors");
+				Log(LOG_LEVEL3, KLog3);
+				} //if
+			else
+				{
+				iFailures++;
+				_LIT(KLog4, "Operation failed with errors ");
+				Log(LOG_LEVEL3, KLog4);
+				SetTestStepResult(TVerdict(EFail));
+				} //else
+			} //if 
+		else 
+			{
+			_LIT(KLogNoTrans, "Nothing to do ");
+			Log(LOG_LEVEL3, KLogNoTrans);
+			} //else
+		}
+		
+		
+	void CBURTestStepBackup::DoActiveBackupL(TTransferDataType aTransferDataType)
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		RTransferTypeArray transferTypes;
+		GenerateSIDTransferTypesL(transferTypes, aTransferDataType);
+		if (transferTypes.Count())
+			{
+			TRAPD(error,
+			for (TInt i=0; i < KRetries;)
+				{
+				CheckSIDStatusL(transferTypes, iTransferTypes);													
+				if (iTransferTypes.Count()) // dataowners ready
+					{
+					DoBackupL();
+					} 
+				else if (transferTypes.Count()) // data owners not ready
+					{
+					User::After(KDelay);
+					i++;
+					}
+				else // finished with all sids
+					{
+					break;
+					}
+				} // for
+				); //TRAPD
+			if (transferTypes.Count())
+				{
+				iFailures++;
+				_LIT(KLogNoTrans, "***Error: Some Data Owners were Not Ready or Failed to Connect");
+				Log(LOG_LEVEL3, KLogNoTrans);
+				} //if
+			transferTypes.ResetAndDestroy();
+			
+			User::LeaveIfError(error);
+			}
+		else 
+			{
+			_LIT(KLogNoTrans, "Nothing to do ");
+			Log(LOG_LEVEL3, KLogNoTrans);
+			}
+
+		}
+		
+	void CBURTestStepBackup::BackupJavaMidletsL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KMidlet, "Backup midlets...");
+		Log(LOG_LEVEL2, KMidlet);
+		GenerateJavaTransferTypesL(iTransferTypes, EJavaMIDlet);
+		DoBackupL();
+		}
+		
+	void CBURTestStepBackup::BackupJavaMidletsDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KMidletData, "Backup midlets data...");
+		Log(LOG_LEVEL2, KMidletData);
+		GenerateJavaTransferTypesL(iTransferTypes, EJavaMIDletData);
+		DoBackupL();
+		}
+	
+	TVerdict CBURTestStepBackup::doTestStepPostambleL()
+		/**
+		@return - TVerdict code
+		 Override of base class pure virtual
+		*/
+		{
+		_LIT(KLog, "Number of failures:");
+		LogWithNum(LOG_LEVEL3, KLog, iFailures);
+		if (iFailures)
+			{
+			SetTestStepResult(TVerdict(EFail));
+			}
+		return TestStepResult();
+		}
+	
+	}	// end namespace
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/TestSteps/src/t_teststepbackupasync.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,589 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// T_TestStepBackup.cpp
+// 
+//
+
+/**
+ @file
+ @released
+*/
+
+#include "t_teststepbackupasync.h"
+
+
+namespace bur_ts
+	{
+			
+	CBURTestStepBackupAsync* CBURTestStepBackupAsync::NewL(CBURTestServer& aTestServer)
+		/**
+		Symbian OS Constructor
+		
+		@internalComponent
+		@released
+		
+		@param aParent - The parent CBURTestServer of this child test step.
+		@return Pointer to a newly created CBURTestStepBackup object.
+		*/
+		{
+		CBURTestStepBackupAsync* self = new (ELeave) CBURTestStepBackupAsync(aTestServer);
+		CleanupStack::PushL(self);
+		self->ConstructL();
+		CleanupStack::Pop();
+		return self;
+		}
+
+	CBURTestStepBackupAsync::CBURTestStepBackupAsync(CBURTestServer& aTestServer)
+		/**
+		C++ Constructor
+		
+		@internalComponent
+		@released
+		
+		@param aParent - The parent CBURTestServer of this child test step.
+		*/
+		: CBURTestStepBase(aTestServer), iDataTransferHandler(NULL)
+		{}
+	
+	void CBURTestStepBackupAsync::ConstructL()
+		/**
+		Symbian OS 2nd-phase Constructor
+		
+		@internalComponent
+		@released
+		*/
+		{
+		TInt error;
+		
+		// Initialise the drive list to empty
+		iDriveList.FillZ();
+		
+		User::LeaveIfError(iFs.Connect());
+		
+		// Install an active scheduler for this test step
+		iActiveScheduler = new(ELeave) CActiveScheduler;
+		CActiveScheduler::Install(iActiveScheduler);
+		
+		TRAP(error, iBackupClient = CSBEClient::NewL());
+		if (error != KErrNone)
+			{
+			_LIT(KClientConnection, "SBEClientConnection");
+			User::Panic(KClientConnection,error);
+			}
+			
+		_LIT(KBURTBackup, "BURTestServerBackup");
+		User::RenameThread(KBURTBackup);
+		//User::SetCritical(User::ESystemCritical);
+		
+		SetTestStepName(KBURTestBackupAsync);
+		}
+	
+	CBURTestStepBackupAsync::~CBURTestStepBackupAsync()
+		/**
+		C++ Destructor
+		
+		@internalComponent
+		@released
+		*/
+		{
+		delete iDataTransferHandler;
+		}
+
+	TVerdict CBURTestStepBackupAsync::doTestStepPreambleL()
+		/**
+		Override of base class virtual function
+		
+		@internalComponent
+		@released
+		
+		@return TVerdict code
+		*/
+		{
+		SetTestStepResult(EPass);
+		return TestStepResult();
+		}
+
+	TVerdict CBURTestStepBackupAsync::doTestStepL()
+		/**
+		Override of base class pure virtual
+		
+		@internalComponent
+		@released
+		
+		@return TVerdict code
+		*/
+		{
+		_LIT(KLog1, "Processing user options...");
+		Log(LOG_LEVEL2, KLog1);
+		ProcessUserOptionsL();
+		
+		// Get a list of data owners:
+		PopulateListOfDataOwnersAsyncL();
+		
+		
+		TBURPartType type = EBURBackupFull;
+		
+		if (iIsPartial)
+			{
+			_LIT(KLog2, "Preparing for PARTIAL backup...");
+			Log(LOG_LEVEL2, KLog2);
+			type = EBURBackupPartial;
+			PrepareForPartialBURL();
+			SetSIDListForPartialL();
+			}
+		else
+			{
+			_LIT(KLog3, "Preparing for FULL backup...");
+			Log(LOG_LEVEL2, KLog3);
+			}
+		
+		CheckValidRegistrationL();
+		
+		_LIT(KLog4, "Saving Data Owners...");
+		Log(LOG_LEVEL2, KLog4);
+		SaveDataOwners();
+		
+		Log(LOG_LEVEL2, _L("Setting backup mode..."));
+		TRAPD(err,SetBURModeAsyncL(type, iBackupIncType));
+		if (err != KErrNone)
+			{
+			_LIT(KBURError, "Error setting Backup mode ");
+			Log(LOG_LEVEL3, KBURError);
+			}
+		
+		iDataTransferHandler = CAsyncBackupTransferHandler::NewL(this);
+		Log(LOG_LEVEL2, _L("Starting backup..."));
+		
+		//BackupRegistrationDataL();
+		
+		BackupPublicDataL();
+		
+		BackupJavaMidletsL();
+		BackupJavaMidletsDataL();
+		
+		// Backup data according to user preferences
+		if (iBackupIncType == EBackupIncrement)
+			{
+			IncrementalBackupL();
+			}
+		else
+			{
+			BaseBackupL();
+			}
+			
+		Log(LOG_LEVEL2, _L("Setting backup mode to Normal ..."));
+		TRAPD(err2,SetBURModeL(EBURNormal, ENoBackup));
+		if (err2 != KErrNone)
+			{
+			_LIT(KBURError, "Error setting Backup mode ");
+			Log(LOG_LEVEL3, KBURError);
+			}
+		
+		
+		return TestStepResult();
+		}
+	
+	void CBURTestStepBackupAsync::BaseBackupL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		// system data
+		BackupSystemBaseDataL();
+		BackupSystemSnapshotDataL();
+		
+		//active
+		BackupActiveBaseDataL();
+		BackupActiveSnapshotDataL();
+		
+		//passive
+		BackupPassiveBaseDataL();
+		BackupPassiveSnapshotDataL();
+		}
+	
+	void CBURTestStepBackupAsync::IncrementalBackupL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KInc, "Backup mode: INCREMENTAL");
+		Log(LOG_LEVEL2, KInc);
+		//active
+		SupplySystemSnapshotDataL();
+		SupplyActiveSnapshotDataL();
+		SupplyPassiveSnapshotDataL();
+		
+		CBURActiveObject* active = CBURActiveObject::NewL();
+		CleanupStack::PushL(active);
+		TRAPD(err,iBackupClient->AllSnapshotsSuppliedL(active->iStatus));
+		if (err == KErrNone)
+			{
+			active->StartL();
+			}
+		
+		if (err != KErrNone || active->Error() != KErrNone)
+			{
+			_LIT(KSnapErr, "Error Supplying Snapshot Data ");
+			LogWithNum(LOG_LEVEL3, KSnapErr, err);
+			}
+		else
+			{
+			_LIT(KSnap, "All Snapshots Supplied");
+			Log(LOG_LEVEL3, KSnap);
+			}
+		
+		CleanupStack::PopAndDestroy(active);
+		
+		// system data
+		BackupSystemBaseDataL();
+		BackupSystemSnapshotDataL();
+		
+		// active
+		BackupActiveIncDataL();
+		BackupActiveSnapshotDataL();
+		
+		//passive
+		BackupPassiveIncDataL();
+		BackupPassiveSnapshotDataL();
+		}
+		
+	void CBURTestStepBackupAsync::BackupSystemBaseDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KLog, "Backup System Data ...");
+		Log(LOG_LEVEL2, KLog);
+		GeneratePIDTransferTypesL(iTransferTypes, ESystemData);
+		DoBackupL();
+		}
+		
+	void CBURTestStepBackupAsync::SupplySystemSnapshotDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		GeneratePIDTransferTypesL(iTransferTypes, ESystemSnapshotData);
+		// go through each of them and check if we have snapshot to supply
+		if (iTransferTypes.Count())
+			{
+			_LIT(KLog, "Supply System Snapshot Data ...");
+			Log(LOG_LEVEL2, KLog);
+			SupplyDataL(iTransferTypes);
+			}
+		}
+		
+	void CBURTestStepBackupAsync::BackupSystemSnapshotDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KLog, "Backup System Snapshot Data ...");
+		Log(LOG_LEVEL2, KLog);
+		GeneratePIDTransferTypesL(iTransferTypes, ESystemSnapshotData);
+		DoBackupL();
+		}
+	
+	
+	void CBURTestStepBackupAsync::BackupRegistrationDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KReg, "Backup registration data...");
+		Log(LOG_LEVEL2, KReg);
+		GenerateSIDTransferTypesL(iTransferTypes, ERegistrationData);
+		DoBackupL();
+		}
+	
+	void CBURTestStepBackupAsync::BackupPassiveSnapshotDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KPassSnap, "Backup passive snapshot data...");
+		Log(LOG_LEVEL2, KPassSnap);
+		GenerateSIDTransferTypesL(iTransferTypes, EPassiveSnapshotData);
+		DoBackupL();
+		}
+	
+	void CBURTestStepBackupAsync::SupplyPassiveSnapshotDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KSupp, "Supplying passive snapshot data...");
+		Log(LOG_LEVEL2, KSupp);
+		DoSupplyL(EPassiveSnapshotData);
+		}
+
+	void CBURTestStepBackupAsync::BackupPassiveBaseDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KPassBase, "Backup passive base data...");
+		Log(LOG_LEVEL2, KPassBase);
+		GenerateSIDTransferTypesL(iTransferTypes, EPassiveBaseData);
+		DoBackupL();
+		}
+	
+	void CBURTestStepBackupAsync::BackupPassiveIncDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KPassInc, "Backup passive incremental data...");
+		Log(LOG_LEVEL2, KPassInc);
+		GenerateSIDTransferTypesL(iTransferTypes, EPassiveIncrementalData);
+		DoBackupL();
+		}
+	
+	void CBURTestStepBackupAsync::BackupActiveSnapshotDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KActSnap, "Backup active snapshot data...");
+		Log(LOG_LEVEL2, KActSnap);
+		DoActiveBackupL(EActiveSnapshotData);
+		}
+	
+	void CBURTestStepBackupAsync::SupplyActiveSnapshotDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KSuppActSnap,"Supplying active snapshot data...");
+		Log(LOG_LEVEL2, KSuppActSnap);
+		DoSupplyL(EActiveSnapshotData);
+		}
+	
+	void CBURTestStepBackupAsync::BackupActiveBaseDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KActBase, "Backup active base data...");
+		Log(LOG_LEVEL2, KActBase);
+		DoActiveBackupL(EActiveBaseData);
+		}
+
+	void CBURTestStepBackupAsync::BackupActiveIncDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KActInc, "Backup active incremental data...");
+		Log(LOG_LEVEL2, KActInc);
+		DoActiveBackupL(EActiveIncrementalData);
+		}
+		
+	void CBURTestStepBackupAsync::BackupPublicDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KPublic, "Backup Public Data...");
+		Log(LOG_LEVEL2, KPublic);
+		RPointerArray<CSBGenericDataType> array;
+		TRAP_IGNORE(GeneratePublicTransferTypesL(array));
+		TRAP_IGNORE(DoPublicBackupL(array));
+		array.ResetAndDestroy();
+		array.Close();
+		}
+		
+	void CBURTestStepBackupAsync::DoPublicBackupL(RPointerArray<CSBGenericDataType>& aTransferTypes)
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KNote, "Public data is Not saved it just for Testing purposes to show the list of files got from the device!");
+		Log(LOG_LEVEL2, KNote);
+		RFileArray array;
+		CleanupClosePushL(array);
+		TInt length = iDriveList.Length();
+		TInt count = aTransferTypes.Count();
+		for (TInt driveCount = 0; driveCount < length && count; driveCount++)
+			{
+			if (iDriveList[driveCount])
+				{
+				for (TInt i =0; i < count; i++)
+					{
+					CBURActiveObject* active = CBURActiveObject::NewL();
+					CleanupStack::PushL(active);
+					iBackupClient->PublicFileListL(TDriveNumber(driveCount), *aTransferTypes[i], array, active->iStatus);
+					active->StartL();
+					User::LeaveIfError(active->Error());
+					CleanupStack::PopAndDestroy(active);
+					
+					TInt fileCount = array.Count();
+					_LIT(KFoundCount, "Found number of files: ");
+					LogWithNum(LOG_LEVEL3, KFoundCount, fileCount);
+					
+					for (TInt j = 0; j < fileCount; j++)
+						{
+						_LIT(KFile, "File: ");
+						LogWithText(LOG_LEVEL4, KFile, array[j].iName); 
+						}
+					
+					array.Reset();
+					}
+				}
+			}		
+		CleanupStack::PopAndDestroy(&array);
+		}
+	
+	void CBURTestStepBackupAsync::DoBackupL()
+		/**
+		Core backup method to carry out the transfer as well as the storage of 
+		data to the archive.
+		
+		@internalComponent
+		@released
+		
+		@param aDataType - Type of data to be backed up.
+		*/
+		{
+		if (iTransferTypes.Count())
+			{
+			// STEP 2 - Start the data request handler to backup data:
+			_LIT(KLog2, "Requesting backup data for IDs per drive...");
+			Log(LOG_LEVEL3, KLog2);
+			iDataTransferHandler->StartL();
+			// Log success:
+			if (iDataTransferHandler->Success())
+				{
+				_LIT(KLog3, "Operation finished with no errors");
+				Log(LOG_LEVEL3, KLog3);
+				} //if
+			else
+				{
+				iFailures++;
+				_LIT(KLog4, "Operation failed with errors ");
+				Log(LOG_LEVEL3, KLog4);
+				SetTestStepResult(TVerdict(EFail));
+				} //else
+			} //if 
+		else 
+			{
+			_LIT(KLogNoTrans, "Nothing to do ");
+			Log(LOG_LEVEL3, KLogNoTrans);
+			} //else
+		}
+		
+		
+	void CBURTestStepBackupAsync::DoActiveBackupL(TTransferDataType aTransferDataType)
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		RTransferTypeArray transferTypes;
+		GenerateSIDTransferTypesL(transferTypes, aTransferDataType);
+		if (transferTypes.Count())
+			{
+			TRAPD(error,
+			for (TInt i=0; i < KRetries;)
+				{
+				CheckSIDStatusL(transferTypes, iTransferTypes);													
+				if (iTransferTypes.Count()) // dataowners ready
+					{
+					DoBackupL();
+					} 
+				else if (transferTypes.Count()) // data owners not ready
+					{
+					User::After(KDelay);
+					i++;
+					}
+				else // finished with all sids
+					{
+					break;
+					}
+				} // for
+				); //TRAPD
+			if (transferTypes.Count())
+				{
+				iFailures++;
+				_LIT(KLogNoTrans, "***Error: Some Data Owners were Not Ready or Failed to Connect");
+				Log(LOG_LEVEL3, KLogNoTrans);
+				} //if
+			transferTypes.ResetAndDestroy();
+			
+			User::LeaveIfError(error);
+			}
+		else 
+			{
+			_LIT(KLogNoTrans, "Nothing to do ");
+			Log(LOG_LEVEL3, KLogNoTrans);
+			}
+
+		}
+		
+	void CBURTestStepBackupAsync::BackupJavaMidletsL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KMidlet, "Backup midlets...");
+		Log(LOG_LEVEL2, KMidlet);
+		GenerateJavaTransferTypesL(iTransferTypes, EJavaMIDlet);
+		DoBackupL();
+		}
+		
+	void CBURTestStepBackupAsync::BackupJavaMidletsDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KMidletData, "Backup midlets data...");
+		Log(LOG_LEVEL2, KMidletData);
+		GenerateJavaTransferTypesL(iTransferTypes, EJavaMIDletData);
+		DoBackupL();
+		}
+	
+	TVerdict CBURTestStepBackupAsync::doTestStepPostambleL()
+		/**
+		@return - TVerdict code
+		 Override of base class pure virtual
+		*/
+		{
+		_LIT(KLog, "Number of failures:");
+		LogWithNum(LOG_LEVEL3, KLog, iFailures);
+		if (iFailures)
+			{
+			SetTestStepResult(TVerdict(EFail));
+			}
+		return TestStepResult();
+		}
+	
+	}	// end namespace
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/TestSteps/src/t_teststeprestore.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,382 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @released
+*/
+#include "t_teststeprestore.h"
+
+namespace bur_ts
+	{
+	
+	CBURTestStepRestore* CBURTestStepRestore::NewL(CBURTestServer& aTestServer)
+		/**
+		Symbian OS Constructor
+		
+		@internalComponent
+		@released
+		
+		@param aParent - The parent CBURTestServer of this child test step.
+		@return Pointer to a newly created CBURTestStepRestore object.
+		*/
+		{
+		CBURTestStepRestore* self = new (ELeave) CBURTestStepRestore(aTestServer);
+		CleanupStack::PushL(self);
+		self->ConstructL();
+		CleanupStack::Pop();
+		return self;
+		}
+	
+	CBURTestStepRestore::CBURTestStepRestore(CBURTestServer& aTestServer)
+		/**
+		C++ Constructor
+		
+		@internalComponent
+		@released
+		
+		@param aParent - The parent CBURTestServer of this child test step.
+		*/
+		:CBURTestStepBase(aTestServer)
+		{}
+	
+	void CBURTestStepRestore::ConstructL()
+		/**
+		Symbian OS 2nd-phase Constructor
+		
+		@internalComponent
+		@released
+		*/
+		{
+		TInt error;
+		
+		// Initialise the drive list to empty:
+		iDriveList.FillZ();
+		
+		iMode = ERestoreMode;
+		
+		User::LeaveIfError(iFs.Connect());
+		
+		// Install an active scheduler for this test step
+		iActiveScheduler = new(ELeave) CActiveScheduler;
+		CActiveScheduler::Install(iActiveScheduler);
+		
+		TRAP(error, iBackupClient = CSBEClient::NewL());
+		if (error != KErrNone)
+			{
+			_LIT(KClientConnection, "SBEClientConn");
+			User::Panic(KClientConnection,error);
+			}
+			
+		_LIT(KBURTRestore, "BURTestServerRestore");
+		User::RenameThread(KBURTRestore);
+		//User::SetCritical(User::ESystemCritical);
+		
+		SetTestStepName(KBURTestRestore);
+		}
+	
+	CBURTestStepRestore::~CBURTestStepRestore()
+		/**
+		C++ Destructor
+		
+		@internalComponent
+		@released
+		*/
+		{
+		}
+
+	TVerdict CBURTestStepRestore::doTestStepPreambleL()
+		/**
+		Override of base class virtual function
+		
+		@internalComponent
+		@released
+		@return TVerdict code
+		*/
+		{
+		SetTestStepResult(EPass);
+		return TestStepResult();
+		}
+
+	TVerdict CBURTestStepRestore::doTestStepL()
+		/**
+		Override of base class pure virtual
+		
+		@internalComponent
+		@released
+		@return TVerdict code
+		*/
+		{
+		_LIT(KLog1, "Processing user options...");
+		Log(LOG_LEVEL2, KLog1);
+		ProcessUserOptionsL();
+		
+		TBURPartType type = EBURRestoreFull;
+			
+		iStorageManager->ReadDataOwnersFromDiskL(iDataOwners);
+		
+		CheckValidRegistrationL();	
+			
+		if (iIsPartial)
+			{
+			_LIT(KLog2, "Preparing for PARTIAL restore...");
+			Log(LOG_LEVEL2, KLog2);
+			PrepareForPartialBURL();
+			SetSIDListForPartialL();
+			type = EBURRestorePartial;
+			}
+		else
+			{
+			_LIT(KLog3, "Preparing for FULL restore...");
+			Log(LOG_LEVEL2, KLog3);
+			}
+			
+		// Set restore mode:
+		_LIT(KLog4, "Setting restore mode...");
+		Log(LOG_LEVEL2, KLog4);
+		TRAPD(burmode, SetBURModeL(type, iBackupIncType));
+		if (burmode != KErrNone)
+			{
+			_LIT(KLog5, "Error setting restore Mode ");
+			LogWithNum(LOG_LEVEL3, KLog5, burmode);
+			}
+		
+		//SupplyRegistrationDataL();
+		
+		// system data
+		SupplySystemSnapshotDataL();
+		RestoreSystemBaseDataL();
+		
+		RestoreJavaMidletL();
+			
+		// confirm system files restored 
+		iBackupClient->AllSystemFilesRestored();
+		
+		
+		/** Restore data according to user preferences */
+		if (iBackupIncType == EBackupIncrement)
+			{
+			IncrementalRestoreL();
+			}
+		else
+			{
+			BaseRestoreL();
+			}
+			
+		Log(LOG_LEVEL2, _L("Setting backup mode to Normal ..."));
+		TRAPD(err2,SetBURModeL(EBURNormal, ENoBackup));
+		if (err2 != KErrNone)
+			{
+			_LIT(KBURError, "Error setting Backup mode ");
+			LogWithNum(LOG_LEVEL3, KBURError, err2);
+			}
+		
+		return TestStepResult();
+		}
+	
+	void CBURTestStepRestore::BaseRestoreL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		RestoreJavaMidletDataL();
+		
+		// passive
+		SupplyPassiveSnapshotDataL();
+		RestorePassiveBaseDataL();
+		
+		//active
+		SupplyActiveSnapshotDataL();
+		RestoreActiveBaseDataL();
+		}
+	
+	void CBURTestStepRestore::IncrementalRestoreL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		RestoreJavaMidletDataL();
+		
+		// passive
+		SupplyPassiveSnapshotDataL();
+		RestorePassiveBaseDataL();
+		RestorePassiveIncDataL();
+		
+		
+		//active
+		SupplyActiveSnapshotDataL();
+		RestoreActiveBaseDataL();
+		RestoreActiveIncDataL();
+		}
+		
+	
+	void CBURTestStepRestore::SupplyRegistrationDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KRes, "Supplying registration data...");
+		Log(LOG_LEVEL2, KRes);
+		DoSupplyL(ERegistrationData);
+		}
+	
+	void CBURTestStepRestore::SupplyPassiveSnapshotDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KSupp, "Supplying passive snapshot data...");
+		Log(LOG_LEVEL2, KSupp);
+		DoSupplyL(EPassiveSnapshotData);	
+		}
+	
+	void CBURTestStepRestore::RestorePassiveBaseDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KResBase, "Restoring passive base data...");
+		Log(LOG_LEVEL2, KResBase);
+		DoSupplyL(EPassiveBaseData);
+		}
+	
+	void CBURTestStepRestore::RestorePassiveIncDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KPassInc, "Restoring passive incremental data...");
+		Log(LOG_LEVEL2, KPassInc);
+		DoSupplyL(EPassiveIncrementalData);
+		}
+	
+	void CBURTestStepRestore::SupplyActiveSnapshotDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KSuppSnap, "Supplying active snapshot data...");
+		Log(LOG_LEVEL2, KSuppSnap);
+		DoSupplyL(EActiveSnapshotData);
+		}
+		
+	void CBURTestStepRestore::RestoreActiveBaseDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KActBase, "Restoring active base data...");
+		Log(LOG_LEVEL2, KActBase);
+		DoSupplyL(EActiveBaseData);
+		}
+		
+	void CBURTestStepRestore::RestoreActiveIncDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KActIncD, "Restoring active incremental data...");
+		Log(LOG_LEVEL2, KActIncD);
+		DoSupplyL(EActiveIncrementalData);
+		}
+		
+	void CBURTestStepRestore::RestoreSystemBaseDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		GeneratePIDTransferTypesL(iTransferTypes, ESystemData);
+		// go through each of them and check if we have snapshot to supply
+		if (iTransferTypes.Count())
+			{
+			_LIT(KSysBase, "Restoring system base data...");
+			Log(LOG_LEVEL2, KSysBase);
+			SupplyDataL(iTransferTypes);
+			}
+		}
+		
+	void CBURTestStepRestore::SupplySystemSnapshotDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		GeneratePIDTransferTypesL(iTransferTypes, ESystemSnapshotData);
+		// go through each of them and check if we have snapshot to supply
+		if (iTransferTypes.Count())
+			{
+			_LIT(KSysSnap, "Supply System Snapshot Data ...");
+			Log(LOG_LEVEL2, KSysSnap);
+			SupplyDataL(iTransferTypes);
+			}
+		}
+		
+	void CBURTestStepRestore::RestoreJavaMidletL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		GenerateJavaTransferTypesL(iTransferTypes, EJavaMIDlet);
+		if (iTransferTypes.Count())
+			{
+			_LIT(KJMidlet, "Restoring Java Midlets ...");
+			Log(LOG_LEVEL2, KJMidlet);
+			SupplyDataL(iTransferTypes);
+			}
+		}
+	
+	void CBURTestStepRestore::RestoreJavaMidletDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		GenerateJavaTransferTypesL(iTransferTypes, EJavaMIDletData);
+		if (iTransferTypes.Count())
+			{
+			_LIT(KJMidletData, "Restoring Java Midlets Data ...");
+			Log(LOG_LEVEL2, KJMidletData);
+			SupplyDataL(iTransferTypes);
+			}
+		}
+
+	TVerdict CBURTestStepRestore::doTestStepPostambleL()
+		/**
+		@return - TVerdict code
+		Override of base class pure virtual
+		*/
+		{
+		_LIT(KLog, "Number of failures:");
+		LogWithNum(LOG_LEVEL3, KLog, iFailures);
+		if (iFailures)
+			{
+			SetTestStepResult(TVerdict(EFail));
+			}
+		return TestStepResult();
+		}
+		
+
+	} 	// end namespace
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testfws/burtestserver/TestSteps/src/t_teststeprestoreasync.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -0,0 +1,388 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// T_TestStepRestore.cpp
+// 
+//
+
+/**
+ @file
+ @released
+*/
+#include "t_teststeprestoreasync.h"
+
+namespace bur_ts
+	{
+	
+	CBURTestStepRestoreAsync* CBURTestStepRestoreAsync::NewL(CBURTestServer& aTestServer)
+		/**
+		Symbian OS Constructor
+		
+		@internalComponent
+		@released
+		
+		@param aParent - The parent CBURTestServer of this child test step.
+		@return Pointer to a newly created CBURTestStepRestoreAsyncAsync object.
+		*/
+		{
+		CBURTestStepRestoreAsync* self = new (ELeave) CBURTestStepRestoreAsync(aTestServer);
+		CleanupStack::PushL(self);
+		self->ConstructL();
+		CleanupStack::Pop();
+		return self;
+		}
+	
+	CBURTestStepRestoreAsync::CBURTestStepRestoreAsync(CBURTestServer& aTestServer)
+		/**
+		C++ Constructor
+		
+		@internalComponent
+		@released
+		
+		@param aParent - The parent CBURTestServer of this child test step.
+		*/
+		:CBURTestStepBase(aTestServer)
+		{}
+	
+	void CBURTestStepRestoreAsync::ConstructL()
+		/**
+		Symbian OS 2nd-phase Constructor
+		
+		@internalComponent
+		@released
+		*/
+		{
+		TInt error;
+		
+		// Initialise the drive list to empty:
+		iDriveList.FillZ();
+		
+		iMode = ERestoreMode;
+		
+		User::LeaveIfError(iFs.Connect());
+		
+		// Install an active scheduler for this test step
+		iActiveScheduler = new(ELeave) CActiveScheduler;
+		CActiveScheduler::Install(iActiveScheduler);
+		
+		TRAP(error, iBackupClient = CSBEClient::NewL());
+		if (error != KErrNone)
+			{
+			_LIT(KClientConnection, "SBEClientConn");
+			User::Panic(KClientConnection,error);
+			}
+			
+		_LIT(KBURTRestore, "BURTestServerRestore");
+		User::RenameThread(KBURTRestore);
+		//User::SetCritical(User::ESystemCritical);
+		
+		SetTestStepName(KBURTestRestoreAsync);
+		}
+	
+	CBURTestStepRestoreAsync::~CBURTestStepRestoreAsync()
+		/**
+		C++ Destructor
+		
+		@internalComponent
+		@released
+		*/
+		{
+		}
+
+	TVerdict CBURTestStepRestoreAsync::doTestStepPreambleL()
+		/**
+		Override of base class virtual function
+		
+		@internalComponent
+		@released
+		@return TVerdict code
+		*/
+		{
+		SetTestStepResult(EPass);
+		return TestStepResult();
+		}
+
+	TVerdict CBURTestStepRestoreAsync::doTestStepL()
+		/**
+		Override of base class pure virtual
+		
+		@internalComponent
+		@released
+		@return TVerdict code
+		*/
+		{
+		_LIT(KLog1, "Processing user options...");
+		Log(LOG_LEVEL2, KLog1);
+		ProcessUserOptionsL();
+		
+		TBURPartType type = EBURRestoreFull;
+			
+		iStorageManager->ReadDataOwnersFromDiskL(iDataOwners);
+		
+		CheckValidRegistrationL();	
+			
+		if (iIsPartial)
+			{
+			_LIT(KLog2, "Preparing for PARTIAL restore...");
+			Log(LOG_LEVEL2, KLog2);
+			PrepareForPartialBURL();
+			SetSIDListForPartialL();
+			type = EBURRestorePartial;
+			}
+		else
+			{
+			_LIT(KLog3, "Preparing for FULL restore...");
+			Log(LOG_LEVEL2, KLog3);
+			}
+			
+		// Set restore mode:
+		_LIT(KLog4, "Setting restore mode...");
+		Log(LOG_LEVEL2, KLog4);
+		TRAPD(burmode, SetBURModeAsyncL(type, iBackupIncType));
+		if (burmode != KErrNone)
+			{
+			_LIT(KLog5, "Error setting restore Mode ");
+			LogWithNum(LOG_LEVEL3, KLog5, burmode);
+			}
+		
+		//SupplyRegistrationDataL();
+		
+		// system data
+		SupplySystemSnapshotDataL();
+		RestoreSystemBaseDataL();
+		
+		RestoreJavaMidletL();
+			
+		// confirm system files restored 
+		CBURActiveObject* active = CBURActiveObject::NewL();
+		CleanupStack::PushL(active);
+		iBackupClient->AllSystemFilesRestoredL(active->iStatus);
+		active->StartL();
+		User::LeaveIfError(active->Error());
+		CleanupStack::PopAndDestroy(active);
+		
+		/** Restore data according to user preferences */
+		if (iBackupIncType == EBackupIncrement)
+			{
+			IncrementalRestoreL();
+			}
+		else
+			{
+			BaseRestoreL();
+			}
+			
+		Log(LOG_LEVEL2, _L("Setting backup mode to Normal ..."));
+		TRAPD(err2,SetBURModeAsyncL(EBURNormal, ENoBackup));
+		if (err2 != KErrNone)
+			{
+			_LIT(KBURError, "Error setting Backup mode ");
+			LogWithNum(LOG_LEVEL3, KBURError, err2);
+			}
+		
+		return TestStepResult();
+		}
+	
+	void CBURTestStepRestoreAsync::BaseRestoreL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		RestoreJavaMidletDataL();
+		
+		// passive
+		SupplyPassiveSnapshotDataL();
+		RestorePassiveBaseDataL();
+		
+		//active
+		SupplyActiveSnapshotDataL();
+		RestoreActiveBaseDataL();
+		}
+	
+	void CBURTestStepRestoreAsync::IncrementalRestoreL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		RestoreJavaMidletDataL();
+		
+		// passive
+		SupplyPassiveSnapshotDataL();
+		RestorePassiveBaseDataL();
+		RestorePassiveIncDataL();
+		
+		
+		//active
+		SupplyActiveSnapshotDataL();
+		RestoreActiveBaseDataL();
+		RestoreActiveIncDataL();
+		}
+		
+	
+	void CBURTestStepRestoreAsync::SupplyRegistrationDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KRes, "Supplying registration data...");
+		Log(LOG_LEVEL2, KRes);
+		DoSupplyL(ERegistrationData);
+		}
+	
+	void CBURTestStepRestoreAsync::SupplyPassiveSnapshotDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KSupp, "Supplying passive snapshot data...");
+		Log(LOG_LEVEL2, KSupp);
+		DoSupplyL(EPassiveSnapshotData);	
+		}
+	
+	void CBURTestStepRestoreAsync::RestorePassiveBaseDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KResBase, "Restoring passive base data...");
+		Log(LOG_LEVEL2, KResBase);
+		DoSupplyL(EPassiveBaseData);
+		}
+	
+	void CBURTestStepRestoreAsync::RestorePassiveIncDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KPassInc, "Restoring passive incremental data...");
+		Log(LOG_LEVEL2, KPassInc);
+		DoSupplyL(EPassiveIncrementalData);
+		}
+	
+	void CBURTestStepRestoreAsync::SupplyActiveSnapshotDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KSuppSnap, "Supplying active snapshot data...");
+		Log(LOG_LEVEL2, KSuppSnap);
+		DoSupplyL(EActiveSnapshotData);
+		}
+		
+	void CBURTestStepRestoreAsync::RestoreActiveBaseDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KActBase, "Restoring active base data...");
+		Log(LOG_LEVEL2, KActBase);
+		DoSupplyL(EActiveBaseData);
+		}
+		
+	void CBURTestStepRestoreAsync::RestoreActiveIncDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		_LIT(KActIncD, "Restoring active incremental data...");
+		Log(LOG_LEVEL2, KActIncD);
+		DoSupplyL(EActiveIncrementalData);
+		}
+		
+	void CBURTestStepRestoreAsync::RestoreSystemBaseDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		GeneratePIDTransferTypesL(iTransferTypes, ESystemData);
+		// go through each of them and check if we have snapshot to supply
+		if (iTransferTypes.Count())
+			{
+			_LIT(KSysBase, "Restoring system base data...");
+			Log(LOG_LEVEL2, KSysBase);
+			SupplyDataL(iTransferTypes);
+			}
+		}
+		
+	void CBURTestStepRestoreAsync::SupplySystemSnapshotDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		GeneratePIDTransferTypesL(iTransferTypes, ESystemSnapshotData);
+		// go through each of them and check if we have snapshot to supply
+		if (iTransferTypes.Count())
+			{
+			_LIT(KSysSnap, "Supply System Snapshot Data ...");
+			Log(LOG_LEVEL2, KSysSnap);
+			SupplyDataL(iTransferTypes);
+			}
+		}
+		
+	void CBURTestStepRestoreAsync::RestoreJavaMidletL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		GenerateJavaTransferTypesL(iTransferTypes, EJavaMIDlet);
+		if (iTransferTypes.Count())
+			{
+			_LIT(KJMidlet, "Restoring Java Midlets ...");
+			Log(LOG_LEVEL2, KJMidlet);
+			SupplyDataL(iTransferTypes);
+			}
+		}
+	
+	void CBURTestStepRestoreAsync::RestoreJavaMidletDataL()
+		/**
+		@internalComponent
+		@released
+		*/
+		{
+		GenerateJavaTransferTypesL(iTransferTypes, EJavaMIDletData);
+		if (iTransferTypes.Count())
+			{
+			_LIT(KJMidletData, "Restoring Java Midlets Data ...");
+			Log(LOG_LEVEL2, KJMidletData);
+			SupplyDataL(iTransferTypes);
+			}
+		}
+
+	TVerdict CBURTestStepRestoreAsync::doTestStepPostambleL()
+		/**
+		@return - TVerdict code
+		Override of base class pure virtual
+		*/
+		{
+		_LIT(KLog, "Number of failures:");
+		LogWithNum(LOG_LEVEL3, KLog, iFailures);
+		if (iFailures)
+			{
+			SetTestStepResult(TVerdict(EFail));
+			}
+		return TestStepResult();
+		}
+		
+
+	} 	// end namespace
--- a/testfws/stif/Logger/src/StifLogger.cpp	Fri Sep 17 08:39:50 2010 +0300
+++ b/testfws/stif/Logger/src/StifLogger.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -485,12 +485,30 @@
                         ( aLoggerSettings.iHardwarePath.Length() -1 ), 1 );
                     }
                 }
-            // Removes drive letter if given and appends implemented path 
-            TParse parse;
-            parse.Set( aTestPath, NULL, NULL );
-            // Path() return value starts with '\'
-            newPath.Append( parse.Path() );
-            aTestPath = newPath;
+            ret = aTestPath.LocateReverse(92);
+                        // Is '\' character founded
+                             
+           if (ret != KErrNotFound)
+                {
+                // Is '\' last character
+                if (ret == (aTestPath.Length() - 1))
+                     {
+                     // delete last '\'
+                     aTestPath.Delete((aTestPath.Length()- 1), 1);
+                     }
+                }
+             ret = aTestPath.LocateReverse('\\');
+               
+             //cut logger specyfic directory (like: \\Demomodule)
+                           
+             aTestPath = aTestPath.Right(aTestPath.Length()-ret);
+                     
+             // patch must end with '\'
+             aTestPath.Append('\\');
+                       
+             // create path by combining path form .ini file with test module name
+             newPath.Append(aTestPath);                                             
+             aTestPath = newPath;
             }
         if( aLoggerSettings.iIsDefined.iHwFormat )
             {
@@ -529,11 +547,28 @@
                         ( aLoggerSettings.iEmulatorPath.Length() -1 ), 1 );
                     }
                 }
-            // Removes drive letter if given and appends implemented path
-            TParse parse;
-            parse.Set( aTestPath, NULL, NULL );
-            // Path() return value starts with '\'
-            newPath.Append( parse.Path() );
+            
+                ret = aTestPath.LocateReverse(92);
+                        // Is '\' character founded
+                             
+                       if (ret != KErrNotFound)
+                            {
+                            // Is '\' last character
+                            if (ret == (aTestPath.Length() - 1))
+                                {
+                                // delete last '\'
+                                aTestPath.Delete((aTestPath.Length()- 1), 1);
+                                }
+                            }
+            ret = aTestPath.LocateReverse('\\');
+                       
+            //cut logger specyfic directory (like: \\Demomodule)      
+            aTestPath = aTestPath.Right(aTestPath.Length()-ret);                       
+            // patch must end with '\'
+            aTestPath.Append('\\'); 
+               
+            // create path by combining path form .ini file with test module name
+            newPath.Append(aTestPath);                                                          
             aTestPath = newPath;
             }
         if( aLoggerSettings.iIsDefined.iFormat )
--- a/testfws/stif/Parser/src/StifFileParser.cpp	Fri Sep 17 08:39:50 2010 +0300
+++ b/testfws/stif/Parser/src/StifFileParser.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -592,7 +592,7 @@
 	CleanupStack::PushL(withoutCommentsBuf);
 	TPtr withoutCommentsBufPtr(withoutCommentsBuf->Des());
 
-	HBufC* endOfLine = HBufC::NewL(2);  //After reading a line it contains 0D0A or 0A or null (how readed line is ended)
+	HBufC* endOfLine = HBufC::NewL(8);  //After reading a line it contains 0D0A or 0A or null (how readed line is ended)
 	CleanupStack::PushL(endOfLine);
 	TPtr endOfLinePtr(endOfLine->Des());
 
--- a/testfws/stif/StifKernelTestClassBase/src/StifKernelTestClassBase.cpp	Fri Sep 17 08:39:50 2010 +0300
+++ b/testfws/stif/StifKernelTestClassBase/src/StifKernelTestClassBase.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -168,8 +168,6 @@
             TStifRunMethodInfo methodInfo;
             TPckg<TStifRunMethodInfo> methodInfoPckg( methodInfo );
 
-            TInt err = KErrNone;
-                                                          
             ret = Kern::ThreadDesRead( iThread, a1, methodInfoPckg, 0, KChunkShiftBy0 );
             if( ret != KErrNone )
                 {
@@ -183,13 +181,7 @@
             // seems to allow leaves (L in the end of the name), it really doesn't!
             ret = RunMethodL( methodInfo.iMethodName, methodInfo.iMethodParams );                                           
                                      
-            if( err != KErrNone )
-                {
-                methodInfo.iResult = err;
-                methodInfo.iMethodResultDes.Copy( _L("RunMethodL leave: ") );
-                methodInfo.iMethodResultDes.AppendNum( err );
-                }
-            else if( ret != KErrNone )
+            if( ret != KErrNone )
                 {
                 methodInfo.iResult = ret;
                 methodInfo.iMethodResultDes.Copy( _L("RunMethodL returned error: ") );
--- a/testfws/stif/StifTFwIf/src/UIStore.cpp	Fri Sep 17 08:39:50 2010 +0300
+++ b/testfws/stif/StifTFwIf/src/UIStore.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -2119,7 +2119,7 @@
         CleanupClosePushL(file);
         
         RBuf buffer;
-        buffer.Create(256);
+        buffer.CreateL(256);
         CleanupClosePushL(buffer);
         
         // Saving
@@ -2227,7 +2227,7 @@
 
         //Search for line
         RBuf buffer;
-        buffer.Create(256);
+        buffer.CreateL(256);
         CleanupClosePushL(buffer);
 
         //Prepare file
@@ -2256,7 +2256,7 @@
             // Position was found. Just update that line (save index of last 
             // started test case)
             RBuf8 b;
-            b.Create(40);
+            b.CreateL(40);
             CleanupClosePushL(b);
 
             b.Copy(KUIStoreLastStartedCaseIndex);
@@ -2351,7 +2351,7 @@
         {
         // Create 8-bit buffer
         RBuf8 buf;
-        buf.Create(buffer.Length());
+        buf.CreateL(buffer.Length());
         CleanupClosePushL(buf);
     
         buf.Copy(buffer);
--- a/testfws/stif/TestScripter/src/TestScripter.cpp	Fri Sep 17 08:39:50 2010 +0300
+++ b/testfws/stif/TestScripter/src/TestScripter.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -1751,7 +1751,7 @@
 void CTestRunner::RunL()
     {
     __TRACEFUNC();
-    __TRACE( KMessage, (_L("CTestRunner::RunL: [%d] "), iStatus.Int() ));
+	__TRACE( KMessage, (_L("CTestRunner::RunL: [%d] "), iStatus.Int() ));
      
     // Check if we need to Pause test case again  
     if( iStatus == KErrNone && iRemainingTimeValue > 0 )
@@ -5111,7 +5111,11 @@
     TPtrC params;
     
     User::LeaveIfError( aItem.GetNextString( method ) );
-    aItem.Remainder( params );
+    TInt ret = aItem.Remainder( params );
+	if ( ret != KErrNone )
+		{
+		RDebug::Print( _L("No parameters given in test class method call") );
+		}
     
     TInt result;
     TMethodResultDes resultDes;
@@ -5126,7 +5130,7 @@
     TPtr8 par8 = myBuf2->Des();   
     par8.Copy( params );
     
-    TInt ret =  iTestClass.RunMethod( met8, par8, result, resultDes );
+    ret =  iTestClass.RunMethod( met8, par8, result, resultDes );
 
     delete myBuf1;
     delete myBuf2;
--- a/testfws/stif/TestServer/inc/TestServer.h	Fri Sep 17 08:39:50 2010 +0300
+++ b/testfws/stif/TestServer/inc/TestServer.h	Mon Oct 04 02:58:21 2010 +0300
@@ -1586,7 +1586,7 @@
 * Check is module TestScripter. Does parsing and returns new module name and
 * error codes(Needed operations when creating server sessions to TestScripter).
 */
-TInt CheckModuleName( TFileName aModuleName, TFileName& aNewModuleName );
+TInt CheckModuleName( const TFileName& aModuleName, TFileName& aNewModuleName );
 
 /**
 * Remove optional index appended to module name.
--- a/testfws/stif/TestServer/src/TestExecutionThread.cpp	Fri Sep 17 08:39:50 2010 +0300
+++ b/testfws/stif/TestServer/src/TestExecutionThread.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -2655,7 +2655,7 @@
 -------------------------------------------------------------------------------
 */
 TInt CTestThreadContainer::HandleMeasurementProcess( 
-            CSTIFTestMeasurement::TStifMeasurementStruct aSTIFMeasurementInfo )
+            const CSTIFTestMeasurement::TStifMeasurementStruct& aSTIFMeasurementInfo )
     {
     // Get access to test measurement stuff
 
--- a/testfws/stif/TestServer/src/TestModuleContainer.cpp	Fri Sep 17 08:39:50 2010 +0300
+++ b/testfws/stif/TestServer/src/TestModuleContainer.cpp	Mon Oct 04 02:58:21 2010 +0300
@@ -2272,7 +2272,7 @@
 
 -------------------------------------------------------------------------------
 */
-TInt CheckModuleName( TFileName aModuleName, TFileName& aNewModuleName )
+TInt CheckModuleName( const TFileName& aModuleName, TFileName& aNewModuleName )
     {
 //--PYTHON-- old code has been replaced with the new one
 /*
--- a/testfws/stif/group/ReleaseNote.txt	Fri Sep 17 08:39:50 2010 +0300
+++ b/testfws/stif/group/ReleaseNote.txt	Mon Oct 04 02:58:21 2010 +0300
@@ -1,5 +1,5 @@
 ========================================================================
-RELEASE NOTE FOR STIF - STIF_201028 (7.3.37)
+RELEASE NOTE FOR STIF - STIF_201036 (7.3.39)
 SUPPORTING SERIES 60 3.0 ->
 ========================================================================
 
--- a/testfws/stif/inc/TestThreadContainer.h	Fri Sep 17 08:39:50 2010 +0300
+++ b/testfws/stif/inc/TestThreadContainer.h	Mon Oct 04 02:58:21 2010 +0300
@@ -213,7 +213,7 @@
         * to TestServer space.
         */ 
         virtual TInt HandleMeasurementProcess(
-                    CSTIFTestMeasurement::TStifMeasurementStruct aSTIFMeasurementInfo );
+                    const CSTIFTestMeasurement::TStifMeasurementStruct& aSTIFMeasurementInfo );
 
         /**
         * Completes a command request.
--- a/testfws/stif/inc/version.h	Fri Sep 17 08:39:50 2010 +0300
+++ b/testfws/stif/inc/version.h	Mon Oct 04 02:58:21 2010 +0300
@@ -20,9 +20,9 @@
 
 #define STIF_MAJOR_VERSION 7
 #define STIF_MINOR_VERSION 3
-#define STIF_BUILD_VERSION 37
+#define STIF_BUILD_VERSION 39
 
-#define STIF_REL_DATE "13th July 2010"
+#define STIF_REL_DATE "07th Sep 2010"
 
 #define TO_UNICODE(text) _L(text) 
 
--- a/testfws/stif/rom/Stif.iby	Fri Sep 17 08:39:50 2010 +0300
+++ b/testfws/stif/rom/Stif.iby	Mon Oct 04 02:58:21 2010 +0300
@@ -18,30 +18,30 @@
 #ifndef __STIF_IBY__
 #define __STIF_IBY__
 
-file=ABI_DIR\BUILD_DIR\stiftestengine.dll            SHARED_LIB_DIR\stiftestengine.dll
-file=ABI_DIR\BUILD_DIR\stiftestserver.dll            SHARED_LIB_DIR\stiftestserver.dll
-file=ABI_DIR\BUILD_DIR\stiftestinterface.dll         SHARED_LIB_DIR\stiftestinterface.dll
-file=ABI_DIR\BUILD_DIR\consoleui.exe                 SHARED_LIB_DIR\consoleui.exe
-file=ABI_DIR\BUILD_DIR\testcombiner.dll              SHARED_LIB_DIR\testcombiner.dll
-file=ABI_DIR\BUILD_DIR\TestServerStarter.exe         SHARED_LIB_DIR\TestServerStarter.exe
-file=ABI_DIR\BUILD_DIR\demomodule.dll                SHARED_LIB_DIR\demomodule.dll
-file=ABI_DIR\BUILD_DIR\atsinterface.exe              SHARED_LIB_DIR\atsinterface.exe
-file=ABI_DIR\BUILD_DIR\atslogger.dll                 SHARED_LIB_DIR\atslogger.dll
-file=ABI_DIR\BUILD_DIR\testscripter.dll              SHARED_LIB_DIR\testscripter.dll
-file=ABI_DIR\BUILD_DIR\stiftfwif.dll                 SHARED_LIB_DIR\stiftfwif.dll
-file=ABI_DIR\BUILD_DIR\suevent.dll                   SHARED_LIB_DIR\suevent.dll
+file=ABI_DIR/BUILD_DIR/StifTestEngine.dll            SHARED_LIB_DIR/StifTestEngine.dll
+file=ABI_DIR/BUILD_DIR/StifTestServer.dll            SHARED_LIB_DIR/StifTestServer.dll
+file=ABI_DIR/BUILD_DIR/StifTestInterface.dll         SHARED_LIB_DIR/StifTestInterface.dll
+file=ABI_DIR/BUILD_DIR/ConsoleUI.exe                 SHARED_LIB_DIR/ConsoleUI.exe
+file=ABI_DIR/BUILD_DIR/testcombiner.dll              SHARED_LIB_DIR/testcombiner.dll
+file=ABI_DIR/BUILD_DIR/TestServerStarter.exe         SHARED_LIB_DIR/TestServerStarter.exe
+file=ABI_DIR/BUILD_DIR/Demomodule.dll                SHARED_LIB_DIR/Demomodule.dll
+file=ABI_DIR/BUILD_DIR/ATSInterface.exe              SHARED_LIB_DIR/ATSInterface.exe
+file=ABI_DIR/BUILD_DIR/atslogger.dll                 SHARED_LIB_DIR/atslogger.dll
+file=ABI_DIR/BUILD_DIR/testscripter.dll              SHARED_LIB_DIR/testscripter.dll
+file=ABI_DIR/BUILD_DIR/StifTFwIf.dll                 SHARED_LIB_DIR/StifTFwIf.dll
+file=ABI_DIR/BUILD_DIR/SUEvent.dll                   SHARED_LIB_DIR/SUEvent.dll
 
 // Touchconsoleui is a component that allows to work with touch screen devices in console mode.
 // It should be use only swith environments that do not supports S60 graphical user interface
 
-//file=ABI_DIR\BUILD_DIR\touchconsoleui.exe            SHARED_LIB_DIR\touchconsoleui.exe
+//file=ABI_DIR/BUILD_DIR/TouchConsoleUI.exe            SHARED_LIB_DIR/TouchConsoleUI.exe
 
-data=\epoc32\data\z\system\data\TestFramework.ini    testframework\TestFramework.ini
+data=EPOCROOT##epoc32/data/z/system/data/TestFramework.ini    testframework/TestFramework.ini
 
 
 #if defined(__S60_)
-// Note: before creating image, copy Stif_31_Stub.sis from \stif\sis\ to \epoc32\data\Z\system\install\
-data=ZSYSTEM\install\Stif_31_Stub.sis    System\Install\Stif_31_Stub.sis
+// Note: before creating image, copy Stif_31_Stub.sis from /stif/sis/ to /epoc32/data/Z/system/install/
+data=ZSYSTEM/install/Stif_31_Stub.SIS    System/Install/Stif_31_Stub.SIS
 #endif
 
 
--- a/testfws/stif/rom/Stif_rom.iby	Fri Sep 17 08:39:50 2010 +0300
+++ b/testfws/stif/rom/Stif_rom.iby	Mon Oct 04 02:58:21 2010 +0300
@@ -20,7 +20,7 @@
 
 #if defined(__S60_)
 // For kernel testing support, uncomment the following line
-device[VARID]=ABI_DIR\BUILD_DIR\StifKernelTestClassBase.dll  SHARED_LIB_DIR\StifKernelTestClassBase.dll
+device[VARID]=ABI_DIR/BUILD_DIR/StifKernelTestClassBase.dll  SHARED_LIB_DIR/StifKernelTestClassBase.dll
 #endif
 
 #endif
Binary file testfws/stif/sis/Stif_31.sis has changed